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 { mapGetters } from 'vuex';
|
||||||
import { OperateMode } from '@/scripts/ConstDic';
|
import { OperateMode } from '@/scripts/ConstDic';
|
||||||
import { MapDeviceType, OperationEvent, DeviceMenu } from '@/scripts/ConstDic';
|
import { MapDeviceType, OperationEvent, DeviceMenu } from '@/scripts/ConstDic';
|
||||||
|
// 开关
|
||||||
import { MenuDisabledState, menuConvert, menuFiltration } from './utils/menuItemStatus';
|
import { MenuDisabledState, menuConvert, menuFiltration } from './utils/menuItemStatus';
|
||||||
|
// import MenuContextHandler from '@/scripts/plugin/MenuContextHandler';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'SignalMenu',
|
name: 'SignalMenu',
|
||||||
@ -222,6 +224,7 @@ export default {
|
|||||||
},
|
},
|
||||||
initMenu() {
|
initMenu() {
|
||||||
// 编辑模式菜单列表
|
// 编辑模式菜单列表
|
||||||
|
// this.menu = MenuContextHandler.menuFiltration(this.menuNormal);
|
||||||
this.menu = menuFiltration(this.menuNormal);
|
this.menu = menuFiltration(this.menuNormal);
|
||||||
if (this.operatemode === OperateMode.ADMIN) {
|
if (this.operatemode === OperateMode.ADMIN) {
|
||||||
this.menu = [...this.menu, ...this.menuForce];
|
this.menu = [...this.menu, ...this.menuForce];
|
||||||
@ -232,6 +235,8 @@ export default {
|
|||||||
this.menu = this.menuForce;
|
this.menu = this.menuForce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// debugger;
|
||||||
|
// this.menu = MenuContextHandler.covert(this.menu);
|
||||||
this.menu = menuConvert(this.menu);
|
this.menu = menuConvert(this.menu);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -876,4 +876,10 @@ router.beforeEach((to, from, next) => {
|
|||||||
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;
|
export default router;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { MapDeviceType } from '@/scripts/ConstDic';
|
||||||
import { sendCommand } from '@/api/jmap/training';
|
import { sendCommand } from '@/api/jmap/training';
|
||||||
import router from '@/router';
|
import router from '@/router';
|
||||||
|
|
||||||
@ -5,24 +6,46 @@ class CommandHandle {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.data = [];
|
this.data = [];
|
||||||
this.instructionMap = {
|
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) {
|
getInstruction(operate) {
|
||||||
return this.instructionMap[operation] || {};
|
return this.instructionMap[operate.commandType.value] || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
getCommand(operates) {
|
getCommand(operates) {
|
||||||
const operate = operates[operates.length - 1] || {};
|
const operate = operates[operates.length - 1] || {};
|
||||||
if (operate && operate.instructionType) {
|
if (operate && operate.commandType) {
|
||||||
const instruction = this.getInstruction(operate.instructionType);
|
const instruction = this.getInstruction(operate);
|
||||||
if (instruction) {
|
if (instruction) {
|
||||||
return {
|
const command = {
|
||||||
...instruction,
|
...instruction,
|
||||||
paramList: this.getParamsList(operates),
|
code: operate.code,
|
||||||
|
val: operate.val,
|
||||||
over: operate.over
|
over: operate.over
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!command.code) {
|
||||||
|
operates.forEach(elem => {
|
||||||
|
if (elem.code) {
|
||||||
|
command.code = elem.code;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return command;
|
||||||
} else {
|
} else {
|
||||||
return { error: true };
|
return { error: true };
|
||||||
}
|
}
|
||||||
@ -31,19 +54,18 @@ class CommandHandle {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkDisabled(menu, selected) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
execute(command) {
|
execute(command) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const group = router.currentRoute.query.group;
|
const group = router.currentRoute.query.group;
|
||||||
if (command) {
|
|
||||||
sendCommand(group, command).then((response) => {
|
sendCommand(group, command).then((response) => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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 {
|
class OperateHandler {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.operates = []; // 操作数据
|
this.operates = []; // 操作数据
|
||||||
this.command = {}; // 命令对象
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 操作组 */
|
/** 操作组 */
|
||||||
@ -136,11 +135,11 @@ class OperateHandler {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const rtn = { valid: false, response: null };
|
const rtn = { valid: false, response: null };
|
||||||
const valid = this.validate(operate);
|
const valid = this.validate(operate);
|
||||||
|
const command = this.getCommand(operate);
|
||||||
|
|
||||||
rtn.valid = valid;
|
rtn.valid = valid;
|
||||||
|
|
||||||
if (valid) {
|
if (valid && command) {
|
||||||
const command = this.getCommand(operate);
|
|
||||||
CommandHandler.execute(command).then(response => {
|
CommandHandler.execute(command).then(response => {
|
||||||
rtn.response = response;
|
rtn.response = response;
|
||||||
resolve(rtn);
|
resolve(rtn);
|
||||||
|
@ -37,12 +37,6 @@
|
|||||||
@switchMode="switchMode"
|
@switchMode="switchMode"
|
||||||
@selectQuest="selectQuest"
|
@selectQuest="selectQuest"
|
||||||
/>
|
/>
|
||||||
<!--@runPlanViewShow="runPlanViewShow"
|
|
||||||
@faultChooseShow="faultChooseShow"
|
|
||||||
@runPlanLoadShow="runPlanLoadShow"
|
|
||||||
@runAddRolesLoadShow="runAddRolesLoadShow"
|
|
||||||
@runQuestLoadShow="runQuestLoadShow"
|
|
||||||
-->
|
|
||||||
|
|
||||||
<menu-system-time ref="menuSystemTime" :offset="offset" :right="right" :group="group" />
|
<menu-system-time ref="menuSystemTime" :offset="offset" :right="right" :group="group" />
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user