Commit 9a1b9a75eca2904ce1ec0251694f408cdbb63b96
1 parent
4749b762
perf: organization tree select folding icon fixed position
Showing
2 changed files
with
58 additions
and
44 deletions
@@ -31,7 +31,6 @@ | @@ -31,7 +31,6 @@ | ||
31 | import { CreateContextOptions } from '/@/components/ContextMenu'; | 31 | import { CreateContextOptions } from '/@/components/ContextMenu'; |
32 | 32 | ||
33 | import { CheckEvent } from './typing'; | 33 | import { CheckEvent } from './typing'; |
34 | - import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons-vue'; | ||
35 | 34 | ||
36 | interface State { | 35 | interface State { |
37 | expandedKeys: Keys; | 36 | expandedKeys: Keys; |
@@ -52,13 +51,13 @@ | @@ -52,13 +51,13 @@ | ||
52 | 'update:searchValue', | 51 | 'update:searchValue', |
53 | ], | 52 | ], |
54 | setup(props, { attrs, slots, emit, expose }) { | 53 | setup(props, { attrs, slots, emit, expose }) { |
55 | - /** | ||
56 | - * 作者自带Tree组件 | ||
57 | - * 新增显示隐藏 | ||
58 | - * ft | ||
59 | - */ | ||
60 | - //ft | ||
61 | - const isFlod = ref(false); | 54 | + // /** |
55 | + // * 作者自带Tree组件 | ||
56 | + // * 新增显示隐藏 | ||
57 | + // * ft | ||
58 | + // */ | ||
59 | + // //ft | ||
60 | + // const isFlod = ref(false); | ||
62 | //ft | 61 | //ft |
63 | const state = reactive<State>({ | 62 | const state = reactive<State>({ |
64 | checkStrictly: props.checkStrictly, | 63 | checkStrictly: props.checkStrictly, |
@@ -234,9 +233,9 @@ | @@ -234,9 +233,9 @@ | ||
234 | } | 233 | } |
235 | 234 | ||
236 | //ft | 235 | //ft |
237 | - function handleFlodOrUnFoldFunc(v) { | ||
238 | - isFlod.value = v; | ||
239 | - } | 236 | + // function handleFlodOrUnFoldFunc(v) { |
237 | + // isFlod.value = v; | ||
238 | + // } | ||
240 | //ft | 239 | //ft |
241 | function handleClickNode(key: string, children: TreeItem[]) { | 240 | function handleClickNode(key: string, children: TreeItem[]) { |
242 | if (!props.clickRowToExpand || !children || children.length === 0) return; | 241 | if (!props.clickRowToExpand || !children || children.length === 0) return; |
@@ -419,7 +418,7 @@ | @@ -419,7 +418,7 @@ | ||
419 | const showTitle = title || toolbar || search || slots.headerTitle; | 418 | const showTitle = title || toolbar || search || slots.headerTitle; |
420 | const scrollStyle: CSSProperties = { height: 'calc(100% - 38px)' }; | 419 | const scrollStyle: CSSProperties = { height: 'calc(100% - 38px)' }; |
421 | return ( | 420 | return ( |
422 | - <div style={isFlod.value ? '' : 'width:0vw'} class={[prefixCls, 'h-full', attrs.class]}> | 421 | + <div class={[prefixCls, 'h-full', attrs.class]}> |
423 | {showTitle && ( | 422 | {showTitle && ( |
424 | <TreeHeader | 423 | <TreeHeader |
425 | style={'position:relative'} | 424 | style={'position:relative'} |
@@ -448,23 +447,6 @@ | @@ -448,23 +447,6 @@ | ||
448 | </ScrollContainer> | 447 | </ScrollContainer> |
449 | 448 | ||
450 | <Empty v-show={unref(getNotFound)} image={Empty.PRESENTED_IMAGE_SIMPLE} class="!mt-4" /> | 449 | <Empty v-show={unref(getNotFound)} image={Empty.PRESENTED_IMAGE_SIMPLE} class="!mt-4" /> |
451 | - <span | ||
452 | - v-show={unref(isFlod)} | ||
453 | - onClick={() => handleFlodOrUnFoldFunc(false)} | ||
454 | - class={['is-flod', unref(isFlod) ? 'fold-right' : 'fold-left']} | ||
455 | - > | ||
456 | - <DoubleLeftOutlined /> | ||
457 | - </span> | ||
458 | - <span | ||
459 | - v-show={!unref(isFlod) && unref(treeDataRef).length != 0} | ||
460 | - onClick={() => handleFlodOrUnFoldFunc(true)} | ||
461 | - class={[ | ||
462 | - 'is-unflod', | ||
463 | - !unref(isFlod) && unref(treeDataRef).length != 0 ? 'fold-left' : 'fold-right', | ||
464 | - ]} | ||
465 | - > | ||
466 | - <DoubleRightOutlined /> | ||
467 | - </span> | ||
468 | </div> | 450 | </div> |
469 | ); | 451 | ); |
470 | }; | 452 | }; |
@@ -481,6 +463,7 @@ | @@ -481,6 +463,7 @@ | ||
481 | top: 0.85rem; | 463 | top: 0.85rem; |
482 | left: 1.1vw; | 464 | left: 1.1vw; |
483 | } | 465 | } |
466 | + | ||
484 | .fold-right { | 467 | .fold-right { |
485 | z-index: 1; | 468 | z-index: 1; |
486 | cursor: pointer; | 469 | cursor: pointer; |
1 | <template> | 1 | <template> |
2 | - <div style="position: absolute"> </div> | ||
3 | - <div class="bg-white m-4 mr-0 overflow-hidden"> | ||
4 | - <BasicTree | ||
5 | - title="组织列表" | ||
6 | - toolbar | ||
7 | - search | ||
8 | - :clickRowToExpand="false" | ||
9 | - :treeData="treeData" | ||
10 | - :expandedKeys="treeExpandData" | ||
11 | - :replaceFields="{ key: 'id', title: 'name' }" | ||
12 | - :selectedKeys="selectedKeys" | ||
13 | - @select="handleSelect" | ||
14 | - v-bind="$attrs" | ||
15 | - /> | 2 | + <div class="organization-tree flex relative"> |
3 | + <div class="cursor-pointer flex py-4 fold-icon" :class="foldFlag ? 'absolute' : ''"> | ||
4 | + <div @click="handleFold"> | ||
5 | + <DoubleRightOutlined :class="[foldFlag ? '' : 'rotate-180']" class="text-xl transform" /> | ||
6 | + </div> | ||
7 | + </div> | ||
8 | + <div | ||
9 | + :style="{ width: foldFlag ? '0px' : '100%' }" | ||
10 | + :class="[foldFlag ? '' : 'my-4 ml-2']" | ||
11 | + class="bg-white mr-0 overflow-hidden" | ||
12 | + > | ||
13 | + <BasicTree | ||
14 | + title="组织列表" | ||
15 | + toolbar | ||
16 | + search | ||
17 | + :clickRowToExpand="false" | ||
18 | + :treeData="treeData" | ||
19 | + :expandedKeys="treeExpandData" | ||
20 | + :replaceFields="{ key: 'id', title: 'name' }" | ||
21 | + :selectedKeys="selectedKeys" | ||
22 | + @select="handleSelect" | ||
23 | + v-bind="$attrs" | ||
24 | + /> | ||
25 | + </div> | ||
16 | </div> | 26 | </div> |
17 | </template> | 27 | </template> |
18 | <script lang="ts" setup name="OrganizationIdTree"> | 28 | <script lang="ts" setup name="OrganizationIdTree"> |
19 | - import { onMounted, ref } from 'vue'; | 29 | + import { onMounted, ref, unref } from 'vue'; |
20 | import { BasicTree, TreeItem } from '/@/components/Tree'; | 30 | import { BasicTree, TreeItem } from '/@/components/Tree'; |
21 | import { getOrganizationList } from '/@/api/system/system'; | 31 | import { getOrganizationList } from '/@/api/system/system'; |
32 | + import { DoubleRightOutlined } from '@ant-design/icons-vue'; | ||
22 | 33 | ||
23 | const emit = defineEmits(['select']); | 34 | const emit = defineEmits(['select']); |
24 | const treeData = ref<TreeItem[]>([]); | 35 | const treeData = ref<TreeItem[]>([]); |
@@ -37,6 +48,12 @@ | @@ -37,6 +48,12 @@ | ||
37 | function resetOrganization() { | 48 | function resetOrganization() { |
38 | selectedKeys.value = []; | 49 | selectedKeys.value = []; |
39 | } | 50 | } |
51 | + | ||
52 | + const foldFlag = ref(true); | ||
53 | + const handleFold = () => { | ||
54 | + foldFlag.value = !unref(foldFlag); | ||
55 | + }; | ||
56 | + | ||
40 | onMounted(async () => { | 57 | onMounted(async () => { |
41 | treeData.value = (await getOrganizationList()) as unknown as TreeItem[]; | 58 | treeData.value = (await getOrganizationList()) as unknown as TreeItem[]; |
42 | const getAllIds = findForAllId(treeData.value as any, []); | 59 | const getAllIds = findForAllId(treeData.value as any, []); |
@@ -47,3 +64,17 @@ | @@ -47,3 +64,17 @@ | ||
47 | resetOrganization, | 64 | resetOrganization, |
48 | }); | 65 | }); |
49 | </script> | 66 | </script> |
67 | + | ||
68 | +<style scoped lang="less"> | ||
69 | + .organization-tree { | ||
70 | + .expand { | ||
71 | + opacity: 0; | ||
72 | + } | ||
73 | + | ||
74 | + &:hover { | ||
75 | + .expand { | ||
76 | + opacity: 1; | ||
77 | + } | ||
78 | + } | ||
79 | + } | ||
80 | +</style> |