chenhj
2025-07-29 ac599197755d425fe28b7597f2cedbd28b6bd44a
src/pages/production/twist/receive/monofil.vue
@@ -5,6 +5,7 @@
      v-model="cardList"
      :fixed="false"
      :auto-show-back-to-top="true"
      :loading-more-enabled="false"
      @query="getList"
    >
      <template #top>
@@ -23,7 +24,7 @@
        </view>
      </template>
    </z-paging>
    <Scan ref="scanRef" />
    <Scan ref="scanRef" emitName="scanMono" />
    <wd-toast />
  </view>
</template>
@@ -32,7 +33,7 @@
import CardTitle from "@/components/card-title/index.vue";
import MonofilCard from "../components/MonofilCard.vue";
import { useToast } from "wot-design-uni";
import { onLoad, onUnload, onShow, onHide } from "@dcloudio/uni-app";
import { onLoad, onUnload } from "@dcloudio/uni-app";
import Scan from "@/components/scan/index.vue";
import ManageApi from "@/api/product/manage";
import TwistApi from "@/api/product/twist";
@@ -49,17 +50,26 @@
const getScanCode = async (code: any) => {
  console.log("自定义扫描的结果回调函数:", code);
  // let parseData = code.trim();
  let codeArr = code.code.split(",");
  console.log("sb:", codeArr);
  console.log("code:===========", JSON.parse(code.code));
  console.log("id:=============", JSON.parse(code.code).id);
  const { data } = await TwistApi.getScarn({
    outPutId: codeArr[1],
    outPutId: JSON.parse(code.code).id,
  });
  const exists = cardList.value.some((item) => item.id === data.id);
  const exists = cardList.value.some((item) => item.monofilamentNumber === data.monofilamentNumber);
  if (!exists) {
    const { id, outPutId, ...rest } = data;
    const { id, outPutId, wireId, oneLength, ...rest } = data;
    console.log("sb", {
      wireId: paramsId.value,
      outputId: id,
      amount: oneLength,
      ongLength: oneLength,
      ...rest,
    });
    cardList.value.push({
      outPutId: id,
      wireId: paramsId.value,
      outputId: id,
      amount: oneLength,
      ongLength: oneLength,
      ...rest,
    });
    pagingRef.value.complete(cardList.value);
@@ -83,10 +93,14 @@
};
const save = async () => {
  const { code } = await TwistApi.addStrandedWireDish(cardList.value);
  const value = cardList.value.filter((item: { id?: number }) => item.id === undefined || item.id === null);
  const { code,msg } = await TwistApi.addStrandedWireDish(value);
  if (code == 200) {
    toast.success("保存成功");
    toast.success(msg);
    cardList.value = [];
    pagingRef.value.refresh();
    getList();
  } else {
    toast.error("保存失败");
  }
@@ -94,17 +108,13 @@
onLoad((options: any) => {
  // 开启广播监听事件
  uni.$on("scan", getScanCode);
  uni.$on("scanMono", getScanCode);
  paramsId.value = options.id;
});
onUnload(() => {
  // 开启广播监听事件
  uni.$off("scan", getScanCode);
  uni.$off("scanMono", getScanCode);
});
onShow(() => {});
onHide(() => {});
</script>
<style lang="scss" scoped>