| | |
| | | </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> |
| | |
| | | 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, |
| | |
| | | name: "", |
| | | type: "", |
| | | status: "", |
| | | storageBlobDTO: [], // 确保 storageBlobDTO 是一个数组 |
| | | }; |
| | | }; |
| | | |
| | |
| | | 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; |
| | |
| | | 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("表单验证失败或API调用失败:", error); |
| | | ElMessage({ |
| | | type: "error", |
| | | message: error.msg || "操作失败", |
| | | }); |
| | | } |
| | | }; |
| | | </script> |