-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtable.go
238 lines (204 loc) · 4.75 KB
/
table.go
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
package amis
// 表格
func Table(opts ...opt) map[string]interface{} {
return newCompent("table", opts...)
}
// 标题
func Table_title(p string) opt {
return func(o map[string]interface{}) {
o["title"] = p
}
}
// 数据源, 绑定当前环境变量
func Table_source(p string) opt {
return func(o map[string]interface{}) {
o["source"] = p
}
}
// 是否固定表头
func Table_affixHeader(p bool) opt {
return func(o map[string]interface{}) {
o["affixHeader"] = p
}
}
// 展示列显示开关, 自动即:列数量大于或等于 5 个时自动开启
func Table_columnsTogglable(p interface{}) opt {
return func(o map[string]interface{}) {
o["columnsTogglable"] = p
}
}
// 当没数据的时候的文字提示
func Table_placeholder(p interface{}) opt {
return func(o map[string]interface{}) {
o["placeholder"] = p
}
}
// 外层 CSS 类名
func Table_className(p string) opt {
return func(o map[string]interface{}) {
o["className"] = p
}
}
// 表格 CSS 类名
func Table_tableClassName(p string) opt {
return func(o map[string]interface{}) {
o["tableClassName"] = p
}
}
// 顶部外层 CSS 类名
func Table_headerClassName(p string) opt {
return func(o map[string]interface{}) {
o["headerClassName"] = p
}
}
// 底部外层 CSS 类名
func Table_footerClassName(p string) opt {
return func(o map[string]interface{}) {
o["footerClassName"] = p
}
}
// 工具栏 CSS 类名
func Table_toolbarClassName(p string) opt {
return func(o map[string]interface{}) {
o["toolbarClassName"] = p
}
}
// 用来设置列信息
func Table_columns(p ...interface{}) opt {
return func(o map[string]interface{}) {
o["columns"] = p
}
}
// 自动合并单元格
func Table_combineNum(p interface{}) opt {
return func(o map[string]interface{}) {
o["combineNum"] = p
}
}
// 悬浮行操作按钮组
func Table_itemActions(p interface{}) opt {
return func(o map[string]interface{}) {
o["itemActions"] = p
}
}
// 配置当前行是否可勾选的条件,要用 [表达式](../../docs/concepts/expression)
func Table_itemCheckableOn(p interface{}) opt {
return func(o map[string]interface{}) {
o["itemCheckableOn"] = p
}
}
// 配置当前行是否可拖拽的条件,要用 [表达式](../../docs/concepts/expression)
func Table_itemDraggableOn(p interface{}) opt {
return func(o map[string]interface{}) {
o["itemDraggableOn"] = p
}
}
// 点击数据行是否可以勾选当前行
func Table_checkOnItemClick(p bool) opt {
return func(o map[string]interface{}) {
o["checkOnItemClick"] = p
}
}
// 给行添加 CSS 类名
func Table_rowClassName(p string) opt {
return func(o map[string]interface{}) {
o["rowClassName"] = p
}
}
// 通过模板给行添加 CSS 类名
func Table_rowClassNameExpr(p interface{}) opt {
return func(o map[string]interface{}) {
o["rowClassNameExpr"] = p
}
}
// 顶部总结行
func Table_prefixRow(p interface{}) opt {
return func(o map[string]interface{}) {
o["prefixRow"] = p
}
}
// 底部总结行
func Table_affixRow(p interface{}) opt {
return func(o map[string]interface{}) {
o["affixRow"] = p
}
}
// 行角标配置
func Table_itemBadge(p interface{}) opt {
return func(o map[string]interface{}) {
o["itemBadge"] = p
}
}
// 内容区域自适应高度
func Table_autoFillHeight(p interface{}) opt {
return func(o map[string]interface{}) {
o["autoFillHeight"] = p
}
}
// 列宽度是否支持调整
func Table_resizable(p bool) opt {
return func(o map[string]interface{}) {
o["resizable"] = p
}
}
// 支持勾选
func Table_selectable(p bool) opt {
return func(o map[string]interface{}) {
o["selectable"] = p
}
}
// 勾选 icon 是否为多选样式`checkbox`, 默认为`radio`
func Table_multiple(p bool) opt {
return func(o map[string]interface{}) {
o["multiple"] = p
}
}
func TableColumn(opts ...opt) map[string]interface{} {
var o = map[string]interface{}{}
for _, op := range opts {
op(o)
}
return o
}
// 表头文本内容
func TableColumn_label(p interface{}) opt {
return func(o map[string]interface{}) {
o["label"] = p
}
}
// 通过名称关联数据
func TableColumn_name(p string) opt {
return func(o map[string]interface{}) {
o["name"] = p
}
}
// 列宽
func TableColumn_width(p interface{}) opt {
return func(o map[string]interface{}) {
o["width"] = p
}
}
// 提示信息
func TableColumn_remark(p interface{}) opt {
return func(o map[string]interface{}) {
o["remark"] = p
}
}
// 是否固定当前列 left | right | none
func TableColumn_fixed(p interface{}) opt {
return func(o map[string]interface{}) {
o["fixe"] = p
}
}
// 弹出框
func TableColumn_popOver(p interface{}) opt {
return func(o map[string]interface{}) {
o["popOver"] = p
}
}
// 是否可复制
func TableColumn_copyable(p interface{}) opt {
return func(o map[string]interface{}) {
o["copyable"] = p
}
}