Merge branch 'dev' of https://git.qcloud.com/joylink/jl-nclient into dev
This commit is contained in:
commit
ff50a2c4f5
@ -24,7 +24,9 @@ import Commands from '@/scripts/plugin/Commands';
|
||||
import { mapGetters } from 'vuex';
|
||||
import { OperateMode } from '@/scripts/ConstDic';
|
||||
import { MapDeviceType, OperationEvent, DeviceMenu } from '@/scripts/ConstDic';
|
||||
// 开关
|
||||
import { MenuDisabledState, menuConvert, menuFiltration } from './utils/menuItemStatus';
|
||||
// import MenuContextHandler from '@/scripts/plugin/MenuContextHandler';
|
||||
|
||||
export default {
|
||||
name: 'SignalMenu',
|
||||
@ -222,6 +224,7 @@ export default {
|
||||
},
|
||||
initMenu() {
|
||||
// 编辑模式菜单列表
|
||||
// this.menu = MenuContextHandler.menuFiltration(this.menuNormal);
|
||||
this.menu = menuFiltration(this.menuNormal);
|
||||
if (this.operatemode === OperateMode.ADMIN) {
|
||||
this.menu = [...this.menu, ...this.menuForce];
|
||||
@ -232,6 +235,8 @@ export default {
|
||||
this.menu = this.menuForce;
|
||||
}
|
||||
|
||||
// debugger;
|
||||
// this.menu = MenuContextHandler.covert(this.menu);
|
||||
this.menu = menuConvert(this.menu);
|
||||
|
||||
},
|
||||
|
@ -876,4 +876,10 @@ router.beforeEach((to, from, next) => {
|
||||
next();
|
||||
});
|
||||
|
||||
// 兼容 vue-router在3.1.0版本以上的路由跳转使用的是 promise 的方式
|
||||
const originalPush = Router.prototype.push;
|
||||
Router.prototype.push = function push(location) {
|
||||
return originalPush.call(this, location).catch(err => err);
|
||||
};
|
||||
|
||||
export default router;
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { MapDeviceType } from '@/scripts/ConstDic';
|
||||
import { sendCommand } from '@/api/jmap/training';
|
||||
import router from '@/router';
|
||||
|
||||
@ -5,24 +6,46 @@ class CommandHandle {
|
||||
constructor() {
|
||||
this.data = [];
|
||||
this.instructionMap = {
|
||||
|
||||
1: {
|
||||
type: MapDeviceType.Signal.type,
|
||||
operation: 1
|
||||
},
|
||||
2: {
|
||||
type: MapDeviceType.Signal.type,
|
||||
operation: 2
|
||||
},
|
||||
8: {
|
||||
type: MapDeviceType.StationStand.type,
|
||||
operation: 8
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
getInstruction(operation) {
|
||||
return this.instructionMap[operation] || {};
|
||||
getInstruction(operate) {
|
||||
return this.instructionMap[operate.commandType.value] || {};
|
||||
}
|
||||
|
||||
getCommand(operates) {
|
||||
const operate = operates[operates.length - 1] || {};
|
||||
if (operate && operate.instructionType) {
|
||||
const instruction = this.getInstruction(operate.instructionType);
|
||||
if (operate && operate.commandType) {
|
||||
const instruction = this.getInstruction(operate);
|
||||
if (instruction) {
|
||||
return {
|
||||
const command = {
|
||||
...instruction,
|
||||
paramList: this.getParamsList(operates),
|
||||
code: operate.code,
|
||||
val: operate.val,
|
||||
over: operate.over
|
||||
};
|
||||
|
||||
if (!command.code) {
|
||||
operates.forEach(elem => {
|
||||
if (elem.code) {
|
||||
command.code = elem.code;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return command;
|
||||
} else {
|
||||
return { error: true };
|
||||
}
|
||||
@ -31,19 +54,18 @@ class CommandHandle {
|
||||
return null;
|
||||
}
|
||||
|
||||
checkDisabled(menu, selected) {
|
||||
|
||||
}
|
||||
|
||||
execute(command) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const group = router.currentRoute.query.group;
|
||||
if (command) {
|
||||
sendCommand(group, command).then((response) => {
|
||||
resolve(response);
|
||||
}).catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
|
||||
sendCommand(group, command).then((response) => {
|
||||
resolve(response);
|
||||
}).catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
62
src/scripts/plugin/MenuContextHandler.js
Normal file
62
src/scripts/plugin/MenuContextHandler.js
Normal file
@ -0,0 +1,62 @@
|
||||
import store from '@/store';
|
||||
class MenuContextHandler {
|
||||
constructor() {
|
||||
this.operates = []; // 操作数据
|
||||
this.command = {}; // 命令对象
|
||||
}
|
||||
|
||||
getCurrentStateObject() {
|
||||
return store.getters['menuOperation/selected'];
|
||||
}
|
||||
|
||||
menuFiltration(menuList) {
|
||||
const SystemType = {
|
||||
'01': 'local', // 现地工作站
|
||||
'02': 'central' // 中心调度工作站
|
||||
};
|
||||
|
||||
const StationControlType = {
|
||||
'01': 'center', // 中控
|
||||
'02': 'station', // 站控
|
||||
'03': 'station'
|
||||
};
|
||||
|
||||
var selected = this.getCurrentStateObject();
|
||||
let control;
|
||||
var menu = [];
|
||||
|
||||
if (selected._type == 'StationStand') {
|
||||
control = store.getters['map/getStationControlByStationCode'](selected.deviceStationCode);
|
||||
} else if (selected._type == 'Station') {
|
||||
control = store.getters['map/getStationControlByStationCode'](selected.code);
|
||||
} else {
|
||||
control = store.getters['map/getStationControlByStationCode'](selected.stationCode);
|
||||
}
|
||||
if (control) {
|
||||
if (store.state.training.prdType != '') {
|
||||
const type = SystemType[store.state.training.prdType];
|
||||
const status = StationControlType[control.status];
|
||||
menu = [...menuList[type]];
|
||||
if (menu.constructor === Array) {
|
||||
menu.forEach(elem => {
|
||||
if (elem.type === 'separator') {
|
||||
elem.show = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (elem.auth.constructor === Object) {
|
||||
elem.show = true;
|
||||
if (!elem.auth['station'] && !elem.auth['center']) { // 控制不显示
|
||||
elem.show = false;
|
||||
}
|
||||
elem.defaultDisabled = !elem.auth[status];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
|
||||
export default new MenuContextHandler();
|
@ -10,7 +10,6 @@ import LangStorage from '@/utils/lang';
|
||||
class OperateHandler {
|
||||
constructor() {
|
||||
this.operates = []; // 操作数据
|
||||
this.command = {}; // 命令对象
|
||||
}
|
||||
|
||||
/** 操作组 */
|
||||
@ -136,11 +135,11 @@ class OperateHandler {
|
||||
return new Promise((resolve, reject) => {
|
||||
const rtn = { valid: false, response: null };
|
||||
const valid = this.validate(operate);
|
||||
const command = this.getCommand(operate);
|
||||
|
||||
rtn.valid = valid;
|
||||
|
||||
if (valid) {
|
||||
const command = this.getCommand(operate);
|
||||
if (valid && command) {
|
||||
CommandHandler.execute(command).then(response => {
|
||||
rtn.response = response;
|
||||
resolve(rtn);
|
||||
|
@ -37,12 +37,6 @@
|
||||
@switchMode="switchMode"
|
||||
@selectQuest="selectQuest"
|
||||
/>
|
||||
<!--@runPlanViewShow="runPlanViewShow"
|
||||
@faultChooseShow="faultChooseShow"
|
||||
@runPlanLoadShow="runPlanLoadShow"
|
||||
@runAddRolesLoadShow="runAddRolesLoadShow"
|
||||
@runQuestLoadShow="runQuestLoadShow"
|
||||
-->
|
||||
|
||||
<menu-system-time ref="menuSystemTime" :offset="offset" :right="right" :group="group" />
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user