From d65f7fb3345662f3f1077f93e9e21d11314a84f6 Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Tue, 30 Jul 2019 13:29:54 +0800 Subject: [PATCH] =?UTF-8?q?desc:=20=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 2 - src/jmap/map.js | 388 ------------------ src/scripts/attribute.js | 101 ++++- src/store/modules/map.js | 10 +- src/styles/element-ui.scss | 3 + src/views/map/mapdraft/mapedit/index.vue | 2 + .../mapedit/mapoperate/config/list.vue | 15 +- .../map/mapdraft/mapedit/mapoperate/link.vue | 203 +++++---- .../mapdraft/mapedit/mapoperate/section.vue | 150 +++++-- .../mapdraft/mapedit/mapoperate/signal.vue | 85 +++- .../mapdraft/mapedit/mapoperate/station.vue | 60 ++- .../mapedit/mapoperate/stationcontrol.vue | 119 +++--- .../mapedit/mapoperate/stationstand.vue | 156 ++----- .../mapdraft/mapedit/mapoperate/switch.vue | 60 ++- 14 files changed, 598 insertions(+), 756 deletions(-) delete mode 100644 src/jmap/map.js diff --git a/.eslintrc.js b/.eslintrc.js index 94bda2b8f..8a6e863bc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,7 +10,6 @@ module.exports = { es6: true, }, extends: ['plugin:vue/recommended', 'eslint:recommended'], - // add your custom rules here //it is base on https://github.com/vuejs/eslint-config-vue rules: { "vue/max-attributes-per-line": [2, { @@ -43,7 +42,6 @@ module.exports = { 'curly': [2, 'multi-line'], 'dot-location': [2, 'property'], 'eol-last': 2, - // 'eqeqeq': ["error", "always", { "null": "ignore" }], // 全等 'generator-star-spacing': [2, { 'before': true, 'after': true diff --git a/src/jmap/map.js b/src/jmap/map.js deleted file mode 100644 index 4adc612fa..000000000 --- a/src/jmap/map.js +++ /dev/null @@ -1,388 +0,0 @@ -import * as zrUtil from 'zrender/src/core/util'; -import zrender from 'zrender'; -import localStore from 'storejs'; -import Painter from './painter'; -import Options from './options'; -import MouseController from './mouseController'; -import deviceState from './constant/deviceState'; -import { selectSkinStyle } from './config/deviceStyle'; -import deviceType from './constant/deviceType'; -import { parser, deviceFactory, createBoundingRect, calculateDCenter } from './utils/parser'; - -const renderer = 'canvas'; -const devicePixelRatio = 1; - -class Jlmap { - constructor(opts) { - // 回调事件 - this.methods = opts.methods; - - // 鼠标事件 - this.events = { __Pan: 'pan', __Zoom: 'zoom', Selected: 'selected', Contextmenu: 'contextmenu', DataZoom: 'dataZoom'}; - - // 原始数据 - this.data = {}; - - // 皮肤参数 - this.skinStyle = ''; - - // 皮肤风格 - this.styleDict = {}; - - // 设备数据 - this.mapDevice = {}; - - // 默认状态 - this.defaultStateDict = this.loadDefaultState(); - - this.initMapInstance(opts); - } - - // 初始化属性有鼠标事件 缩放等 - initMapInstance(opts) { - const width = opts.dom.clientWidth; - const height = opts.dom.clientHeight; - - this.$zr = zrender.init(opts.dom, Object.assign({ renderer, devicePixelRatio, width, height }, opts.config)); - - this.$options = new Options(Object.assign({ scaleRate: 1, offsetX: 0, offsetY: 0 }, opts.options || {}), (dataZoom) => { this.$mouseController.trigger(this.events.DataZoom, dataZoom); }); // 缩放 - this.$painter = new Painter(this); - this.$painter.updateZrSize({width: this.$zr.getWidth(), height: this.$zr.getHeight()}); - this.$painter.updateTransform(this.$options); - - this.optionsHandler = this.setOptions.bind(this); - - this.$mouseController = new MouseController(this); - this.$mouseController.enable(); - - this.$mouseController.on(this.events.__Pan, this.optionsHandler); - this.$mouseController.on(this.events.__Zoom, this.optionsHandler); - } - - loadStyle(skinStyle) { - return selectSkinStyle(skinStyle); - } - - loadDefaultState() { - const defaultStateDict = {}; - - zrUtil.each(Object.keys(deviceState), (type) => { - defaultStateDict[type] = {}; - zrUtil.each(Object.keys(deviceState[type] || {}), (state) => { - defaultStateDict[type][state] = deviceState[type][state].Default; - }, this); - }, this); - - return defaultStateDict; - } - - setMap(map) { - // 保存皮肤类型 - if (map.skinVO) { - this.skinStyle = map.skinVO.code; - } - - // 保存原始数据 - this.data = map; - - // 加载对应皮肤 - this.styleDict = this.loadStyle(this.skinStyle); - - // 解析地图数据 - this.mapDevice = parser(map, this); - - // 数据加载完成 回调 - if (this.methods.dataLoaded instanceof Function) { this.methods.dataLoaded(this.mapDevice); } - - // 初次渲染视图 - this.$painter.repaint(this.mapDevice); - - // 视图加载完成 回调 - if (this.methods.viewLoaded instanceof Function) { this.methods.viewLoaded(this.mapDevice); } - - } - - setDefaultState() { - const list = []; - - Object.values(this.mapDevice).forEach(elem => { - const code = elem._code; - const type = elem._type; - // 列车不需要设置默认状态 - type != deviceType.Train && list.push(Object.assign({ code, type }, this.defaultStateDict[type])); - }); - - this.update(list); - - if (this.methods.stateLoaded instanceof Function) { this.methods.stateLoaded(list); } - } - - setOptions(opts) { - const options = this.pullBack(opts); - this.$options.update(options); - this.$painter.updateTransform(this.$options); - - if (this.$options.disabled == true) { - this.$mouseController.disable(); - } else { - this.$mouseController.enable(opts); - } - - if (this.methods.optionsUpdate instanceof Function) { this.methods.optionsUpdate(this.$options); } - } - - setCenter(deviceCode) { - const device = this.mapDevice[deviceCode]; - if (device && device.instance) { - var rect = createBoundingRect(device.instance); - var dcenter = calculateDCenter(rect, { width: this.$zr.getWidth(), height: this.$zr.getHeight() }); - this.setOptions(dcenter); - } - } - - setLayerVisible(layer) { - this.$painter.setLayerVisible(layer); - } - - setLevelVisible(list, show) { - this.$painter.setLevelVisible(list, show); - } - - render(list) { - (list || []).forEach(elem => { - const type = elem.type; - const code = elem.code; - const oDevice = this.mapDevice[code] || deviceFactory(type, this.styleDict[type], elem); - const nDevice = Object.assign(oDevice || {}, elem); - this.dataSync(nDevice, nDevice._dispose, !this.mapDevice[code]); - this.$painter.delete(oDevice); - if (!elem._dispose) { - this.mapDevice[code] = nDevice; - this.$painter.add(nDevice); - } - }); - - if (this.methods.viewUpdate instanceof Function) { this.methods.viewUpdate(list); } - } - - // 中间处理 - hookHandle(elem) { - // 如果是延时计时,需要保存计数值到全局 - if (elem._type === deviceType.StationCounter) { - let val = '' + elem.val; - if (val === '0' || !elem.val) { - val = elem.val = localStore.get(elem._code) || '0'; - } - - localStore(elem._code, val); - } - - return elem; - } - - // 后处理 - postHandle(list) { - list.forEach(elem => { - if (elem._type == deviceType.Switch) { - const item = this.mapDevice[elem.code]; - if (item) { - const sectionA = this.mapDevice[item.sectionACode]; - const sectionB = this.mapDevice[item.sectionBCode]; - const sectionC = this.mapDevice[item.sectionCCode]; - if (sectionA && sectionB && sectionC) { - item['cutOff'] = sectionA.cutOff; - item['sectionAstatus'] = sectionA.status; - item['sectionBstatus'] = sectionB.status; - item['sectionCstatus'] = sectionC.status; - } - } - - this.$painter.update(item); - } - - if (elem._type == deviceType.Section) { - const item = this.mapDevice[elem.code]; - if (item) { - const swch = this.mapDevice[item.relSwitchCode]; - if (swch) { - const sectionA = this.mapDevice[swch.sectionACode]; - const sectionB = this.mapDevice[swch.sectionBCode]; - const sectionC = this.mapDevice[swch.sectionCCode]; - if (sectionA && sectionB && sectionC) { - swch['sectionAstatus'] = sectionA.status; - swch['sectionBstatus'] = sectionB.status; - swch['sectionCstatus'] = sectionC.status; - } - - this.$painter.update(swch); - } - } - } - }); - } - - update(list) { - (list || []).forEach(elem => { - const code = elem.code; - const oDevice = this.mapDevice[code] || {}; - if (elem._dispose) { - this.$painter.delete(oDevice); - } else { - const nDevice = Object.assign(oDevice, this.hookHandle(elem)); - this.$painter.update(nDevice); - } - }); - - // 状态后处理 - this.postHandle(list); - - if (this.methods.stateUpdate instanceof Function) { this.methods.stateUpdate(list); } - } - - pullBack(payload) { - if (payload.type === 'zoom') { - const zrWidth = this.$zr.getWidth(); - const zrHeight = this.$zr.getHeight(); - const originX = payload.originX || zrWidth / 2; - const originY = payload.originY || zrHeight / 2; - const x = (this.$options.offsetX + originX) / this.$options.scaleRate; - const y = (this.$options.offsetY + originY) / this.$options.scaleRate; - const newScaleRate = this.$options.getScaleRate(payload.scale); - const dx = originX - (x * newScaleRate - this.$options.offsetX); - const dy = originY - (y * newScaleRate - this.$options.offsetY); - payload.dx = dx; - payload.dy = dy; - } - - return payload || {}; - } - - dataSync(model, isDel, isAdd) { - const code = model.code; - const type = model.type; - - let prop = null; - switch (type) { - case deviceType.Link: prop = 'linkList'; break; - case deviceType.Sction: prop = 'sectionList'; break; - case deviceType.Switch: prop = 'switchList'; break; - case deviceType.Signal: prop = 'signalList'; break; - case deviceType.Station: prop = 'stationList'; break; - case deviceType.StationStand: prop = 'stationStandList'; break; - case deviceType.StationControl: prop = 'stationControlList'; break; - case deviceType.StationCounter: prop = 'stationCounterList'; break; - case deviceType.ZcControl: prop = 'zcControlList'; break; - case deviceType.StationDelayUnlock: prop = 'stationDelayUnlockList'; break; - case deviceType.LcControl: prop = 'lcControlList'; break; - case deviceType.LimitControl: prop = 'tempSpeedLimitList'; break; - case deviceType.ImageControl: prop = 'imageControl'; break; - case deviceType.Train: prop = 'trainList'; break; - case deviceType.TrainWindow: prop = 'trainWindowList'; break; - case deviceType.Line: prop = 'lineList'; break; - case deviceType.Text: prop = 'textList'; break; - } - - const list = this.data[prop]; - if (list) { - if (isAdd) { - list.push(model); - } - if (isDel) { - const idex = list.findIndex(elem => { return elem.code == code; }); - if (idex >= 0) { - list.splice(idex, 1); - } - } - } - } - - getZr() { - return this.$zr; - } - - getEvents() { - return this.events; - } - - getSkinStyle() { - return this.skinStyle; - } - - getStyleDict() { - return this.styleDict; - } - - getDefaultStateDict() { - return this.defaultStateDict; - } - - getDeviceByCode(code) { - return this.mapDevice[code]; - } - - resize(opt) { - this.$zr.resize(opt); - this.$painter.updateZrSize(opt); - } - - refresh() { - this.$painter.refresh(); - } - - clearTrainView() { - this.$painter.clearLevel(deviceType.Train); - } - - clear() { - this.$painter.clear(); - } - - dispose() { - this.off(this.events.Pan, this.optionsHandler); - this.off(this.events.Zoom, this.optionsHandler); - - this.skinStyle = ''; - this.styleDict = {}; - this.mapDevice = {}; - - this.$mouseController.dispose(); - this.$zr && zrender.dispose(this.$zr); - this.$painter.dispose(); - } - - on(eventname, cb, context) { - const idx = Object.values(this.events).indexOf(eventname); - if (idx >= 0) { - switch (eventname) { - case this.events.Selected: - this.$mouseController.on(this.events.Selected, cb, context); - break; - case this.events.Contextmenu: - this.$mouseController.on(this.events.Contextmenu, cb, context); - break; - case this.events.DataZoom: - this.$mouseController.on(this.events.DataZoom, cb, context); - break; - } - } - } - - off(eventname, cb) { - const idx = Object.values(this.events).indexOf(eventname); - if (idx >= 0) { - switch (eventname) { - case this.events.Selected: - this.$mouseController.off(this.events.Selected, cb); - break; - case this.events.Contextmenu: - this.$mouseController.off(this.events.Contextmenu, cb); - break; - case this.events.DataZoom: - this.$mouseController.off(this.events.DataZoom, cb); - break; - } - } - } -} - -export default Jlmap; diff --git a/src/scripts/attribute.js b/src/scripts/attribute.js index 2b5a95fa2..abfd1f5bb 100644 --- a/src/scripts/attribute.js +++ b/src/scripts/attribute.js @@ -55,11 +55,11 @@ export const attribute = { { prop: 'leftSdCode', label: '左侧侧向Link:', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: [], optionCode: 'linkList' }, { prop: 'rightFdCode', label: '右侧正向Link:', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: [], optionCode: 'linkList' }, { prop: 'rightSdCode', label: '右侧侧向Link:', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: [], optionCode: 'linkList' }, - { prop: 'lp', label: 'Link 起点坐标:', type: 'coordinate', children: [ + { prop: 'lp', label: 'Link 起点坐标:', type: 'coordinate', width: '160px', children: [ { prop: 'lp.x', firstLevel: 'lp', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '20px', disabled: true }, { prop: 'lp.y', firstLevel: 'lp', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '20px', disabled: true } ] }, - { prop: 'rp', label: 'Link 终点坐标:', type: 'coordinate', children: [ + { prop: 'rp', label: 'Link 终点坐标:', type: 'coordinate', width: '160px', children: [ { prop: 'rp.x', firstLevel: 'rp', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '20px', disabled: true }, { prop: 'rp.y', firstLevel: 'rp', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '20px', disabled: true } ] } @@ -326,7 +326,7 @@ export const attribute = { { prop: 'kmPost', label: '公里标名称:', type: 'input' }, { prop: 'kmPostFont', label: '公里标字体:', type: 'font', placeholder: '公里标字体' }, { prop: 'kmPostFontColor', label: '公里标字体颜色:', type: 'color' }, - { prop: 'position.x', firstLevel: 'position', secondLevel: 'y', label: 'x坐标:', type: 'number', placeholder: 'px' }, + { prop: 'position.x', firstLevel: 'position', secondLevel: 'x', label: 'x坐标:', type: 'number', placeholder: 'px' }, { prop: 'position.y', firstLevel: 'position', secondLevel: 'y', label: 'y坐标:', type: 'number', placeholder: 'px' } ], rules: { @@ -350,5 +350,100 @@ export const attribute = { ] } } + }, + stationControl: { + attr: { + labelWidth: '160px', + items: [ + { prop: 'stationCode', label: '所属设备集中站:', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: [], optionCode: 'stationList' }, + { prop: 'code', label: '控制模式编码:', type: 'select', optionLabel: 'code', optionValue: 'code', options: [], optionCode: 'stationControlList', change: true, deviceChange: 'deviceChange' }, + { prop: 'zcCode', label: '所属zc区域编码:', type: 'select', optionLabel: 'code&&name', optionValue: 'code', options: [], optionCode: 'zcList' }, + { prop: 'name', label: '控制模式名称:', type: 'input' }, + { prop: 'zokContent', label: '中控内容:', type: 'input' }, + { prop: 'zakContent', label: '站控内容:', type: 'input' }, + { prop: 'jjzkContent', label: '紧急站控/总报警内容:', type: 'input' }, + { prop: 'zzkContent', label: '站中控内容:', type: 'input' }, + { prop: 'position.x', firstLevel: 'position', secondLevel: 'x', label: '坐标 x:', type: 'number', placeholder: 'px' }, + { prop: 'position.y', firstLevel: 'position', secondLevel: 'y', label: '坐标 y:', type: 'number', placeholder: 'px' } + ], + rules: { + code: [ + { required: true, message: '请选择设备', trigger: 'change' } + ], + stationCode: [ + { required: true, message: '请选择所属车站', trigger: 'change' } + ], + zokContent: [ + { required: true, message: '请输入中控内容', trigger: 'blur' } + ], + zakContent: [ + { required: true, message: '请输入站控内容', trigger: 'blur' } + ], + jjzkContent: [ + { required: true, message: '请输入紧急站控内容', trigger: 'blur' } + ], + zzkContent: [ + { required: true, message: '请输入站中控内容', trigger: 'blur' } + ], + 'position.x': [ + { required: true, message: '请输入坐标x', trigger: 'blur' } + ], + 'position.y': [ + { required: true, message: '请输入坐标y', trigger: 'blur' } + ] + } + } + }, + stationStand: { + attr: { + labelWidth: '130px', + items: [ + { prop: 'deviceStationCode', label: '所属设备集中站:', type: 'select', optionLabel: 'name', optionValue: 'code', options: [], optionCode: 'stationList' }, + { prop: 'code', label: '站台编码:', type: 'select', optionLabel: 'code&&name', optionValue: 'code', options: [], optionCode: 'stationStandList', change: true, deviceChange: 'deviceChange' }, + { prop: 'name', label: '站台名称:', type: 'input', disabled: true }, + { prop: 'stationCode', label: '所属车站:', type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: [], optionCode: 'stationList' }, + { prop: 'direction', label: '上下行方向:', type: 'select', optionLabel: 'name', optionValue: 'code', options: [], optionCode: 'RunDirectionTypeList' }, + { prop: 'visible', label: '是否显示:', type: 'checkbox' }, + { prop: 'nameShow', label: '是否显示名称:', type: 'checkbox' }, + { prop: 'doorLocationType', label: '站台方向:', type: 'select', optionLabel: 'name', optionValue: 'code', options: [], optionCode: 'DoorLocationTypeList' }, + { prop: 'hasDoor', label: '是否显示屏蔽门:', type: 'checkbox' }, + { prop: 'width', label: '宽度 w:', type: 'number', min: 0, max: 2000, placeholder: 'px' }, + { prop: 'height', label: '高度 h', type: 'number', min: 0, max: 2000, placeholder: 'px' }, + { prop: 'position.x', firstLevel: 'position', secondLevel: 'x', label: '坐标 x:', type: 'number', placeholder: 'px' }, + { prop: 'position.y', firstLevel: 'position', secondLevel: 'y', label: '坐标 y:', type: 'number', placeholder: 'px' } + ], + rules: { + code: [ + { required: true, message: '请重新选择设备', trigger: 'change' } + ], + stationCode: [ + { required: true, message: '请选择关联车站', trigger: 'change' } + ], + name: [ + { required: true, message: '请输入计数器名称', trigger: 'change' } + ], + doorLocationType: [ + { required: true, message: '请选择站台方向', trigger: 'change' } + ], + deviceStationCode: [ + { required: true, message: '请选择所属设备集中站', trigger: 'change' } + ], + direction: [ + { required: true, message: '请选择上下行方向', trigger: 'change' } + ], + width: [ + { required: true, message: '请输入车站宽度', trigger: 'change' } + ], + height: [ + { required: true, message: '请输入车站高度', trigger: 'change' } + ], + 'position.x': [ + { required: true, message: '请输入x坐标', trigger: 'change' } + ], + 'position.y': [ + { required: true, message: '请输入y坐标', trigger: 'change' } + ] + } + } } }; diff --git a/src/store/modules/map.js b/src/store/modules/map.js index 0dee56a4a..60602e703 100644 --- a/src/store/modules/map.js +++ b/src/store/modules/map.js @@ -82,7 +82,7 @@ function saveMapDeviceDefaultConvert(state) { // 是否集中站 if (map.stationControlList && map.stationControlList.length) { map.stationControlList.forEach(elem => { - const station = deviceMap[elem.stationCode] ? deviceMap[elem.stationCode].model : null; + const station = deviceMap[elem.stationCode]; if (station) { station.centralized = true; } @@ -110,7 +110,7 @@ function saveMapDeviceDefaultConvert(state) { // 站台轨设置 if (map.stationStandList && map.stationStandList.length && map.sectionList && map.sectionList.length) { map.stationStandList.forEach((stand) => { - const stopPoint = deviceMap[stand.stopPointCode] ? deviceMap[stand.stopPointCode].model : null; + const stopPoint = deviceMap[stand.stopPointCode]; if (stopPoint) { map.sectionList.forEach(section => { if (section.type === '01' && @@ -155,19 +155,19 @@ function saveMapDeviceDefaultConvert(state) { // 设置道岔区段 if (map.switchList && map.switchList.length && map.sectionList && map.sectionList.length) { map.switchList.forEach(elem => { - const sectiona = deviceMap[elem.sectionACode] ? deviceMap[elem.sectionACode].model : null; + const sectiona = deviceMap[elem.sectionACode]; if (sectiona && sectiona.type !== '03') { sectiona.nameShow = false; sectiona.isSwitchSection = true; sectiona.relSwitchCode = elem.code; } - const sectionb = deviceMap[elem.sectionBCode] ? deviceMap[elem.sectionBCode].model : null; + const sectionb = deviceMap[elem.sectionBCode]; if (sectionb && sectiona.type !== '03') { sectionb.nameShow = false; sectionb.isSwitchSection = true; sectionb.relSwitchCode = elem.code; } - const sectionc = deviceMap[elem.sectionCCode] ? deviceMap[elem.sectionCCode].model : null; + const sectionc = deviceMap[elem.sectionCCode]; if (sectionc && sectiona.type !== '03') { sectionc.nameShow = false; sectionc.isSwitchSection = true; diff --git a/src/styles/element-ui.scss b/src/styles/element-ui.scss index aef9051e2..637c2c0ab 100644 --- a/src/styles/element-ui.scss +++ b/src/styles/element-ui.scss @@ -57,3 +57,6 @@ .el-card__body { padding: 0px; } +.el-radio{ + margin-right: 0; +} diff --git a/src/views/map/mapdraft/mapedit/index.vue b/src/views/map/mapdraft/mapedit/index.vue index 9749cbfee..974c43554 100644 --- a/src/views/map/mapdraft/mapedit/index.vue +++ b/src/views/map/mapdraft/mapedit/index.vue @@ -265,11 +265,13 @@ export default { this.mapSaveing = true; this.$store.dispatch('map/saveMapDeviceDefaultConvert').then(() => { + console.log(Object.assign(map, { mapId: this.$route.params.mapId })); saveMap(Object.assign(map, { mapId: this.$route.params.mapId })).then(response => { this.$message.success('保存成功'); this.mapSaveing = false; this.initAutoSaveTask(); }).catch(error => { + console.log(error); this.$messageBox('保存失败'); this.mapSaveing = false; if (error.code === 40004 || error.code === 40005 || error.code === 40003) { diff --git a/src/views/map/mapdraft/mapedit/mapoperate/config/list.vue b/src/views/map/mapdraft/mapedit/mapoperate/config/list.vue index a72083224..24f067a65 100644 --- a/src/views/map/mapdraft/mapedit/mapoperate/config/list.vue +++ b/src/views/map/mapdraft/mapedit/mapoperate/config/list.vue @@ -66,11 +66,11 @@
- {{ item.placeholder }} + {{ item.placeholder }}
- {{ item.placeholder }} + {{ item.placeholder }}
@@ -82,14 +82,14 @@