From c7afec3ad75b22bc8b96d8129956913c2b473d9b Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期四, 19 六月 2025 16:11:36 +0800
Subject: [PATCH] 优化生产管理接口及表格字段

---
 src/views/archiveManagement/mould/archiveDialog.vue |   57 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 44 insertions(+), 13 deletions(-)

diff --git a/src/views/archiveManagement/mould/archiveDialog.vue b/src/views/archiveManagement/mould/archiveDialog.vue
index 521ae1a..793d222 100644
--- a/src/views/archiveManagement/mould/archiveDialog.vue
+++ b/src/views/archiveManagement/mould/archiveDialog.vue
@@ -36,10 +36,12 @@
       </el-row>
     </template>
     <fileUpload
-    v-model="ruleForm.file"
-    :fileSize="1024"
-    :fileType="['pdf', 'docx', 'txt', 'xlsx', 'pptx....']"
-    :limit="10"
+      ref="fileUploadRef"
+      :fileSize="1024"
+      :fileType="['pdf', 'docx', 'txt', 'xlsx', 'pptx....']"
+      :limit="10"
+      :drag="false"
+      v-model:modelValue="modelValue"
     />
   </el-dialog>
 </template>
@@ -48,6 +50,7 @@
 import { ref, watch } from "vue";
 import { addOrEditArchive } from "@/api/archiveManagement";
 import fileUpload from "@/components/FileUpload/index.vue";
+import { ElMessage } from "element-plus";
 
 const centerDialogVisible = defineModel("centerDialogVisible", {
   type: Boolean,
@@ -72,6 +75,7 @@
     name: "",
     type: "",
     status: "",
+    storageBlobDTO: [], // 纭繚 storageBlobDTO 鏄竴涓暟缁�
   };
 };
 
@@ -93,13 +97,28 @@
   type: [{ required: true, message: "璇烽�夋嫨鏂囨。绫诲瀷", trigger: "blur" }],
   status: [{ required: true, message: "璇烽�夋嫨鏂囨。鐘舵��", trigger: "blur" }],
 };
-
+const fileUploadRef = ref(null);
+const initForm = () => {
+  ruleForm.value = {};
+  fileUploadRef.value.init();
+};
+const editForm = (val) => {
+  ruleForm.value = copyForm.value;
+  nextTick(() => {
+    fileUploadRef.value.editInit(val);
+  });
+};
+defineExpose({
+  initForm,
+  editForm,
+});
 const options = [
   { value: "鏈夋晥", label: "鏈夋晥" },
   { value: "鏃犳晥", label: "鏃犳晥" },
   { value: "浣滃簾", label: "浣滃簾" },
 ];
-const emit = defineEmits(["submitForm"]);
+const emit = defineEmits(["submitForm", "update:modelValue"]);
+const modelValue = ref([]);
 const submit = async () => {
   // 楠岃瘉琛ㄥ崟
   if (!ruleFormRef.value) return;
@@ -109,19 +128,31 @@
     if (!valid) {
       return;
     }
-
+    ruleForm.value.storageBlobDTO = modelValue.value; // 纭繚 ruleForm 鏄渶鏂扮殑
     // 璋冪敤 API
-    let res = await addOrEditArchive(ruleForm.value);
-    console.log("API 鍝嶅簲:", res);
-
+    try {
+      const res = await addOrEditArchive(ruleForm.value);
+      ElMessage({
+        type: "success",
+        message: res.msg || "鎿嶄綔鎴愬姛",
+      });
+      emit("submitForm", res);
+    } catch (error) {
+      ElMessage({
+        type: "error",
+        message: error.msg || "鎿嶄綔澶辫触",
+      });
+      return;
+    }
     // 鍙戦�� emit 浜嬩欢
-    emit("submitForm", res);
-    console.log("emit submitForm 宸插彂閫�");
 
     // 鍏抽棴瀵硅瘽妗�
     centerDialogVisible.value = false;
   } catch (error) {
-    console.error("琛ㄥ崟楠岃瘉澶辫触鎴朅PI璋冪敤澶辫触:", error);
+    ElMessage({
+      type: "error",
+      message: error.msg || "鎿嶄綔澶辫触",
+    });
   }
 };
 </script>

--
Gitblit v1.9.3