From 461d64afe1dc4ac55088255b1d5041c5e831cad2 Mon Sep 17 00:00:00 2001 From: lVAL Date: Wed, 24 Feb 2021 18:52:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BF=E8=B7=AF=EF=BC=9A=E5=8D=97=E4=BA=AC2?= =?UTF-8?q?=EF=BC=8C=E5=93=88=E5=B0=94=E6=BB=A8=20=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9A=201.=E7=BB=98=E5=88=B6=E5=93=88=E5=B0=94=E6=BB=A8?= =?UTF-8?q?=E4=BC=A0=E8=BE=93=E4=BF=A1=E5=8F=B7=E6=9C=BA=202.=E5=A4=84?= =?UTF-8?q?=E7=90=86=E4=BC=A0=E8=BE=93=E4=BF=A1=E5=8F=B7=E6=9C=BA=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmapNew/config/skinCode/haerbin_01.js | 7 ++++ src/jmapNew/config/skinCode/nanjing_02.js | 3 +- src/jmapNew/map.js | 5 ++- src/jmapNew/painter.js | 5 +-- src/jmapNew/shape/Arrow/index.js | 4 +- src/jmapNew/shape/Signal/index.js | 10 +++-- .../theme/haerbin_01/menus/menuButton.vue | 25 +++++++---- src/jmapNew/theme/haerbin_01/model.js | 3 +- .../theme/nanjing_02/menus/menuButton.vue | 11 ++++- src/jmapNew/utils/adapter.js | 41 +++++++++++++++++++ src/jmapNew/utils/parser.js | 16 ++++---- src/scripts/cmdPlugin/Handler.js | 3 +- src/scripts/cmdPlugin/MenuContextHandler.js | 4 +- 13 files changed, 103 insertions(+), 34 deletions(-) create mode 100644 src/jmapNew/utils/adapter.js diff --git a/src/jmapNew/config/skinCode/haerbin_01.js b/src/jmapNew/config/skinCode/haerbin_01.js index 5f394e279..e9de33339 100644 --- a/src/jmapNew/config/skinCode/haerbin_01.js +++ b/src/jmapNew/config/skinCode/haerbin_01.js @@ -202,6 +202,13 @@ class SkinCode extends defaultStyle { borderDashColor: '#FFFFFF', // 信号灯按钮边线 buttonColor: 'darkgreen', // 信号灯按钮颜色 buttonLightenColor: '#E4EF50' // 信号灯按钮闪烁颜色 + }, + transmission: { // 传输信号机 + fillColor: '#f00', + fillColorVirtual: '#000080', + sideLength: 20, + textColor: '#fff', + strokeColor: '#00FFFF', }, lowButton:{ display: false // 现地 信号机按钮 diff --git a/src/jmapNew/config/skinCode/nanjing_02.js b/src/jmapNew/config/skinCode/nanjing_02.js index d73799447..4c9f5ab90 100644 --- a/src/jmapNew/config/skinCode/nanjing_02.js +++ b/src/jmapNew/config/skinCode/nanjing_02.js @@ -259,9 +259,10 @@ class SkinCode extends defaultStyle { }, transmission: { // 传输信号机 fillColor: '#f00', + fillColorVirtual: '#000080', sideLength: 20, textColor: '#fff', - strokeColor: '#00FFFF' + strokeColor: '#00FFFF', } }; diff --git a/src/jmapNew/map.js b/src/jmapNew/map.js index 03c2971a0..69a00defb 100644 --- a/src/jmapNew/map.js +++ b/src/jmapNew/map.js @@ -10,6 +10,7 @@ import deviceType from './constant/deviceType'; import { selectLineCode } from './config/deviceStyle'; import { deviceFactory, createBoundingRect, calculateDCenter } from './utils/parser'; import { deepAssign } from '@/utils/index'; +import * as adapter from '@/jmapNew/utils/adapter'; import store from '@/store/index'; import Vue from 'vue'; @@ -615,9 +616,9 @@ class Jlmap { } getShapeTipPoint(opts) { - const device = this.mapDevice[opts.code]; + const device = adapter.adapterByDevice(this.mapDevice[opts.code], this.mapDevice); if (device) { - return this.$painter.getShapeTipPoint(device.instance, opts); + return this.$painter.getShapeTipPoint(device.instance, opts); } } diff --git a/src/jmapNew/painter.js b/src/jmapNew/painter.js index 734f3348f..5f0c5edd2 100644 --- a/src/jmapNew/painter.js +++ b/src/jmapNew/painter.js @@ -223,10 +223,9 @@ class Painter { getShapeTipPoint(instance, opts) { if (instance) { var point = instance.getShapeTipPoint(opts); - if (point) { + if (point) { // 矩阵变换 - var transform = this.$transformHandle.transform; - var transPoint = vector.applyTransform([], [point.x, point.y], transform); + var transPoint = instance.transformCoordToGlobal(point.x, point.y); return { x: transPoint[0], y: transPoint[1] diff --git a/src/jmapNew/shape/Arrow/index.js b/src/jmapNew/shape/Arrow/index.js index f022e4259..8b64f10f5 100644 --- a/src/jmapNew/shape/Arrow/index.js +++ b/src/jmapNew/shape/Arrow/index.js @@ -54,11 +54,11 @@ export default class Arrow extends Group { } setShowStation(stationCode) { if (!stationCode || this.model.stationCode === stationCode) { - this.arrow.show(); + this.show(); this.isShowShape = true; this.setState(this.model); } else { - this.arrow.hide(); + this.hide(); this.isShowShape = false; } } diff --git a/src/jmapNew/shape/Signal/index.js b/src/jmapNew/shape/Signal/index.js index 11e186f44..52e15f274 100644 --- a/src/jmapNew/shape/Signal/index.js +++ b/src/jmapNew/shape/Signal/index.js @@ -22,11 +22,12 @@ import { findDeviceByModelDepType } from '../utils/ShapeDepFind'; // import background from './../../../ibp/shape/background'; class Signal extends Group { - constructor(model, {style}) { + constructor(model, {style, mapDevice}) { super(); this._code = model.code; this._type = model._type; this.model = model; + this.mapDevice = mapDevice; this.style = style; this.count = parseInt(model.lampPositionType); this.lamps = new Array(this.count); @@ -321,10 +322,12 @@ class Signal extends Group { const drict = this.model.right ? 1 : -1; // 朝向 左:右 const posit = this.model.positionType == '01' ? -1 : 1; // 位置 上:下 // 信号机名称 + const actual = this.mapDevice[model.linkSignalCode]; const sigNameX = model.position.x + model.positionPoint.x + drict * 0.433 * style.Signal.transmission.sideLength + model.namePosition.x; const sigNameY = model.position.y + model.positionPoint.y + posit * (style.Signal.distance + style.Section.line.width + style.Signal.lamp.radiusR * 2 + model.namePosition.y + style.Signal.text.distance); const textAlign = style.Signal.text.isAlignCenter ? 'middle' : this.model.right ? 'left' : 'right'; const textVerticalAlign = posit == 1 ? 'top' : 'bottom'; + const fillColor = actual.virtual? style.Signal.transmission.fillColorVirtual: style.Signal.transmission.fillColor; this.sigName = new ESigName({ zlevel: this.zlevel, z: this.z, @@ -353,7 +356,7 @@ class Signal extends Group { ] }, style: { - fill: style.Signal.transmission.fillColor, + fill: fillColor, stroke: style.Signal.transmission.strokeColor, lineWidth: 0 } @@ -850,7 +853,8 @@ class Signal extends Group { default: var drict = this.model.right ? 1 : -1; // 朝向 右:左 var offsetY = this.model.positionType == '01' ? this.style.Signal.text.fontSize : 0; // 位置 上:下 - rect = this.sigPost.getBoundingRect().clone(); + var shape = this.model.type == 'TRANSMISSION'? this.transmission: this.sigPost; + rect = shape.getBoundingRect().clone(); rect.x = rect.x + drict * this.style.Signal.post.standardVerticalWidth; rect.y = rect.y - offsetY; break; diff --git a/src/jmapNew/theme/haerbin_01/menus/menuButton.vue b/src/jmapNew/theme/haerbin_01/menus/menuButton.vue index 9e8fe638a..fb8a24523 100644 --- a/src/jmapNew/theme/haerbin_01/menus/menuButton.vue +++ b/src/jmapNew/theme/haerbin_01/menus/menuButton.vue @@ -139,7 +139,9 @@ import NoticeInfo from '@/jmapNew/theme/components/menus/childDialog/noticeInfo' import CMD from '@/scripts/cmdPlugin/CommandEnum'; import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler'; import { TrainingMode } from '@/scripts/ConstDic'; +import * as adapter from '@/jmapNew/utils/adapter'; import BanIcon from '@/assets/ban-heb.png'; + export default { components: { NoticeInfo @@ -210,6 +212,12 @@ export default { commandId() { return OperationEvent.Command.commandHaerbin.confirm.domId; }, + mapDevice() { + return this.$store.state.map.mapDevice; + }, + actualSelected() { + return adapter.adapterAsDevice(this.selected, this.mapDevice); + }, cr1ConfrimId() { return OperationEvent.Command.commandHaerbin.confrimCr1.domId; }, @@ -226,13 +234,14 @@ export default { '01': 'Local', // 现地工作站 '02': 'Center' // 中心调度工作站 }; + if (this.selected._type) { const control = this.getStationControl(this.selected); const type = State2SimulationMap[this.$store.state.training.prdType]; if (control.controlMode != type) { this.clearAllMenuShow(); if (type == 'Center' && this.selected._type == 'Station') { - this.selectedObj = this.selected; + this.selectedObj = this.actualSelected; if (this.selectedObj._type) { this.canCommand = true; const step = { @@ -256,7 +265,7 @@ export default { return false; } } - this.selectedObj = this.selected; + this.selectedObj = this.actualSelected; this.speedShowCon = false; if (this.selectedObj._type) { if (this.selectedObj._type == 'Section' && (this.selectedObj.type == '03' || this.selectedObj.type == '04')) { // 道岔区段 道岔计轴区段 都是道岔操作 @@ -276,10 +285,10 @@ export default { this.handleSwicthMenu(); break; case 'Signal': - if (this.oldClickObj && this.oldClickObj.code != this.selectedObj.code) { + if (this.oldClickObj && this.oldClickObj.code != this.actualSelected.code) { this.checkSignal(); } else { - this.handleSingalMenu(); + this.handleSignalMenu(); } break; case 'Section': @@ -444,11 +453,11 @@ export default { sectionCode: section.code }; }, - handleSingalMenu() { + handleSignalMenu() { this.clearAllMenuShow(); this.deviceHighLight(this.oldDevice, false); - this.deviceHighLight(this.selectedObj, true); - this.oldDevice = this.selectedObj; + this.deviceHighLight(this.actualSelected, true); + this.oldDevice = this.actualSelected; if (this.oldClickObj) { // 清除上上次信号机背景 this.deviceHighLight(this.oldClickObj, false); } @@ -519,7 +528,7 @@ export default { this.deviceHighLight(this.selectedObj, true); this.oldDevice = this.selectedObj; } else { - this.handleSingalMenu(); + this.handleSignalMenu(); } }, handleSectionMenu() { diff --git a/src/jmapNew/theme/haerbin_01/model.js b/src/jmapNew/theme/haerbin_01/model.js index 43eb8879e..53a250e7f 100644 --- a/src/jmapNew/theme/haerbin_01/model.js +++ b/src/jmapNew/theme/haerbin_01/model.js @@ -33,8 +33,7 @@ class Model { this['private'][deviceType.Signal] = { nameShow: true, // 信号机名称显示 linkageAutoRouteShow: true, // 联锁自动进路表示灯显示 - atsAutoTriggerShow: true, // ATS自动触发表示灯显示 - aliasCodes: [] // 信号机别名列表 + atsAutoTriggerShow: true // ATS自动触发表示灯显示 }; this['private'][deviceType.Train] = { }; diff --git a/src/jmapNew/theme/nanjing_02/menus/menuButton.vue b/src/jmapNew/theme/nanjing_02/menus/menuButton.vue index 95cd8fd2d..d1145b202 100644 --- a/src/jmapNew/theme/nanjing_02/menus/menuButton.vue +++ b/src/jmapNew/theme/nanjing_02/menus/menuButton.vue @@ -225,6 +225,7 @@ import { deepAssign } from '@/utils/index'; import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler'; import { TrainingMode, MouseEvent } from '@/scripts/ConstDic'; import { EventBus } from '@/scripts/event-bus'; +import * as adapter from '@/jmapNew/utils/adapter'; import CMD from '@/scripts/cmdPlugin/CommandEnum'; import BanIcon from '@/assets/ban-heb.png'; @@ -316,6 +317,12 @@ export default { commandId() { return OperationEvent.Command.commandHaerbin.confirm.domId; }, + mapDevice() { + return this.$store.state.map.mapDevice; + }, + actualSelected() { + return adapter.adapterAsDevice(this.selected, this.mapDevice); + }, setDetainTrainId() { return OperationEvent.StationStand.setDetainTrain.menuButton.domId; }, @@ -332,7 +339,7 @@ export default { return OperationEvent.Command.commandHaerbin.confrimCr2.domId; }, stationContorl() { - return this.getStationControl(this.selectedObj || {}) || this.getStationControl({_type: 'Station', code: this.$store.state.map.showCentralizedStationCode}) || {}; + return this.getStationControl(this.selected || {}) || this.getStationControl({_type: 'Station', code: this.$store.state.map.showCentralizedStationCode}) || {}; }, isLocal() { return this.$store.state.training.prdType == '01'; @@ -357,7 +364,7 @@ export default { 'selected': function (val) { EventBus.$emit('sendMsg', {}); // 清空执行栏 this.initMenus();// 初始化菜单数据 - this.selectedObj = this.selected; + this.selectedObj = this.actualSelected; this.rightClickDialogVisible = false; if (this.selectedObj._type && (val._event == MouseEvent.Left || (val._event == MouseEvent.Right && this.$store.state.training.prdType === '01'))) { const type = this.State2SimulationMap[this.$store.state.training.prdType]; diff --git a/src/jmapNew/utils/adapter.js b/src/jmapNew/utils/adapter.js new file mode 100644 index 000000000..666bf9d2a --- /dev/null +++ b/src/jmapNew/utils/adapter.js @@ -0,0 +1,41 @@ +import deviceType from '../constant/deviceType'; + +// 默认策略 +function executeStrategy(strategy, value) { return strategy? strategy(): value }; + +// 适配转换虚拟设备为正式设备 +export function adapterAsDevice(device, mapDevice) { + if (!device) return device; + const strategyMap = { + [deviceType.Signal]: _ => { + return device.type == 'TRANSMISSION'? mapDevice[device.linkSignalCode]: device; + } + } + + return executeStrategy(strategyMap[device._type], device); +} + +// 获取当前可显示适配设备 +export function adapterByDevice(device, mapDevice) { + if (!device) return device; + + const strategyMap = { + [deviceType.Signal]: _ => { + if (device.aliasCodes) { + for(var code of device.aliasCodes) { + let it = mapDevice[code]; + if (it && + it.type == 'TRANSMISSION' && + it.instance && + it.instance.isShowShape) { + console.log(it.instance); + return it; + } + } + } + return device; + } + } + + return executeStrategy(strategyMap[device._type], device); +} diff --git a/src/jmapNew/utils/parser.js b/src/jmapNew/utils/parser.js index 600cf4d87..890692fc3 100644 --- a/src/jmapNew/utils/parser.js +++ b/src/jmapNew/utils/parser.js @@ -284,14 +284,14 @@ export function parser(data, skinCode, showConfig) { }); // 二次处理 - // zrUtil.each(data.stationStandList || [], elem => { - // const device = mapDevice[elem.code]; - // if (device.aliasCodes) { - // // 信号机别名列表 - // device - // } - // mapDevice[elem.code] = createDevice(deviceType.StationStand, elem, propConvert, showConfig); - // }, this); + zrUtil.each(data.signalList || [], elem => { + const actual = mapDevice[elem.linkSignalCode]; + if (actual && elem.type == 'TRANSMISSION') { + // 信号机别名列表 + if (!actual.aliasCodes) { actual.aliasCodes = []; } + actual.aliasCodes.push(elem.code); + } + }, this); } return mapDevice; diff --git a/src/scripts/cmdPlugin/Handler.js b/src/scripts/cmdPlugin/Handler.js index 94808dd71..23bd42953 100644 --- a/src/scripts/cmdPlugin/Handler.js +++ b/src/scripts/cmdPlugin/Handler.js @@ -37,8 +37,7 @@ class Handler { const basicInfo = store.getters['training/basicInfo']; if (basicInfo.id && valid) { const group = router.currentRoute.query.group; - const order = this.getOrder(); - sendTrainingNextStepNew(basicInfo.id, {...operation, order}, group).then(res=>{ + sendTrainingNextStepNew(basicInfo.id, operation, group).then(res=>{ if (!valid) { this.pop(); } else if (operation.cancel === true) { diff --git a/src/scripts/cmdPlugin/MenuContextHandler.js b/src/scripts/cmdPlugin/MenuContextHandler.js index 68344af97..64dd67de4 100644 --- a/src/scripts/cmdPlugin/MenuContextHandler.js +++ b/src/scripts/cmdPlugin/MenuContextHandler.js @@ -71,12 +71,14 @@ class MenuContextHandler { if (type) { menu = [...menuList[type]]; } - // 特殊处理站台的右键操作( 因为小站台不允许有操作 ) + + // 特殊处理站台的右键操作( 因为小站台不允许有操作 ) if (selected._type == 'StationStand') { if (selected.small) { menu = []; } } + if (menu.constructor === Array) { menu.forEach(elem => { if (elem.children && elem.children.length > 0) {