committed by
GitHub
55 changed files with 452 additions and 584 deletions
@ -1,6 +1,6 @@ |
|||||
import BasicTree from './src/Tree.vue'; |
import BasicTree from './src/BasicTree.vue'; |
||||
import './style'; |
import './style'; |
||||
|
|
||||
export { BasicTree }; |
export { BasicTree }; |
||||
export type { ContextMenuItem } from '/@/hooks/web/useContextMenu'; |
export type { ContextMenuItem } from '/@/hooks/web/useContextMenu'; |
||||
export * from './src/tree'; |
export * from './src/types/tree'; |
||||
@ -1,4 +1,4 @@ |
|||||
import type { InsertNodeParams, KeyType, FieldNames, TreeItem } from './tree'; |
import type { InsertNodeParams, KeyType, FieldNames, TreeItem } from '../types/tree'; |
||||
import type { Ref, ComputedRef } from 'vue'; |
import type { Ref, ComputedRef } from 'vue'; |
||||
import type { TreeDataItem } from 'ant-design-vue/es/tree/Tree'; |
import type { TreeDataItem } from 'ant-design-vue/es/tree/Tree'; |
||||
|
|
||||
@ -1,108 +0,0 @@ |
|||||
import type { PropType } from 'vue'; |
|
||||
import type { |
|
||||
ReplaceFields, |
|
||||
ActionItem, |
|
||||
Keys, |
|
||||
CheckKeys, |
|
||||
ContextMenuOptions, |
|
||||
TreeItem, |
|
||||
} from './typing'; |
|
||||
import type { ContextMenuItem } from '/@/hooks/web/useContextMenu'; |
|
||||
import type { TreeDataItem } from 'ant-design-vue/es/tree/Tree'; |
|
||||
import { propTypes } from '/@/utils/propTypes'; |
|
||||
|
|
||||
export const basicProps = { |
|
||||
value: { |
|
||||
type: [Object, Array] as PropType<Keys | CheckKeys>, |
|
||||
}, |
|
||||
renderIcon: { |
|
||||
type: Function as PropType<(params: Recordable) => string>, |
|
||||
}, |
|
||||
|
|
||||
helpMessage: { |
|
||||
type: [String, Array] as PropType<string | string[]>, |
|
||||
default: '', |
|
||||
}, |
|
||||
|
|
||||
title: propTypes.string, |
|
||||
toolbar: propTypes.bool, |
|
||||
search: propTypes.bool, |
|
||||
searchValue: propTypes.string, |
|
||||
checkStrictly: propTypes.bool, |
|
||||
clickRowToExpand: propTypes.bool.def(true), |
|
||||
checkable: propTypes.bool.def(false), |
|
||||
defaultExpandLevel: { |
|
||||
type: [String, Number] as PropType<string | number>, |
|
||||
default: '', |
|
||||
}, |
|
||||
defaultExpandAll: propTypes.bool.def(false), |
|
||||
|
|
||||
replaceFields: { |
|
||||
type: Object as PropType<ReplaceFields>, |
|
||||
}, |
|
||||
|
|
||||
treeData: { |
|
||||
type: Array as PropType<TreeDataItem[]>, |
|
||||
}, |
|
||||
|
|
||||
actionList: { |
|
||||
type: Array as PropType<ActionItem[]>, |
|
||||
default: () => [], |
|
||||
}, |
|
||||
|
|
||||
expandedKeys: { |
|
||||
type: Array as PropType<Keys>, |
|
||||
default: () => [], |
|
||||
}, |
|
||||
|
|
||||
selectedKeys: { |
|
||||
type: Array as PropType<Keys>, |
|
||||
default: () => [], |
|
||||
}, |
|
||||
|
|
||||
checkedKeys: { |
|
||||
type: Array as PropType<CheckKeys>, |
|
||||
default: () => [], |
|
||||
}, |
|
||||
|
|
||||
beforeRightClick: { |
|
||||
type: Function as PropType<(...arg: any) => ContextMenuItem[] | ContextMenuOptions>, |
|
||||
default: null, |
|
||||
}, |
|
||||
|
|
||||
rightMenuList: { |
|
||||
type: Array as PropType<ContextMenuItem[]>, |
|
||||
}, |
|
||||
// 自定义数据过滤判断方法(注: 不是整个过滤方法,而是内置过滤的判断方法,用于增强原本仅能通过title进行过滤的方式)
|
|
||||
filterFn: { |
|
||||
type: Function as PropType< |
|
||||
(searchValue: any, node: TreeItem, replaceFields: ReplaceFields) => boolean |
|
||||
>, |
|
||||
default: null, |
|
||||
}, |
|
||||
// 高亮搜索值,仅高亮具体匹配值(通过title)值为true时使用默认色值,值为#xxx时使用此值替代且高亮开启
|
|
||||
highlight: { |
|
||||
type: [Boolean, String] as PropType<Boolean | String>, |
|
||||
default: false, |
|
||||
}, |
|
||||
// 搜索完成时自动展开结果
|
|
||||
expandOnSearch: propTypes.bool.def(false), |
|
||||
// 搜索完成自动选中所有结果,当且仅当 checkable===true 时生效
|
|
||||
checkOnSearch: propTypes.bool.def(false), |
|
||||
// 搜索完成自动select所有结果
|
|
||||
selectedOnSearch: propTypes.bool.def(false), |
|
||||
}; |
|
||||
|
|
||||
export const treeNodeProps = { |
|
||||
actionList: { |
|
||||
type: Array as PropType<ActionItem[]>, |
|
||||
default: () => [], |
|
||||
}, |
|
||||
replaceFields: { |
|
||||
type: Object as PropType<ReplaceFields>, |
|
||||
}, |
|
||||
treeData: { |
|
||||
type: Array as PropType<TreeDataItem[]>, |
|
||||
default: () => [], |
|
||||
}, |
|
||||
}; |
|
||||
@ -1,54 +0,0 @@ |
|||||
import type { TreeDataItem, CheckEvent as CheckEventOrigin } from 'ant-design-vue/es/tree/Tree'; |
|
||||
import { ContextMenuItem } from '/@/hooks/web/useContextMenu'; |
|
||||
export interface ActionItem { |
|
||||
render: (record: Recordable) => any; |
|
||||
show?: boolean | ((record: Recordable) => boolean); |
|
||||
} |
|
||||
|
|
||||
export interface TreeItem extends TreeDataItem { |
|
||||
icon?: any; |
|
||||
} |
|
||||
|
|
||||
export interface ReplaceFields { |
|
||||
children?: string; |
|
||||
title?: string; |
|
||||
key?: string; |
|
||||
} |
|
||||
|
|
||||
export type Keys = (string | number)[]; |
|
||||
export type CheckKeys = |
|
||||
| (string | number)[] |
|
||||
| { checked: (string | number)[]; halfChecked: (string | number)[] }; |
|
||||
|
|
||||
export interface TreeActionType { |
|
||||
checkAll: (checkAll: boolean) => void; |
|
||||
expandAll: (expandAll: boolean) => void; |
|
||||
setExpandedKeys: (keys: Keys) => void; |
|
||||
getExpandedKeys: () => Keys; |
|
||||
setSelectedKeys: (keys: Keys) => void; |
|
||||
getSelectedKeys: () => Keys; |
|
||||
setCheckedKeys: (keys: CheckKeys) => void; |
|
||||
getCheckedKeys: () => CheckKeys; |
|
||||
filterByLevel: (level: number) => void; |
|
||||
insertNodeByKey: (opt: InsertNodeParams) => void; |
|
||||
insertNodesByKey: (opt: InsertNodeParams) => void; |
|
||||
deleteNodeByKey: (key: string) => void; |
|
||||
updateNodeByKey: (key: string, node: Omit<TreeDataItem, 'key'>) => void; |
|
||||
setSearchValue: (value: string) => void; |
|
||||
getSearchValue: () => string; |
|
||||
} |
|
||||
|
|
||||
export interface InsertNodeParams { |
|
||||
parentKey: string | null; |
|
||||
node: TreeDataItem; |
|
||||
list?: TreeDataItem[]; |
|
||||
push?: 'push' | 'unshift'; |
|
||||
} |
|
||||
|
|
||||
export interface ContextMenuOptions { |
|
||||
icon?: string; |
|
||||
styles?: any; |
|
||||
items?: ContextMenuItem[]; |
|
||||
} |
|
||||
|
|
||||
export type CheckEvent = CheckEventOrigin; |
|
||||
Loading…
Reference in new issue