Commit 9677fae5b8d6a42c5e1e01b169dcb5e0978dbb95

Authored by fengtao
1 parent 5e2c8199

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

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