From 88bc0b649b697968e52f80eec35f86b73ac0abda Mon Sep 17 00:00:00 2001 From: RubyLiu Date: Thu, 21 Sep 2023 18:57:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=94=A8=E6=88=B7=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms-user-group-comp/addUserModal.vue | 3 +- .../business/ms-user-selector/index.vue | 60 ++++++++++++------- .../userGroup/projectUserGroup.vue | 7 +-- .../project/components/addProjectModal.vue | 4 +- .../components/addOrganizationModal.vue | 4 +- .../components/addProjectModal.vue | 3 +- .../components/addUserModal.vue | 2 +- 7 files changed, 51 insertions(+), 32 deletions(-) diff --git a/frontend/src/components/business/ms-user-group-comp/addUserModal.vue b/frontend/src/components/business/ms-user-group-comp/addUserModal.vue index 05188e1031..cebb9541f3 100644 --- a/frontend/src/components/business/ms-user-group-comp/addUserModal.vue +++ b/frontend/src/components/business/ms-user-group-comp/addUserModal.vue @@ -2,7 +2,6 @@
- + {{ data.value.name }} - + {{ data.name }} @@ -62,25 +63,18 @@ }>(); const { t } = useI18n(); + const allOptions = ref([]); const currentOptions = ref([]); const currentLoadParams = ref>(props.loadOptionParams || {}); + const loading = ref(false); const currentValue = computed(() => { return currentOptions.value.filter((item) => props.value.includes(item.id)) || []; }); - const change = ( - value: string | number | boolean | Record | (string | number | boolean | Record)[] - ) => { - const tmpArr = Array.isArray(value) ? value : [value]; - const { valueKey } = props; - emit( - 'update:value', - tmpArr.map((item) => item[valueKey]) - ); - }; const loadList = async () => { try { + loading.value = true; const list = (await initOptionsFunc(props.type, currentLoadParams.value || {})) || []; const { firstLabelKey, secondLabelKey, disabledKey, valueKey } = props; list.forEach((item: MsUserSelectorOption) => { @@ -97,23 +91,49 @@ item.id = item[valueKey] as string; } }); - currentOptions.value = [...list]; + allOptions.value = [...list]; } catch (error) { // eslint-disable-next-line no-console console.log(error); - currentOptions.value = []; + allOptions.value = []; } }; - const search = async (value: string) => { - currentLoadParams.value = { - ...currentLoadParams.value, - keyword: value, - }; - await loadList(); + const debouncedSearch = async (value: string) => { + if (!value) { + currentLoadParams.value = { + ...currentLoadParams.value, + keyword: value, + }; + await loadList(); + } else { + const fn = debounce( + () => { + currentLoadParams.value = { + ...currentLoadParams.value, + keyword: value, + }; + loadList(); + }, + 300, + { maxWait: 1000 } + ); + fn(); + } }; - const debouncedSearch = debounce(search, 300, { maxWait: 1000 }); + const change = ( + value: string | number | boolean | Record | (string | number | boolean | Record)[] + ) => { + const tmpArr = Array.isArray(value) ? value : [value]; + currentOptions.value = tmpArr; + const { valueKey } = props; + emit( + 'update:value', + tmpArr.map((item) => item[valueKey]) + ); + debouncedSearch(''); + }; onMounted(async () => { await loadList(); diff --git a/frontend/src/views/project-management/projectAndPermission/userGroup/projectUserGroup.vue b/frontend/src/views/project-management/projectAndPermission/userGroup/projectUserGroup.vue index 9804b94d48..0512a843b3 100644 --- a/frontend/src/views/project-management/projectAndPermission/userGroup/projectUserGroup.vue +++ b/frontend/src/views/project-management/projectAndPermission/userGroup/projectUserGroup.vue @@ -66,19 +66,18 @@ v-model:visible="addUserGroupVisible" :ok-text="t('common.create')" title-align="start" - class="ms-modal-form ms-modal-medium" - width="480px" + class="ms-modal-form ms-modal-small" >
- + - +
diff --git a/frontend/src/views/setting/organization/project/components/addProjectModal.vue b/frontend/src/views/setting/organization/project/components/addProjectModal.vue index dbb13161af..f30e341883 100644 --- a/frontend/src/views/setting/organization/project/components/addProjectModal.vue +++ b/frontend/src/views/setting/organization/project/components/addProjectModal.vue @@ -1,7 +1,7 @@
- +
- + @@ -17,7 +18,7 @@
- +
- +