From 20dbdee5a002544f6a4e12b5e39e338052418782 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 26 十二月 2025 10:36:27 +0800
Subject: [PATCH] fix: 完成成品单丝报工逻辑

---
 src/pages/production/wire/report/reportManage.vue |  144 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 126 insertions(+), 18 deletions(-)

diff --git a/src/pages/production/wire/report/reportManage.vue b/src/pages/production/wire/report/reportManage.vue
index 9a39001..7df3b0f 100644
--- a/src/pages/production/wire/report/reportManage.vue
+++ b/src/pages/production/wire/report/reportManage.vue
@@ -1,7 +1,7 @@
 <template>
   <view class="report-manage-page">
-    <view class="pt-2">
-      <wd-card class="card_bg">
+    <view class="pt-2 fixed-header-card">
+      <wd-card class="card_bg header-card">
         <template #title>
           <view class="flex justify-between w-full">
             <text class="font-medium text-[#252525]">鎶ュ伐绠$悊</text>
@@ -195,7 +195,9 @@
         </wd-row>
         <template #footer>
           <view class="flex gap-2">
-            <wd-button plain size="small" @click="toAttachment(child)">闄勪欢</wd-button>
+            <wd-button plain size="small" @click="toAttachment(child)" style="margin-right: 10px">
+              闄勪欢
+            </wd-button>
             <wd-button plain type="error" size="small" @click="handleDeleteSingle(child)">
               鍒犻櫎
             </wd-button>
@@ -242,7 +244,7 @@
           </wd-cell-group>
         </view>
         <view class="dialog-footer">
-          <wd-button plain @click="closeAddDialog">鍙栨秷</wd-button>
+          <wd-button plain @click="closeAddDialog" style="margin-right: 10px">鍙栨秷</wd-button>
           <wd-button type="primary" class="ml-2" @click="handleSaveNewChild">淇濆瓨</wd-button>
         </view>
       </view>
@@ -270,6 +272,9 @@
 const oneLength = ref();
 const allChildDataList = ref<any[]>([]);
 const wireDetail = ref<any>(null);
+const isMonofil = ref();
+const meterWeight = ref();
+const totalWeight = ref();
 
 // 鏂板寮规鐩稿叧
 const addDialogVisible = ref(false);
@@ -342,20 +347,33 @@
 const handleAdd = () => {
   const lastChild = childList.value[childList.value.length - 1];
 
-  // 浠庤鎯呮暟鎹腑鑾峰彇绫抽噸
-  const meterWeight =
+  // 浠庤鎯呮暟鎹腑鑾峰彇绫抽噸锛屼紭鍏堜娇鐢ㄤ紶鍏ョ殑鍙傛暟
+  const meterWeightValue =
+    Number(meterWeight.value) ||
     Number(wireDetail.value?.meterWeight) ||
     Number(wireDetail.value?.weight) ||
     Number(wireDetail.value?.theoryWeight) ||
     0;
 
+  // 濡傛灉鏄垚鍝佸崟涓濓紝鏍规嵁鍏紡鑷姩璁$畻鐩橀暱锛�(totalWeight/meterWeight)*1000
+  let calculatedLength = "";
+  if (
+    isMonofil.value &&
+    (isMonofil.value === 1 || isMonofil.value === "1" || isMonofil.value === true)
+  ) {
+    const totalWeightValue = Number(totalWeight.value) || 0;
+    if (totalWeightValue > 0 && meterWeightValue > 0) {
+      calculatedLength = ((totalWeightValue / meterWeightValue) * 1000).toFixed(2);
+    }
+  }
+
   // 鍒濆鍖栨柊鏁版嵁锛屽鏋滄湁鏈�鍚庝竴鏉℃暟鎹紝浣跨敤鍏跺�间綔涓洪粯璁ゅ��
   newChildData.value = {
     dishModel: lastChild?.dishModel || "",
-    actuallyLength: lastChild?.actuallyLength || "",
+    actuallyLength: calculatedLength || lastChild?.actuallyLength || "",
     actuallyWeight: lastChild?.actuallyWeight || "",
     isJoint: lastChild?.isJoint || 0,
-    meterWeight: meterWeight,
+    meterWeight: meterWeightValue,
   };
 
   addDialogVisible.value = true;
@@ -528,28 +546,68 @@
   }
 };
 
-// 鑷姩璁$畻瀹為檯閲嶉噺
+// 鑷姩璁$畻瀹為檯閲嶉噺锛堟牴鎹暱搴︼級
 const handleCalculateWeight = (row: any) => {
   // 浠� newChildData 瀵硅薄涓幏鍙栫背閲�
-  const meterWeight = Number(row.meterWeight) || 0;
+  const meterWeightValue = Number(row.meterWeight) || 0;
   const actuallyLength = Number(row.actuallyLength);
 
-  if (meterWeight > 0 && actuallyLength > 0) {
-    const calculatedWeight = (meterWeight * actuallyLength) / 1000;
+  if (meterWeightValue > 0 && actuallyLength > 0) {
+    const calculatedWeight = (meterWeightValue * actuallyLength) / 1000;
     row.actuallyWeight = Number(calculatedWeight.toFixed(3));
   }
-  console.log("row", meterWeight, actuallyLength);
+  console.log("row", meterWeightValue, actuallyLength);
 };
 
-// 鐩戝惉瀹為檯闀垮害鍙樺寲锛岃嚜鍔ㄨ绠楅噸閲�
+// 鑷姩璁$畻瀹為檯闀垮害锛堟牴鎹噸閲忥紝浠呮垚鍝佸崟涓濓級
+const handleCalculateLength = (row: any) => {
+  // 濡傛灉鏄垚鍝佸崟涓濓紝鏍规嵁閲嶉噺璁$畻闀垮害
+  if (
+    isMonofil.value &&
+    (isMonofil.value === 1 || isMonofil.value === "1" || isMonofil.value === true)
+  ) {
+    const meterWeightValue = Number(meterWeight.value) || Number(row.meterWeight) || 0;
+    const actuallyWeight = Number(row.actuallyWeight);
+
+    if (meterWeightValue > 0 && actuallyWeight > 0) {
+      const calculatedLength = (actuallyWeight / meterWeightValue) * 1000;
+      row.actuallyLength = Number(calculatedLength.toFixed(2));
+    }
+  }
+};
+
+// 鐩戝惉瀹為檯闀垮害鍙樺寲锛岃嚜鍔ㄨ绠楅噸閲忥紙闈炴垚鍝佸崟涓濇椂锛�
 watch(
   () => newChildData.value.actuallyLength,
   (newValue, oldValue) => {
-    console.log("瀹為檯闀垮害鍙樺寲:", { newValue, oldValue, newChildData: newChildData.value });
-    if (newValue && String(newValue).trim() !== "") {
+    console.log("瀹為檯闀垮害鍙樺寲:", { newValue, oldValue, isMonofil: isMonofil.value });
+    // 濡傛灉涓嶆槸鎴愬搧鍗曚笣锛屾墠鏍规嵁闀垮害璁$畻閲嶉噺
+    if (
+      newValue &&
+      String(newValue).trim() !== "" &&
+      !(
+        isMonofil.value &&
+        (isMonofil.value === 1 || isMonofil.value === "1" || isMonofil.value === true)
+      )
+    ) {
       // 浣跨敤 nextTick 纭繚 v-model 宸茬粡鏇存柊
       nextTick(() => {
         handleCalculateWeight(newChildData.value);
+      });
+    }
+  },
+  { immediate: false, deep: true }
+);
+
+// 鐩戝惉瀹為檯閲嶉噺鍙樺寲锛岃嚜鍔ㄨ绠楅暱搴︼紙浠呮垚鍝佸崟涓濓級
+watch(
+  () => newChildData.value.actuallyWeight,
+  (newValue, oldValue) => {
+    console.log("瀹為檯閲嶉噺鍙樺寲:", { newValue, oldValue, isMonofil: isMonofil.value });
+    if (newValue && String(newValue).trim() !== "") {
+      // 浣跨敤 nextTick 纭繚 v-model 宸茬粡鏇存柊
+      nextTick(() => {
+        handleCalculateLength(newChildData.value);
       });
     }
   },
@@ -569,6 +627,11 @@
     supplier: options.supplier,
   };
 
+  // 鎺ユ敹浼犻�掔殑鍙傛暟
+  isMonofil.value = options.isMonofil;
+  meterWeight.value = options.meterWeight;
+  totalWeight.value = options.totalWeight;
+
   await getDetailData(options.wireId);
   await getData();
 });
@@ -578,12 +641,27 @@
 .report-manage-page {
   min-height: 100vh;
   background: #f3f9f8;
-  padding-bottom: 20px;
+  padding: 0 4px 20px 4px;
 }
 
 .card_bg {
   box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.05);
   padding-bottom: 10px;
+}
+
+.fixed-header-card {
+  position: sticky;
+  top: 0;
+  z-index: 100;
+  background: #f3f9f8;
+  padding: 8px 0;
+}
+
+.header-card {
+  border: none;
+  margin: 0;
+  border-radius: 0;
+  box-shadow: none;
 }
 
 .icon_box {
@@ -649,7 +727,37 @@
 }
 
 .page-content {
-  padding: 12px;
+  padding: 12px 4px;
   margin-top: 12px;
 }
+
+// 寮规 z-index 闇�瑕侀珮浜庡浐瀹氬ご閮ㄥ崱鐗�
+:deep(.yl-popup) {
+  z-index: 400 !important;
+}
+
+// 寮规閬僵灞� z-index 涔熼渶瑕侀珮浜庡浐瀹氬ご閮ㄥ崱鐗囷紙浣跨敤鏇撮珮鐨勫�肩‘淇濆湪鍥哄畾澶撮儴涔嬩笂锛�
+:deep(.wd-popup__mask),
+:deep(.wd-popup-mask),
+:deep([class*="popup"][class*="mask"]),
+:deep(.wd-overlay),
+:deep([class*="overlay"]) {
+  z-index: 300 !important;
+}
+.wd-card {
+  margin-left: 5px;
+  margin-right: 5px;
+  margin-top: 0px;
+}
+</style>
+
+<style lang="scss">
+// 鍏ㄥ眬鏍峰紡锛氱‘淇濆脊妗嗛伄缃╁眰 z-index 楂樹簬鍥哄畾澶撮儴鍗$墖
+.wd-popup__mask,
+.wd-popup-mask,
+[class*="popup"][class*="mask"],
+.wd-overlay,
+[class*="overlay"] {
+  z-index: 300 !important;
+}
 </style>

--
Gitblit v1.9.3