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/panManagement/component/openAdd.vue | 163 +++++++++++++++++++++++++++++++++--------------------- 1 files changed, 99 insertions(+), 64 deletions(-) diff --git a/src/views/contingencyManagement/panManagement/component/openAdd.vue b/src/views/contingencyManagement/panManagement/component/openAdd.vue index 02c44c0..6a6bd50 100644 --- a/src/views/contingencyManagement/panManagement/component/openAdd.vue +++ b/src/views/contingencyManagement/panManagement/component/openAdd.vue @@ -1,6 +1,14 @@ <template> <div class="system-edit-user-container"> - <el-dialog :title="titles" v-model="isShowDialog" width="50%" draggable :fullscreen="full" :close-on-click-modal="false"> + <el-dialog + :title="titles" + v-model="isShowDialog" + width="50%" + draggable + :fullscreen="full" + :close-on-click-modal="false" + @close="resetForm(ruleFormRef)" + > <el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button> <el-form ref="ruleFormRef" :model="ruleForm" size="default" label-width="120px" :disabled="disabled"> <el-row :gutter="35"> @@ -12,16 +20,17 @@ <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> <el-form-item label="适用部门" prop="responsibleDepartment"> <el-tree-select - v-model="ruleForm.responsibleDepartment" - :data="data" + v-model="responsibleDepartment" + :data="newTreeList" + class="w100" + clearable + :props="propse" multiple :render-after-expand="false" - :props="propse" - clearable - show-checkbox - check-strictly - check-on-click-node - placeholder="请选择" + check-strictly + check-on-click-node + placeholder="请选择" + @change="changeDepartment" /> <el-divider /> </el-form-item> @@ -66,8 +75,7 @@ <el-form-item label="编写部门" prop="authorDeptId"> <el-tree-select v-model="ruleForm.authorDeptId" - check-strictly - :data="data" + :data="newTreeList" class="w100" :props="propse" clearable @@ -89,7 +97,7 @@ </el-col> <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> <el-form-item label="应急队伍" prop="emergencyTeam"> - <el-input v-model="ruleForm.emergencyTeam" placeholder="请选择" class="input-with-select"> + <el-input v-model="ruleForm.teamName" placeholder="请选择" class="input-with-select"> <template #append> <el-button :icon="Search" @click="daiInpt(0)" /> </template> @@ -133,7 +141,7 @@ </span> </template> </el-dialog> - <CheckTemplate ref="Shows" @SearchUser="SearchUser" /> + <CheckTemplate ref="Shows" @SearchUser="SearchUser" /> <DailogSearchUserManger ref="userRef" @SearchUser="onUser" /> <RegionsDialog ref="openRef" /> </div> @@ -170,17 +178,11 @@ authorName: '', authorDeptId: '', // 编写部门 releaseDate: '', // 发布实施日期 - fileList: [ - // { - // fileUrl: 'url', - // fileName: 'name', - // }, - ], - emergencyTeam: '', //应急队伍 + fileList: [], areaList: [], //区域列表 teamList: [], + // teamId: '', //应急队伍 deptList: [], - abolishStatus: false, }); const titles = ref(); const disabled = ref(); @@ -195,12 +197,21 @@ .seeEmergencyTeam(id) .then((res) => { if (res.data.code == 200) { - ruleForm.value = res.data.data; - let arr = []; - for (let i = 0; i < ruleForm.value.teamList.length; i++) { - arr.push(ruleForm.value.teamList[i].emergencyTeam); - } - ruleForm.value.emergencyTeam = arr.toString(); + ruleForm.value = res.data.data; + ruleForm.value.teamName = '' + responsibleDepartment.value = [] + if(res.data.data.teamList){ + for(var a = 0;a<res.data.data.teamList.length;a++){ + ruleForm.value.teamName+=res.data.data.teamList[a].teamName+';' + } + } + if(res.data.data.deptList){ + for(var a = 0;a<res.data.data.deptList.length;a++){ + + responsibleDepartment.value.push(res.data.data.deptList[a].departmentId) + } + } + } }); } @@ -209,30 +220,55 @@ const releaseDate = ref(''); // 上传附件 const fileList = ref<UploadUserFile[]>([]); - //部门树 - 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; + data.value = res.data.data; + getTreeList(res.data.data, newTreeList); } else { ElMessage.error(res.data.msg); } }); }; - const treeSelect = ref(); - // const trees = 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); + }); }; onMounted(() => { department(); }); + const changeDepartment = (e) => { + var temList = []; + for (var a = 0; a < e.length; a++) { + temList.push({ + departmentId: e[a], + }); + } + ruleForm.value.deptList = temList; + console.log(ruleForm); + }; //定义树形下拉框 - const responsibleDepartment = ref(); + const responsibleDepartment = ref([]); const data = ref(); const submitForm = async (title: string, formEl: FormInstance | undefined) => { @@ -241,6 +277,7 @@ await formEl.validate((valid, fields) => { if (valid) { isShowDialog.value = false; + delete ruleForm.value.teamName emergencyPlanApi() .addEmergencyPlan(ruleForm.value) .then((res) => { @@ -269,8 +306,10 @@ if (!formEl) return; await formEl.validate((valid, fields) => { if (valid) { - isShowDialog.value = false; - emergencyPlanApi() + ruleForm.value.fileList=[] + isShowDialog.value = false; + delete ruleForm.value.teamName + emergencyPlanApi() .editEmergencyTeam(ruleForm.value) .then((res) => { if (res.data.code == 200) { @@ -304,18 +343,11 @@ authorName: '', authorDeptId: '', // 编写部门 releaseDate: '', // 发布实施日期 - fileList: [ - // { - // fileUrl: 'url', - // fileName: 'name', - // }, - ], - emergencyTeam: '', //应急队伍 + fileList: [], + // teamId: '', //应急队伍ID areaList: [], //区域列表 - teamList: [ - ], + teamList: [], deptList: [], - abolishStatus: false, }; } }; @@ -323,23 +355,24 @@ isShowDialog.value = false; if (!formEl) return; formEl.resetFields(); + ruleForm.value = {}; }; // 应急队伍弹窗 const Shows = ref(); const daiInpt = (data: any) => { - Shows.value.openDailog(data); + Shows.value.openDailog(data); }; - const SearchUser = (val: any) => { - let arr = []; - for (let i = 0; i < val.length; i++) { - arr.push(val[i].teamName); - ruleForm.value.teamList.push({ - userUid: val[i].uid, - emergencyTeam: val[i].teamName, - }); - } - ruleForm.value.emergencyTeam = arr.toString(); - }; + const SearchUser = (val: any) => { + let arr = []; + ruleForm.value.teamList = []; + for (let i = 0; i < val.length; i++) { + arr.push(val[i].teamName); + ruleForm.value.teamList.push({ + teamId: val[i].id, + }); + } + ruleForm.value.teamName = arr.toString(); + }; // 选择区域弹窗 const openRef = ref(); const regionsDialog = () => { @@ -371,13 +404,13 @@ data, Search, releaseDate, - treeSelect, + // treeSelect, // trees, propse, department, daiInpt, Shows, - SearchUser, + SearchUser, submitForm, openUser, userRef, @@ -394,6 +427,8 @@ ruleForm, resetForm, onUser, + newTreeList, + changeDepartment, }; }, }); -- Gitblit v1.9.2