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

180 lines
4.8 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: {}, // 选中的地图对象
selectedCount: 0, // 选中对象变更标识
menu: null, // 弹出菜单设备
menuPosition: {}, // 弹出菜单位置
menuCount: 0, // 弹出菜单变更标识
menuParam: '', // 弹出菜单参数
magnifyCount: 0, // 地图放大比例标识
shrinkCount: 0, // 地图缩小比例标识
mapDrawSelectCount: 0 // 地图编辑点击标识
},
2019-07-25 13:24:40 +08:00
2019-11-07 19:39:52 +08:00
getters: {
selected: (state) => {
return state.selected;
},
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;
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;
state.selectedCount += 1;
},
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;
}
},
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);
},
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');
}
}
2019-07-25 13:24:40 +08:00
};
export default menuOperation;