169 lines
3.6 KiB
JavaScript
169 lines
3.6 KiB
JavaScript
|
import { TrainingMode } from '@/scripts/ConstDic';
|
||
|
|
||
|
/**
|
||
|
* 菜单操作状态数据
|
||
|
*/
|
||
|
const menuOperation = {
|
||
|
namespaced: true,
|
||
|
|
||
|
state: {
|
||
|
break: false, // 对话框菜单是否弹出(用于中断控制)
|
||
|
mbmpCount: 0, // 地图按钮菜单位置变更标识
|
||
|
buttonOperation: null, // 按钮菜单是否被按下
|
||
|
selected: {}, // 选中的地图对象
|
||
|
selectedCount: 0, // 选中对象变更标识
|
||
|
menu: null, // 弹出菜单设备
|
||
|
menuPosition: {}, // 弹出菜单位置
|
||
|
menuCount: 0, // 弹出菜单变更标识
|
||
|
menuParam: '', // 弹出菜单参数
|
||
|
magnifyCount: 0, // 地图放大比例标识
|
||
|
shrinkCount: 0 // 地图缩小比例标识
|
||
|
},
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
},
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
doAccess: (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;
|
||
|
}
|
||
|
},
|
||
|
|
||
|
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('doAccess');
|
||
|
}
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 地图按钮菜单位置改变事件
|
||
|
*/
|
||
|
mbmPositionChange: ({ commit }) => {
|
||
|
commit('mbmpCountIncrement');
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 设置按钮菜单按钮
|
||
|
*/
|
||
|
setButtonOperation: ({ commit }, operation) => {
|
||
|
commit('setButtonOperation', operation);
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 设置选中model
|
||
|
*/
|
||
|
setSelected: ({ commit }, selected) => {
|
||
|
commit('setSelected', selected);
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 设置菜单
|
||
|
*/
|
||
|
setPopMenu: ({ commit }, payLoad) => {
|
||
|
commit('setMenu', payLoad.menu);
|
||
|
commit('setMenuParam', payLoad.param);
|
||
|
commit('setMenuPosition', payLoad.position);
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 更新坐标
|
||
|
*/
|
||
|
setMenuPositionOffset: ({ commit }, offset) => {
|
||
|
commit('setMenuPositionOffset', offset);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
export default menuOperation;
|