From 9ea5d7fdfb05199a507eade4112d67f81201b72a Mon Sep 17 00:00:00 2001 From: joylink_cuiweidong <364937672@qq.com> Date: Tue, 14 Apr 2020 18:45:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=89=88=E5=9C=B0=E5=9B=BE=E4=BF=A1?= =?UTF-8?q?=E5=8F=B7=E6=9C=BA=20=E5=8C=BA=E6=AE=B5=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/newMap/newMapdraft/index.vue | 107 ++++++++++++++++-- .../newMapdraft/mapoperate/section/index.vue | 38 +++---- 2 files changed, 116 insertions(+), 29 deletions(-) diff --git a/src/views/newMap/newMapdraft/index.vue b/src/views/newMap/newMapdraft/index.vue index 484f0a253..3b12ad147 100644 --- a/src/views/newMap/newMapdraft/index.vue +++ b/src/views/newMap/newMapdraft/index.vue @@ -227,6 +227,90 @@ export default { }); return flag; }, + verifySectionRelation(map) { + let flag = true; + const tipInfoList = []; + map.sectionList.forEach(section => { + section.type === '01' && map.sectionList.forEach(item => { + if (section.code !== item.code && item.type === '01' && this.checkSectionPointsHasCoincide(section.points, item.points) && !this.checkCorrelation(section, item)) { + tipInfoList.push('区段' + section.name + '(' + section.code + '): 与区段' + item.name + '(' + item.code + ')' + '有点重叠,但并未设置与其的关联关系!' ); + } + }); + }); + if (!tipInfoList.length) { + flag = true; + } else { + flag = false; + this.$messageBox(this.$t('tip.dataValidationFailed')); + this.tableToExcel(tipInfoList); + } + return flag; + }, + verifySignalPosition(map) { + let flag = true; + const tipInfoList = []; + map.signalList.forEach(signal => { + const section = this.$store.getters['map/getDeviceByCode'](signal.sectionCode); + if (section) { + const offsetX = signal.positionPoint ? signal.positionPoint.x : 0; + const signalPositionX = signal.position.x - offsetX; + const max = Math.max(section.points[section.points.length - 1].x, section.points[0].x); + const min = Math.min(section.points[section.points.length - 1].x, section.points[0].x); + if (signalPositionX < min && signalPositionX > max) { + tipInfoList.push('信号机' + signal.name + '(' + signal.code + ')未在其关联的区段' + section.name + '(' + section.code + ')里'); + } + // if (signal.right) { + // const rightSection = this.$store.getters['map/getDeviceByCode'](section.rightSectionCode); + // if (rightSection && rightSection.points[0].x != section.points[section.points.length - 1].x) { + // const max = Math.max(section.points[section.points.length - 1].x, section.points[0].x); + // const min = Math.min(section.points[section.points.length - 1].x, section.points[0].x); + // if (signalPositionX < min && signalPositionX > max) { + // tipInfoList.push('信号机' + signal.name + '(' + signal.code + ')未在其关联的区段' + section.name + '(' + section.code + ')里'); + // } + // } else { + // if (signalPositionX > section.points[section.points.length - 1].x && signalPositionX < section.points[0].x) { + // tipInfoList.push('信号机' + signal.name + '(' + signal.code + ')未在其关联的区段' + section.name + '(' + section.code + ')里'); + // } + // } + // } else { + // const leftSection = this.$store.getters['map/getDeviceByCode'](section.leftSectionCode); + // if (leftSection && leftSection.points[leftSection.points.length - 1].x != section.points[0].x) { + // const max = Math.max(section.points[section.points.length - 1].x, section.points[0].x); + // const min = Math.min(section.points[section.points.length - 1].x, section.points[0].x); + // if (signalPositionX < min && signalPositionX > max) { + // tipInfoList.push('信号机' + signal.name + '(' + signal.code + ')未在其关联的区段' + section.name + '(' + section.code + ')里'); + // } + // } else { + // if (signalPositionX < section.points[0].x && signalPositionX > section.points[section.points.length - 1].x) { + // tipInfoList.push('信号机' + signal.name + '(' + signal.code + ')未在其关联的区段' + section.name + '(' + section.code + ')里'); + // } + // } + // } + } else { + tipInfoList.push('信号机' + signal.name + '(' + signal.code + ')所关联的区段不存在'); + } + }); + if (!tipInfoList.length) { + flag = true; + } else { + flag = false; + this.$messageBox(this.$t('tip.dataValidationFailed')); + this.tableToExcel(tipInfoList); + } + return flag; + }, + checkPointsCoincide(point1, point2) { // 校验两点是否重合 + if (point1 && point2) { + return point1.x === point2.x && point1.y === point2.y; + } + return false; + }, + checkSectionPointsHasCoincide(points1, points2) { // 校验两区段的左右点是否有重合 + return points1.length && points2.length && (this.checkPointsCoincide(points1[0], points2[0]) || this.checkPointsCoincide(points1[0], points2[points2.length - 1]) || this.checkPointsCoincide(points1[points1.length - 1], points2[points2.length - 1]) || this.checkPointsCoincide(points1[points1.length - 1], points2[0])); + }, + checkCorrelation(section1, section2) { // 校验后者是否与前者有关联关系 + return section1.leftSectionCode === section2.code || section1.rightSectionCode === section2.code; + }, saveMapEvent() { // 保存地图 const map = this.$store.state.map.map; if (this.$refs.jlmapVisual && map && parseInt(this.$route.params.mapId)) { @@ -259,20 +343,23 @@ export default { if (this.$refs.jlmapVisual) { const map = this.$store.state.map.map; if (map && this.$route.params.mapId) { - verifyMap(this.$route.params.mapId).then(res => { - if (res.data.length) { - this.tableToExcel(res.data); - this.$messageBox(this.$t('tip.dataValidationFailed')); - } else { - this.$message.success(this.$t('tip.dataValidationSuccess')); + if (this.verifySectionRelation(map)) { + if (this.verifySignalPosition(map)) { + verifyMap(this.$route.params.mapId).then(res => { + if (res.data.length) { + this.tableToExcel(res.data); + this.$messageBox(this.$t('tip.dataValidationFailed')); + } else { + this.$message.success(this.$t('tip.dataValidationSuccess')); + } + }).catch(() => { + this.$message.error(this.$t('tip.requestFailed')); + }); } - }).catch(() => { - this.$message.error(this.$t('tip.requestFailed')); - }); + } } } }, - tableToExcel(data) { const filterVal = ['index']; const arr = []; diff --git a/src/views/newMap/newMapdraft/mapoperate/section/index.vue b/src/views/newMap/newMapdraft/mapoperate/section/index.vue index 7585ffb69..dc656d039 100644 --- a/src/views/newMap/newMapdraft/mapoperate/section/index.vue +++ b/src/views/newMap/newMapdraft/mapoperate/section/index.vue @@ -7,7 +7,7 @@
- {{ $t('map.sectionRelationCheck') }} + {{ $t('map.updateObj') }} {{ $t('map.deleteObj') }} @@ -620,24 +620,24 @@ export default { checkSectionPointsHasCoincide(points1, points2) { // 校验两区段的左右点是否有重合 return points1.length && points2.length && (this.checkPointsCoincide(points1[0], points2[0]) || this.checkPointsCoincide(points1[0], points2[points2.length - 1]) || this.checkPointsCoincide(points1[points1.length - 1], points2[points2.length - 1]) || this.checkPointsCoincide(points1[points1.length - 1], points2[0])); }, - checkCorrelation(section1, section2) { // 校验后者是否与前者有关联关系 - return section1.leftSectionCode === section2.code || section1.rightSectionCode === section2.code; - }, - verifyData() { // 区段关联关系校验 - this.tipInfoList = []; - this.sectionList.forEach(section => { - section.type === '01' && this.sectionList.forEach(item => { - if (section.code !== item.code && item.type === '01' && this.checkSectionPointsHasCoincide(section.points, item.points) && !this.checkCorrelation(section, item)) { - this.tipInfoList.push(section.name + '(' + section.code + '): 与' + item.name + '(' + item.code + ')' + '有点重叠,但并未设置与其的关联关系!' ); - } - }); - }); - if (!this.tipInfoList.length) { - this.$message.success('计轴区段关联关系校验通过!'); - } else { - this.$refs.tipInfo.doShow(); - } - }, + // checkCorrelation(section1, section2) { // 校验后者是否与前者有关联关系 + // return section1.leftSectionCode === section2.code || section1.rightSectionCode === section2.code; + // }, + // verifyData() { // 区段关联关系校验 + // this.tipInfoList = []; + // this.sectionList.forEach(section => { + // section.type === '01' && this.sectionList.forEach(item => { + // if (section.code !== item.code && item.type === '01' && this.checkSectionPointsHasCoincide(section.points, item.points) && !this.checkCorrelation(section, item)) { + // this.tipInfoList.push(section.name + '(' + section.code + '): 与' + item.name + '(' + item.code + ')' + '有点重叠,但并未设置与其的关联关系!' ); + // } + // }); + // }); + // if (!this.tipInfoList.length) { + // this.$message.success('计轴区段关联关系校验通过!'); + // } else { + // this.$refs.tipInfo.doShow(); + // } + // }, tipInfoHandle(list) { if (list.length) { this.tipInfoList = list;