From f7971a56c855718b42b71df907c46f409b0810bb Mon Sep 17 00:00:00 2001
From: zhaojiale <631455805@qq.com>
Date: 星期一, 15 八月 2022 13:58:03 +0800
Subject: [PATCH] 修改按钮修改

---
 src/views/contingencyManagement/contingency/component/openAdd.vue |   67 ++++++++++++++++++---------------
 1 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/src/views/contingencyManagement/contingency/component/openAdd.vue b/src/views/contingencyManagement/contingency/component/openAdd.vue
index cf1f71c..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);
@@ -163,12 +156,7 @@
                 principalPhone: '', // 负责人手机
                 telephoneNumber: '', // 固定电话
                 teamDesc: '',  //队伍描述
-                fileList: [
-                    {
-                        fileUrl: 'url',
-                        fileName: 'name',
-                    }
-                ],
+                fileList: [],
                 memberList: []
             });
             const titles = ref();
@@ -193,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()
@@ -318,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) => {
@@ -385,12 +396,7 @@
                         principalPhone: '', // 负责人手机
                         telephoneNumber: '', // 固定电话
                         teamDesc: '',  //队伍描述
-                        fileList: [
-                            {
-                                fileUrl: 'url',
-                                fileName: 'name',
-                            }
-                        ],
+                        fileList: [],
                         memberList: []
                     };
                 }
@@ -399,7 +405,9 @@
                 isShowDialog.value = false;
                 if (!formEl) return;
                 formEl.resetFields();
+                fileList.value = []
                 tableData.value=[]
+                ruleForm.value = {}
             };
             // 定义表格数据
             const tableData = ref([]);
@@ -416,7 +424,6 @@
                 }else {
                     addRef.value.openDialog('新建应急队伍人员','',teamId.value);
                 }
-
             };
             // 请求列表数据
             const listApi = async () => {
@@ -430,10 +437,6 @@
             // 新增后刷新
             const onMyAdd = (e: object) => {
                 listApi();
-                // console.log(e)
-                // item.value = e
-                // tableData.value.push(item.value)
-                // console.log(tableData)
             };
             // 打开修改弹窗
             const onEdit = (val: string, row: object) => {
@@ -507,7 +510,9 @@
                 department,
                 peopleInsertBtn,
                 teamId,
-                newTreeList
+                newTreeList,
+                successUploader,
+                initFileListData
             };
         },
     });

--
Gitblit v1.9.2