|
@@ -370,8 +370,8 @@ let shareState = reactive({
|
|
|
});
|
|
|
let patternId = ref('');
|
|
|
let shareId = ref('');
|
|
|
-const overlays = [];
|
|
|
-const overlaysData = [];
|
|
|
+let overlays = [];
|
|
|
+let overlaysData = [];
|
|
|
watch(
|
|
|
() => drawing,
|
|
|
() => {
|
|
@@ -486,6 +486,14 @@ const addText = (textEditState) => {
|
|
|
const map = drawTool.getMap();
|
|
|
// 监听地图点击事件
|
|
|
map.off('click', handleClickMap);
|
|
|
+ webSock.send(
|
|
|
+ JSON.stringify({
|
|
|
+ operation: 'add', // 必填
|
|
|
+ name: data.title, // 必填
|
|
|
+ content: JSON.stringify(data), // 必填
|
|
|
+ visible: false
|
|
|
+ })
|
|
|
+ );
|
|
|
close();
|
|
|
};
|
|
|
// watch(
|
|
@@ -655,6 +663,23 @@ const handleUndo = () => {
|
|
|
console.log(history.value, future.value, currentState.value);
|
|
|
}
|
|
|
};
|
|
|
+// 移除所有覆盖物
|
|
|
+const removeAllOverlay = () => {
|
|
|
+ const map = getMap();
|
|
|
+ overlays.forEach((item, index) => {
|
|
|
+ if (Array.isArray(item)) {
|
|
|
+ item.forEach((overlay) => {
|
|
|
+ // 移除地图上覆盖物
|
|
|
+ map.remove(overlay);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 移除地图上覆盖物
|
|
|
+ map.remove(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ overlays = [];
|
|
|
+ overlaysData = [];
|
|
|
+};
|
|
|
// 根据索引移除覆盖物
|
|
|
const removeOverlayByIndex = (index: number) => {
|
|
|
const map = getMap();
|
|
@@ -666,6 +691,14 @@ const removeOverlayByIndex = (index: number) => {
|
|
|
} else {
|
|
|
// 移除地图上覆盖物
|
|
|
map.remove(overlays[index]);
|
|
|
+ if (collaboration.value) {
|
|
|
+ webSock.send(
|
|
|
+ JSON.stringify({
|
|
|
+ operation: 'delete',
|
|
|
+ id: overlays[index].getExtData()?.id
|
|
|
+ })
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
overlays.splice(index, 1);
|
|
|
overlaysData.splice(index, 1);
|
|
@@ -773,13 +806,34 @@ const handleShareConfirm = (data) => {
|
|
|
shareState.id = '';
|
|
|
};
|
|
|
const getWebSocketData = (data) => {
|
|
|
+ if (data && data.length > 0) {
|
|
|
+ const data2 = [];
|
|
|
+ const data3 = deepClone(data);
|
|
|
+ data.forEach((item) => {
|
|
|
+ if (!!item.content) {
|
|
|
+ const parseContent = JSON.parse(item.content);
|
|
|
+ if (parseContent.type === 'marker' && !!parseContent.icon) {
|
|
|
+ parseContent.icon = getImageUrl(parseContent.icon);
|
|
|
+ }
|
|
|
+ data2.push(parseContent);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const res = getMapUtils().drawData(data2);
|
|
|
+ removeAllOverlay();
|
|
|
+ res.forEach((item, index) => {
|
|
|
+ overlays.push(item);
|
|
|
+ overlaysData.push(data3[index]);
|
|
|
+ });
|
|
|
+ commit(deepClone(overlaysData));
|
|
|
+ currentState.value = data;
|
|
|
+ }
|
|
|
console.log('接收数据', data);
|
|
|
};
|
|
|
const handleSendForm = () => {
|
|
|
if (!form.value.pattern_name) {
|
|
|
return proxy?.$modal.msgWarning('请填写预案名称');
|
|
|
}
|
|
|
- createWebSocket('eZokH5XO6VC6xIXEHirTF', getWebSocketData);
|
|
|
+ webSock = createWebSocket('eZokH5XO6VC6xIXEHirTF', getWebSocketData);
|
|
|
patternId.value = 'eZokH5XO6VC6xIXEHirTF';
|
|
|
// createCollaboration(form.value).then(() => {
|
|
|
// patternId.value = form.value.pattern_id;
|