From dd9171eef52864b6d025ef9cc2b5770f5d40ce15 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期六, 11 十月 2025 15:33:48 +0800
Subject: [PATCH] 生产管控-生产报表与绩效分析、库存与物料看板、智能排产三个前端页面开发
---
src/views/archiveManagement/mould/archiveDialog.vue | 116 ++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 73 insertions(+), 43 deletions(-)
diff --git a/src/views/archiveManagement/mould/archiveDialog.vue b/src/views/archiveManagement/mould/archiveDialog.vue
index 521ae1a..d60cd84 100644
--- a/src/views/archiveManagement/mould/archiveDialog.vue
+++ b/src/views/archiveManagement/mould/archiveDialog.vue
@@ -1,28 +1,28 @@
<template>
<el-dialog v-model="centerDialogVisible" title="鏂囨。绠$悊" width="500" center>
<el-form
- ref="ruleFormRef"
- style="max-width: 600px"
- :model="ruleForm"
- :rules="rules"
- label-width="auto"
+ ref="ruleFormRef"
+ style="max-width: 600px"
+ :model="ruleForm"
+ :rules="rules"
+ label-width="auto"
>
<el-form-item label="鍚嶇О" prop="name">
- <el-input v-model="ruleForm.name" placeholder="璇疯緭鍏ユ枃妗e悕绉�" />
+ <el-input v-model="ruleForm.name" placeholder="璇疯緭鍏ユ枃妗e悕绉�"/>
</el-form-item>
<el-form-item label="璇疯緭鍏ユ枃妗g被鍨�" prop="type">
<el-select v-model="ruleForm.type" placeholder="璇疯緭鍏ユ枃妗g被鍨�">
- <el-option label="鍚堝悓" value="鍚堝悓" />
- <el-option label="鎶ュ憡" value="鎶ュ憡" />
+ <el-option label="鍚堝悓" value="鍚堝悓"/>
+ <el-option label="鎶ュ憡" value="鎶ュ憡"/>
</el-select>
</el-form-item>
<el-form-item label="璇疯緭鍏ユ枃妗g姸鎬�" prop="status">
<el-select v-model="ruleForm.status" placeholder="璇疯緭鍏ユ枃妗g姸鎬�">
<el-option
- v-for="option in options"
- :key="option.value"
- :label="option.label"
- :value="option.value"
+ v-for="option in options"
+ :key="option.value"
+ :label="option.label"
+ :value="option.value"
/>
</el-select>
</el-form-item>
@@ -31,23 +31,26 @@
<el-row>
<el-col :span="24" style="text-align: right">
<el-button @click="centerDialogVisible = false">鍙� 娑�</el-button>
- <el-button type="primary" @click="submit"> 纭� 瀹� </el-button>
+ <el-button type="primary" @click="submit"> 纭� 瀹�</el-button>
</el-col>
</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>
<script setup>
-import { ref, watch } from "vue";
-import { addOrEditArchive } from "@/api/archiveManagement";
+import {ref, watch, nextTick} 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,
@@ -65,6 +68,7 @@
};
// 鍒濆鍖栬〃鍗曟暟鎹殑杈呭姪鍑芥暟
const initFormData = (rowData) => {
+ console.log("rowData", rowData);
if (rowData && rowData.id) {
return copyFormData(rowData);
}
@@ -72,6 +76,7 @@
name: "",
type: "",
status: "",
+ storageBlobDTO: [], // 纭繚 storageBlobDTO 鏄竴涓暟缁�
};
};
@@ -81,25 +86,45 @@
const copyForm = ref();
// 鐩戝惉 row 鐨勫彉鍖栵紝鏇存柊 ruleForm
watch(
- () => props.row,
- (newRow) => {
- copyForm.value = initFormData(newRow);
- ruleForm.value = JSON.parse(JSON.stringify(copyForm.value));
- },
- { deep: true }
+ () => props.row,
+ (newRow) => {
+ copyForm.value = initFormData(newRow);
+ ruleForm.value = JSON.parse(JSON.stringify(copyForm.value));
+ },
+ {deep: true}
);
const rules = {
- name: [{ required: true, message: "璇疯緭鍏ユ枃妗e悕绉�", trigger: "blur" }],
- type: [{ required: true, message: "璇烽�夋嫨鏂囨。绫诲瀷", trigger: "blur" }],
- status: [{ required: true, message: "璇烽�夋嫨鏂囨。鐘舵��", trigger: "blur" }],
+ name: [{required: true, message: "璇疯緭鍏ユ枃妗e悕绉�", trigger: "blur"}],
+ type: [{required: true, message: "璇烽�夋嫨鏂囨。绫诲瀷", trigger: "blur"}],
+ status: [{required: true, message: "璇烽�夋嫨鏂囨。鐘舵��", trigger: "blur"}],
};
-
+const initTreeDataId = ref(null);
+const fileUploadRef = ref(null);
+const initForm = (val) => {
+ initTreeDataId.value = val.id || null; // 纭繚 initTreeDataId 鍒濆鍖栦负 null
+ ruleForm.value = {};
+ ruleForm.value.treeId = val.id || null; // 纭繚 treeId 鍒濆鍖栦负 null
+ nextTick(() => {
+ 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: "浣滃簾" },
+ {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 +134,24 @@
if (!valid) {
return;
}
-
+ ruleForm.value.storageBlobDTO = modelValue.value; // 纭繚 ruleForm 鏄渶鏂扮殑
// 璋冪敤 API
- let res = await addOrEditArchive(ruleForm.value);
- console.log("API 鍝嶅簲:", res);
-
- // 鍙戦�� emit 浜嬩欢
- emit("submitForm", res);
- console.log("emit submitForm 宸插彂閫�");
-
- // 鍏抽棴瀵硅瘽妗�
+ try {
+ const res = await addOrEditArchive(ruleForm.value);
+ emit("submitForm", res);
+ } catch (error) {
+ ElMessage({
+ type: "error",
+ message: error.msg || "鎿嶄綔澶辫触",
+ });
+ return;
+ }
centerDialogVisible.value = false;
} catch (error) {
- console.error("琛ㄥ崟楠岃瘉澶辫触鎴朅PI璋冪敤澶辫触:", error);
+ ElMessage({
+ type: "error",
+ message: error.msg || "鎿嶄綔澶辫触",
+ });
}
};
</script>
--
Gitblit v1.9.3