非编辑数据调整
This commit is contained in:
parent
04caf21f2f
commit
e8eb0f5ef7
@ -154,3 +154,55 @@ export function handlerCommonTypeData(data: sync_data_message.UpdataData) {
|
||||
return new IscsTextData(iscsGraphicData.IscsText.deserialize(data.data));
|
||||
}
|
||||
}
|
||||
|
||||
export function handlerNoEditCommonData(
|
||||
data: sync_data_message.UpdataData,
|
||||
storage: ICommonStorage,
|
||||
operationType: string
|
||||
) {
|
||||
switch (data.type) {
|
||||
case Rect.Type:
|
||||
const rectData = iscsGraphicData.Rect.deserialize(data.data);
|
||||
// syncNoEditData(operationType, rectData, storage.rects);
|
||||
if (operationType === 'graphic-create') {
|
||||
storage.rects.push(rectData);
|
||||
} else if (operationType === 'graphic-delete') {
|
||||
const index = storage.rects.findIndex(
|
||||
(ele) => ele.common.id === rectData.common.id
|
||||
);
|
||||
storage.rects.splice(index, 1);
|
||||
} else if (operationType === 'graphic-drag') {
|
||||
const index = storage.rects.findIndex(
|
||||
(ele) => ele.common.id === rectData.common.id
|
||||
);
|
||||
storage.rects[index] = rectData;
|
||||
}
|
||||
console.log(rectData, storage);
|
||||
break;
|
||||
case Arrow.Type:
|
||||
const arrowData = iscsGraphicData.Arrow.deserialize(data.data);
|
||||
syncNoEditData(operationType, arrowData, storage.arrows);
|
||||
break;
|
||||
case TextContent.Type:
|
||||
const iscsTextData = iscsGraphicData.IscsText.deserialize(data.data);
|
||||
syncNoEditData(operationType, iscsTextData, storage.iscsTexts);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
export function syncNoEditData(
|
||||
operationType: string,
|
||||
data: any,
|
||||
dataArray: any[]
|
||||
) {
|
||||
console.log(data, dataArray, '====');
|
||||
if (operationType === 'graphic-create') {
|
||||
dataArray.push(data);
|
||||
} else if (operationType === 'graphic-delete') {
|
||||
const index = dataArray.findIndex((ele) => ele.id === data.id);
|
||||
dataArray.splice(index, 1);
|
||||
} else if (operationType === 'graphic-drag') {
|
||||
const index = dataArray.findIndex((ele) => ele.id === data.id);
|
||||
dataArray[index] = data;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import {
|
||||
loadCommonDrawDatas,
|
||||
saveCommonDrawDatas,
|
||||
saveDrawToServer,
|
||||
handlerNoEditCommonData,
|
||||
} from './commonApp';
|
||||
import { CCTVButtonData } from './graphics/CCTV/CCTVButtonInteraction';
|
||||
import { CCTVButtonDraw } from 'src/graphics/CCTV/cctvButton/CCTVButtonDrawAssistant';
|
||||
@ -88,7 +89,7 @@ function handleSubscribe(app: IDrawApp) {
|
||||
destination: `/rtss_simulation/draft/iscs/${drawStore.draftId}`,
|
||||
messageHandle: (message: Uint8Array) => {
|
||||
const syncData = sync_data_message.SyncData.deserialize(message);
|
||||
console.log(syncData.userId, useAuthStore().userId, 'userID');
|
||||
console.log(syncData.userId, useAuthStore().userId, 'userID', syncData);
|
||||
if (syncData.userId === useAuthStore().userId) {
|
||||
console.info('当前用户操作');
|
||||
return;
|
||||
@ -120,6 +121,51 @@ function handleSubscribe(app: IDrawApp) {
|
||||
app.deleteGraphics(...graphics);
|
||||
}
|
||||
} else {
|
||||
storage = iscsGraphicData.IscsGraphicStorage.deserialize(
|
||||
toUint8Array(base64)
|
||||
);
|
||||
if (syncData.submenu === '火灾报警平面图') {
|
||||
for (let i = 0; i < storage.fasPlatformAlarmStorages.length; i++) {
|
||||
const fasPlatformAlarm = storage.fasPlatformAlarmStorages[i];
|
||||
if (fasPlatformAlarm.stationName == syncData.station) {
|
||||
// canvasProperty = fasPlatformAlarm.canvas;
|
||||
// datas = loadCommonDrawDatas(fasPlatformAlarm);
|
||||
// break;
|
||||
syncData.datas.forEach((data) => {
|
||||
handlerNoEditCommonData(
|
||||
data,
|
||||
fasPlatformAlarm,
|
||||
syncData.operationType
|
||||
);
|
||||
});
|
||||
storage.fasPlatformAlarmStorages[i] = fasPlatformAlarm;
|
||||
console.log(fasPlatformAlarm, 'fasPlatformAlarm');
|
||||
}
|
||||
}
|
||||
} else if (syncData.submenu === '监控布局图') {
|
||||
for (
|
||||
let i = 0;
|
||||
i < storage.cctvOfStationControlStorages.length;
|
||||
i++
|
||||
) {
|
||||
const ctvOfStationControl = storage.cctvOfStationControlStorages[i];
|
||||
if (ctvOfStationControl.stationName == syncData.station) {
|
||||
// canvasProperty = ctvOfStationControl.canvas;
|
||||
// datas = loadCommonDrawDatas(ctvOfStationControl);
|
||||
// ctvOfStationControl.cctvButtons.forEach((cctvButton) => {
|
||||
// datas.push(new CCTVButtonData(cctvButton));
|
||||
// });
|
||||
// break;
|
||||
syncData.datas.forEach((data) => {
|
||||
handlerNoEditCommonData(
|
||||
data,
|
||||
ctvOfStationControl,
|
||||
syncData.operationType
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
graphicQueryer: (state, store) => {
|
||||
@ -159,9 +205,11 @@ export async function loadDrawDatas(): Promise<IGraphicStorage> {
|
||||
hasLoadData = true;
|
||||
}
|
||||
if (base64) {
|
||||
storage = iscsGraphicData.IscsGraphicStorage.deserialize(
|
||||
toUint8Array(base64)
|
||||
);
|
||||
if (!hasLoadData) {
|
||||
storage = iscsGraphicData.IscsGraphicStorage.deserialize(
|
||||
toUint8Array(base64)
|
||||
);
|
||||
}
|
||||
|
||||
let datas = [];
|
||||
let canvasProperty;
|
||||
|
Loading…
Reference in New Issue
Block a user