diff --git a/src/api/rpTools.js b/src/api/rpTools.js new file mode 100644 index 000000000..9a3a03c7e --- /dev/null +++ b/src/api/rpTools.js @@ -0,0 +1,67 @@ +import request from '@/utils/request'; + +/** + * 获取运行图数据 + */ +export function getRpTools() { + return request({ + url: '/api/rpTools', + method: 'get' + }); +} + +/** + * 添加车次 + */ +export function addRpTrip(data) { + return request({ + url: '/api/rpTools/trip', + method: 'post', + data + }); +} + +/** + * 修改到站时间 + */ +export function justTripNoArrival(tripNo, data) { + return request({ + url: `/api/rpTools/${tripNo}/arrival`, + method: 'put', + data + }) +} + + +/** + * 修改发车时间 + */ +export function justTripNoDeparture(tripNo, data) { + return request({ + url: `/api/rpTools/${tripNo}/departure`, + method: 'put', + data + }) +} + +/** + * 平移车次 + */ +export function translateTripNo(tripNo, data) { + return request({ + url: `/api/rpTools/${tripNo}/trip`, + method: 'put', + data + }) +} + + +/** + * 删除车次 + */ +export function deleteTripNo(tripNo) { + return request({ + url: `/api/rpTools/${tripNo}/trip`, + method: 'delete' + }) +} diff --git a/src/jmapNew/theme/aus_00/planConvert.js b/src/jmapNew/theme/aus_00/planConvert.js new file mode 100644 index 000000000..4d7b31991 --- /dev/null +++ b/src/jmapNew/theme/aus_00/planConvert.js @@ -0,0 +1,129 @@ +import { createMartPointReverse, createSeriesModel, createMarkLineModels, hexColor, convertSheetToList, prefixTime } from '@/utils/runPlan'; + +export default { + /** 边缘高度*/ + EdgeHeight: 600, + + /** 间隔高度*/ + CoordMultiple: 1, + + /** 偏移时间*/ + TranslationTime: 0, + + /** 将后台数据解析成图表*/ + convertDataToModels(tripList, stations, kmRangeCoordMap, lineStyle) { + var models = []; + /** 按车次遍历数据*/ + if (tripList && tripList.length) { + tripList.forEach(trip => { + const opt = { name: `run-${trip.tripNo}`, type: 'line', markPoint: { data: [] }, data: []}; + + if (trip.tripNo && + trip.stationTimeList.length) { + opt.markPoint.data.push(createMartPointReverse({ + name: `${trip.tripNo}`, + color: '#000' || lineStyle.color, + coord: [ + trip.stationTimeList[0].arrivalTime, + this.getCoordYByElem(stations, kmRangeCoordMap, trip.stationTimeList[0]) + ] + })); + } + + /** 计算停站点坐标集合*/ + trip.stationTimeList.forEach(elem => { + if (elem.arrivalTime) { + opt.data.push([elem.arrivalTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem), elem.stationCode, trip.tripNo]); + } + + if (elem.departureTime) { + opt.data.push([elem.departureTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem), elem.stationCode, trip.tripNo]); + } + }); + + models.push(opt); + }); + } + + console.log(models); + + return models; +}, + + /** 更新数据并解析成图表*/ + updateDataToModels(tripList, stations, kmRangeCoordMap, runPlanData, series, lineStyle) { + if (tripList && tripList.length) { + } + return series; + }, + + /** 初始化Y轴*/ + initializeYaxis(stations) { + return createMarkLineModels(stations, (elem) => { + return this.EdgeHeight + elem.kmRange * this.CoordMultiple; + }); + }, + + /** 将后台数据转换为试图序列模型*/ + convertStationsToMap(stations) { + var map = {}; + if (stations && stations.length) { + stations.forEach((elem) => { + map[`${elem.kmRange}`] = this.EdgeHeight + elem.kmRange * this.CoordMultiple; + }); + } + + return map; + }, + + /** 计算y轴最小值*/ + computedYaxisMinValue(stations) { + return stations[0].kmRange * this.CoordMultiple; + }, + + /** 计算y轴最大值*/ + computedYaxisMaxValue(stations) { + return stations[stations.length - 1].kmRange * this.CoordMultiple + this.EdgeHeight * 2; + }, + + /** 格式化y轴数据*/ + computedFormatYAxis(stations, params) { + var yText = '0m'; + + stations.forEach(elem => { + if (elem.kmRange < parseInt(params.value) / this.CoordMultiple - this.EdgeHeight) { + yText = Math.floor(elem.kmRange) + 'm'; + } + }); + + return yText; + }, + + /** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/ + computedReentryNumber(code) { + // return parseInt(code || 1) % 2 ? 1 : 2; + return 1; + }, + + /** 根据方向计算y折返偏移量*/ + getYvalueByDirectionCode(defaultVlue, directionCode, num) { + if (directionCode === '1') { + defaultVlue += this.EdgeHeight / 2 * num; + } else if (directionCode === '2') { + defaultVlue -= this.EdgeHeight / 2 * num; + } + + return defaultVlue; + }, + + /** 根据elem计算y值*/ + getCoordYByElem(stations, kmRangeCoordMap, elem) { + var defaultVlue = 0; + var station = stations.find(it => { return it.code == elem.stationCode; }); + if (station) { + defaultVlue = kmRangeCoordMap[`${station.kmRange}`]; + } + + return defaultVlue; + } +}; diff --git a/src/jmapNew/theme/factory.js b/src/jmapNew/theme/factory.js index 9ae66e4de..6075c2bd3 100644 --- a/src/jmapNew/theme/factory.js +++ b/src/jmapNew/theme/factory.js @@ -2,6 +2,7 @@ class Theme { constructor(code) { this._code = '02'; this._mapMenu = { + '00': 'aus_00', '01': 'chengdu_01', '02': 'fuzhou_01', '03': 'beijing_01', diff --git a/src/router/index_Common.js b/src/router/index_Common.js index 78b730364..6c6d49a7f 100644 --- a/src/router/index_Common.js +++ b/src/router/index_Common.js @@ -86,6 +86,7 @@ const DemonstrationDetail = () => import('@/views/demonstration/detail/index'); const PlanMonitorEditTool = () => import('@/views/planMonitor/editTool/index'); const PlanMonitorEditUserTool = () => import('@/views/planMonitor/editTool/userindex'); +const PlanMonitorEditAUSTool = () => import('@/views/planMonitor/editToolAUS/index'); const PlanMonitorDetail = () => import('@/views/planMonitor/detail'); const DesignPlatformHome = () => import('@/views/designPlatform/home'); @@ -369,12 +370,17 @@ export const publicAsyncRoute = [ path: '/plan/usertool', component: PlanMonitorEditUserTool, hidden: true + }, + { // 运行图编辑 + path: '/plan/AUStool', + component: PlanMonitorEditAUSTool, + hidden: true }, { // 运行图编辑 path: '/plan/tool', component: PlanMonitorEditTool, hidden: true - }, + }, { path: '/displayIscs/system', component: IscsSystem, diff --git a/src/scripts/ConstDic.js b/src/scripts/ConstDic.js index 04dc03082..470e51d96 100644 --- a/src/scripts/ConstDic.js +++ b/src/scripts/ConstDic.js @@ -128,7 +128,9 @@ export const DeviceMenu = { SetDriver: '106', Script: '107', IscsSystem: '108', - IscsInterface: '109' + IscsInterface: '109', + + planAusContextMenu: '200' }; /** diff --git a/src/store/index_Common.js b/src/store/index_Common.js index 3d4220bed..dc1b2f8b5 100644 --- a/src/store/index_Common.js +++ b/src/store/index_Common.js @@ -16,6 +16,7 @@ import scriptRecord from './modules/scriptRecord'; import ibp from './modules/ibp'; import order from './modules/order'; import iscs from './modules/iscs'; +import rpTools from './modules/rpTools'; import getters from './getters'; @@ -38,7 +39,8 @@ const store = new Vuex.Store({ scriptRecord, ibp, order, - iscs + iscs, + rpTools }, getters }); diff --git a/src/store/modules/rpTools.js b/src/store/modules/rpTools.js new file mode 100644 index 000000000..5bc5d1af8 --- /dev/null +++ b/src/store/modules/rpTools.js @@ -0,0 +1,93 @@ +const runPlan = { + namespaced: true, + + state: { + stations: [], // 车站列表 + planData: {}, // 运行图原始数据 + editData: {}, // 运行图编辑数据 + planSizeCount: 0, // 运行图canvas 大小变更标识 + planLoadedCount: 0, // 运行图数据更新 + planUpdateCount: 0, // 运行图更新标识 + selected: {}, // 选择的对象 + refreshCount: 0, // 刷新页面重新加载 + width: 800, // 运行图canvas 容器 宽度 + height: 600, // 运行图canvas 容器 高度 + }, + getters: { + stations: (state) => { + return state.stations || []; + } + }, + mutations: { + setWidth: (state, width) => { + state.width = width; + state.planSizeCount += 1; + }, + setHeight: (state, height) => { + state.height = height; + state.planSizeCount += 1; + }, + setStations: (state, stations) => { + state.stations = stations; + }, + setPlanData: (state, data) => { + state.planData = data; + state.editData = {}; + state.planLoadedCount++; + }, + setSelected: (state, selected) => { + state.selected = selected; + }, + clear: (state) => { + state.planData = {}; + state.editData = {}; + state.selected = {}; + }, + refresh: (state) => { + state.refreshCount++; + } + }, + actions: { + /** 设置运行图大小*/ + resize({ commit }, opt) { + if (opt.width) { + commit('setWidth', opt.width); + } + if (opt.height) { + commit('setHeight', opt.height); + } + }, + /** 设置stations数据 */ + setStations: ({ commit }, mapModel) => { + return new Promise((resolve) => { + commit('setStations', mapModel); + resolve(mapModel); + }); + }, + /** 设置运行图数据 */ + setPlanData: ({ commit }, data) => { + commit('setPlanData', data); + }, + /** 选择车次*/ + setSelected: ({ commit }, selected) => { + commit('setSelected', selected); + }, + /** 更新数据*/ + updateRunPlanData: ({ commit }, data) => { + commit('updateRunPlanData', data); + }, + /** 清空数据*/ + clear: ({ commit }) => { + return new Promise((resolve) => { + commit('clear'); + resolve(); + }); + }, + /** 刷新页面*/ + refresh: ({commit}) => { + commit('refresh'); + } + } +}; + +export default runPlan; diff --git a/src/utils/baseUrl.js b/src/utils/baseUrl.js index 524befeac..a1032fe84 100644 --- a/src/utils/baseUrl.js +++ b/src/utils/baseUrl.js @@ -2,8 +2,8 @@ export function getBaseUrl() { let BASE_API; if (process.env.NODE_ENV === 'development') { // BASE_API = 'https://joylink.club/jlcloud'; - BASE_API = 'https://test.joylink.club/jlcloud'; - // BASE_API = 'http://192.168.3.5:9000'; // 袁琪 + // BASE_API = 'https://test.joylink.club/jlcloud'; + BASE_API = 'http://192.168.3.5:9000'; // 袁琪 // BASE_API = 'http://192.168.3.6:9000'; // 旭强 // BASE_API = 'http://192.168.3.175:9000'; // 张赛 // BASE_API = 'http://192.168.3.82:9000'; // 杜康 diff --git a/src/views/planMonitor/editToolAUS/contextMenu.vue b/src/views/planMonitor/editToolAUS/contextMenu.vue new file mode 100644 index 000000000..da215d989 --- /dev/null +++ b/src/views/planMonitor/editToolAUS/contextMenu.vue @@ -0,0 +1,90 @@ + + + + diff --git a/src/views/planMonitor/editToolAUS/index.vue b/src/views/planMonitor/editToolAUS/index.vue new file mode 100644 index 000000000..fc61fabde --- /dev/null +++ b/src/views/planMonitor/editToolAUS/index.vue @@ -0,0 +1,392 @@ + + + + + diff --git a/src/views/planMonitor/editToolAUS/monitor.js b/src/views/planMonitor/editToolAUS/monitor.js new file mode 100644 index 000000000..516256731 --- /dev/null +++ b/src/views/planMonitor/editToolAUS/monitor.js @@ -0,0 +1,160 @@ +import { DeviceMenu } from '@/scripts/ConstDic'; +import { timeFormat } from '@/utils/date'; + +export default { + data() { + return { + isDragging: false, + createModel: { + endStationCode: '', + startStationCode: '', + startTime: { + hour: '', + minute: '', + second: '' + } + } + } + }, + watch: { + myChart: function() { + this.listenersBind(); + } + }, + beforeDestroy() { + this.listenersOff(); + }, + methods: { + getStationByCoord(stations, y) { + for(var i = stations.length-1; i >= 0; i--) { + const station = stations[i]; + if (station.kmRange <= y) { + return station; + } + } + return null; + }, + pixelExecCb(e, cb) { + let myChart = this.myChart; + let pointInPixel= [e.offsetX, e.offsetY]; + if (myChart.containPixel('grid', pointInPixel) && this.planConvert) { + let pointInGrid = myChart.convertFromPixel({seriesIndex:0},pointInPixel); + let xIndex = pointInGrid[0]; + let yIndex = pointInGrid[1]; + let op = myChart.getOption(); + let minY = op.yAxis[0].min; + let xVal = op.xAxis[0].data[xIndex]; + let edgeOffset = this.planConvert.EdgeHeight/6; + let yObj = this.getStationByCoord(this.stations, yIndex-minY-edgeOffset); + if (yObj && cb) { + cb(yObj, xVal, pointInPixel); + } + } + }, + listenersBind() { + if (this.myChart) { + const zr = this.myChart.getZr(); + zr.on('click', this.onClick, this) + zr.on('contextmenu', this.onContextMenu, this); + this.myChart.on('mousedown', this.onDragStart); + this.myChart.on('mouseup', this.onDragEnd); + this.myChart.on('click', 'series', this.onSelect); + this.myChart.on('datazoom', this.onClearMarks); + } + }, + listenersOff() { + if (this.myChart) { + const zr = this.myChart.getZr(); + zr.off('click', this.onClick); + zr.off('contextmenu', this.onContextMenu); + this.myChart.off('mousedown', this.onDragStart); + this.myChart.off('mouseup', this.onDragEnd); + this.myChart.off('click', 'series', this.onSelect); + this.myChart.off('datazoom', this.onClearMarks); + } + }, + onClick(e) { + this.pixelExecCb(e, this.handleMarkPoint) + }, + onContextMenu(e) { + console.log(e, 'onContextMenu'); + this.onClearMarks(); + if(e.target) { + const event = e.event; + const point = { + x: event.clientX, + y: event.clientY + } + this.$store.dispatch('menuOperation/setPopMenu', { position: point, menu: DeviceMenu.planAusContextMenu }); + } else { + this.$message.info('No train number selected') + } + }, + onClearMarks() { + if (this.myChart) { + let op = this.myChart.getOption(); + op.graphic[0].elements = []; + this.myChart.setOption(op, {notMerge: true}) + } + }, + onSelect(e) { + console.log(e, 'select') + }, + onDragStart(e) { + console.log(e, 'dragStart'); + }, + onDragEnd(e) { + console.log(e, 'dragEnd'); + }, + createMarkPoint(point, text) { + return { + type: 'group', + z: 100, + children: [ + { + type: 'circle', + z: 100, + shape: { + cx: point[0], + cy: point[1], + r: 5 + }, + style: { + fill: 'rgba(0,0,0,0.3)' + } + }, + { + type: 'circle', + z: 100, + shape: { + cx: point[0], + cy: point[1], + r: 10 + }, + style: { + fill: 'rgba(0,0,0,0.3)' + } + } + ] + } + }, + handleMarkPoint(yObj, xVal, pointInPixel) { + let myChart = this.myChart; + if (myChart) { + let op = myChart.getOption(); + let graphic = op.graphic[0]; + if (graphic) { + graphic.elements.push(this.createMarkPoint(pointInPixel, 'hello world')) + myChart.setOption(op); + if (graphic.elements.length == 1) { + this.createModel.startStationCode = yObj.code; + this.createModel.startTime = timeFormat(xVal); + } else if (graphic.elements.length >= 2) { + this.createModel.endStationCode = yObj.code; + this.createRpTrip(this.createModel); + } + } + } + } + } +} diff --git a/src/views/planMonitor/editToolAUS/schedule.vue b/src/views/planMonitor/editToolAUS/schedule.vue new file mode 100644 index 000000000..03de8ae14 --- /dev/null +++ b/src/views/planMonitor/editToolAUS/schedule.vue @@ -0,0 +1,599 @@ + + + +