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: [] // 成都一号线请求堆栈 }, 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; } }, 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; 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 = []; } }, 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); } } }; export default menuOperation;