Skip to content

Commit

Permalink
fix: 重置搜索框 (#1986)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoJohw authored Nov 22, 2024
1 parent 1a0fb97 commit 099adb0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/pages/src/views/organization/components/search-org.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@

<script setup lang="ts">
import { bkTooltips as vBkTooltips } from 'bkui-vue';
import { inject, reactive, ref } from 'vue';
import { defineEmits, inject, reactive, ref } from 'vue';
import ViewUser from './view-user.vue';
Expand All @@ -127,6 +127,7 @@ import { getFields } from '@/http/settingFiles';
import { t } from '@/language/index';
import useAppStore from '@/store/app';
const emit = defineEmits(['select']);
const appStore = useAppStore();
const editLeaveBefore = inject('editLeaveBefore');
Expand Down Expand Up @@ -193,6 +194,7 @@ const handleOrgSelect = (org) => {
selected.value = org;
searchDialogVisible.value = false;
appStore.currentOrg = { ...org };
emit('select');
};
const handleUserSelect = async (user) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
import { defineExpose, ref } from 'vue';
import { getDepartmentsList } from '@/http/organizationFiles';
import useAppStore from '@/store/app';
Expand Down Expand Up @@ -62,10 +62,10 @@ const getData = (isChildren) => {
const treeData = ref([]);
watch(() => appStore.currentOrg.organization_path, async () => {
const getTreeData = async () => {
const { data = [] } = await getDepartmentsList(appStore.currentOrg.id, appStore.currentOrg.tenant_id);
treeData.value = getData(Boolean(data?.length));
});
};
const formatTreeData = (data = []) => data.map(item => ({ ...item, async: item.has_children }));
Expand All @@ -87,4 +87,8 @@ const getPrefixIcon = (item: { children?: any[] }, renderType: string) => {
},
};
};
defineExpose({
getTreeData,
});
</script>
11 changes: 9 additions & 2 deletions src/pages/src/views/organization/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
:max="400"
:initial-divide="280">
<template #aside>
<search></search>
<search @select="handleSearchSelect"></search>
<div v-show="appStore.isSearchTree">
<search-result-tree></search-result-tree>
<search-result-tree ref="searchResultTreeRef"></search-result-tree>
</div>
<bk-resize-layout
v-show="!appStore.isSearchTree"
Expand Down Expand Up @@ -84,6 +84,13 @@ const importHandle = async () => {
await getList();
tableListRef.value.importDialogHandle();
};

const searchResultTreeRef = ref();
const handleSearchSelect = () => {
if (searchResultTreeRef.value) {
searchResultTreeRef.value.getTreeData();
}
};
</script>

<style lang="postcss" scoped>
Expand Down

0 comments on commit 099adb0

Please sign in to comment.