spring
8 天以前 646135b9c54d6ccf5d47af30bf208bdfe5005017
src/pages/production/twist/receive/monofil.vue
@@ -25,7 +25,12 @@
        <block v-for="item in nodeList" :key="item">
          <wd-tab :title="item.twistedLayer" :name="item.twistedLayer">
            <scroll-view class="content" scroll-y>
              <MonofilCard v-for="(m, i) in item.strandedWireDish" :key="i" :data="m" />
              <MonofilCard
                v-for="(m, i) in item.strandedWireDish"
                :key="i"
                :data="m"
                @delete="handleDeleteCard(item, m)"
              />
            </scroll-view>
          </wd-tab>
        </block>
@@ -123,8 +128,32 @@
      toast.error("未找到当前选中的层");
      return;
    }
    // 解析扫码数据,现在二维码只包含id
    const scanData = JSON.parse(code.code);
    const outPutId = scanData.id;
    if (!outPutId) {
      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: JSON.parse(code.code).id,
      outPutId: outPutId,
      twistId: currentLayer.twistId,
    });
@@ -333,6 +362,44 @@
  }
};
// 删除卡片
const handleDeleteCard = async (layer: any, cardData: any) => {
  // 显示确认提示
  uni.showModal({
    title: "提示",
    content: "确定要删除该单丝吗?",
    success: async (res) => {
      if (res.confirm) {
        try {
          // 如果有id,调用接口删除
          if (cardData.id !== undefined && cardData.id !== null) {
            const { code, msg } = await TwistApi.deleteStrandedWireDish(cardData.id);
            if (code !== 200) {
              toast.error(msg || "删除失败");
              return;
            }
          }
          // 前端直接删除(无论是否有id,都从前端删除)
          if (layer.strandedWireDish && Array.isArray(layer.strandedWireDish)) {
            const index = layer.strandedWireDish.findIndex(
              (item: any) => item.monofilamentNumber === cardData.monofilamentNumber
            );
            if (index !== -1) {
              layer.strandedWireDish.splice(index, 1);
              toast.success("删除成功");
              // 刷新当前层的数据显示
              getList();
            }
          }
        } catch (error: any) {
          toast.error(error.msg || "删除失败");
        }
      }
    },
  });
};
onLoad(async (options: any) => {
  // 开启广播监听事件
  uni.$on("scanMono", getScanCode);