From 28c34d9a4b47b6d18b5d3d240c8d848361952e9c Mon Sep 17 00:00:00 2001 From: zane Date: Fri, 13 Sep 2024 14:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=96=E9=83=A8=E7=8E=AF=E5=A2=83=E6=BB=B4?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/inout/order.js | 17 +++++++++ src/api/inout/splitCode.js | 7 ++++ src/main.js | 2 ++ src/views/collect/DealOrder.vue | 54 +++++++++++++++++++++++++++-- src/views/collect/IoCreateOrder.vue | 48 ++++++++++++++++++++++++- src/winExtend.js | 17 +++++++++ 6 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 src/winExtend.js diff --git a/src/api/inout/order.js b/src/api/inout/order.js index 2803c2d8..a8ff179a 100644 --- a/src/api/inout/order.js +++ b/src/api/inout/order.js @@ -614,4 +614,21 @@ export function submitCheckResult(query) { }); } +export function batchVailCode(query) { + return axios({ + url: "warehouse/inout/batchVailCode", + method: "post", + data: query + }); +} + + +export function batchAddCode(query) { + return axios({ + url: "warehouse/inout/batchAddCode", + method: "post", + data: query + }); +} + diff --git a/src/api/inout/splitCode.js b/src/api/inout/splitCode.js index 41923fb5..5733d709 100644 --- a/src/api/inout/splitCode.js +++ b/src/api/inout/splitCode.js @@ -53,4 +53,11 @@ export function findInvRemindByBillNo(query) { } +export function orderbatchAddCode(query) { + return axios({ + url: "/udiwms/ioSplit/collect/order/batchAddCode", + method: "post", + data: query + }); +} diff --git a/src/main.js b/src/main.js index aa6634a8..27bc8d84 100644 --- a/src/main.js +++ b/src/main.js @@ -69,6 +69,7 @@ import deptSelect from "@/views/components/deptSelect/index.vue"; import planChooseDevice from "@/views/components/planChooseDevice/index.vue"; import _ from "loadsh" +import winExtend from "@/winExtend.js"; // 全局方法挂载 Vue.prototype.getDicts = getDicts; @@ -114,6 +115,7 @@ Vue.use(plugins); Vue.use(VueMeta); Vue.use(allTools); Vue.use(ShowMsgBox) +Vue.use(winExtend); DictData.install(); /** diff --git a/src/views/collect/DealOrder.vue b/src/views/collect/DealOrder.vue index 8c2127a2..ef5f7bdc 100644 --- a/src/views/collect/DealOrder.vue +++ b/src/views/collect/DealOrder.vue @@ -156,6 +156,7 @@ type="tel" placeholder="请点击输入框进行扫码设置或者扫码录入" v-model="scanCode" + :disabled="scanDisabled" > @@ -347,14 +348,14 @@ import prescribeOriginPanel from "./PannelOrderBiz"; import prescribeCodePanel from "./PanelOrderTagCode"; import PannelOrderBiz from "./PannelOrderBiz"; import {listPage} from "@/api/basic/workPlace/sysWorkplaceManage"; -import {enterCodeWeb} from "@/api/inout/order"; +import {enterCodeWeb,batchVailCode} from "@/api/inout/order"; import {draftOrder, finishOrder, startSplit, tagCode, updateOrder} from "@/api/collect/splitCreateOrder"; import {selectCorpList} from "@/api/basic/basicUnitMaintain"; import {getCurOrder, getNextOrder, findByBill, findFromCorp} from "@/api/collect/collectOrder"; import PanelOrderAllDetail from "@/views/collect/PanelOrderAllDetail"; import {getWorkBindBusTypes, removeBusTypeById} from '@/api/basic/workPlace/sysWorkplaceDocuments' import {getInvListByUser} from "@/api/system/invWarehouse"; - +import {orderbatchAddCode} from "@/api/inout/splitCode"; export default { /** * 处理处方 @@ -445,7 +446,9 @@ export default { busTypeTotal: 0, invList: [], - viewType: 1 + viewType: 1, + scanDisabled: false, + valiCodes: [] } }, @@ -996,9 +999,54 @@ export default { let corp = this.fromInvOptions.find(item => item.erpId === this.formData.fromCorp); this.formData.fromCorpName = corp.name }, + //处理事件 + handleRecCodesEvent(event) { + console.log('接收 recCodes event:',event.detail.recCodes); + let params = { + codeList: event.detail.recCodes, + }; + //校验 + batchVailCode(params).then((res) => { + if (res.code === 20000) { + this.valiCodes = []; + console.log("==滴码接收==",res.data); + let list = res.data; + list.forEach(item => { + if (item.status === 1) { + this.valiCodes.push(item.code); + } + }); + }else{ + this.$message.error(res.message) + } + }); + if(this.valiCodes != null && this.valiCodes.length > 0){ + //批量添加 + let params2 = { + workPlaceCode:this.formData.workPlaceCode, + codeList:this.valiCodes + } + orderbatchAddCode(params2).then((res) => { + if (res.code === 20000) { + this.$message.success("添加成功") + }else{ + this.$message.error(res.message) + } + }); + this.scanCode = this.valiCodes.join(";"); + } + } }, mounted() { this.$refs.inputRef.focus(); + //环境判断 + if(window.navigator.userAgent.indexOf("GLXP_PC") != -1){ + this.scanDisabled = true; + window.addEventListener('recCodes', this.handleRecCodesEvent); + } + }, + unmounted() { + window.removeEventListener('recCodes', this.handleRecCodesEvent); }, created() { getHead("prescribeTagCodeDeal", "1").then((re) => { diff --git a/src/views/collect/IoCreateOrder.vue b/src/views/collect/IoCreateOrder.vue index 73c42014..0a44c3e0 100644 --- a/src/views/collect/IoCreateOrder.vue +++ b/src/views/collect/IoCreateOrder.vue @@ -204,6 +204,7 @@ type="tel" placeholder="请点击输入框进行扫码设置或者扫码录入" v-model="scanCode" + :disabled="scanDisabled" > @@ -315,6 +316,7 @@ import { submitOrderWeb, saveOrderWeb, enterCodeWeb, submitAllocateBiz, rollbackWaitcheck, submitCodeResult, submitCheckResult, delmitBiz, + batchVailCode,batchAddCode } from "@/api/inout/order"; import {filterSubAll, findByFrom, findInvByUser} from "@/api/system/invSubWarehouse"; import {parseTime} from "@/utils/coTools"; @@ -570,6 +572,8 @@ export default { rowData: {}, curWorkPlace: null, fifoSplitEnable: false, + scanDisabled: false,//是否禁用扫码输入框 + valiCodes:[] }; }, components: { @@ -1846,7 +1850,41 @@ export default { this.showSearch = true } }, - + //处理事件 + handleRecCodesEvent(event) { + console.log('接收 recCodes event:',event.detail.recCodes); + let params = { + codeList: event.detail.recCodes, + }; + //校验 + batchVailCode(params).then((response) => { + if (response.code === 20000) { + console.log("==滴码接收==",response.data); + this.valiCodes = []; + let list = response.data; + list.forEach(item => { + if (item.status === 1) { + valiCodes.push(item.code); + } + }); + } + this.scanCode = this.valiCodes.join(";"); + }); + //批量添加 + if(this.valiCodes !=null && this.valiCodes.length > 0){ + let params2 = { + workPlaceCode:this.orderFormData.workPlaceCode, + codeList:this.valiCodes + } + batchAddCode(params2).then((res) => { + if (res.code === 20000) { + this.$message.success("添加成功") + }else{ + this.$message.error(res.message) + } + }); + } + } }, filters: {}, mounted() { @@ -1875,6 +1913,14 @@ export default { }; inputer.focus(); this.$refs.inputRef.focus(); + //环境判断 + if(window.navigator.userAgent.indexOf("GLXP_PC") != -1){ + this.scanDisabled = true; + window.addEventListener('recCodes', this.handleRecCodesEvent); + } + }, + unmounted() { + window.removeEventListener('recCodes', this.handleRecCodesEvent); }, created() { // this.splitType = this.$route.query.splitType; diff --git a/src/winExtend.js b/src/winExtend.js new file mode 100644 index 00000000..435d98e8 --- /dev/null +++ b/src/winExtend.js @@ -0,0 +1,17 @@ +//扩展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 + } + })); + }else{ + alert("收到空数据"); + } + +} \ No newline at end of file