From 2475c65a3c091cee4fe48f49e0f53697403750df Mon Sep 17 00:00:00 2001
From: Your Name <123456>
Date: 星期三, 17 八月 2022 19:55:34 +0800
Subject: [PATCH] 冲突

---
 src/views/contingencyManagement/contingency/component/openAdd.vue |  112 +++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 71 insertions(+), 41 deletions(-)

diff --git a/src/views/contingencyManagement/contingency/component/openAdd.vue b/src/views/contingencyManagement/contingency/component/openAdd.vue
index e853358..a36d5c7 100644
--- a/src/views/contingencyManagement/contingency/component/openAdd.vue
+++ b/src/views/contingencyManagement/contingency/component/openAdd.vue
@@ -30,7 +30,7 @@
                     </el-col>
                     <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                         <el-form-item label="负责人部门" prop="principalDepartmentId">
-                            <el-tree-select v-model="ruleForm.principalDepartmentId" :data="data" class="w100"
+                            <el-tree-select v-model="ruleForm.principalDepartmentId" :data="newTreeList" class="w100"
                                             :props="propse" clearable placeholder="请选择"/>
                         </el-form-item>
                     </el-col>
@@ -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,37 +181,81 @@
                         .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()
 
-            //部门树
-            const department = () => {
-                goalManagementApi()
+
+
+            //el-tree-select回显
+            const propse = {
+                label: 'depName',
+                children: 'children',
+            };
+            const newTreeList = [];
+            //得到部门树
+            const department = async () => {
+                await goalManagementApi()
                     .getTreedepartment()
                     .then((res) => {
                         if (res.data.code == 200) {
                             data.value = res.data.data;
+                            getTreeList(res.data.data, newTreeList);
                         } else {
                             ElMessage.error(res.data.msg);
                         }
                     });
             };
-            //定义树形下拉框
-            const principalDepartmentId = ref()
-            const propse = {
-                label: 'depName',
-                children: 'children',
-                value: 'depId',
+            // 递归树状数据且修改字段名
+            const getTreeList = (treeList, newTreeList) => {
+                treeList.map((c) => {
+                    let tempData = {
+                        depName: c.depName,
+                        value: c.depId,
+                        children: [],
+                    };
+                    if (c.children && c.children.length > 0) {
+                        tempData.children = [];
+                        getTreeList(c.children, tempData.children);
+                    }
+                    newTreeList.push(tempData);
+                });
             };
-            const data = ref()
             onMounted(() => {
                 department();
             });
+
+
+
+
             // 打开用户选择弹窗
             const userRef = ref();
             const openUser = () => {
@@ -294,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) => {
@@ -361,12 +396,7 @@
                         principalPhone: '', // 负责人手机
                         telephoneNumber: '', // 固定电话
                         teamDesc: '',  //队伍描述
-                        fileList: [
-                            {
-                                fileUrl: 'url',
-                                fileName: 'name',
-                            }
-                        ],
+                        fileList: [],
                         memberList: []
                     };
                 }
@@ -375,7 +405,9 @@
                 isShowDialog.value = false;
                 if (!formEl) return;
                 formEl.resetFields();
+                fileList.value = []
                 tableData.value=[]
+                ruleForm.value = {}
             };
             // 定义表格数据
             const tableData = ref([]);
@@ -392,7 +424,6 @@
                 }else {
                     addRef.value.openDialog('新建应急队伍人员','',teamId.value);
                 }
-
             };
             // 请求列表数据
             const listApi = async () => {
@@ -406,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) => {
@@ -482,7 +509,10 @@
                 onRowDel,
                 department,
                 peopleInsertBtn,
-                teamId
+                teamId,
+                newTreeList,
+                successUploader,
+                initFileListData
             };
         },
     });

--
Gitblit v1.9.2