From 775b34282eb286f0ce3bd008e931f82279331442 Mon Sep 17 00:00:00 2001 From: zane Date: Fri, 13 Sep 2024 17:55:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E5=B1=80=E8=8F=9C=E5=8D=95=E5=8F=98?= =?UTF-8?q?=E6=8D=A2=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/index.js | 4 +++- src/store/modules/tabActive.js | 20 +++++++++++++++++++ src/views/collect/CollectOrderTabs.vue | 4 ++++ src/views/collect/DealOrder.vue | 4 ++-- src/views/collect/IoCreateOrder.vue | 4 ++-- src/winExtend.js | 27 ++++++++++++++++++++------ 6 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 src/store/modules/tabActive.js diff --git a/src/store/index.js b/src/store/index.js index 97aaef80..45afb2a9 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -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 }) diff --git a/src/store/modules/tabActive.js b/src/store/modules/tabActive.js new file mode 100644 index 00000000..82333ce7 --- /dev/null +++ b/src/store/modules/tabActive.js @@ -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 +} + diff --git a/src/views/collect/CollectOrderTabs.vue b/src/views/collect/CollectOrderTabs.vue index 3c36edb7..a3df1d68 100644 --- a/src/views/collect/CollectOrderTabs.vue +++ b/src/views/collect/CollectOrderTabs.vue @@ -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); } } }) diff --git a/src/views/collect/DealOrder.vue b/src/views/collect/DealOrder.vue index 4726ef4e..0c8d2543 100644 --- a/src/views/collect/DealOrder.vue +++ b/src/views/collect/DealOrder.vue @@ -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) => { diff --git a/src/views/collect/IoCreateOrder.vue b/src/views/collect/IoCreateOrder.vue index 0a44c3e0..b1a46bf4 100644 --- a/src/views/collect/IoCreateOrder.vue +++ b/src/views/collect/IoCreateOrder.vue @@ -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; diff --git a/src/winExtend.js b/src/winExtend.js index 435d98e8..7b3601fe 100644 --- a/src/winExtend.js +++ b/src/winExtend.js @@ -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 参数必须是一个字符串数组'); } - // 触发自定义事件 - window.dispatchEvent(new CustomEvent('recCodes', { - detail: { - recCodes: codes - } - })); + console.log("菜单触发事件",store.state.tabActive.menuActive); + //触发自定义事件 + 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("收到空数据"); }