修改模式,轮询编辑框

This commit is contained in:
fangxiang 2022-06-14 17:58:27 +08:00
parent 4851ee1504
commit 081c1a27ee
12 changed files with 978 additions and 923 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "media_player_client", "name": "media_player_client",
"version": "1.4.12", "version": "1.4.13",
"description": "A Quasar Framework app", "description": "A Quasar Framework app",
"productName": "MediaPlayerClient", "productName": "MediaPlayerClient",
"author": "fangxiang <fangxiang@cloudview.work>", "author": "fangxiang <fangxiang@cloudview.work>",
@ -10,7 +10,7 @@
}, },
"dependencies": { "dependencies": {
"@quasar/cli": "^1.3.2", "@quasar/cli": "^1.3.2",
"@quasar/extras": "^1.13.4", "@quasar/extras": "^1.14.0",
"@tinymce/tinymce-vue": "4", "@tinymce/tinymce-vue": "4",
"@types/element-resize-detector": "^1.1.3", "@types/element-resize-detector": "^1.1.3",
"autoprefixer": "^10.4.2", "autoprefixer": "^10.4.2",
@ -18,7 +18,7 @@
"core-js": "^3.21.0", "core-js": "^3.21.0",
"element-resize-detector": "^1.2.4", "element-resize-detector": "^1.2.4",
"qrcode.vue": "^3.3.3", "qrcode.vue": "^3.3.3",
"quasar": "^2.6.2", "quasar": "^2.7.1",
"reconnecting-websocket": "^4.4.0", "reconnecting-websocket": "^4.4.0",
"sortablejs": "^1.15.0", "sortablejs": "^1.15.0",
"to": "^0.2.9", "to": "^0.2.9",

View File

@ -31,6 +31,17 @@ export default defineComponent({
document.title = $t.t("title"); document.title = $t.t("title");
// quasar
try {
{
import("quasar/lang/" + $t.locale.value).then((lang) => {
$q.lang.set(lang.default);
});
}
} catch (e) {
console.log(e);
}
window.onresize = (evt: any) => window.onresize = (evt: any) =>
EventBus.getInstance().emit(EventNamesDefine.WindowResize, evt); EventBus.getInstance().emit(EventNamesDefine.WindowResize, evt);

View File

@ -4,8 +4,6 @@ import { Cookies } from "quasar";
import messages from "src/i18n"; import messages from "src/i18n";
console.log();
let language = Cookies.get("language"); let language = Cookies.get("language");
// 如果 cookie 中没有语言信息,则使用服务器给的语言 // 如果 cookie 中没有语言信息,则使用服务器给的语言

View File

@ -253,7 +253,7 @@ export default defineComponent({
if (item.length > 4) { if (item.length > 4) {
return false; return false;
} }
if (!/^0[xX]?[A-Fa-f0-9]/.test(item)) { if (!/^0[xX][A-Fa-f0-9]{1,2}/.test(item)) {
return false; return false;
} }
} }

View File

@ -9,6 +9,7 @@
<q-item <q-item
class="full-width" class="full-width"
clickable clickable
:disable="!$store.state.power_state"
@dblclick=" @dblclick="
(evt) => { (evt) => {
if (!$store.state.power_state) { if (!$store.state.power_state) {
@ -50,7 +51,7 @@
&nbsp;&nbsp;{{ prop.node.name }} &nbsp;&nbsp;{{ prop.node.name }}
</div> </div>
</q-item-section> </q-item-section>
<q-popup-proxy context-menu> <q-popup-proxy :context-menu="$store.state.power_state">
<q-list> <q-list>
<q-item <q-item
v-if=" v-if="

View File

@ -142,28 +142,11 @@
</template> </template>
<template v-slot:body-cell="props"> <template v-slot:body-cell="props">
<q-td :props="props"> <q-td :props="props">
<div v-if="props.col.name == 'value'"> <div v-if="props.col.name == 'index'">
<div v-if="props.pageIndex % 2"> {{ props.pageIndex + 1 }}
{{ props.value }}{{ $t("s") }}
<q-popup-edit v-model="props.row.value">
<q-input
type="number"
v-model="props.row.value"
:min="min_delay"
dense
autofocus
>
<template v-slot:append>
<span>{{ $t("s") }}</span>
</template>
</q-input>
</q-popup-edit>
</div> </div>
<div v-else> <div v-else-if="props.col.name == 'uuid'" class="fit">
<q-popup-edit <q-popup-edit ref="popup_edit" v-model="props.row.uuid">
ref="popup_edit"
v-model="props.row.value"
>
<q-tree <q-tree
ref="tree" ref="tree"
:nodes="$store.state.mode_tree" :nodes="$store.state.mode_tree"
@ -177,15 +160,13 @@
:clickable="!prop.node.is_group" :clickable="!prop.node.is_group"
@click=" @click="
(evt) => { (evt) => {
props.row.value = props.row.uuid = prop.node.item_data.uuid;
prop.node.item_data.uuid;
$refs.popup_edit.hide(); $refs.popup_edit.hide();
} }
" "
:style="{ :style="{
border: border:
props.row.value == props.value == prop?.node?.item_data?.uuid
prop?.node?.item_data?.uuid
? '1px solid #aacceec2' ? '1px solid #aacceec2'
: 'none', : 'none',
}" }"
@ -220,11 +201,25 @@
</q-popup-edit> </q-popup-edit>
{{ {{
modes.find( modes.find(
(element) => (element) => element && element.uuid == props.value
element && element.uuid == props.row.value
)?.name ?? "" )?.name ?? ""
}} }}
</div> </div>
<div v-else-if="props.col.name == 'delay'">
{{ props.value }}{{ $t("s") }}
<q-popup-edit v-model="props.row.delay">
<q-input
type="number"
v-model="props.row.delay"
:min="min_delay"
dense
autofocus
>
<template v-slot:append>
<span>{{ $t("s") }}</span>
</template>
</q-input>
</q-popup-edit>
</div> </div>
<div v-else> <div v-else>
{{ $t(props.value) }} {{ $t(props.value) }}
@ -393,6 +388,11 @@ import { EWeekDays } from "src/entities/EWeekDays";
const __MIN_DELAY = 10; const __MIN_DELAY = 10;
class TableRow {
uuid = "";
delay = __MIN_DELAY;
}
export default defineComponent({ export default defineComponent({
name: "ComponentPlanDialog", name: "ComponentPlanDialog",
@ -408,22 +408,29 @@ export default defineComponent({
let uuid = ref(""); let uuid = ref("");
const selected: any = ref(null); const selected: any = ref(null);
let loading = ref(false); let loading = ref(false);
let datas: Ref<StringKeyValueEntity[]> = ref([]); let datas: Ref<TableRow[]> = ref([]);
let modes = ref(GlobalData.getInstance().modes); let modes = ref(GlobalData.getInstance().modes);
const columns = [ const columns = [
{ {
align: "left", align: "left",
name: "key", name: "index",
required: true, required: true,
label: $t.t("operator"), label: $t.t("No."),
field: "key",
sortable: false, sortable: false,
}, },
{ {
align: "left", align: "left",
name: "value", name: "uuid",
label: $t.t("operator value"), required: true,
field: "value", label: $t.t("signal source"),
field: "uuid",
sortable: false,
},
{
align: "left",
name: "delay",
label: $t.t("delay"),
field: "delay",
sortable: false, sortable: false,
}, },
]; ];
@ -459,15 +466,26 @@ export default defineComponent({
const requestAddPlan = async () => { const requestAddPlan = async () => {
let entity = new PlanEntity(); let entity = new PlanEntity();
for (let i = 1; i < datas.value.length; i += 2) {
if (parseInt(datas.value[i].value) < __MIN_DELAY) { const __datas: StringKeyValueEntity[] = [];
datas.value[i].value = __MIN_DELAY.toString();
for (const item of datas.value) {
if (item) {
__datas.push({
key: "operator_call_mode",
value: item.uuid,
});
__datas.push({
key: "param_delay",
value: item.delay.toString(),
});
} }
} }
entity.group_uuid = selected.value; entity.group_uuid = selected.value;
entity.uuid = uuid.value; entity.uuid = uuid.value;
entity.name = name.value ?? ""; entity.name = name.value ?? "";
entity.datas = datas.value; entity.datas = __datas;
entity.time_ = time_.value; entity.time_ = time_.value;
entity.timing_cycle = timing_cycle.value == $t.t("enable"); entity.timing_cycle = timing_cycle.value == $t.t("enable");
entity.week_days = EWeekDays.EWeekNone; entity.week_days = EWeekDays.EWeekNone;
@ -497,15 +515,26 @@ export default defineComponent({
const requestEditPlan = async () => { const requestEditPlan = async () => {
let entity = new PlanEntity(); let entity = new PlanEntity();
for (let i = 1; i < datas.value.length; i += 2) {
if (parseInt(datas.value[i].value) < __MIN_DELAY) { const __datas: StringKeyValueEntity[] = [];
datas.value[i].value = __MIN_DELAY.toString();
for (const item of datas.value) {
if (item) {
__datas.push({
key: "operator_call_mode",
value: item.uuid,
});
__datas.push({
key: "param_delay",
value: item.delay.toString(),
});
} }
} }
entity.group_uuid = selected.value; entity.group_uuid = selected.value;
entity.uuid = uuid.value; entity.uuid = uuid.value;
entity.name = name.value ?? ""; entity.name = name.value ?? "";
entity.datas = datas.value; entity.datas = __datas;
entity.time_ = time_.value; entity.time_ = time_.value;
entity.timing_cycle = timing_cycle.value == $t.t("enable"); entity.timing_cycle = timing_cycle.value == $t.t("enable");
entity.week_days = EWeekDays.EWeekNone; entity.week_days = EWeekDays.EWeekNone;
@ -562,6 +591,7 @@ export default defineComponent({
console.log(a); console.log(a);
}, },
showDialog(options: any) { showDialog(options: any) {
let __datas: StringKeyValueEntity[] = [];
if (options) { if (options) {
type.value = options.type ?? 1; type.value = options.type ?? 1;
time_.value = "09:00:00"; time_.value = "09:00:00";
@ -577,39 +607,43 @@ export default defineComponent({
timing_cycle.value = options.data?.item_data?.timing_cycle timing_cycle.value = options.data?.item_data?.timing_cycle
? $t.t("enable") ? $t.t("enable")
: $t.t("disable"); : $t.t("disable");
datas.value = JSON.parse( __datas = JSON.parse(
JSON.stringify(options.data?.item_data?.datas ?? []) JSON.stringify(options.data?.item_data?.datas ?? [])
); );
} else { } else {
name.value = options.data?.name ?? $t.t("new plan 1"); name.value = options.data?.name ?? $t.t("new plan 1");
selected.value = options.data?.uuid ?? null; selected.value = options.data?.uuid ?? null;
uuid.value = options.data?.uuid ?? null; uuid.value = options.data?.uuid ?? null;
datas.value = options.data?.item_data?.datas ?? []; __datas = options.data?.item_data?.datas ?? [];
} }
modes.value = GlobalData.getInstance().modes; modes.value = GlobalData.getInstance().modes;
let temp = []; datas.value = [];
let auto_removed = false;
for ( for (
let i = 0; let i = 0;
i < i < (__datas.length % 2 ? __datas.length - 1 : __datas.length);
(datas.value.length % 2
? datas.value.length - 1
: datas.value.length);
i += 2 i += 2
) { ) {
const item = datas.value[i]; const uuid_item = __datas[i];
const delay_item = __datas[i + 1];
if (item && item.key.startsWith("operator_")) { if (uuid_item && uuid_item.key.startsWith("operator_")) {
const item_value = GlobalData.getInstance().modes.find( const item_value = GlobalData.getInstance().modes.find(
(element) => element && element.uuid == item.value (element) => element && element.uuid == uuid_item.value
); );
const delay = parseInt(delay_item.value);
if (item_value) { if (item_value) {
temp.push(datas.value[i]); datas.value.push({
temp.push(datas.value[i + 1]); uuid: uuid_item.value,
delay: isNaN(delay) ? __MIN_DELAY : delay,
});
}
} else {
auto_removed = true;
} }
} }
} if (auto_removed) {
if (temp.length != datas.value.length) {
$q.notify({ $q.notify({
type: "warning", type: "warning",
message: $t.t("auto delete unknow mode success"), message: $t.t("auto delete unknow mode success"),
@ -617,7 +651,6 @@ export default defineComponent({
timeout: 1500, timeout: 1500,
}); });
} }
datas.value = temp;
// format time // format time
{ {
@ -634,9 +667,9 @@ export default defineComponent({
} }
} }
for (let i = 1; i < datas.value.length; i += 2) { for (const item of datas.value) {
if (parseInt(datas.value[i].value) < __MIN_DELAY) { if (item.delay < __MIN_DELAY) {
datas.value[i].value = __MIN_DELAY.toString(); item.delay = __MIN_DELAY;
} }
} }
@ -665,16 +698,17 @@ export default defineComponent({
treeNodesFilter(node: any, filter: any) { treeNodesFilter(node: any, filter: any) {
return node.is_group; return node.is_group;
}, },
addRow() { addRow(insert_flag: boolean = false) {
datas.value.push({ const item = {
key: "operator_call_mode", uuid: GlobalData.getInstance().modes[0].uuid,
value: GlobalData.getInstance().modes[0].uuid, delay: __MIN_DELAY,
}); };
datas.value.push({ if (insert_flag) {
key: "param_delay", datas.value.splice(current_index + 1, 0, item);
value: __MIN_DELAY.toString(), } else {
}); datas.value.push(item);
}
}, },
onContextMenu( onContextMenu(
evt: PointerEvent, evt: PointerEvent,

View File

@ -9,6 +9,7 @@
<q-item <q-item
class="full-width" class="full-width"
clickable clickable
:disable="!$store.state.power_state"
@dblclick=" @dblclick="
(evt) => !prop.node.is_group && runPlan(prop.node.item_data) (evt) => !prop.node.is_group && runPlan(prop.node.item_data)
" "
@ -30,7 +31,7 @@
{{ prop.node.name }} {{ prop.node.name }}
</div> </div>
</q-item-section> </q-item-section>
<q-popup-proxy context-menu> <q-popup-proxy :context-menu="$store.state.power_state">
<q-list> <q-list>
<q-item <q-item
v-if=" v-if="

View File

@ -78,28 +78,11 @@
</template> </template>
<template v-slot:body-cell="props"> <template v-slot:body-cell="props">
<q-td :props="props"> <q-td :props="props">
<div v-if="props.col.name == 'value'"> <div v-if="props.col.name == 'index'">
<div v-if="props.pageIndex % 2"> {{ props.pageIndex + 1 }}
{{ props.value }}{{ $t("s") }}
<q-popup-edit v-model="props.row.value">
<q-input
type="number"
v-model="props.row.value"
:min="min_delay"
dense
autofocus
>
<template v-slot:append>
<span>{{ $t("s") }}</span>
</template>
</q-input>
</q-popup-edit>
</div> </div>
<div v-else> <div v-else-if="props.col.name == 'uuid'" class="fit">
<q-popup-edit <q-popup-edit ref="popup_edit" v-model="props.row.uuid">
ref="popup_edit"
v-model="props.row.value"
>
<q-tree <q-tree
ref="tree" ref="tree"
:nodes="$store.state.signal_source_tree" :nodes="$store.state.signal_source_tree"
@ -113,13 +96,13 @@
:clickable="!prop.node.is_group" :clickable="!prop.node.is_group"
@click=" @click="
(evt) => { (evt) => {
props.row.value = prop.node.uuid; props.row.uuid = prop.node.uuid;
$refs.popup_edit.hide(); $refs.popup_edit.hide();
} }
" "
:style="{ :style="{
border: border:
props.row.value == prop.node.uuid props.value == prop.node.uuid
? '1px solid #aacceec2' ? '1px solid #aacceec2'
: 'none', : 'none',
}" }"
@ -150,14 +133,27 @@
{{ {{
signals.find( signals.find(
(element) => (element) =>
element && element.uuid == props.row.value element && element.uuid == props.row.uuid
)?.name ?? "" )?.name ?? ""
}} }}
</div> </div>
<div v-else-if="props.col.name == 'delay'">
{{ props.value }}{{ $t("s") }}
<q-popup-edit v-model="props.row.delay">
<q-input
type="number"
v-model="props.row.delay"
:min="min_delay"
dense
autofocus
>
<template v-slot:append>
<span>{{ $t("s") }}</span>
</template>
</q-input>
</q-popup-edit>
</div> </div>
<div v-else> <div v-else>UNKNOW</div>
{{ $t(props.value) }}
</div>
</q-td> </q-td>
</template> </template>
</q-table> </q-table>
@ -173,7 +169,7 @@
flat flat
:label="$t('add row')" :label="$t('add row')"
color="primary" color="primary"
@click="addRow" @click="addRow(false)"
/> />
<q-space /> <q-space />
<q-btn <q-btn
@ -204,7 +200,7 @@
/></q-item-section> /></q-item-section>
<q-item-section>{{ $t("delete row") }}</q-item-section> <q-item-section>{{ $t("delete row") }}</q-item-section>
</q-item> </q-item>
<q-item clickable v-close-popup @click="(evt) => addRow()"> <q-item clickable v-close-popup @click="(evt) => addRow(true)">
<q-item-section avatar><q-icon name="add" /></q-item-section> <q-item-section avatar><q-icon name="add" /></q-item-section>
<q-item-section>{{ $t("add row") }}</q-item-section> <q-item-section>{{ $t("add row") }}</q-item-section>
</q-item> </q-item>
@ -236,6 +232,11 @@ import { Common } from "src/common/Common";
const __MIN_DELAY = 10; const __MIN_DELAY = 10;
class TableRow {
uuid = "";
delay = __MIN_DELAY;
}
export default defineComponent({ export default defineComponent({
name: "ComponentPollingSettingDialog", name: "ComponentPollingSettingDialog",
@ -248,24 +249,31 @@ export default defineComponent({
let show_dialog = ref(false); let show_dialog = ref(false);
let loading = ref(false); let loading = ref(false);
let datas: Ref<StringKeyValueEntity[]> = ref([]); let datas: Ref<TableRow[]> = ref([]);
let signals = ref(GlobalData.getInstance().signal_source); let signals = ref(GlobalData.getInstance().signal_source);
let polling_name = ref(""); let polling_name = ref("");
const columns = [ const columns = [
{ {
align: "left", align: "left",
name: "key", name: "index",
required: true, required: true,
label: $t.t("operator"), label: $t.t("No."),
field: "key",
sortable: false, sortable: false,
}, },
{ {
align: "left", align: "left",
name: "value", name: "uuid",
label: $t.t("operator value"), required: true,
field: "value", label: $t.t("signal source"),
field: "uuid",
sortable: false,
},
{
align: "left",
name: "delay",
label: $t.t("delay"),
field: "delay",
sortable: false, sortable: false,
}, },
]; ];
@ -293,8 +301,18 @@ export default defineComponent({
show_dialog.value = true; show_dialog.value = true;
if (options) { if (options) {
datas.value = []; datas.value = [];
for (const item of options) { if (options.length % 2) {
datas.value.push(item); options.splice(options.length - 1, 1);
}
for (let i = 0; i < options.length; i += 2) {
const item_signal = options[i];
const item_delay = options[i + 1];
if (item_signal && item_delay) {
datas.value.push({
uuid: item_signal.value,
delay: parseInt(item_delay.value),
});
}
} }
} }
polling_name.value = name ?? $t.t("new polling"); polling_name.value = name ?? $t.t("new polling");
@ -306,13 +324,25 @@ export default defineComponent({
_resolve = null; _resolve = null;
} }
_resolve = resolve; _resolve = resolve;
show_dialog.value = true; show_dialog.value = true;
if (options) { if (options) {
datas.value = []; datas.value = [];
for (const item of options) {
datas.value.push(item); for (
let i = 0;
i < (options.length % 2 ? options.length - 1 : options.length);
i += 2
) {
const item_signal = options[i];
const item_delay = options[i + 1];
if (item_signal && item_delay) {
datas.value.push({
uuid: item_signal.value,
delay: parseInt(item_delay.value),
});
}
} }
signals.value = GlobalData.getInstance().signal_source;
} }
polling_name.value = name ?? $t.t("new polling"); polling_name.value = name ?? $t.t("new polling");
}); });
@ -324,16 +354,17 @@ export default defineComponent({
_resolve = null; _resolve = null;
} }
}, },
addRow() { addRow(insert_flag: boolean = false) {
datas.value.push({ const item = {
key: "operator_play_signal_source", uuid: GlobalData.getInstance().signal_source[0].uuid,
value: GlobalData.getInstance().signal_source[0].uuid, delay: __MIN_DELAY,
}); };
if (insert_flag) {
datas.value.splice(current_index + 1, 0, item);
} else {
datas.value.push(item);
}
datas.value.push({
key: "param_delay",
value: __MIN_DELAY.toString(),
});
signals.value = GlobalData.getInstance().signal_source; signals.value = GlobalData.getInstance().signal_source;
}, },
onContextMenu( onContextMenu(
@ -352,19 +383,29 @@ export default defineComponent({
}, },
deleteRow() { deleteRow() {
if (datas.value.length > current_index) { if (datas.value.length > current_index) {
const start = Math.floor(current_index / 2); datas.value.splice(current_index, 1);
if (!isNaN(start)) {
datas.value.splice(start, 2);
}
} }
}, },
async onSubmit() { async onSubmit() {
loading.value = true; loading.value = true;
try { try {
let __datas: StringKeyValueEntity[] = [];
for (const item of datas.value) {
if (item) {
__datas.push({
key: "operator_play_signal_source",
value: item.uuid,
});
__datas.push({
key: "param_delay",
value: item.delay.toString(),
});
}
}
if (_resolve) { if (_resolve) {
_resolve({ _resolve({
name: polling_name.value, name: polling_name.value,
datas: datas.value, datas: __datas,
}); });
_resolve = null; _resolve = null;
} }

View File

@ -8,8 +8,9 @@
<template v-slot:default-header="prop"> <template v-slot:default-header="prop">
<q-item <q-item
class="full-width" class="full-width"
:disable="!$store.state.power_state"
clickable clickable
:draggable="!prop.node.is_group" :draggable="!prop.node.is_group && $store.state.power_state"
@dragstart="(evt) => onDragStart(evt, prop.node)" @dragstart="(evt) => onDragStart(evt, prop.node)"
@dblclick=" @dblclick="
(evt) => (evt) =>
@ -33,7 +34,7 @@
{{ prop.node.name }} {{ prop.node.name }}
</div> </div>
</q-item-section> </q-item-section>
<q-popup-proxy context-menu> <q-popup-proxy :context-menu="$store.state.power_state">
<q-list> <q-list>
<q-item <q-item
v-if=" v-if="

View File

@ -5,7 +5,8 @@
<q-item <q-item
class="full-width" class="full-width"
clickable clickable
:draggable="!prop.node.is_group" :disable="!$store.state.power_state"
:draggable="!prop.node.is_group && $store.state.power_state"
@dragstart="(evt) => onDragStart(evt, prop.node)" @dragstart="(evt) => onDragStart(evt, prop.node)"
@click=" @click="
$store.commit( $store.commit(
@ -39,7 +40,10 @@
{{ prop.node.name }} {{ prop.node.name }}
</div> </div>
</q-item-section> </q-item-section>
<q-popup-proxy context-menu @before-show="updateContextMenu"> <q-popup-proxy
:context-menu="$store.state.power_state"
@before-show="updateContextMenu"
>
<q-list> <q-list>
<q-item <q-item
clickable clickable

View File

@ -576,4 +576,5 @@ export default {
"the start time should not exceed the current time, and the target time should not be less than the current time": "the start time should not exceed the current time, and the target time should not be less than the current time":
"正计时的时候起始时间不要超过当前时间,倒计时的时候目标时间不要小于当前时间", "正计时的时候起始时间不要超过当前时间,倒计时的时候目标时间不要小于当前时间",
"pos x": "X坐标", "pos x": "X坐标",
"No.": "序号",
}; };

1331
yarn.lock

File diff suppressed because it is too large Load Diff