添加轮询、预案内容时自动弹窗列表框

This commit is contained in:
fangxiang 2022-07-29 11:00:11 +08:00
parent 7ff2e48b84
commit cf98b9ba08
3 changed files with 93 additions and 10 deletions

View File

@ -0,0 +1,37 @@
export interface ShowProupParam {
refs: any;
ref_name: string;
delay: number;
count: number;
max_count: number;
}
export class TableAddRowHelper {
private timer_handler: any = null;
showProup(param: ShowProupParam) {
if (this.timer_handler) {
clearTimeout(this.timer_handler);
this.timer_handler = null;
}
this.show_proup(param);
}
private show_proup = (param: ShowProupParam) => {
this.timer_handler = setTimeout(() => {
param.count += param.delay;
if (param.count > param.max_count) {
console.log("errrrrrrrrr");
return;
}
if (param.refs) {
const dom = param.refs[param.ref_name];
if (dom) {
dom.show();
} else {
this.show_proup(param);
}
}
}, param.delay);
};
}

View File

@ -146,7 +146,10 @@
{{ 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-popup-edit
:ref="'popup_edit' + props.pageIndex"
v-model="props.row.uuid"
>
<q-tree
ref="tree"
:nodes="$store.state.mode_tree"
@ -161,7 +164,9 @@
@click="
(evt) => {
props.row.uuid = prop.node.item_data.uuid;
$refs.popup_edit.hide();
$refs[
'popup_edit' + props.pageIndex
]?.hide();
}
"
:style="{
@ -343,7 +348,7 @@
no-caps
:label="$t('add row')"
color="primary"
@click="addRow"
@click="addRow(false)"
/>
<q-space />
<q-btn
@ -376,7 +381,12 @@
/></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
v-if="false"
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>
@ -406,14 +416,18 @@ import { useI18n } from "vue-i18n";
import { StringKeyValueEntity } from "src/entities/StringKeyValueEntity";
import { PlanEntity } from "src/entities/PlanEntity";
import { EWeekDays } from "src/entities/EWeekDays";
import { TableAddRowHelper } from "src/common/TableAddRowHelper";
const __MIN_DELAY = 10;
const __DEFAULT_DELAY = 60;
class TableRow {
uuid = "";
delay = __MIN_DELAY;
}
const table_add_row_helper = new TableAddRowHelper();
export default defineComponent({
name: "ComponentPlanDialog",
@ -729,13 +743,19 @@ export default defineComponent({
addRow(insert_flag: boolean = false) {
const item = {
uuid: GlobalData.getInstance().modes[0].uuid,
delay: __MIN_DELAY,
delay: __DEFAULT_DELAY,
};
if (insert_flag) {
datas.value.splice(current_index + 1, 0, item);
} else {
datas.value.push(item);
table_add_row_helper.showProup({
refs: (<any>this).$refs,
ref_name: "popup_edit" + (datas.value.length - 1),
delay: 5,
count: 0,
max_count: 5000,
});
}
},
onContextMenu(

View File

@ -72,6 +72,7 @@
:rows-per-page-options="[0]"
:virtual-scroll-sticky-size-start="48"
@row-contextmenu="onContextMenu"
ref="polling_table"
>
<template v-slot:loading>
<q-inner-loading showing color="primary" />
@ -82,7 +83,10 @@
{{ 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-popup-edit
:ref="'popup_edit' + props.pageIndex"
v-model="props.row.uuid"
>
<q-tree
ref="tree"
:nodes="$store.state.signal_source_tree"
@ -97,7 +101,9 @@
@click="
(evt) => {
props.row.uuid = prop.node.uuid;
$refs.popup_edit.hide();
$refs[
'popup_edit' + props.pageIndex
]?.hide();
}
"
:style="{
@ -221,7 +227,12 @@
/></q-item-section>
<q-item-section>{{ $t("delete row") }}</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="(evt) => addRow(true)">
<q-item
v-if="false"
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>
@ -250,14 +261,18 @@ import { useQuasar } from "quasar";
import { useI18n } from "vue-i18n";
import { StringKeyValueEntity } from "src/entities/StringKeyValueEntity";
import { Common } from "src/common/Common";
import { TableAddRowHelper } from "src/common/TableAddRowHelper";
const __MIN_DELAY = 10;
const __DEFAULT_DELAY = 60;
class TableRow {
uuid = "";
delay = __MIN_DELAY;
}
const table_add_row_helper = new TableAddRowHelper();
export default defineComponent({
name: "ComponentPollingSettingDialog",
@ -269,6 +284,8 @@ export default defineComponent({
const min_delay = ref(__MIN_DELAY);
let show_dialog = ref(false);
const polling_table: Ref<any> = ref(null);
let loading = ref(false);
let datas: Ref<TableRow[]> = ref([]);
let signals = ref(GlobalData.getInstance().signal_source);
@ -307,6 +324,7 @@ export default defineComponent({
return {
show_dialog,
polling_table,
min_delay,
loading,
datas,
@ -380,12 +398,20 @@ export default defineComponent({
addRow(insert_flag: boolean = false) {
const item = {
uuid: GlobalData.getInstance().signal_source[0].uuid,
delay: __MIN_DELAY,
delay: __DEFAULT_DELAY,
};
if (insert_flag) {
datas.value.splice(current_index + 1, 0, item);
(<any>this).$refs["popup_edit" + current_index]?.show();
} else {
datas.value.push(item);
table_add_row_helper.showProup({
refs: (<any>this).$refs,
ref_name: "popup_edit" + (datas.value.length - 1),
delay: 5,
count: 0,
max_count: 5000,
});
}
signals.value = GlobalData.getInstance().signal_source;