From 27c416bf9742574411401fb67203ee9669e57c8a Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 26 十一月 2025 14:20:02 +0800
Subject: [PATCH] fix: 绞线报工的盘具领用和芯线领用的厂家字段使用字典维护做下拉框

---
 src/pages/production/detail/twistDetail.vue |   99 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 90 insertions(+), 9 deletions(-)

diff --git a/src/pages/production/detail/twistDetail.vue b/src/pages/production/detail/twistDetail.vue
index c4e5230..0f7be88 100644
--- a/src/pages/production/detail/twistDetail.vue
+++ b/src/pages/production/detail/twistDetail.vue
@@ -1,14 +1,19 @@
 <template>
   <view>
-    <ProductCard />
+    <ProductCard
+      :data="cardData"
+      :map="{
+        deviceModel: 'deviceModel',
+        model: 'model',
+        systemNo: 'systemNo',
+        totalAmount: 'totalAmount',
+        amount: 'amount',
+        unAmount: 'unAmount',
+      }"
+    />
     <view class="mx-3">
       <wd-grid class="rounded-lg" clickable>
-        <wd-grid-item
-          icon="computer"
-          link-type="navigateTo"
-          url="/pages/production/twist/report/index"
-          text="鎶ュ伐"
-        />
+        <wd-grid-item icon="computer" @click="handleReportClick" text="鎶ュ伐" />
         <!-- <wd-grid-item
           icon="chart"
           text="鑷"
@@ -18,13 +23,13 @@
         <wd-grid-item
           icon="tips"
           link-type="navigateTo"
-          url="/pages/production/twist/backman/index"
+          :url="`/pages/production/twist/backman/index?id=${paramsId}`"
           text="鏉傚伐"
         />
         <wd-grid-item
           icon="wallet"
           link-type="navigateTo"
-          url="/pages/production/twist/receive/index"
+          :url="`/pages/production/twist/receive/index?id=${paramsId}`"
           text="鏉愭枡棰嗙敤"
         />
       </wd-grid>
@@ -33,7 +38,83 @@
 </template>
 
 <script lang="ts" setup>
+import { onLoad } from "@dcloudio/uni-app";
 import ProductCard from "@/components/product_card/index.vue";
+import TwistApi from "@/api/product/twist";
+import { getPrepareId, setPrepareId, clearPrepareId } from "@/utils/cache";
+import HomeApi from "@/api/home";
+
+const paramsId = ref();
+const cardData = reactive({
+  deviceModel: undefined,
+  model: undefined,
+  systemNo: undefined,
+  totalAmount: undefined,
+  amount: undefined,
+  unAmount: undefined,
+});
+
+const getDetailData = async (id: string) => {
+  const { data } = await TwistApi.getTwistDetailById({
+    id: id,
+  });
+  cardData.deviceModel = data.deviceModel;
+  cardData.model = data.model;
+  cardData.systemNo = data.systemNo;
+  cardData.totalAmount = data.totalLength;
+  cardData.amount = data.length;
+  cardData.unAmount = data.unLength;
+};
+
+// 鑾峰彇骞剁紦瀛樼敓浜у噯澶嘔D
+const initPrepareId = async () => {
+  try {
+    const { data } = await HomeApi.getIndex();
+    if (data && data.prepareId) {
+      setPrepareId(data.prepareId);
+    } else {
+      // 濡傛灉娌℃湁 prepareId锛屾竻绌虹紦瀛�
+      clearPrepareId();
+    }
+  } catch (error) {
+    console.error("鑾峰彇鐢熶骇鍑嗗ID澶辫触:", error);
+    // 鑾峰彇澶辫触鏃朵篃娓呯┖缂撳瓨
+    clearPrepareId();
+  }
+};
+
+// 澶勭悊鎶ュ伐鐐瑰嚮
+const handleReportClick = () => {
+  const prepareId = getPrepareId();
+  console.log("缁炵嚎琛ㄦ牸鎶ュ伐妫�鏌� - prepareId鍊�:", prepareId);
+
+  // 濡傛灉prepareId涓虹┖鎴栨湭瀹氫箟锛岃鏄庣敓浜у噯澶囨湭瀹屾垚
+  if (!prepareId) {
+    console.log("缁炵嚎琛ㄦ牸鎶ュ伐闃绘 - 鐢熶骇鍑嗗鏈畬鎴�");
+    uni.showModal({
+      title: "鎻愮ず",
+      content: "璇峰湪鐢佃剳绔畬鎴愮敓浜у噯澶囩‘璁わ紝鍐嶈繘琛屾姤宸ユ搷浣�",
+      showCancel: false,
+      confirmText: "纭畾",
+      success: () => {
+        // 鐢ㄦ埛鐐瑰嚮纭畾鍚庯紝涓嶅仛浠讳綍鎿嶄綔
+      },
+    });
+    return;
+  }
+
+  // 濡傛灉鏈� prepareId锛屾甯歌烦杞�
+  uni.navigateTo({
+    url: `/pages/production/twist/report/index?id=${paramsId.value}`,
+  });
+};
+
+onLoad(async (options: any) => {
+  paramsId.value = options.id;
+  await getDetailData(options.id);
+  // 鑾峰彇骞剁紦瀛樼敓浜у噯澶嘔D
+  await initPrepareId();
+});
 </script>
 
 <style lang="scss" scoped></style>

--
Gitblit v1.9.3