Ben Lin
2024-10-30 28a53fe81cdb551d2bf2023167487a3060e0f180
src/components/TigerTree/src/TigerTree.vue
@@ -33,6 +33,7 @@
  import { CreateContextOptions } from '/@/components/ContextMenu';
  import { treeEmits, treeProps } from './types/tree';
  import { createBEM } from '/@/utils/bem';
import { EventDataNode } from 'ant-design-vue/es/tree';
  export default defineComponent({
    name: 'TigerTree',
@@ -47,7 +48,7 @@
        expandedKeys: props.expandedKeys || [],
        selectedKeys: props.selectedKeys || [],
        checkedKeys: props.checkedKeys || [],
        halfCheckedKeys: props.halfCheckedKeys|| [],
        halfCheckedKeys: props.halfCheckedKeys || [],
      });
      const searchState = reactive({
@@ -109,6 +110,12 @@
            emit('gethalfCheckedKeys', toRaw(state.halfCheckedKeys));
          },
          onRightClick: handleRightClick,
          onClick: (e: MouseEvent, node: EventDataNode) => {
            if(node.selected){
              console.log(state.selectedKeys, node);
              emit('unselect', node);
            }
          }
        };
        return omit(propsData, 'treeData', 'class');
      });
@@ -193,8 +200,8 @@
        state.expandedKeys = expandAll ? getAllKeys() : ([] as KeyType[]);
      }
      function addHouse(add: boolean) {
        emit('addHouse', add);
      function handleAdd(add: boolean) {
        emit('handleAdd', add);
      }
      function onStrictlyChange(strictly: boolean) {
@@ -221,7 +228,6 @@
          }
        },
      );
      function handleSearch(searchValue: string) {
        if (searchValue !== searchState.searchText) searchState.searchText = searchValue;
@@ -353,7 +359,7 @@
        getNodeById,
        checkAll,
        expandAll,
        addHouse,
        handleAdd,
        filterByLevel: (level: number) => {
          state.expandedKeys = filterByLevel(level);
        },
@@ -438,7 +444,7 @@
      expose(instance);
      return () => {
        const { title, helpMessage, toolbar,add,search, checkable } = props;
        const { title, helpMessage, toolbar, add, search, checkable } = props;
        const showTitle = title || toolbar || search || slots.headerTitle;
        const scrollStyle: CSSProperties = { height: 'calc(100% - 38px)' };
        return (
@@ -448,7 +454,7 @@
                checkable={checkable}
                checkAll={checkAll}
                expandAll={expandAll}
                addHouse = {addHouse}
                onHandleAdd={handleAdd}
                title={title}
                search={search}
                toolbar={toolbar}
@@ -461,14 +467,18 @@
                {extendSlots(slots)}
              </TreeHeader>
            )}
            <div style='height:777px;overflow-y: scroll;'>
              <Spin
            <Spin
              wrapperClassName={unref(props.treeWrapperClassName)}
              spinning={unref(props.loading)}
              tip="加载中..."
            >
              <ScrollContainer style={scrollStyle} v-show={!unref(getNotFound)}>
                <Tree {...unref(getBindValues)} showIcon={false} disabled={props.disabled} treeData={treeData.value} />
                <Tree
                  {...unref(getBindValues)}
                  showIcon={false}
                  disabled={props.disabled}
                  treeData={treeData.value}
                />
              </ScrollContainer>
              <Empty
                v-show={unref(getNotFound)}
@@ -476,7 +486,6 @@
                class="!mt-4"
              />
            </Spin>
            </div>
          </div>
        );
      };