From 2de633725d5e5d843853240933f63220dc4e4cb2 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 03 十二月 2025 16:53:57 +0800
Subject: [PATCH] fix: 导体会存在每隔一段距离需要标记的情况,需要通知工人进行标记。

---
 src/pages/production/twist/report/index.vue |  264 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 220 insertions(+), 44 deletions(-)

diff --git a/src/pages/production/twist/report/index.vue b/src/pages/production/twist/report/index.vue
index f63f742..5a0fe0d 100644
--- a/src/pages/production/twist/report/index.vue
+++ b/src/pages/production/twist/report/index.vue
@@ -2,7 +2,29 @@
   <view class="list">
     <z-paging ref="pagingRef" v-model="twistReportList" :fixed="false" @query="getTwistReportList">
       <template #top>
-        <CardTitle title="鎶ュ伐淇℃伅" :hideAction="true" :full="false" @action="addReport" />
+        <CardTitle title="鎶ュ伐淇℃伅" :hideAction="false" :full="false">
+          <template #action>
+            <wd-button
+              icon="chart"
+              :round="false"
+              size="small"
+              plain
+              style="margin-right: 10px"
+              @click="handleSelfCheck"
+            >
+              鑷
+            </wd-button>
+            <wd-button
+              icon="file-add"
+              :round="false"
+              size="small"
+              custom-class="add_btn"
+              @click="addReport"
+            >
+              鏂板
+            </wd-button>
+          </template>
+        </CardTitle>
       </template>
       <wd-card v-for="item in twistReportList" :key="item.id" type="rectangle" custom-class="round">
         <template #title>
@@ -12,15 +34,15 @@
               <text class="text-[#0D867F] ml-2 font-medium">鐢熶骇浜�</text>
               <text class="text-[#333333] ml-2">{{ item.productUser }}</text>
             </view>
-            <view class="text-[#A8A8A8]" @click="toEdit">缂栬緫</view>
+            <!-- <view class="text-[#A8A8A8]" @click="toEdit">缂栬緫</view> -->
           </view>
         </template>
-        <ProductionCard :data="cardAttr" :value="item" />
+        <TwistReportCard :data="cardAttr" :value="item" />
         <template #footer>
           <wd-button size="small" plain style="margin-right: 10px" @click="toAttachment(item)">
             闄勪欢
           </wd-button>
-          <wd-button size="small" plain @click="toCheck(item.id)">鑷</wd-button>
+          <wd-button size="small" plain type="error" @click="handleDelete(item)">鍒犻櫎</wd-button>
         </template>
       </wd-card>
     </z-paging>
@@ -30,12 +52,17 @@
         <wd-button type="text" @click="cancel">鍙栨秷</wd-button>
         <wd-button type="text" @click="submit">纭畾</wd-button>
       </view>
-      <TwistForm ref="twistFormRef" />
+      <TwistForm
+        ref="twistFormRef"
+        :first-tare-value="twistReportList.length > 0 ? twistReportList[0].tare : undefined"
+        :team-id="teamId"
+        :is-first-report="twistReportList.length === 0"
+      />
     </wd-popup>
     <wd-popup v-model="drawFormRef.visible" position="bottom" custom-class="yl-popup">
       <Draw
         :single-regulation-info-array="drawData.singleRegulationInfoArray"
-        :steel-regulation-info-array="drawData.steelRegulationInfoArray"
+        :steel-regulation-info="drawData.steelRegulationInfo"
         :reel-tooling-info="drawData.reelToolingInfo"
         :wire-id="drawData.wireId"
         @close="handleDrawClose"
@@ -47,13 +74,15 @@
 <script setup lang="ts">
 import CardTitle from "@/components/card-title/index.vue";
 import TwistForm from "./form.vue";
-import { useToast } from "wot-design-uni";
-import ProductionCard from "../../components/ProductionCard.vue";
+import { useToast, dayjs } from "wot-design-uni";
+import TwistReportCard from "../components/TwistReportCard.vue";
 import { onLoad } from "@dcloudio/uni-app";
-import { ref } from "vue";
+import { ref, reactive, nextTick } from "vue";
 import ManageApi from "@/api/product/manage";
 import TwistApi from "@/api/product/twist";
 import Draw from "./draw.vue";
+import HomeApi from "@/api/home";
+import { setTeamId, getTeamId, setPrepareId } from "@/utils/cache";
 
 const drawFormRef = reactive({
   visible: false,
@@ -63,7 +92,6 @@
 const handleDrawClose = () => {
   // 纭繚寮圭獥琚纭叧闂�
   drawFormRef.visible = false;
-  console.log('Draw popup closed');
 };
 const pagingRef = ref();
 const paramsId = ref();
@@ -74,43 +102,93 @@
 });
 const drawData = ref({
   singleRegulationInfoArray: [],
-  steelRegulationInfoArray: [],
-  reelToolingInfo: {},
+  steelRegulationInfo: {
+    model: "",
+    twistedDirection: "",
+    outerDiameter: "",
+    scratch: "",
+    oilStain: "",
+  },
+  reelToolingInfo: {
+    nutFixed: "",
+    sidePlateFlat: "",
+    centerPlateFlat: "",
+    paintQuality: "",
+    burrCrack: "",
+    edgeBlunt: "",
+    woodMold: "",
+    weldQuality: "",
+  },
   wireId: "",
 });
 
 const cardAttr = ref<any[]>([
   {
-    label: "棰嗙敤鏉嗗彿",
-    prop: "poleNumber",
-  },
-  {
-    label: "鏉嗛噸(kg)",
-    prop: "poleWeight",
-  },
-  {
-    label: "鍗曚笣鐩樺彿",
+    label: "鎵规鍙�",
     prop: "monofilamentNumber",
+    span: 24,
   },
   {
-    label: "瀹為檯閲嶉噺(kg)",
-    prop: "actuallyWeight",
+    label: "璐ㄩ噺杩芥函鍙�",
+    prop: "systemNo",
+    span: 24,
   },
   {
     label: "鐩橀暱(m)",
     prop: "oneLength",
   },
   {
-    label: "鐞嗚閲嶉噺(kg)",
-    prop: "theoryWeight",
-  },
-  {
     label: "瑙勬牸鍨嬪彿",
     prop: "model",
+  },
+  {
+    label: "鐢熶骇闀垮害(m)",
+    prop: "actuallyLength",
+  },
+  {
+    label: "鐩樺叿鐨噸(kg)",
+    prop: "tare",
+  },
+  {
+    label: "鐢熶骇鏃ユ湡",
+    prop: "productTime",
+    span: 24,
+  },
+  {
+    label: "鍔犲伐鏃堕棿(h)",
+    prop: "processHour",
   },
 ]);
 
 const twistReportList = ref<any[]>([]);
+const teamId = ref<string | number | null>(null);
+
+// 鑾峰彇骞剁紦瀛樼彮缁処D鍜岀敓浜у噯澶嘔D
+const initTeamId = async () => {
+  // 鍏堝皾璇曚粠缂撳瓨鑾峰彇
+  const cachedTeamId = getTeamId();
+  if (cachedTeamId) {
+    teamId.value = cachedTeamId;
+  }
+
+  // 璋冪敤鎺ュ彛鑾峰彇鏈�鏂版暟鎹�
+  try {
+    const { data } = await HomeApi.getIndex();
+    if (data) {
+      // 瀛樺偍鐝粍ID
+      if (data.id) {
+        teamId.value = data.id;
+        setTeamId(data.id);
+      }
+      // 瀛樺偍鐢熶骇鍑嗗ID
+      if (data.prepareId) {
+        setPrepareId(data.prepareId);
+      }
+    }
+  } catch (error) {
+    console.error("鑾峰彇鏁版嵁澶辫触:", error);
+  }
+};
 
 const toEdit = () => {
   uni.navigateTo({
@@ -118,21 +196,83 @@
   });
 };
 
-const addReport = () => {
-  dialog.visible = true;
+// 涓昏〃鏁版嵁
+const mainTableData = ref<any>({});
+
+// 鑾峰彇涓昏〃鏁版嵁
+const getMainTableData = async () => {
+  try {
+    const { data } = await TwistApi.getTwistDetailById({
+      id: paramsId.value,
+    });
+    mainTableData.value = {
+      model: data.model,
+      totalLength: data.totalLength,
+      systemNo: data.systemNo,
+    };
+    // 璁剧疆涓昏〃鏁版嵁鍒拌〃鍗曠粍浠�
+    if (twistFormRef.value) {
+      twistFormRef.value.setMainTableData(mainTableData.value);
+    }
+  } catch (error) {
+    console.error("鑾峰彇涓昏〃鏁版嵁澶辫触:", error);
+  }
+};
+
+const addReport = async () => {
+  // 妫�鏌ユ槸鍚︽墍鏈夋暟鎹兘宸蹭繚瀛橈紙閮芥湁id锛�
+  if (twistReportList.value.length > 0 && twistReportList.value.every((item) => item.id)) {
+    // 纭繚涓昏〃鏁版嵁宸茶幏鍙�
+    if (!mainTableData.value.model) {
+      await getMainTableData();
+    }
+    dialog.visible = true;
+    // 绛夊緟寮圭獥鎵撳紑鍚庤缃暟鎹�
+    await nextTick();
+    if (twistFormRef.value) {
+      twistFormRef.value.setMainTableData(mainTableData.value);
+    }
+  } else if (twistReportList.value.length === 0) {
+    // 纭繚涓昏〃鏁版嵁宸茶幏鍙�
+    if (!mainTableData.value.model) {
+      await getMainTableData();
+    }
+    dialog.visible = true;
+    // 绛夊緟寮圭獥鎵撳紑鍚庤缃暟鎹�
+    await nextTick();
+    if (twistFormRef.value) {
+      twistFormRef.value.setMainTableData(mainTableData.value);
+    }
+  } else {
+    toast.warning("璇峰厛淇濆瓨鏈潯鏁版嵁锛屽啀鏂板");
+  }
 };
 
 const submit = async () => {
+  // 楠岃瘉蹇呭~瀛楁 - 鏍规嵁鍙傝�冧唬鐮侊紝闇�瑕佹鏌ョ敓浜ч暱搴﹀拰鐩樺叿鐨噸
+  const formData = twistFormRef.value?.getFormData?.() || {};
+  const firstTareValue =
+    twistReportList.value.length > 0 ? twistReportList.value[0].tare : undefined;
+
+  if (!formData.actuallyLength) {
+    toast.warning("璇疯緭鍏ョ敓浜ч暱搴﹀悗鍐嶆彁浜�");
+    return;
+  }
+
+  if (!formData.tare && !firstTareValue) {
+    toast.warning("璇疯緭鍏ョ洏鍏风毊閲嶅悗鍐嶆彁浜�");
+    return;
+  }
+
   const isSuccess = await twistFormRef.value.submit();
-  dialog.visible = !isSuccess; // 濡傛灉鎻愪氦鎴愬姛锛屽叧闂脊绐�
   if (isSuccess) {
-    // 鎻愪氦鎴愬姛鍚庢墽琛�
-    showDrawPopup();
+    dialog.visible = false;
+    // 鎻愪氦鎴愬姛鍚庡埛鏂板垪琛�
+    pagingRef.value?.reload();
   }
 };
 
 const cancel = () => {
-  toast.show("鍙栨秷");
   dialog.visible = false;
 };
 
@@ -151,14 +291,13 @@
     const { data } = await TwistApi.querySingleDishInspection({
       id: paramsId.value,
     });
-    console.log("棰嗙敤淇℃伅鏁版嵁:", data);
     // 閫傞厤涓嶅悓鐨勬暟鎹粨鏋勮繑鍥炴牸寮�
     const responseData = data.data || data;
     if (responseData && responseData.singleWirePrePareInfoVo) {
       const info = responseData.singleWirePrePareInfoVo;
       drawData.value = {
         singleRegulationInfoArray: info.singleRegulationInfoArray || [],
-        steelRegulationInfoArray: info.steelRegulationInfoArray || [],
+        steelRegulationInfo: info.steelRegulationInfo || {},
         reelToolingInfo: info.reelToolingInfo || {},
         wireId: paramsId.value,
       };
@@ -166,7 +305,7 @@
       drawFormRef.visible = true;
       toast.success("璇峰~鍐欓鐢ㄤ俊鎭�!");
     } else {
-      toast.error("宸插瓨鍦ㄩ鐢ㄤ俊鎭�,鏃犻渶濉姤!");
+      // toast.error("宸插瓨鍦ㄩ鐢ㄤ俊鎭�,鏃犻渶濉姤!");
     }
   } catch (error) {
     console.error("鑾峰彇棰嗙敤淇℃伅澶辫触:", error);
@@ -174,15 +313,39 @@
   }
 };
 
-const closeDrawPopup = () => {
-  drawDialogVisible.value = false;
+const handleSelfCheck = () => {
+  // 璺宠浆鍒拌嚜妫�椤甸潰锛屼紶閫� wireId
+  uni.navigateTo({
+    url: `/pages/production/twist/selfInspect/index?id=${paramsId.value}`,
+  });
 };
 
-const handleSelfCheck = (id: string) => {
-  console.log("鎵ц鑷鎿嶄綔锛孖D:", id);
-  uni.showToast({
-    title: "鑷鍔熻兘寮�鍙戜腑",
-    icon: "none",
+// 鍒犻櫎鎶ュ伐璁板綍
+const handleDelete = (item: any) => {
+  uni.showModal({
+    title: "鎻愮ず",
+    content: "纭畾鍒犻櫎鍚楋紵",
+    success: async (res) => {
+      if (res.confirm) {
+        try {
+          if (item.id) {
+            const { code } = await TwistApi.deleteWireOutput({ id: item.id });
+            if (code == 200) {
+              toast.success("鍒犻櫎鎴愬姛");
+              // 鍒锋柊鍒楄〃
+              pagingRef.value?.reload();
+            } else {
+              toast.error("鍒犻櫎澶辫触");
+            }
+          } else {
+            toast.warning("璇ヨ褰曞皻鏈繚瀛橈紝鏃犳硶鍒犻櫎");
+          }
+        } catch (error) {
+          console.error("鍒犻櫎澶辫触:", error);
+          toast.error("鍒犻櫎澶辫触锛岃閲嶈瘯");
+        }
+      }
+    },
   });
 };
 
@@ -197,11 +360,24 @@
     wireId: paramsId.value,
     type: "缁炵嚎",
   });
+  // 鏍煎紡鍖栫敓浜ф棩鏈�
+  if (Array.isArray(data)) {
+    data.forEach((item: any) => {
+      if (item.productTime) {
+        item.productTime = dayjs(item.productTime).format("YYYY-MM-DD HH:mm:ss");
+      }
+    });
+  }
   pagingRef.value.complete(data);
 };
 
-onLoad((options: any) => {
+onLoad(async (options: any) => {
   paramsId.value = options.id;
+  // 鑾峰彇骞剁紦瀛樼彮缁処D
+  await initTeamId();
+  // 鑾峰彇涓昏〃鏁版嵁
+  await getMainTableData();
+  showDrawPopup();
 });
 </script>
 

--
Gitblit v1.9.3