| | |
| | | return; |
| | | } |
| | | |
| | | // 解析扫码数据,现在二维码只包含id |
| | | const scanData = JSON.parse(code.code); |
| | | // 解析扫码数据:可能包含 id(outPutId) 或 monofilamentNumber |
| | | let scanCode = code.code || code; |
| | | const scanData = JSON.parse(scanCode); |
| | | const outPutId = scanData.id; |
| | | const monofilamentNumber = scanData.monofilamentNumber; |
| | | |
| | | if (!outPutId) { |
| | | toast.error("二维码格式错误,缺少id信息"); |
| | | let data: any; |
| | | |
| | | if (outPutId) { |
| | | // 有 outPutId:先查层级,再调 scarn |
| | | const { data: tagData } = await TwistApi.getTagByIdLs({ |
| | | outPutId: outPutId, |
| | | }); |
| | | if (tagData.layer && tagData.layer !== currentLayer.twistedLayer) { |
| | | toast.error( |
| | | `领用层级不对,当前层是:${currentLayer.twistedLayer},领用单丝层是:${tagData.layer}` |
| | | ); |
| | | } |
| | | const res = await TwistApi.getScarn({ |
| | | outPutId: outPutId, |
| | | twistId: currentLayer.twistId, |
| | | }); |
| | | data = res.data; |
| | | } else if (monofilamentNumber) { |
| | | // 无 outPutId 有 monofilamentNumber:只调 scarnTag,返回含 layer 用于提示 |
| | | const res = await TwistApi.getScarnTag({ |
| | | monofilamentNumber, |
| | | twistId: currentLayer.twistId, |
| | | }); |
| | | data = res.data; |
| | | if (data.layer && data.layer !== currentLayer.twistedLayer) { |
| | | toast.error( |
| | | `领用层级不对,当前层是:${currentLayer.twistedLayer},领用单丝层是:${data.layer}` |
| | | ); |
| | | } |
| | | } else { |
| | | toast.error("二维码格式错误,缺少id或单丝编号信息"); |
| | | return; |
| | | } |
| | | |
| | | // 调用接口获取拉丝详细信息 |
| | | const { data: tagData } = await TwistApi.getTagByIdLs({ |
| | | outPutId: outPutId, |
| | | }); |
| | | |
| | | // 判断层级是否匹配(如果接口返回的数据中有layer字段) |
| | | if (tagData.layer && tagData.layer !== currentLayer.twistedLayer) { |
| | | toast.error( |
| | | `领用层级不对,当前层是:${currentLayer.twistedLayer},领用单丝层是:${tagData.layer}` |
| | | ); |
| | | // return; |
| | | } |
| | | |
| | | // 调用单丝领用扫码接口 |
| | | const { data } = await TwistApi.getScarn({ |
| | | outPutId: outPutId, |
| | | twistId: currentLayer.twistId, |
| | | }); |
| | | |
| | | // 检查当前层是否已存在该单丝 |
| | | const exists = currentLayer.strandedWireDish?.some( |
| | |
| | | } |
| | | } catch (error) { |
| | | toast.error("二维码异常,请更换二维码!"); |
| | | console.log(error); |
| | | } |
| | | }; |
| | | |