tntd 1.3.66 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dist/0645cf743e4e44ca9da321d689897f07.png +0 -0
  2. package/dist/09db77de0c24fa0f45f8a5cf299a3d11.png +0 -0
  3. package/dist/1.tntd.js +12 -0
  4. package/dist/1d0b52448de217857b270af807e9360d.png +0 -0
  5. package/dist/25d78d77c9c2f0d403e5d899ceb5b1ef.png +0 -0
  6. package/dist/27fa44ff0c98e1594d79b73045aabedf.png +0 -0
  7. package/dist/2c95075adb68d6131b59cae9fa554ec2.png +0 -0
  8. package/dist/377c871d922a25c773a9e7c2f42ed7c0.png +0 -0
  9. package/dist/3d901589b40bd56ff1fde2bbb700bfe1.png +0 -0
  10. package/dist/4abe481e130d7be0574e45573de8beb7.png +0 -0
  11. package/dist/95ee2260a509cd630d89c5367ed1973b.png +0 -0
  12. package/dist/b9dd5ff3622296fbee51ed68f4bca1bf.png +0 -0
  13. package/dist/bd2921989f9296089ba58efb7a76f3ef.png +0 -0
  14. package/dist/stats.json +45855 -0
  15. package/dist/tntd.css +1 -0
  16. package/dist/tntd.js +15 -0
  17. package/es/ArrayInput/README.md +129 -0
  18. package/es/ArrayInput/icon.js +24 -0
  19. package/es/ArrayInput/index.js +282 -0
  20. package/es/ArrayInput/index.less +20 -0
  21. package/es/AuthContext.js +4 -0
  22. package/es/Columns/README.md +149 -0
  23. package/es/Columns/index.js +86 -0
  24. package/es/Columns/index.less +75 -0
  25. package/es/DevelopmentLogin/LoginModal.js +126 -0
  26. package/es/DevelopmentLogin/README.md +49 -0
  27. package/es/DevelopmentLogin/index.js +40 -0
  28. package/es/Ellipsis/README.md +104 -0
  29. package/es/Ellipsis/Svg/CopySVG.js +63 -0
  30. package/es/Ellipsis/Svg/TickSVG.js +41 -0
  31. package/es/Ellipsis/index.js +143 -0
  32. package/es/Ellipsis/index.less +56 -0
  33. package/es/Handle/README.md +104 -0
  34. package/es/Handle/index.js +92 -0
  35. package/es/Handle/index.less +9 -0
  36. package/es/Icon/README.md +119 -0
  37. package/es/Icon/fonts/demo.css +539 -0
  38. package/es/Icon/fonts/demo_index.html +3345 -0
  39. package/es/Icon/fonts/iconfont.css +569 -0
  40. package/es/Icon/fonts/iconfont.eot +0 -0
  41. package/es/Icon/fonts/iconfont.js +41 -0
  42. package/es/Icon/fonts/iconfont.json +975 -0
  43. package/es/Icon/fonts/iconfont.svg +440 -0
  44. package/es/Icon/fonts/iconfont.ttf +0 -0
  45. package/es/Icon/fonts/iconfont.woff +0 -0
  46. package/es/Icon/fonts/iconfont.woff2 +0 -0
  47. package/es/Icon/iconList.js +1 -0
  48. package/es/Icon/index.js +26 -0
  49. package/es/Icon/index.less +9 -0
  50. package/es/Img/Contain.js +69 -0
  51. package/es/Img/Cover.js +126 -0
  52. package/es/Img/README.md +131 -0
  53. package/es/Img/index.js +76 -0
  54. package/es/Layout/ActionsContext.js +3 -0
  55. package/es/Layout/AppList.js +233 -0
  56. package/es/Layout/Application.js +115 -0
  57. package/es/Layout/Avatar.js +116 -0
  58. package/es/Layout/CompatibleLanguage.js +179 -0
  59. package/es/Layout/EnterpriseLayout/Avatar.js +144 -0
  60. package/es/Layout/EnterpriseLayout/Language.js +81 -0
  61. package/es/Layout/EnterpriseLayout/Theme.js +77 -0
  62. package/es/Layout/EnterpriseLayout/index.js +31 -0
  63. package/es/Layout/GlobalNavigation/NavigationPopup.js +396 -0
  64. package/es/Layout/GlobalNavigation/index.js +137 -0
  65. package/es/Layout/Header.js +95 -0
  66. package/es/Layout/HeaderActions.js +107 -0
  67. package/es/Layout/HeaderNavs.js +93 -0
  68. package/es/Layout/HeaderTabs.js +264 -0
  69. package/es/Layout/Iconfont.js +4 -0
  70. package/es/Layout/Language.js +81 -0
  71. package/es/Layout/Layout.js +234 -0
  72. package/es/Layout/Logo.js +86 -0
  73. package/es/Layout/OrgAppList.js +310 -0
  74. package/es/Layout/README.md +783 -0
  75. package/es/Layout/SideMenu.js +340 -0
  76. package/es/Layout/Theme.js +107 -0
  77. package/es/Layout/checkAuth.js +29 -0
  78. package/es/Layout/createActions.js +39 -0
  79. package/es/Layout/images/avatar/empty.png +0 -0
  80. package/es/Layout/images/avatar/female1.png +0 -0
  81. package/es/Layout/images/avatar/female2.png +0 -0
  82. package/es/Layout/images/avatar/female3.png +0 -0
  83. package/es/Layout/images/avatar/female4.png +0 -0
  84. package/es/Layout/images/avatar/female5.png +0 -0
  85. package/es/Layout/images/avatar/female6.png +0 -0
  86. package/es/Layout/images/avatar/male1.png +0 -0
  87. package/es/Layout/images/avatar/male2.png +0 -0
  88. package/es/Layout/images/avatar/male3.png +0 -0
  89. package/es/Layout/images/avatar/male4.png +0 -0
  90. package/es/Layout/images/avatar/male5.png +0 -0
  91. package/es/Layout/images/avatar/male6.png +0 -0
  92. package/es/Layout/images/index.js +35 -0
  93. package/es/Layout/images/logo/baldur.svg +14 -0
  94. package/es/Layout/images/logo/bi.svg +14 -0
  95. package/es/Layout/images/logo/bridge.svg +15 -0
  96. package/es/Layout/images/logo/convert.svg +18 -0
  97. package/es/Layout/images/logo/dataocean.svg +31 -0
  98. package/es/Layout/images/logo/default.svg +19 -0
  99. package/es/Layout/images/logo/dispatch.svg +14 -0
  100. package/es/Layout/images/logo/graph.svg +26 -0
  101. package/es/Layout/images/logo/handle.svg +10 -0
  102. package/es/Layout/images/logo/indicator.svg +41 -0
  103. package/es/Layout/images/logo/kafka.svg +12 -0
  104. package/es/Layout/images/logo/logo-custom.svg +13 -0
  105. package/es/Layout/images/logo/model.svg +17 -0
  106. package/es/Layout/images/logo/mysql.svg +15 -0
  107. package/es/Layout/images/logo/orion.svg +24 -0
  108. package/es/Layout/images/logo/salaxy.svg +11 -0
  109. package/es/Layout/images/logo/storage.svg +16 -0
  110. package/es/Layout/images/logo/tnt_cli_identify.svg +19 -0
  111. package/es/Layout/images/logo/turing.svg +35 -0
  112. package/es/Layout/images/theme/theme1.svg +35 -0
  113. package/es/Layout/images/theme/theme2.svg +33 -0
  114. package/es/Layout/index.js +122 -0
  115. package/es/Layout/paaslayout/CompactSideMenu.js +167 -0
  116. package/es/Layout/paaslayout/Header.js +77 -0
  117. package/es/Layout/paaslayout/Logo.js +22 -0
  118. package/es/Layout/paaslayout/SideMenu.js +168 -0
  119. package/es/Layout/paaslayout/index.js +235 -0
  120. package/es/Layout/storage.js +47 -0
  121. package/es/Layout/utils.js +136 -0
  122. package/es/LoadingButton/README.md +75 -0
  123. package/es/LoadingButton/index.js +45 -0
  124. package/es/Modal/README.md +59 -0
  125. package/es/Modal/index.js +96 -0
  126. package/es/Modal/index.less +86 -0
  127. package/es/Page/Box.js +74 -0
  128. package/es/Page/README.md +180 -0
  129. package/es/Page/index.js +165 -0
  130. package/es/Page/index.less +144 -0
  131. package/es/Page/utils.js +23 -0
  132. package/es/QueryForm/Field/Checkbox.js +21 -0
  133. package/es/QueryForm/Field/Select.js +80 -0
  134. package/es/QueryForm/Field/SelectInput.js +92 -0
  135. package/es/QueryForm/Field/fieldsMap.js +32 -0
  136. package/es/QueryForm/Field/index.js +157 -0
  137. package/es/QueryForm/README.md +512 -0
  138. package/es/QueryForm/createActions.js +53 -0
  139. package/es/QueryForm/index.js +384 -0
  140. package/es/QueryForm/index.less +133 -0
  141. package/es/QueryForm/useForm.js +7 -0
  142. package/es/QueryListScene/List.js +378 -0
  143. package/es/QueryListScene/QueryForm.js +166 -0
  144. package/es/QueryListScene/QueryListScene.js +76 -0
  145. package/es/QueryListScene/README.md +790 -0
  146. package/es/QueryListScene/Title.js +12 -0
  147. package/es/QueryListScene/Toolbar.js +20 -0
  148. package/es/QueryListScene/createActions.js +72 -0
  149. package/es/QueryListScene/index.js +19 -0
  150. package/es/QueryListScene/index.less +97 -0
  151. package/es/QueryListScene/useActions.js +7 -0
  152. package/es/Select/DropDownWrap.js +116 -0
  153. package/es/Select/README.md +68 -0
  154. package/es/Select/index.js +622 -0
  155. package/es/Table/README.md +109 -0
  156. package/es/Table/ResizableTable/index.js +110 -0
  157. package/es/Table/ResizableTable/index.less +36 -0
  158. package/es/Table/index.js +35 -0
  159. package/es/Title/README.md +106 -0
  160. package/es/Title/index.js +40 -0
  161. package/es/Title/index.less +170 -0
  162. package/es/index.js +19 -0
  163. package/es/locale.js +60 -0
  164. package/package.json +1 -1
  165. package/doc-scripts.config.js +0 -37
  166. package/doc-scripts.renderer.js +0 -11
  167. package/docs/README.md +0 -1643
@@ -0,0 +1,790 @@
1
+ ## QueryListScene查询列表
2
+ 主要用于查询列表页面场景,主要包括三部分: 表单查询、操作工具栏、表格数据展示。组件特点:
3
+ - 标签结构化、语义化,提高代码可读性
4
+ - 样式统一,方便统一维护升级
5
+ - 数据状态管理 + 通用逻辑涵盖(如Loading、分页、切换页码、查询、重置、自动轮询等)
6
+
7
+ ### 安装
8
+ ```
9
+ npm install tntd --save
10
+ ```
11
+
12
+ ### 代码演示
13
+
14
+ ### 展开/收起查询条件
15
+ ```jsx
16
+ import React, { useState, Fragment } from 'react';
17
+ import ReactDOM from 'react-dom';
18
+ import { Button, Popconfirm, Divider, ButtonGroup, TreeSelect, Cascader } from 'antd';
19
+ import { QueryListScene } from 'tntd';
20
+ import { createGlobalStyle } from 'styled-components';
21
+ import 'antd/dist/antd.css';
22
+
23
+ const GlobalStyle = createGlobalStyle`
24
+ .site-body {
25
+ .ichYgh {
26
+ overflow: visible;
27
+ }
28
+ }
29
+ `;
30
+
31
+ const { QueryForm, Field, Toolbar, QueryList, createActions } = QueryListScene;
32
+ const actions = createActions();
33
+
34
+ const ColumnActions = ({ record }) => {
35
+ const onDelete = () => {
36
+ new Promise(resolve => {
37
+ resolve(true);
38
+ }).then(() => {
39
+ actions.search();
40
+ });
41
+ };
42
+
43
+ return (
44
+ <span>
45
+ <a>编辑</a>
46
+ <Divider type="vertical" />
47
+ <Popconfirm
48
+ title="删除确认"
49
+ onConfirm={onDelete}
50
+ okText="确认"
51
+ cancelText="取消"
52
+ >
53
+ <a>删除</a>
54
+ </Popconfirm>
55
+ <Divider type="vertical" />
56
+ <a
57
+ download
58
+ target="__blank"
59
+ href={`/download?id=${record.id}`}
60
+ >
61
+ 下载
62
+ </a>
63
+ </span>
64
+ );
65
+ };
66
+
67
+ const columns = [
68
+ {
69
+ title: 'ID',
70
+ dataIndex: 'id',
71
+ width: 80,
72
+ sorter: true
73
+ },
74
+ {
75
+ title: '项目名称',
76
+ dataIndex: 'name',
77
+ sorter: (a, b) => a.name > b.name
78
+ },
79
+ {
80
+ title: '管理员',
81
+ dataIndex: 'owner',
82
+ width: 100
83
+ },
84
+ {
85
+ title: '创建时间',
86
+ dataIndex: 'createTime',
87
+ width: 200
88
+ },
89
+ {
90
+ title: '状态',
91
+ dataIndex: 'status',
92
+ width: 100
93
+ },
94
+ {
95
+ title: '操作',
96
+ dataIndex: 'operation',
97
+ width: 150,
98
+ render: (val, record) => <ColumnActions record={record} />
99
+ }
100
+ ];
101
+ const query = ({ current = 1, pageSize, ...rest }) => {
102
+ pageSize = pageSize || 10;
103
+ console.log('query params...', rest);
104
+
105
+ return new Promise(resolve => {
106
+ setTimeout(() => {
107
+ resolve({
108
+ current,
109
+ pageSize,
110
+ total: 100,
111
+ data: new Array(100).fill(1).map(
112
+ (item, index) => ({
113
+ id: index + 1,
114
+ name: `项目${index + 1}`,
115
+ owner: `张三${index + 1}`,
116
+ createTime: '2019-09-10 16:30:34',
117
+ status: ['初始化', '运行中', '成功', '失败'][index % 4]
118
+ })
119
+ ).slice((current - 1) * pageSize, current * pageSize)
120
+ });
121
+ }, 500);
122
+ });
123
+ };
124
+
125
+ const ExtraActions = (
126
+ <Button.Group>
127
+ <Button icon="cloud-upload" />
128
+ <Button icon="cloud-download" />
129
+ <Button icon="setting" />
130
+ </Button.Group>
131
+ );
132
+
133
+ ReactDOM.render(
134
+ <QueryListScene
135
+ title="项目管理"
136
+ query={query}
137
+ actions={actions}
138
+ interval={5000}
139
+ >
140
+ <QueryForm
141
+ extraActions={ExtraActions}
142
+ initialValues={{
143
+ name: 'zhangsan',
144
+ status: 'initial'
145
+ }}
146
+ defaultExpanded={true}
147
+ >
148
+ <Field
149
+ name="tree"
150
+ component={TreeSelect}
151
+ props={{
152
+ placeholder: "树形选择",
153
+ dropdownStyle:{
154
+ maxHeight: 400,
155
+ overflow: 'auto'
156
+ },
157
+ treeData: [
158
+ {
159
+ title: 'Node1',
160
+ value: '0-0',
161
+ key: '0-0',
162
+ children: [
163
+ {
164
+ title: 'Child Node1',
165
+ value: '0-0-1',
166
+ key: '0-0-1',
167
+ },
168
+ {
169
+ title: 'Child Node2',
170
+ value: '0-0-2',
171
+ key: '0-0-2',
172
+ },
173
+ ],
174
+ },
175
+ {
176
+ title: 'Node2',
177
+ value: '0-1',
178
+ key: '0-1',
179
+ }
180
+ ]
181
+ }}
182
+ />
183
+ <Field
184
+ type="input"
185
+ name="name"
186
+ props={{
187
+ placeholder: "名称"
188
+ }}
189
+ />
190
+ <Field
191
+ type="select"
192
+ name="status"
193
+ props={{
194
+ placeholder: '状态',
195
+ options: [
196
+ { label: '初始化', value: 'initial' },
197
+ { label: '运行中', value: 'running' },
198
+ { label: '成功', value: 'success', disabled: true },
199
+ { label: '失败', value: 'fail' }
200
+ ]
201
+ }}
202
+ />
203
+ <Field
204
+ type="select"
205
+ name="select1"
206
+ props={{
207
+ placeholder: '状态',
208
+ loadData: () => new Promise(resolve => resolve(['初始化', '运行中', '成功', '失败']))
209
+ }}
210
+ />
211
+ <Field
212
+ type="input"
213
+ name="name2"
214
+ props={{ placeholder: "名称" }}
215
+ />
216
+ <Field
217
+ type="search"
218
+ name="search"
219
+ props={{
220
+ placeholder: '搜索'
221
+ }}
222
+ />
223
+ <Field
224
+ type="select"
225
+ name="select2"
226
+ props={{
227
+ placeholder: '状态',
228
+ options: ['初始化', '运行中', '成功', '失败']
229
+ }}
230
+ />
231
+ <Field type="date" name="date3" />
232
+ <Field type="input" name="field1" />
233
+ <Field type="input" name="field2" />
234
+ <Field type="dateRange" name="date2" />
235
+ </QueryForm>
236
+ <Toolbar>
237
+ <Button type="primary">新增</Button>
238
+ <Button type="warning">删除</Button>
239
+ </Toolbar>
240
+ <QueryList
241
+ resizable={true}
242
+ rowKey="id"
243
+ paginationSticky
244
+ bordered={false}
245
+ columns={columns}
246
+ scroll={{ y: 540 }}
247
+ />
248
+ </QueryListScene>,
249
+ document.getElementById('root')
250
+ )
251
+ ```
252
+
253
+
254
+ ### 抽屉显示更多条件
255
+ ```jsx
256
+ import React, { useState, Fragment } from 'react';
257
+ import ReactDOM from 'react-dom';
258
+ import { Button, Popconfirm, Divider, ButtonGroup, TreeSelect, Cascader, Icon } from 'antd';
259
+ import { QueryListScene } from 'tntd';
260
+ import { createGlobalStyle } from 'styled-components';
261
+ import 'antd/dist/antd.css';
262
+
263
+ const GlobalStyle = createGlobalStyle`
264
+ .site-body {
265
+ .ichYgh {
266
+ overflow: visible;
267
+ }
268
+ }
269
+ `;
270
+
271
+ const { QueryForm, Field, Toolbar, QueryList, createActions } = QueryListScene;
272
+ const actions = createActions();
273
+
274
+ const ColumnActions = ({ record }) => {
275
+ const onDelete = () => {
276
+ new Promise(resolve => {
277
+ resolve(true);
278
+ }).then(() => {
279
+ actions.search();
280
+ });
281
+ };
282
+
283
+ return (
284
+ <span>
285
+ <a>编辑</a>
286
+ <Divider type="vertical" />
287
+ <Popconfirm
288
+ title="删除确认"
289
+ onConfirm={onDelete}
290
+ okText="确认"
291
+ cancelText="取消"
292
+ >
293
+ <a>删除</a>
294
+ </Popconfirm>
295
+ <Divider type="vertical" />
296
+ <a
297
+ download
298
+ target="__blank"
299
+ href={`/download?id=${record.id}`}
300
+ >
301
+ 下载
302
+ </a>
303
+ </span>
304
+ );
305
+ };
306
+
307
+ const columns = [
308
+ {
309
+ title: 'ID',
310
+ dataIndex: 'id',
311
+ width: 80,
312
+ sorter: true
313
+ },
314
+ {
315
+ title: '项目名称',
316
+ dataIndex: 'name',
317
+ sorter: (a, b) => a.name > b.name
318
+ },
319
+ {
320
+ title: '管理员',
321
+ dataIndex: 'owner',
322
+ width: 100
323
+ },
324
+ {
325
+ title: '创建时间',
326
+ dataIndex: 'createTime',
327
+ width: 200
328
+ },
329
+ {
330
+ title: '状态',
331
+ dataIndex: 'status',
332
+ width: 100
333
+ },
334
+ {
335
+ title: '操作',
336
+ dataIndex: 'operation',
337
+ width: 150,
338
+ render: (val, record) => <ColumnActions record={record} />
339
+ }
340
+ ];
341
+ const query = ({ current = 1, pageSize, ...rest }) => {
342
+ pageSize = pageSize || 10;
343
+ console.log('query params...', rest);
344
+
345
+ return new Promise(resolve => {
346
+ setTimeout(() => {
347
+ resolve({
348
+ current,
349
+ pageSize: 10,
350
+ total: 100,
351
+ data: new Array(100).fill(1).map(
352
+ (item, index) => ({
353
+ id: index + 1,
354
+ name: `项目${index + 1}`,
355
+ owner: `张三${index + 1}`,
356
+ createTime: '2019-09-10 16:30:34',
357
+ status: ['初始化', '运行中', '成功', '失败'][index % 4]
358
+ })
359
+ ).slice((current - 1) * pageSize, current * pageSize)
360
+ });
361
+ }, 500);
362
+ });
363
+ };
364
+
365
+ const ExtraActions = (
366
+ <Button.Group>
367
+ <Button icon="cloud-upload" />
368
+ <Button icon="cloud-download" />
369
+ <Button icon="setting" />
370
+ </Button.Group>
371
+ );
372
+
373
+ const QueryListPage = () => {
374
+ return (
375
+ <Fragment>
376
+ <QueryListScene
377
+ title="项目管理"
378
+ query={query}
379
+ actions={actions}
380
+ // interval={5000}
381
+ >
382
+ <QueryForm
383
+ extraActions={ExtraActions}
384
+ // 设置showFieldCount时,则使用抽屉显示更多否则使用展开/收起交互
385
+ showFieldCount={2}
386
+ initialValues={{
387
+ name: 'xxx',
388
+ status: 'initial',
389
+ obj: {
390
+ name: 'zhangsan'
391
+ }
392
+ }}
393
+ >
394
+ <Field
395
+ type="selectInput"
396
+ name="obj"
397
+ props={{
398
+ placeholder: "名称",
399
+ options: [
400
+ { label: '名称', value: 'name' },
401
+ { label: 'ID', value: 'id' }
402
+ ],
403
+ addonBeforeStyle: { width: '100px' }
404
+ }}
405
+ />
406
+ <Field
407
+ name="tree"
408
+ component={TreeSelect}
409
+ props={{
410
+ placeholder: "名称222",
411
+ dropdownStyle:{
412
+ maxHeight: 400,
413
+ overflow: 'auto'
414
+ },
415
+ treeData: [
416
+ {
417
+ title: 'Node1',
418
+ value: '0-0',
419
+ key: '0-0',
420
+ children: [
421
+ {
422
+ title: 'Child Node1',
423
+ value: '0-0-1',
424
+ key: '0-0-1',
425
+ },
426
+ {
427
+ title: 'Child Node2',
428
+ value: '0-0-2',
429
+ key: '0-0-2',
430
+ },
431
+ ],
432
+ },
433
+ {
434
+ title: 'Node2',
435
+ value: '0-1',
436
+ key: '0-1',
437
+ }
438
+ ]
439
+ }}
440
+ />
441
+ <Field
442
+ type="input"
443
+ name="name"
444
+ props={{
445
+ placeholder: "名称"
446
+ }}
447
+ />
448
+ <Field
449
+ name="cascader"
450
+ component={Cascader}
451
+ props={{
452
+ options: [
453
+ {
454
+ value: 'zhejiang',
455
+ label: 'Zhejiang',
456
+ children: [
457
+ {
458
+ value: 'hangzhou',
459
+ label: 'Hangzhou',
460
+ children: [
461
+ {
462
+ value: 'xihu',
463
+ label: 'West Lake'
464
+ }
465
+ ]
466
+ }
467
+ ]
468
+ }
469
+ ]
470
+ }}
471
+ />
472
+ <Field
473
+ type="date"
474
+ name="date1"
475
+ />
476
+ <Field
477
+ title="状态"
478
+ type="select"
479
+ name="status2"
480
+ props={{
481
+ placeholder: '状态',
482
+ options: [
483
+ { label: '初始化', value: 'initial' },
484
+ { label: '运行中', value: 'running' },
485
+ { label: '成功', value: 'success', disabled: true },
486
+ { label: '失败', value: 'fail' }
487
+ ]
488
+ }}
489
+ />
490
+ <Field title="日期" type="date" name="date" />
491
+ <Field
492
+ title="日期范围"
493
+ type="dateRange"
494
+ name="date2"
495
+ />
496
+ <Field
497
+ title="状态"
498
+ type="select"
499
+ name="select1"
500
+ props={{
501
+ placeholder: '状态',
502
+ fieldNames: {
503
+ label: 'displayName',
504
+ value: 'name'
505
+ },
506
+ loadData: () => new Promise(
507
+ resolve => resolve([
508
+ { name: 'success', displayName: '成功' },
509
+ { name: 'fail', displayName: '失败' }
510
+ ])
511
+ )
512
+ }}
513
+ />
514
+ <Field
515
+ title="名称"
516
+ type="input"
517
+ name="name2"
518
+ props={{ placeholder: "名称" }}
519
+ />
520
+ <Field
521
+ title="状态2"
522
+ type="select"
523
+ name="select2"
524
+ props={{
525
+ placeholder: '状态',
526
+ options: ['初始化', '运行中', '成功', '失败']
527
+ }}
528
+ />
529
+ </QueryForm>
530
+ <Toolbar>
531
+ <Button type="primary">新增</Button>
532
+ <Button type="warning">删除</Button>
533
+ </Toolbar>
534
+ <QueryList
535
+ rowKey="id"
536
+ paginationSticky
537
+ bordered={false}
538
+ columns={columns}
539
+ />
540
+ </QueryListScene>
541
+ </Fragment>
542
+ );
543
+ };
544
+
545
+ ReactDOM.render(
546
+ <Fragment>
547
+ <QueryListPage />
548
+ <GlobalStyle />
549
+ </Fragment>,
550
+ document.getElementById('root')
551
+ )
552
+ ```
553
+
554
+
555
+ ### QueryListScene with memory
556
+ - 使用场景: 从列表页跳转到其它页面再回到列表页时会记住查询条件及分页参数。
557
+ - 重置记忆数据:actions.resetMemoryData
558
+
559
+ ```jsx
560
+ import React, { useState, useEffect, Fragment } from 'react';
561
+ import ReactDOM from 'react-dom';
562
+ import { Button } from 'antd';
563
+ import { QueryListScene } from 'tntd';
564
+
565
+ const { QueryForm, Field, Toolbar, QueryList, createActions, useActions } = QueryListScene;
566
+ // const actions = createActions();
567
+
568
+ const QueryListPage = () => {
569
+ const actions = useActions();
570
+ const [visible, setVisible] = useState(true);
571
+ const query = params => {
572
+ params.pageSize = params.pageSize || 10;
573
+ const { current, pageSize } = params;
574
+ console.log('memory query params...', params);
575
+
576
+ return Promise.resolve({
577
+ current,
578
+ pageSize,
579
+ total: 100,
580
+ data: new Array(100).fill(1).map(
581
+ (item, index) => ({
582
+ id: index + 1,
583
+ name: `项目${index + 1}`,
584
+ owner: `张三${index + 1}`,
585
+ createTime: '2019-09-10 16:30:34',
586
+ status: ['初始化', '运行中', '成功', '失败'][index % 4]
587
+ })
588
+ ).slice((current - 1) * pageSize, current * pageSize)
589
+ });
590
+ };
591
+
592
+ // 用法完全和QueryListScene一样
593
+ return (
594
+ <Fragment>
595
+ <Button
596
+ type={visible ? 'danger' : 'primary'}
597
+ onClick={() => setVisible(!visible)}
598
+ >
599
+ {visible ? '销毁列表' : '显示列表'}
600
+ </Button>
601
+ <Button
602
+ onClick={actions.resetMemoryData}
603
+ >
604
+ 重置记忆数据
605
+ </Button>
606
+ {
607
+ visible ? (
608
+ <QueryListScene
609
+ memory
610
+ actions={actions}
611
+ query={query}
612
+ >
613
+ <QueryForm initialValues={{ name: '项目' }}>
614
+ <Field
615
+ name="name"
616
+ type="input"
617
+ props={{
618
+ placeholder: '名称'
619
+ }}
620
+ />
621
+ <Field
622
+ type="select"
623
+ name="status"
624
+ props={{
625
+ placeholder: '状态',
626
+ options: ['初始化', '运行中', '成功', '失败']
627
+ }}
628
+ />
629
+ </QueryForm>
630
+ <QueryList
631
+ resizable={true}
632
+ rowKey="id"
633
+ columns={[
634
+ { dataIndex: 'id', title: 'ID', width: 100, },
635
+ { dataIndex: 'name', title: '名称', width: 200 },
636
+ { dataIndex: 'owner', title: '负责人', width: 100 },
637
+ { dataIndex: 'status', title: '状态' }
638
+ ]}
639
+ />
640
+ </QueryListScene>
641
+ ) : <p style={{ color: 'red' }}>列表已销毁</p>
642
+ }
643
+ </Fragment>
644
+ );
645
+ };
646
+
647
+ ReactDOM.render(
648
+ <QueryListPage />,
649
+ document.getElementById('root')
650
+ )
651
+ ```
652
+
653
+
654
+
655
+ ### API
656
+ #### QueryListScene
657
+
658
+ | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
659
+ | :-------- | :-------------------------------------------------------------------------------- | :------ | :----- | :------- |
660
+ | query | 查询数据方法,调用时会把queryform数据作为参数 | Promise | 无 | 是 |
661
+ | title | 标题 | string | 无 | 否 |
662
+ | actions | 组件上聚合的方法,需由createActions方法创建出来 | Object | 无 | 否 |
663
+ | interval | 轮训时间间隔单位ms,设置该值后列表可自动轮询 | number | 无 | 否 |
664
+ | memory | 组件销毁时是否需要记住表单和分页数据 | boolean | false | 否 |
665
+ | className | css类 | string | 无 | 否 |
666
+ | size | 目前主要设置header高度,默认按照新的设计,如果需要保持原有系统不变,则设置为large | string | 无 | 否 |
667
+
668
+ #### QueryForm
669
+ | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
670
+ | :------------- | :-------------------------------------------------------- | :-------- | :----- | :------- |
671
+ | showFieldCount | 显示在外面的表单数量(尽在“更多条件”在Drawer交互时使用) | number | 无 | 否 |
672
+ | showExpand | 展开/收起功能配置,默认开启 | boolean | true | 否 |
673
+ | showSearch | 搜索按钮显示配置,默认开启 | boolean | true | 否 |
674
+ | showReset | 重置按钮显示配置,默认开启 | boolean | true | 否 |
675
+ | drawerProps | Drawer props(参见antd,设置样式宽度时可用) | Object | 无 | 否 |
676
+ | extraActions | 额外操作 | ReactNode | 无 | 否 |
677
+ | renderActions | 表单操作, 自定义操作按钮,默认是查询、重置 | Function | 无 | 否 |
678
+ | onChange | 表单变化事件,onChange(values, { name, value, preValue }) | Function | 无 | 否 |
679
+ | onReset | 重置按钮点击事件回调,onReset(initialValues) | Function | 无 | 否 |
680
+ | onSearch | 点击搜索按钮事件回调,onSearch(values) | Function | 无 | 否 |
681
+ | onToggleExpand | 展开/收起回调事件,onToggleExpand(expanded) | Function | 无 | 否 |
682
+
683
+
684
+ #### Field
685
+ | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
686
+ | :-------- | :------------------------------------------------------------- | :----- | :----- | :------- |
687
+ | name | 表单项名,保证唯一 | string | 无 | 是 |
688
+ | title | 表单label | string | 无 | 否 |
689
+ | type | 表单类型input、search, number、select、selectInput、 date、 dateRange | 无 | 否 |
690
+ | component | 表单组件,如果内置的type表单组件不满足需求的话,可以直接传ReactNode类型的表单组件,其优先级高于type,如 antd TreeSelect、Cascader等,也可以完全自定义表单组件 | 无 | 否 |
691
+ | props | 表单元素属性,参照antd, Input, InputNumber, Select, DatePicker | Object | 无 | 否 |
692
+ | className | 添加样式class | string | 无 | 否 |
693
+
694
+ type="select", props 扩展了 options, fieldNames, loadData用法如下:
695
+ ```js
696
+ <Field
697
+ type="select"
698
+ name="status"
699
+ props={{
700
+ options: [
701
+ { name: 'success', displayName: '成功' },
702
+ { name: 'fail', displayName: '失败' }
703
+ ],
704
+ fieldNames: {
705
+ label: 'displayName',
706
+ value: 'name'
707
+ }
708
+ }}
709
+ />
710
+ ```
711
+ loadData 是一个function 返回一个promise, 用于异步加载options的场景
712
+ ```js
713
+ <Field
714
+ type="select"
715
+ name="status"
716
+ props={{
717
+ loadData: () => new Promise(
718
+ resolve => resolve([
719
+ { name: 'success', displayName: '成功' },
720
+ { name: 'fail', displayName: '失败' }
721
+ ])
722
+ ),
723
+ fieldNames: {
724
+ label: 'displayName',
725
+ value: 'name'
726
+ }
727
+ }}
728
+ />
729
+ ```
730
+
731
+ type="selectInput", 扩展了addonBeforeStyle属性,用来设置前面Select的样式
732
+ ```js
733
+ <Field
734
+ type="selectInput"
735
+ props={{
736
+ addonBeforeStyle: {
737
+ width: '160px'
738
+ }
739
+ }}
740
+ />
741
+ ```
742
+
743
+ #### Toolbar
744
+
745
+
746
+ #### QueryList
747
+ 同antd Table
748
+
749
+ | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
750
+ | :-------------- | :--------------------------------------------- | :------ | :----- | :------- |
751
+ | resizable | 可伸缩列,设置width的列可拖拽改变列宽度 | boolean | false | 否 |
752
+ | localPagination | 前端分页,数据一次性从接口获取,前端分页时使用 | boolean | false | 否 |
753
+ | paginationSticky | 分页是否吸底(sticky) | boolean | false | 否 |
754
+
755
+ #### createActions
756
+ ```
757
+ const { createActions } = QueryListScene;
758
+ const actions = createActions();
759
+
760
+ actions对象接口如下:
761
+ {
762
+ // 设置查询表单数据(默认自动查询,不需要查询needSearch传false)
763
+ setFormData: (data: Object, needSearch = true),
764
+ // 重置表单数据
765
+ resetFormData: (needSearch = false),
766
+ // 重置记忆数据,form、pagination
767
+ resetMemoryData(),
768
+ // 设置表格数据
769
+ setTableDataSource: (dataSource: Array),
770
+ // 设置分页数据
771
+ setPagination: (
772
+ pagination: Object = {
773
+ current,
774
+ pageSize,
775
+ total
776
+ }
777
+ ),
778
+ // 查询列表, params 为查询参数,会扩展到formData上, showLoading:是否显示loading
779
+ search: (params?: Object, showLoading?: boolean = true),
780
+
781
+ // 获取表单数据,name不传则是整个表单数据对象,传了name则获取单个表单值
782
+ getFormData: (name?: string),
783
+ // 获取当前查询条件的表单数据,与getFormData的区别在于,这里是已执行过查询的数据
784
+ getSubmittedFormData: (name?: string),
785
+ // 获取列表数据
786
+ getTableDataSource: (),
787
+ // 获取分页数据
788
+ getPagination: ()
789
+ }
790
+ ```