From 87edc55a377c3fca459ab48010a9716b0311c4a8 Mon Sep 17 00:00:00 2001
From: Your Name <123456>
Date: 星期一, 15 八月 2022 09:21:54 +0800
Subject: [PATCH] lct

---
 src/views/contingencyManagement/contingency/component/openAdd.vue |   48 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/src/views/contingencyManagement/contingency/component/openAdd.vue b/src/views/contingencyManagement/contingency/component/openAdd.vue
index d5495f2..a36d5c7 100644
--- a/src/views/contingencyManagement/contingency/component/openAdd.vue
+++ b/src/views/contingencyManagement/contingency/component/openAdd.vue
@@ -52,17 +52,8 @@
                     </el-col>
                     <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                         <el-form-item label="相关附件" prop="fileList">
-                            <el-upload
-                                    v-model:file-list="fileList"
-                                    class="upload-demo"
-                                    action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
-                                    :on-change="handleChange"
-                            >
-                                <el-button type="primary">点击上传</el-button>
-                                <template #tip>
-                                    <div class="el-upload__tip">添加相关附件</div>
-                                </template>
-                            </el-upload>
+                            <uploaderFile :fileList="fileList" :systemName="'EMERGENCY'" :disabled="disabled"
+                                          @successUploader="successUploader"></uploaderFile>
                         </el-form-item>
                     </el-col>
                 </el-row>
@@ -142,6 +133,7 @@
     import DailogSearchUserManger from "/@/components/DailogSearchUserManger/index.vue"
     import {contingencyApi} from "/@/api/contingencyManagement/contingency";
     import {goalManagementApi} from "/@/api/goalManagement";
+    import uploaderFile from '/@/components/uploaderFile/index.vue';
     // import {releaseDrillPlanApi} from "/@/api/releaseDrillPlan";
 
 
@@ -150,6 +142,7 @@
         components: {
             AddEmergencyPersonnel,
             DailogSearchUserManger,
+            uploaderFile
         },
         setup(prop, {emit}) {
             const isShowDialog = ref(false);
@@ -188,14 +181,34 @@
                         .then((res) => {
                             if (res.data.code == 200) {
                                 ruleForm.value = res.data.data;
+                                fileList.value = (res.data.data.fileList?res.data.data.fileList:[])
+                                initFileListData()
                                 listApi()
                             }
                         });
                 }
             }
             // 上传附件
-            const fileList = ref<UploadUserFile[]>([])
-
+            const fileList = ref([])
+            const initFileListData = async () => {
+                for(var a = 0;a<fileList.value.length;a++){
+                    fileList.value[a].name = fileList.value[a].fileName
+                }
+            }
+            // 上传成功组装数据
+            const successUploader = (list) =>{
+                fileList.value = list
+                const formFileList = []
+                for(var a = 0;a<fileList.value.length;a++){
+                    formFileList.push(
+                        {
+                            fileName:fileList.value[a].fileName,
+                            fileUrl:''
+                        }
+                    )
+                }
+                ruleForm.value.fileList = formFileList
+            }
             //定义树形下拉框
             const principalDepartmentId = ref()
             const data = ref()
@@ -313,6 +326,9 @@
                 }
             };
             const onSubmit = async (title: string, formEl: FormInstance | undefined) => {
+                if(!ruleForm.value.fileList){
+                    ruleForm.value.fileList = []
+                }
                 if (title == '新建应急队伍管理') {
                     if (!formEl) return;
                     await formEl.validate((valid, fields) => {
@@ -346,7 +362,6 @@
                     if (!formEl) return;
                     await formEl.validate((valid, fields) => {
                         if (valid) {
-                          ruleForm.value.fileList=[]
                             isShowDialog.value = false;
                             contingencyApi()
                                 .editEmergencyTeam(ruleForm.value)
@@ -390,6 +405,7 @@
                 isShowDialog.value = false;
                 if (!formEl) return;
                 formEl.resetFields();
+                fileList.value = []
                 tableData.value=[]
                 ruleForm.value = {}
             };
@@ -494,7 +510,9 @@
                 department,
                 peopleInsertBtn,
                 teamId,
-                newTreeList
+                newTreeList,
+                successUploader,
+                initFileListData
             };
         },
     });

--
Gitblit v1.9.2