This commit is contained in:
fan 2020-03-19 17:11:46 +08:00
commit 5173c4e8d9
2 changed files with 107 additions and 89 deletions

View File

@ -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});
}
});
});
}
}

View File

@ -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);
// }
// });
// }