diff --git a/src/api/jmap/mapdraft.js b/src/api/jmap/mapdraft.js index e44c6f8e8..08de4628a 100644 --- a/src/api/jmap/mapdraft.js +++ b/src/api/jmap/mapdraft.js @@ -59,14 +59,14 @@ export function saveMap(data) { }); } -/** 保存新草稿地图*/ -export function saveNewMap(data) { - return request({ - url: `/api/mapBuild/${data.mapId}/saveNewElements`, - method: 'post', - data: data - }); -} +// 保存新草稿地图 +// export function saveNewMap(data) { +// return request({ +// url: `/api/mapBuild/${data.mapId}/saveNewElements`, +// method: 'post', +// data: data +// }); +// } /** 草稿地图另存为*/ export function saveAsMap(data) { diff --git a/src/jmapNew/shape/Section/index.js b/src/jmapNew/shape/Section/index.js index 1b9cd1f58..a3c93df42 100644 --- a/src/jmapNew/shape/Section/index.js +++ b/src/jmapNew/shape/Section/index.js @@ -234,8 +234,8 @@ export default class Section extends Group { /** 区段名称 (逻辑区段名称 或 物理区段名称 是否显示)*/ let tempx = x; let tempy = y; - if (model.type === '01') { - if (style.Section.text.show && !model.isSwitchSection) { + if (model.type == '01') { + if (style.Section.text.show) { const opposite = style.Section.text.opposite ? -1 : 1; tempx += traingle.getSin(style.Section.text.distance); tempy += traingle.getCos(style.Section.text.distance) * (style.Section.text.position || opposite * drict); @@ -257,7 +257,7 @@ export default class Section extends Group { }); this.add(this.name); } - } else if (model.type === '02') { + } else if (model.type == '02') { if (style.Section.logicText.show) { const opposite = style.Section.logicText.opposite ? -1 : 1; tempx += traingle.getSin(style.Section.logicText.distance); @@ -280,7 +280,7 @@ export default class Section extends Group { }); this.add(this.name); } - } else if (model.type === '03') { + } else if (model.type == '03') { if (style.Section.switchText.show) { this.name = new ETextName({ zlevel: this.zlevel, @@ -300,7 +300,7 @@ export default class Section extends Group { }); this.add(this.name); } - } else if (model.type === '04') { + } else if (model.type == '04') { if (router.currentRoute.path.startsWith('/design/usermap/map/draw') && router.currentRoute.path.endsWith('/draft') ) { this.name = new ETextName({ zlevel: this.zlevel, diff --git a/src/jmapNew/utils/parser.js b/src/jmapNew/utils/parser.js index 71aabb2bb..b90528d1c 100644 --- a/src/jmapNew/utils/parser.js +++ b/src/jmapNew/utils/parser.js @@ -133,8 +133,7 @@ export function parser(data, skinCode) { if (cnodeSection && lnodeSection && rnodeSection) { cnodeSection['switch'] = lnodeSection['switch'] = rnodeSection['switch'] = mapDevice[elem.code]; - const cnode = mapDevice[cnodeSection.linkCode]; - if (cnode && cnode.leftFdCode === lnodeSection.linkCode && cnode.leftSdCode === rnodeSection.linkCode) { + if (cnodeSection.points[0].x == lnodeSection.points[lnodeSection.points.length - 1].x && cnodeSection.points[0].y == lnodeSection.points[lnodeSection.points.length - 1].y) { mapDevice[elem.code].intersection = { x: cnodeSection.points[0].x, y: cnodeSection.points[0].y @@ -143,7 +142,7 @@ export function parser(data, skinCode) { x: rnodeSection.points[rnodeSection.points.length - 2].x, y: rnodeSection.points[rnodeSection.points.length - 2].y }; - } else if (cnode && cnode.rightFdCode === lnodeSection.linkCode && cnode.rightSdCode === rnodeSection.linkCode) { + } else if (cnodeSection.points[cnodeSection.points.length - 1].x == lnodeSection.points[0].x && cnodeSection.points[cnodeSection.points.length - 1].y == lnodeSection.points[0].y) { mapDevice[elem.code].intersection = { x: cnodeSection.points[cnodeSection.points.length - 1].x, y: cnodeSection.points[cnodeSection.points.length - 1].y diff --git a/src/store/modules/map.js b/src/store/modules/map.js index b2b3ee9fb..6d81d44b6 100644 --- a/src/store/modules/map.js +++ b/src/store/modules/map.js @@ -1,5 +1,6 @@ import deviceType from '@/jmap/constant/deviceType'; -import { parser, updateMapData } from '@/jmap/utils/parser'; +// import { parser, updateMapData } from '@/jmap/utils/parser'; +import { parser, updateMapData } from '@/jmapNew/utils/parser'; import Vue from 'vue'; import { deepAssign } from '@/utils/index'; @@ -9,12 +10,13 @@ import { deepAssign } from '@/utils/index'; * @param {Object} device * @param {Array} list */ -function queryDeleteModels(map, device, dict) { +function queryDeleteModels(state, device, dict) { function setDisPose(model, dict) { if (!dict[model.code] || !dict[model.code]._dispose) { dict[model.code] = {...model, _dispose: true }; } } + const map = state.map; if (device && map) { setDisPose(device, dict); @@ -35,7 +37,7 @@ function queryDeleteModels(map, device, dict) { if (map.switchList && map.switchList.length) { map.switchList.forEach(elem => { if (elem.sectionACode == device.code || elem.sectionBCode == device.code || elem.sectionCCode == device.code) { - queryDeleteModels(map, elem, dict); + queryDeleteModels(state, elem, dict); } }); } @@ -43,18 +45,32 @@ function queryDeleteModels(map, device, dict) { break; case deviceType.Switch: map.sectionList.forEach(elem => { - if (elem.type == '04' && elem.relSwitchCode == device.code) { - setDisPose(elem, dict); - } - if (elem.relSwitchCode == device.code && elem.type != '04') { + if (elem.type == '03' && elem.relSwitchCode == device.code) { if (!dict[elem.code] || !dict[elem.code]._dispose) { const copyModel = deepAssign({}, elem); + if (copyModel.parentCode) { + const setionModel = deepAssign({}, dict[copyModel.parentCode] || state.mapDevice[copyModel.parentCode]); + setionModel.relevanceSectionList.forEach((item, index) => { + if (item == copyModel.code) { + setionModel.relevanceSectionList.splice(index, 1); + dict[setionModel.code] = setionModel; + } + }); + } copyModel.relSwitchCode = ''; copyModel.parentCode = ''; copyModel.isSwitchSection = false; + copyModel.type = '01'; dict[elem.code] = copyModel; } } + if (elem.type == '04') { + if (dict[elem.code] && !dict[elem.code].relevanceSectionList.length) { + setDisPose(elem, dict); + } else if (!elem.relevanceSectionList.length) { + setDisPose(elem, dict); + } + } }); break; } @@ -652,7 +668,7 @@ const map = { const dict = {}; models.forEach((model) => { if (model['_dispose']) { - queryDeleteModels(state.map, model, dict); + queryDeleteModels(state, model, dict); } else { dict[model.code] = model; } diff --git a/src/views/newMap/newMapdraft/index.vue b/src/views/newMap/newMapdraft/index.vue index b30a971df..aa9f3bdab 100644 --- a/src/views/newMap/newMapdraft/index.vue +++ b/src/views/newMap/newMapdraft/index.vue @@ -48,7 +48,7 @@