修复部分数据不更新的BUG

This commit is contained in:
fangxiang 2021-08-26 11:19:31 +08:00
parent d122d437ca
commit f0699229a5
7 changed files with 329 additions and 328 deletions

View File

@ -121,10 +121,7 @@ import { Common } from "src/common/Common";
import GlobalData from "src/common/GlobalData";
import { useQuasar } from "quasar";
import { useI18n } from "vue-i18n";
import EventBus, { EventNamesDefine } from "src/common/EventBus";
import { Protocol } from "src/entities/WSProtocol";
import { ModeEntity } from "src/entities/ModeEntity";
import { NotifyMessage } from "src/common/ClientConnection";
export default defineComponent({
name: "PageModeTree",
@ -150,98 +147,6 @@ export default defineComponent({
tree.value?.setExpanded("", true);
});
EventBus.getInstance().on(
EventNamesDefine.NotifyMessage,
(response: NotifyMessage) => {
if (response) {
switch (response.packet.command) {
case Protocol.Commands.kRpcAddMode:
{
const temp = JSON.parse(
response.data
) as Protocol.ModeAddNotifyEntity;
if (temp) {
GlobalData.getInstance().modes.push(temp.mode);
$store.commit("addModeTreeItem", {
parent: temp.mode.group_uuid,
is_group: false,
item_data: temp.mode,
});
}
}
break;
case Protocol.Commands.kRpcDeleteMode:
{
const temp = JSON.parse(
response.data
) as Protocol.ModeDeleteNotifyEntity;
console.log(temp);
if (temp) {
$store.commit("deleteModeTreeItem", {
is_group: false,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditMode:
{
const temp = JSON.parse(
response.data
) as Protocol.ModeEditNotifyEntity;
if (temp) {
$store.commit("setModeTreeItem", {
is_group: false,
item_data: temp.mode,
});
}
}
break;
case Protocol.Commands.kRpcAddModeGroup:
{
const temp = JSON.parse(
response.data
) as Protocol.ModeGroupAddNotifyEntity;
if (temp) {
$store.commit("addModeTreeItem", {
parent: temp.mode_group.parent_uuid,
is_group: true,
item_data: temp.mode_group,
});
}
}
break;
case Protocol.Commands.kRpcDeleteModeGroup:
{
const temp = JSON.parse(
response.data
) as Protocol.ModeGroupDeleteNotifyEntity;
if (temp) {
$store.commit("deleteModeTreeItem", {
is_group: true,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditModeGroup:
{
const temp = JSON.parse(
response.data
) as Protocol.ModeGroupEditNotifyEntity;
if (temp) {
$store.commit("setModeTreeItem", {
is_group: true,
item_data: temp.mode_group,
});
}
}
break;
}
}
}
);
return {
tree,
tree_nodes,

View File

@ -358,10 +358,8 @@ export default defineComponent({
},
showDialog(options: any) {
if (options) {
console.log(options);
type.value = options.type ?? 1;
if (type.value == 2) {
console.log(options);
name.value = options.data?.name ?? null;
selected.value = options.data?.item_data?.group_uuid ?? null;
uuid.value = options.data?.item_data?.uuid ?? null;
@ -375,26 +373,37 @@ export default defineComponent({
datas.value = options.data?.item_data?.datas ?? [];
}
modes.value = GlobalData.getInstance().modes;
const datas_length = datas.value.length;
datas.value = datas.value.filter((item) => {
if (item) {
if (item.key == "operator") {
return GlobalData.getInstance().modes.find(
let temp = [];
for (
let i = 0;
i <
(datas.value.length % 2
? datas.value.length - 1
: datas.value.length);
i += 2
) {
const item = datas.value[i];
console.log(item);
if (item && item.key.startsWith("operator_")) {
const item_value = GlobalData.getInstance().modes.find(
(element) => element && element.uuid == item.value
);
if (item_value) {
temp.push(datas.value[i]);
temp.push(datas.value[i + 1]);
}
return true;
}
return false;
});
if (datas_length != datas.value.length) {
}
if (temp.length != datas.value.length) {
$q.notify({
type: "success",
type: "warning",
message: $t.t("auto delete unknow mode success"),
position: "top",
timeout: 1000,
});
}
datas.value = temp;
}
show_dialog.value = true;
},

View File

@ -150,97 +150,6 @@ export default defineComponent({
tree.value?.setExpanded("", true);
});
EventBus.getInstance().on(
EventNamesDefine.NotifyMessage,
(response: NotifyMessage) => {
if (response) {
switch (response.packet.command) {
case Protocol.Commands.kRpcAddPlan:
{
const temp = JSON.parse(
response.data
) as Protocol.PlanAddNotifyEntity;
if (temp) {
GlobalData.getInstance().plans.push(temp.plan);
$store.commit("addPlanTreeItem", {
parent: temp.plan.group_uuid,
is_group: false,
item_data: temp.plan,
});
}
}
break;
case Protocol.Commands.kRpcDeletePlan:
{
const temp = JSON.parse(
response.data
) as Protocol.PlanDeleteNotifyEntity;
if (temp) {
$store.commit("deletePlanTreeItem", {
is_group: false,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditPlan:
{
const temp = JSON.parse(
response.data
) as Protocol.PlanEditNotifyEntity;
if (temp) {
$store.commit("setPlanTreeItem", {
is_group: false,
item_data: temp.plan,
});
}
}
break;
case Protocol.Commands.kRpcAddPlanGroup:
{
const temp = JSON.parse(
response.data
) as Protocol.PlanGroupAddNotifyEntity;
if (temp) {
$store.commit("addPlanTreeItem", {
parent: temp.plan_group.parent_uuid,
is_group: true,
item_data: temp.plan_group,
});
}
}
break;
case Protocol.Commands.kRpcDeletePlanGroup:
{
const temp = JSON.parse(
response.data
) as Protocol.PlanGroupDeleteNotifyEntity;
if (temp) {
$store.commit("deletePlanTreeItem", {
is_group: true,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditPlanGroup:
{
const temp = JSON.parse(
response.data
) as Protocol.PlanGroupEditNotifyEntity;
if (temp) {
$store.commit("setPlanTreeItem", {
is_group: true,
item_data: temp.plan_group,
});
}
}
break;
}
}
}
);
return {
tree,
tree_nodes,

View File

@ -159,99 +159,6 @@ export default defineComponent({
tree.value?.setExpanded("", true);
});
EventBus.getInstance().on(
EventNamesDefine.NotifyMessage,
(response: NotifyMessage) => {
if (response) {
switch (response.packet.command) {
case Protocol.Commands.kRpcAddSignalSource:
{
const temp = JSON.parse(
response.data
) as Protocol.SignalSourceAddNotifyEntity;
if (temp) {
GlobalData.getInstance().signal_source.push(
temp.signal_source
);
$store.commit("addSignalSourceTreeItem", {
parent: temp.signal_source.group_uuid,
is_group: false,
item_data: temp.signal_source,
});
}
}
break;
case Protocol.Commands.kRpcDeleteSignalSource:
{
const temp = JSON.parse(
response.data
) as Protocol.SignalSourceDeleteNotifyEntity;
if (temp) {
$store.commit("deleteSignalSourceTreeItem", {
is_group: false,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditSignalSource:
{
const temp = JSON.parse(
response.data
) as Protocol.SignalSourceEditNotifyEntity;
if (temp) {
$store.commit("setSignalSourceTreeItem", {
is_group: false,
item_data: temp.signal_source,
});
}
}
break;
case Protocol.Commands.kRpcAddSignalSourceGroup:
{
const temp = JSON.parse(
response.data
) as Protocol.SignalSourceGroupAddNotifyEntity;
if (temp) {
$store.commit("addSignalSourceTreeItem", {
parent: temp.signal_source_group.parent_uuid,
is_group: true,
item_data: temp.signal_source_group,
});
}
}
break;
case Protocol.Commands.kRpcDeleteSignalSourceGroup:
{
const temp = JSON.parse(
response.data
) as Protocol.SignalSourceGroupDeleteNotifyEntity;
if (temp) {
$store.commit("deleteSignalSourceTreeItem", {
is_group: true,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditSignalSourceGroup:
{
const temp = JSON.parse(
response.data
) as Protocol.SignalSourceGroupEditNotifyEntity;
if (temp) {
$store.commit("setSignalSourceTreeItem", {
is_group: true,
item_data: temp.signal_source_group,
});
}
}
break;
}
}
}
);
return {
tree,
tree_nodes,

View File

@ -10,13 +10,16 @@ import WallPage from "src/pages/WallPage.vue";
import EventBus, { EventNamesDefine } from "src/common/EventBus";
import { useQuasar } from "quasar";
import { useI18n } from "vue-i18n";
import { useStore } from "src/store";
import { NotifyMessage } from "src/common/ClientConnection";
import { Protocol } from "src/entities/WSProtocol";
import GlobalData from "src/common/GlobalData";
export default defineComponent({
name: "PageIndex",
components: { WallPage },
setup() {
const $store = useStore();
const $q = useQuasar();
const $t = useI18n();
@ -33,13 +36,36 @@ export default defineComponent({
EventBus.getInstance().on(
EventNamesDefine.NotifyMessage,
(response: NotifyMessage) => {
(notify: NotifyMessage) => {
try {
switch (response.packet.command) {
switch (notify.packet.command) {
case Protocol.Commands.kSetApplicationConfig:
{
let temp = JSON.parse(
notify.data
) as Protocol.ApplicationConfigChangeNotifyEntity;
if (temp) {
let global_data = GlobalData.getInstance();
if (global_data && global_data.applicationConfig) {
(<any>GlobalData.getInstance().applicationConfig)[
temp.key
] = temp.value;
$store.commit(
"setWallCol",
global_data.applicationConfig.wall_col
);
$store.commit(
"setWallRow",
global_data.applicationConfig.wall_row
);
}
}
}
break;
case Protocol.Commands.kCurrentRunningPlanStateChanged:
{
const temp = JSON.parse(
response.data
notify.data
) as Protocol.PlanRunningStateChangeNotifyEntity;
if (temp && temp.plan) {
$q.notify({
@ -57,6 +83,276 @@ export default defineComponent({
}
}
break;
case Protocol.Commands.kRpcAddMode:
{
const temp = JSON.parse(
notify.data
) as Protocol.ModeAddNotifyEntity;
if (temp) {
GlobalData.getInstance().modes.push(temp.mode);
$store.commit("addModeTreeItem", {
parent: temp.mode.group_uuid,
is_group: false,
item_data: temp.mode,
});
}
}
break;
case Protocol.Commands.kRpcDeleteMode:
{
const temp = JSON.parse(
notify.data
) as Protocol.ModeDeleteNotifyEntity;
if (temp) {
let pos = GlobalData.getInstance().modes.findIndex(
(element) => element && element.uuid == temp.uuid
);
if (pos != -1) {
GlobalData.getInstance().modes.splice(pos, 1);
}
$store.commit("deleteModeTreeItem", {
is_group: false,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditMode:
{
const temp = JSON.parse(
notify.data
) as Protocol.ModeEditNotifyEntity;
if (temp) {
let pos = GlobalData.getInstance().modes.findIndex(
(element) => element && element.uuid == temp.mode.uuid
);
if (pos != -1) {
GlobalData.getInstance().modes[pos] = temp.mode;
}
$store.commit("setModeTreeItem", {
is_group: false,
item_data: temp.mode,
});
}
}
break;
case Protocol.Commands.kRpcAddModeGroup:
{
const temp = JSON.parse(
notify.data
) as Protocol.ModeGroupAddNotifyEntity;
if (temp) {
$store.commit("addModeTreeItem", {
parent: temp.mode_group.parent_uuid,
is_group: true,
item_data: temp.mode_group,
});
}
}
break;
case Protocol.Commands.kRpcDeleteModeGroup:
{
const temp = JSON.parse(
notify.data
) as Protocol.ModeGroupDeleteNotifyEntity;
if (temp) {
$store.commit("deleteModeTreeItem", {
is_group: true,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditModeGroup:
{
const temp = JSON.parse(
notify.data
) as Protocol.ModeGroupEditNotifyEntity;
if (temp) {
$store.commit("setModeTreeItem", {
is_group: true,
item_data: temp.mode_group,
});
}
}
break;
case Protocol.Commands.kRpcAddPlan:
{
const temp = JSON.parse(
notify.data
) as Protocol.PlanAddNotifyEntity;
if (temp) {
GlobalData.getInstance().plans.push(temp.plan);
$store.commit("addPlanTreeItem", {
parent: temp.plan.group_uuid,
is_group: false,
item_data: temp.plan,
});
}
}
break;
case Protocol.Commands.kRpcDeletePlan:
{
const temp = JSON.parse(
notify.data
) as Protocol.PlanDeleteNotifyEntity;
if (temp) {
let pos = GlobalData.getInstance().plans.findIndex(
(element) => element && element.uuid == temp.uuid
);
if (pos != -1) {
GlobalData.getInstance().plans.splice(pos, 1);
}
$store.commit("deletePlanTreeItem", {
is_group: false,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditPlan:
{
const temp = JSON.parse(
notify.data
) as Protocol.PlanEditNotifyEntity;
if (temp) {
let pos = GlobalData.getInstance().plans.findIndex(
(element) => element && element.uuid == temp.plan.uuid
);
if (pos != -1) {
GlobalData.getInstance().plans[pos] = temp.plan;
}
$store.commit("setPlanTreeItem", {
is_group: false,
item_data: temp.plan,
});
}
}
break;
case Protocol.Commands.kRpcAddPlanGroup:
{
const temp = JSON.parse(
notify.data
) as Protocol.PlanGroupAddNotifyEntity;
if (temp) {
$store.commit("addPlanTreeItem", {
parent: temp.plan_group.parent_uuid,
is_group: true,
item_data: temp.plan_group,
});
}
}
break;
case Protocol.Commands.kRpcDeletePlanGroup:
{
const temp = JSON.parse(
notify.data
) as Protocol.PlanGroupDeleteNotifyEntity;
if (temp) {
$store.commit("deletePlanTreeItem", {
is_group: true,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditPlanGroup:
{
const temp = JSON.parse(
notify.data
) as Protocol.PlanGroupEditNotifyEntity;
if (temp) {
$store.commit("setPlanTreeItem", {
is_group: true,
item_data: temp.plan_group,
});
}
}
break;
case Protocol.Commands.kRpcAddSignalSource:
{
const temp = JSON.parse(
notify.data
) as Protocol.SignalSourceAddNotifyEntity;
if (temp) {
GlobalData.getInstance().signal_source.push(
temp.signal_source
);
$store.commit("addSignalSourceTreeItem", {
parent: temp.signal_source.group_uuid,
is_group: false,
item_data: temp.signal_source,
});
}
}
break;
case Protocol.Commands.kRpcDeleteSignalSource:
{
const temp = JSON.parse(
notify.data
) as Protocol.SignalSourceDeleteNotifyEntity;
if (temp) {
$store.commit("deleteSignalSourceTreeItem", {
is_group: false,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditSignalSource:
{
const temp = JSON.parse(
notify.data
) as Protocol.SignalSourceEditNotifyEntity;
if (temp) {
$store.commit("setSignalSourceTreeItem", {
is_group: false,
item_data: temp.signal_source,
});
}
}
break;
case Protocol.Commands.kRpcAddSignalSourceGroup:
{
const temp = JSON.parse(
notify.data
) as Protocol.SignalSourceGroupAddNotifyEntity;
if (temp) {
$store.commit("addSignalSourceTreeItem", {
parent: temp.signal_source_group.parent_uuid,
is_group: true,
item_data: temp.signal_source_group,
});
}
}
break;
case Protocol.Commands.kRpcDeleteSignalSourceGroup:
{
const temp = JSON.parse(
notify.data
) as Protocol.SignalSourceGroupDeleteNotifyEntity;
if (temp) {
$store.commit("deleteSignalSourceTreeItem", {
is_group: true,
uuid: temp.uuid,
});
}
}
break;
case Protocol.Commands.kRpcEditSignalSourceGroup:
{
const temp = JSON.parse(
notify.data
) as Protocol.SignalSourceGroupEditNotifyEntity;
if (temp) {
$store.commit("setSignalSourceTreeItem", {
is_group: true,
item_data: temp.signal_source_group,
});
}
}
break;
}
} catch {}
}

View File

@ -156,29 +156,6 @@ export default defineComponent({
}
}
break;
case Protocol.Commands.kSetApplicationConfig:
{
let temp = JSON.parse(
notify.data
) as Protocol.ApplicationConfigChangeNotifyEntity;
if (temp) {
let global_data = GlobalData.getInstance();
if (global_data && global_data.applicationConfig) {
(<any>GlobalData.getInstance().applicationConfig)[
temp.key
] = temp.value;
$store.commit(
"setWallCol",
global_data.applicationConfig.wall_col
);
$store.commit(
"setWallRow",
global_data.applicationConfig.wall_row
);
}
}
}
break;
}
}
}

View File

@ -306,12 +306,12 @@ export default defineComponent({
EventBus.getInstance().on(
EventNamesDefine.NotifyMessage,
(response: NotifyMessage) => {
(notify: NotifyMessage) => {
try {
switch (response.packet.command) {
switch (notify.packet.command) {
case Protocol.Commands.kCloseWindow:
{
const temp = JSON.parse(response.data);
const temp = JSON.parse(notify.data);
if (temp && temp.window_id) {
$store.commit("removeWindow", {
window_id: temp.window_id,
@ -321,7 +321,7 @@ export default defineComponent({
break;
case Protocol.Commands.kMoveWindow:
{
const temp = JSON.parse(response.data);
const temp = JSON.parse(notify.data);
if (temp && temp.window_id) {
const window = $store.state.windows.find(
(item) => item.window_id == temp.window_id
@ -345,7 +345,7 @@ export default defineComponent({
break;
case Protocol.Commands.kResizeWindow:
{
const temp = JSON.parse(response.data);
const temp = JSON.parse(notify.data);
if (temp && temp.window_id) {
const window = $store.state.windows.find(
(item) => item.window_id == temp.window_id
@ -369,9 +369,7 @@ export default defineComponent({
break;
case Protocol.Commands.kOpenWindow:
{
const temp = JSON.parse(
response.data
) as WindowOpenNotifyEntity;
const temp = JSON.parse(notify.data) as WindowOpenNotifyEntity;
if (temp) {
$store.commit("pushWindow", temp);
}
@ -380,7 +378,7 @@ export default defineComponent({
case Protocol.Commands.kWindowOtherStateChanged:
{
const temp = JSON.parse(
response.data
notify.data
) as WindowOtherStateChangeNotifyEntity;
if (temp && temp.window_id) {
const window = $store.state.windows.find(