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/selfInspect/form.vue |  381 ++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 324 insertions(+), 57 deletions(-)

diff --git a/src/pages/production/wire/selfInspect/form.vue b/src/pages/production/wire/selfInspect/form.vue
index 6402db7..cafa99a 100644
--- a/src/pages/production/wire/selfInspect/form.vue
+++ b/src/pages/production/wire/selfInspect/form.vue
@@ -1,66 +1,333 @@
 <template>
-  <wd-form ref="form" :model="model" class="relative form_box">
-    <wd-cell-group :border="true">
-      <wd-input
-        v-model="model.selfInspectName"
-        label="鑷鍚嶇О"
-        label-width="100px"
-        prop="selfInspectName"
-        clearable
-        placeholder="璇疯緭鍏ヨ嚜妫�鍚嶇О"
-      />
-      <wd-input
-        v-model="model.unit"
-        label="鍗曚綅"
-        label-width="100px"
-        prop="unit"
-        clearable
-        placeholder="璇疯緭鍏ュ崟浣�"
-      />
-      <wd-input
-        v-model="model.standard"
-        label="鏍囧噯鍊�"
-        label-width="100px"
-        prop="standard"
-        clearable
-        placeholder="璇疯緭鍏ユ爣鍑嗗��"
-      />
-      <wd-input
-        v-model="model.selfInspectValue"
-        label="鑷鍊�"
-        label-width="100px"
-        prop="selfInspectValue"
-        clearable
-        placeholder="璇疯緭鍏ヨ嚜妫�鍊�"
-      />
-      <wd-input
-        v-model="model.selfInspectResult"
-        label="鑷缁撴灉"
-        label-width="100px"
-        prop="selfInspectResult"
-        clearable
-        placeholder="璇疯緭鍏ヨ嚜妫�缁撴灉"
-      />
-    </wd-cell-group>
-  </wd-form>
+  <view class="form-container">
+    <view class="dialog-header">
+      <text class="dialog-title">{{ isEdit ? "缂栬緫鑷" : "鏂板鑷" }}</text>
+      <wd-icon name="close" class="close-icon" @click="handleClose"></wd-icon>
+    </view>
+    <view class="dialog-content">
+      <wd-form ref="formRef" :model="formData">
+        <!-- 鍩烘湰淇℃伅 -->
+        <view class="section-title">鍩烘湰淇℃伅</view>
+        <wd-cell-group border>
+          <wd-input
+            v-model="formData.fixedInfo.firstNo"
+            label="棣栨鍗曞彿"
+            label-width="120px"
+            placeholder="璇疯緭鍏ラ妫�鍗曞彿"
+          />
+          <wd-input
+            v-model="formData.fixedInfo.lastSlot"
+            label="瀹氬緞妯″叿"
+            label-width="120px"
+            placeholder="璇疯緭鍏ュ畾寰勬ā鍏�"
+          />
+        </wd-cell-group>
+
+        <!-- 鍗曚笣鐩村緞 -->
+        <view class="section-title">鍗曚笣鐩村緞(mm)</view>
+        <wd-cell-group border>
+          <wd-cell title="鏈�澶у��" label-width="120px">
+            <wd-input-number
+              v-model="formData.inspectionResult.maxDia"
+              :min="0"
+              :precision="3"
+              :step="0.01"
+              placeholder="璇疯緭鍏ユ渶澶у��"
+              :max="
+                formData.inspectionResult.minDia !== null &&
+                formData.inspectionResult.minDia !== undefined
+                  ? undefined
+                  : 999999
+              "
+            />
+          </wd-cell>
+          <wd-cell title="鏈�灏忓��" label-width="120px">
+            <wd-input-number
+              v-model="formData.inspectionResult.minDia"
+              :min="0"
+              :precision="3"
+              :step="0.01"
+              placeholder="璇疯緭鍏ユ渶灏忓��"
+              :max="
+                formData.inspectionResult.maxDia !== null &&
+                formData.inspectionResult.maxDia !== undefined
+                  ? formData.inspectionResult.maxDia
+                  : 999999
+              "
+            />
+          </wd-cell>
+        </wd-cell-group>
+
+        <!-- 澶栬 -->
+        <view class="section-title">澶栬</view>
+        <wd-cell-group border>
+          <wd-cell title="澶栬璐ㄩ噺" label-width="120px">
+            <view class="checkbox-group">
+              <wd-checkbox
+                v-for="option in appearanceOptions"
+                :key="option.value"
+                :modelValue="
+                  Array.isArray(formData.inspectionResult.appearance)
+                    ? formData.inspectionResult.appearance.includes(String(option.value))
+                    : false
+                "
+                shape="square"
+                @change="(val) => handleAppearanceChange(String(option.value), val)"
+              >
+                {{ option.label }}
+              </wd-checkbox>
+            </view>
+          </wd-cell>
+        </wd-cell-group>
+
+        <!-- 鎴愮洏璐ㄩ噺 -->
+        <view class="section-title">鎴愮洏璐ㄩ噺</view>
+        <wd-cell-group border>
+          <wd-cell title="鍗风粫绱у瘑" label-width="120px">
+            <wd-radio-group v-model="formData.inspectionResult.windingTightness" size="small">
+              <wd-radio value="鏄�">鏄�</wd-radio>
+              <wd-radio value="鍚�">鍚�</wd-radio>
+            </wd-radio-group>
+          </wd-cell>
+          <wd-cell title="鎺掑垪鏁撮綈" label-width="120px">
+            <wd-radio-group v-model="formData.inspectionResult.arrangementNeatness" size="small">
+              <wd-radio value="鏄�">鏄�</wd-radio>
+              <wd-radio value="鍚�">鍚�</wd-radio>
+            </wd-radio-group>
+          </wd-cell>
+          <wd-cell title="澶栧眰閾濈嚎绂讳晶鏉胯竟缂樿窛绂�(mm)" label-width="200px">
+            <wd-input-number
+              v-model="formData.inspectionResult.aluminumWireDistance"
+              :min="0"
+              :precision="0"
+              placeholder="璇疯緭鍏ヨ窛绂�"
+              :class="{ 'text-danger': formData.inspectionResult.aluminumWireDistance < 25 }"
+            />
+          </wd-cell>
+        </wd-cell-group>
+
+        <!-- 鍏朵粬淇℃伅 -->
+        <view class="section-title">鍏朵粬淇℃伅</view>
+        <wd-cell-group border>
+          <wd-cell title="鎴愬搧妯″悗鎺ュご鎯呭喌" label-width="120px">
+            <wd-radio-group v-model="formData.inspectionResult.jointCondition" size="small">
+              <wd-radio value="鏈�">鏈�</wd-radio>
+              <wd-radio value="鏃�">鏃�</wd-radio>
+            </wd-radio-group>
+          </wd-cell>
+          <wd-cell title="缁撹" label-width="120px">
+            <wd-radio-group v-model="formData.inspectionResult.conclusion" size="small">
+              <wd-radio value="鍚堟牸">鍚堟牸</wd-radio>
+              <wd-radio value="涓嶅悎鏍�">涓嶅悎鏍�</wd-radio>
+            </wd-radio-group>
+          </wd-cell>
+        </wd-cell-group>
+      </wd-form>
+    </view>
+    <view class="dialog-footer">
+      <wd-button plain @click="handleClose" style="margin-right: 10px">鍙栨秷</wd-button>
+      <wd-button type="primary" class="ml-2" @click="handleSubmit">淇濆瓨</wd-button>
+    </view>
+  </view>
 </template>
 
 <script setup lang="ts">
-import useFormData from "@/hooks/useFormData";
-const { form: model } = useFormData({
-  selfInspectName: undefined, // 鑷鍚嶇О
-  unit: undefined, // 鍗曚綅
-  standard: undefined, // 鏍囧噯鍊�
-  selfInspectValue: undefined, // 鑷鍊�
-  selfInspectResult: undefined, // 鑷鍊�
-});
+import { ref, watch, computed } from "vue";
+import { dayjs } from "wot-design-uni";
+
+const props = defineProps<{
+  visible: boolean;
+  formData: any;
+  appearanceOptions: Array<{ label: string; value: string | number }>;
+  previousAppearanceValue?: string[];
+}>();
+
+const emit = defineEmits<{
+  (e: "update:visible", value: boolean): void;
+  (e: "submit", data: any): void;
+  (e: "close"): void;
+}>();
+
+const formRef = ref();
+const isEdit = computed(() => !!props.formData?.id && !props.formData?.isNew);
+
+// 瀛樺偍鍓嶄竴涓瑙傝川閲忓��
+const previousAppearanceValue = ref<string[]>(props.previousAppearanceValue || []);
+
+// 澶勭悊澶栬璐ㄩ噺浜掓枼閫昏緫
+const handleAppearanceQualityChange = (
+  selectedValues: string[],
+  previousValues: string[],
+  allOptions: Array<{ label: string; value: string | number }>
+): string[] => {
+  if (!allOptions || allOptions.length === 0) {
+    return selectedValues;
+  }
+
+  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 isSelectingOtherWithNoIssue =
+    hadNoIssue && hasNoIssue && selectedValues.length > previousValues.length;
+
+  let result: string[];
+  if (isNewlySelectedNoIssue) {
+    result = [noIssueValue];
+  } else if (isSelectingOtherWithNoIssue) {
+    result = selectedValues.filter((val) => val !== noIssueValue);
+  } else {
+    result = selectedValues;
+  }
+
+  return result;
+};
+
+// 澶勭悊澶栬閫夋嫨鍙樺寲
+const handleAppearanceChange = (optionValue: string, checked: boolean) => {
+  const currentValues = Array.isArray(props.formData.inspectionResult.appearance)
+    ? props.formData.inspectionResult.appearance
+    : [];
+
+  let newValues: string[];
+  if (checked) {
+    newValues = [...currentValues, optionValue];
+  } else {
+    newValues = currentValues.filter((v: string) => v !== optionValue);
+  }
+
+  const processedValues = handleAppearanceQualityChange(
+    newValues,
+    previousAppearanceValue.value,
+    props.appearanceOptions
+  );
+
+  props.formData.inspectionResult.appearance = JSON.parse(JSON.stringify(processedValues));
+  previousAppearanceValue.value = JSON.parse(JSON.stringify(processedValues));
+};
+
+const handleClose = () => {
+  emit("update:visible", false);
+  emit("close");
+};
+
+const handleSubmit = () => {
+  // 楠岃瘉鍗曚笣鐩村緞锛氭渶澶у�煎簲璇ュぇ浜庢垨绛変簬鏈�灏忓��
+  const maxDia = props.formData.inspectionResult.maxDia;
+  const minDia = props.formData.inspectionResult.minDia;
+
+  if (maxDia !== null && minDia !== null && maxDia < minDia) {
+    uni.showToast({
+      title: "鍗曚笣鐩村緞鏈�澶у�间笉鑳藉皬浜庢渶灏忓��",
+      icon: "none",
+    });
+    return;
+  }
+
+  // 楠岃瘉澶栧眰閾濈嚎绂讳晶鏉胯竟缂樿窛绂�
+  const aluminumWireDistance = props.formData.inspectionResult.aluminumWireDistance;
+  if (aluminumWireDistance < 25) {
+    uni.showToast({
+      title: "澶栧眰閾濈嚎绂讳晶鏉胯竟缂樿窛绂讳笉鑳戒綆浜�25mm",
+      icon: "none",
+    });
+    return;
+  }
+
+  emit("submit", props.formData);
+};
+
+// 鐩戝惉 visible 鍙樺寲锛屽垵濮嬪寲 previousAppearanceValue
+watch(
+  () => props.visible,
+  (newVal) => {
+    if (newVal && props.formData?.inspectionResult?.appearance) {
+      previousAppearanceValue.value = JSON.parse(
+        JSON.stringify(props.formData.inspectionResult.appearance || [])
+      );
+    }
+  }
+);
 </script>
+
 <style lang="scss" scoped>
-.form_box {
+.form-container {
+  max-height: 80vh;
+  display: flex;
+  flex-direction: column;
+  background: #fff;
+  border-radius: 12px 12px 0 0;
 }
-.submit_btn {
-  position: absolute;
-  bottom: 0;
-  width: 100%;
+
+.dialog-header {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding: 16px;
+  border-bottom: 1px solid #e6e6e6;
+  position: sticky;
+  top: 0;
+  background: #fff;
+  z-index: 10;
+}
+
+.dialog-title {
+  font-size: 16px;
+  color: #333;
+  font-weight: 500;
+}
+
+.close-icon {
+  font-size: 20px;
+  color: #999;
+  padding: 4px;
+}
+
+.dialog-content {
+  flex: 1;
+  overflow-y: auto;
+  padding: 16px;
+}
+
+.section-title {
+  font-size: 14px;
+  font-weight: 700;
+  color: #252525;
+  margin: 16px 0 8px 0;
+  padding-bottom: 8px;
+  border-bottom: 1px solid #e6e6e6;
+}
+
+.checkbox-group {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 12px;
+}
+
+:deep(.wd-checkbox) {
+  margin-right: 0;
+}
+
+.dialog-footer {
+  display: flex;
+  justify-content: flex-end;
+  padding: 16px;
+  border-top: 1px solid #e6e6e6;
+  gap: 8px;
+}
+
+.text-danger {
+  :deep(.wd-input-number__input) {
+    color: #f56c6c;
+    border-color: #f56c6c;
+  }
 }
 </style>

--
Gitblit v1.9.3