修改模式,轮询编辑框

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

View File

@ -31,6 +31,17 @@ export default defineComponent({
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) =>
EventBus.getInstance().emit(EventNamesDefine.WindowResize, evt);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -78,86 +78,82 @@
</template>
<template v-slot:body-cell="props">
<q-td :props="props">
<div v-if="props.col.name == 'value'">
<div v-if="props.pageIndex % 2">
{{ 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 v-else>
<q-popup-edit
ref="popup_edit"
v-model="props.row.value"
<div v-if="props.col.name == 'index'">
{{ props.pageIndex + 1 }}
</div>
<div v-else-if="props.col.name == 'uuid'" class="fit">
<q-popup-edit ref="popup_edit" v-model="props.row.uuid">
<q-tree
ref="tree"
:nodes="$store.state.signal_source_tree"
node-key="uuid"
labelKey="name"
default-expand-all
>
<q-tree
ref="tree"
:nodes="$store.state.signal_source_tree"
node-key="uuid"
labelKey="name"
default-expand-all
>
<template v-slot:default-header="prop">
<q-item
class="full-width"
:clickable="!prop.node.is_group"
@click="
(evt) => {
props.row.value = prop.node.uuid;
$refs.popup_edit.hide();
}
"
:style="{
border:
props.row.value == prop.node.uuid
? '1px solid #aacceec2'
: 'none',
}"
>
<q-item-section avatar>
<q-icon
:name="
prop.node.is_group
? 'img:source_icon/group.png'
: getItemIcon(
prop.node.item_data?.window_type
)
"
color="orange"
size="28px"
class="q-mr-sm"
/>
</q-item-section>
<q-item-section>
<div class="text-weight-bold text-primary">
{{ prop.node.name }}
</div>
</q-item-section>
</q-item>
</template>
</q-tree>
</q-popup-edit>
{{
signals.find(
(element) =>
element && element.uuid == props.row.value
)?.name ?? ""
}}
</div>
<template v-slot:default-header="prop">
<q-item
class="full-width"
:clickable="!prop.node.is_group"
@click="
(evt) => {
props.row.uuid = prop.node.uuid;
$refs.popup_edit.hide();
}
"
:style="{
border:
props.value == prop.node.uuid
? '1px solid #aacceec2'
: 'none',
}"
>
<q-item-section avatar>
<q-icon
:name="
prop.node.is_group
? 'img:source_icon/group.png'
: getItemIcon(
prop.node.item_data?.window_type
)
"
color="orange"
size="28px"
class="q-mr-sm"
/>
</q-item-section>
<q-item-section>
<div class="text-weight-bold text-primary">
{{ prop.node.name }}
</div>
</q-item-section>
</q-item>
</template>
</q-tree>
</q-popup-edit>
{{
signals.find(
(element) =>
element && element.uuid == props.row.uuid
)?.name ?? ""
}}
</div>
<div v-else>
{{ $t(props.value) }}
<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 v-else>UNKNOW</div>
</q-td>
</template>
</q-table>
@ -173,7 +169,7 @@
flat
:label="$t('add row')"
color="primary"
@click="addRow"
@click="addRow(false)"
/>
<q-space />
<q-btn
@ -204,7 +200,7 @@
/></q-item-section>
<q-item-section>{{ $t("delete row") }}</q-item-section>
</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>{{ $t("add row") }}</q-item-section>
</q-item>
@ -236,6 +232,11 @@ import { Common } from "src/common/Common";
const __MIN_DELAY = 10;
class TableRow {
uuid = "";
delay = __MIN_DELAY;
}
export default defineComponent({
name: "ComponentPollingSettingDialog",
@ -248,24 +249,31 @@ export default defineComponent({
let show_dialog = ref(false);
let loading = ref(false);
let datas: Ref<StringKeyValueEntity[]> = ref([]);
let datas: Ref<TableRow[]> = ref([]);
let signals = ref(GlobalData.getInstance().signal_source);
let polling_name = ref("");
const columns = [
{
align: "left",
name: "key",
name: "index",
required: true,
label: $t.t("operator"),
field: "key",
label: $t.t("No."),
sortable: false,
},
{
align: "left",
name: "value",
label: $t.t("operator value"),
field: "value",
name: "uuid",
required: true,
label: $t.t("signal source"),
field: "uuid",
sortable: false,
},
{
align: "left",
name: "delay",
label: $t.t("delay"),
field: "delay",
sortable: false,
},
];
@ -293,8 +301,18 @@ export default defineComponent({
show_dialog.value = true;
if (options) {
datas.value = [];
for (const item of options) {
datas.value.push(item);
if (options.length % 2) {
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");
@ -306,13 +324,25 @@ export default defineComponent({
_resolve = null;
}
_resolve = resolve;
show_dialog.value = true;
if (options) {
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");
});
@ -324,16 +354,17 @@ export default defineComponent({
_resolve = null;
}
},
addRow() {
datas.value.push({
key: "operator_play_signal_source",
value: GlobalData.getInstance().signal_source[0].uuid,
});
addRow(insert_flag: boolean = false) {
const item = {
uuid: 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;
},
onContextMenu(
@ -352,19 +383,29 @@ export default defineComponent({
},
deleteRow() {
if (datas.value.length > current_index) {
const start = Math.floor(current_index / 2);
if (!isNaN(start)) {
datas.value.splice(start, 2);
}
datas.value.splice(current_index, 1);
}
},
async onSubmit() {
loading.value = true;
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) {
_resolve({
name: polling_name.value,
datas: datas.value,
datas: __datas,
});
_resolve = null;
}

View File

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

View File

@ -5,7 +5,8 @@
<q-item
class="full-width"
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)"
@click="
$store.commit(
@ -39,7 +40,10 @@
{{ prop.node.name }}
</div>
</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-item
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":
"正计时的时候起始时间不要超过当前时间,倒计时的时候目标时间不要小于当前时间",
"pos x": "X坐标",
"No.": "序号",
};

1331
yarn.lock

File diff suppressed because it is too large Load Diff