-
Notifications
You must be signed in to change notification settings - Fork 0
/
component.ts
73 lines (66 loc) · 1.47 KB
/
component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* @file types
* @author zipple
*/
import React from 'react';
export interface List {
text: string;
checked: boolean;
disabled: boolean;
children?: List[];
[index: string]: any;
}
export interface Column {
name: string;
needFilter: boolean;
}
export interface IProps {
dataSource: List[];
baseCellHeight?: number;
mode?: 'view'|'edit';
columns?: Column[];
onChange?: (...args: any) => any;
renderDisabledCellTips?: (node: Node) => React.ReactNode;
renderItem?: (node: Node) => React.ReactNode;
onlyReturnLeafNodes?: boolean;
showOperatorBtn?: boolean;
onCancel?: (...args: any) => any;
onSave?: (changedNodes: Node[]) => any;
style?: object;
emptyText?: string;
okText?: string;
cancelText?: string;
onNodeChange?: (...args) => void;
}
export interface Node {
nodeId: string;
text: string;
checked: boolean;
indeterminate: boolean;
level: number;
disabled: boolean;
children?: Node[];
parent?: Node;
isEmptyNode: boolean;
[index: string]: any;
}
export interface IAction {
type: 'init'|'checked'|'uncheck'|'filter';
payload?: Node|IState|string[];
}
export interface IState {
// 列
columns: Column[];
// 全部数据
rawTree: Node;
// 当前渲染的数据
tree: Node;
// 触发onChange的节点
changedNodes: Node[];
// 选中的过滤节点
filterNodes: string[];
// 是否只保留叶子变更节点
onlyReturnLeafNodes: boolean;
// 当前点击的节点
currentClickedNode: Node|null;
}