From 5384750e59bbb27c54e090100429c48eaba46df0 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 20 十一月 2025 10:15:20 +0800
Subject: [PATCH] fix: 完成拉丝自检、原材料自检优化
---
src/pages/production/wire/report/rawMaterial.vue | 222 +++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 174 insertions(+), 48 deletions(-)
diff --git a/src/pages/production/wire/report/rawMaterial.vue b/src/pages/production/wire/report/rawMaterial.vue
index e75d424..96f67e6 100644
--- a/src/pages/production/wire/report/rawMaterial.vue
+++ b/src/pages/production/wire/report/rawMaterial.vue
@@ -30,6 +30,7 @@
v-model="materialData.conductivity"
range-key="label"
placeholder="璇疯緭鍏�"
+ type="number"
></wd-input>
</wd-form-item>
<wd-form-item label="鎶楁媺寮哄害(Mpa)" prop="tensileStrength" required>
@@ -37,6 +38,7 @@
v-model="materialData.tensileStrength"
range-key="label"
placeholder="璇疯緭鍏�"
+ type="number"
></wd-input>
</wd-form-item>
<wd-form-item label="鐢甸樆鐜�(n惟路m)" prop="resistivity" required>
@@ -44,6 +46,7 @@
v-model="materialData.resistivity"
range-key="label"
placeholder="璇疯緭鍏�"
+ type="number"
></wd-input>
</wd-form-item>
<wd-form-item label="浼搁暱鐜�(%)" prop="elongationRate" required>
@@ -51,15 +54,25 @@
v-model="materialData.elongationRate"
range-key="label"
placeholder="璇疯緭鍏�"
+ type="number"
></wd-input>
</wd-form-item>
<wd-form-item label="澶栬璐ㄩ噺" prop="appearanceQuality" required>
- <wd-select-picker
- v-model="materialData.appearanceQuality"
- range-key="label"
- :columns="drawing_appearanceQuality"
- placeholder="璇烽�夋嫨"
- ></wd-select-picker>
+ <view class="checkbox-group">
+ <wd-checkbox
+ v-for="option in drawing_appearanceQuality"
+ :key="option.value"
+ :modelValue="
+ Array.isArray(materialData.appearanceQuality)
+ ? materialData.appearanceQuality.includes(String(option.value))
+ : false
+ "
+ shape="square"
+ @change="(val) => handleAppearanceQualityCheckbox(String(option.value), val)"
+ >
+ {{ option.label }}
+ </wd-checkbox>
+ </view>
</wd-form-item>
</wd-form>
</view>
@@ -73,7 +86,7 @@
</template>
<script setup lang="ts">
-import { ref, onMounted } from "vue";
+import { ref, onMounted, watch, nextTick } from "vue";
import { useToast } from "wot-design-uni";
import ManageApi from "@/api/product/manage";
@@ -131,9 +144,104 @@
const activeTab = ref("reel"); // 涓巘ab鐨刵ame淇濇寔涓�鑷�
const toast = useToast();
+// 瀛樺偍鍓嶄竴涓瑙傝川閲忓�硷紝鐢ㄤ簬姣旇緝鍙樺寲
+const previousAppearanceQuality = ref<string[]>([]);
+
+// 澶勭悊澶栬璐ㄩ噺涓嬫媺妗嗙殑浜掓枼閫夋嫨閫昏緫
+const handleAppearanceQualityChange = (
+ selectedValues: string[],
+ allOptions: Array<{ label: string; value: string | number }>
+): string[] => {
+ // 濡傛灉娌℃湁閫夐」鏁版嵁锛岀洿鎺ヨ繑鍥�
+ if (!allOptions || allOptions.length === 0) {
+ return selectedValues;
+ }
+
+ // 鑾峰彇涔嬪墠鐨勫��
+ const previousValues = previousAppearanceQuality.value || [];
+
+ // 鏌ユ壘"鏃犲瑙傞棶棰�"閫夐」鐨勫��
+ const noIssueOption = allOptions.find(
+ (item) => item.label === "鏃犲瑙傞棶棰�" || item.value === "鏃犲瑙傞棶棰�"
+ );
+
+ if (!noIssueOption) {
+ // 濡傛灉瀛楀吀涓病鏈�"鏃犲瑙傞棶棰�"閫夐」锛岀洿鎺ヨ繑鍥�
+ return selectedValues;
+ }
+
+ const noIssueValue = String(noIssueOption.value);
+
+ // 妫�鏌ュ綋鍓嶉�変腑鍊间腑鏄惁鍖呭惈"鏃犲瑙傞棶棰�"
+ 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 = result;
+ return result;
+};
+
+// 澶勭悊澶嶉�夋鐨刢hange浜嬩欢
+const handleAppearanceQualityCheckbox = (optionValue: string, checked: boolean) => {
+ const currentValues = Array.isArray(materialData.value.appearanceQuality)
+ ? materialData.value.appearanceQuality
+ : [];
+
+ let newValues: string[];
+ if (checked) {
+ // 閫変腑
+ newValues = [...currentValues, optionValue];
+ } else {
+ // 鍙栨秷閫変腑
+ newValues = currentValues.filter((v) => v !== optionValue);
+ }
+
+ // 搴旂敤浜掓枼閫昏緫
+ const result = handleAppearanceQualityChange(
+ newValues,
+ drawing_appearanceQuality.value as Array<{ label: string; value: string | number }>
+ );
+
+ // 鏇存柊鍊�
+ materialData.value.appearanceQuality = result;
+};
+
// 鏈湴鍝嶅簲寮忔暟鎹紝鐢ㄤ簬瀛樺偍鐢ㄦ埛杈撳叆
const materialData = ref<Record<string, any>>({});
const initializeData = () => {
+ // 鏌ユ壘"鏃犲瑙傞棶棰�"鐨勫��
+ const noIssueOption = drawing_appearanceQuality.value.find(
+ (item) => item.label === "鏃犲瑙傞棶棰�" || item.value === "鏃犲瑙傞棶棰�"
+ );
+ const defaultAppearanceQuality = noIssueOption ? [String(noIssueOption.value)] : [];
+
// 鍒濆鍖栧師鏉愭枡鏁版嵁
materialData.value = {
model: "",
@@ -142,8 +250,11 @@
tensileStrength: "",
resistivity: "",
elongationRate: "",
- appearanceQuality: "",
+ appearanceQuality: defaultAppearanceQuality,
};
+
+ // 鍒濆鍖栧墠涓�涓��
+ previousAppearanceQuality.value = defaultAppearanceQuality;
};
// 鍒濆鍖栨暟鎹�
@@ -152,7 +263,32 @@
// 鍦ㄧ粍浠舵寕杞芥椂寮傛鍔犺浇鏁版嵁瀛楀吀
onMounted(async () => {
await loadDictData();
+ // 瀛楀吀鏁版嵁鍔犺浇瀹屾垚鍚庯紝閲嶆柊鍒濆鍖栨暟鎹紝纭繚榛樿鍊艰兘姝g‘鍖归厤
+ initializeData();
});
+
+// 鐩戝惉澶栬璐ㄩ噺鍙樺寲锛屽簲鐢ㄤ簰鏂ラ�昏緫
+watch(
+ () => materialData.value.appearanceQuality,
+ (newValue, oldValue) => {
+ const normalizedNewValue = Array.isArray(newValue) ? newValue : [];
+ const normalizedOldValue = Array.isArray(oldValue) ? oldValue : [];
+
+ // 搴旂敤浜掓枼閫昏緫
+ const result = handleAppearanceQualityChange(
+ normalizedNewValue,
+ drawing_appearanceQuality.value as Array<{ label: string; value: string | number }>
+ );
+
+ // 濡傛灉鍊艰淇敼浜嗭紝寮傛鏇存柊锛岄伩鍏嶅湪鐩戝惉涓悓姝ヤ慨鏀�
+ if (JSON.stringify(result) !== JSON.stringify(normalizedNewValue)) {
+ nextTick(() => {
+ materialData.value.appearanceQuality = result;
+ });
+ }
+ },
+ { deep: true }
+);
// 鐩戝惉props鍙樺寲锛屾洿鏂版湰鍦版暟鎹�
@@ -166,6 +302,30 @@
};
const handleSubmit = async () => {
+ // 琛ㄥ崟楠岃瘉
+ if (
+ !materialData.value.model ||
+ materialData.value.model === "" ||
+ !materialData.value.spec ||
+ materialData.value.spec === "" ||
+ !materialData.value.conductivity ||
+ materialData.value.conductivity === "" ||
+ !materialData.value.tensileStrength ||
+ materialData.value.tensileStrength === "" ||
+ !materialData.value.resistivity ||
+ materialData.value.resistivity === "" ||
+ !materialData.value.elongationRate ||
+ materialData.value.elongationRate === "" ||
+ !materialData.value.appearanceQuality ||
+ (Array.isArray(materialData.value.appearanceQuality) &&
+ materialData.value.appearanceQuality.length === 0) ||
+ (!Array.isArray(materialData.value.appearanceQuality) &&
+ materialData.value.appearanceQuality === "")
+ ) {
+ toast.error("璇峰~鍐欏畬鏁寸殑蹇呭~椤�");
+ return false;
+ }
+
try {
// 璋冪敤API鎻愪氦鏁版嵁
await ManageApi.addWireRawMaterialInspect({
@@ -273,47 +433,13 @@
width: 100%;
}
-// 缇庡寲閫夋嫨鍣ㄦ牱寮� - 澧炲姞鏉冮噸纭繚鏍峰紡鐢熸晥
-:deep(.wd-select-picker) {
- & .wd-select-picker__option {
- text-align: center !important;
- padding: 12px 0 !important;
- font-size: 16px !important;
- }
-
- & .wd-select-picker__confirm {
- border-radius: 8px !important;
- background-color: #409eff !important;
- color: white !important;
- font-weight: 500 !important;
- }
-
- & .wd-select-picker__header {
- padding: 10px 0 !important;
- border-bottom: 1px solid #e6e6e6 !important;
- }
-
- & .wd-select-picker__title {
- font-size: 16px !important;
- font-weight: 500 !important;
- }
+.checkbox-group {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 12px;
}
-// 纭繚閫夋嫨鍣ㄥ唴閮ㄩ�夐」灞呬腑 - 鏇撮�氱敤鐨勯�夋嫨鍣�
-:deep(.wd-select-picker__content) {
- .wd-select-picker__option {
- text-align: center !important;
- padding: 12px 0 !important;
- font-size: 16px !important;
- }
-}
-
-// 鐩存帴閽堝閫夐」鍏冪礌鐨勯�夋嫨鍣�
-:deep([class*="select-picker"].wd-popup) {
- .wd-select-picker__option {
- text-align: center !important;
- padding: 12px 0 !important;
- font-size: 16px !important;
- }
+:deep(.wd-checkbox) {
+ margin-right: 0;
}
</style>
--
Gitblit v1.9.3