逻辑区段生成调整
This commit is contained in:
parent
d03b3c1978
commit
a707d142be
@ -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, // 逻辑区段会覆盖物理区段
|
||||
|
@ -206,7 +206,6 @@ export default {
|
||||
kmRangeLeft: '',
|
||||
region: '',
|
||||
namePosition: { x: 0, y: 0 },
|
||||
logicSectionNum: [0],
|
||||
logicSectionCodeList: [],
|
||||
logicSectionShow: true,
|
||||
logicSectionNameSort: true,
|
||||
|
@ -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() {
|
||||
|
@ -2,25 +2,28 @@
|
||||
<div style="height:100%">
|
||||
<div style="height: calc(100% - 46px);">
|
||||
<el-scrollbar wrap-class="scrollbar-wrapper">
|
||||
<el-table :data="tableData" style="width: 80%; margin: 0 auto;">
|
||||
<el-table-column :label="$t('map.sectionPolyline')" width="150">
|
||||
<template slot-scope="scope">
|
||||
<span style="margin-left: 10px">{{ $t('map.aux') }}{{ scope.row.index }}{{ $t('map.sectionLine') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('map.sectionLogicalNumber')" width="130">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.num" size="mini" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('map.operation')">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">{{ $t('map.empty') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--<el-table :data="tableData" style="width: 80%; margin: 0 auto;">-->
|
||||
<!--<el-table-column :label="$t('map.sectionPolyline')" width="150">-->
|
||||
<!--<template slot-scope="scope">-->
|
||||
<!--<span style="margin-left: 10px">{{ $t('map.aux') }}{{ scope.row.index }}{{ $t('map.sectionLine') }}</span>-->
|
||||
<!--</template>-->
|
||||
<!--</el-table-column>-->
|
||||
<!--<el-table-column :label="$t('map.sectionLogicalNumber')" width="130">-->
|
||||
<!--<template slot-scope="scope">-->
|
||||
<!--<el-input v-model="scope.row.num" size="mini" />-->
|
||||
<!--</template>-->
|
||||
<!--</el-table-column>-->
|
||||
<!--<el-table-column :label="$t('map.operation')">-->
|
||||
<!--<template slot-scope="scope">-->
|
||||
<!--<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">{{ $t('map.empty') }}-->
|
||||
<!--</el-button>-->
|
||||
<!--</template>-->
|
||||
<!--</el-table-column>-->
|
||||
<!--</el-table>-->
|
||||
<el-form ref="showDelimiter" label-width="130px" size="mini">
|
||||
<el-form-item label="逻辑区段数量">
|
||||
<el-input-number v-model="logicNum" :min="0" />
|
||||
</el-form-item>
|
||||
<el-form-item label="是否显示分隔符" style="margin-top:30px;margin-left:30px;">
|
||||
<el-checkbox v-model="isDelimiter" />
|
||||
</el-form-item>
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user