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 | 31 | import { CreateContextOptions } from '/@/components/ContextMenu'; |
| 32 | 32 | |
| 33 | 33 | import { CheckEvent } from './typing'; |
| 34 | - import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons-vue'; | |
| 35 | 34 | |
| 36 | 35 | interface State { |
| 37 | 36 | expandedKeys: Keys; |
| ... | ... | @@ -52,13 +51,13 @@ |
| 52 | 51 | 'update:searchValue', |
| 53 | 52 | ], |
| 54 | 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 | 61 | //ft |
| 63 | 62 | const state = reactive<State>({ |
| 64 | 63 | checkStrictly: props.checkStrictly, |
| ... | ... | @@ -234,9 +233,9 @@ |
| 234 | 233 | } |
| 235 | 234 | |
| 236 | 235 | //ft |
| 237 | - function handleFlodOrUnFoldFunc(v) { | |
| 238 | - isFlod.value = v; | |
| 239 | - } | |
| 236 | + // function handleFlodOrUnFoldFunc(v) { | |
| 237 | + // isFlod.value = v; | |
| 238 | + // } | |
| 240 | 239 | //ft |
| 241 | 240 | function handleClickNode(key: string, children: TreeItem[]) { |
| 242 | 241 | if (!props.clickRowToExpand || !children || children.length === 0) return; |
| ... | ... | @@ -419,7 +418,7 @@ |
| 419 | 418 | const showTitle = title || toolbar || search || slots.headerTitle; |
| 420 | 419 | const scrollStyle: CSSProperties = { height: 'calc(100% - 38px)' }; |
| 421 | 420 | return ( |
| 422 | - <div style={isFlod.value ? '' : 'width:0vw'} class={[prefixCls, 'h-full', attrs.class]}> | |
| 421 | + <div class={[prefixCls, 'h-full', attrs.class]}> | |
| 423 | 422 | {showTitle && ( |
| 424 | 423 | <TreeHeader |
| 425 | 424 | style={'position:relative'} |
| ... | ... | @@ -448,23 +447,6 @@ |
| 448 | 447 | </ScrollContainer> |
| 449 | 448 | |
| 450 | 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 | 450 | </div> |
| 469 | 451 | ); |
| 470 | 452 | }; |
| ... | ... | @@ -481,6 +463,7 @@ |
| 481 | 463 | top: 0.85rem; |
| 482 | 464 | left: 1.1vw; |
| 483 | 465 | } |
| 466 | + | |
| 484 | 467 | .fold-right { |
| 485 | 468 | z-index: 1; |
| 486 | 469 | cursor: pointer; | ... | ... |
| 1 | 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 | 26 | </div> |
| 17 | 27 | </template> |
| 18 | 28 | <script lang="ts" setup name="OrganizationIdTree"> |
| 19 | - import { onMounted, ref } from 'vue'; | |
| 29 | + import { onMounted, ref, unref } from 'vue'; | |
| 20 | 30 | import { BasicTree, TreeItem } from '/@/components/Tree'; |
| 21 | 31 | import { getOrganizationList } from '/@/api/system/system'; |
| 32 | + import { DoubleRightOutlined } from '@ant-design/icons-vue'; | |
| 22 | 33 | |
| 23 | 34 | const emit = defineEmits(['select']); |
| 24 | 35 | const treeData = ref<TreeItem[]>([]); |
| ... | ... | @@ -37,6 +48,12 @@ |
| 37 | 48 | function resetOrganization() { |
| 38 | 49 | selectedKeys.value = []; |
| 39 | 50 | } |
| 51 | + | |
| 52 | + const foldFlag = ref(true); | |
| 53 | + const handleFold = () => { | |
| 54 | + foldFlag.value = !unref(foldFlag); | |
| 55 | + }; | |
| 56 | + | |
| 40 | 57 | onMounted(async () => { |
| 41 | 58 | treeData.value = (await getOrganizationList()) as unknown as TreeItem[]; |
| 42 | 59 | const getAllIds = findForAllId(treeData.value as any, []); |
| ... | ... | @@ -47,3 +64,17 @@ |
| 47 | 64 | resetOrganization, |
| 48 | 65 | }); |
| 49 | 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> | ... | ... |