增加修改轮询功能,修复添加轮询不更新轮询列表的BUG
This commit is contained in:
parent
e65352d757
commit
2511d6ff9b
|
@ -1,3 +1,4 @@
|
||||||
|
import { PollingEntity } from "./../entities/PollingEntity";
|
||||||
import ReconnectingWebSocket from "reconnecting-websocket";
|
import ReconnectingWebSocket from "reconnecting-websocket";
|
||||||
import NormalWindowRequestEntity from "src/entities/NormalWindowRequestEntity";
|
import NormalWindowRequestEntity from "src/entities/NormalWindowRequestEntity";
|
||||||
import { PlanEntity } from "src/entities/PlanEntity";
|
import { PlanEntity } from "src/entities/PlanEntity";
|
||||||
|
@ -375,6 +376,30 @@ export default class ClientConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async addPolling(
|
||||||
|
group_uuid: string,
|
||||||
|
name: string,
|
||||||
|
datas: StringKeyValueEntity[]
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
return await this.doRpc<Protocol.AddPollingResponseEntity>(
|
||||||
|
new Protocol.AddPollingRequestEntity(0, group_uuid, name, datas, "")
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async editPolling(entity: PollingEntity) {
|
||||||
|
try {
|
||||||
|
return await this.doRpc<Protocol.EditPollingResponseEntity>(
|
||||||
|
new Protocol.EditPollingRequestEntity(0, entity)
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async deletePolling(uuid: string) {
|
public async deletePolling(uuid: string) {
|
||||||
try {
|
try {
|
||||||
return await this.doRpc<Protocol.DeletePollingResponseEntity>(
|
return await this.doRpc<Protocol.DeletePollingResponseEntity>(
|
||||||
|
@ -745,10 +770,11 @@ export default class ClientConnection {
|
||||||
|
|
||||||
public async setPollingData(
|
public async setPollingData(
|
||||||
window_id: number,
|
window_id: number,
|
||||||
|
name: string,
|
||||||
datas?: StringKeyValueEntity[]
|
datas?: StringKeyValueEntity[]
|
||||||
) {
|
) {
|
||||||
return await this.doRpc<Protocol.SetPollingDataResponseEntity>(
|
return await this.doRpc<Protocol.SetPollingDataResponseEntity>(
|
||||||
new Protocol.SetPollingDataRequestEntity(window_id, datas)
|
new Protocol.SetPollingDataRequestEntity(window_id, name, datas)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -288,7 +288,7 @@ export default class RemoteDataExangeProcesser {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Protocol.Commands.kRpcAddPollingGroup:
|
case Protocol.Commands.kRpcAddPolling:
|
||||||
{
|
{
|
||||||
const temp = JSON.parse(
|
const temp = JSON.parse(
|
||||||
notify.data
|
notify.data
|
||||||
|
|
|
@ -40,6 +40,23 @@
|
||||||
|
|
||||||
<q-card-section style="max-height: 70vh; width: 50vw" class="scroll">
|
<q-card-section style="max-height: 70vh; width: 50vw" class="scroll">
|
||||||
<q-list>
|
<q-list>
|
||||||
|
<q-item>
|
||||||
|
<q-item-section avatar>
|
||||||
|
<div class="text-h6 q-pb-md">
|
||||||
|
{{ $t("polling name") }}:
|
||||||
|
</div></q-item-section
|
||||||
|
>
|
||||||
|
<q-item-section
|
||||||
|
><q-input
|
||||||
|
v-model="polling_name"
|
||||||
|
lazy-rules
|
||||||
|
:placeholder="$t('please input polling name')"
|
||||||
|
:rules="[
|
||||||
|
(val) =>
|
||||||
|
(val && val.length > 0) || $t('Please type something'),
|
||||||
|
]"
|
||||||
|
/></q-item-section>
|
||||||
|
</q-item>
|
||||||
<q-item>
|
<q-item>
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
<q-table
|
<q-table
|
||||||
|
@ -194,6 +211,7 @@ export default defineComponent({
|
||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
let datas: Ref<StringKeyValueEntity[]> = ref([]);
|
let datas: Ref<StringKeyValueEntity[]> = ref([]);
|
||||||
let signals = ref(GlobalData.getInstance().signal_source);
|
let signals = ref(GlobalData.getInstance().signal_source);
|
||||||
|
let polling_name = ref("");
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -228,10 +246,11 @@ export default defineComponent({
|
||||||
show_context_menu,
|
show_context_menu,
|
||||||
target_dom,
|
target_dom,
|
||||||
signals,
|
signals,
|
||||||
|
polling_name,
|
||||||
loga(a: any) {
|
loga(a: any) {
|
||||||
console.log(a);
|
console.log(a);
|
||||||
},
|
},
|
||||||
showDialog(options: StringKeyValueEntity[] | null) {
|
showDialog(name: string, options: StringKeyValueEntity[] | null) {
|
||||||
show_dialog.value = true;
|
show_dialog.value = true;
|
||||||
if (options) {
|
if (options) {
|
||||||
datas.value = [];
|
datas.value = [];
|
||||||
|
@ -239,8 +258,9 @@ export default defineComponent({
|
||||||
datas.value.push(item);
|
datas.value.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
polling_name.value = name ?? $t.t("new polling");
|
||||||
},
|
},
|
||||||
showDialogAsync(options: StringKeyValueEntity[] | null) {
|
showDialogAsync(name: string, options: StringKeyValueEntity[] | null) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (_resolve) {
|
if (_resolve) {
|
||||||
_resolve();
|
_resolve();
|
||||||
|
@ -255,6 +275,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
signals.value = GlobalData.getInstance().signal_source;
|
signals.value = GlobalData.getInstance().signal_source;
|
||||||
}
|
}
|
||||||
|
polling_name.value = name ?? $t.t("new polling");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
resetData() {
|
resetData() {
|
||||||
|
@ -302,7 +323,10 @@ export default defineComponent({
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
if (_resolve) {
|
if (_resolve) {
|
||||||
_resolve(datas.value);
|
_resolve({
|
||||||
|
name: polling_name.value,
|
||||||
|
datas: datas.value,
|
||||||
|
});
|
||||||
_resolve = null;
|
_resolve = null;
|
||||||
}
|
}
|
||||||
show_dialog.value = false;
|
show_dialog.value = false;
|
||||||
|
|
|
@ -44,31 +44,21 @@
|
||||||
clickable
|
clickable
|
||||||
v-close-popup
|
v-close-popup
|
||||||
v-ripple
|
v-ripple
|
||||||
@click="
|
@click="addPolling($event, prop.node.item_data)"
|
||||||
$refs.polling_dialog.showDialog({
|
|
||||||
type: 1,
|
|
||||||
data: { uuid: prop.node.uuid },
|
|
||||||
})
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<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 polling item") }}</q-item-section>
|
<q-item-section>{{ $t("add polling") }}</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item
|
<q-item
|
||||||
clickable
|
clickable
|
||||||
v-close-popup
|
v-close-popup
|
||||||
v-if="
|
v-if="
|
||||||
prop.node.name == $t('root') ||
|
false &&
|
||||||
(prop.node.is_group && prop.node.item_data)
|
(prop.node.name == $t('root') ||
|
||||||
|
(prop.node.is_group && prop.node.item_data))
|
||||||
"
|
"
|
||||||
v-ripple
|
v-ripple
|
||||||
@click="
|
@click="addPollingGroup($event, prop.node.item_data)"
|
||||||
() =>
|
|
||||||
$refs.group_dialog.showDialog({
|
|
||||||
type: 1,
|
|
||||||
data: prop.node,
|
|
||||||
})
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<q-item-section avatar
|
<q-item-section avatar
|
||||||
><q-icon name="create_new_folder"
|
><q-icon name="create_new_folder"
|
||||||
|
@ -80,17 +70,8 @@
|
||||||
clickable
|
clickable
|
||||||
v-ripple
|
v-ripple
|
||||||
v-close-popup
|
v-close-popup
|
||||||
v-if="prop.node.item_data && false"
|
v-if="!prop.node.is_group && prop.node.item_data"
|
||||||
@click="
|
@click="editPolling($event, prop.node.item_data)"
|
||||||
() =>
|
|
||||||
(prop.node.is_group
|
|
||||||
? $refs.group_dialog
|
|
||||||
: $refs.polling_dialog
|
|
||||||
).showDialog({
|
|
||||||
type: 2,
|
|
||||||
data: prop.node,
|
|
||||||
})
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<q-item-section avatar><q-icon name="edit" /></q-item-section>
|
<q-item-section avatar><q-icon name="edit" /></q-item-section>
|
||||||
<q-item-section>{{ $t("edit") }}</q-item-section>
|
<q-item-section>{{ $t("edit") }}</q-item-section>
|
||||||
|
@ -117,10 +98,11 @@
|
||||||
</q-tree>
|
</q-tree>
|
||||||
</q-scroll-area>
|
</q-scroll-area>
|
||||||
</div>
|
</div>
|
||||||
|
<polling-setting-dialog ref="polling_setting_dialog" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, computed, onMounted, ref, nextTick } from "vue";
|
import { defineComponent, computed, onMounted, ref, Ref, nextTick } from "vue";
|
||||||
import { useStore } from "src/store";
|
import { useStore } from "src/store";
|
||||||
import { Common } from "src/common/Common";
|
import { Common } from "src/common/Common";
|
||||||
import GlobalData from "src/common/GlobalData";
|
import GlobalData from "src/common/GlobalData";
|
||||||
|
@ -129,10 +111,17 @@ import { useI18n } from "vue-i18n";
|
||||||
import EventBus, { EventNamesDefine } from "src/common/EventBus";
|
import EventBus, { EventNamesDefine } from "src/common/EventBus";
|
||||||
import { Protocol } from "src/entities/WSProtocol";
|
import { Protocol } from "src/entities/WSProtocol";
|
||||||
import { NotifyMessage } from "src/common/ClientConnection";
|
import { NotifyMessage } from "src/common/ClientConnection";
|
||||||
import { PollingTreeItemEntity } from "src/entities/PollingEntity";
|
import {
|
||||||
|
PollingEntity,
|
||||||
|
PollingTreeItemEntity,
|
||||||
|
} from "src/entities/PollingEntity";
|
||||||
|
import PollingSettingDialog from "src/components/PollingSettingDialog.vue";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "ComponentPollingTree",
|
name: "ComponentPollingTree",
|
||||||
|
components: {
|
||||||
|
PollingSettingDialog,
|
||||||
|
},
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
const $store = useStore();
|
const $store = useStore();
|
||||||
|
@ -156,6 +145,7 @@ export default defineComponent({
|
||||||
});
|
});
|
||||||
|
|
||||||
const tree: any | null = ref(null);
|
const tree: any | null = ref(null);
|
||||||
|
const polling_setting_dialog: Ref<any> = ref(null);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
while (!tree.value.nodes.length) {
|
while (!tree.value.nodes.length) {
|
||||||
|
@ -166,6 +156,7 @@ export default defineComponent({
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tree,
|
tree,
|
||||||
|
polling_setting_dialog,
|
||||||
tree_nodes,
|
tree_nodes,
|
||||||
content_height,
|
content_height,
|
||||||
loga(a: any) {
|
loga(a: any) {
|
||||||
|
@ -209,6 +200,91 @@ export default defineComponent({
|
||||||
e.dataTransfer.dropEffect = "move";
|
e.dataTransfer.dropEffect = "move";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async editPolling(event: MouseEvent, data: PollingEntity) {
|
||||||
|
if (polling_setting_dialog.value) {
|
||||||
|
const result = await polling_setting_dialog.value.showDialogAsync(
|
||||||
|
data.name,
|
||||||
|
data.polling_signal_sources
|
||||||
|
);
|
||||||
|
if (result) {
|
||||||
|
const { name, datas } = result;
|
||||||
|
if (name && datas) {
|
||||||
|
try {
|
||||||
|
const new_data = new PollingEntity();
|
||||||
|
PollingEntity.copy(new_data, data);
|
||||||
|
new_data.name = name;
|
||||||
|
new_data.polling_signal_sources = datas;
|
||||||
|
const resposne = await GlobalData.getInstance()
|
||||||
|
.getCurrentClient()
|
||||||
|
?.editPolling(new_data);
|
||||||
|
if (resposne) {
|
||||||
|
if (resposne.success) {
|
||||||
|
$q.notify({
|
||||||
|
color: "positive",
|
||||||
|
icon: "done",
|
||||||
|
message: $t.t("edit polling") + $t.t("success") + "!",
|
||||||
|
position: "top",
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$q.notify({
|
||||||
|
color: "negative",
|
||||||
|
icon: "warning",
|
||||||
|
message: $t.t("edit polling") + $t.t("failed") + "!",
|
||||||
|
position: "top",
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async addPolling(event: MouseEvent, data: any) {
|
||||||
|
if (polling_setting_dialog.value) {
|
||||||
|
const result = await polling_setting_dialog.value.showDialogAsync(
|
||||||
|
null,
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
if (result) {
|
||||||
|
const { name, datas } = result;
|
||||||
|
if (name && datas) {
|
||||||
|
try {
|
||||||
|
const resposne = await GlobalData.getInstance()
|
||||||
|
.getCurrentClient()
|
||||||
|
?.addPolling(/* data.uuid */ "", name, datas);
|
||||||
|
if (resposne) {
|
||||||
|
if (resposne.success) {
|
||||||
|
$q.notify({
|
||||||
|
color: "positive",
|
||||||
|
icon: "done",
|
||||||
|
message: $t.t("add polling") + $t.t("success") + "!",
|
||||||
|
position: "top",
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$q.notify({
|
||||||
|
color: "negative",
|
||||||
|
icon: "warning",
|
||||||
|
message: $t.t("add polling") + $t.t("failed") + "!",
|
||||||
|
position: "top",
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
addPollingGroup(event: MouseEvent, data: any) {
|
||||||
|
console.log(data);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1166,6 +1166,60 @@ export namespace Protocol {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class AddPollingRequestEntity extends Protocol.PacketEntity {
|
||||||
|
name: string;
|
||||||
|
group_uuid: string;
|
||||||
|
polling_signal_sources: StringKeyValueEntity[];
|
||||||
|
note: string;
|
||||||
|
constructor(
|
||||||
|
rcp_id?: number,
|
||||||
|
group_uuid?: string,
|
||||||
|
name?: string,
|
||||||
|
polling_signal_sources?: StringKeyValueEntity[],
|
||||||
|
note?: string
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
this.rpc_id = rcp_id ?? 0;
|
||||||
|
this.command = Protocol.Commands.kRpcAddPolling;
|
||||||
|
this.name = name ?? "new pollong";
|
||||||
|
this.group_uuid = group_uuid ?? "";
|
||||||
|
this.polling_signal_sources = Array.isArray(polling_signal_sources)
|
||||||
|
? polling_signal_sources
|
||||||
|
: [];
|
||||||
|
this.note = note ?? "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AddPollingResponseEntity extends Protocol.PacketEntity {
|
||||||
|
success = false;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.command = Protocol.Commands.kRpcAddPolling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class EditPollingRequestEntity extends Protocol.PacketEntity {
|
||||||
|
entity: PollingEntity = new PollingEntity();
|
||||||
|
constructor(rcp_id?: number, entity?: PollingEntity) {
|
||||||
|
super();
|
||||||
|
this.rpc_id = rcp_id ?? 0;
|
||||||
|
this.command = Protocol.Commands.kRpcEditPolling;
|
||||||
|
if (entity) {
|
||||||
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class EditPollingResponseEntity extends Protocol.PacketEntity {
|
||||||
|
success = false;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.command = Protocol.Commands.kRpcEditPolling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class DeletePollingRequestEntity extends Protocol.PacketEntity {
|
export class DeletePollingRequestEntity extends Protocol.PacketEntity {
|
||||||
uuid: string = "";
|
uuid: string = "";
|
||||||
constructor(rcp_id?: number, uuid?: string) {
|
constructor(rcp_id?: number, uuid?: string) {
|
||||||
|
@ -1699,9 +1753,11 @@ export namespace Protocol {
|
||||||
|
|
||||||
export class SetPollingDataRequestEntity extends Protocol.PacketEntity {
|
export class SetPollingDataRequestEntity extends Protocol.PacketEntity {
|
||||||
datas: StringKeyValueEntity[] = [];
|
datas: StringKeyValueEntity[] = [];
|
||||||
|
name: string;
|
||||||
window_id: number = 0;
|
window_id: number = 0;
|
||||||
constructor(
|
constructor(
|
||||||
window_id: number,
|
window_id: number,
|
||||||
|
name: string,
|
||||||
datas?: StringKeyValueEntity[],
|
datas?: StringKeyValueEntity[],
|
||||||
rcp_id?: number
|
rcp_id?: number
|
||||||
) {
|
) {
|
||||||
|
@ -1715,6 +1771,7 @@ export namespace Protocol {
|
||||||
this.datas = datas;
|
this.datas = datas;
|
||||||
}
|
}
|
||||||
this.window_id = window_id;
|
this.window_id = window_id;
|
||||||
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,4 +340,9 @@ export default {
|
||||||
usb7: "USB7",
|
usb7: "USB7",
|
||||||
usb8: "USB8",
|
usb8: "USB8",
|
||||||
polling: "轮询",
|
polling: "轮询",
|
||||||
|
"polling name": "轮询名称",
|
||||||
|
"please input polling name": "请输入轮询名称",
|
||||||
|
"new polling": "新建轮询",
|
||||||
|
"add polling": "添加轮询",
|
||||||
|
"edit polling": "修改轮询",
|
||||||
};
|
};
|
||||||
|
|
|
@ -886,14 +886,21 @@ export default defineComponent({
|
||||||
const polling = GlobalData.getInstance()._pollings.find(
|
const polling = GlobalData.getInstance()._pollings.find(
|
||||||
(element) => element && element.uuid == window.polling_uuid
|
(element) => element && element.uuid == window.polling_uuid
|
||||||
);
|
);
|
||||||
const datas = await polling_setting_dialog.value.showDialogAsync(
|
const signal_source = GlobalData.getInstance().signal_source.find(
|
||||||
|
(element) =>
|
||||||
|
element && element.uuid == window.signal_source_table_uuid
|
||||||
|
);
|
||||||
|
const result = await polling_setting_dialog.value.showDialogAsync(
|
||||||
|
polling ? polling.name : signal_source ? signal_source.name : null,
|
||||||
polling ? polling.polling_signal_sources : []
|
polling ? polling.polling_signal_sources : []
|
||||||
);
|
);
|
||||||
if (datas) {
|
if (result) {
|
||||||
|
const { name, datas } = result;
|
||||||
|
if (name && datas) {
|
||||||
try {
|
try {
|
||||||
const resposne = await GlobalData.getInstance()
|
const resposne = await GlobalData.getInstance()
|
||||||
.getCurrentClient()
|
.getCurrentClient()
|
||||||
?.setPollingData(window_id, datas);
|
?.setPollingData(window_id, name, datas);
|
||||||
if (resposne) {
|
if (resposne) {
|
||||||
if (resposne.success) {
|
if (resposne.success) {
|
||||||
$q.notify({
|
$q.notify({
|
||||||
|
@ -918,6 +925,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -791,7 +791,6 @@ export default store(function (/* { ssrContext } */) {
|
||||||
),
|
),
|
||||||
playload
|
playload
|
||||||
);
|
);
|
||||||
console.log(state.polling_tree);
|
|
||||||
},
|
},
|
||||||
// polling tree end
|
// polling tree end
|
||||||
setDeviceIpAddress(state: StateInterface, playload?: any) {
|
setDeviceIpAddress(state: StateInterface, playload?: any) {
|
||||||
|
|
Loading…
Reference in New Issue