From a707d142be4b094e7556b2a1e7c48faf72a64625 Mon Sep 17 00:00:00 2001
From: fan <18706759286@163.com>
Date: Tue, 12 May 2020 13:57:33 +0800
Subject: [PATCH] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8C=BA=E6=AE=B5=E7=94=9F?=
=?UTF-8?q?=E6=88=90=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/jmapNew/shape/Section/index.js | 4 +-
.../newMapdraft/mapoperate/section/create.vue | 1 -
.../newMapdraft/mapoperate/section/index.vue | 8 +-
.../mapoperate/section/logicBlock.vue | 174 ++++++++++--------
.../mapoperate/section/splitOrMerge.vue | 6 +-
.../mapoperate/switch/createAxle.vue | 1 -
.../newMapdraft/mapoperate/trainwindow.vue | 4 +-
7 files changed, 105 insertions(+), 93 deletions(-)
diff --git a/src/jmapNew/shape/Section/index.js b/src/jmapNew/shape/Section/index.js
index 60d7fd065..ce2015f70 100644
--- a/src/jmapNew/shape/Section/index.js
+++ b/src/jmapNew/shape/Section/index.js
@@ -267,8 +267,8 @@ export default class Section extends Group {
createSection() {
const model = this.model;
const style = this.style;
- // 创建区段 model.logicSectionNum 为空 或 0 表明没有逻辑区段 创建 否则过滤
- if ((model.type == '01' && (model.logicSectionNum[0] == 0 || model.logicSectionNum.length == 0)) || model.type == '02' || model.type == '03') {
+ // 创建区段 model.logicSectionCodeList 为空 或 0 表明没有逻辑区段 创建 否则过滤
+ if ((model.type == '01' && (!model.logicSectionCodeList || !model.logicSectionCodeList.length)) || model.type == '02' || model.type == '03') {
this.section = new ELines({
zlevel: this.zlevel,
z: model.type == '02' ? this.z + 1 : this.z, // 逻辑区段会覆盖物理区段
diff --git a/src/views/newMap/newMapdraft/mapoperate/section/create.vue b/src/views/newMap/newMapdraft/mapoperate/section/create.vue
index 986d02bd8..6ddfbe17f 100644
--- a/src/views/newMap/newMapdraft/mapoperate/section/create.vue
+++ b/src/views/newMap/newMapdraft/mapoperate/section/create.vue
@@ -206,7 +206,6 @@ export default {
kmRangeLeft: '',
region: '',
namePosition: { x: 0, y: 0 },
- logicSectionNum: [0],
logicSectionCodeList: [],
logicSectionShow: true,
logicSectionNameSort: true,
diff --git a/src/views/newMap/newMapdraft/mapoperate/section/index.vue b/src/views/newMap/newMapdraft/mapoperate/section/index.vue
index 3ccc82b57..1f0a904fc 100644
--- a/src/views/newMap/newMapdraft/mapoperate/section/index.vue
+++ b/src/views/newMap/newMapdraft/mapoperate/section/index.vue
@@ -129,7 +129,6 @@ export default {
kmRangeRight: 0,
kmRangeLeft: 0,
region: '',
- logicSectionNum: [],
logicSectionCodeList: [],
logicSectionShow: false, // 是否显示逻辑区段
standTrack: false, // 是否站台轨
@@ -166,7 +165,6 @@ export default {
belongStation: '' // 所属车站
},
oldPoint: [], // 区段未修改前 坐标
- logicSectionNums: [1],
field: '',
oldLeftSectionCode: '',
oldRightSectionCode: '',
@@ -924,7 +922,7 @@ export default {
if (val === 'four') {
this.$nextTick(() => {
this.$refs.logicBlock.computedLogicSectionNumList(
- this.editModel.logicSectionNum
+ this.editModel.logicSectionCodeList
);
});
}
@@ -975,8 +973,6 @@ export default {
this.clear();
this.activeName = 'first';
this.editModel = deepAssign(this.editModel, selected);
- this.editModel.logicSectionNum =
- selected.type === '01' ? selected.logicSectionNum : [0];
this.editModel.points = JSON.parse(
JSON.stringify(selected.points)
);
@@ -1058,11 +1054,9 @@ export default {
addPoint(index) {
const data = { x: 0, y: 0 };
this.editModel.points.splice(index + 1, 0, data);
- this.logicSectionNums.splice(index + 1, 0, 1);
},
delPoint(index) {
this.editModel.points.splice(index, 1);
- this.logicSectionNums.splice(index, 1);
},
// 修改区段属性
edit() {
diff --git a/src/views/newMap/newMapdraft/mapoperate/section/logicBlock.vue b/src/views/newMap/newMapdraft/mapoperate/section/logicBlock.vue
index c69ce627b..41f2ad7e7 100644
--- a/src/views/newMap/newMapdraft/mapoperate/section/logicBlock.vue
+++ b/src/views/newMap/newMapdraft/mapoperate/section/logicBlock.vue
@@ -2,25 +2,28 @@
-
-
-
- {{ $t('map.aux') }}{{ scope.row.index }}{{ $t('map.sectionLine') }}
-
-
-
-
-
-
-
-
-
- {{ $t('map.empty') }}
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -57,9 +60,9 @@ export default {
},
data() {
return {
- tableData: [],
addList: [],
- isDelimiter:false
+ isDelimiter:false,
+ logicNum: 0
};
},
computed: {
@@ -70,50 +73,85 @@ export default {
methods:{
// 生成逻辑区段
editSectionNum() {
- let models = [];
+ const models = [];
this.addList = [];
- let counts = 0;
- let logicSectionNumList = [];
+ const counts = 0;
const sectionPoints = [...this.editModel.points]; // 获取区段点
- let allNotZeros = true;
- let totalNum = 0;
const lengthFact = this.editModel.lengthFact;
- this.tableData.forEach((ele, index) => {
- totalNum += Number(ele.num);
- });
let lineLength = 0; // NaN 由于 0/0 造成的
- if (totalNum) {
- lineLength = lengthFact / totalNum; // 均分逻辑区段偏移量
+ if (this.logicNum) {
+ lineLength = lengthFact / this.logicNum; // 均分逻辑区段偏移量
}
- this.tableData.forEach((ele, index) => {
- models = [...models, ...this.createLogicalSections(Number(ele.num), sectionPoints[index], sectionPoints[index + 1], this.editModel, counts, lineLength, totalNum)];
- allNotZeros = Number(ele.num) && allNotZeros;
- logicSectionNumList.push(Number(ele.num));
- counts += parseInt(ele.num);
- });
- if (counts == 0 || allNotZeros) {
- let logicSectionCodeList = [];
- models.forEach(item=> {
- logicSectionCodeList.push(item.code);
- });
- this.sectionList.forEach(section => { // 删除之前的逻辑区段
- if (section.type === '02' && section.parentCode == this.editModel.code) {
- models.push(deepAssign(section, {_dispose: true}));
- }
- });
- if (counts == 0) {
- logicSectionNumList = [];
- logicSectionCodeList = [];
+ if (sectionPoints.length === 2) {
+ const triangle = new JTriangle(sectionPoints[0], sectionPoints[1]);
+ const offset = Math.sqrt(triangle.abspowz) / this.logicNum;
+ for (let i = 0; i < this.logicNum; i++) {
+ const points = [
+ { x: sectionPoints[0].x + triangle.getCos(offset * i), y: sectionPoints[0].y + triangle.getSin(offset * i) },
+ { x: sectionPoints[0].x + triangle.getCos(offset * (i + 1)), y: sectionPoints[0].y + triangle.getSin(offset * (i + 1)) }
+ ];
+ const param = this.addLogicalSection(this.editModel, points, counts + i, lineLength, this.logicNum);
+ models.push(param);
+ this.addList.push(param);
}
- const model = deepAssign(this.editModel, {_type: 'Section'});
- model.logicSectionNum = [...logicSectionNumList];
- model.logicSectionCodeList = [...logicSectionCodeList];
- models.push(model);
- this.$emit('updateMapModel', models);
} else {
- this.$messageBox('逻辑区段在个折线上数量要均为0或均不为0');
+ const triangleList = [];
+ const pointLength = [0];
+ let totalLength = 0;
+ for (let i = 1; i < sectionPoints.length; i++) {
+ const triangle = new JTriangle(sectionPoints[i - 1], sectionPoints[i]);
+ triangleList.push(triangle);
+ totalLength += Math.floor(Math.sqrt(triangle.abspowz));
+ pointLength.push(totalLength);
+ }
+ const offset = this.logicNum ? Math.floor(totalLength / this.logicNum) : 0;
+ let startPoint = sectionPoints[0];
+ let startIndex = 1;
+ for (let i = 0; i < this.logicNum; i++) {
+ const rectLength = (i + 1) * offset;
+ let flag = true;
+ for (let index = 0; index < pointLength.length; index++) {
+ if (rectLength <= pointLength[index] && flag) {
+ const points = [{x: startPoint.x, y: startPoint.y}];
+ let surplusLength = rectLength - pointLength[index - 1];
+ if (startIndex === index) {
+ surplusLength = offset;
+ }
+ for (let j = startIndex; j <= index; j++) {
+ if (i === this.logicNum - 1 && j === index) {
+ points.push(sectionPoints[sectionPoints.length - 1]);
+ } else if (j === index) {
+ points.push({x: points[points.length - 1].x + triangleList[index - 1].getCos(surplusLength),
+ y: points[points.length - 1].y + triangleList[index - 1].getSin(surplusLength)});
+ } else if (index - startIndex > 1) {
+ points.push(sectionPoints[j]);
+ }
+ }
+ startIndex = index;
+ const param = this.addLogicalSection(this.editModel, points, counts + i, lineLength, this.logicNum);
+ startPoint = {x:points[points.length - 1].x, y:points[points.length - 1].y };
+ models.push(param);
+ this.addList.push(param);
+ flag = false;
+ }
+ }
+ }
}
-
+ let logicSectionCodeList = [];
+ models.forEach(item=> {
+ logicSectionCodeList.push(item.code);
+ });
+ this.editModel.logicSectionCodeList.forEach( logicCode => {
+ const section = this.$store.getters['map/getDeviceByCode'](logicCode);
+ models.push(deepAssign(section, {_dispose: true}));
+ });
+ if (this.logicNum === 0) {
+ logicSectionCodeList = [];
+ }
+ const model = deepAssign(this.editModel, {_type: 'Section'});
+ model.logicSectionCodeList = [...logicSectionCodeList];
+ models.push(model);
+ this.$emit('updateMapModel', models);
},
handleDelete(index, row) {
row.num = 0;
@@ -168,7 +206,6 @@ export default {
logicSectionNameSort: model.logicSectionNameSort,
switchSection: model.switchSection,
relSwitchCode: model.relSwitchCode,
- logicSectionNum: [],
logicSectionShow: model.logicSectionShow,
stationCode: model.stationCode,
destinationCode: '', // 目的地码
@@ -178,7 +215,8 @@ export default {
points: points,
curve: false,
nameShow: true,
- lengthFact: lineLength ? lineLength.toFixed(3) : lineLength,
+ logicSectionCodeList: [],
+ lengthFact: lineLength ? lineLength.toFixed(3) : 0,
trainWindowCode: '',
kmRangeRight: model.kmRangeRight,
kmRangeLeft: model.kmRangeLeft,
@@ -194,24 +232,8 @@ export default {
return data;
},
// 计算逻辑区段数量列表展示
- computedLogicSectionNumList(logicSectionNum) {
- this.tableData = [];
- this.logicSectionNums = [...logicSectionNum];
-
- var i; var num; var len = this.editModel.points.length;
- if (len > 1 && this.editModel.type === '01') {
- for (i = 0; i < len - 1; i++) {
- num = 0;
- if (Array.isArray(this.logicSectionNums) && this.logicSectionNums[i]) {
- num = parseInt(this.logicSectionNums[i]);
- }
- this.tableData.push({ index: i + 1, num: num });
- }
-
- if (this.tableData.length <= 0) {
- this.tableData.push({ index: i + 1, num: 0 });
- }
- }
+ computedLogicSectionNumList(logicSectionCodeList) {
+ this.logicNum = logicSectionCodeList ? logicSectionCodeList.length : 0;
}
}
};
diff --git a/src/views/newMap/newMapdraft/mapoperate/section/splitOrMerge.vue b/src/views/newMap/newMapdraft/mapoperate/section/splitOrMerge.vue
index 95021ae95..f8fa9c3ac 100644
--- a/src/views/newMap/newMapdraft/mapoperate/section/splitOrMerge.vue
+++ b/src/views/newMap/newMapdraft/mapoperate/section/splitOrMerge.vue
@@ -186,7 +186,6 @@ export default {
relSwitchCode: '',
trainWindowCode: '',
logicSectionNameSort: selected.logicSectionNameSort,
- logicSectionNum: selected.logicSectionNum,
logicSectionShow: selected.logicSectionShow,
sepTypeLeft: index == 0 ? selected.sepTypeLeft : '01', // 左侧分隔符类型 (起始左侧按原来区段类型走 其余 默认 01)
sepTypeRight: index == this.addModel.splitNumber ? selected.sepTypeRight : '01', // 右侧分隔符类型 (终点右侧按原来区段类型走 其余 默认 01)
@@ -208,7 +207,7 @@ export default {
relevanceSectionList: [],
roadType: selected.roadType,
firstTurnBack: false,
- belongStation: ''
+ belongStation: ''
};
models.push(model);
}
@@ -287,7 +286,7 @@ export default {
relevanceSectionList: [],
roadType: null,
firstTurnBack: false,
- belongStation: ''
+ belongStation: ''
};
models.push(deepAssign(this.$store.getters['map/getDeviceByCode'](lsection.code), { _dispose: true }));
models.push(deepAssign(this.$store.getters['map/getDeviceByCode'](rsection.code), { _dispose: true }));
@@ -312,7 +311,6 @@ export default {
});
},
handleRealLocationRelationships(model, realRigth, realLeft) {
- model.logicSectionNum = realLeft.logicSectionNum;
model.logicSectionShow = realLeft.logicSectionShow;
model.sepTypeLeft = realLeft.sepTypeLeft;
model.sepTypeRight = realRigth.sepTypeRight;
diff --git a/src/views/newMap/newMapdraft/mapoperate/switch/createAxle.vue b/src/views/newMap/newMapdraft/mapoperate/switch/createAxle.vue
index f2934263f..9098b3444 100644
--- a/src/views/newMap/newMapdraft/mapoperate/switch/createAxle.vue
+++ b/src/views/newMap/newMapdraft/mapoperate/switch/createAxle.vue
@@ -126,7 +126,6 @@ export default {
relSwitchCode: '',
relevanceSectionList: this.fromData.relevanceSectionList,
points: [{ x: 0, y: 0 }, { x: 0, y: 0 }],
- logicSectionNum: [0],
logicSectionShow: false,
sepTypeLeft: '00',
offsetLeft: 0,
diff --git a/src/views/newMap/newMapdraft/mapoperate/trainwindow.vue b/src/views/newMap/newMapdraft/mapoperate/trainwindow.vue
index 3c4bf74d0..614d6bb1f 100644
--- a/src/views/newMap/newMapdraft/mapoperate/trainwindow.vue
+++ b/src/views/newMap/newMapdraft/mapoperate/trainwindow.vue
@@ -204,7 +204,7 @@ export default {
this.field = field == this.field ? '' : field;
},
deviceSelect(selected) {
- this.$refs.form && this.$refs.form.resetFields();
+ this.$refs.form && this.$refs.form.resetFields();
if (selected && selected._type.toUpperCase() === 'TrainWindow'.toUpperCase()) {
this.activeName = 'first';
this.editModel = deepAssign(this.editModel, selected);
@@ -311,7 +311,7 @@ export default {
if (this.sectionList && this.sectionList.length) {
this.sectionList.forEach(elem => {
// elem.type !== '03' // 更宽泛的匹配条件 !elem.switchSection 严格匹配条件
- if (elem.type !== '04' && !elem.switchSection && !elem.trainWindowCode && (elem.logicSectionNum.length == 0 || elem.logicSectionNum.length == 1 && elem.logicSectionNum[0] == 0)) {
+ if (elem.type !== '04' && !elem.switchSection && !elem.trainWindowCode && ( !elem.logicSectionCodeList || elem.logicSectionCodeList.length === 0)) {
const triangle = new JTriangle(elem.points[0], elem.points[elem.points.length - 1]);
const param = this.createModel({
triangle: triangle,