buhuazhen
5 天以前 f2e14fbd69737ca7717835fcc4e02c0f01de10d4
src/pages/production/twist/receive/monofil.vue
@@ -129,21 +129,45 @@
      return;
    }
    // 解析扫码数据
    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 (scanData.layer && scanData.layer !== currentLayer.twistedLayer) {
      toast.error(
        `领用层级不对,当前层是:${currentLayer.twistedLayer},领用单丝层是:${scanData.layer}`
      );
      // return;
    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 } = await TwistApi.getScarn({
      outPutId: scanData.id,
      twistId: currentLayer.twistId,
    });
    // 检查当前层是否已存在该单丝
    const exists = currentLayer.strandedWireDish?.some(
@@ -172,6 +196,7 @@
    }
  } catch (error) {
    toast.error("二维码异常,请更换二维码!");
    console.log(error);
  }
};