From ac3ad638949e4d560ddf69320a5f9bb28ca5aaca Mon Sep 17 00:00:00 2001 From: ahaos <8406649+lhailgl@user.noreply.gitee.com> Date: 星期三, 19 七月 2023 22:48:30 +0800 Subject: [PATCH] !29 修改列表打开对话框和接口请求顺序 Merge pull request !29 from ahaos/tspr --- src/views/system/dept/index.vue | 67 ++++++++++++++++----------------- 1 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index e833e71..12f7564 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -4,7 +4,7 @@ <div class="mb-[10px]" v-show="showSearch"> <el-card shadow="hover"> <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="68px"> - <el-form-item label="鑿滃崟鍚嶇О" prop="menuName"> + <el-form-item label="閮ㄩ棬鍚嶇О" prop="deptName"> <el-input v-model="queryParams.deptName" placeholder="璇疯緭鍏ラ儴闂ㄥ悕绉�" clearable @keyup.enter="handleQuery" /> </el-form-item> <el-form-item label="鐘舵��" prop="status"> @@ -219,23 +219,7 @@ queryFormRef.value?.resetFields(); handleQuery() } -/** 鏂板鎸夐挳鎿嶄綔 */ -const handleAdd = (row?: DeptVO) => { - listDept().then(res => { - const data = proxy?.handleTree<DeptOptionsType>(res.data, "deptId"); - if (data) { - deptOptions.value = data - dialog.visible = true; - dialog.title = "娣诲姞閮ㄩ棬"; - nextTick(() => { - reset(); - if (row && row.deptId) { - form.value.parentId = row?.deptId; - } - }) - } - }) -} + /** 灞曞紑/鎶樺彔鎿嶄綔 */ const handleToggleExpandAll = () => { isExpandAll.value = !isExpandAll.value; @@ -249,28 +233,41 @@ }) } +/** 鏂板鎸夐挳鎿嶄綔 */ +const handleAdd = async (row?: DeptVO) => { + reset(); + const res = await listDept(); + const data = proxy?.handleTree<DeptOptionsType>(res.data, "deptId"); + if (data) { + deptOptions.value = data + if (row && row.deptId) { + form.value.parentId = row?.deptId; + } + dialog.visible = true; + dialog.title = "娣诲姞閮ㄩ棬"; + } +} + /** 淇敼鎸夐挳鎿嶄綔 */ const handleUpdate = async (row: DeptVO) => { + reset(); const res = await getDept(row.deptId); + form.value = res.data + const response = await listDeptExcludeChild(row.deptId); + const data = proxy?.handleTree<DeptOptionsType>(response.data, "deptId") + if (data) { + deptOptions.value = data; + if (data.length === 0) { + const noResultsOptions: DeptOptionsType = { + deptId: res.data.parentId, + deptName: res.data.parentName, + children: [] + }; + deptOptions.value.push(noResultsOptions); + } + } dialog.visible = true; dialog.title = "淇敼閮ㄩ棬"; - await nextTick(async () => { - reset(); - form.value = res.data - const response = await listDeptExcludeChild(row.deptId); - const data = proxy?.handleTree<DeptOptionsType>(response.data, "deptId") - if (data) { - deptOptions.value = data; - if (data.length === 0) { - const noResultsOptions: DeptOptionsType = { - deptId: res.data.parentId, - deptName: res.data.parentName, - children: [] - }; - deptOptions.value.push(noResultsOptions); - } - } - }) } /** 鎻愪氦鎸夐挳 */ const submitForm = () => { -- Gitblit v1.9.3