|  |  | 
 |  |  | <template> | 
 |  |  |   <view class="draw-container"> | 
 |  |  |     <view class="header"> | 
 |  |  |       <text class="title">领用信息</text> | 
 |  |  |       <text class="title">领用自检</text> | 
 |  |  |       <wd-icon name="close" class="close-icon" @click="handleClose"></wd-icon> | 
 |  |  |     </view> | 
 |  |  |     <view class="content"> | 
 |  |  |       <wd-tabs v-model="activeTab" @change="handleTabChange"> | 
 |  |  |         <wd-tab title="原材料领用" name="material"> | 
 |  |  |         <wd-tab title="原材料领用自检" name="material"> | 
 |  |  |           <view class="form-section"> | 
 |  |  |             <template v-for="(item, index) in localMaterialData" :key="index"> | 
 |  |  |               <view v-if="index > 0" class="mt-4 pt-4 border-t border-gray-100"></view> | 
 |  |  | 
 |  |  |                   <wd-input v-model="item.model" :disabled="false" placeholder="请输入"></wd-input> | 
 |  |  |                 </wd-form-item> | 
 |  |  |                 <wd-form-item label="外观质量" prop="appearanceQuality" required> | 
 |  |  |                   <wd-select-picker | 
 |  |  |                     v-model="item.appearanceQuality" | 
 |  |  |                     :columns="appearanceQualityOptions" | 
 |  |  |                     placeholder="请选择" | 
 |  |  |                     range-key="label" | 
 |  |  |                   ></wd-select-picker> | 
 |  |  |                   <view class="checkbox-group"> | 
 |  |  |                     <wd-checkbox | 
 |  |  |                       v-for="option in appearanceQualityOptions" | 
 |  |  |                       :key="option.value" | 
 |  |  |                       :modelValue=" | 
 |  |  |                         Array.isArray(item.appearanceQuality) | 
 |  |  |                           ? item.appearanceQuality.includes(String(option.value)) | 
 |  |  |                           : false | 
 |  |  |                       " | 
 |  |  |                       shape="square" | 
 |  |  |                       @change=" | 
 |  |  |                         (val) => handleAppearanceQualityCheckbox(index, String(option.value), val) | 
 |  |  |                       " | 
 |  |  |                     > | 
 |  |  |                       {{ option.label }} | 
 |  |  |                     </wd-checkbox> | 
 |  |  |                   </view> | 
 |  |  |                 </wd-form-item> | 
 |  |  |                 <wd-form-item label="直径" prop="diameter" required> | 
 |  |  |                 <wd-form-item label="直径(mm)" prop="diameter" required> | 
 |  |  |                   <wd-input v-model="item.dia" :disabled="false" placeholder="请输入"></wd-input> | 
 |  |  |                 </wd-form-item> | 
 |  |  |                 <wd-form-item label="长度" prop="length" required> | 
 |  |  |                 <wd-form-item label="长度(m)" prop="length" required> | 
 |  |  |                   <wd-input v-model="item.length" :disabled="false" placeholder="请输入"></wd-input> | 
 |  |  |                 </wd-form-item> | 
 |  |  |                 <wd-form-item label="卷绕紧密" prop="windingTightness" required> | 
 |  |  |                   <wd-picker | 
 |  |  |                     v-model="item.windingTightness" | 
 |  |  |                     range-key="label" | 
 |  |  |                     :columns="trueOrFalseOptions" | 
 |  |  |                     placeholder="请选择" | 
 |  |  |                   ></wd-picker> | 
 |  |  |                   <wd-radio-group v-model="item.windingTightness" cell shape="dot"> | 
 |  |  |                     <wd-radio value="是">是</wd-radio> | 
 |  |  |                     <wd-radio value="否">否</wd-radio> | 
 |  |  |                   </wd-radio-group> | 
 |  |  |                 </wd-form-item> | 
 |  |  |                 <wd-form-item label="排列整齐" prop="arrangement" required> | 
 |  |  |                   <wd-picker | 
 |  |  |                     v-model="item.arrangement" | 
 |  |  |                     range-key="label" | 
 |  |  |                     :columns="trueOrFalseOptions" | 
 |  |  |                     placeholder="请选择" | 
 |  |  |                   ></wd-picker> | 
 |  |  |                   <wd-radio-group v-model="item.arrangement" cell shape="dot"> | 
 |  |  |                     <wd-radio value="是">是</wd-radio> | 
 |  |  |                     <wd-radio value="否">否</wd-radio> | 
 |  |  |                   </wd-radio-group> | 
 |  |  |                 </wd-form-item> | 
 |  |  |                 <wd-form-item label="外层铝线离侧板边缘距离" prop="edgeDistance" required> | 
 |  |  |                 <wd-form-item label="外层铝线离侧板边缘距离(mm)" prop="edgeDistance" required> | 
 |  |  |                   <wd-input | 
 |  |  |                     v-model="item.edgeDistance" | 
 |  |  |                     :disabled="false" | 
 |  |  | 
 |  |  |             </template> | 
 |  |  |           </view> | 
 |  |  |         </wd-tab> | 
 |  |  |         <wd-tab title="钢芯领用" name="steel"> | 
 |  |  |         <wd-tab title="钢芯领用自检" name="steel"> | 
 |  |  |           <view class="form-section"> | 
 |  |  |             <template v-for="(item, index) in localSteelData" :key="index"> | 
 |  |  |               <view v-if="index > 0" class="mt-4 pt-4 border-t border-gray-100"></view> | 
 |  |  |               <wd-form :model="item"> | 
 |  |  |                 <wd-form-item label="规格型号" prop="model" required> | 
 |  |  |                   <wd-input v-model="item.model" :disabled="false" placeholder="请输入"></wd-input> | 
 |  |  |                 </wd-form-item> | 
 |  |  |                 <wd-form-item label="绞向" prop="twistedDirection" required> | 
 |  |  |                   <wd-input | 
 |  |  |                     v-model="item.twistedDirection" | 
 |  |  |                     :disabled="false" | 
 |  |  |                     placeholder="请输入" | 
 |  |  |                   ></wd-input> | 
 |  |  |                 </wd-form-item> | 
 |  |  |                 <wd-form-item label="外径" prop="outerDiameter" required> | 
 |  |  |                   <wd-input | 
 |  |  |                     v-model="item.outerDiameter" | 
 |  |  |                     :disabled="false" | 
 |  |  |                     placeholder="请输入" | 
 |  |  |                   ></wd-input> | 
 |  |  |                 </wd-form-item> | 
 |  |  |                 <wd-form-item label="划伤" prop="scratch" required> | 
 |  |  |                   <wd-picker | 
 |  |  |                     v-model="item.scratch" | 
 |  |  |                     range-key="label" | 
 |  |  |                     :columns="trueOrFalseOptions" | 
 |  |  |                     placeholder="请选择" | 
 |  |  |                   ></wd-picker> | 
 |  |  |                 </wd-form-item> | 
 |  |  |                 <wd-form-item label="油污" prop="oilStain" required> | 
 |  |  |                   <wd-picker | 
 |  |  |                     v-model="item.oilStain" | 
 |  |  |                     range-key="label" | 
 |  |  |                     :columns="trueOrFalseOptions" | 
 |  |  |                     placeholder="请选择" | 
 |  |  |                   ></wd-picker> | 
 |  |  |                 </wd-form-item> | 
 |  |  |               </wd-form> | 
 |  |  |             </template> | 
 |  |  |             <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"> | 
 |  |  |         <wd-tab title="盘具领用自检" name="reel"> | 
 |  |  |           <view class="form-section"> | 
 |  |  |             <wd-form :model="localReelData"> | 
 |  |  |               <wd-form-item label="螺母是否固定" prop="nutFixed" required> | 
 |  |  |                 <wd-picker | 
 |  |  |                   v-model="localReelData.nutFixed" | 
 |  |  |                   range-key="label" | 
 |  |  |                   :columns="trueOrFalseOptions" | 
 |  |  |                   placeholder="请选择" | 
 |  |  |                 ></wd-picker> | 
 |  |  |                 <wd-radio-group v-model="localReelData.nutFixed" cell shape="dot"> | 
 |  |  |                   <wd-radio value="是">是</wd-radio> | 
 |  |  |                   <wd-radio value="否">否</wd-radio> | 
 |  |  |                 </wd-radio-group> | 
 |  |  |               </wd-form-item> | 
 |  |  |               <wd-form-item label="侧板是否平直" prop="sidePlateFlat" required> | 
 |  |  |                 <wd-picker | 
 |  |  |                   v-model="localReelData.sidePlateFlat" | 
 |  |  |                   range-key="label" | 
 |  |  |                   :columns="trueOrFalseOptions" | 
 |  |  |                   placeholder="请选择" | 
 |  |  |                 ></wd-picker> | 
 |  |  |                 <wd-radio-group v-model="localReelData.sidePlateFlat" cell shape="dot"> | 
 |  |  |                   <wd-radio value="是">是</wd-radio> | 
 |  |  |                   <wd-radio value="否">否</wd-radio> | 
 |  |  |                 </wd-radio-group> | 
 |  |  |               </wd-form-item> | 
 |  |  |               <wd-form-item label="中心板是否平直" prop="centerPlateFlat" required> | 
 |  |  |                 <wd-picker | 
 |  |  |                   v-model="localReelData.centerPlateFlat" | 
 |  |  |                   range-key="label" | 
 |  |  |                   :columns="trueOrFalseOptions" | 
 |  |  |                   placeholder="请选择" | 
 |  |  |                 ></wd-picker> | 
 |  |  |                 <wd-radio-group v-model="localReelData.centerPlateFlat" cell shape="dot"> | 
 |  |  |                   <wd-radio value="是">是</wd-radio> | 
 |  |  |                   <wd-radio value="否">否</wd-radio> | 
 |  |  |                 </wd-radio-group> | 
 |  |  |               </wd-form-item> | 
 |  |  |               <wd-form-item label="涂漆质量" prop="paintQuality" required> | 
 |  |  |                 <wd-picker | 
 |  |  |                   v-model="localReelData.paintQuality" | 
 |  |  |                   range-key="label" | 
 |  |  |                   :columns="paintQualityOptions" | 
 |  |  |                   placeholder="请选择" | 
 |  |  |                 ></wd-picker> | 
 |  |  |                 <wd-radio-group v-model="localReelData.paintQuality" cell shape="dot"> | 
 |  |  |                   <wd-radio | 
 |  |  |                     v-for="option in paintQualityOptions" | 
 |  |  |                     :key="option.value" | 
 |  |  |                     :value="option.value" | 
 |  |  |                   > | 
 |  |  |                     {{ option.label }} | 
 |  |  |                   </wd-radio> | 
 |  |  |                 </wd-radio-group> | 
 |  |  |               </wd-form-item> | 
 |  |  |               <wd-form-item label="毛刺裂纹扭折" prop="burrCrack" required> | 
 |  |  |                 <wd-picker | 
 |  |  |                   v-model="localReelData.burrCrack" | 
 |  |  |                   range-key="label" | 
 |  |  |                   :columns="trueOrFalseOptions" | 
 |  |  |                   placeholder="请选择" | 
 |  |  |                 ></wd-picker> | 
 |  |  |                 <wd-radio-group v-model="localReelData.burrCrack" cell shape="dot"> | 
 |  |  |                   <wd-radio value="是">是</wd-radio> | 
 |  |  |                   <wd-radio value="否">否</wd-radio> | 
 |  |  |                 </wd-radio-group> | 
 |  |  |               </wd-form-item> | 
 |  |  |               <wd-form-item label="锐角棱边倒钝" prop="edgeBlunt" required> | 
 |  |  |                 <wd-picker | 
 |  |  |                   v-model="localReelData.edgeBlunt" | 
 |  |  |                   range-key="label" | 
 |  |  |                   :columns="haveOrNotOptions" | 
 |  |  |                   placeholder="请选择" | 
 |  |  |                 ></wd-picker> | 
 |  |  |                 <wd-radio-group v-model="localReelData.edgeBlunt" cell shape="dot"> | 
 |  |  |                   <wd-radio | 
 |  |  |                     v-for="option in haveOrNotOptions" | 
 |  |  |                     :key="option.value" | 
 |  |  |                     :value="option.value" | 
 |  |  |                   > | 
 |  |  |                     {{ option.label }} | 
 |  |  |                   </wd-radio> | 
 |  |  |                 </wd-radio-group> | 
 |  |  |               </wd-form-item> | 
 |  |  |               <wd-form-item label="木板是否发霉" prop="woodMold" required> | 
 |  |  |                 <wd-picker | 
 |  |  |                   v-model="localReelData.woodMold" | 
 |  |  |                   range-key="label" | 
 |  |  |                   :columns="trueOrFalseOptions" | 
 |  |  |                   placeholder="请选择" | 
 |  |  |                 ></wd-picker> | 
 |  |  |                 <wd-radio-group v-model="localReelData.woodMold" cell shape="dot"> | 
 |  |  |                   <wd-radio value="是">是</wd-radio> | 
 |  |  |                   <wd-radio value="否">否</wd-radio> | 
 |  |  |                 </wd-radio-group> | 
 |  |  |               </wd-form-item> | 
 |  |  |               <wd-form-item label="焊接质量" prop="weldQuality"> | 
 |  |  |                 <wd-select-picker | 
 |  |  |                   v-model="localReelData.weldQuality" | 
 |  |  |                   range-key="label" | 
 |  |  |                   :columns="weldQualityOptions" | 
 |  |  |                   placeholder="请选择" | 
 |  |  |                 ></wd-select-picker> | 
 |  |  |                 <view class="checkbox-group"> | 
 |  |  |                   <wd-checkbox | 
 |  |  |                     v-for="option in weldQualityOptions" | 
 |  |  |                     :key="option.value" | 
 |  |  |                     :modelValue=" | 
 |  |  |                       Array.isArray(localReelData.weldQuality) | 
 |  |  |                         ? localReelData.weldQuality.includes(String(option.value)) | 
 |  |  |                         : false | 
 |  |  |                     " | 
 |  |  |                     shape="square" | 
 |  |  |                     @change="(val) => handleWeldQualityCheckbox(String(option.value), val)" | 
 |  |  |                   > | 
 |  |  |                     {{ option.label }} | 
 |  |  |                   </wd-checkbox> | 
 |  |  |                 </view> | 
 |  |  |               </wd-form-item> | 
 |  |  |             </wd-form> | 
 |  |  |           </view> | 
 |  |  | 
 |  |  | </template> | 
 |  |  |  | 
 |  |  | <script setup lang="ts"> | 
 |  |  | import { ref, watch } from "vue"; | 
 |  |  | import { ref, watch, nextTick } from "vue"; | 
 |  |  | import { useToast } from "wot-design-uni"; | 
 |  |  | import TwistApi from "@/api/product/twist"; | 
 |  |  | import ManageApi from "@/api/product/manage"; | 
 |  |  | 
 |  |  | // 定义TypeScript接口 | 
 |  |  | interface MaterialData { | 
 |  |  |   model: string; | 
 |  |  |   appearanceQuality: string; | 
 |  |  |   appearanceQuality: string | string[]; | 
 |  |  |   dia: string; | 
 |  |  |   length: string; | 
 |  |  |   windingTightness: string; | 
 |  |  | 
 |  |  |   burrCrack: string; | 
 |  |  |   edgeBlunt: string; | 
 |  |  |   woodMold: string; | 
 |  |  |   weldQuality: string; | 
 |  |  |   weldQuality: string | string[]; | 
 |  |  | } | 
 |  |  |  | 
 |  |  | // 定义组件的props | 
 |  |  | const props = defineProps<{ | 
 |  |  |   singleRegulationInfoArray: MaterialData[]; | 
 |  |  |   steelRegulationInfoArray: SteelData[]; | 
 |  |  |   steelRegulationInfo: SteelData; | 
 |  |  |   reelToolingInfo: ReelData; | 
 |  |  |   wireId: string; | 
 |  |  | }>(); | 
 |  |  | 
 |  |  |     console.error("加载数据字典失败:", error); | 
 |  |  |   } | 
 |  |  | }; | 
 |  |  |  | 
 |  |  | // 存储每个原材料项的前一个外观质量值,用于比较变化 | 
 |  |  | const previousAppearanceQuality = ref<Map<number, string[]>>(new Map()); | 
 |  |  |  | 
 |  |  | // 处理外观质量下拉框的互斥选择逻辑 | 
 |  |  | const handleAppearanceQualityChange = ( | 
 |  |  |   index: number, | 
 |  |  |   selectedValues: string[], | 
 |  |  |   allOptions: Array<{ label: string; value: string }> | 
 |  |  | ): string[] => { | 
 |  |  |   // 如果没有选项数据,直接返回 | 
 |  |  |   if (!allOptions || allOptions.length === 0) { | 
 |  |  |     return selectedValues; | 
 |  |  |   } | 
 |  |  |  | 
 |  |  |   // 获取之前的值 | 
 |  |  |   const previousValues = previousAppearanceQuality.value.get(index) || []; | 
 |  |  |  | 
 |  |  |   // 查找"无外观问题"选项的值 | 
 |  |  |   const noIssueOption = allOptions.find( | 
 |  |  |     (item) => item.label === "无外观问题" || item.value === "无外观问题" | 
 |  |  |   ); | 
 |  |  |  | 
 |  |  |   if (!noIssueOption) { | 
 |  |  |     // 如果字典中没有"无外观问题"选项,直接返回 | 
 |  |  |     return selectedValues; | 
 |  |  |   } | 
 |  |  |  | 
 |  |  |   const noIssueValue = noIssueOption.value as string; | 
 |  |  |  | 
 |  |  |   // 检查当前选中值中是否包含"无外观问题" | 
 |  |  |   const hasNoIssue = selectedValues.includes(noIssueValue); | 
 |  |  |  | 
 |  |  |   // 检查之前是否包含"无外观问题" | 
 |  |  |   const hadNoIssue = previousValues.includes(noIssueValue); | 
 |  |  |  | 
 |  |  |   // 判断是否新选择了"无外观问题"(之前没有,现在有) | 
 |  |  |   const isNewlySelectedNoIssue = !hadNoIssue && hasNoIssue; | 
 |  |  |  | 
 |  |  |   // 判断是否移除了"无外观问题"(之前有,现在没有) | 
 |  |  |   const isRemovedNoIssue = hadNoIssue && !hasNoIssue; | 
 |  |  |  | 
 |  |  |   // 判断是否在"无外观问题"已选中的情况下选择了其他选项 | 
 |  |  |   const isSelectingOtherWithNoIssue = | 
 |  |  |     hadNoIssue && hasNoIssue && selectedValues.length > previousValues.length; | 
 |  |  |  | 
 |  |  |   let result: string[]; | 
 |  |  |  | 
 |  |  |   if (isNewlySelectedNoIssue) { | 
 |  |  |     // 如果新选择了"无外观问题",则只保留"无外观问题" | 
 |  |  |     result = [noIssueValue]; | 
 |  |  |   } else if (isSelectingOtherWithNoIssue) { | 
 |  |  |     // 如果"无外观问题"已经被选中,且新选择了其他选项,则移除"无外观问题" | 
 |  |  |     result = selectedValues.filter((val) => val !== noIssueValue); | 
 |  |  |   } else if (isRemovedNoIssue) { | 
 |  |  |     // 如果移除了"无外观问题",直接返回(已经是其他选项了) | 
 |  |  |     result = selectedValues; | 
 |  |  |   } else { | 
 |  |  |     result = selectedValues; | 
 |  |  |   } | 
 |  |  |  | 
 |  |  |   // 保存当前值作为下一次的前一个值 | 
 |  |  |   previousAppearanceQuality.value.set(index, result); | 
 |  |  |   return result; | 
 |  |  | }; | 
 |  |  |  | 
 |  |  | // 处理复选框的change事件 | 
 |  |  | const handleAppearanceQualityCheckbox = ( | 
 |  |  |   index: number, | 
 |  |  |   optionValue: string | number, | 
 |  |  |   checked: boolean | 
 |  |  | ) => { | 
 |  |  |   const currentValues = Array.isArray(localMaterialData.value[index].appearanceQuality) | 
 |  |  |     ? localMaterialData.value[index].appearanceQuality | 
 |  |  |     : []; | 
 |  |  |  | 
 |  |  |   let newValues: string[]; | 
 |  |  |   if (checked) { | 
 |  |  |     // 选中 | 
 |  |  |     newValues = [...(currentValues as string[]), optionValue as string]; | 
 |  |  |   } else { | 
 |  |  |     // 取消选中 | 
 |  |  |     newValues = (currentValues as string[]).filter((v) => v !== optionValue); | 
 |  |  |   } | 
 |  |  |  | 
 |  |  |   // 应用互斥逻辑 | 
 |  |  |   const result = handleAppearanceQualityChange( | 
 |  |  |     index, | 
 |  |  |     newValues, | 
 |  |  |     appearanceQualityOptions.value as Array<{ label: string; value: string }> | 
 |  |  |   ); | 
 |  |  |  | 
 |  |  |   // 更新值 | 
 |  |  |   localMaterialData.value[index].appearanceQuality = result; | 
 |  |  | }; | 
 |  |  |  | 
 |  |  | // 处理焊接质量复选框的change事件 | 
 |  |  | 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); | 
 |  |  |   } | 
 |  |  |  | 
 |  |  |   // 更新值 | 
 |  |  |   localReelData.value.weldQuality = newValues; | 
 |  |  | }; | 
 |  |  |  | 
 |  |  | const haveOrNotOptions = [ | 
 |  |  |   { | 
 |  |  |     label: "有", | 
 |  |  | 
 |  |  |  | 
 |  |  | // 本地响应式数据,用于存储用户输入 | 
 |  |  | const localMaterialData = ref<MaterialData[]>([]); | 
 |  |  | const localSteelData = ref<SteelData[]>([]); | 
 |  |  | const localSteelData = ref<SteelData>({ | 
 |  |  |   model: "", | 
 |  |  |   twistedDirection: "", | 
 |  |  |   outerDiameter: "", | 
 |  |  |   scratch: "", | 
 |  |  |   oilStain: "", | 
 |  |  | }); | 
 |  |  | const localReelData = ref<ReelData>({ | 
 |  |  |   nutFixed: "", | 
 |  |  |   sidePlateFlat: "", | 
 |  |  | 
 |  |  |  | 
 |  |  | // 初始化本地数据 | 
 |  |  | const initializeData = () => { | 
 |  |  |   // 查找"无外观问题"的值 | 
 |  |  |   const noIssueOption = appearanceQualityOptions.value.find( | 
 |  |  |     (item) => item.label === "无外观问题" || item.value === "无外观问题" | 
 |  |  |   ); | 
 |  |  |   const defaultAppearanceQuality = noIssueOption ? [noIssueOption.value as string] : []; | 
 |  |  |  | 
 |  |  |   // 初始化原材料数据 | 
 |  |  |   localMaterialData.value = | 
 |  |  |     props.singleRegulationInfoArray.length > 0 | 
 |  |  |       ? props.singleRegulationInfoArray.map((item) => ({ | 
 |  |  |           model: item.model || "", | 
 |  |  |           appearanceQuality: item.appearanceQuality || "", | 
 |  |  |           dia: item.dia || "", | 
 |  |  |           length: item.length || "", | 
 |  |  |           windingTightness: item.windingTightness || "", | 
 |  |  |           arrangement: item.arrangement || "", | 
 |  |  |           edgeDistance: item.edgeDistance || "", | 
 |  |  |         })) | 
 |  |  |       ? props.singleRegulationInfoArray.map((item, idx) => { | 
 |  |  |           // 处理外观质量数据,确保是数组格式 | 
 |  |  |           let initialQuality: string[] = []; | 
 |  |  |           if (item.appearanceQuality) { | 
 |  |  |             if (Array.isArray(item.appearanceQuality)) { | 
 |  |  |               initialQuality = item.appearanceQuality.map((v) => String(v)); | 
 |  |  |             } else if (typeof item.appearanceQuality === "string") { | 
 |  |  |               initialQuality = [item.appearanceQuality]; | 
 |  |  |             } | 
 |  |  |           } else { | 
 |  |  |             initialQuality = defaultAppearanceQuality; | 
 |  |  |           } | 
 |  |  |  | 
 |  |  |           // 初始化前一个值 | 
 |  |  |           previousAppearanceQuality.value.set(idx, initialQuality); | 
 |  |  |  | 
 |  |  |           return { | 
 |  |  |             model: item.model || "", | 
 |  |  |             appearanceQuality: initialQuality, | 
 |  |  |             dia: item.dia || "", | 
 |  |  |             length: item.length || "", | 
 |  |  |             windingTightness: item.windingTightness || "是", | 
 |  |  |             arrangement: item.arrangement || "是", | 
 |  |  |             edgeDistance: item.edgeDistance || "", | 
 |  |  |           }; | 
 |  |  |         }) | 
 |  |  |       : [ | 
 |  |  |           { | 
 |  |  |             model: "", | 
 |  |  |             appearanceQuality: "", | 
 |  |  |             appearanceQuality: defaultAppearanceQuality, | 
 |  |  |             dia: "", | 
 |  |  |             length: "", | 
 |  |  |             windingTightness: "", | 
 |  |  |             arrangement: "", | 
 |  |  |             windingTightness: "是", | 
 |  |  |             arrangement: "是", | 
 |  |  |             edgeDistance: "", | 
 |  |  |           }, | 
 |  |  |         ]; | 
 |  |  |  | 
 |  |  |   // 如果新建了第一条数据,初始化它的前一个值 | 
 |  |  |   if (localMaterialData.value.length > 0 && !previousAppearanceQuality.value.has(0)) { | 
 |  |  |     previousAppearanceQuality.value.set(0, defaultAppearanceQuality); | 
 |  |  |   } | 
 |  |  |  | 
 |  |  |   // 初始化钢芯数据 | 
 |  |  |   localSteelData.value = | 
 |  |  |     props.steelRegulationInfoArray.length > 0 | 
 |  |  |       ? props.steelRegulationInfoArray.map((item) => ({ | 
 |  |  |           model: item.model || "", | 
 |  |  |           twistedDirection: item.twistedDirection || "", | 
 |  |  |           outerDiameter: item.outerDiameter || "", | 
 |  |  |           scratch: item.scratch || "", | 
 |  |  |           oilStain: item.oilStain || "", | 
 |  |  |         })) | 
 |  |  |       : [ | 
 |  |  |           { | 
 |  |  |             model: "", | 
 |  |  |             twistedDirection: "", | 
 |  |  |             outerDiameter: "", | 
 |  |  |             scratch: "", | 
 |  |  |             oilStain: "", | 
 |  |  |           }, | 
 |  |  |         ]; | 
 |  |  |     props.steelRegulationInfo && Object.keys(props.steelRegulationInfo).length > 0 | 
 |  |  |       ? { | 
 |  |  |           model: props.steelRegulationInfo.model || "", | 
 |  |  |           twistedDirection: props.steelRegulationInfo.twistedDirection || "", | 
 |  |  |           outerDiameter: props.steelRegulationInfo.outerDiameter || "", | 
 |  |  |           scratch: props.steelRegulationInfo.scratch || "否", | 
 |  |  |           oilStain: props.steelRegulationInfo.oilStain || "否", | 
 |  |  |         } | 
 |  |  |       : { | 
 |  |  |           model: "", | 
 |  |  |           twistedDirection: "", | 
 |  |  |           outerDiameter: "", | 
 |  |  |           scratch: "否", | 
 |  |  |           oilStain: "否", | 
 |  |  |         }; | 
 |  |  |  | 
 |  |  |   // 初始化盘具数据 | 
 |  |  |   // 处理焊接质量默认值:如果为空则设置为"已磨光"和"已修平" | 
 |  |  |   let weldQualityValue: string[] = []; | 
 |  |  |   if ( | 
 |  |  |     Array.isArray(props.reelToolingInfo.weldQuality) && | 
 |  |  |     props.reelToolingInfo.weldQuality.length > 0 | 
 |  |  |   ) { | 
 |  |  |     weldQualityValue = props.reelToolingInfo.weldQuality.map((v) => String(v)); | 
 |  |  |   } else if ( | 
 |  |  |     props.reelToolingInfo.weldQuality && | 
 |  |  |     typeof props.reelToolingInfo.weldQuality === "string" | 
 |  |  |   ) { | 
 |  |  |     weldQualityValue = [props.reelToolingInfo.weldQuality as string]; | 
 |  |  |   } else { | 
 |  |  |     // 默认选择"已磨光"和"已修平" | 
 |  |  |     weldQualityValue = ["已磨光", "已修平"]; | 
 |  |  |   } | 
 |  |  |  | 
 |  |  |   localReelData.value = { | 
 |  |  |     nutFixed: props.reelToolingInfo.nutFixed || "", | 
 |  |  |     sidePlateFlat: props.reelToolingInfo.sidePlateFlat || "", | 
 |  |  |     centerPlateFlat: props.reelToolingInfo.centerPlateFlat || "", | 
 |  |  |     paintQuality: props.reelToolingInfo.paintQuality || "", | 
 |  |  |     burrCrack: props.reelToolingInfo.burrCrack || "", | 
 |  |  |     edgeBlunt: props.reelToolingInfo.edgeBlunt || "", | 
 |  |  |     woodMold: props.reelToolingInfo.woodMold || "", | 
 |  |  |     weldQuality: props.reelToolingInfo.weldQuality || "", | 
 |  |  |     nutFixed: props.reelToolingInfo.nutFixed || "是", | 
 |  |  |     sidePlateFlat: props.reelToolingInfo.sidePlateFlat || "是", | 
 |  |  |     centerPlateFlat: props.reelToolingInfo.centerPlateFlat || "是", | 
 |  |  |     paintQuality: props.reelToolingInfo.paintQuality || "完好", | 
 |  |  |     burrCrack: props.reelToolingInfo.burrCrack || "否", | 
 |  |  |     edgeBlunt: props.reelToolingInfo.edgeBlunt || "无", | 
 |  |  |     woodMold: props.reelToolingInfo.woodMold || "否", | 
 |  |  |     weldQuality: weldQualityValue, | 
 |  |  |   }; | 
 |  |  | }; | 
 |  |  |  | 
 |  |  | // 用于跟踪每个原材料项的初始外观质量值 | 
 |  |  | const appearanceQualityWatchers = ref<Map<number, any>>(new Map()); | 
 |  |  |  | 
 |  |  | // 初始化数据 | 
 |  |  | initializeData(); | 
 |  |  |  | 
 |  |  | // 为每个原材料项添加独立的外观质量监听器 | 
 |  |  | const setupAppearanceQualityWatchers = () => { | 
 |  |  |   // 清除旧的监听器 | 
 |  |  |   appearanceQualityWatchers.value.forEach((stop) => stop()); | 
 |  |  |   appearanceQualityWatchers.value.clear(); | 
 |  |  |  | 
 |  |  |   // 为每个项添加新的监听器 | 
 |  |  |   localMaterialData.value.forEach((item, index) => { | 
 |  |  |     const stop = watch( | 
 |  |  |       () => item.appearanceQuality, | 
 |  |  |       (newValue, oldValue) => { | 
 |  |  |         const normalizedNewValue = Array.isArray(newValue) ? newValue : []; | 
 |  |  |         const normalizedOldValue = Array.isArray(oldValue) ? oldValue : []; | 
 |  |  |  | 
 |  |  |         // 应用互斥逻辑 | 
 |  |  |         const result = handleAppearanceQualityChange( | 
 |  |  |           index, | 
 |  |  |           normalizedNewValue, | 
 |  |  |           appearanceQualityOptions.value as Array<{ label: string; value: string }> | 
 |  |  |         ); | 
 |  |  |  | 
 |  |  |         // 如果值被修改了,异步更新,避免在监听中同步修改 | 
 |  |  |         if (JSON.stringify(result) !== JSON.stringify(normalizedNewValue)) { | 
 |  |  |           nextTick(() => { | 
 |  |  |             item.appearanceQuality = result; | 
 |  |  |           }); | 
 |  |  |         } | 
 |  |  |       }, | 
 |  |  |       { deep: true } | 
 |  |  |     ); | 
 |  |  |  | 
 |  |  |     appearanceQualityWatchers.value.set(index, stop); | 
 |  |  |   }); | 
 |  |  | }; | 
 |  |  |  | 
 |  |  | // 初始化监听器 | 
 |  |  | setupAppearanceQualityWatchers(); | 
 |  |  |  | 
 |  |  | // 监听props变化,更新本地数据 | 
 |  |  | watch(() => props.singleRegulationInfoArray, initializeData, { deep: true }); | 
 |  |  | watch(() => props.steelRegulationInfoArray, initializeData, { deep: true }); | 
 |  |  | watch( | 
 |  |  |   () => props.singleRegulationInfoArray, | 
 |  |  |   () => { | 
 |  |  |     initializeData(); | 
 |  |  |     setupAppearanceQualityWatchers(); | 
 |  |  |   }, | 
 |  |  |   { deep: true } | 
 |  |  | ); | 
 |  |  | watch(() => props.steelRegulationInfo, initializeData, { deep: true }); | 
 |  |  | watch(() => props.reelToolingInfo, initializeData, { deep: true }); | 
 |  |  |  | 
 |  |  | const handleTabChange = (tabName: string) => { | 
 |  |  | 
 |  |  |   if ( | 
 |  |  |     activeTab.value === "material" || | 
 |  |  |     (!localMaterialData.value.length && | 
 |  |  |       !localSteelData.value.length && | 
 |  |  |       !Object.keys(localSteelData.value).length && | 
 |  |  |       !Object.keys(localReelData.value).length) | 
 |  |  |   ) { | 
 |  |  |     for (let i = 0; i < localMaterialData.value.length; i++) { | 
 |  |  | 
 |  |  |   if ( | 
 |  |  |     activeTab.value === "steel" || | 
 |  |  |     (!localMaterialData.value.length && | 
 |  |  |       !localSteelData.value.length && | 
 |  |  |       !Object.keys(localSteelData.value).length && | 
 |  |  |       !Object.keys(localReelData.value).length) | 
 |  |  |   ) { | 
 |  |  |     for (let i = 0; i < localSteelData.value.length; i++) { | 
 |  |  |       const item = localSteelData.value[i]; | 
 |  |  |       if ( | 
 |  |  |         !item.model || | 
 |  |  |         item.model === "" || | 
 |  |  |         !item.twistedDirection || | 
 |  |  |         item.twistedDirection === "" || | 
 |  |  |         !item.outerDiameter || | 
 |  |  |         item.outerDiameter === "" || | 
 |  |  |         !item.scratch || | 
 |  |  |         item.scratch === "" || | 
 |  |  |         !item.oilStain || | 
 |  |  |         item.oilStain === "" | 
 |  |  |       ) { | 
 |  |  |         toast.error(`钢芯第${i + 1}行存在必填项未填写`); | 
 |  |  |         return false; | 
 |  |  |       } | 
 |  |  |     const steel = localSteelData.value; | 
 |  |  |     if ( | 
 |  |  |       !steel.model || | 
 |  |  |       steel.model === "" || | 
 |  |  |       !steel.twistedDirection || | 
 |  |  |       steel.twistedDirection === "" || | 
 |  |  |       !steel.outerDiameter || | 
 |  |  |       steel.outerDiameter === "" || | 
 |  |  |       !steel.scratch || | 
 |  |  |       steel.scratch === "" || | 
 |  |  |       !steel.oilStain || | 
 |  |  |       steel.oilStain === "" | 
 |  |  |     ) { | 
 |  |  |       toast.error("钢芯数据存在必填项未填写"); | 
 |  |  |       return false; | 
 |  |  |     } | 
 |  |  |   } | 
 |  |  |  | 
 |  |  | 
 |  |  |   if ( | 
 |  |  |     activeTab.value === "reel" || | 
 |  |  |     (!localMaterialData.value.length && | 
 |  |  |       !localSteelData.value.length && | 
 |  |  |       !Object.keys(localSteelData.value).length && | 
 |  |  |       !Object.keys(localReelData.value).length) | 
 |  |  |   ) { | 
 |  |  |     const reel = localReelData.value; | 
 |  |  | 
 |  |  |     await TwistApi.addSingleDishInspection({ | 
 |  |  |       inspectResult: { | 
 |  |  |         singleRegulationInfoArray: localMaterialData.value, | 
 |  |  |         steelRegulationInfoArray: localSteelData.value, | 
 |  |  |         steelRegulationInfo: localSteelData.value, | 
 |  |  |         reelToolingInfo: localReelData.value, | 
 |  |  |       }, | 
 |  |  |       wireId: props.wireId, | 
 |  |  | 
 |  |  |   await loadDictData(); | 
 |  |  | }); | 
 |  |  | watch( | 
 |  |  |   () => [props.singleRegulationInfoArray, props.steelRegulationInfoArray, props.reelToolingInfo], | 
 |  |  |   () => [props.singleRegulationInfoArray, props.steelRegulationInfo, props.reelToolingInfo], | 
 |  |  |   () => { | 
 |  |  |     const hasMaterial = | 
 |  |  |       Array.isArray(props.singleRegulationInfoArray) && props.singleRegulationInfoArray.length > 0; | 
 |  |  |     const hasSteel = | 
 |  |  |       Array.isArray(props.steelRegulationInfoArray) && props.steelRegulationInfoArray.length > 0; | 
 |  |  |       props.steelRegulationInfo && | 
 |  |  |       typeof props.steelRegulationInfo === "object" && | 
 |  |  |       Object.keys(props.steelRegulationInfo).length > 0; | 
 |  |  |     const hasReel = | 
 |  |  |       props.reelToolingInfo && | 
 |  |  |       typeof props.reelToolingInfo === "object" && | 
 |  |  | 
 |  |  | .submit-btn { | 
 |  |  |   width: 100%; | 
 |  |  | } | 
 |  |  |  | 
 |  |  | .checkbox-group { | 
 |  |  |   display: flex; | 
 |  |  |   flex-wrap: wrap; | 
 |  |  |   gap: 12px; | 
 |  |  | } | 
 |  |  |  | 
 |  |  | :deep(.wd-checkbox) { | 
 |  |  |   margin-right: 0; | 
 |  |  | } | 
 |  |  | </style> |