From 5b62f70d5df5731a571d709f0f9ff312a7cec5dc Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 20 十一月 2025 16:25:59 +0800
Subject: [PATCH] fix: 巡检加上绞合外径可选

---
 src/pages/production/twist/report/index.vue |  396 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 337 insertions(+), 59 deletions(-)

diff --git a/src/pages/production/twist/report/index.vue b/src/pages/production/twist/report/index.vue
index 602f50a..5a0fe0d 100644
--- a/src/pages/production/twist/report/index.vue
+++ b/src/pages/production/twist/report/index.vue
@@ -1,29 +1,72 @@
 <template>
-  <view class="page pt-2">
-    <CardTitle title="鎶ュ伐淇℃伅" :hideAction="true" @action="addReport" />
-    <view class="list">
-      <wd-card v-for="(item, index) in 6" type="rectangle" custom-class="round">
+  <view class="list">
+    <z-paging ref="pagingRef" v-model="twistReportList" :fixed="false" @query="getTwistReportList">
+      <template #top>
+        <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>
           <view class="flex justify-between">
             <view>
               <wd-icon name="user" color="#0D867F"></wd-icon>
               <text class="text-[#0D867F] ml-2 font-medium">鐢熶骇浜�</text>
-              <text class="text-[#333333] ml-2">鏂瑰厗鐜�</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" />
+        <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 type="error" @click="handleDelete(item)">鍒犻櫎</wd-button>
+        </template>
       </wd-card>
-      <wd-loadmore custom-class="loadmore" state="loading" />
-    </view>
+    </z-paging>
 
     <wd-popup v-model="dialog.visible" position="bottom" custom-class="yl-popup">
       <view class="action px-3">
         <wd-button type="text" @click="cancel">鍙栨秷</wd-button>
         <wd-button type="text" @click="submit">纭畾</wd-button>
       </view>
-      <TwistForm />
+      <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="drawData.steelRegulationInfo"
+        :reel-tooling-info="drawData.reelToolingInfo"
+        :wire-id="drawData.wireId"
+        @close="handleDrawClose"
+      />
     </wd-popup>
     <wd-toast />
   </view>
@@ -31,52 +74,121 @@
 <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, 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,
+});
+
+// 澶勭悊draw缁勪欢鍏抽棴浜嬩欢
+const handleDrawClose = () => {
+  // 纭繚寮圭獥琚纭叧闂�
+  drawFormRef.visible = false;
+};
+const pagingRef = ref();
+const paramsId = ref();
+const twistFormRef = ref();
 const toast = useToast();
 const dialog = reactive({
   visible: false,
 });
+const drawData = ref({
+  singleRegulationInfoArray: [],
+  steelRegulationInfo: {
+    model: "",
+    twistedDirection: "",
+    outerDiameter: "",
+    scratch: "",
+    oilStain: "",
+  },
+  reelToolingInfo: {
+    nutFixed: "",
+    sidePlateFlat: "",
+    centerPlateFlat: "",
+    paintQuality: "",
+    burrCrack: "",
+    edgeBlunt: "",
+    woodMold: "",
+    weldQuality: "",
+  },
+  wireId: "",
+});
 
 const cardAttr = ref<any[]>([
   {
-    label: "鍚堝悓鍙�",
-    value: "ht2921246",
-  },
-  {
-    label: "鐘舵��",
-    value: "-----",
-  },
-  {
-    label: "瀹㈡埛鍚嶇О",
-    value: "澶忓織璞�",
-  },
-  {
-    label: "鏈哄彴",
-    value: "-----",
-  },
-  {
-    label: "瑙勬牸鍨嬪彿",
-    value: "2921246",
-  },
-  {
-    label: "宸茬敓浜ф暟閲�",
-    value: "0",
-  },
-  {
-    label: "鐩橀暱(m)",
-    value: "292",
-  },
-  {
-    label: "璁″垝鏁伴噺",
-    value: "100",
+    label: "鎵规鍙�",
+    prop: "monofilamentNumber",
+    span: 24,
   },
   {
     label: "璐ㄩ噺杩芥函鍙�",
-    value: "JX-1838",
+    prop: "systemNo",
+    span: 24,
+  },
+  {
+    label: "鐩橀暱(m)",
+    prop: "oneLength",
+  },
+  {
+    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({
@@ -84,34 +196,200 @@
   });
 };
 
-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 submit = () => {
-  toast.show("鎻愪氦");
-  dialog.visible = false;
+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();
+  if (isSuccess) {
+    dialog.visible = false;
+    // 鎻愪氦鎴愬姛鍚庡埛鏂板垪琛�
+    pagingRef.value?.reload();
+  }
 };
 
 const cancel = () => {
-  toast.show("鍙栨秷");
   dialog.visible = false;
 };
+
+const toAttachment = (item: any) => {
+  uni.navigateTo({
+    url: "/pages/production/twist/attachment/index",
+    success: () => {
+      // 椤甸潰璺宠浆鎴愬姛鍚庡彂閫佷簨浠朵紶閫掓暟鎹�
+      uni.$emit("detailData", item);
+    },
+  });
+};
+
+const showDrawPopup = async () => {
+  try {
+    const { data } = await TwistApi.querySingleDishInspection({
+      id: paramsId.value,
+    });
+    // 閫傞厤涓嶅悓鐨勬暟鎹粨鏋勮繑鍥炴牸寮�
+    const responseData = data.data || data;
+    if (responseData && responseData.singleWirePrePareInfoVo) {
+      const info = responseData.singleWirePrePareInfoVo;
+      drawData.value = {
+        singleRegulationInfoArray: info.singleRegulationInfoArray || [],
+        steelRegulationInfo: info.steelRegulationInfo || {},
+        reelToolingInfo: info.reelToolingInfo || {},
+        wireId: paramsId.value,
+      };
+      // 鏄剧ずDraw寮圭獥
+      drawFormRef.visible = true;
+      toast.success("璇峰~鍐欓鐢ㄤ俊鎭�!");
+    } else {
+      // toast.error("宸插瓨鍦ㄩ鐢ㄤ俊鎭�,鏃犻渶濉姤!");
+    }
+  } catch (error) {
+    console.error("鑾峰彇棰嗙敤淇℃伅澶辫触:", error);
+    toast.error("鑾峰彇淇℃伅澶辫触锛岃閲嶈瘯");
+  }
+};
+
+const handleSelfCheck = () => {
+  // 璺宠浆鍒拌嚜妫�椤甸潰锛屼紶閫� wireId
+  uni.navigateTo({
+    url: `/pages/production/twist/selfInspect/index?id=${paramsId.value}`,
+  });
+};
+
+// 鍒犻櫎鎶ュ伐璁板綍
+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("鍒犻櫎澶辫触锛岃閲嶈瘯");
+        }
+      }
+    },
+  });
+};
+
+// 淇濈暀鍘熸湁鐨刢onfirm鍑芥暟锛岀敤浜庡叾浠栧湴鏂硅皟鐢�
+// const confirm = async () => {
+//   await showDrawPopup();
+// };
+
+// 鑾峰彇鎷変笣鎶ュ伐鍒楄〃
+const getTwistReportList = async () => {
+  const { data } = await ManageApi.getReportList({
+    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(async (options: any) => {
+  paramsId.value = options.id;
+  // 鑾峰彇骞剁紦瀛樼彮缁処D
+  await initTeamId();
+  // 鑾峰彇涓昏〃鏁版嵁
+  await getMainTableData();
+  showDrawPopup();
+});
 </script>
 
 <style lang="scss" scoped>
-.page {
+.list {
+  height: calc(100vh - 80px);
+  padding: 12px;
   background: #f3f9f8;
 
-  .list {
-    height: calc(100vh - 120px);
-    margin: 12px;
-    overflow: scroll;
-
-    :deep() {
-      .round {
-        border-radius: 4px;
-      }
+  :deep() {
+    .round {
+      border-radius: 4px;
     }
   }
 }

--
Gitblit v1.9.3