From 78c565e37520fad100693c4e298e30e7c916d1bb Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 28 十月 2025 16:21:40 +0800
Subject: [PATCH] fix: 领用二维码异常提示,原材料自检重构
---
src/pages/production/twist/report/draw.vue | 739 ++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 499 insertions(+), 240 deletions(-)
diff --git a/src/pages/production/twist/report/draw.vue b/src/pages/production/twist/report/draw.vue
index 22a7c7a..56eb4bc 100644
--- a/src/pages/production/twist/report/draw.vue
+++ b/src/pages/production/twist/report/draw.vue
@@ -1,50 +1,57 @@
<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-form>
- <wd-form-item label="瑙勬牸鍨嬪彿" prop="spec" required>
+ <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="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"
@@ -55,114 +62,116 @@
</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>
- <wd-form-item label="瑙勬牸鍨嬪彿" prop="spec" 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>
+ <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>
@@ -175,69 +184,200 @@
</view>
</template>
-<script setup>
-import { ref, watch } from "vue";
+<script setup lang="ts">
+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 | string[];
+ dia: string;
+ length: string;
+ windingTightness: string;
+ arrangement: string;
+ edgeDistance: string;
+}
+
+interface SteelData {
+ model: string;
+ twistedDirection: string;
+ outerDiameter: string;
+ scratch: string;
+ oilStain: string;
+}
+
+interface ReelData {
+ nutFixed: string;
+ sidePlateFlat: string;
+ centerPlateFlat: string;
+ paintQuality: string;
+ burrCrack: string;
+ edgeBlunt: string;
+ woodMold: string;
+ weldQuality: string | string[];
+}
// 瀹氫箟缁勪欢鐨刾rops
-const props = defineProps({
- singleRegulationInfoArray: {
- type: Array,
- default: () => [],
- },
- steelRegulationInfoArray: {
- type: Array,
- default: () => [],
- },
- reelToolingInfo: {
- type: Object,
- default: () => ({}),
- },
- wireId: {
- type: String,
- default: "",
- },
-});
+const props = defineProps<{
+ singleRegulationInfoArray: MaterialData[];
+ steelRegulationInfo: SteelData;
+ reelToolingInfo: ReelData;
+ wireId: string;
+}>();
-const appearanceQualityOptions = [
- {
- label: "鏈夊垝浼�",
- value: "鏈夊垝浼�",
- },
- {
- label: "鏈夌鑺�",
- value: "鏈夌鑺�",
- },
- {
- label: "鏈夐粦鑹叉补姹�",
- value: "鏈夐粦鑹叉补姹�",
- },
- {
- label: "鏃�",
- value: "鏃�",
- },
-];
-const paintQualityOptions = [
- {
- label: "瀹屽ソ",
- value: "瀹屽ソ",
- },
- {
- label: "鐮存崯",
- value: "鐮存崯",
- },
-];
-const weldQualityOptions = [
- {
- label: "宸茬(鍏�",
- value: "宸茬(鍏�",
- },
- {
- label: "宸茬(鐨�",
- value: "宸茬(鐨�",
- },
-];
+const appearanceQualityOptions = ref<Array<{ label: string; value: string | number }>>([]);
+const paintQualityOptions = ref<Array<{ label: string; value: string | number }>>([]);
+const weldQualityOptions = ref<Array<{ label: string; value: string | number }>>([]);
+
+// 浠庢暟鎹瓧鍏镐腑鍔犺浇鏁版嵁
+const loadDictData = async () => {
+ try {
+ // 鍒嗗埆璋冪敤dictAPI鑾峰彇鍚勪釜瀛楀吀鏁版嵁
+ const paintQualityRes = await ManageApi.dictAPI("draw_paint_quality");
+ const weldQualityRes = await ManageApi.dictAPI("draw_welding_quality");
+ const qualityRes = await ManageApi.dictAPI("draw_appearance_quality");
+
+ // 澶勭悊杩斿洖鏁版嵁锛岃浆鎹负缁勪欢鎵�闇�鐨勬牸寮� {label: string, value: string}
+ if (paintQualityRes.data && Array.isArray(paintQualityRes.data)) {
+ paintQualityOptions.value = paintQualityRes.data.map((item) => ({
+ label: item.dictLabel || "",
+ value: item.dictValue || "",
+ }));
+ }
+ if (weldQualityRes.data && Array.isArray(weldQualityRes.data)) {
+ weldQualityOptions.value = weldQualityRes.data.map((item) => ({
+ label: item.dictLabel || "",
+ value: item.dictValue || "",
+ }));
+ }
+ if (qualityRes.data && Array.isArray(qualityRes.data)) {
+ appearanceQualityOptions.value = qualityRes.data.map((item) => ({
+ label: item.dictLabel || "",
+ value: item.dictValue || "",
+ }));
+ }
+ } catch (error) {
+ 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;
+};
+
+// 澶勭悊澶嶉�夋鐨刢hange浜嬩欢
+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;
+};
+
+// 澶勭悊鐒婃帴璐ㄩ噺澶嶉�夋鐨刢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);
+ }
+
+ // 鏇存柊鍊�
+ localReelData.value.weldQuality = newValues;
+};
+
const haveOrNotOptions = [
{
label: "鏈�",
@@ -260,82 +400,188 @@
];
// 瀹氫箟缁勪欢鐨別mits
const emit = defineEmits(["close"]);
-const activeTab = ref("material");
+const activeTab = ref<string>("material");
const toast = useToast();
// 鏈湴鍝嶅簲寮忔暟鎹紝鐢ㄤ簬瀛樺偍鐢ㄦ埛杈撳叆
-const localMaterialData = ref([]);
-const localSteelData = ref([]);
-const localReelData = ref({});
+const localMaterialData = ref<MaterialData[]>([]);
+const localSteelData = ref<SteelData>({
+ model: "",
+ twistedDirection: "",
+ outerDiameter: "",
+ scratch: "",
+ oilStain: "",
+});
+const localReelData = ref<ReelData>({
+ nutFixed: "",
+ sidePlateFlat: "",
+ centerPlateFlat: "",
+ paintQuality: "",
+ burrCrack: "",
+ edgeBlunt: "",
+ woodMold: "",
+ weldQuality: "",
+});
// 鍒濆鍖栨湰鍦版暟鎹�
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) => {
+const handleTabChange = (tabName: string) => {
activeTab.value = tabName;
};
@@ -350,7 +596,7 @@
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++) {
@@ -381,26 +627,24 @@
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;
}
}
@@ -408,7 +652,7 @@
if (
activeTab.value === "reel" ||
(!localMaterialData.value.length &&
- !localSteelData.value.length &&
+ !Object.keys(localSteelData.value).length &&
!Object.keys(localReelData.value).length)
) {
const reel = localReelData.value;
@@ -423,7 +667,7 @@
await TwistApi.addSingleDishInspection({
inspectResult: {
singleRegulationInfoArray: localMaterialData.value,
- steelRegulationInfoArray: localSteelData.value,
+ steelRegulationInfo: localSteelData.value,
reelToolingInfo: localReelData.value,
},
wireId: props.wireId,
@@ -446,14 +690,19 @@
return true;
}
};
-
+// 鍦ㄧ粍浠舵寕杞芥椂寮傛鍔犺浇鏁版嵁瀛楀吀
+onMounted(async () => {
+ 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" &&
@@ -548,4 +797,14 @@
.submit-btn {
width: 100%;
}
+
+.checkbox-group {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 12px;
+}
+
+:deep(.wd-checkbox) {
+ margin-right: 0;
+}
</style>
--
Gitblit v1.9.3