From b6d44a48904223b973d494bcb072b9a509b2fc91 Mon Sep 17 00:00:00 2001 From: shizhongming Date: Sun, 3 Mar 2024 15:02:41 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E7=B3=BB=E7=BB=9F=E6=A8=A1=E5=9D=97-?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E7=AE=A1=E7=90=86):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97=E6=80=A7?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/SysDept/SysDeptTree.vue | 10 +- .../views/dept/SysDeptTreeList.vue | 4 +- .../views/dept/components/SysDeptEdit.vue | 34 +-- .../views/dept/components/SysDeptTree.vue | 233 ------------------ 4 files changed, 29 insertions(+), 252 deletions(-) delete mode 100644 src/modules/smart-system/views/dept/components/SysDeptTree.vue diff --git a/src/modules/smart-system/components/SysDept/SysDeptTree.vue b/src/modules/smart-system/components/SysDept/SysDeptTree.vue index c6017fc89..6bceb28b9 100644 --- a/src/modules/smart-system/components/SysDept/SysDeptTree.vue +++ b/src/modules/smart-system/components/SysDept/SysDeptTree.vue @@ -97,9 +97,17 @@ if (async) { return unref(dataList); } + const convertDataList = unref(dataList).map(({ deptId, deptName, deptCode, parentId }) => { + return { + deptId, + deptName, + deptCode, + parentId, + }; + }); return ( TreeUtils.convertList2Tree( - dataList.value, + convertDataList, (item) => item.deptId, (item) => item.parentId, 0, diff --git a/src/modules/smart-system/views/dept/SysDeptTreeList.vue b/src/modules/smart-system/views/dept/SysDeptTreeList.vue index 30805a970..aff49f5df 100644 --- a/src/modules/smart-system/views/dept/SysDeptTreeList.vue +++ b/src/modules/smart-system/views/dept/SysDeptTreeList.vue @@ -33,7 +33,7 @@ {{ $t('common.button.delete') }} - +
@@ -67,7 +67,7 @@ import { useModal } from '@/components/Modal'; import { errorMessage, successMessage } from '@/utils/message/SystemNotice'; - import SysDeptTree from './components/SysDeptTree.vue'; + import SysDeptTree from '../../components/SysDept/SysDeptTree.vue'; import SysDeptEdit from './components/SysDeptEdit.vue'; import SysDeptEditModal from './components/SysDeptEditModal.vue'; import { deleteApi, saveUpdateBatchApi } from './SysDept.api'; diff --git a/src/modules/smart-system/views/dept/components/SysDeptEdit.vue b/src/modules/smart-system/views/dept/components/SysDeptEdit.vue index 4d18519f5..0e9c53497 100644 --- a/src/modules/smart-system/views/dept/components/SysDeptEdit.vue +++ b/src/modules/smart-system/views/dept/components/SysDeptEdit.vue @@ -8,7 +8,7 @@ import type { FormSchema } from '@/components/Form'; import { Spin } from 'ant-design-vue'; - import { ref, watch } from 'vue'; + import { nextTick, ref, watch } from 'vue'; import { useForm, BasicForm } from '@/components/Form'; import { propTypes } from '@/utils/propTypes'; import { useI18n } from '@/hooks/web/useI18n'; @@ -28,23 +28,25 @@ watch( () => props.deptId, - async (value) => { - if (!value) { - await resetFields(); - } else { - try { - getLoading.value = true; - const deptData = await getByIdApi(value); - if (deptData.parentDept) { - deptData.parentName = deptData.parentDept.deptName; - } else { - deptData.parentName = '根'; + (value) => { + nextTick(async () => { + if (!value) { + resetFields(); + } else { + try { + getLoading.value = true; + const deptData = await getByIdApi(value); + if (deptData.parentDept) { + deptData.parentName = deptData.parentDept.deptName; + } else { + deptData.parentName = '根'; + } + setFieldsValue(deptData); + } finally { + getLoading.value = false; } - await setFieldsValue(deptData); - } finally { - getLoading.value = false; } - } + }); }, ); diff --git a/src/modules/smart-system/views/dept/components/SysDeptTree.vue b/src/modules/smart-system/views/dept/components/SysDeptTree.vue deleted file mode 100644 index 5d7bafde2..000000000 --- a/src/modules/smart-system/views/dept/components/SysDeptTree.vue +++ /dev/null @@ -1,233 +0,0 @@ - - - - -