rt-sim-training-client/src/store/modules/menuoperation.js
2020-09-01 15:10:35 +08:00

248 lines
7.4 KiB
JavaScript

import { TrainingMode } from '@/scripts/ConstDic';
/**
* 菜单操作状态数据
*/
const menuOperation = {
namespaced: true,
state: {
break: false, // 对话框菜单是否弹出(用于中断控制)
mbmpCount: 0, // 地图按钮菜单位置变更标识
buttonOperation: null, // 按钮菜单是否被按下
selected: {}, // 选中的地图对象
subType: '', // 选中的设备子元素类型
selectedCount: 0, // 选中对象变更标识
setMenuChangeCount: 0, // 哈尔滨线路左键点击变更标识
menu: null, // 弹出菜单设备
menuPosition: {}, // 弹出菜单位置
menuCount: 0, // 弹出菜单变更标识
menuParam: '', // 弹出菜单参数
magnifyCount: 0, // 地图放大比例标识
shrinkCount: 0, // 地图缩小比例标识
mapDrawSelectCount: 0, // 地图编辑点击标识
requestList: [], // 成都一号线请求堆栈
startSignalCode: '', // 西安二号线排列进路选中始端信号机
endSignalRouteList: [], // 西安二号线排列进路终端信号和进路list eg:[{endSignalCode:'',routeCode:''}]
leftClickCount: 0
},
getters: {
selected: (state) => {
return state.selected;
},
subType: (state) => {
return state.subType;
},
mbmpCount: (state) => {
return state.mbmpCount;
},
menuParam: (state) => {
return state.menuParam;
},
buttonOperation: (state) => {
return state.buttonOperation;
},
checkDialogIsOpen: (state) => (menu) => {
return state.menu == menu;
},
selectedCount:(state)=>{
return state.selectedCount;
},
requestList: (state)=>{
return state.requestList;
},
startSignalCode: (state)=>{
return state.startSignalCode;
},
endSignalRouteList: (state) => {
return state.endSignalRouteList;
},
leftClickCount: (state) => {
return state.leftClickCount;
}
},
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;
state.selectedCount += 1;
},
setMenuChange: (state, selected) => {
state.selected = selected.device;
state.subType = selected.subType;
state.setMenuChangeCount += 1;
},
mbmpCountIncrement: (state) => {
state.mbmpCount += 1;
},
setMenu: (state, menu) => {
state.menu = menu;
console.log('加载菜单');
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;
},
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);
}
});
},
resetRequestList: (state) => {
state.requestList = [];
},
setRouteSelectStartSignal: (state, param) => {
state.startSignalCode = param.startSignalCode;
state.endSignalRouteList = param.endSignalRouteList;
},
setLeftClickCount: (state) => {
state.leftClickCount++;
}
},
actions: {
/**
* 放大地图
*/
handleMagnifyCount: ({ commit }) => {
commit('setMagnifyCount');
},
/**
* 缩小地图
*/
handleShrinkCount: ({ commit }) => {
commit('setShrinkCount');
},
/** 清除菜单操作*/
reset: ({ commit }) => {
commit('reset');
},
/**
* 处理操作是否中断
*/
handleBreakFlag: ({ commit, rootState }, payLoad) => {
if (rootState.training.mode === TrainingMode.EDIT && rootState.training.started && payLoad && payLoad.break) {
commit('doBreak', rootState.training.mode);
} else {
commit('doRoute');
}
},
/**
* 地图按钮菜单位置改变事件
*/
mbmPositionChange: ({ commit }) => {
commit('mbmpCountIncrement');
},
/**
* 设置按钮菜单按钮
*/
setButtonOperation: ({ commit }, operation) => {
commit('setButtonOperation', operation);
},
/**
* 设置选中model
*/
setSelected: ({ commit }, selected) => {
commit('setSelected', selected);
},
// 改变哈尔滨底部菜单
setMenuChange: ({ commit }, selected) => {
commit('setMenuChange', selected);
},
/**
* 设置菜单
*/
setPopMenu: ({ commit }, payLoad) => {
commit('setMenu', payLoad.menu);
commit('setMenuParam', payLoad.param);
commit('setMenuPosition', payLoad.position);
},
/**
* 更新坐标
*/
setMenuPositionOffset: ({ commit }, offset) => {
commit('setMenuPositionOffset', offset);
},
setMapDrawSelectCount: ({ commit }) => {
commit('setMapDrawSelectCount');
},
pushRequestList: ({ commit }, request) => {
commit('pushRequestList', request);
},
spliceRequestList: ({ commit }, request) => {
commit('spliceRequestList', request);
},
/** 西安二号线排列进路保存信号机进路数据 */
setRouteSelectStartSignal: ({ commit }, param) => {
commit('setRouteSelectStartSignal', param);
},
/** 鼠标左键选中 */
setLeftClickCount: ({ commit } ) => {
commit('setLeftClickCount');
}
}
};
export default menuOperation;