diff --git a/.env.development b/.env.development index 45e70ba5..d23661e2 100644 --- a/.env.development +++ b/.env.development @@ -6,7 +6,7 @@ ENV = 'development' # 开发环境 # VUE_APP_BASE_API = 'https://mudi.dsxyy.org/UDI_WMS_MC/' -VUE_APP_BASE_API = 'http://127.0.0.1:9991' +VUE_APP_BASE_API = 'http://192.168.0.166:9991' VUE_APP_SYNC_API ="http://127.0.0.1:10001" # VUE_APP_BASE_API = 'http://dm.xmglxp.com:81/UDI_WMS_MC/' # 应用访问路径 例如使用前缀 /admin/ diff --git a/src/api/basic/product/udiRelevance.js b/src/api/basic/product/udiRelevance.js index 13727978..95d72553 100644 --- a/src/api/basic/product/udiRelevance.js +++ b/src/api/basic/product/udiRelevance.js @@ -234,4 +234,11 @@ export function getYbDrugDetail(query) { }); } +export function getCodeRelDetail(query) { + return axios({ + url: "/spms/udchs/codeRe/list", + method: "post", + data: query + }); +} diff --git a/src/views/basic/product/productEdit.vue b/src/views/basic/product/productEdit.vue index 80b5705a..efdc1abc 100644 --- a/src/views/basic/product/productEdit.vue +++ b/src/views/basic/product/productEdit.vue @@ -1149,7 +1149,7 @@ import { removeDiRl, removeRl, thirdSysDetail, - updatetSingleUdiInfo, updatetUdiInfos + updatetSingleUdiInfo, updatetUdiInfos,getCodeRelDetail } from "@/api/basic/product/udiRelevance"; import {isBlank} from "@/utils/strUtil"; import {filterByUuid, levelByUuid} from "@/api/basic/product/udiInfo"; @@ -1251,6 +1251,7 @@ export default { measname: null, manufactory: null, ybbm: null, + sptm: null, cpms: null, productsType: 2, //高级设置默认开启扫码 @@ -1745,6 +1746,20 @@ export default { this.selectedIndex = null this.getDetailList() this.getDiLevel(); + + //如果都为空 进行补充 + if (!this.$isNotBlank(this.editQuery.sptm) && !this.$isNotBlank(this.editQuery.ybbm)) { + getCodeRelDetail({drugcode:row.nameCode}).then((response) => { + if (response.code == 20000) { + if (this.response.data != null && this.response.data.length > 0) { + this.editQuery.sptm = this.response.data[0].sptm; + this.editQuery.ybbm = this.response.data[0].ybbm; + } + } + }).catch(() => { + }) + } + } else { this.isSave = true this.$message.error(res.message) diff --git a/src/views/collect/CollectOrderTabs.vue b/src/views/collect/CollectOrderTabs.vue index eb99fd4b..c0e81a84 100644 --- a/src/views/collect/CollectOrderTabs.vue +++ b/src/views/collect/CollectOrderTabs.vue @@ -517,6 +517,7 @@ export default { if (foundTab) { // 如果找到了,执行一些操作 this.menuActive = foundTab.number + // 上面这个呀呀呀呀呀呀呀呀 this.$set(this.resetKeys, foundTab.name, Date.now()); this.$store.commit('tabActive/SET_MENU_ACTIVE', foundTab.number); } diff --git a/src/views/collect/DealOrder.vue b/src/views/collect/DealOrder.vue index ab11abc9..2f4602ae 100644 --- a/src/views/collect/DealOrder.vue +++ b/src/views/collect/DealOrder.vue @@ -195,7 +195,8 @@ - 定向查询 + 定向查询 + { if (response.code === 20000) { this.$refs.inputRef.focus(); @@ -1173,7 +1178,7 @@ export default { vailOrderFinish() { - if (!this.autoFinishOrderFlag){ + if (!this.autoFinishOrderFlag) { return } vailOrderFinish(this.formData).then(res => { @@ -1353,6 +1358,23 @@ export default { }); }, + handleScanComplete(fullScanData) { + console.log("Scan complete:", fullScanData.join(";")); + if (this.formData.billNo == null && this.formDataVisible.scanType != 1) { + this.enterBillNoKey(fullScanData[0]) + return; + } + let params = { + codeList: fullScanData, + }; + if (this.formData.billNo == null) { + this.$message.error("请先选入单据!"); + return + } + this.batchVailCode(params) + // 在这里处理完整的扫码数据,如提交到后台或显示 + }, + parseString(str) { // 1. 判断是否以 "MA" 开头 if (str.startsWith("MA")) { @@ -1382,6 +1404,62 @@ export default { // 如果没有任何条件满足,返回 false return false; }, + socketListener() { + let lastScanTime = Date.now(); + let scanBuffer = []; + let scanTimeout = null; + const SCAN_TIMEOUT = 1000; // 1秒间隔,表示扫码结束的判定标准 + const self = this; + console.log("启用监听") + this.ws.onmessage = function (event) { + let scanData = event.data; // 获取扫码数据 + let currentTime = Date.now(); + console.log(scanData) + // 如果时间间隔超过预设的阈值,表示这是一次新的扫码 + if (currentTime - lastScanTime > SCAN_TIMEOUT) { + // 处理上一次完整的扫码数据 + if (scanBuffer.length > 0) { + self.handleScanComplete(scanBuffer); + } + // 清空缓冲区,开始新的扫码 + scanBuffer = []; + } + // 重置上一次扫码的时间 + lastScanTime = currentTime; + // 将数据添加到缓冲区 + scanBuffer.push(scanData); + + // 如果已经有一个定时器在等待,可以清除它 + if (scanTimeout) { + clearTimeout(scanTimeout); + } + // 设置新的定时器,等待指定的时间后执行扫码结束处理 + scanTimeout = setTimeout(() => { + // 定时器到时,处理扫码结束 + self.handleScanComplete(scanBuffer); + scanBuffer = []; + }, SCAN_TIMEOUT); + }; + }, + handleVisibilityChange() { + if (document.visibilityState === 'visible') { + console.log('用户切回到了处理页面'); + if (this.ws == null || this.ws.readyState === WebSocket.CLOSED) { + this.ws = new WebSocket("ws://127.0.0.1:9988"); + const self = this; + this.ws.onopen = function (evt) { + console.log("处理单据WebSocket 连接中 ..."); + self.socketListener() + }; + + } + } else { + if (this.ws && this.ws.readyState === WebSocket.OPEN) { + this.ws.close(); + console.log("关闭处理单据websocket成功") + } + } + }, }, mounted() { this.$refs.inputRef.focus(); @@ -1391,9 +1469,36 @@ export default { window.removeEventListener('djcl', this.handleRecCodesEvent); window.addEventListener('djcl', this.handleRecCodesEvent); } + document.addEventListener('visibilitychange', this.handleVisibilityChange); + // window.addEventListener('storage', (event) => { + // if (document.visibilityState == 'hidden') { + // console.log("关闭处理单据websocket") + // if (this.ws && this.ws.readyState === WebSocket.OPEN) { + // this.ws.close(); + // console.log("关闭处理单据websocket成功") + // } + // } else { + // if (!this.ws) { + // this.ws = new WebSocket("ws://127.0.0.1:9988"); + // this.ws.onopen = function (evt) { + // console.log("处理单据WebSocket 连接中 ..."); + // }; + // this.socketListener() + // } + // } + // }); + }, + + beforeDestroy() { window.removeEventListener('djcl', this.handleRecCodesEvent); + document.removeEventListener('visibilitychange', this.handleVisibilityChange); + + this.ws.close(); + this.ws.onclose = function (evt) { + console.log("处理单据 Connection closed."); + }; }, created() { getHead("prescribeTagCodeDeal", "1").then((re) => { diff --git a/src/views/collect/IoCreateOrder.vue b/src/views/collect/IoCreateOrder.vue index 42c406fb..11d6f3a7 100644 --- a/src/views/collect/IoCreateOrder.vue +++ b/src/views/collect/IoCreateOrder.vue @@ -14,7 +14,6 @@ - 选入已完成单据 @@ -2089,9 +2088,71 @@ export default { this.$message.error("获取错误") } }) + }, + handleScanComplete(fullScanData) { + console.log('接收 recCodes event:', fullScanData.join(";")); + let params = { + codeList: fullScanData, + }; + this.batchVailCode(params) + }, + socketListener() { + let lastScanTime = Date.now(); + let scanBuffer = []; + let scanTimeout = null; + const SCAN_TIMEOUT = 1000; // 1秒间隔,表示扫码结束的判定标准 + const self = this; + console.log("启用监听") + this.ws.onmessage = function (event) { + let scanData = event.data; // 获取扫码数据 + let currentTime = Date.now(); + console.log(scanData) + // 如果时间间隔超过预设的阈值,表示这是一次新的扫码 + if (currentTime - lastScanTime > SCAN_TIMEOUT) { + // 处理上一次完整的扫码数据 + if (scanBuffer.length > 0) { + self.handleScanComplete(scanBuffer); + } + // 清空缓冲区,开始新的扫码 + scanBuffer = []; + } + // 重置上一次扫码的时间 + lastScanTime = currentTime; + // 将数据添加到缓冲区 + scanBuffer.push(scanData); + + // 如果已经有一个定时器在等待,可以清除它 + if (scanTimeout) { + clearTimeout(scanTimeout); + } + // 设置新的定时器,等待指定的时间后执行扫码结束处理 + scanTimeout = setTimeout(() => { + // 定时器到时,处理扫码结束 + self.handleScanComplete(scanBuffer); + scanBuffer = []; + }, SCAN_TIMEOUT); + }; + }, + handleVisibilityChange() { + if (document.visibilityState === 'visible') { + console.log('用户切回到了工位页面'); + if (this.ws == null || this.ws.readyState === WebSocket.CLOSED) { + this.ws = new WebSocket("ws://127.0.0.1:9988"); + const self = this; + this.ws.onopen = function (evt) { + console.log("工位上货WebSocket 连接中 ..."); + self.socketListener() + }; - } + } + } else { + if (this.ws && this.ws.readyState === WebSocket.OPEN) { + this.ws.close(); + console.log("关闭处理单据websocket成功") + } + } + }, }, filters: {}, mounted() { @@ -2126,9 +2187,31 @@ export default { window.removeEventListener('gwsh', this.handleRecCodesEvent); window.addEventListener('gwsh', this.handleRecCodesEvent); } + document.addEventListener('visibilitychange', this.handleVisibilityChange); + // window.addEventListener('storage', (event) => { + // console.log("关闭上货单据websocket") + // if (this.ws && this.ws.readyState === WebSocket.OPEN) { + // this.ws.close(); + // console.log("关闭上货单据websocket成功") + // } else { + // if (!this.ws) { + // this.ws = new WebSocket("ws://127.0.0.1:9988"); + // this.ws.onopen = function (evt) { + // console.log("处理单据WebSocket 连接中 ..."); + // }; + // this.socketListener() + // } + // } + // }); + // window.dispatchEvent(new CustomEvent('storage', null)); }, beforeDestroy() { window.removeEventListener('gwsh', this.handleRecCodesEvent); + this.ws.close(); + this.ws.onclose = function (evt) { + console.log("工位上货Connection closed."); + }; + document.removeEventListener('visibilitychange', this.handleVisibilityChange); }, created() { // this.splitType = this.$route.query.splitType; diff --git a/src/views/inout/DialogCreateOrder.vue b/src/views/inout/DialogCreateOrder.vue index 06d8c670..736fd0b1 100644 --- a/src/views/inout/DialogCreateOrder.vue +++ b/src/views/inout/DialogCreateOrder.vue @@ -909,14 +909,14 @@ export default { let query = { code: this.orderFormData.invCode, editType: 2, //可编辑 - productType:1 + productType: 1 }; if (this.viewTypeKsck) { query = { code: this.orderFormData.invCode, editType: 2, //可编辑 useDyCount: 2, //可编辑 - productType:1 + productType: 1 }; }