desc: 调整道岔生成逻辑
This commit is contained in:
parent
aef74d32da
commit
68d0f374aa
@ -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) {
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@
|
||||
</transition>
|
||||
</template>
|
||||
<script>
|
||||
import { saveNewMap, saveMap, getMapDetail, verifyMap, postBuildMapImport } from '@/api/jmap/mapdraft';
|
||||
import { saveMap, getMapDetail, verifyMap, postBuildMapImport } from '@/api/jmap/mapdraft';
|
||||
import { ViewMode, TrainingMode, getDeviceMenuByDeviceType } from '@/scripts/ConstDic';
|
||||
import { checkLoginLine } from '@/api/login';
|
||||
import JlmapVisual from '@/views/newMap/jlmapNew/index';
|
||||
|
@ -28,6 +28,7 @@
|
||||
:selected="selected"
|
||||
@updateMapModel="updateMapModel"
|
||||
@setCenter="setCenter"
|
||||
@fieldSelectSwitchSection="fieldSelectSwitchSection"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('map.station')" class="tab_pane_box" name="Station">
|
||||
@ -228,6 +229,7 @@ export default {
|
||||
feild: '',
|
||||
singlaType: '',
|
||||
stationType: '',
|
||||
switchType: '',
|
||||
ViewMode: ViewMode,
|
||||
LogicalViewTypeList: [
|
||||
{ code: 'Link', name: this.$t('map.link') }
|
||||
@ -280,6 +282,8 @@ export default {
|
||||
const type = device._type;
|
||||
if (this.stationType) {
|
||||
this.enabledTab = 'Station';
|
||||
} else if (this.switchType) {
|
||||
this.enabledTab = 'Switch';
|
||||
} else if (this.singlaType) {
|
||||
this.enabledTab = 'Signal';
|
||||
} else if (this.feild) {
|
||||
@ -297,6 +301,9 @@ export default {
|
||||
fieldSelect(type) {
|
||||
this.feild = type;
|
||||
},
|
||||
fieldSelectSwitchSection(type) {
|
||||
this.switchType = type;
|
||||
},
|
||||
handleSelectLogicalView(handle) {
|
||||
this.$emit('handleSelectLogicalView', handle);
|
||||
},
|
||||
|
@ -273,7 +273,8 @@ export default {
|
||||
lengthFact: 0,
|
||||
isCurve: false,
|
||||
leftSectionCode: '',
|
||||
rightSectionCode: ''
|
||||
rightSectionCode: '',
|
||||
relevanceSectionList: []
|
||||
},
|
||||
tableData: [],
|
||||
oldPoint: [], // 区段未修改前 坐标
|
||||
@ -771,7 +772,8 @@ export default {
|
||||
lengthFact: 0,
|
||||
kmRangeRight: model.kmRangeRight,
|
||||
kmRangeLeft: model.kmRangeLeft,
|
||||
region: model.region
|
||||
region: model.region,
|
||||
relevanceSectionList: []
|
||||
};
|
||||
return data;
|
||||
},
|
||||
@ -861,7 +863,8 @@ export default {
|
||||
leftStopPointOffset: 0,
|
||||
destinationCode: '',
|
||||
destinationCodePoint: { x: 0, y: 0 },
|
||||
isCurve: false
|
||||
isCurve: false,
|
||||
relevanceSectionList: []
|
||||
};
|
||||
if (this.createModel.type == '01') {
|
||||
model.points = [
|
||||
@ -1005,7 +1008,8 @@ export default {
|
||||
y: selected.points[0].y + (index * modelY)
|
||||
}
|
||||
],
|
||||
namePosition: { x: 0, y: 0 }
|
||||
namePosition: { x: 0, y: 0 },
|
||||
relevanceSectionList: []
|
||||
};
|
||||
models.push(model);
|
||||
}
|
||||
@ -1083,7 +1087,8 @@ export default {
|
||||
isCurve: false,
|
||||
kmRangeRight: '',
|
||||
kmRangeLeft: '',
|
||||
region: ''
|
||||
region: '',
|
||||
relevanceSectionList: []
|
||||
};
|
||||
models.push(deepAssign(this.$store.getters['map/getDeviceByCode'](lsection.code), { _dispose: true }));
|
||||
models.push(deepAssign(this.$store.getters['map/getDeviceByCode'](rsection.code), { _dispose: true }));
|
||||
|
@ -16,13 +16,41 @@
|
||||
<el-tab-pane class="view-control" :label="$t('map.newConstruction')" name="second">
|
||||
<div class="flex_box">
|
||||
<el-button type="primary" @click="create">{{ $t('map.createSwitch') }}</el-button>
|
||||
<el-button type="" @click="questionList = []">{{ $t('map.clearHint') }}</el-button>
|
||||
<!-- <el-button type="" @click="questionList = []">{{ $t('map.clearHint') }}</el-button> -->
|
||||
</div>
|
||||
<div style="height: calc(100% - 46px);">
|
||||
<el-scrollbar wrap-class="scrollbar-wrapper">
|
||||
<!-- <el-scrollbar wrap-class="scrollbar-wrapper">
|
||||
<el-card v-if="questionList.length" class="box-card">
|
||||
<div v-for="(item, index) in questionList" :key="index" class="text item">{{ item }}</div>
|
||||
</el-card>
|
||||
</el-scrollbar> -->
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane class="view-control" label="生成道岔计轴区段" name="three">
|
||||
<div style="height: 100%;">
|
||||
<el-scrollbar wrap-class="scrollbar-wrapper">
|
||||
<el-form ref="oprt1" :model="fromData" label-width="130px" size="mini" :rules="mergeRules">
|
||||
<el-form-item label="关联区段" prop="relevanceSectionList">
|
||||
<el-select v-model="fromData.relevanceSectionList" filterable multiple :placeholder="$t('rules.pleaseSelect')">
|
||||
<el-option
|
||||
v-for="item in sectionList"
|
||||
:key="item.code"
|
||||
:label="item.name + '(' + item.code + ')'"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button
|
||||
:type="field === 'relevanceSectionList' ? 'danger' : 'primary'"
|
||||
size="small"
|
||||
@click="hover('relevanceSectionList')"
|
||||
>{{ $t('map.activate') }}</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button-group>
|
||||
<el-button type="primary" size="big" @click="createSwitchSectionManual">生成道岔计轴区段</el-button>
|
||||
</el-button-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
@ -51,7 +79,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
activeName: 'first',
|
||||
questionList: [],
|
||||
// questionList: [],
|
||||
editModel: {
|
||||
code: '',
|
||||
name: '',
|
||||
@ -64,6 +92,10 @@ export default {
|
||||
sectionBCode: '',
|
||||
sectionCCode: '',
|
||||
tp: { x: 0, y: 0 }
|
||||
},
|
||||
field: '',
|
||||
fromData: {
|
||||
relevanceSectionList: []
|
||||
}
|
||||
};
|
||||
},
|
||||
@ -141,6 +173,13 @@ export default {
|
||||
'stationList',
|
||||
'lineCode'
|
||||
])
|
||||
// switchSectionList() {
|
||||
// let list = [];
|
||||
// if (this.sectionList && this.sectionList.length) {
|
||||
// list = this.sectionList.filter(elem => { return elem.type === '03'; });
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
},
|
||||
watch: {
|
||||
selected: function (val, oldVal) {
|
||||
@ -160,8 +199,14 @@ export default {
|
||||
if (selected && selected._type.toUpperCase() === 'Switch'.toUpperCase()) {
|
||||
this.activeName = 'first';
|
||||
this.editModel = deepAssign(this.editModel, selected);
|
||||
} else if (selected && selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'relevanceSectionList'.toUpperCase()) {
|
||||
this.fromData.relevanceSectionList.push(selected.code);
|
||||
}
|
||||
},
|
||||
hover(field) {
|
||||
this.field = field == this.field ? '' : field;
|
||||
this.$emit('fieldSelectSwitchSection', this.field);
|
||||
},
|
||||
findSectionA(pointX, pointY) {
|
||||
const list = [];
|
||||
this.sectionList.forEach(item => {
|
||||
@ -180,12 +225,90 @@ export default {
|
||||
});
|
||||
return list;
|
||||
},
|
||||
create() { // 一键生成道岔
|
||||
this.questionList = []; // 有问题区段列表
|
||||
// const models = [];
|
||||
const createArr = []; // 创建model列表
|
||||
checkAddListA(points, code) { // 判断是否添加list
|
||||
let flag = false;
|
||||
this.sectionList.forEach(section => {
|
||||
if (!section.rightSectionCode && section.type == '03') { // 右侧关联关系为空 且 道岔区段
|
||||
section.points.forEach((point, index) => {
|
||||
if (index > 0 && section.code != code) {
|
||||
if (point.x == points.x && point.y == points.y) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
return flag;
|
||||
},
|
||||
checkAddListB(points, code) { // 判断是否添加list
|
||||
let flag = false;
|
||||
this.sectionList.forEach(section => {
|
||||
section.points.forEach((point, index) => {
|
||||
if (index == 0 && section.code != code) {
|
||||
if (point.x == points.x && point.y == points.y) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
return flag;
|
||||
},
|
||||
changeSectionAttr() { // 修改区段属性
|
||||
const changeSectionList = []; // 改变的区段列表
|
||||
this.sectionList.forEach(section => {
|
||||
const oneSection = section.points[section.points.length - 1];
|
||||
const oneSectionStar = section.points[0];
|
||||
let countA = 0;
|
||||
let countB = 0;
|
||||
this.sectionList.forEach(elem => {
|
||||
const twoSection = elem.points[0];
|
||||
const twoSectionEnd = elem.points[elem.points.length - 1];
|
||||
if (oneSection.x == twoSection.x && oneSection.y == twoSection.y) {
|
||||
countA++;
|
||||
if (countA >= 2) {
|
||||
if (!this.checkAddListA(oneSection, section.code)) { // 右侧关系清空
|
||||
const sectionModel = deepAssign({}, section);
|
||||
sectionModel.rightSectionCode = '';
|
||||
sectionModel.type = '03';
|
||||
const list = this.findSectionA(sectionModel.points[sectionModel.points.length - 1].x, sectionModel.points[sectionModel.points.length - 1].y);
|
||||
list.forEach(elem => {
|
||||
const sectionModel = deepAssign({}, elem);
|
||||
sectionModel.leftSectionCode = '';
|
||||
sectionModel.type = '03';
|
||||
changeSectionList.push(sectionModel);
|
||||
});
|
||||
changeSectionList.push(sectionModel);
|
||||
}
|
||||
}
|
||||
} else if (oneSectionStar.x == twoSectionEnd.x && oneSectionStar.y == twoSectionEnd.y) {
|
||||
countB++;
|
||||
if (countB >= 2) {
|
||||
if (!this.checkAddListB(oneSectionStar, section.code)) { // 左侧关系清空
|
||||
const sectionModel = deepAssign({}, section);
|
||||
sectionModel.leftSectionCode = '';
|
||||
sectionModel.type = '03';
|
||||
const list = this.findSectionB(sectionModel.points[0].x, sectionModel.points[0].y);
|
||||
list.forEach(elem => {
|
||||
const sectionModel = deepAssign({}, elem);
|
||||
sectionModel.rightSectionCode = '';
|
||||
sectionModel.type = '03';
|
||||
changeSectionList.push(sectionModel);
|
||||
});
|
||||
changeSectionList.push(sectionModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
return changeSectionList;
|
||||
},
|
||||
create() { // 一键生成道岔
|
||||
// this.questionList = []; // 有问题区段列表
|
||||
const createArr = []; // 创建model列表
|
||||
// const models = []; // 道岔列表
|
||||
const changeSectionList = this.changeSectionAttr();
|
||||
changeSectionList.forEach(section => {
|
||||
if (!section.rightSectionCode) { // 右侧关联关系为空 且 道岔区段
|
||||
const list = this.findSectionA(section.points[section.points.length - 1].x, section.points[section.points.length - 1].y);
|
||||
let sectionB = {};
|
||||
let sectionC = {};
|
||||
@ -197,33 +320,35 @@ export default {
|
||||
sectionC = item;
|
||||
}
|
||||
});
|
||||
const uname = 'switch_' + section.name.replace('section_', '');
|
||||
const model = {
|
||||
_type: 'Switch',
|
||||
code: getUID('Switch'),
|
||||
name: uname,
|
||||
nameShow: true,
|
||||
timeoutShow: true,
|
||||
sectionACode: section.code,
|
||||
sectionBCode: sectionB.code,
|
||||
sectionCCode: sectionC.code,
|
||||
namePosition: { x: 0, y: 0 },
|
||||
turnTime: 3,
|
||||
tp: { x: 0, y: 0 },
|
||||
intersection: {
|
||||
x: section.points[section.points.length - 1].x,
|
||||
y: section.points[section.points.length - 1].y
|
||||
},
|
||||
skew: {
|
||||
x: sectionC.points[1].x,
|
||||
y: sectionC.points[1].y
|
||||
}
|
||||
};
|
||||
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
|
||||
!swch && createArr.push(model); // 已有的道岔不在创建
|
||||
if (section.code && sectionB.code && sectionC.code) {
|
||||
const uname = 'switch_' + section.name.replace('section_', '');
|
||||
const model = {
|
||||
_type: 'Switch',
|
||||
code: getUID('Switch'),
|
||||
name: uname,
|
||||
nameShow: true,
|
||||
timeoutShow: true,
|
||||
sectionACode: section.code,
|
||||
sectionBCode: sectionB.code,
|
||||
sectionCCode: sectionC.code,
|
||||
namePosition: { x: 0, y: 0 },
|
||||
turnTime: 3,
|
||||
tp: { x: 0, y: 0 },
|
||||
intersection: {
|
||||
x: section.points[section.points.length - 1].x,
|
||||
y: section.points[section.points.length - 1].y
|
||||
},
|
||||
skew: {
|
||||
x: sectionC.points[1].x,
|
||||
y: sectionC.points[1].y
|
||||
}
|
||||
};
|
||||
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
|
||||
!swch && createArr.push(model); // 已有的道岔不在创建
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!section.leftSectionCode && section.type == '03') { // 左侧关联关系为空 且 道岔区段
|
||||
if (!section.leftSectionCode) { // 左侧关联关系为空 且 道岔区段
|
||||
const list = this.findSectionB(section.points[0].x, section.points[0].y);
|
||||
let sectionB = {};
|
||||
let sectionC = {};
|
||||
@ -235,50 +360,48 @@ export default {
|
||||
sectionC = item;
|
||||
}
|
||||
});
|
||||
const uname = 'switch_' + section.name.replace('section_', '');
|
||||
const model = {
|
||||
_type: 'Switch',
|
||||
code: getUID('Switch'),
|
||||
name: uname,
|
||||
nameShow: true,
|
||||
timeoutShow: true,
|
||||
sectionACode: section.code,
|
||||
sectionBCode: sectionB.code,
|
||||
sectionCCode: sectionC.code,
|
||||
namePosition: { x: 0, y: 0 },
|
||||
turnTime: 3,
|
||||
tp: { x: 0, y: 0 },
|
||||
intersection: {
|
||||
x: section.points[0].x,
|
||||
y: section.points[0].y
|
||||
},
|
||||
skew: {
|
||||
x: sectionC.points[sectionC.points.length - 2].x,
|
||||
y: sectionC.points[sectionC.points.length - 2].y
|
||||
}
|
||||
};
|
||||
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
|
||||
!swch && createArr.push(model); // 已有的道岔不在创建
|
||||
if (section.code && sectionB.code && sectionC.code) {
|
||||
const uname = 'switch_' + section.name.replace('section_', '');
|
||||
const model = {
|
||||
_type: 'Switch',
|
||||
code: getUID('Switch'),
|
||||
name: uname,
|
||||
nameShow: true,
|
||||
timeoutShow: true,
|
||||
sectionACode: section.code,
|
||||
sectionBCode: sectionB.code,
|
||||
sectionCCode: sectionC.code,
|
||||
namePosition: { x: 0, y: 0 },
|
||||
turnTime: 3,
|
||||
tp: { x: 0, y: 0 },
|
||||
intersection: {
|
||||
x: section.points[0].x,
|
||||
y: section.points[0].y
|
||||
},
|
||||
skew: {
|
||||
x: sectionC.points[sectionC.points.length - 2].x,
|
||||
y: sectionC.points[sectionC.points.length - 2].y
|
||||
}
|
||||
};
|
||||
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
|
||||
!swch && createArr.push(model); // 已有的道岔不在创建
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.$confirm(this.$t('tip.confirmBatchGeneration'), this.$t('tip.hint'), {
|
||||
confirmButtonText: this.$t('tip.confirm'),
|
||||
cancelButtonText: this.$t('tip.cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
|
||||
const models = this.createSwitchSection(createArr);
|
||||
models.forEach(item => {
|
||||
}).then((res) => {
|
||||
const modelsList = this.createSwitchSection(createArr, changeSectionList);
|
||||
modelsList.forEach(item => {
|
||||
createArr.push(item);
|
||||
});
|
||||
this.$emit('updateMapModel', createArr);
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: this.$t('tip.cancelGeneration')
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.log(error, '错误信息');
|
||||
this.$message( this.$t('tip.cancelGeneration'));
|
||||
});
|
||||
},
|
||||
// 修改对象
|
||||
@ -303,7 +426,6 @@ export default {
|
||||
cancelButtonText: this.$t('tip.cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
// _that.handleDelete(selected);
|
||||
models.push(deepAssign(selected, { _dispose: true }));
|
||||
_that.$emit('updateMapModel', models);
|
||||
_that.deviceSelect();
|
||||
@ -312,24 +434,6 @@ export default {
|
||||
});
|
||||
}
|
||||
},
|
||||
// 删除道岔/ 关联的道岔区段以及 道岔绑定关系
|
||||
handleDelete(selected) {
|
||||
// const models = [];
|
||||
// this.sectionList.forEach(elem => {
|
||||
// if (elem.relSwitchCode == selected.code && elem.type == '04') { // 删除道岔计轴区段
|
||||
// models.push(deepAssign({ _type: 'Section', code: elem.code }, { _dispose: true }));
|
||||
// }
|
||||
// if (elem.relSwitchCode == selected.code && elem.type == '03') { // 删除道岔区段关联关系
|
||||
// const section = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.code));
|
||||
// section.relSwitchCode = '';
|
||||
// section.parentCode = '';
|
||||
// section.isSwitchSection = false;
|
||||
// models.push(section);
|
||||
// }
|
||||
// });
|
||||
// models.push(deepAssign(selected, { _dispose: true }));
|
||||
// this.$emit('updateMapModel', models);
|
||||
},
|
||||
findSectionDataByLinkCodeAndPoint(code, point) {
|
||||
var rtn = null;
|
||||
var sectionList = this.sectionList;
|
||||
@ -361,30 +465,56 @@ export default {
|
||||
}
|
||||
return rtn;
|
||||
},
|
||||
findSectionData(sectionList, code) {
|
||||
var rtn = null;
|
||||
if (sectionList && sectionList.length) {
|
||||
for (var i = 0; i < sectionList.length; ++i) {
|
||||
if (code === sectionList[i].code) {
|
||||
rtn = sectionList[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rtn;
|
||||
},
|
||||
// 一键生成道岔计轴区段
|
||||
createSwitchSection(list) {
|
||||
createSwitchSection(list, sectionLists) {
|
||||
const models = [];
|
||||
if (list && list.length && this.sectionList && this.sectionList.length) {
|
||||
const switchList = [...this.switchList, ...list];
|
||||
if (list && list.length && sectionLists && sectionLists.length) {
|
||||
const sectionList = [];
|
||||
list.forEach(elem => {
|
||||
const sectionb = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionBCode));
|
||||
const sectiona = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionACode));
|
||||
const sectionc = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionCCode));
|
||||
const sectionb = this.findSectionData(sectionLists, elem.sectionBCode);
|
||||
const sectiona = this.findSectionData(sectionLists, elem.sectionACode);
|
||||
const sectionc = this.findSectionData(sectionLists, elem.sectionCCode);
|
||||
const uid = getUID('Section');
|
||||
elem['uid'] = uid;
|
||||
list.forEach(ele => {
|
||||
const sectiona1 = deepAssign({}, this.$store.getters['map/getDeviceByCode'](ele.sectionACode));
|
||||
const sectionb1 = deepAssign({}, this.$store.getters['map/getDeviceByCode'](ele.sectionBCode));
|
||||
switchList.forEach(ele => {
|
||||
const sectiona1 = this.findSectionData(sectionLists, ele.sectionACode);
|
||||
const sectionc1 = this.findSectionData(sectionLists, ele.sectionCCode);
|
||||
const sectionb1 = this.findSectionData(sectionLists, ele.sectionBCode);
|
||||
if (sectionb1.points[0].x == sectionb.points[sectionb.points.length - 1].x && sectionb1.points[0].y == sectionb.points[sectionb.points.length - 1].y) {
|
||||
elem['relevanceSectionList'] = [elem.sectionACode, elem.sectionBCode, elem.sectionCCode, ele.sectionACode, ele.sectionBCode, ele.sectionCCode];
|
||||
sectionList.push(elem);
|
||||
sectiona.parentCode = uid;
|
||||
sectionb.parentCode = uid;
|
||||
sectionc.parentCode = uid;
|
||||
sectiona1.parentCode = uid;
|
||||
sectionb1.parentCode = uid;
|
||||
sectionc1.parentCode = uid;
|
||||
}
|
||||
if (sectiona1.points[0].x == sectiona.points[sectiona.points.length - 1].x && sectiona1.points[0].y == sectiona.points[sectiona.points.length - 1].y) {
|
||||
elem['relevanceSectionList'] = [elem.sectionACode, elem.sectionBCode, elem.sectionCCode, ele.sectionACode, ele.sectionBCode, ele.sectionCCode];
|
||||
sectionList.push(elem);
|
||||
sectiona.parentCode = uid;
|
||||
sectionb.parentCode = uid;
|
||||
sectionc.parentCode = uid;
|
||||
sectiona1.parentCode = uid;
|
||||
sectionb1.parentCode = uid;
|
||||
sectionc1.parentCode = uid;
|
||||
}
|
||||
});
|
||||
sectiona.parentCode = uid;
|
||||
sectionb.parentCode = uid;
|
||||
sectionc.parentCode = uid;
|
||||
|
||||
sectiona.relSwitchCode = elem.code;
|
||||
sectionb.relSwitchCode = elem.code;
|
||||
sectionc.relSwitchCode = elem.code;
|
||||
@ -395,11 +525,10 @@ export default {
|
||||
models.push(sectionb);
|
||||
models.push(sectionc);
|
||||
});
|
||||
console.log(sectionList, '生成道岔计轴区段');
|
||||
sectionList.forEach(elem => {
|
||||
const sectiona = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionACode));
|
||||
const sectionb = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionBCode));
|
||||
const sectionc = deepAssign({}, this.$store.getters['map/getDeviceByCode'](elem.sectionCCode));
|
||||
const sectiona = this.findSectionData(sectionLists, elem.sectionACode);
|
||||
const sectionb = this.findSectionData(sectionLists, elem.sectionBCode);
|
||||
const sectionc = this.findSectionData(sectionLists, elem.sectionCCode);
|
||||
if (sectiona && sectionb && sectionc) {
|
||||
let point = {
|
||||
x: sectiona.points[sectiona.points.length - 1].x,
|
||||
@ -430,7 +559,8 @@ export default {
|
||||
isSegmentation: false,
|
||||
segmentationPosition: { x: 0, y: 0 },
|
||||
isSwitchSection: true,
|
||||
relSwitchCode: elem.code,
|
||||
relSwitchCode: '',
|
||||
relevanceSectionList: elem.relevanceSectionList,
|
||||
points: [{ x: 0, y: 0 }, { x: 0, y: 0 }],
|
||||
logicSectionNum: [0],
|
||||
logicSectionShow: false,
|
||||
@ -443,11 +573,60 @@ export default {
|
||||
trainPosType: sectiona.trainPosType,
|
||||
isCurve: false
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
return models;
|
||||
},
|
||||
createSwitchSectionManual() {
|
||||
const models = [];
|
||||
const uid = getUID('Section');
|
||||
this.fromData.relevanceSectionList.forEach(item => {
|
||||
const section = deepAssign({}, this.$store.getters['map/getDeviceByCode'](item));
|
||||
section.parentCode = uid;
|
||||
});
|
||||
const sectionCode = this.fromData.relevanceSectionList[0];
|
||||
const sectiona = deepAssign({}, this.$store.getters['map/getDeviceByCode'](sectionCode));
|
||||
models.push({
|
||||
_type: 'Section',
|
||||
code: uid,
|
||||
name: uid,
|
||||
type: '04',
|
||||
axleShow: false,
|
||||
namePosition: {
|
||||
x: sectiona.points[sectiona.points.length - 1].x,
|
||||
y: sectiona.points[sectiona.points.length - 1].y
|
||||
},
|
||||
isStandTrack: false,
|
||||
kmRangeRight: '',
|
||||
kmRangeLeft: '',
|
||||
region: '',
|
||||
standTrackName: '',
|
||||
standTrackNamePosition: { x: 0, y: 0 },
|
||||
isReentryTrack: false,
|
||||
reentryTrackName: '',
|
||||
reentryTrackNamePosition: { x: 0, y: 0 },
|
||||
isTransferTrack: false,
|
||||
transferTrackName: '',
|
||||
transferTrackNamePosition: { x: 0, y: 0 },
|
||||
isSegmentation: false,
|
||||
segmentationPosition: { x: 0, y: 0 },
|
||||
isSwitchSection: true,
|
||||
relSwitchCode: '',
|
||||
relevanceSectionList: this.fromData.relevanceSectionList,
|
||||
points: [{ x: 0, y: 0 }, { x: 0, y: 0 }],
|
||||
logicSectionNum: [0],
|
||||
logicSectionShow: false,
|
||||
sepTypeLeft: '00',
|
||||
offsetLeft: 0,
|
||||
sepTypeRight: '00',
|
||||
offsetRight: 0,
|
||||
parentCode: '',
|
||||
stationCode: sectiona.stationCode,
|
||||
trainPosType: sectiona.trainPosType,
|
||||
isCurve: false
|
||||
});
|
||||
this.$emit('updateMapModel', models);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user