Merge remote-tracking branch 'origin/test'

This commit is contained in:
fan 2023-09-20 14:51:28 +08:00
commit ac096dd663
19 changed files with 614 additions and 407 deletions

View File

@ -51,7 +51,7 @@ export default {
menuSignal: { menuSignal: {
routeSelect: '进路选排', routeSelect: '进路选排',
routeCancel: '进路取消', routeCancel: '进路取消',
signalBlock: '信号封', signalBlock: '信号封',
signalDeblock: '信号解封', signalDeblock: '信号解封',
signalReopen: '信号重开', signalReopen: '信号重开',
guideRouteHandle: '引导进路办理', guideRouteHandle: '引导进路办理',

View File

@ -27,7 +27,11 @@ export function parser(data, skinCode, showConfig) {
zrUtil.each(centralStationList, elem => { zrUtil.each(centralStationList, elem => {
mapDevice[elem.code].stationCode = elem.code; mapDevice[elem.code].stationCode = elem.code;
zrUtil.each(elem.chargeStationCodeList || [], item => { zrUtil.each(elem.chargeStationCodeList || [], item => {
mapDevice[item].stationCode = elem.code; if (mapDevice[item]) {
mapDevice[item].stationCode = elem.code;
} else {
console.error('未获取到设备' + item);
}
}); });
}); });
zrUtil.each(data.sectionList || [], elem => { zrUtil.each(data.sectionList || [], elem => {

View File

@ -423,21 +423,21 @@ export default {
break; break;
case 'center': case 'center':
operate.cmdType = CMD.ControlConvertMenu.CMD_CM_APPLY_FOR_CENTER_CONTROL; operate.cmdType = CMD.ControlConvertMenu.CMD_CM_APPLY_FOR_CENTER_CONTROL;
// delete operate.over; delete operate.over;
operate.subType = 'center'; operate.subType = 'center';
operate.param = {stationCodes: [model.code]}; operate.param = {stationCodes: [model.code]};
operate.code = model.code; operate.code = model.code;
break; break;
case 'emergency': case 'emergency':
operate.cmdType = CMD.ControlConvertMenu.CMD_CM_EMERGENCY_STATION_CONTROL; operate.cmdType = CMD.ControlConvertMenu.CMD_CM_EMERGENCY_STATION_CONTROL;
// delete operate.over; delete operate.over;
operate.subType = 'emergency'; operate.subType = 'emergency';
operate.param = {stationCodes: [model.code]}; operate.param = {stationCodes: [model.code]};
operate.code = model.code; operate.code = model.code;
break; break;
case 'interconnected': case 'interconnected':
operate.cmdType = CMD.ControlConvertMenu.CMD_CM_EMERGENCY_STATION_CONTROL; operate.cmdType = CMD.ControlConvertMenu.CMD_CM_EMERGENCY_STATION_CONTROL;
// delete operate.over; delete operate.over;
operate.subType = 'interconnected'; operate.subType = 'interconnected';
operate.param = {stationCodes: [model.code]}; operate.param = {stationCodes: [model.code]};
operate.code = model.code; operate.code = model.code;
@ -447,7 +447,7 @@ export default {
this.$store.dispatch('trainingNew/next', operate).then(({ valid, response }) => { this.$store.dispatch('trainingNew/next', operate).then(({ valid, response }) => {
// //
// const operate = Object.assign({}, operate); // const operate = Object.assign({}, operate);
if (subType == 'center ' || subType == 'emergency' || subType == 'interconnected' ) { if (subType == 'center' || subType == 'emergency' || subType == 'interconnected' ) {
operate['operateNext'] = operate.operation = this.Command.close.password.operation; operate['operateNext'] = operate.operation = this.Command.close.password.operation;
if (subType == 'center') { if (subType == 'center') {
operate['nextCmdType'] = CMD.ControlConvertMenu.CMD_CM_APPLY_FOR_CENTER_CONTROL; operate['nextCmdType'] = CMD.ControlConvertMenu.CMD_CM_APPLY_FOR_CENTER_CONTROL;

View File

@ -34,6 +34,9 @@
<el-button :disabled="showRight" type="primary" size="mini" icon="el-icon-arrow-right" @click="adjustDirection" /> <el-button :disabled="showRight" type="primary" size="mini" icon="el-icon-arrow-right" @click="adjustDirection" />
</el-col> </el-col>
</el-row> </el-row>
<el-row style="text-align: center;margin-top: 15px;">
<el-button type="primary" size="mini" @click="handleRun">自动运行</el-button>
</el-row>
</el-dialog> </el-dialog>
</template> </template>
@ -41,6 +44,7 @@
import LeftTrain from '@/assets/left_train.png'; import LeftTrain from '@/assets/left_train.png';
import RightTrain from '@/assets/right_train.png'; import RightTrain from '@/assets/right_train.png';
import { sandTableTrainControl } from '@/api/simulation'; import { sandTableTrainControl } from '@/api/simulation';
import {menuOperate} from '@/jmapNew/theme/components/utils/menuOperate';
export default { export default {
name: 'TrainOperation', name: 'TrainOperation',
data() { data() {
@ -113,12 +117,36 @@ export default {
adjustDirection() { adjustDirection() {
sandTableTrainControl(this.$route.query.group, { groupNumber: this.groupNumber, right: !this.right, speed: this.speed }).then(resp => { sandTableTrainControl(this.$route.query.group, { groupNumber: this.groupNumber, right: !this.right, speed: this.speed }).then(resp => {
this.right = !this.right; this.right = !this.right;
}).catch(err => { this.$message.error(err.message); }); }).catch(err => { this.$message.error(err.message); }).finally(() => { this.changeSpeedFlag = false; });
}, },
brakeTrain() { brakeTrain() {
sandTableTrainControl(this.$route.query.group, { groupNumber: this.groupNumber, right: this.right, speed: 0 }).then(resp => { sandTableTrainControl(this.$route.query.group, { groupNumber: this.groupNumber, right: this.right, speed: 0 }).then(resp => {
this.speed = 0; this.speed = 0;
}).catch(err => { this.$message.error(err.message); }); }).catch(err => { this.$message.error(err.message); }).finally(() => { this.changeSpeedFlag = false; });
},
handleRun() {
const step = {
over: true,
operation: menuOperate.Common.trainDrive.operation,
cmdType: menuOperate.Common.trainDrive.cmdType,
param: {
groupNumber: this.groupNumber,
param: {
speedLimit: '',
through: 0,
targetDeviceCode: ''
}
}
};
this.$store.dispatch('trainingNew/next', step).then(({ valid }) => {
if (valid) {
this.$store.dispatch('menuOperation/handleBreakFlag', { break: true });
} else {
this.$messageBox('Failed to set or cancel the fault!');
}
}).catch((error) => {
this.$messageBox(error.message || 'Failed to set or cancel the fault!');
}).finally(() => { this.changeSpeedFlag = false; });
} }
} }
}; };

View File

@ -107,7 +107,7 @@ export default {
this.tempData = [{ this.tempData = [{
code: selected.code, code: selected.code,
name: selected.name, name: selected.name,
status: selected.blockade ? this.$t('menu.unblocked') : this.$t('menu.blocked') }]; status: selected.blockade ? this.$t('menu.blocked') : this.$t('menu.unblocked') }];
const timer = setInterval(() => { const timer = setInterval(() => {
if (this.$refs.table) { if (this.$refs.table) {
this.$refs.table.setCurrentRow(this.tempData[0]); this.$refs.table.setCurrentRow(this.tempData[0]);

View File

@ -149,7 +149,7 @@ export default {
}, },
watch: { watch: {
'$store.state.menuOperation.menuCount': function (val) { '$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Section) && !this.buttonOperation && !(this.work == 'localWork' && this.roles == 'DEPOT_DISPATCHER')) { if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Section) && !this.buttonOperation) {
this.doShow(this.$store.state.menuOperation.menuPosition); this.doShow(this.$store.state.menuOperation.menuPosition);
} else { } else {
this.doClose(); this.doClose();
@ -205,7 +205,9 @@ export default {
}); });
}, },
doShow(point) { doShow(point) {
this.initMenu(); if (!(this.work == 'localWork' && this.roles == 'DEPOT_DISPATCHER' && this.operatemode !== OperateMode.FAULT)) {
this.initMenu();
}
if (this.$refs && this.$refs.popMenu && this.menu && this.menu.length) { if (this.$refs && this.$refs.popMenu && this.menu && this.menu.length) {
this.$refs.popMenu.resetShowPosition(point); this.$refs.popMenu.resetShowPosition(point);
} }

View File

@ -195,7 +195,7 @@ export default {
}, },
watch: { watch: {
'$store.state.menuOperation.menuCount': function (val) { '$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Signal) && !this.buttonOperation && !(this.work == 'localWork' && this.roles == 'DEPOT_DISPATCHER')) { if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Signal) && !this.buttonOperation) {
this.doShow(this.$store.state.menuOperation.menuPosition); this.doShow(this.$store.state.menuOperation.menuPosition);
} else { } else {
this.doClose(); this.doClose();
@ -361,7 +361,9 @@ export default {
} }
}, },
doShow(point) { doShow(point) {
this.initMenu(); if (!(this.work == 'localWork' && this.roles == 'DEPOT_DISPATCHER' && this.operatemode !== OperateMode.FAULT)) {
this.initMenu();
}
if (this.$refs && this.$refs.popMenu && this.menu && this.menu.length) { if (this.$refs && this.$refs.popMenu && this.menu && this.menu.length) {
this.$refs.popMenu.resetShowPosition(point); this.$refs.popMenu.resetShowPosition(point);
} }

View File

@ -131,7 +131,7 @@ export default {
}, },
watch: { watch: {
'$store.state.menuOperation.menuCount': function (val) { '$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Station) && !this.buttonOperation && !(this.work == 'localWork' && this.roles == 'DEPOT_DISPATCHER')) { if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Station) && !this.buttonOperation) {
this.doShow(this.$store.state.menuOperation.menuPosition); this.doShow(this.$store.state.menuOperation.menuPosition);
} else { } else {
this.doClose(); this.doClose();
@ -154,7 +154,9 @@ export default {
}, },
doShow(point) { doShow(point) {
if (this.selected.ciStation) { if (this.selected.ciStation) {
this.initMenu(); if (!(this.work == 'localWork' && this.roles == 'DEPOT_DISPATCHER' && this.operatemode !== OperateMode.FAULT)) {
this.initMenu();
}
if (this.$refs && this.$refs.popMenu && this.menu && this.menu.length) { if (this.$refs && this.$refs.popMenu && this.menu && this.menu.length) {
this.$refs.popMenu.resetShowPosition(point); this.$refs.popMenu.resetShowPosition(point);
} }

View File

@ -185,7 +185,7 @@ export default {
}, },
watch: { watch: {
'$store.state.menuOperation.menuCount': function (val) { '$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.StationStand) && !this.buttonOperation && !(this.work == 'localWork' && this.roles == 'DEPOT_DISPATCHER')) { if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.StationStand) && !this.buttonOperation) {
this.doShow(this.$store.state.menuOperation.menuPosition); this.doShow(this.$store.state.menuOperation.menuPosition);
} else { } else {
this.doClose(); this.doClose();
@ -221,7 +221,9 @@ export default {
// } // }
}, },
doShow(point) { doShow(point) {
this.initMenu(); if (!(this.work == 'localWork' && this.roles == 'DEPOT_DISPATCHER' && this.operatemode !== OperateMode.FAULT)) {
this.initMenu();
}
if (this.$refs && this.$refs.popMenu && this.menu && this.menu.length) { if (this.$refs && this.$refs.popMenu && this.menu && this.menu.length) {
this.$refs.popMenu.resetShowPosition(point); this.$refs.popMenu.resetShowPosition(point);
} }

View File

@ -153,7 +153,7 @@ export default {
}, },
watch: { watch: {
'$store.state.menuOperation.menuCount': function (val) { '$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Switch) && !this.buttonOperation && !(this.work == 'localWork' && this.roles == 'DEPOT_DISPATCHER')) { if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Switch) && !this.buttonOperation) {
this.doShow(this.$store.state.menuOperation.menuPosition); this.doShow(this.$store.state.menuOperation.menuPosition);
} else { } else {
this.doClose(); this.doClose();
@ -207,7 +207,9 @@ export default {
}); });
}, },
doShow(point) { doShow(point) {
this.initMenu(); if (!(this.work == 'localWork' && this.roles == 'DEPOT_DISPATCHER' && this.operatemode !== OperateMode.FAULT)) {
this.initMenu();
}
if (this.$refs && this.$refs.popMenu && this.menu && this.menu.length) { if (this.$refs && this.$refs.popMenu && this.menu && this.menu.length) {
this.$refs.popMenu.resetShowPosition(point); this.$refs.popMenu.resetShowPosition(point);
} }

View File

@ -178,7 +178,7 @@ export default {
} }
}, },
'$store.state.menuOperation.selected': function (val) { '$store.state.menuOperation.selected': function (val) {
if (val._type === 'Train' && val._event === MouseEvent.Left && this.project === 'srsandbox') { if (val._type === 'Train' && val._event === MouseEvent.Left && (this.project === 'srsandbox' || this.project === 'ngysandtable')) {
this.$refs.trainOperation.doShow(val); this.$refs.trainOperation.doShow(val);
} }
} }

View File

@ -1,5 +1,5 @@
import { createMartPoint, createMartPointReverse, createSeriesModel, createMarkLineModels, hexColor } from './util'; import { createMartPoint, createMartPointReverse, createSeriesModel, createMarkLineModels, hexColor } from './util';
import store from '@/store/index'; // import store from '@/store/index';
const defaultConfig = { const defaultConfig = {
/** 边缘高度*/ /** 边缘高度*/
@ -49,7 +49,6 @@ class EqualDistanceParser {
var idx = 0; var idx = 0;
var lastPoint = null; var lastPoint = null;
var nextPoint = null; var nextPoint = null;
/** 如果车次号为空,不显示名称*/ /** 如果车次号为空,不显示名称*/
if (train.tripNumber) { if (train.tripNumber) {
// 如果不是被删除的首个车次 // 如果不是被删除的首个车次
@ -59,9 +58,9 @@ class EqualDistanceParser {
pointdata.name = `${service.serviceNumber}${train.tripNumber}`; pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color; pointdata.color = '#000' || lineStyle.color;
pointdata.directionCode = train.right ? '2' : '1'; pointdata.directionCode = train.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) { // if (!store.state.map.mapConfig.upRight) {
pointdata.directionCode = train.right ? '1' : '2'; // pointdata.directionCode = train.right ? '1' : '2';
} // }
pointdata.coord = [train.stationTimeList[0].secondTime, this.getCoordYByElem(stations, kmRangeMap, train.stationTimeList[0], pointdata.directionCode, false)]; pointdata.coord = [train.stationTimeList[0].secondTime, this.getCoordYByElem(stations, kmRangeMap, train.stationTimeList[0], pointdata.directionCode, false)];
/** 给服务对象添加服务名称和标记点*/ /** 给服务对象添加服务名称和标记点*/
opt.markPointData.push(this.__createMartPoint(pointdata)); opt.markPointData.push(this.__createMartPoint(pointdata));
@ -170,10 +169,10 @@ class EqualDistanceParser {
runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => { runPlanData[elem.serviceNumber][elem.tripNumber].sort((a, b) => {
return parseInt(a.secondTime) - parseInt(b.secondTime); return parseInt(a.secondTime) - parseInt(b.secondTime);
}); });
let directionCode = elem.right ? '2' : '1'; const directionCode = elem.right ? '2' : '1';
if (!store.state.map.mapConfig.upRight) { // if (!store.state.map.mapConfig.upRight) {
directionCode = elem.right ? '1' : '2'; // directionCode = elem.right ? '1' : '2';
} // }
/** 如果此记录车组号的数据为第一条时,则打上标签*/ /** 如果此记录车组号的数据为第一条时,则打上标签*/
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) { if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`); const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
@ -262,7 +261,6 @@ class EqualDistanceParser {
} else if (directionCode === '2') { } else if (directionCode === '2') {
defaultValue += sign * this.getEdge() / 2; defaultValue += sign * this.getEdge() / 2;
} }
return defaultValue; return defaultValue;
} }

View File

@ -331,7 +331,8 @@ export default {
mapId: mapId, mapId: mapId,
simType:paramVO.type, simType:paramVO.type,
project: this.projectCode, project: this.projectCode,
projectDevice:this.$route.query.projectDevice projectDevice:this.$route.query.projectDevice,
type: this.$route.query.type
}; };
if (config) { if (config) {
if (config.client) { query.client = config.client; } if (config.client) { query.client = config.client; }

View File

@ -21,7 +21,7 @@ import { getSessionStorage } from '@/utils/auth';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import TerminalsPicture from './terminals/index'; import TerminalsPicture from './terminals/index';
import SimulationMenu from './simulationMenu/simulationMenu'; import SimulationMenu from './simulationMenu/simulationMenu';
import { getSimulationInfoNew, destroySimulationByAdmin, exitSimulation } from '@/api/simulation'; import { getSimulationInfoNew } from '@/api/simulation';
import { loadMapDataById, loadRunPlanData } from '@/utils/loaddata'; import { loadMapDataById, loadRunPlanData } from '@/utils/loaddata';
import { getByGroupStationList } from '@/api/jmap/map'; import { getByGroupStationList } from '@/api/jmap/map';
import { EventBus } from '@/scripts/event-bus'; import { EventBus } from '@/scripts/event-bus';
@ -134,15 +134,18 @@ export default {
}, },
// //
initLoadData() { initLoadData() {
getSimulationInfoNew(this.group).then(resp => { getSimulationInfoNew(this.group).then(async resp => {
if (resp && resp.data && !resp.data.dataError) { if (resp && resp.data && !resp.data.dataError) {
this.$store.dispatch('runPlan/setRunPlanInfo', resp.data.runPlan); this.$store.dispatch('runPlan/setRunPlanInfo', resp.data.runPlan);
this.$store.dispatch('training/setDomConfig', resp.data.paramVO && resp.data.paramVO.domConfig ? resp.data.paramVO.domConfig : {}); this.$store.dispatch('training/setDomConfig', resp.data.paramVO && resp.data.paramVO.domConfig ? resp.data.paramVO.domConfig : {});
this.$store.dispatch('map/setLinkSwitchMap', resp.data.linkSwitchMap || {}); this.$store.dispatch('map/setLinkSwitchMap', resp.data.linkSwitchMap || {});
loadMapDataById(this.mapId, 'simulation');
if (this.simType === 'METRO') { if (this.simType === 'METRO') {
this.loadRunPlan(); this.$store.dispatch('runPlan/clear');
const respSl = await getByGroupStationList(this.group);
this.$store.dispatch('runPlan/setStations', respSl.data);
await loadRunPlanData(this.group);
} }
await loadMapDataById(this.mapId, 'simulation');
} else { } else {
this.endViewLoading(); this.endViewLoading();
this.$messageBox('此地图数据正在维护中,无法运行!'); this.$messageBox('此地图数据正在维护中,无法运行!');
@ -154,13 +157,6 @@ export default {
this.$message.error('获取仿真信息失败!'); this.$message.error('获取仿真信息失败!');
}); });
}, },
loadRunPlan() {
this.$store.dispatch('runPlan/clear');
getByGroupStationList(this.group).then(resp => {
this.$store.dispatch('runPlan/setStations', resp.data);
loadRunPlanData(this.group);
});
},
// //
endViewLoading() { endViewLoading() {
this.$nextTick(() => { this.$nextTick(() => {

View File

@ -288,7 +288,13 @@ export default {
}, },
tripNumberModify(row) { tripNumberModify(row) {
if (row) { if (row) {
this.$refs.modifyService.doShow({serviceNumber:this.$store.state.runPlan.selected.serviceNumber, tripNumber:row.tripNumber}); let serviceNumber;
if (this.loadRunPlanId) {
serviceNumber = this.$store.state.runPlan.draftSelected.serviceNumber;
} else {
serviceNumber = this.$store.state.runPlan.selected.serviceNumber;
}
this.$refs.modifyService.doShow({serviceNumber:serviceNumber, tripNumber:row.tripNumber});
} }
}, },
serviceNumberChange(row) { serviceNumberChange(row) {

View File

@ -405,7 +405,7 @@ export default {
this.destroy(); this.destroy();
let startValue = 3600 + this.PlanParser.getTranslation(); let startValue = 3600 + this.PlanParser.getTranslation();
const offsetTime = 3600; const offsetTime = 3600;
const initTime = toTimeStamp(formatDuring(this.$store.state.socket.simulationTimeSync)); const initTime = toTimeStamp(formatDuring(this.$store.state.socket.simulationTimeSync | 0));
startValue = initTime - this.PlanParser.getTranslation(); startValue = initTime - this.PlanParser.getTranslation();
option.dataZoom[0].startValue = option.dataZoom[1].startValue = startValue - offsetTime; option.dataZoom[0].startValue = option.dataZoom[1].startValue = startValue - offsetTime;
option.dataZoom[0].endValue = option.dataZoom[1].endValue = startValue + offsetTime; option.dataZoom[0].endValue = option.dataZoom[1].endValue = startValue + offsetTime;

View File

@ -1007,21 +1007,21 @@ export default {
deviceCode: '' deviceCode: ''
}; };
memberMap[this.generationForm.systemType].push(memberDispatcher); memberMap[this.generationForm.systemType].push(memberDispatcher);
const memberNccDispatcher = {
id: this.getMemberId(this.generationForm.systemType),
name: '',
type: 'NCC_DISPATCHER',
deviceCode: ''
};
memberMap[this.generationForm.systemType].push(memberNccDispatcher);
const memberOccDispatcher = {
id: this.getMemberId(this.generationForm.systemType),
name: '',
type: 'OCC_DISPATCHER',
deviceCode: ''
};
memberMap[this.generationForm.systemType].push(memberOccDispatcher);
} }
const memberNccDispatcher = {
id: this.getMemberId(this.generationForm.systemType),
name: '',
type: 'NCC_DISPATCHER',
deviceCode: ''
};
memberMap[this.generationForm.systemType].push(memberNccDispatcher);
const memberOccDispatcher = {
id: this.getMemberId(this.generationForm.systemType),
name: '',
type: 'OCC_DISPATCHER',
deviceCode: ''
};
memberMap[this.generationForm.systemType].push(memberOccDispatcher);
this.stationList.forEach(station => { this.stationList.forEach(station => {
if (!station.depot) { if (!station.depot) {
const member = { const member = {

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<div class="flex_box"> <div class="flex_box">
<el-button type="primary" @click="create">{{ $t('map.createSwitch') }}</el-button> <el-button type="primary" @click="createSwitch">{{ $t('map.createSwitch') }}</el-button>
<el-button type="error" @click="deleteSwitch">一键删除道岔</el-button> <el-button type="error" @click="deleteSwitch">一键删除道岔</el-button>
</div> </div>
</div> </div>
@ -21,248 +21,248 @@ export default {
]) ])
}, },
methods:{ methods:{
create() { // // create() { //
const createArr = []; // model // const createArr = []; // model
// const changeSectionLists = []; // // const changeSectionLists = [];
// const changeSectionList = this.changeSectionsAttr(); // // // const changeSectionList = this.changeSectionsAttr(); //
const changeSectionList = this.changeSectionAttr(); // // const changeSectionList = this.changeSectionAttr(); //
changeSectionList.forEach(section => { // changeSectionList.forEach(section => {
if (section['typeModel'] && section['typeModel'] == 'start') { // // if (section['typeModel'] && section['typeModel'] == 'start') { //
const list = this.findSectionA(section.points[section.points.length - 1].x, section.points[section.points.length - 1].y, changeSectionList, section.code); // const list = this.findSectionA(section.points[section.points.length - 1].x, section.points[section.points.length - 1].y, changeSectionList, section.code);
let sectionB = {}; // let sectionB = {};
let sectionC = {}; // let sectionC = {};
if (list.length >= 2) { // if (list.length >= 2) {
list.forEach(item => { // list.forEach(item => {
let sectionEnd; // let sectionEnd;
if (this.handleResetPoint(item.points)) { // if (this.handleResetPoint(item.points)) {
sectionEnd = item.points.length == 2 ? item.points[item.points.length - 1] : item.points[1]; // sectionEnd = item.points[1];
} else { // } else {
sectionEnd = item.points.length == 2 ? item.points[0] : item.points[item.points.length - 2]; // sectionEnd = item.points.length == 2 ? item.points[0] : item.points[item.points.length - 2];
} // }
if ((sectionEnd.y == section.points[section.points.length - 1].y) || (sectionEnd.x == section.points[section.points.length - 1].x)) { // // if ((sectionEnd.y == section.points[section.points.length - 1].y) || (sectionEnd.x == section.points[section.points.length - 1].x)) { //
sectionB = item; // sectionB = item;
} else { // } else {
sectionC = item; // sectionC = item;
} // }
}); // });
if (section.code && sectionB.code && sectionC.code) { // if (section.code && sectionB.code && sectionC.code) {
const uname = 'W' + section.name.replace('T', ''); // const uname = 'W' + section.name.replace('T', '');
const switchModel = getModel('Switch'); // const switchModel = getModel('Switch');
let intersection; // let intersection;
if (this.handleResetPoint(section.points)) { // if (this.handleResetPoint(section.points)) {
intersection = section.points.length == 2 ? section.points[section.points.length - 1] : section.points[1]; // intersection = section.points[1];
} else { // } else {
intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2]; // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
} // }
let skew; // let skew;
if (this.handleResetPoint(sectionC.points)) { // if (this.handleResetPoint(sectionC.points)) {
skew = sectionC.points[sectionC.points.length - 1]; // skew = sectionC.points[sectionC.points.length - 1];
} else { // } else {
skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2]; // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
} // }
const data = { // const data = {
code: getUID('W', [...this.switchList, ...createArr]), // code: getUID('W', [...this.switchList, ...createArr]),
name: uname, // name: uname,
nameShow: true, // nameShow: true,
timeoutShow: true, // timeoutShow: true,
sectionACode: section.code, // sectionACode: section.code,
sectionBCode: sectionB.code, // sectionBCode: sectionB.code,
sectionCCode: sectionC.code, // sectionCCode: sectionC.code,
turnTime: 3, // turnTime: 3,
intersection: { // intersection: {
x: intersection.x, // x: intersection.x,
y: intersection.y // y: intersection.y
}, // },
skew: { // skew: {
x: skew.x, // x: skew.x,
y: skew.y // y: skew.y
}, // },
pos: 'N', // // pos: 'N', //
// N- R- NO-() EX- // // N- R- NO-() EX-
throat: '' // throat: ''
}; // };
const model = Object.assign(switchModel, data); // const model = Object.assign(switchModel, data);
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode); // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
!swch && createArr.push(model); // // !swch && createArr.push(model); //
} // }
} // }
} // }
if (section['typeModel'] && section['typeModel'] == 'end') { // // if (section['typeModel'] && section['typeModel'] == 'end') { //
const list = this.findSectionB(section.points[0].x, section.points[0].y, changeSectionList, section.code); // const list = this.findSectionB(section.points[0].x, section.points[0].y, changeSectionList, section.code);
let sectionB = {}; // let sectionB = {};
let sectionC = {}; // let sectionC = {};
if (list.length >= 2) { // if (list.length === 2) {
list.forEach(item => { // list.forEach(item => {
let sectionStart; // let sectionStart;
if (this.handleResetPoint(item.points)) { // if (this.handleResetPoint(item.points)) {
sectionStart = item.points.length == 2 ? item.points[0] : item.points[item.points.length - 2]; // sectionStart = item.points.length == 2 ? item.points[0] : item.points[item.points.length - 2];
} else { // } else {
sectionStart = item.points.length == 2 ? item.points[item.points.length - 1] : item.points[1]; // sectionStart = item.points[1];
} // }
const dy = section.points[1].y - section.points[0].y; // const dy = section.points[1].y - section.points[0].y;
const dx = section.points[1].x - section.points[0].x; // const dx = section.points[1].x - section.points[0].x;
const startDx = sectionStart.x - section.points[0].x; // const startDx = sectionStart.x - section.points[0].x;
const startDy = sectionStart.y - section.points[0].y; // const startDy = sectionStart.y - section.points[0].y;
if ((sectionStart.y == section.points[0].y) || (sectionStart.x == section.points[0].x) || // if ((sectionStart.y == section.points[0].y) || (sectionStart.x == section.points[0].x) ||
(dy * startDx == dx * startDy)) { // // (dy * startDx == dx * startDy)) { //
sectionB = item; // sectionB = item;
} else { // } else {
sectionC = item; // sectionC = item;
} // }
}); // });
if (section.code && sectionB.code && sectionC.code) { // if (section.code && sectionB.code && sectionC.code) {
const uname = 'W' + section.name.replace('T', ''); // const uname = 'W' + section.name.replace('T', '');
const switchModel = getModel('Switch'); // const switchModel = getModel('Switch');
let intersection; // let intersection;
if (this.handleResetPoint(section.points)) { // if (this.handleResetPoint(section.points)) {
intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 1]; // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 1];
} else { // } else {
intersection = section.points.length == 2 ? section.points[section.points.length - 1] : section.points[0]; // intersection = section.points.length == 2 ? section.points[section.points.length - 1] : section.points[0];
} // }
let skew; // let skew;
if (this.handleResetPoint(sectionC.points)) { // if (this.handleResetPoint(sectionC.points)) {
skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2]; // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
} else { // } else {
skew = sectionC.points[sectionC.points.length - 1]; // skew = sectionC.points[sectionC.points.length - 1];
} // }
const data = { // const data = {
code: getUID('W', [...this.switchList, ...createArr]), // code: getUID('W', [...this.switchList, ...createArr]),
name: uname, // name: uname,
nameShow: true, // nameShow: true,
timeoutShow: true, // timeoutShow: true,
sectionACode: section.code, // sectionACode: section.code,
sectionBCode: sectionB.code, // sectionBCode: sectionB.code,
sectionCCode: sectionC.code, // sectionCCode: sectionC.code,
turnTime: 3, // turnTime: 3,
intersection: { // intersection: {
x: intersection.x, // x: intersection.x,
y: intersection.y // y: intersection.y
}, // },
skew: { // skew: {
x: skew.x, // x: skew.x,
y: skew.y // y: skew.y
}, // },
pos: 'N', // // pos: 'N', //
// N- R- NO-() EX- // // N- R- NO-() EX-
throat: '' // throat: ''
}; // };
const model = Object.assign(switchModel, data); // const model = Object.assign(switchModel, data);
const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode); // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
!swch && createArr.push(model); // // !swch && createArr.push(model); //
} // }
} // }
// if (item['typeModel'] == 'start') { // // // if (item['typeModel'] == 'start') { //
// const section = item.A; // // const section = item.A;
// const sectionB = item.B; // // const sectionB = item.B;
// const sectionC = item.C; // // const sectionC = item.C;
// if (section.code && sectionB.code && sectionC.code) { // // if (section.code && sectionB.code && sectionC.code) {
// const uname = 'W' + section.name.replace('T', ''); // // const uname = 'W' + section.name.replace('T', '');
// const switchModel = getModel('Switch'); // // const switchModel = getModel('Switch');
// let intersection; // // let intersection;
// if (this.handleResetPoint(section.points)) { // // if (this.handleResetPoint(section.points)) {
// intersection = section.points[section.points.length - 1]; // // intersection = section.points[section.points.length - 1];
// } else { // // } else {
// intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2]; // // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
// } // // }
// let skew; // // let skew;
// if (this.handleResetPoint(sectionC.points)) { // // if (this.handleResetPoint(sectionC.points)) {
// skew = sectionC.points[sectionC.points.length - 1]; // // skew = sectionC.points[sectionC.points.length - 1];
// } else { // // } else {
// skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2]; // // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
// } // // }
// const data = { // // const data = {
// code: getUID('W', [...this.switchList, ...createArr]), // // code: getUID('W', [...this.switchList, ...createArr]),
// name: uname, // // name: uname,
// nameShow: true, // // nameShow: true,
// timeoutShow: true, // // timeoutShow: true,
// sectionACode: section.code, // // sectionACode: section.code,
// sectionBCode: sectionB.code, // // sectionBCode: sectionB.code,
// sectionCCode: sectionC.code, // // sectionCCode: sectionC.code,
// turnTime: 3, // // turnTime: 3,
// intersection: { // // intersection: {
// x: intersection.x, // // x: intersection.x,
// y: intersection.y // // y: intersection.y
// }, // // },
// skew: { // // skew: {
// x: skew.x, // // x: skew.x,
// y: skew.y // // y: skew.y
// }, // // },
// normalPosition: 1 // // // normalPosition: 1 //
// }; // // };
// const model = Object.assign(switchModel, data); // // const model = Object.assign(switchModel, data);
// const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode); // // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
// !swch && createArr.push(model); // // // !swch && createArr.push(model); //
// } // // }
// } // // }
// if (item['typeModel'] == 'end') { // // // if (item['typeModel'] == 'end') { //
// const section = item.A; // // const section = item.A;
// const sectionB = item.B; // // const sectionB = item.B;
// const sectionC = item.C; // // const sectionC = item.C;
// if (section.code && sectionB.code && sectionC.code) { // // if (section.code && sectionB.code && sectionC.code) {
// const uname = 'W' + section.name.replace('T', ''); // // const uname = 'W' + section.name.replace('T', '');
// const switchModel = getModel('Switch'); // // const switchModel = getModel('Switch');
// let intersection; // // let intersection;
// if (this.handleResetPoint(section.points)) { // // if (this.handleResetPoint(section.points)) {
// intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2]; // // intersection = section.points.length == 2 ? section.points[0] : section.points[section.points.length - 2];
// } else { // // } else {
// intersection = section.points[section.points.length - 1]; // // intersection = section.points[section.points.length - 1];
// } // // }
// let skew; // // let skew;
// if (this.handleResetPoint(sectionC.points)) { // // if (this.handleResetPoint(sectionC.points)) {
// skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2]; // // skew = sectionC.points.length == 2 ? sectionC.points[0] : sectionC.points[sectionC.points.length - 2];
// } else { // // } else {
// skew = sectionC.points[sectionC.points.length - 1]; // // skew = sectionC.points[sectionC.points.length - 1];
// } // // }
// const data = { // // const data = {
// code: getUID('W', [...this.switchList, ...createArr]), // // code: getUID('W', [...this.switchList, ...createArr]),
// name: uname, // // name: uname,
// nameShow: true, // // nameShow: true,
// timeoutShow: true, // // timeoutShow: true,
// sectionACode: section.code, // // sectionACode: section.code,
// sectionBCode: sectionB.code, // // sectionBCode: sectionB.code,
// sectionCCode: sectionC.code, // // sectionCCode: sectionC.code,
// turnTime: 3, // // turnTime: 3,
// intersection: { // // intersection: {
// x: intersection.x, // // x: intersection.x,
// y: intersection.y // // y: intersection.y
// }, // // },
// skew: { // // skew: {
// x: skew.x, // // x: skew.x,
// y: skew.y // // y: skew.y
// }, // // },
// normalPosition: 1 // // // normalPosition: 1 //
// }; // // };
// const model = Object.assign(switchModel, data); // // const model = Object.assign(switchModel, data);
// const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode); // // const swch = this.findSwitchData(model.sectionACode, model.sectionBCode, model.sectionCCode);
// !swch && createArr.push(model); // // // !swch && createArr.push(model); //
// } // // }
// } // // }
} // }
}); // });
this.$confirm(this.$t('tip.confirmBatchGeneration'), this.$t('tip.hint'), { // this.$confirm(this.$t('tip.confirmBatchGeneration'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'), // confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'), // cancelButtonText: this.$t('tip.cancel'),
type: 'warning' // type: 'warning'
}).then((res) => { // }).then((res) => {
const modelsList = this.createSwitchSection(createArr, changeSectionList); // const modelsList = this.createSwitchSection(createArr, changeSectionList);
modelsList.forEach(item => { // modelsList.forEach(item => {
createArr.push(item); // createArr.push(item);
}); // });
this.$emit('updateMapModel', createArr); // this.$emit('updateMapModel', createArr);
}).catch((error) => { // }).catch((error) => {
this.$message( this.$t('tip.cancelGeneration')); // this.$message( this.$t('tip.cancelGeneration'));
}); // });
}, // },
findArr(arr) { // findArr(arr) {
if (arr[0].slope !== arr[1].slope && arr[0].slope !== arr[2].slope) { // if (arr[0].slope !== arr[1].slope && arr[0].slope !== arr[2].slope) {
return arr[0]; // return arr[0];
} // }
for (var i = 0, len = arr.length; i < len; i++) { // for (var i = 0, len = arr.length; i < len; i++) {
if (arr[i].slope !== arr[0].slope) { // if (arr[i].slope !== arr[0].slope) {
return arr[i]; // return arr[i];
} // }
} // }
}, // },
// //
// changeSectionsAttr() { // changeSectionsAttr() {
// const pointMap = {}; // const pointMap = {};
@ -379,48 +379,48 @@ export default {
// var BC = Math.sqrt(Math.pow(B.x - C.x, 2) + Math.pow(B.y - C.y, 2)); // var BC = Math.sqrt(Math.pow(B.x - C.x, 2) + Math.pow(B.y - C.y, 2));
// return Math.pow(AB, 2) + Math.pow(BC, 2) > Math.pow(AC, 2); // return Math.pow(AB, 2) + Math.pow(BC, 2) > Math.pow(AC, 2);
// }, // },
findSectionA(pointX, pointY, lists, code) { // findSectionA(pointX, pointY, lists, code) {
const list = []; // const list = [];
lists.forEach(item => { // lists.forEach(item => {
if (item.code != code) { // if (item.code != code) {
if (this.handleResetPoint(item.points)) { // if (this.handleResetPoint(item.points)) {
if (item.points[0].x == pointX && item.points[0].y == pointY) { // if (item.points[0].x == pointX && item.points[0].y == pointY) {
list.push(item); // list.push(item);
} // }
} else { // } else {
if (item.points[item.points.length - 1].x == pointX && item.points[item.points.length - 1].y == pointY) { // if (item.points[item.points.length - 1].x == pointX && item.points[item.points.length - 1].y == pointY) {
list.push(item); // list.push(item);
} // }
} // }
} // }
}); // });
return list; // return list;
}, // },
findSectionB(pointX, pointY, lists, code) { // findSectionB(pointX, pointY, lists, code) {
const list = []; // const list = [];
lists.forEach(item => { // lists.forEach(item => {
if (item.code != code) { // if (item.code != code) {
if (this.handleResetPoint(item.points)) { // if (this.handleResetPoint(item.points)) {
if (item.points[item.points.length - 1].x == pointX && item.points[item.points.length - 1].y == pointY) { // if (item.points[item.points.length - 1].x == pointX && item.points[item.points.length - 1].y == pointY && list.findIndex(elem => elem.code === item.code) === -1) {
list.push(item); // list.push(item);
} // }
} else { // } else {
if (item.points[0].x == pointX && item.points[0].y == pointY) { // if (item.points[0].x == pointX && item.points[0].y == pointY && list.findIndex(elem => elem.code === item.code) === -1) {
list.push(item); // list.push(item);
} // }
} // }
} // }
}); // });
return list; // return list;
}, // },
findSwitchData(sectionACode, sectionBCode, sectionCCode) { findSwitchData(sectionACode, sectionBCode, sectionCCode) {
var rtn = null; var rtn = null;
var switchList = this.switchList; var switchList = this.switchList;
if (switchList && switchList.length) { if (switchList && switchList.length) {
for (var i = 0; i < switchList.length; ++i) { for (var i = 0; i < switchList.length; ++i) {
if (sectionACode === switchList[i].sectionACode && if (sectionACode === switchList[i].sectionACode &&
sectionBCode === switchList[i].sectionBCode && sectionBCode === switchList[i].sectionBCode &&
sectionCCode === switchList[i].sectionCCode) { sectionCCode === switchList[i].sectionCCode) {
rtn = switchList[i]; rtn = switchList[i];
break; break;
} }
@ -429,75 +429,239 @@ export default {
return rtn; return rtn;
}, },
// //
handleResetPoint(points) { // handleResetPoint(points) {
return points[points.length - 1].x >= points[points.length - 2].x; // return points[points.length - 1].x >= points[points.length - 2].x;
}, // },
// findSwitchSection() {
changeSectionAttr() { const pointMap = new Map();
const changeSectionList = []; //
this.sectionList.forEach(section => { this.sectionList.forEach(section => {
if (section.type == '01' || section.type == '03') { if (section.type === '01') {
const oneSection = section.points[section.points.length - 1]; const startP = `${section.points[0].x}_${section.points[0].y}`;
const oneSectionStar = section.points[0]; const endP = `${section.points[section.points.length - 1].x}_${section.points[section.points.length - 1].y}`;
let countA = 0; if (pointMap.get(startP)) {
let countB = 0; const value = pointMap.get(startP);
this.sectionList.forEach(elem => { value.count++;
if ((elem.type == '01' || section.type == '03') && section.code != elem.code) { value.sections.push({ device: section, type: 'start' });
let twoSection, twoSectionEnd; } else {
if (this.handleResetPoint(elem.points)) { pointMap.set(startP, { count: 1, sections: [{ device: section, type: 'start' }] });
twoSection = elem.points[0]; }
twoSectionEnd = elem.points[elem.points.length - 1]; if (pointMap.get(endP)) {
} else { const value = pointMap.get(endP);
twoSection = elem.points[elem.points.length - 1]; value.count++;
twoSectionEnd = elem.points[0]; value.sections.push({ device: section, type: 'end' });
} } else {
if (oneSection.x == twoSection.x && oneSection.y == twoSection.y) { pointMap.set(endP, { count: 1, sections: [{device: section, type: 'end'}] });
countA++; }
if (countA >= 2) {
// if (!this.checkAddListA(oneSection, section.code)) { //
const sectionModel = deepAssign({}, section);
sectionModel.rightSectionCode = '';
sectionModel.sepTypeRight = '00'; //
sectionModel.type = '03';
const list = this.findSectionA(sectionModel.points[sectionModel.points.length - 1].x, sectionModel.points[sectionModel.points.length - 1].y, this.sectionList, sectionModel.code);
list.forEach(elem => {
const sectionModelElem = deepAssign({}, elem);
sectionModelElem.leftSectionCode = '';
sectionModelElem.sepTypeLeft = '00';
sectionModelElem.type = '03';
changeSectionList.push(sectionModelElem);
});
sectionModel['typeModel'] = 'start';
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.sepTypeLeft = '00';
sectionModel.type = '03';
const list = this.findSectionB(sectionModel.points[0].x, sectionModel.points[0].y, this.sectionList, sectionModel.code);
list.forEach(elem => {
const sectionModelElem = deepAssign({}, elem);
sectionModelElem.rightSectionCode = '';
sectionModelElem.sepTypeRight = '00'; //
sectionModelElem.type = '03';
changeSectionList.push(sectionModelElem);
});
sectionModel['typeModel'] = 'end';
changeSectionList.push(sectionModel);
// }
}
}
}
});
} }
}); });
return changeSectionList; const switchSectionGroups = [];
pointMap.forEach((value, key) => {
if (value.count === 3) {
const switchSectionGroup = [];
value.sections.forEach(item => {
const sectionModelElem = deepAssign({}, item.device);
sectionModelElem.type = '03';
if (item.type === 'start') {
sectionModelElem.rightSectionCode = '';
sectionModelElem.sepTypeRight = '00';
} else if (item.type === 'end') {
sectionModelElem.leftSectionCode = '';
sectionModelElem.sepTypeLeft = '00';
}
switchSectionGroup.push({ sectionModel:sectionModelElem, type: item.type });
});
switchSectionGroups.push(switchSectionGroup);
}
});
return switchSectionGroups;
}, },
getAngle(x1, y1, x2, y2) {
const dot = x1 * x2 + y1 * y2;
const det = x1 * y2 + x2 * y1;
const angle = Math.atan2(det, dot) / Math.PI * 180;
return (angle + 360) % 360;
},
isLine(p1, p2, p) {
const k1 = ((p2.y - p1.y) / (p2.x - p1.x)).toFixed(3);
const k2 = ((p.y - p1.y) / (p.x - p1.x)).toFixed(3);
const error = Math.abs(k2 - k1);
return error - 0.001 < Number.EPSILON;
},
createSwitch() {
const createArr = []; // model
const changeSectionList = [];
const switchSectionGroups = this.findSwitchSection();
switchSectionGroups.forEach(group => {
let sectionA, sectionB, sectionC;
let skew;
const coreP = group[0].type === 'start' ? group[0].sectionModel.points[0] : group[0].sectionModel.points[group[0].sectionModel.points.length - 1];
const p0 = group[0].type === 'start' ? group[0].sectionModel.points[1] : group[0].sectionModel.points[group[0].sectionModel.points.length - 2];
const p1 = group[1].type === 'start' ? group[1].sectionModel.points[1] : group[1].sectionModel.points[group[1].sectionModel.points.length - 2];
const p2 = group[2].type === 'start' ? group[2].sectionModel.points[1] : group[2].sectionModel.points[group[2].sectionModel.points.length - 2];
if (this.isLine(p0, p1, coreP)) {
sectionC = group[2].sectionModel;
skew = p2;
const angle = this.getAngle(p0.x - coreP.x, p0.y - coreP.y, p2.x - coreP.x, p2.y - coreP.y);
if (angle > 90 && angle < 270) {
sectionA = group[0].sectionModel;
sectionB = group[1].sectionModel;
} else {
sectionA = group[1].sectionModel;
sectionB = group[0].sectionModel;
}
// 线B AC线
if (p2.y === coreP.y) {
sectionC = sectionB;
sectionB = group[2].sectionModel;
skew = angle > 90 && angle < 270 ? p1 : p0;
}
} else if (this.isLine(p1, p2, coreP)) {
sectionC = group[0].sectionModel;
skew = p0;
const angle = this.getAngle(p1.x - coreP.x, p1.y - coreP.y, p0.x - coreP.x, p0.y - coreP.y);
if (angle > 90 && angle < 270) {
sectionA = group[1].sectionModel;
sectionB = group[2].sectionModel;
} else {
sectionA = group[2].sectionModel;
sectionB = group[1].sectionModel;
}
// 线B AC线
if (p0.y === coreP.y) {
sectionC = sectionB;
sectionB = group[0].sectionModel;
skew = angle > 90 && angle < 270 ? p2 : p1;
}
} else if (this.isLine(p0, p2, coreP)) {
sectionC = group[1].sectionModel;
skew = p1;
const angel = this.getAngle(p2.x - coreP.x, p2.y - coreP.y, p1.x - coreP.x, p1.y - coreP.y);
if (angel > 90 && angel < 270) {
sectionA = group[2].sectionModel;
sectionB = group[0].sectionModel;
} else {
sectionA = group[0].sectionModel;
sectionB = group[2].sectionModel;
}
// 线B AC线
if (p1.y === coreP.y) {
sectionC = sectionB;
sectionB = group[1].sectionModel;
skew = angel > 90 && angel < 270 ? p0 : p2;
}
}
if (sectionA && sectionB && sectionC) {
changeSectionList.push(sectionA);
changeSectionList.push(sectionB);
changeSectionList.push(sectionC);
const uname = 'W' + sectionA.name.replace('T', '');
const switchModel = getModel('Switch');
const data = {
code: getUID('W', [...this.switchList, ...createArr]),
name: uname,
nameShow: true,
timeoutShow: true,
sectionACode: sectionA.code,
sectionBCode: sectionB.code,
sectionCCode: sectionC.code,
turnTime: 3,
intersection: {
x: coreP.x,
y: coreP.y
},
skew: {
x: skew.x,
y: skew.y
},
pos: 'N', //
// N- R- NO-() EX-
throat: ''
};
const model = Object.assign(switchModel, data);
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((res) => {
const modelsList = this.createSwitchSection(createArr, changeSectionList);
modelsList.forEach(item => {
createArr.push(item);
});
this.$emit('updateMapModel', createArr);
}).catch(() => {
this.$message( this.$t('tip.cancelGeneration'));
});
},
//
// changeSectionAttr() {
// const changeSectionList = []; //
// this.sectionList.forEach(section => {
// if (section.type == '01' || section.type == '03') {
// const oneSection = section.points[section.points.length - 1];
// const oneSectionStar = section.points[0];
// let countA = 0;
// let countB = 0;
// this.sectionList.forEach(elem => {
// if ((elem.type == '01' || section.type == '03') && section.code != elem.code) {
// let twoSection, twoSectionEnd;
// if (this.handleResetPoint(elem.points)) {
// twoSection = elem.points[0];
// twoSectionEnd = elem.points[elem.points.length - 1];
// } else {
// twoSection = elem.points[elem.points.length - 1];
// twoSectionEnd = elem.points[0];
// }
// 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.sepTypeRight = '00'; //
// sectionModel.type = '03';
// const list = this.findSectionA(sectionModel.points[sectionModel.points.length - 1].x, sectionModel.points[sectionModel.points.length - 1].y, this.sectionList, sectionModel.code);
// list.forEach(elem => {
// const sectionModelElem = deepAssign({}, elem);
// sectionModelElem.leftSectionCode = '';
// sectionModelElem.sepTypeLeft = '00';
// sectionModelElem.type = '03';
// changeSectionList.push(sectionModelElem);
// });
// sectionModel['typeModel'] = 'start';
// 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.sepTypeLeft = '00';
// sectionModel.type = '03';
// const list = this.findSectionB(sectionModel.points[0].x, sectionModel.points[0].y, this.sectionList, sectionModel.code);
// list.forEach(elem => {
// const sectionModelElem = deepAssign({}, elem);
// sectionModelElem.rightSectionCode = '';
// sectionModelElem.sepTypeRight = '00'; //
// sectionModelElem.type = '03';
// changeSectionList.push(sectionModelElem);
// });
// sectionModel['typeModel'] = 'end';
// changeSectionList.push(sectionModel);
// // }
// }
// }
// }
// });
// }
// });
// return changeSectionList;
// },
// checkAddListA(points, code) { // list () // checkAddListA(points, code) { // list ()
// let flag = false; // let flag = false;
// this.sectionList.forEach(section => { // this.sectionList.forEach(section => {
@ -645,8 +809,8 @@ export default {
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.flex_box{ .flex_box{
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
</style> </style>

View File

@ -207,7 +207,7 @@ export default {
getDeviceDetail(row.id).then(res=>{ getDeviceDetail(row.id).then(res=>{
if (res.data) { if (res.data) {
let url = ''; let url = '';
url = `${window.location.protocol}//${window.location.host}/cbtc/login?project=${row.project.toLowerCase().replace(/_/, '')}&projectDevice=${row.code}&type=${row.type}`; url = `${window.location.protocol}//${window.location.host}/cbtc/login?project=${row.project.toLowerCase().replaceAll('_', '')}&projectDevice=${row.code}&type=${row.type}`;
this.url = url; this.url = url;
this.$messageBox(); this.$messageBox();
this.$confirm(`登录路径:${url}`, '登录路径', { this.$confirm(`登录路径:${url}`, '登录路径', {