| | |
| | | let tagData: any = null; |
| | | let outPutId: string | number | undefined; |
| | | let monofilamentNumber: string | undefined; |
| | | let needContractCheck = false; // 是否需要进行合同号校验(只对绞线) |
| | | |
| | | if (isJsonCode) { |
| | | // ===== 绞线等原有二维码逻辑(JSON) ===== |
| | |
| | | } |
| | | |
| | | outPutId = scanData.id; |
| | | monofilamentNumber = scanData.monofilamentNumber; |
| | | |
| | | if (!outPutId) { |
| | | toast.error("二维码格式错误,缺少id信息"); |
| | | if (outPutId) { |
| | | //TODO兼容目前已打印的二维码 |
| | | // 有 id:按 id 查重并调 getTagByIdAll(返回数组) |
| | | const exists = goodsList.value.some((item) => { |
| | | const itemId = item.id; |
| | | return itemId && itemId === outPutId && itemId !== "-"; |
| | | }); |
| | | if (exists) { |
| | | toast.error("该条码已存在,请勿重复扫码"); |
| | | return; |
| | | } |
| | | const { data } = await OutboundApi.getTagByIdAll({ |
| | | outPutId: outPutId, |
| | | }); |
| | | tagData = data; |
| | | if (!tagData) { |
| | | toast.error("未查询到条码信息"); |
| | | return; |
| | | } |
| | | } else if (monofilamentNumber) { |
| | | // 有 monofilamentNumber:按单丝号查重并调 getTagByMonofilamentNumber(返回对象) |
| | | const exists = goodsList.value.some((item) => { |
| | | const itemMono = item.monofilamentNumber; |
| | | return itemMono && itemMono === monofilamentNumber && itemMono !== "-"; |
| | | }); |
| | | if (exists) { |
| | | toast.error("该条码已存在,请勿重复扫码"); |
| | | return; |
| | | } |
| | | const { data } = await OutboundApi.getTagByMonofilamentNumber({ |
| | | monofilamentNumber, |
| | | }); |
| | | if (!data || (Array.isArray(data) && !data.length)) { |
| | | toast.error("未查询到条码信息"); |
| | | return; |
| | | } |
| | | tagData = Array.isArray(data) ? data[0] : data; |
| | | outPutId = tagData?.id || monofilamentNumber; |
| | | } else { |
| | | toast.error("二维码格式错误,缺少id或单丝编号信息"); |
| | | return; |
| | | } |
| | | |
| | | // 检查是否已存在(根据 id 判断) |
| | | const exists = goodsList.value.some((item) => { |
| | | const itemId = item.id; |
| | | return itemId && itemId === outPutId && itemId !== "-"; |
| | | }); |
| | | |
| | | if (exists) { |
| | | toast.error("该条码已存在,请勿重复扫码"); |
| | | return; |
| | | } |
| | | |
| | | // 调用接口获取绞线/拉丝详细信息(含出库状态) |
| | | const { data } = await OutboundApi.getTagByIdAll({ |
| | | outPutId: outPutId, |
| | | }); |
| | | |
| | | const list = data || []; |
| | | if (!list.length) { |
| | | toast.error("未查询到条码信息"); |
| | | return; |
| | | } |
| | | |
| | | tagData = list[0]; |
| | | needContractCheck = true; // 只有绞线需要做合同号校验 |
| | | } else { |
| | | // ===== 单丝拉丝二维码逻辑(纯字符串) ===== |
| | | // 示例:ZD7z30202616101201#[@]01,Φ5.6,-,750826011001001,600.6 |
| | |
| | | return; |
| | | } |
| | | |
| | | // 调用拉丝接口:GET /mes/app/getTagByLsMonofilamentNumber?monofilamentNumber=xxxx |
| | | // 调用拉丝接口:GET /mes/app/getTagByMonofilamentNumber?monofilamentNumber=xxxx |
| | | let data; |
| | | try { |
| | | const response = await OutboundApi.getTagByLsMonofilamentNumber({ |
| | | const response = await OutboundApi.getTagByMonofilamentNumber({ |
| | | monofilamentNumber, |
| | | }); |
| | | data = response.data; |
| | |
| | | if (!formattedMonofilamentNumber) { |
| | | return; |
| | | } |
| | | |
| | | // 检查是否已存在(针对手动处理后的单丝号进行去重) |
| | | const isDuplicate = goodsList.value.some((item) => { |
| | | const itemMono = item.monofilamentNumber; |
| | | return itemMono && itemMono === formattedMonofilamentNumber; |
| | | }); |
| | | |
| | | if (isDuplicate) { |
| | | toast.error(`条码"${formattedMonofilamentNumber}"已存在,请勿重复扫码`); |
| | | return; |
| | | } |
| | | |
| | | const newItem = { |
| | | id: monofilamentNumber || "-", |
| | | contractNo: "未在mes中生产", |
| | |
| | | clienteleName: "-", |
| | | actuallyLength: "-", |
| | | productionDate: "-", |
| | | type: "", |
| | | type: "拉丝", |
| | | devicemodel: "", |
| | | state: "", |
| | | projectId: "", |
| | |
| | | toast.error("该条码已出库,无法重复出库"); |
| | | return; |
| | | } |
| | | |
| | | // 合同号校验:只对绞线(JSON 场景)进行校验 |
| | | if (needContractCheck) { |
| | | const scannedContractNo = tagData?.contractno || ""; |
| | | if (scannedContractNo && vsrccode.value && scannedContractNo !== vsrccode.value) { |
| | | toast.error(`合同号"${scannedContractNo}"与当前发货单为"${vsrccode.value}"不匹配`); |
| | | return; |
| | | } |
| | | } |
| | | // |
| | | // // 合同号校验:只对绞线(JSON 场景)进行校验 |
| | | // if (needContractCheck) { |
| | | // const scannedContractNo = tagData?.contractno || ""; |
| | | // if (scannedContractNo && vsrccode.value && scannedContractNo !== vsrccode.value) { |
| | | // toast.error(`合同号"${scannedContractNo}"与当前发货单为"${vsrccode.value}"不匹配`); |
| | | // return; |
| | | // } |
| | | // } |
| | | |
| | | // 提取数据字段(根据接口返回的数据结构) |
| | | const parsedData = { |
| | |
| | | scanCode: scanText, |
| | | }; |
| | | |
| | | // 再次检查是否已存在(针对手动处理后的单丝号进行去重) |
| | | const isDuplicate = goodsList.value.some((item) => { |
| | | const itemMono = item.monofilamentNumber; |
| | | const currentMono = parsedData.monofilamentNumber; |
| | | return itemMono && itemMono === currentMono && itemMono !== "-"; |
| | | }); |
| | | |
| | | if (isDuplicate) { |
| | | toast.error(`条码"${parsedData.monofilamentNumber}"已存在,请勿重复扫码`); |
| | | return; |
| | | } |
| | | |
| | | // 检查类型是否一致 |
| | | if (goodsList.value.length > 0) { |
| | | const firstItemType = goodsList.value[0].type; |
| | | const currentType = parsedData.type; |
| | | // 如果类型不一致,提示错误 |
| | | if (firstItemType && currentType && firstItemType !== currentType) { |
| | | toast.error(`目前只能进行${firstItemType}出库`); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | // 添加到列表 |
| | | const newItem = { |
| | | ...parsedData, |