全局菜单变换监听

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 tagsView from './modules/tagsView'
import permission from './modules/permission' import permission from './modules/permission'
import settings from './modules/settings' import settings from './modules/settings'
import tabActive from './modules/tabActive'
import getters from './getters' import getters from './getters'
Vue.use(Vuex) Vue.use(Vuex)
@ -17,7 +18,8 @@ const store = new Vuex.Store({
user, user,
tagsView, tagsView,
permission, permission,
settings settings,
tabActive
}, },
getters 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.menuActive = foundTab.number
this.$set(this.resetKeys, foundTab.name, Date.now()); this.$set(this.resetKeys, foundTab.name, Date.now());
this.$store.commit('tabActive/SET_MENU_ACTIVE', foundTab.number);
} }
}, },
clickMenuItem(val) { clickMenuItem(val) {
@ -450,6 +451,7 @@ export default {
this.editableTabsValue = foundTab.name this.editableTabsValue = foundTab.name
this.$set(this.resetKeys, foundTab.name, Date.now()); this.$set(this.resetKeys, foundTab.name, Date.now());
this.menuActive = foundTab.number this.menuActive = foundTab.number
this.$store.commit('tabActive/SET_MENU_ACTIVE', foundTab.number);
} else { } else {
// //
this.addTab(item) this.addTab(item)
@ -473,6 +475,7 @@ export default {
this.editableTabs.push(item) this.editableTabs.push(item)
this.editableTabsValue = item.name this.editableTabsValue = item.name
this.menuActive = item.number this.menuActive = item.number
this.$store.commit('tabActive/SET_MENU_ACTIVE', item.number);
}, },
removeTab(targetName) { removeTab(targetName) {
let tabs = this.editableTabs let tabs = this.editableTabs
@ -485,6 +488,7 @@ export default {
if (nextTab) { if (nextTab) {
activeName = nextTab.name activeName = nextTab.name
this.menuActive = nextTab.number 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){ if(window.navigator.userAgent.indexOf("GLXP_PC") != -1){
this.scanDisabled = true; this.scanDisabled = true;
window.addEventListener('recCodes', this.handleRecCodesEvent); window.addEventListener('djcl', this.handleRecCodesEvent);
} }
}, },
unmounted() { unmounted() {
window.removeEventListener('recCodes', this.handleRecCodesEvent); window.removeEventListener('djcl', this.handleRecCodesEvent);
}, },
created() { created() {
getHead("prescribeTagCodeDeal", "1").then((re) => { getHead("prescribeTagCodeDeal", "1").then((re) => {

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

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

Loading…
Cancel
Save