From c13c2bb15b501c74fe4270b0ae763e5c9422ee39 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 19 十一月 2025 10:02:52 +0800
Subject: [PATCH] fix: 重构绞线报工功能

---
 src/pages/production/components/Statistics.vue            |    4 
 src/pages/production/list/index.vue                       |   17 +
 src/pages/production/twist/report/index.vue               |  205 +++++++++++++++++++---
 src/api/product/twist.ts                                  |   10 +
 src/pages/production/detail/wireDetail.vue                |    3 
 src/pages/production/twist/components/TwistReportCard.vue |   37 ++++
 src/pages/production/twist/report/form.vue                |  184 ++++++++++++--------
 src/pages/production/detail/twistDetail.vue               |    3 
 src/pages/production/index.vue                            |   40 ++++
 src/components/product_card/index.vue                     |   13 +
 src/utils/cache.ts                                        |   17 +
 src/pages/production/wire/attachment/index.vue            |    1 
 12 files changed, 424 insertions(+), 110 deletions(-)

diff --git a/src/api/product/twist.ts b/src/api/product/twist.ts
index aec3912..086f1d3 100644
--- a/src/api/product/twist.ts
+++ b/src/api/product/twist.ts
@@ -87,6 +87,16 @@
       method: "DELETE",
     });
   },
+
+  // 鍒犻櫎缁炵嚎鎶ュ伐
+  deleteWireOutput(params: { id: number }) {
+    // 灏嗗弬鏁版嫾鎺ュ埌 URL 浣滀负 query 鍙傛暟
+    const queryString = `?id=${params.id}`;
+    return request<BaseResult<any>>({
+      url: `/strandedWire/deleteWireOutput${queryString}`,
+      method: "DELETE",
+    });
+  },
 };
 
 export default TwistApi;
diff --git a/src/components/product_card/index.vue b/src/components/product_card/index.vue
index 9fb6b8c..24ff6e9 100644
--- a/src/components/product_card/index.vue
+++ b/src/components/product_card/index.vue
@@ -8,6 +8,19 @@
         </wd-tag>
       </view>
     </template>
+    <wd-row class="my-2" v-if="data[map.systemNo]">
+      <wd-col :span="24">
+        <view class="flex">
+          <view class="icon_box">
+            <wd-icon name="folder" color="#0D867F"></wd-icon>
+          </view>
+          <text class="text-[#646874] mx-2">
+            璐ㄩ噺杩芥函鍙�:
+            <text class="text-[#252525]">{{ data[map.systemNo] }}</text>
+          </text>
+        </view>
+      </wd-col>
+    </wd-row>
     <wd-row class="my-2">
       <wd-col :span="12">
         <view class="flex">
diff --git a/src/pages/production/components/Statistics.vue b/src/pages/production/components/Statistics.vue
index 094e0e2..b35822d 100644
--- a/src/pages/production/components/Statistics.vue
+++ b/src/pages/production/components/Statistics.vue
@@ -1,6 +1,6 @@
 <template>
   <view class="statistics_box">
-    <wd-row>
+    <!-- <wd-row>
       <wd-col :span="12">
         <view class="h_48 px-4 flex items-center">
           <view class="icon_box">
@@ -19,7 +19,7 @@
           <text class="text-lg text-[#339599] ml-2 font-semibold">87%</text>
         </view>
       </wd-col>
-    </wd-row>
+    </wd-row> -->
   </view>
 </template>
 <style scoped lang="scss">
diff --git a/src/pages/production/detail/twistDetail.vue b/src/pages/production/detail/twistDetail.vue
index 6ccb078..fede20a 100644
--- a/src/pages/production/detail/twistDetail.vue
+++ b/src/pages/production/detail/twistDetail.vue
@@ -5,6 +5,7 @@
       :map="{
         deviceModel: 'deviceModel',
         model: 'model',
+        systemNo: 'systemNo',
         totalAmount: 'totalAmount',
         amount: 'amount',
         unAmount: 'unAmount',
@@ -50,6 +51,7 @@
 const cardData = reactive({
   deviceModel: undefined,
   model: undefined,
+  systemNo: undefined,
   totalAmount: undefined,
   amount: undefined,
   unAmount: undefined,
@@ -61,6 +63,7 @@
   });
   cardData.deviceModel = data.deviceModel;
   cardData.model = data.model;
+  cardData.systemNo = data.systemNo;
   cardData.totalAmount = data.totalLength;
   cardData.amount = data.length;
   cardData.unAmount = data.unLength;
diff --git a/src/pages/production/detail/wireDetail.vue b/src/pages/production/detail/wireDetail.vue
index 305e6e0..29f6caf 100644
--- a/src/pages/production/detail/wireDetail.vue
+++ b/src/pages/production/detail/wireDetail.vue
@@ -5,6 +5,7 @@
       :map="{
         deviceModel: 'deviceModel',
         model: 'model',
+        systemNo: 'systemNo',
         totalAmount: 'totalAmount',
         amount: 'amount',
         unAmount: 'unAmount',
@@ -50,6 +51,7 @@
 const cardData = reactive({
   deviceModel: undefined,
   model: undefined,
+  systemNo: undefined,
   totalAmount: undefined,
   amount: undefined,
   unAmount: undefined,
@@ -62,6 +64,7 @@
   });
   cardData.deviceModel = data.deviceModel;
   cardData.model = data.model;
+  cardData.systemNo = data.systemNo;
   cardData.totalAmount = data.totalAmount;
   cardData.amount = data.amount;
   cardData.unAmount = data.unAmount;
diff --git a/src/pages/production/index.vue b/src/pages/production/index.vue
index 017062f..1fbe803 100644
--- a/src/pages/production/index.vue
+++ b/src/pages/production/index.vue
@@ -2,7 +2,14 @@
   <view>
     <wd-row>
       <wd-col :span="21">
-        <wd-search placeholder-left hide-cancel></wd-search>
+        <wd-search
+          v-model="searchKeyword"
+          placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
+          placeholder-left
+          hide-cancel
+          @search="handleSearch"
+          @clear="handleClear"
+        ></wd-search>
       </wd-col>
       <wd-col :span="3">
         <view class="scan_box" @click="openScan">
@@ -14,16 +21,30 @@
       <wd-tab :title="`寰呯敓浜�(${total.wait})`" class="tab_bg">
         <ProductList
           ref="waitRef"
+          :key="`wait-${searchKey}`"
           :api="ManageApi.getProductList"
           state="寰呭畬鎴�"
+          :model="searchKeyword"
           @ok="changeWait"
+        />
+      </wd-tab>
+      <wd-tab :title="`閮ㄥ垎瀹屾垚(${total.partial})`" class="tab_bg">
+        <ProductList
+          ref="partialRef"
+          :key="`partial-${searchKey}`"
+          :api="ManageApi.getProductList"
+          state="閮ㄥ垎瀹屾垚"
+          :model="searchKeyword"
+          @ok="changePartial"
         />
       </wd-tab>
       <wd-tab :title="`宸茬敓浜�(${total.already})`" class="tab_bg">
         <ProductList
           ref="alreadyRef"
+          :key="`already-${searchKey}`"
           :api="ManageApi.getProductList"
           state="宸插畬鎴�"
+          :model="searchKeyword"
           @ok="changeAlready"
         />
       </wd-tab>
@@ -48,10 +69,14 @@
 const toast = useToast();
 
 const waitRef = ref();
+const partialRef = ref();
 const alreadyRef = ref();
 const tab = ref<number>(0);
+const searchKeyword = ref("");
+const searchKey = ref(0);
 const total = reactive({
   wait: 0,
+  partial: 0,
   already: 0,
 });
 
@@ -59,10 +84,23 @@
   total.wait = num;
 };
 
+const changePartial = (num: number) => {
+  total.partial = num;
+};
+
 const changeAlready = (num: number) => {
   total.already = num;
 };
 
+const handleSearch = () => {
+  searchKey.value++;
+};
+
+const handleClear = () => {
+  searchKeyword.value = "";
+  handleSearch();
+};
+
 const openScan = () => {
   scanRef.value.triggerScan();
 };
diff --git a/src/pages/production/list/index.vue b/src/pages/production/list/index.vue
index 92862f8..79b8d0e 100644
--- a/src/pages/production/list/index.vue
+++ b/src/pages/production/list/index.vue
@@ -36,6 +36,7 @@
 const map = reactive({
   deviceModel: "deviceModel",
   model: "model",
+  systemNo: "systemNo",
   totalAmount: "totalAmount",
   amount: "amount",
   unAmount: "unAmount",
@@ -50,13 +51,17 @@
     type: String,
     default: "",
   },
+  model: {
+    type: String,
+    default: "",
+  },
 });
 
 const emits = defineEmits(["ok"]);
 const list = ref<any[]>([]);
 
 const toDetail = (id: number, type: string) => {
-  toast.show("鐐瑰嚮鍗$墖");
+  // toast.show("鐐瑰嚮鍗$墖");
   if (type == "鎷変笣") {
     uni.navigateTo({
       url: `/pages/production/detail/wireDetail?id=${id}`,
@@ -69,22 +74,28 @@
 };
 
 const getList = async (pageNo: number, pageSize: number) => {
-  const { code, data } = await props.api({
+  const params: any = {
     userName: userInfo.value.userName,
     state: props.state,
     current: pageNo,
     size: pageSize,
-  });
+  };
+  if (props.model) {
+    params.model = props.model;
+  }
+  const { code, data } = await props.api(params);
   if (code == 200) {
     if (data.type == "缁炵嚎") {
       map.deviceModel = "deviceModel";
       map.model = "model";
+      map.systemNo = "systemNo";
       map.totalAmount = "totalLength";
       map.amount = "length";
       map.unAmount = "unLength";
     } else if (data.type == "鎷変笣") {
       map.deviceModel = "deviceModel";
       map.model = "model";
+      map.systemNo = "systemNo";
       map.totalAmount = "totalAmount";
       map.amount = "amount";
       map.unAmount = "unAmount";
diff --git a/src/pages/production/twist/components/TwistReportCard.vue b/src/pages/production/twist/components/TwistReportCard.vue
new file mode 100644
index 0000000..ee3f754
--- /dev/null
+++ b/src/pages/production/twist/components/TwistReportCard.vue
@@ -0,0 +1,37 @@
+<template>
+  <wd-row>
+    <wd-col v-for="(item, index) in data" :key="index" :span="item.span || 24" class="my-1">
+      <view class="flex w-full h-[20px]">
+        <view class="text-[#646874] pl-1 mr-3">{{ item.label }}</view>
+        <view class="font-medium pr-1" :style="{ color: item.color ?? color }">
+          {{ value[item.prop] }} {{ value[item.unitProp] }} {{ item.unit }}
+        </view>
+      </view>
+    </wd-col>
+  </wd-row>
+</template>
+
+<script lang="ts" setup>
+defineProps({
+  data: {
+    type: Array as any,
+    default: () => {
+      return [];
+    },
+  },
+  value: {
+    type: Object,
+    default: () => {
+      return {};
+    },
+  },
+  color: {
+    type: String,
+    default: "#333333",
+  },
+  unit: {
+    type: String,
+    default: "",
+  },
+});
+</script>
diff --git a/src/pages/production/twist/report/form.vue b/src/pages/production/twist/report/form.vue
index 2e62f0c..cb804bb 100644
--- a/src/pages/production/twist/report/form.vue
+++ b/src/pages/production/twist/report/form.vue
@@ -2,103 +2,139 @@
   <wd-form ref="form" :model="model" class="relative form_box">
     <wd-cell-group :border="true">
       <wd-input
-        v-model="model.contractNo"
-        label="棰嗙敤鏉嗗彿"
-        label-width="100px"
-        prop="contractNo"
-        clearable
-        placeholder="璇疯緭鍏ラ鐢ㄦ潌鍙�"
-      />
-      <wd-input
-        v-model="model.status"
-        label="鏉嗛噸(kg)"
-        label-width="100px"
-        prop="status"
-        clearable
-        placeholder="璇疯緭鍏ユ潌閲�"
-      />
-      <wd-input
-        v-model="model.clientName"
-        label="鍗曚笣鐩樺彿"
-        label-width="100px"
-        prop="clientName"
-        clearable
-        placeholder="璇疯緭鍏ュ崟涓濈洏鍙�"
-      />
-      <wd-input
-        v-model="model.workbench"
-        label="瀹為檯閲嶉噺(kg)"
-        label-width="100px"
-        prop="workbench"
-        clearable
-        placeholder="璇疯緭鍏ュ疄闄呴噸閲�"
-      />
-      <wd-input
-        v-model="model.quality"
-        label="鐩橀暱(m)"
-        label-width="100px"
-        prop="quality"
-        clearable
-        placeholder="璇疯緭鍏ョ洏闀�"
-      />
-      <wd-input
-        v-model="model.specification"
-        label="鐞嗚閲嶉噺(kg)"
-        label-width="100px"
-        prop="specification"
-        clearable
-        placeholder="璇疯緭鍏ョ悊璁洪噸閲�"
-      />
-      <wd-input
-        v-model="model.disc"
-        label="瑙勬牸鍨嬪彿"
-        label-width="100px"
-        prop="disc"
-        clearable
-        placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
-      />
-      <wd-input
         v-model="model.actuallyLength"
-        label="瀹為檯鐩橀暱(m)"
+        label="鐢熶骇闀垮害(m)"
         label-width="100px"
         prop="actuallyLength"
         clearable
-        placeholder="璇疯緭鍏ュ疄闄呯洏闀�"
-      />
+        placeholder="璇疯緭鍏ョ敓浜ч暱搴�"
+        type="digit"
+      >
+        <template #label>
+          <span style="color: #f56c6c">鐢熶骇闀垮害(m)</span>
+        </template>
+      </wd-input>
+      <wd-input
+        v-model="model.tare"
+        label="鐩樺叿鐨噸(kg)"
+        label-width="100px"
+        prop="tare"
+        :disabled="!isFirstReport"
+        :clearable="isFirstReport"
+        :placeholder="isFirstReport ? '璇疯緭鍏ョ洏鍏风毊閲�' : '鐩樺叿鐨噸鑷姩甯﹀嚭'"
+        type="digit"
+      >
+        <template #label>
+          <span style="color: #f56c6c">鐩樺叿鐨噸(kg)</span>
+        </template>
+      </wd-input>
     </wd-cell-group>
   </wd-form>
 </template>
 
 <script lang="ts" setup>
+import { computed, watch } from "vue";
 import useFormData from "@/hooks/useFormData";
-import { useToast } from "wot-design-uni";
+import { useToast, dayjs } from "wot-design-uni";
 import TwistApi from "@/api/product/twist";
+
+// 瀹氫箟 props
+const props = defineProps<{
+  firstTareValue?: number;
+  teamId?: string | number | null;
+  isFirstReport?: boolean; // 鏄惁鏄涓�鏉℃姤宸�
+}>();
+
+// 璁$畻鏄惁鏄涓�鏉℃姤宸�
+const isFirstReport = computed(() => props.isFirstReport ?? true);
 
 const paramsId = ref();
 const toast = useToast();
-const { form: model } = useFormData({
-  poleNumber: undefined, // 棰嗙敤鏉嗗彿
-  poleWeight: undefined, // 鏉嗛噸(kg)
-  monofilamentNumber: undefined, // 鍗曚笣鐩樺彿
-  actuallyWeight: undefined, // 瀹為檯閲嶉噺(kg)
-  oneLength: undefined, // 鐩橀暱(m)
-  theoryWeight: undefined, // 鐞嗚閲嶉噺(kg)
-  model: undefined, // 瑙勬牸鍨嬪彿
-  actuallyLength: undefined, // 瀹為檯鐩橀暱(m)
+const { form: model, resetForm } = useFormData({
+  actuallyLength: undefined, // 鐢熶骇闀垮害(m)
+  tare: undefined, // 鐩樺叿鐨噸(kg)
 });
 
+// 涓昏〃鏁版嵁锛堜粠鐖剁粍浠朵紶鍏ワ級
+const mainTableData = ref<any>({});
+
+// 璁剧疆涓昏〃鏁版嵁
+const setMainTableData = (data: any) => {
+  mainTableData.value = data;
+};
+
+// 鐩戝惉 firstTareValue 鍙樺寲锛屽鏋滀笉鏄涓�鏉★紝鑷姩濉厖
+watch(
+  () => props.firstTareValue,
+  (newVal) => {
+    if (!isFirstReport.value && newVal !== undefined) {
+      model.tare = newVal;
+    }
+  },
+  { immediate: true }
+);
+
 const submit = async () => {
-  const { code } = await TwistApi.addTwistOutput({
+  // 鑾峰彇绗竴鏉℃暟鎹殑鐨噸鍊硷紝鐢ㄤ簬鍚庣画鏂板鐨勬姤宸�
+  const firstTareValue = props.firstTareValue;
+
+  // 濡傛灉涓昏〃鏁版嵁鏈幏鍙栵紝灏濊瘯閲嶆柊鑾峰彇
+  if (!mainTableData.value.model) {
+    try {
+      const { data } = await TwistApi.getTwistDetailById({
+        id: paramsId.value,
+      });
+      mainTableData.value = {
+        model: data.model,
+        totalLength: data.totalLength,
+        systemNo: data.systemNo,
+      };
+    } catch (error) {
+      console.error("鑾峰彇涓昏〃鏁版嵁澶辫触:", error);
+      toast.error("鑾峰彇瑙勬牸鍨嬪彿鏁版嵁澶辫触锛岃閲嶈瘯");
+      return false;
+    }
+  }
+
+  // 鍐嶆妫�鏌ヤ富琛ㄦ暟鎹�
+  if (!mainTableData.value.model) {
+    toast.error("瑙勬牸鍨嬪彿鏁版嵁鏈幏鍙栵紝璇烽噸璇�");
+    return false;
+  }
+
+  const submitData = {
+    teamId: props.teamId || null,
     wireId: paramsId.value,
-    ...model,
-  });
+    type: "缁炵嚎",
+    actuallyLength: model.actuallyLength,
+    tare: model.tare || firstTareValue,
+    // 浠庝富琛ㄨ幏鍙栫殑瀛楁
+    model: mainTableData.value.model, // 瑙勬牸鍨嬪彿
+    oneLength: mainTableData.value.totalLength,
+    systemNo: mainTableData.value.systemNo,
+    monofilamentNumber: undefined, // 鎵规鍙凤紙鍚庣鑷姩鐢熸垚锛�
+    // 鐢熶骇鏃ユ湡鑷姩璁剧疆涓哄綋鍓嶆椂闂�
+    productTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
+  };
+
+  // 璋冭瘯鏃ュ織
+  console.log("鎻愪氦鏁版嵁:", submitData);
+  console.log("涓昏〃鏁版嵁:", mainTableData.value);
+
+  const { code } = await TwistApi.addTwistOutput(submitData);
   if (code == 200) {
     toast.success("鎻愪氦鎴愬姛");
+    resetForm();
     return true;
   } else {
     toast.error("鎻愪氦澶辫触");
     return false;
   }
+};
+
+// 鑾峰彇琛ㄥ崟鏁版嵁
+const getFormData = () => {
+  return { ...model };
 };
 
 onLoad((options: any) => {
@@ -107,12 +143,12 @@
 
 defineExpose({
   submit,
+  getFormData,
+  setMainTableData,
 });
 </script>
 
 <style lang="scss" scoped>
-.form_box {
-}
 .submit_btn {
   position: absolute;
   bottom: 0;
diff --git a/src/pages/production/twist/report/index.vue b/src/pages/production/twist/report/index.vue
index f100b78..b9244b1 100644
--- a/src/pages/production/twist/report/index.vue
+++ b/src/pages/production/twist/report/index.vue
@@ -12,15 +12,23 @@
               <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="handleSelfCheck(item.id)">鑷</wd-button>
+          <wd-button
+            size="small"
+            plain
+            style="margin-right: 10px"
+            @click="handleSelfCheck(item.id)"
+          >
+            鑷
+          </wd-button>
+          <wd-button size="small" plain type="error" @click="handleDelete(item)">鍒犻櫎</wd-button>
         </template>
       </wd-card>
     </z-paging>
@@ -30,7 +38,12 @@
         <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
@@ -47,13 +60,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, reactive } 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 } from "@/utils/cache";
 
 const drawFormRef = reactive({
   visible: false,
@@ -95,36 +110,65 @@
 
 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
+const initTeamId = async () => {
+  // 鍏堝皾璇曚粠缂撳瓨鑾峰彇
+  const cachedTeamId = getTeamId();
+  if (cachedTeamId) {
+    teamId.value = cachedTeamId;
+    return;
+  }
+
+  // 濡傛灉缂撳瓨涓病鏈夛紝鍒欒皟鐢ㄦ帴鍙h幏鍙�
+  try {
+    const { data } = await HomeApi.getIndex();
+    if (data && data.team) {
+      teamId.value = data.team;
+      setTeamId(data.team);
+    }
+  } catch (error) {
+    console.error("鑾峰彇鐝粍ID澶辫触:", error);
+  }
+};
 
 const toEdit = () => {
   uni.navigateTo({
@@ -132,23 +176,83 @@
   });
 };
 
+// 涓昏〃鏁版嵁
+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 () => {
-  dialog.visible = true;
-  // 鎵撳紑鏂板寮圭獥鏃惰嚜鍔ㄦ墽琛�
-  // await showDrawPopup();
+  // 妫�鏌ユ槸鍚︽墍鏈夋暟鎹兘宸蹭繚瀛橈紙閮芥湁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;
 };
 
@@ -197,6 +301,35 @@
   });
 };
 
+// 鍒犻櫎鎶ュ伐璁板綍
+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();
@@ -208,11 +341,23 @@
     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>
diff --git a/src/pages/production/wire/attachment/index.vue b/src/pages/production/wire/attachment/index.vue
index 3c81d5c..d6394e8 100644
--- a/src/pages/production/wire/attachment/index.vue
+++ b/src/pages/production/wire/attachment/index.vue
@@ -526,3 +526,4 @@
 
 
 
+
diff --git a/src/utils/cache.ts b/src/utils/cache.ts
index 93b1a42..ed9ab16 100644
--- a/src/utils/cache.ts
+++ b/src/utils/cache.ts
@@ -1,6 +1,7 @@
 const TOKEN_KEY = "app-token";
 const USER_INFO_KEY = "user-info";
 const DICT_KEY = "dict";
+const TEAM_ID_KEY = "team-id";
 import { type DictData } from "@/api/system/dict";
 
 // 璁剧疆 token
@@ -48,9 +49,25 @@
   uni.removeStorageSync(DICT_KEY);
 }
 
+// 璁剧疆鐝粍ID
+export function setTeamId(teamId: string | number) {
+  uni.setStorageSync(TEAM_ID_KEY, teamId);
+}
+
+// 鑾峰彇鐝粍ID
+export function getTeamId(): string | number | null {
+  return uni.getStorageSync(TEAM_ID_KEY) || null;
+}
+
+// 娓呴櫎鐝粍ID
+export function clearTeamId() {
+  uni.removeStorageSync(TEAM_ID_KEY);
+}
+
 // 娓呴櫎鎵�鏈夌紦瀛樹俊鎭�
 export function clearAll() {
   clearToken();
   clearUserInfo();
   clearDictCache();
+  clearTeamId();
 }

--
Gitblit v1.9.3