@teamias/rex-design 0.1.24 → 0.1.26
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.
- package/dist/components/base-form/demo/DependencyDemo.js +14 -0
- package/dist/components/base-form/modules/renderComponentNode.js +69 -13
- package/dist/components/base-form/types/field-type.d.ts +2 -0
- package/dist/components/base-table/base-table.js +15 -11
- package/dist/components/base-table/demo/VirtualScroll.d.ts +2 -0
- package/dist/components/base-table/demo/VirtualScroll.js +177 -0
- package/dist/components/base-table/demo/VirtualScrollDataCell.d.ts +2 -0
- package/dist/components/base-table/demo/VirtualScrollDataCell.js +196 -0
- package/package.json +1 -1
|
@@ -80,6 +80,20 @@ export default (function () {
|
|
|
80
80
|
field: 'category',
|
|
81
81
|
action: 'clear'
|
|
82
82
|
}]
|
|
83
|
+
}, {
|
|
84
|
+
valueType: 'select',
|
|
85
|
+
field: 'subProduct',
|
|
86
|
+
label: '商品(依赖请求)',
|
|
87
|
+
tooltip: '开启 dependenciesRequest,类别有值后才发起请求,挂载时不会自动请求',
|
|
88
|
+
api: '/products',
|
|
89
|
+
dependenciesRequest: true,
|
|
90
|
+
dependenciesV2: [{
|
|
91
|
+
field: 'category',
|
|
92
|
+
action: 'updateData'
|
|
93
|
+
}, {
|
|
94
|
+
field: 'category',
|
|
95
|
+
action: 'clear'
|
|
96
|
+
}]
|
|
83
97
|
}, {
|
|
84
98
|
valueType: 'input',
|
|
85
99
|
field: 'showField',
|
|
@@ -65,6 +65,25 @@ var getValueTypeMinWidth = function getValueTypeMinWidth(type) {
|
|
|
65
65
|
return 100;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* 判断依赖参数是否就绪
|
|
70
|
+
* - dependenciesV2 updateData: 依赖字段未就绪时跳过请求
|
|
71
|
+
*/
|
|
72
|
+
var areDependenciesReady = function areDependenciesReady(dependenciesRequest, dependencies, params) {
|
|
73
|
+
if (!dependenciesRequest) return true;
|
|
74
|
+
var updateDataFields = dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(function (dep) {
|
|
75
|
+
return dep.action === 'updateData';
|
|
76
|
+
}).map(function (dep) {
|
|
77
|
+
return dep.field;
|
|
78
|
+
});
|
|
79
|
+
if (updateDataFields !== null && updateDataFields !== void 0 && updateDataFields.length) {
|
|
80
|
+
return updateDataFields.every(function (k) {
|
|
81
|
+
return params[k] !== undefined && params[k] !== null && params[k] !== '';
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
};
|
|
86
|
+
|
|
68
87
|
/** 渲染组件项 */
|
|
69
88
|
export var renderComponentNode = function renderComponentNode(outConfig, values, form) {
|
|
70
89
|
var fields = outConfig.fields,
|
|
@@ -345,27 +364,33 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
|
|
|
345
364
|
while (1) switch (_context.prev = _context.next) {
|
|
346
365
|
case 0:
|
|
347
366
|
_ref5 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, keyWords = _ref5.keyWords, params = _objectWithoutProperties(_ref5, _excluded7);
|
|
367
|
+
if (areDependenciesReady(item.dependenciesRequest, item.dependenciesV2, params)) {
|
|
368
|
+
_context.next = 3;
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
return _context.abrupt("return", []);
|
|
372
|
+
case 3:
|
|
348
373
|
key = JSON.stringify(params);
|
|
349
374
|
if (!map[key]) {
|
|
350
|
-
_context.next =
|
|
375
|
+
_context.next = 6;
|
|
351
376
|
break;
|
|
352
377
|
}
|
|
353
378
|
return _context.abrupt("return", map[key]);
|
|
354
|
-
case 4:
|
|
355
|
-
_context.next = 6;
|
|
356
|
-
return requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions(item.api, params, item);
|
|
357
379
|
case 6:
|
|
380
|
+
_context.next = 8;
|
|
381
|
+
return requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions(item.api, params, item);
|
|
382
|
+
case 8:
|
|
358
383
|
_context.t0 = _context.sent;
|
|
359
384
|
if (_context.t0) {
|
|
360
|
-
_context.next =
|
|
385
|
+
_context.next = 11;
|
|
361
386
|
break;
|
|
362
387
|
}
|
|
363
388
|
_context.t0 = [];
|
|
364
|
-
case
|
|
389
|
+
case 11:
|
|
365
390
|
res = _context.t0;
|
|
366
391
|
map[key] = res;
|
|
367
392
|
return _context.abrupt("return", res);
|
|
368
|
-
case
|
|
393
|
+
case 14:
|
|
369
394
|
case "end":
|
|
370
395
|
return _context.stop();
|
|
371
396
|
}
|
|
@@ -412,7 +437,14 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
|
|
|
412
437
|
case 0:
|
|
413
438
|
// 拆分参数,keyWords 为搜索关键字,其余为接口参数
|
|
414
439
|
_params$keyWords = params.keyWords, keyWords = _params$keyWords === void 0 ? '' : _params$keyWords, restParams = _objectWithoutProperties(params, _excluded8);
|
|
415
|
-
newParams = restParams;
|
|
440
|
+
newParams = restParams;
|
|
441
|
+
if (areDependenciesReady(item.dependenciesRequest, item.dependenciesV2, newParams)) {
|
|
442
|
+
_context2.next = 4;
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
return _context2.abrupt("return", []);
|
|
446
|
+
case 4:
|
|
447
|
+
// 处理搜索关键字参数的传递方式
|
|
416
448
|
if (item.apiSearchKey === false) {
|
|
417
449
|
// 配置为 false,默认传 keyWords 字段
|
|
418
450
|
newParams.keyWords = keyWords || undefined;
|
|
@@ -427,7 +459,7 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
|
|
|
427
459
|
|
|
428
460
|
// 发起接口请求,返回选项数据
|
|
429
461
|
return _context2.abrupt("return", (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions(item.api, newParams, item)) || []);
|
|
430
|
-
case
|
|
462
|
+
case 6:
|
|
431
463
|
case "end":
|
|
432
464
|
return _context2.stop();
|
|
433
465
|
}
|
|
@@ -493,8 +525,14 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
|
|
|
493
525
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
494
526
|
while (1) switch (_context3.prev = _context3.next) {
|
|
495
527
|
case 0:
|
|
528
|
+
if (areDependenciesReady(item.dependenciesRequest, item.dependenciesV2, params)) {
|
|
529
|
+
_context3.next = 2;
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
return _context3.abrupt("return", []);
|
|
533
|
+
case 2:
|
|
496
534
|
return _context3.abrupt("return", (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions(item.api, params, item)) || []);
|
|
497
|
-
case
|
|
535
|
+
case 3:
|
|
498
536
|
case "end":
|
|
499
537
|
return _context3.stop();
|
|
500
538
|
}
|
|
@@ -528,8 +566,14 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
|
|
|
528
566
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
529
567
|
while (1) switch (_context4.prev = _context4.next) {
|
|
530
568
|
case 0:
|
|
569
|
+
if (areDependenciesReady(item.dependenciesRequest, item.dependenciesV2, params)) {
|
|
570
|
+
_context4.next = 2;
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
return _context4.abrupt("return", []);
|
|
574
|
+
case 2:
|
|
531
575
|
return _context4.abrupt("return", (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions(item.api, params, item)) || []);
|
|
532
|
-
case
|
|
576
|
+
case 3:
|
|
533
577
|
case "end":
|
|
534
578
|
return _context4.stop();
|
|
535
579
|
}
|
|
@@ -552,8 +596,14 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
|
|
|
552
596
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
553
597
|
while (1) switch (_context5.prev = _context5.next) {
|
|
554
598
|
case 0:
|
|
599
|
+
if (areDependenciesReady(item.dependenciesRequest, item.dependenciesV2, params)) {
|
|
600
|
+
_context5.next = 2;
|
|
601
|
+
break;
|
|
602
|
+
}
|
|
603
|
+
return _context5.abrupt("return", []);
|
|
604
|
+
case 2:
|
|
555
605
|
return _context5.abrupt("return", (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions(item.api, params, item)) || []);
|
|
556
|
-
case
|
|
606
|
+
case 3:
|
|
557
607
|
case "end":
|
|
558
608
|
return _context5.stop();
|
|
559
609
|
}
|
|
@@ -576,8 +626,14 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
|
|
|
576
626
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
577
627
|
while (1) switch (_context6.prev = _context6.next) {
|
|
578
628
|
case 0:
|
|
629
|
+
if (areDependenciesReady(item.dependenciesRequest, item.dependenciesV2, params)) {
|
|
630
|
+
_context6.next = 2;
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
return _context6.abrupt("return", []);
|
|
634
|
+
case 2:
|
|
579
635
|
return _context6.abrupt("return", (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions(item.api, params, item)) || []);
|
|
580
|
-
case
|
|
636
|
+
case 3:
|
|
581
637
|
case "end":
|
|
582
638
|
return _context6.stop();
|
|
583
639
|
}
|
|
@@ -82,6 +82,8 @@ export interface IBaseFormFieldItem<T extends TValueType = TValueType> {
|
|
|
82
82
|
action: Extract<'value' | 'search' | 'visible' | 'disabled', 'search' | 'visible' | 'disabled'>;
|
|
83
83
|
}>;
|
|
84
84
|
dependenciesV2?: IDependenciesV2[];
|
|
85
|
+
/** 开启依赖字段有值才触发 request 请求 */
|
|
86
|
+
dependenciesRequest?: boolean;
|
|
85
87
|
/** 选择项 */
|
|
86
88
|
options?: Array<TOption>;
|
|
87
89
|
/** api接口 */
|
|
@@ -230,26 +230,30 @@ export var BaseTable = function BaseTable(_ref) {
|
|
|
230
230
|
if (loading) return;
|
|
231
231
|
var timer = null;
|
|
232
232
|
var fn = function fn() {
|
|
233
|
-
var contentBodyEl = document.querySelector(".".concat(state.tableKey));
|
|
234
|
-
var bodyEl = contentBodyEl === null || contentBodyEl === void 0 ? void 0 : contentBodyEl.querySelector('tbody');
|
|
235
|
-
// console.log(bodyEl);
|
|
236
|
-
|
|
237
|
-
if (!bodyEl) return;
|
|
238
233
|
if (timer) clearTimeout(timer);
|
|
239
234
|
timer = setTimeout(function () {
|
|
240
235
|
timer = null;
|
|
241
|
-
|
|
236
|
+
// 重新查询,避免使用过期的 DOM 引用
|
|
237
|
+
var el = document.querySelector(".".concat(state.tableKey));
|
|
238
|
+
var tbody = (el === null || el === void 0 ? void 0 : el.querySelector('tbody')) || (el === null || el === void 0 ? void 0 : el.querySelector('.ant-table-tbody'));
|
|
239
|
+
if (!tbody || !el) return;
|
|
240
|
+
var bodyRect = tbody.getBoundingClientRect();
|
|
242
241
|
// 54: 底部padding + 分页高度 + 分页padding
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
242
|
+
var nextScrollHeight = Math.max(window.innerHeight - bodyRect.top - 54, 300);
|
|
243
|
+
var nextTableWidth = el.offsetWidth;
|
|
244
|
+
if (nextScrollHeight === state.scrollHeight && nextTableWidth === state.tableWidth) return;
|
|
245
|
+
state.scrollHeight = nextScrollHeight;
|
|
246
|
+
state.tableWidth = nextTableWidth;
|
|
246
247
|
update();
|
|
247
248
|
}, 0);
|
|
248
249
|
};
|
|
249
250
|
fn();
|
|
250
|
-
|
|
251
|
+
var el = document.querySelector(".".concat(state.tableKey));
|
|
252
|
+
var observer = el ? new ResizeObserver(fn) : null;
|
|
253
|
+
observer === null || observer === void 0 || observer.observe(el);
|
|
251
254
|
return function () {
|
|
252
|
-
|
|
255
|
+
observer === null || observer === void 0 || observer.disconnect();
|
|
256
|
+
if (timer) clearTimeout(timer);
|
|
253
257
|
};
|
|
254
258
|
}, [loading], {
|
|
255
259
|
wait: 0
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { BaseTable } from "../../..";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* title: 虚拟滚动 + onCell 行列合并
|
|
6
|
+
* description: 开启 `virtual` 虚拟滚动渲染海量数据,同时通过 `fieldPropsFn` 为列提供 `onCell`,可实现行合并(rowSpan)和列合并(colSpan)。
|
|
7
|
+
*/
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
var DEPARTMENTS = ['市场部', '技术部', '人事部', '财务部', '运营部'];
|
|
10
|
+
var ROLES = ['销售', '运营', '前端', '后端', '全栈', 'HRBP', '招聘', '财务', '会计', '审计'];
|
|
11
|
+
var CITIES = ['北京', '上海', '广州', '深圳', '杭州', '成都', '武汉', '南京', '天津', '重庆'];
|
|
12
|
+
var STATUSES = ['在职', '离职', '试用期', '待入职'];
|
|
13
|
+
var TOTAL = 10000;
|
|
14
|
+
export default (function () {
|
|
15
|
+
var dataSource = useMemo(function () {
|
|
16
|
+
var deptSize = Math.floor(TOTAL / DEPARTMENTS.length);
|
|
17
|
+
var data = [];
|
|
18
|
+
DEPARTMENTS.forEach(function (dept, di) {
|
|
19
|
+
var count = di === DEPARTMENTS.length - 1 ? TOTAL - data.length - 1 : deptSize;
|
|
20
|
+
for (var n = 0; n < count; n++) {
|
|
21
|
+
var idx = data.length + 1;
|
|
22
|
+
data.push({
|
|
23
|
+
key: "row-".concat(idx),
|
|
24
|
+
category: dept,
|
|
25
|
+
name: "\u5458\u5DE5 ".concat(idx),
|
|
26
|
+
age: 20 + idx % 30,
|
|
27
|
+
department: "".concat(dept).concat(Math.floor(n / 100) + 1, "\u7EC4"),
|
|
28
|
+
role: ROLES[idx % ROLES.length],
|
|
29
|
+
score: 60 + idx % 40,
|
|
30
|
+
city: CITIES[idx % CITIES.length],
|
|
31
|
+
phone: "138".concat(String(idx).padStart(8, '0')),
|
|
32
|
+
email: "user".concat(idx, "@example.com"),
|
|
33
|
+
status: STATUSES[idx % STATUSES.length],
|
|
34
|
+
remark: ''
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// 汇总行
|
|
40
|
+
data.push({
|
|
41
|
+
key: 'summary',
|
|
42
|
+
category: '汇总',
|
|
43
|
+
name: '合计',
|
|
44
|
+
age: 0,
|
|
45
|
+
department: '—',
|
|
46
|
+
role: '—',
|
|
47
|
+
score: 0,
|
|
48
|
+
city: '',
|
|
49
|
+
phone: '',
|
|
50
|
+
email: '',
|
|
51
|
+
status: '',
|
|
52
|
+
remark: "\u5171 ".concat(TOTAL, " \u4EBA")
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// 计算 category 列 rowSpan:相邻相同部门合并
|
|
56
|
+
var i = 0;
|
|
57
|
+
while (i < data.length) {
|
|
58
|
+
var cat = data[i].category;
|
|
59
|
+
var j = i + 1;
|
|
60
|
+
while (j < data.length && data[j].category === cat) j++;
|
|
61
|
+
data[i]._categoryRowSpan = j - i;
|
|
62
|
+
for (var k = i + 1; k < j; k++) data[k]._categoryRowSpan = 0;
|
|
63
|
+
i = j;
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
}, []);
|
|
67
|
+
return /*#__PURE__*/_jsx(BaseTable, {
|
|
68
|
+
useDataCellRender: false,
|
|
69
|
+
virtual: true,
|
|
70
|
+
fieldsConfig: [{
|
|
71
|
+
title: '部门',
|
|
72
|
+
dataIndex: 'category',
|
|
73
|
+
width: 100,
|
|
74
|
+
align: 'center'
|
|
75
|
+
}, {
|
|
76
|
+
title: '姓名',
|
|
77
|
+
dataIndex: 'name',
|
|
78
|
+
width: 100
|
|
79
|
+
}, {
|
|
80
|
+
title: '年龄',
|
|
81
|
+
dataIndex: 'age',
|
|
82
|
+
width: 80,
|
|
83
|
+
align: 'center'
|
|
84
|
+
}, {
|
|
85
|
+
title: '区域',
|
|
86
|
+
dataIndex: 'department',
|
|
87
|
+
width: 120
|
|
88
|
+
}, {
|
|
89
|
+
title: '岗位',
|
|
90
|
+
dataIndex: 'role',
|
|
91
|
+
width: 100
|
|
92
|
+
}, {
|
|
93
|
+
title: '评分',
|
|
94
|
+
dataIndex: 'score',
|
|
95
|
+
width: 80,
|
|
96
|
+
align: 'center'
|
|
97
|
+
}, {
|
|
98
|
+
title: '城市',
|
|
99
|
+
dataIndex: 'city',
|
|
100
|
+
width: 100
|
|
101
|
+
}, {
|
|
102
|
+
title: '手机号',
|
|
103
|
+
dataIndex: 'phone',
|
|
104
|
+
width: 140
|
|
105
|
+
}, {
|
|
106
|
+
title: '邮箱',
|
|
107
|
+
dataIndex: 'email',
|
|
108
|
+
width: 200
|
|
109
|
+
}, {
|
|
110
|
+
title: '状态',
|
|
111
|
+
dataIndex: 'status',
|
|
112
|
+
width: 100,
|
|
113
|
+
align: 'center'
|
|
114
|
+
}, {
|
|
115
|
+
title: '备注',
|
|
116
|
+
dataIndex: 'remark',
|
|
117
|
+
width: 220
|
|
118
|
+
}],
|
|
119
|
+
fieldPropsFn: function fieldPropsFn() {
|
|
120
|
+
return {
|
|
121
|
+
// 行合并:相同部门的行合并为一个单元格
|
|
122
|
+
category: {
|
|
123
|
+
onCell: function onCell(record) {
|
|
124
|
+
var _record$_categoryRowS;
|
|
125
|
+
return {
|
|
126
|
+
rowSpan: (_record$_categoryRowS = record._categoryRowSpan) !== null && _record$_categoryRowS !== void 0 ? _record$_categoryRowS : 1
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
// 列合并:汇总行的 city/phone/email/status 设为 colSpan=0,由 remark 列占据
|
|
131
|
+
city: {
|
|
132
|
+
onCell: function onCell(record) {
|
|
133
|
+
return record.category === '汇总' ? {
|
|
134
|
+
colSpan: 0
|
|
135
|
+
} : {};
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
phone: {
|
|
139
|
+
onCell: function onCell(record) {
|
|
140
|
+
return record.category === '汇总' ? {
|
|
141
|
+
colSpan: 0
|
|
142
|
+
} : {};
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
email: {
|
|
146
|
+
onCell: function onCell(record) {
|
|
147
|
+
return record.category === '汇总' ? {
|
|
148
|
+
colSpan: 0
|
|
149
|
+
} : {};
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
status: {
|
|
153
|
+
onCell: function onCell(record) {
|
|
154
|
+
return record.category === '汇总' ? {
|
|
155
|
+
colSpan: 0
|
|
156
|
+
} : {};
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
// 备注列:汇总行横跨 city/phone/email/status/remark 共 5 列
|
|
160
|
+
remark: {
|
|
161
|
+
onCell: function onCell(record) {
|
|
162
|
+
return record.category === '汇总' ? {
|
|
163
|
+
colSpan: 5
|
|
164
|
+
} : {};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
dataSource: dataSource,
|
|
170
|
+
scroll: function scroll(h) {
|
|
171
|
+
return {
|
|
172
|
+
y: h
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
pagination: false
|
|
176
|
+
});
|
|
177
|
+
});
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { BaseTable } from "../../..";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* title: 虚拟滚动 + DataCell 渲染 + 区域行合并
|
|
6
|
+
* description: 启用 `virtual` 虚拟滚动,同时使用默认的 DataCell 方式渲染单元格,并通过 `fieldPropsFn` 为 `department` 列提供 `onCell`,实现相同区域的行合并(rowSpan)。
|
|
7
|
+
*/
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
var DEPARTMENTS = ['市场部', '技术部', '人事部', '财务部', '运营部'];
|
|
10
|
+
var ROLES = ['销售', '运营', '前端', '后端', '全栈', 'HRBP', '招聘', '财务', '会计', '审计'];
|
|
11
|
+
var CITIES = ['北京', '上海', '广州', '深圳', '杭州', '成都', '武汉', '南京', '天津', '重庆'];
|
|
12
|
+
var STATUSES = ['在职', '离职', '试用期', '待入职'];
|
|
13
|
+
var TOTAL = 10000;
|
|
14
|
+
|
|
15
|
+
/** DataCell 文本单元格格式 */
|
|
16
|
+
var textCell = function textCell(value) {
|
|
17
|
+
return [{
|
|
18
|
+
type: 'text',
|
|
19
|
+
props: {
|
|
20
|
+
value: String(value)
|
|
21
|
+
}
|
|
22
|
+
}];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** DataCell 头像单元格格式 */
|
|
26
|
+
var avatarCell = function avatarCell(idx) {
|
|
27
|
+
return [{
|
|
28
|
+
type: 'img',
|
|
29
|
+
props: {
|
|
30
|
+
value: "https://api.dicebear.com/7.x/miniavs/svg?seed=".concat(idx),
|
|
31
|
+
label: "\u5458\u5DE5 ".concat(idx),
|
|
32
|
+
width: 32,
|
|
33
|
+
height: 32,
|
|
34
|
+
style: {
|
|
35
|
+
borderRadius: '50%'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** DataCell 多维度评分单元格格式 */
|
|
42
|
+
var scoreCell = function scoreCell(base) {
|
|
43
|
+
return [{
|
|
44
|
+
type: 'group-v2',
|
|
45
|
+
props: {
|
|
46
|
+
itemsDirection: 'column',
|
|
47
|
+
itemsGap: 2,
|
|
48
|
+
items: [{
|
|
49
|
+
type: 'text',
|
|
50
|
+
value: "\u7EE9\u6548\u5206\uFF1A".concat(base),
|
|
51
|
+
style: {
|
|
52
|
+
color: '#1677ff'
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
type: 'text',
|
|
56
|
+
value: "\u6280\u672F\u5206\uFF1A".concat(Math.min(base + 5, 100)),
|
|
57
|
+
style: {
|
|
58
|
+
color: '#52c41a'
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
type: 'text',
|
|
62
|
+
value: "\u7EFC\u5408\u5206\uFF1A".concat(Math.round((base + Math.min(base + 5, 100)) / 2)),
|
|
63
|
+
style: {
|
|
64
|
+
color: '#faad14'
|
|
65
|
+
}
|
|
66
|
+
}]
|
|
67
|
+
}
|
|
68
|
+
}];
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** DataCell 标签单元格格式 */
|
|
72
|
+
var tagCell = function tagCell(value) {
|
|
73
|
+
return [{
|
|
74
|
+
type: 'tag',
|
|
75
|
+
props: {
|
|
76
|
+
value: value,
|
|
77
|
+
color: value === '在职' ? 'green' : value === '离职' ? 'red' : value === '试用期' ? 'blue' : 'orange'
|
|
78
|
+
}
|
|
79
|
+
}];
|
|
80
|
+
};
|
|
81
|
+
export default (function () {
|
|
82
|
+
var dataSource = useMemo(function () {
|
|
83
|
+
var deptSize = Math.floor(TOTAL / DEPARTMENTS.length);
|
|
84
|
+
var data = [];
|
|
85
|
+
DEPARTMENTS.forEach(function (dept, di) {
|
|
86
|
+
var count = di === DEPARTMENTS.length - 1 ? TOTAL - data.length : deptSize;
|
|
87
|
+
for (var n = 0; n < count; n++) {
|
|
88
|
+
var idx = data.length + 1;
|
|
89
|
+
var deptGroup = "".concat(dept).concat(Math.floor(n / 100) + 1, "\u7EC4");
|
|
90
|
+
data.push({
|
|
91
|
+
key: "row-".concat(idx),
|
|
92
|
+
_deptGroup: deptGroup,
|
|
93
|
+
avatar: avatarCell(idx),
|
|
94
|
+
name: textCell("\u5458\u5DE5 ".concat(idx)),
|
|
95
|
+
age: textCell(20 + idx % 30),
|
|
96
|
+
category: textCell(dept),
|
|
97
|
+
department: textCell(deptGroup),
|
|
98
|
+
role: textCell(ROLES[idx % ROLES.length]),
|
|
99
|
+
score: scoreCell(60 + idx % 40),
|
|
100
|
+
city: textCell(CITIES[idx % CITIES.length]),
|
|
101
|
+
phone: textCell("138".concat(String(idx).padStart(8, '0'))),
|
|
102
|
+
email: textCell("user".concat(idx, "@example.com")),
|
|
103
|
+
status: tagCell(STATUSES[idx % STATUSES.length]),
|
|
104
|
+
remark: textCell('')
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// 计算 department 列 rowSpan:相邻相同区域合并
|
|
110
|
+
var i = 0;
|
|
111
|
+
while (i < data.length) {
|
|
112
|
+
var grp = data[i]._deptGroup;
|
|
113
|
+
var j = i + 1;
|
|
114
|
+
while (j < data.length && data[j]._deptGroup === grp) j++;
|
|
115
|
+
data[i]._departmentRowSpan = j - i;
|
|
116
|
+
for (var k = i + 1; k < j; k++) data[k]._departmentRowSpan = 0;
|
|
117
|
+
i = j;
|
|
118
|
+
}
|
|
119
|
+
return data;
|
|
120
|
+
}, []);
|
|
121
|
+
return /*#__PURE__*/_jsx(BaseTable, {
|
|
122
|
+
virtual: true,
|
|
123
|
+
fieldsConfig: [{
|
|
124
|
+
title: '头像',
|
|
125
|
+
dataIndex: 'avatar',
|
|
126
|
+
width: 64,
|
|
127
|
+
align: 'center'
|
|
128
|
+
}, {
|
|
129
|
+
title: '姓名',
|
|
130
|
+
dataIndex: 'name',
|
|
131
|
+
width: 100
|
|
132
|
+
}, {
|
|
133
|
+
title: '年龄',
|
|
134
|
+
dataIndex: 'age',
|
|
135
|
+
width: 80,
|
|
136
|
+
align: 'center'
|
|
137
|
+
}, {
|
|
138
|
+
title: '部门',
|
|
139
|
+
dataIndex: 'category',
|
|
140
|
+
width: 100,
|
|
141
|
+
align: 'center'
|
|
142
|
+
}, {
|
|
143
|
+
title: '区域',
|
|
144
|
+
dataIndex: 'department',
|
|
145
|
+
width: 120
|
|
146
|
+
}, {
|
|
147
|
+
title: '岗位',
|
|
148
|
+
dataIndex: 'role',
|
|
149
|
+
width: 100
|
|
150
|
+
}, {
|
|
151
|
+
title: '评分',
|
|
152
|
+
dataIndex: 'score',
|
|
153
|
+
width: 160
|
|
154
|
+
}, {
|
|
155
|
+
title: '城市',
|
|
156
|
+
dataIndex: 'city',
|
|
157
|
+
width: 100
|
|
158
|
+
}, {
|
|
159
|
+
title: '手机号',
|
|
160
|
+
dataIndex: 'phone',
|
|
161
|
+
width: 140
|
|
162
|
+
}, {
|
|
163
|
+
title: '邮箱',
|
|
164
|
+
dataIndex: 'email',
|
|
165
|
+
width: 200
|
|
166
|
+
}, {
|
|
167
|
+
title: '状态',
|
|
168
|
+
dataIndex: 'status',
|
|
169
|
+
width: 100,
|
|
170
|
+
align: 'center'
|
|
171
|
+
}, {
|
|
172
|
+
title: '备注',
|
|
173
|
+
dataIndex: 'remark',
|
|
174
|
+
width: 220
|
|
175
|
+
}],
|
|
176
|
+
fieldPropsFn: function fieldPropsFn() {
|
|
177
|
+
return {
|
|
178
|
+
department: {
|
|
179
|
+
onCell: function onCell(record) {
|
|
180
|
+
var _ref;
|
|
181
|
+
return {
|
|
182
|
+
rowSpan: (_ref = record._departmentRowSpan) !== null && _ref !== void 0 ? _ref : 1
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
dataSource: dataSource,
|
|
189
|
+
scroll: function scroll(h) {
|
|
190
|
+
return {
|
|
191
|
+
y: h
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
pagination: false
|
|
195
|
+
});
|
|
196
|
+
});
|