Commit 9677fae5b8d6a42c5e1e01b169dcb5e0978dbb95

Authored by fengtao
1 parent 5e2c8199

feat:Tree组件 新增显示隐藏功能

... ... @@ -31,6 +31,7 @@
31 31 import { CreateContextOptions } from '/@/components/ContextMenu';
32 32
33 33 import { CheckEvent } from './typing';
  34 + import { LeftOutlined, RightOutlined } from '@ant-design/icons-vue';
34 35
35 36 interface State {
36 37 expandedKeys: Keys;
... ... @@ -51,6 +52,14 @@
51 52 'update:searchValue',
52 53 ],
53 54 setup(props, { attrs, slots, emit, expose }) {
  55 + /**
  56 + * 作者自带Tree组件
  57 + * 新增显示隐藏
  58 + * ft
  59 + */
  60 + //ft
  61 + const isFlod = ref(false);
  62 + //ft
54 63 const state = reactive<State>({
55 64 checkStrictly: props.checkStrictly,
56 65 expandedKeys: props.expandedKeys || [],
... ... @@ -205,6 +214,7 @@
205 214 });
206 215
207 216 function handleSearch(searchValue: string) {
  217 + console.log('searchValue', searchValue);
208 218 if (searchValue !== searchText.value) searchText.value = searchValue;
209 219 emit('update:searchValue', searchValue);
210 220 if (!searchValue) {
... ... @@ -223,6 +233,11 @@
223 233 );
224 234 }
225 235
  236 + //ft
  237 + function handleFlodOrUnFoldFunc(v) {
  238 + isFlod.value = v;
  239 + }
  240 + //ft
226 241 function handleClickNode(key: string, children: TreeItem[]) {
227 242 if (!props.clickRowToExpand || !children || children.length === 0) return;
228 243 if (!state.expandedKeys.includes(key)) {
... ... @@ -388,9 +403,10 @@
388 403 const showTitle = title || toolbar || search || slots.headerTitle;
389 404 const scrollStyle: CSSProperties = { height: 'calc(100% - 38px)' };
390 405 return (
391   - <div class={[prefixCls, 'h-full', attrs.class]}>
  406 + <div style={isFlod.value ? '' : 'width:0vw'} class={[prefixCls, 'h-full', attrs.class]}>
392 407 {showTitle && (
393 408 <TreeHeader
  409 + style={'position:relative'}
394 410 checkable={checkable}
395 411 checkAll={checkAll}
396 412 expandAll={expandAll}
... ... @@ -416,6 +432,28 @@
416 432 </ScrollContainer>
417 433
418 434 <Empty v-show={unref(getNotFound)} image={Empty.PRESENTED_IMAGE_SIMPLE} class="!mt-4" />
  435 + <span
  436 + v-show={unref(isFlod)}
  437 + onClick={() => handleFlodOrUnFoldFunc(false)}
  438 + style={
  439 + isFlod.value
  440 + ? 'z-index:9999;cursor:pointer;position:absolute;top:40vh;left:17.5vw'
  441 + : 'z-index:9999;cursor:pointer;position:absolute;top:40vh;left:0.5vw'
  442 + }
  443 + >
  444 + <RightOutlined />
  445 + </span>
  446 + <span
  447 + v-show={!unref(isFlod) && unref(treeDataRef).length != 0}
  448 + onClick={() => handleFlodOrUnFoldFunc(true)}
  449 + style={
  450 + isFlod.value
  451 + ? 'z-index:9999;cursor:pointer;position:absolute;top:40vh;left:17.5vw'
  452 + : 'z-index:9999;cursor:pointer;position:absolute;top:40vh;left:0.5vw'
  453 + }
  454 + >
  455 + <LeftOutlined />
  456 + </span>
419 457 </div>
420 458 );
421 459 };
... ...