rt-sim-training-client/src/store/modules/menuoperation.js

247 lines
7.3 KiB
JavaScript
Raw Normal View History

2019-07-25 13:24:40 +08:00
import { TrainingMode } from '@/scripts/ConstDic';
/**
* 菜单操作状态数据
*/
const menuOperation = {
2019-11-07 19:39:52 +08:00
namespaced: true,
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
state: {
break: false, // 对话框菜单是否弹出(用于中断控制)
mbmpCount: 0, // 地图按钮菜单位置变更标识
buttonOperation: null, // 按钮菜单是否被按下
selected: {}, // 选中的地图对象
subType: '', // 选中的设备子元素类型
2019-11-07 19:39:52 +08:00
selectedCount: 0, // 选中对象变更标识
2020-03-18 18:47:37 +08:00
setMenuChangeCount: 0, // 哈尔滨线路左键点击变更标识
2019-11-07 19:39:52 +08:00
menu: null, // 弹出菜单设备
menuPosition: {}, // 弹出菜单位置
menuCount: 0, // 弹出菜单变更标识
menuParam: '', // 弹出菜单参数
magnifyCount: 0, // 地图放大比例标识
shrinkCount: 0, // 地图缩小比例标识
2020-01-09 17:48:25 +08:00
mapDrawSelectCount: 0, // 地图编辑点击标识
2020-04-29 11:36:16 +08:00
requestList: [], // 成都一号线请求堆栈
startSignalCode: '', // 西安二号线排列进路选中始端信号机
endSignalRouteList: [], // 西安二号线排列进路终端信号和进路list eg:[{endSignalCode:'',routeCode:''}]
leftClickCount: 0
2019-11-07 19:39:52 +08:00
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
getters: {
selected: (state) => {
return state.selected;
},
subType: (state) => {
return state.subType;
},
2019-11-07 19:39:52 +08:00
mbmpCount: (state) => {
return state.mbmpCount;
},
menuParam: (state) => {
return state.menuParam;
},
buttonOperation: (state) => {
return state.buttonOperation;
},
checkDialogIsOpen: (state) => (menu) => {
return state.menu == menu;
2019-11-08 13:01:41 +08:00
},
selectedCount:(state)=>{
return state.selectedCount;
2020-01-09 17:48:25 +08:00
},
requestList: (state)=>{
return state.requestList;
2020-04-29 11:36:16 +08:00
},
startSignalCode: (state)=>{
return state.startSignalCode;
},
endSignalRouteList: (state) => {
return state.endSignalRouteList;
},
leftClickCount: (state) => {
return state.leftClickCount;
2019-11-07 19:39:52 +08:00
}
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
mutations: {
reset: (state) => {
state.menu = null;
state.selected = null;
state.menuPosition = {};
state.buttonOperation = null;
},
doBreak: (state, editStatus) => {
if (!state.break) {
state.break = true;
if (editStatus != TrainingMode.EDIT) {
state.menuCount += 1;
}
}
},
doRoute: (state) => {
if (state.break) {
state.break = false;
state.menuCount += 1;
}
},
setButtonOperation: (state, operation) => {
state.buttonOperation = operation;
},
setSelected: (state, selected) => {
state.selected = selected.device;
state.subType = selected.subType;
2019-11-07 19:39:52 +08:00
state.selectedCount += 1;
},
2020-03-18 18:47:37 +08:00
setMenuChange: (state, selected) => {
state.selected = selected.device;
state.subType = selected.subType;
state.setMenuChangeCount += 1;
},
2019-11-07 19:39:52 +08:00
mbmpCountIncrement: (state) => {
state.mbmpCount += 1;
},
setMenu: (state, menu) => {
state.menu = menu;
state.menuCount += 1;
},
setMenuParam: (state, param) => {
state.menuParam = param;
},
setMenuPosition: (state, position) => {
state.menuPosition = position;
},
setMenuPositionOffset: (state, offset) => {
if (state.menuPosition) {
state.menuPosition = {
x: state.menuPosition.x + offset.x,
y: state.menuPosition.y + offset.y
};
}
},
setMagnifyCount: (state) => {
state.magnifyCount += 1;
},
setShrinkCount: (state) => {
state.shrinkCount += 1;
},
setMapDrawSelectCount: (state) => {
state.mapDrawSelectCount += 1;
2020-01-09 17:48:25 +08:00
},
pushRequestList: (state, request) => {
state.requestList.push(request);
},
spliceRequestList: (state, row) => {
state.requestList.forEach((item, index) => {
if (item.device.code == row.deviceCode && item.operation.code == row.operateCode) {
state.requestList.splice(index, 1);
}
});
},
2020-01-09 17:48:25 +08:00
resetRequestList: (state) => {
state.requestList = [];
2020-04-29 11:36:16 +08:00
},
setRouteSelectStartSignal: (state, param) => {
state.startSignalCode = param.startSignalCode;
state.endSignalRouteList = param.endSignalRouteList;
},
setLeftClickCount: (state) => {
state.leftClickCount++;
2019-11-07 19:39:52 +08:00
}
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
actions: {
/**
2019-07-25 13:24:40 +08:00
* 放大地图
*/
2019-11-07 19:39:52 +08:00
handleMagnifyCount: ({ commit }) => {
commit('setMagnifyCount');
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
/**
2019-07-25 13:24:40 +08:00
* 缩小地图
*/
2019-11-07 19:39:52 +08:00
handleShrinkCount: ({ commit }) => {
commit('setShrinkCount');
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
/** 清除菜单操作*/
reset: ({ commit }) => {
commit('reset');
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
/**
2019-07-25 13:24:40 +08:00
* 处理操作是否中断
*/
2019-11-07 19:39:52 +08:00
handleBreakFlag: ({ commit, rootState }, payLoad) => {
if (rootState.training.mode === TrainingMode.EDIT && rootState.training.started && payLoad && payLoad.break) {
commit('doBreak', rootState.training.mode);
} else {
commit('doRoute');
}
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
/**
2019-07-25 13:24:40 +08:00
* 地图按钮菜单位置改变事件
*/
2019-11-07 19:39:52 +08:00
mbmPositionChange: ({ commit }) => {
commit('mbmpCountIncrement');
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
/**
2019-07-25 13:24:40 +08:00
* 设置按钮菜单按钮
*/
2019-11-07 19:39:52 +08:00
setButtonOperation: ({ commit }, operation) => {
commit('setButtonOperation', operation);
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
/**
2019-07-25 13:24:40 +08:00
* 设置选中model
*/
2019-11-07 19:39:52 +08:00
setSelected: ({ commit }, selected) => {
commit('setSelected', selected);
},
2020-03-18 18:47:37 +08:00
// 改变哈尔滨底部菜单
setMenuChange: ({ commit }, selected) => {
commit('setMenuChange', selected);
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
/**
2019-07-25 13:24:40 +08:00
* 设置菜单
*/
2019-11-07 19:39:52 +08:00
setPopMenu: ({ commit }, payLoad) => {
commit('setMenu', payLoad.menu);
commit('setMenuParam', payLoad.param);
commit('setMenuPosition', payLoad.position);
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
/**
2019-07-25 13:24:40 +08:00
* 更新坐标
*/
2019-11-07 19:39:52 +08:00
setMenuPositionOffset: ({ commit }, offset) => {
commit('setMenuPositionOffset', offset);
},
2019-10-24 09:46:58 +08:00
2019-11-07 19:39:52 +08:00
setMapDrawSelectCount: ({ commit }) => {
commit('setMapDrawSelectCount');
2020-01-09 17:48:25 +08:00
},
pushRequestList: ({ commit }, request) => {
commit('pushRequestList', request);
},
spliceRequestList: ({ commit }, request) => {
commit('spliceRequestList', request);
2020-04-29 11:36:16 +08:00
},
/** 西安二号线排列进路保存信号机进路数据 */
setRouteSelectStartSignal: ({ commit }, param) => {
commit('setRouteSelectStartSignal', param);
},
/** 鼠标左键选中 */
setLeftClickCount: ({ commit } ) => {
commit('setLeftClickCount');
2019-11-07 19:39:52 +08:00
}
}
2019-07-25 13:24:40 +08:00
};
export default menuOperation;