diff --git a/src/jmapNew/theme/beijing_01/menus/menuSection.vue b/src/jmapNew/theme/beijing_01/menus/menuSection.vue index 5ceeaab81..200a9d641 100644 --- a/src/jmapNew/theme/beijing_01/menus/menuSection.vue +++ b/src/jmapNew/theme/beijing_01/menus/menuSection.vue @@ -20,6 +20,7 @@ import { DeviceMenu } from '@/scripts/ConstDic'; import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler'; import MenuContextHandler from '@/scripts/cmdPlugin/MenuContextHandler'; import CMD from '@/scripts/cmdPlugin/CommandEnum'; +import {menuOperate} from './utils/menuOperate'; export default { name: 'SectionMenu', @@ -172,18 +173,8 @@ export default { // }, // 故障解锁 faultUnlock(selectType) { - const operate = { - start: true, - operation: OperationEvent.Section.fault.menu.operation, - param: { - sectionCode: selectType.code - } - }; - this.$store.dispatch('training/nextNew', operate).then(({ valid }) => { - if (valid) { - this.$store.dispatch('menuOperation/handleBreakFlag', { break: true }); - this.$refs.sectionControl.doShow(operate, this.selected); - } + this.commitOperate(menuOperate.Section.fault, selectType, [selectType.code]).then((data)=>{ + this.$refs.sectionControl.doShow(data.operate, data.selected); }); }, undeveloped() { @@ -196,104 +187,56 @@ export default { }, // 切除 split() { - const operate = { - start: true, - code: this.selected.code, - operation: OperationEvent.Section.split.menu.operation, - param: { - sectionCode: `${this.selected.code}` - } - }; - this.$store.dispatch('training/nextNew', operate).then(({ valid }) => { - if (valid) { - this.$store.dispatch('menuOperation/handleBreakFlag', { break: true }); - this.$refs.sectionControl.doShow(operate, this.selected); - } + this.commitOperate(menuOperate.Section.split, this.selected, [this.selected.code]).then((data)=>{ + this.$refs.sectionControl.doShow(data.operate, data.selected); }); }, alxeEffective() { - const operate = { - start: true, - code: this.selected.code, - operation: OperationEvent.Section.alxeEffective.menu.operation, - param: { - sectionCode: `${this.selected.code}` - } - }; - this.$store.dispatch('training/nextNew', operate).then(({ valid }) => { - if (valid) { - this.$store.dispatch('menuOperation/handleBreakFlag', { break: true }); - this.$refs.alxeEffective.doShow(operate, this.selected); - } + this.commitOperate(menuOperate.Section.alxeEffective, this.selected, [this.selected.code]).then((data)=>{ + this.$refs.alxeEffective.doShow(data.operate, data.selected); }); }, // 激活 active() { - const operate = { - start: true, - code: this.selected.code, - operation: OperationEvent.Section.active.menu.operation, - param: { - sectionCode: `${this.selected.code}` - } - }; - this.$store.dispatch('training/nextNew', operate).then(({ valid }) => { - if (valid) { - this.$store.dispatch('menuOperation/handleBreakFlag', { break: true }); - this.$refs.sectionControl.doShow(operate, this.selected); - } + this.commitOperate(menuOperate.Section.active, this.selected, [this.selected.code]).then((data)=>{ + this.$refs.sectionControl.doShow(data.operate, data.selected); }); }, // 区段计轴预复位 axlePreReset(selectType) { - const operate = { - start: true, - code: this.selected.code, - operation: OperationEvent.Section.axlePreReset.menu.operation, - param: { - sectionCode: selectType.code - } - }; - this.$store.dispatch('training/nextNew', operate).then(({ valid }) => { - if (valid) { - this.$store.dispatch('menuOperation/handleBreakFlag', { break: true }); - this.$refs.sectionControl.doShow(operate, this.selected); - // this.$refs.sectionCmdControl.doShow(operate, this.selected); - } + this.commitOperate(menuOperate.Section.axlePreReset, selectType, [selectType.code]).then((data)=>{ + this.$refs.sectionControl.doShow(data.operate, data.selected); }); }, // 区段计轴预复位 // axlePreReset() { - // const operate = { - // start: true, - // code: this.selected.code, - // operation: OperationEvent.Section.axlePreReset.menu.operation, - // param: { - // sectionCode: `${this.selected.code}` - // } - // }; - // this.$store.dispatch('training/nextNew', operate).then(({ valid }) => { - // if (valid) { - // this.$store.dispatch('menuOperation/handleBreakFlag', { break: true }); - // this.$refs.sectionCmdControl.doShow(operate, this.selected); - // } + // this.commitOperate(menuOperate.Section.axlePreReset, this.selected, [this.selected.code]).then((data)=>{ + // this.$refs.sectionCmdControl.doShow(data.operate, data.selected); // }); // }, // 设置速度 setSpeed() { - const operate = { + this.commitOperate(menuOperate.Section.setSpeed, this.selected, [this.selected.code]).then((data)=>{ + this.$refs.speedLimitControl.doShow(data.operate, data.selected); + }); + }, + commitOperate(operate, selected, paramList) { + const step = { start: true, - code: this.selected.code, - operation: OperationEvent.Section.setSpeed.menu.operation, - param: { - sectionCode: `${this.selected.code}` - } + operation: operate.operation, + param:{} }; - this.$store.dispatch('training/nextNew', operate).then(({ valid }) => { - if (valid) { - this.$store.dispatch('menuOperation/handleBreakFlag', { break: true }); - this.$refs.speedLimitControl.doShow(operate, this.selected); - } + operate.param.forEach((each, index)=>{ + step.param[each] = paramList[index]; + }); + const obj = this; + return new Promise(function(resolve, reject) { + obj.$store.dispatch('training/nextNew', step).then(({ valid }) => { + if (valid) { + obj.$store.dispatch('menuOperation/handleBreakFlag', { break: true }); + resolve({operate:step, selected:selected}); + } + }); }); } } diff --git a/src/jmapNew/theme/beijing_01/menus/utils/menuOperate.js b/src/jmapNew/theme/beijing_01/menus/utils/menuOperate.js new file mode 100644 index 000000000..9befae7c6 --- /dev/null +++ b/src/jmapNew/theme/beijing_01/menus/utils/menuOperate.js @@ -0,0 +1,75 @@ +import Vue from 'vue'; +import store from '@/store'; +import CMD from '@/scripts/cmdPlugin/CommandEnum'; +import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler'; + +// 控制禁用 +export const menuOperate = { + Section:{ + active:{ + // 区段激活 + operation: OperationEvent.Section.active.menu.operation, + param:['sectionCode'], + cmdType: CMD.Section.CMD_SECTION_ACTIVE + }, + alxeEffective:{ + // 确认计轴有效 + operation: OperationEvent.Section.alxeEffective.menu.operation, + param:['sectionCode'], + cmdType: CMD.Section.CMD_SECTION_COMFIRMATION_AXLE + }, + split:{ + // 区段切除 + operation: OperationEvent.Section.split.menu.operation, + param:['sectionCode'], + cmdType: CMD.Section.CMD_SECTION_CUT_OFF + }, + setSpeed:{ + // 设置速度 + operation: OperationEvent.Section.setSpeed.menu.operation, + param:['sectionCode'], + cmdType: CMD.Section.CMD_SECTION_SET_LIMIT_SPEED + }, + axlePreReset:{ + // 区段计轴预复位 + operation: OperationEvent.Section.axlePreReset.menu.operation, + param:['sectionCode'], + cmdType: CMD.Section.CMD_SECTION_AXIS_PRE_RESET + }, + fault:{ + // 区段故障解锁 + operation: OperationEvent.Section.fault.menu.operation, + param:['sectionCode'], + cmdType: CMD.Section.CMD_SECTION_FAULT_UNLOCK + } + } +}; + +// export function commitOperate(menuoperate, paramList, selected, callback) { +// return new Promise((resolve, reject) => { +// try { +// const operate = { +// start: true, +// operation: OperationEvent.Section.split.menu.operation, +// param: { +// sectionCode: `${this.selected.code}` +// } +// }; +// this.$store.dispatch('training/nextNew', operate).then(({ valid }) => { +// if (valid) { +// this.$store.dispatch('menuOperation/handleBreakFlag', { break: true }); +// resolve(true); +// // callback({operate:operate, selected:selected}); +// // this.$refs.sectionControl.doShow(operate, this.selected); +// } +// }).catch((error) => { +// this.loading = false; +// this.doClose(); +// this.$refs.noticeInfo.doShow(operate, error.message); +// }); +// } catch (error) { +// reject(error); +// } +// }); + +// }