From 988558aaa309068fd393cc654be537434b0a15ea Mon Sep 17 00:00:00 2001
From: Your Name <123456>
Date: 星期四, 11 八月 2022 19:11:18 +0800
Subject: [PATCH] 修改

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

diff --git a/src/views/contingencyManagement/contingency/component/openAdd.vue b/src/views/contingencyManagement/contingency/component/openAdd.vue
index e853358..d5495f2 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>
@@ -163,12 +163,7 @@
                 principalPhone: '', // 负责人手机
                 telephoneNumber: '', // 固定电话
                 teamDesc: '',  //队伍描述
-                fileList: [
-                    {
-                        fileUrl: 'url',
-                        fileName: 'name',
-                    }
-                ],
+                fileList: [],
                 memberList: []
             });
             const titles = ref();
@@ -201,29 +196,53 @@
             // 上传附件
             const fileList = ref<UploadUserFile[]>([])
 
-            //部门树
-            const department = () => {
-                goalManagementApi()
+            //定义树形下拉框
+            const principalDepartmentId = ref()
+            const data = ref()
+
+
+
+            //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 = () => {
@@ -327,6 +346,7 @@
                     if (!formEl) return;
                     await formEl.validate((valid, fields) => {
                         if (valid) {
+                          ruleForm.value.fileList=[]
                             isShowDialog.value = false;
                             contingencyApi()
                                 .editEmergencyTeam(ruleForm.value)
@@ -361,12 +381,7 @@
                         principalPhone: '', // 负责人手机
                         telephoneNumber: '', // 固定电话
                         teamDesc: '',  //队伍描述
-                        fileList: [
-                            {
-                                fileUrl: 'url',
-                                fileName: 'name',
-                            }
-                        ],
+                        fileList: [],
                         memberList: []
                     };
                 }
@@ -376,6 +391,7 @@
                 if (!formEl) return;
                 formEl.resetFields();
                 tableData.value=[]
+                ruleForm.value = {}
             };
             // 定义表格数据
             const tableData = ref([]);
@@ -392,7 +408,6 @@
                 }else {
                     addRef.value.openDialog('新建应急队伍人员','',teamId.value);
                 }
-
             };
             // 请求列表数据
             const listApi = async () => {
@@ -406,10 +421,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 +493,8 @@
                 onRowDel,
                 department,
                 peopleInsertBtn,
-                teamId
+                teamId,
+                newTreeList
             };
         },
     });

--
Gitblit v1.9.2