From 8cc901ed214f3885b34a07d0520fbcfd50063439 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 19 十一月 2025 14:30:39 +0800
Subject: [PATCH] fix: 完成绞线自检,生产确认等功能新增

---
 src/pages/production/twist/report/draw.vue |  151 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 94 insertions(+), 57 deletions(-)

diff --git a/src/pages/production/twist/report/draw.vue b/src/pages/production/twist/report/draw.vue
index b8e2a1e..b148266 100644
--- a/src/pages/production/twist/report/draw.vue
+++ b/src/pages/production/twist/report/draw.vue
@@ -62,45 +62,6 @@
             </template>
           </view>
         </wd-tab>
-        <wd-tab title="鑺嚎棰嗙敤鑷" name="steel">
-          <view class="form-section">
-            <wd-form :model="localSteelData">
-              <wd-form-item label="瑙勬牸鍨嬪彿" prop="model" required>
-                <wd-input
-                  v-model="localSteelData.model"
-                  :disabled="false"
-                  placeholder="璇疯緭鍏�"
-                ></wd-input>
-              </wd-form-item>
-              <wd-form-item label="缁炲悜" prop="twistedDirection" required>
-                <wd-input
-                  v-model="localSteelData.twistedDirection"
-                  :disabled="false"
-                  placeholder="璇疯緭鍏�"
-                ></wd-input>
-              </wd-form-item>
-              <wd-form-item label="澶栧緞" prop="outerDiameter" required>
-                <wd-input
-                  v-model="localSteelData.outerDiameter"
-                  :disabled="false"
-                  placeholder="璇疯緭鍏�"
-                ></wd-input>
-              </wd-form-item>
-              <wd-form-item label="鍒掍激" prop="scratch" required>
-                <wd-radio-group v-model="localSteelData.scratch" cell shape="dot">
-                  <wd-radio value="鏄�">鏄�</wd-radio>
-                  <wd-radio value="鍚�">鍚�</wd-radio>
-                </wd-radio-group>
-              </wd-form-item>
-              <wd-form-item label="娌规薄" prop="oilStain" required>
-                <wd-radio-group v-model="localSteelData.oilStain" cell shape="dot">
-                  <wd-radio value="鏄�">鏄�</wd-radio>
-                  <wd-radio value="鍚�">鍚�</wd-radio>
-                </wd-radio-group>
-              </wd-form-item>
-            </wd-form>
-          </view>
-        </wd-tab>
         <wd-tab title="鐩樺叿棰嗙敤鑷" name="reel">
           <view class="form-section">
             <wd-form :model="localReelData">
@@ -163,7 +124,9 @@
                     :key="option.value"
                     :modelValue="
                       Array.isArray(localReelData.weldQuality)
-                        ? localReelData.weldQuality.includes(String(option.value))
+                        ? localReelData.weldQuality
+                            .map((v) => String(v))
+                            .includes(String(option.value))
                         : false
                     "
                     shape="square"
@@ -172,6 +135,45 @@
                     {{ option.label }}
                   </wd-checkbox>
                 </view>
+              </wd-form-item>
+            </wd-form>
+          </view>
+        </wd-tab>
+        <wd-tab title="鑺嚎棰嗙敤鑷" name="steel">
+          <view class="form-section">
+            <wd-form :model="localSteelData">
+              <wd-form-item label="瑙勬牸鍨嬪彿" prop="model" required>
+                <wd-input
+                  v-model="localSteelData.model"
+                  :disabled="false"
+                  placeholder="璇疯緭鍏�"
+                ></wd-input>
+              </wd-form-item>
+              <wd-form-item label="缁炲悜" prop="twistedDirection" required>
+                <wd-input
+                  v-model="localSteelData.twistedDirection"
+                  :disabled="false"
+                  placeholder="璇疯緭鍏�"
+                ></wd-input>
+              </wd-form-item>
+              <wd-form-item label="澶栧緞" prop="outerDiameter" required>
+                <wd-input
+                  v-model="localSteelData.outerDiameter"
+                  :disabled="false"
+                  placeholder="璇疯緭鍏�"
+                ></wd-input>
+              </wd-form-item>
+              <wd-form-item label="鍒掍激" prop="scratch" required>
+                <wd-radio-group v-model="localSteelData.scratch" cell shape="dot">
+                  <wd-radio value="鏄�">鏄�</wd-radio>
+                  <wd-radio value="鍚�">鍚�</wd-radio>
+                </wd-radio-group>
+              </wd-form-item>
+              <wd-form-item label="娌规薄" prop="oilStain" required>
+                <wd-radio-group v-model="localSteelData.oilStain" cell shape="dot">
+                  <wd-radio value="鏄�">鏄�</wd-radio>
+                  <wd-radio value="鍚�">鍚�</wd-radio>
+                </wd-radio-group>
               </wd-form-item>
             </wd-form>
           </view>
@@ -360,21 +362,29 @@
 };
 
 // 澶勭悊鐒婃帴璐ㄩ噺澶嶉�夋鐨刢hange浜嬩欢
-const handleWeldQualityCheckbox = (optionValue: string, checked: boolean) => {
-  const currentValues = Array.isArray(localReelData.value.weldQuality)
-    ? localReelData.value.weldQuality
-    : [];
-
-  let newValues: string[];
-  if (checked) {
-    // 閫変腑
-    newValues = [...currentValues, optionValue];
-  } else {
-    // 鍙栨秷閫変腑
-    newValues = currentValues.filter((v) => v !== optionValue);
+const handleWeldQualityCheckbox = (optionValue: string, checked: any) => {
+  // 纭繚 weldQuality 鏄暟缁�
+  if (!Array.isArray(localReelData.value.weldQuality)) {
+    localReelData.value.weldQuality = [];
   }
 
-  // 鏇存柊鍊�
+  const currentValues = [...localReelData.value.weldQuality.map((v) => String(v))];
+  const optionValueStr = String(optionValue);
+
+  // 鍒ゆ柇褰撳墠鏄惁宸查�変腑
+  const isCurrentlyChecked = currentValues.includes(optionValueStr);
+
+  // 鏍规嵁褰撳墠鐘舵�佸垏鎹細濡傛灉褰撳墠宸查�変腑锛屽垯鍙栨秷閫変腑锛涘鏋滃綋鍓嶆湭閫変腑锛屽垯閫変腑
+  let newValues: string[];
+  if (isCurrentlyChecked) {
+    // 褰撳墠宸查�変腑锛屽彇娑堥�変腑
+    newValues = currentValues.filter((v) => v !== optionValueStr);
+  } else {
+    // 褰撳墠鏈�変腑锛岄�変腑
+    newValues = [...currentValues, optionValueStr];
+  }
+
+  // 鐩存帴鏇存柊鍊�
   localReelData.value.weldQuality = newValues;
 };
 
@@ -457,7 +467,7 @@
             length: item.length || "",
             windingTightness: item.windingTightness || "鏄�",
             arrangement: item.arrangement || "鏄�",
-            edgeDistance: item.edgeDistance || "",
+            edgeDistance: item.edgeDistance || "25",
           };
         })
       : [
@@ -468,7 +478,7 @@
             length: "",
             windingTightness: "鏄�",
             arrangement: "鏄�",
-            edgeDistance: "",
+            edgeDistance: "25",
           },
         ];
 
@@ -510,7 +520,16 @@
     weldQualityValue = [props.reelToolingInfo.weldQuality as string];
   } else {
     // 榛樿閫夋嫨"宸茬(鍏�"鍜�"宸蹭慨骞�"
-    weldQualityValue = ["宸茬(鍏�", "宸蹭慨骞�"];
+    // 濡傛灉瀛楀吀鏁版嵁宸插姞杞斤紝浣跨敤瀛楀吀涓殑瀹為檯鍊硷紱鍚﹀垯浣跨敤瀛楃涓�
+    if (weldQualityOptions.value.length > 0) {
+      const defaultOptions = weldQualityOptions.value.filter(
+        (opt) => opt.label === "宸茬(鍏�" || opt.label === "宸蹭慨骞�"
+      );
+      weldQualityValue = defaultOptions.map((opt) => String(opt.value));
+    } else {
+      // 瀛楀吀鏈姞杞芥椂锛屼娇鐢ㄥ瓧绗︿覆浣滀负涓存椂鍊硷紝鍚庣画浼氬湪瀛楀吀鍔犺浇鍚庨噸鏂板垵濮嬪寲
+      weldQualityValue = ["宸茬(鍏�", "宸蹭慨骞�"];
+    }
   }
 
   localReelData.value = {
@@ -579,7 +598,8 @@
   { deep: true }
 );
 watch(() => props.steelRegulationInfo, initializeData, { deep: true });
-watch(() => props.reelToolingInfo, initializeData, { deep: true });
+// 娉ㄦ剰锛氫笉鐩戝惉 props.reelToolingInfo 鐨勫彉鍖栵紝閬垮厤瑕嗙洊鐢ㄦ埛鐨勬搷浣�
+// watch(() => props.reelToolingInfo, initializeData, { deep: true });
 
 const handleTabChange = (tabName: string) => {
   activeTab.value = tabName;
@@ -693,6 +713,23 @@
 // 鍦ㄧ粍浠舵寕杞芥椂寮傛鍔犺浇鏁版嵁瀛楀吀
 onMounted(async () => {
   await loadDictData();
+  // 瀛楀吀鏁版嵁鍔犺浇瀹屾垚鍚庯紝閲嶆柊鍒濆鍖栨暟鎹紝纭繚榛樿鍊艰兘姝g‘鍖归厤
+  // 浣嗗彧鍒濆鍖� weldQuality 濡傛灉瀹冭繕鏄┖鏁扮粍鎴栭粯璁ゅ��
+  if (
+    !Array.isArray(localReelData.value.weldQuality) ||
+    localReelData.value.weldQuality.length === 0 ||
+    (localReelData.value.weldQuality.length === 2 &&
+      localReelData.value.weldQuality.includes("宸茬(鍏�") &&
+      localReelData.value.weldQuality.includes("宸蹭慨骞�"))
+  ) {
+    // 鍙湁鍦ㄦ槸榛樿鍊兼垨绌烘暟缁勬椂鎵嶉噸鏂板垵濮嬪寲
+    const defaultOptions = weldQualityOptions.value.filter(
+      (opt) => opt.label === "宸茬(鍏�" || opt.label === "宸蹭慨骞�"
+    );
+    if (defaultOptions.length > 0) {
+      localReelData.value.weldQuality = defaultOptions.map((opt) => String(opt.value));
+    }
+  }
 });
 watch(
   () => [props.singleRegulationInfoArray, props.steelRegulationInfo, props.reelToolingInfo],

--
Gitblit v1.9.3