全局菜单变换监听

20240912_adapter_z
zane 7 months ago
parent 8d0ad82d04
commit 775b34282e

@ -6,6 +6,7 @@ import user from './modules/user'
import tagsView from './modules/tagsView'
import permission from './modules/permission'
import settings from './modules/settings'
import tabActive from './modules/tabActive'
import getters from './getters'
Vue.use(Vuex)
@ -17,7 +18,8 @@ const store = new Vuex.Store({
user,
tagsView,
permission,
settings
settings,
tabActive
},
getters
})

@ -0,0 +1,20 @@
const state = {
menuActive: 0,
}
const mutations = {
SET_MENU_ACTIVE: (state, menuActive) => {
state.menuActive = menuActive
}
}
const actions = {
}
export default {
namespaced: true,
state,
mutations,
actions
}

@ -439,6 +439,7 @@ export default {
//
this.menuActive = foundTab.number
this.$set(this.resetKeys, foundTab.name, Date.now());
this.$store.commit('tabActive/SET_MENU_ACTIVE', foundTab.number);
}
},
clickMenuItem(val) {
@ -450,6 +451,7 @@ export default {
this.editableTabsValue = foundTab.name
this.$set(this.resetKeys, foundTab.name, Date.now());
this.menuActive = foundTab.number
this.$store.commit('tabActive/SET_MENU_ACTIVE', foundTab.number);
} else {
//
this.addTab(item)
@ -473,6 +475,7 @@ export default {
this.editableTabs.push(item)
this.editableTabsValue = item.name
this.menuActive = item.number
this.$store.commit('tabActive/SET_MENU_ACTIVE', item.number);
},
removeTab(targetName) {
let tabs = this.editableTabs
@ -485,6 +488,7 @@ export default {
if (nextTab) {
activeName = nextTab.name
this.menuActive = nextTab.number
this.$store.commit('tabActive/SET_MENU_ACTIVE', nextTab.number);
}
}
})

@ -1042,11 +1042,11 @@ export default {
//
if(window.navigator.userAgent.indexOf("GLXP_PC") != -1){
this.scanDisabled = true;
window.addEventListener('recCodes', this.handleRecCodesEvent);
window.addEventListener('djcl', this.handleRecCodesEvent);
}
},
unmounted() {
window.removeEventListener('recCodes', this.handleRecCodesEvent);
window.removeEventListener('djcl', this.handleRecCodesEvent);
},
created() {
getHead("prescribeTagCodeDeal", "1").then((re) => {

@ -1916,11 +1916,11 @@ export default {
//
if(window.navigator.userAgent.indexOf("GLXP_PC") != -1){
this.scanDisabled = true;
window.addEventListener('recCodes', this.handleRecCodesEvent);
window.addEventListener('gwsh', this.handleRecCodesEvent);
}
},
unmounted() {
window.removeEventListener('recCodes', this.handleRecCodesEvent);
window.removeEventListener('gwsh', this.handleRecCodesEvent);
},
created() {
// this.splitType = this.$route.query.splitType;

@ -1,15 +1,30 @@
import store from "./store";
//扩展window函数
window.recCodes = function recCodes(codes) {
if(codes){
if (!Array.isArray(codes) || codes.some(item => typeof item!== 'string')) {
throw new Error('codes 参数必须是一个字符串数组');
}
console.log("菜单触发事件",store.state.tabActive.menuActive);
//触发自定义事件
window.dispatchEvent(new CustomEvent('recCodes', {
let menuActive = store.state.tabActive.menuActive;
if(menuActive == 0){//处理单据
console.log("处理单据事件");
window.dispatchEvent(new CustomEvent('djcl', {
detail: {
recCodes: codes
}
}));
}else if(menuActive == 1){//工位上货
console.log("工位上货事件");
window.dispatchEvent(new CustomEvent('gwsh', {
detail: {
recCodes: codes
}
}));
}else{
}
}else{
alert("收到空数据");
}

Loading…
Cancel
Save