@kne/table-page 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -84,6 +84,7 @@ npm i --save @kne/table-page
84
84
  | `options` | 操作列,铺满单元格 |
85
85
  | `enum` | 枚举值渲染,自动映射 color/text |
86
86
  | `tag` | 标签渲染,单个 Tag 组件 |
87
+ | `status` | 状态渲染,antd Badge 组件 |
87
88
  | `tagList` | 标签列表渲染,多个 Tag 组件 |
88
89
  | `amount` | 金额列,右对齐,自动省略号 |
89
90
  | `list` | 列表渲染,自动省略号 |
@@ -97,7 +98,7 @@ npm i --save @kne/table-page
97
98
 
98
99
  例如 `renderType: "enum-small"` 表示枚举值 + 小尺寸列。维度(width、min、max、ellipsis)可通过 `globalParams.renderTypeSize` 全局定制。
99
100
 
100
- 默认导出 `getTagColor`、`renderTagItem`、`renderTagList` 工具函数,用于 Tag 相关渲染。
101
+ 默认导出 `getTagColor`、`renderTagItem`、`renderTagList`、`getStatusType`、`renderStatusItem` 工具函数,用于 Tag / Status 相关渲染。
101
102
 
102
103
  ### 其他导出
103
104
 
@@ -123,14 +124,14 @@ npm i --save @kne/table-page
123
124
  #### 示例代码
124
125
 
125
126
  - TablePage
126
- - 表格页面组件,基于 @kne/react-fetch 实现数据加载与分页,支持 useSort 服务端排序、列配置、总结栏等
127
+ - 表格页面组件,基于 @kne/react-fetch 实现数据加载与分页,支持 sticky 固定表头、useSort 服务端排序、列配置、总结栏等
127
128
  - _TablePage(@kne/current-lib_table-page)[import * as _TablePage from "@kne/table-page"],(@kne/current-lib_table-page/dist/index.css),antd(antd),_ReactFilter(@kne/react-filter)[import * as _ReactFilter from "@kne/react-filter"],(@kne/react-filter/dist/index.css)
128
129
 
129
130
  ```jsx
130
131
  const { default: TablePage, Table } = _TablePage;
131
132
  const { fields } = _ReactFilter;
132
133
  const { SuperSelectFilterItem } = fields;
133
- const { Table: AntTable, Flex, Badge, Tag, Button, Space, message } = antd;
134
+ const { Table: AntTable, Flex, Tag, Button, Space, message } = antd;
134
135
  const { useMemo } = React;
135
136
 
136
137
  const TOTAL = 156;
@@ -145,17 +146,17 @@ const educations = ['本科', '硕士', '博士', '大专'];
145
146
  const performances = ['A', 'B', 'C', 'S'];
146
147
 
147
148
  const statusMap = {
148
- active: { color: 'success', text: '在职' },
149
- vacation: { color: 'warning', text: '休假' },
150
- resigned: { color: 'default', text: '离职' },
151
- probation: { color: 'processing', text: '试用期' }
149
+ active: { type: 'success', text: '在职' },
150
+ vacation: { type: 'warning', text: '休假' },
151
+ resigned: { type: 'default', text: '离职' },
152
+ probation: { type: 'processing', text: '试用期' }
152
153
  };
153
154
 
154
155
  const perfMap = {
155
- S: { color: 'success', text: 'S' },
156
- A: { color: 'processing', text: 'A' },
157
- B: { color: 'warning', text: 'B' },
158
- C: { color: 'error', text: 'C' }
156
+ S: { type: 'success', text: 'S' },
157
+ A: { type: 'processing', text: 'A' },
158
+ B: { type: 'warning', text: 'B' },
159
+ C: { type: 'error', text: 'C' }
159
160
  };
160
161
 
161
162
  const departmentOptions = departments.map(item => ({ value: item, label: item }));
@@ -180,23 +181,48 @@ const buildEmployee = index => {
180
181
  };
181
182
  };
182
183
 
183
- const statusRender = value => {
184
- const { color, text } = statusMap[value] || { color: 'default', text: value };
185
- return <Badge status={color} text={text} />;
186
- };
187
-
188
- const perfRender = value => {
189
- const { color, text } = perfMap[value] || { color: 'default', text: value };
190
- return <Tag color={color === 'processing' ? 'blue' : color === 'success' ? 'green' : color === 'warning' ? 'orange' : color === 'error' ? 'red' : 'default'}>{text}</Tag>;
191
- };
192
-
193
184
  const columns = [
194
- { name: 'employeeNo', title: '工号', width: 180, min: 120, max: 240, fixed: 'left', sort: { single: true } },
195
- { name: 'name', title: '姓名', width: 100, min: 80, max: 160, sort: true },
185
+ {
186
+ name: 'employeeNo',
187
+ title: '工号',
188
+ width: 180,
189
+ min: 120,
190
+ max: 240,
191
+ fixed: 'left',
192
+ sort: { single: true },
193
+ renderType: 'main',
194
+ primary: true,
195
+ onClick: ({ item, colItem }) => {
196
+ message.info(&#96;查看员工:${colItem.name}(${item})&#96;);
197
+ }
198
+ },
199
+ {
200
+ name: 'name',
201
+ title: '姓名',
202
+ width: 100,
203
+ min: 80,
204
+ max: 160,
205
+ sort: true,
206
+ renderType: 'main',
207
+ onClick: ({ item, colItem }) =>
208
+ new Promise(resolve => {
209
+ const hide = message.loading(&#96;正在加载 ${item} 的详情…&#96;, 0);
210
+ setTimeout(() => {
211
+ hide();
212
+ message.success(&#96;${colItem.department} · ${colItem.position}&#96;);
213
+ resolve();
214
+ }, 600);
215
+ })
216
+ },
196
217
  { name: 'department', title: '部门', width: 150, min: 120, max: 240, sort: true },
197
218
  { name: 'position', title: '职位', width: 120, min: 100, max: 200 },
198
- { name: 'status', title: '状态', width: 100, min: 80, max: 140, render: statusRender },
199
- { name: 'performance', title: '绩效', width: 80, min: 70, max: 120, render: perfRender },
219
+ {
220
+ name: 'status',
221
+ title: '状态',
222
+ renderType: 'status',
223
+ getValueOf: item => statusMap[item.status] || { type: 'default', text: item.status }
224
+ },
225
+ { name: 'performance', title: '绩效', width: 80, min: 70, max: 120, renderType: 'tag', getValueOf: item => perfMap[item.performance] || { type: 'default', text: item.performance } },
200
226
  { name: 'phone', title: '手机号', width: 140, min: 120, max: 180, render: value => value.replace(/(\d{3})(\d{4})(\d{4})/, '$1-$2-$3') },
201
227
  { name: 'email', title: '邮箱', width: 200, min: 160, max: 320, ellipsis: true },
202
228
  { name: 'joinDate', title: '入职日期', width: 120, min: 100, max: 160, format: 'date', sort: true },
@@ -295,12 +321,20 @@ const Tips = () => (
295
321
  </div>
296
322
  <div>
297
323
  <Tag color="orange">列配置</Tag>
298
- 设置 <code>name</code> 开启列宽拖动与显示/隐藏,「薪资范围」「学历」默认隐藏;操作列使用 <code>renderType="options"</code> 且 <code>fixed="right"</code>。
324
+ 设置 <code>name</code> 开启列宽拖动与显示/隐藏,「薪资范围」「学历」默认隐藏;状态列使用 <code>renderType="status"</code>,绩效列使用 <code>renderType="tag"</code>,操作列使用 <code>renderType="options"</code> 且 <code>fixed="right"</code>。
299
325
  </div>
300
326
  <div>
301
327
  <Tag color="cyan">排序</Tag>
302
328
  配合 <code>Table.useSort</code> 与 <code>sortRender</code>,在 <code>onSortChange</code> 中调用 <code>reload</code> 传排序参数,与翻页一样不闪烁。
303
329
  </div>
330
+ <div>
331
+ <Tag color="geekblue">固定表头</Tag>
332
+ 设置 <code>sticky</code> 与 <code>scroll.y</code>,表体在固定高度内滚动时表头保持可见;横向滚动配合 <code>scroll.x</code>。
333
+ </div>
334
+ <div>
335
+ <Tag color="magenta">单元格点击</Tag>
336
+ 列配置 <code>onClick</code>(配合 <code>renderType="main"</code>、<code>primary</code> / <code>hover</code>),仅可点击单元格 hover 时显示手型;工号列同步演示异步点击 loading。
337
+ </div>
304
338
  <div>
305
339
  <Tag color="purple">总结栏</Tag>
306
340
  <code>summary</code> 回调可拿到 <code>data</code>、<code>requestParams</code> 等 fetch 上下文。
@@ -347,8 +381,8 @@ const BaseExample = () => {
347
381
  ref={tableRef}
348
382
  name="demo-employee-table"
349
383
  sticky
384
+ scroll={{ x: 1600, y: 400 }}
350
385
  sortRender={sortRender}
351
- scroll={{ x: 1600 }}
352
386
  rowSelection={getRowSelection(allEmployees)}
353
387
  selectedRows={selectedRows}
354
388
  search={{ name: 'keyword', label: '关键词', placeholder: '搜索工号/姓名', style: { width: 220 } }}
@@ -446,9 +480,16 @@ render(<BaseExample />);
446
480
 
447
481
  ```jsx
448
482
  const { TableView } = _TablePage;
449
- const { Flex, Tag, Badge } = antd;
483
+ const { Flex, Tag } = antd;
450
484
  const { useState } = React;
451
485
 
486
+ const orderStatusMap = {
487
+ 已完成: { type: 'success', text: '已完成' },
488
+ 处理中: { type: 'processing', text: '处理中' },
489
+ 待发货: { type: 'warning', text: '待发货' },
490
+ 已取消: { type: 'default', text: '已取消' }
491
+ };
492
+
452
493
  const dataSource = [
453
494
  {
454
495
  id: 'ORD20240115001',
@@ -503,23 +544,25 @@ const dataSource = [
503
544
  ];
504
545
 
505
546
  const columns = [
506
- { name: 'id', title: '订单编号', width: 180 },
507
- { name: 'customerName', title: '客户名称', span: 10 },
547
+ { name: 'id', title: '订单编号', width: 180, renderType: 'small' },
548
+ { name: 'customerName', title: '客户名称', span: 10, renderType: 'main' },
508
549
  { name: 'contact', title: '联系人', width: 80 },
509
- { name: 'phone', title: '联系电话', width: '130px', render: (value) => value.replace(/(\d{3})(\d{4})(\d{4})/, '$1-$2-$3') },
510
- { name: 'amount', title: '订单金额(元)', render: (value) => <strong style={{ color: '#f5222d' }}>¥{value.toLocaleString()}</strong> },
550
+ { name: 'phone', title: '联系电话', width: '130px', render: value => value.replace(/(\d{3})(\d{4})(\d{4})/, '$1-$2-$3') },
551
+ {
552
+ name: 'amount',
553
+ title: '订单金额(元)',
554
+ renderType: 'amount',
555
+ format: 'number-style:decimal-maximumFractionDigits:0-useGrouping:true-suffix:元'
556
+ },
511
557
  { name: 'orderDate', title: '下单日期', format: 'date' },
512
558
  { name: 'deliveryDate', title: '预计送达', format: 'date' },
513
- { name: 'status', title: '订单状态', width: 100, render: (value) => {
514
- const config = {
515
- '已完成': { color: 'success', text: '已完成' },
516
- '处理中': { color: 'processing', text: '处理中' },
517
- '待发货': { color: 'warning', text: '待发货' },
518
- '已取消': { color: 'default', text: '已取消' }
519
- };
520
- const { color, text } = config[value] || { color: 'default', text: value };
521
- return <Badge status={color} text={text} />;
522
- }}
559
+ {
560
+ name: 'status',
561
+ title: '订单状态',
562
+ width: 100,
563
+ renderType: 'status',
564
+ getValueOf: item => orderStatusMap[item.status] || { type: 'default', text: item.status }
565
+ }
523
566
  ];
524
567
 
525
568
  const WithCheckbox = () => {
@@ -555,19 +598,22 @@ const WithSelected = () => {
555
598
 
556
599
  const WithColumnWidth = () => {
557
600
  const widthColumns = [
558
- { name: 'id', title: '订单编号', width: 180 },
559
- { name: 'customerName', title: '客户名称', width: '200px' },
560
- { name: 'amount', title: '订单金额(元)', width: 120, render: (value) => <strong style={{ color: '#f5222d' }}>¥{value.toLocaleString()}</strong> },
561
- { name: 'status', title: '订单状态', width: '100px', render: (value) => {
562
- const config = {
563
- '已完成': { color: 'success', text: '已完成' },
564
- '处理中': { color: 'processing', text: '处理中' },
565
- '待发货': { color: 'warning', text: '待发货' },
566
- '已取消': { color: 'default', text: '已取消' }
567
- };
568
- const { color, text } = config[value] || { color: 'default', text: value };
569
- return <Badge status={color} text={text} />;
570
- }}
601
+ { name: 'id', title: '订单编号', width: 180, renderType: 'small' },
602
+ { name: 'customerName', title: '客户名称', width: '200px', renderType: 'main' },
603
+ {
604
+ name: 'amount',
605
+ title: '订单金额(元)',
606
+ width: 120,
607
+ renderType: 'amount',
608
+ format: 'number-style:decimal-maximumFractionDigits:0-useGrouping:true-suffix:元'
609
+ },
610
+ {
611
+ name: 'status',
612
+ title: '订单状态',
613
+ width: '100px',
614
+ renderType: 'status',
615
+ getValueOf: item => orderStatusMap[item.status] || { type: 'default', text: item.status }
616
+ }
571
617
  ];
572
618
  return (
573
619
  <div>
@@ -606,9 +652,16 @@ render(<BaseExample />);
606
652
 
607
653
  ```jsx
608
654
  const { Table } = _TablePage;
609
- const { Flex, Tag, Badge } = antd;
655
+ const { Flex, Tag } = antd;
610
656
  const { useState } = React;
611
657
 
658
+ const orderStatusMap = {
659
+ 已完成: { type: 'success', text: '已完成' },
660
+ 处理中: { type: 'processing', text: '处理中' },
661
+ 待发货: { type: 'warning', text: '待发货' },
662
+ 已取消: { type: 'default', text: '已取消' }
663
+ };
664
+
612
665
  const dataSource = [
613
666
  {
614
667
  id: 'ORD20240115001',
@@ -663,27 +716,25 @@ const dataSource = [
663
716
  ];
664
717
 
665
718
  const columns = [
666
- { name: 'id', title: '订单编号', width: 180 },
667
- { name: 'customerName', title: '客户名称', width: 200 },
719
+ { name: 'id', title: '订单编号', width: 180, renderType: 'small' },
720
+ { name: 'customerName', title: '客户名称', width: 200, renderType: 'main' },
668
721
  { name: 'contact', title: '联系人', width: 80 },
669
722
  { name: 'phone', title: '联系电话', width: 130, render: value => value.replace(/(\d{3})(\d{4})(\d{4})/, '$1-$2-$3') },
670
- { name: 'amount', title: '订单金额(元)', width: 120, render: value => <strong style={{ color: '#f5222d' }}>¥{value.toLocaleString()}</strong> },
723
+ {
724
+ name: 'amount',
725
+ title: '订单金额(元)',
726
+ width: 120,
727
+ renderType: 'amount',
728
+ format: 'number-style:decimal-maximumFractionDigits:0-useGrouping:true-suffix:元'
729
+ },
671
730
  { name: 'orderDate', title: '下单日期', width: 110, format: 'date' },
672
731
  { name: 'deliveryDate', title: '预计送达', width: 110, format: 'date' },
673
732
  {
674
733
  name: 'status',
675
734
  title: '订单状态',
676
735
  width: 100,
677
- render: value => {
678
- const config = {
679
- 已完成: { color: 'success', text: '已完成' },
680
- 处理中: { color: 'processing', text: '处理中' },
681
- 待发货: { color: 'warning', text: '待发货' },
682
- 已取消: { color: 'default', text: '已取消' }
683
- };
684
- const { color, text } = config[value] || { color: 'default', text: value };
685
- return <Badge status={color} text={text} />;
686
- }
736
+ renderType: 'status',
737
+ getValueOf: item => orderStatusMap[item.status] || { type: 'default', text: item.status }
687
738
  }
688
739
  ];
689
740
 
@@ -774,7 +825,14 @@ render(<BaseExample />);
774
825
 
775
826
  ```jsx
776
827
  const { Table, TableView } = _TablePage;
777
- const { Button, Flex, Space, Badge, message } = antd;
828
+ const { Button, Flex, Space, message } = antd;
829
+
830
+ const orderStatusMap = {
831
+ 已完成: { type: 'success', text: '已完成' },
832
+ 处理中: { type: 'processing', text: '处理中' },
833
+ 待发货: { type: 'warning', text: '待发货' },
834
+ 已取消: { type: 'default', text: '已取消' }
835
+ };
778
836
 
779
837
  const dataSource = [
780
838
  {
@@ -820,25 +878,23 @@ const dataSource = [
820
878
  ];
821
879
 
822
880
  const columns = [
823
- { name: 'id', title: '订单编号', width: 180 },
824
- { name: 'customerName', title: '客户名称', width: 220 },
881
+ { name: 'id', title: '订单编号', width: 180, renderType: 'small' },
882
+ { name: 'customerName', title: '客户名称', width: 220, renderType: 'main' },
825
883
  { name: 'contact', title: '联系人', width: 100 },
826
- { name: 'amount', title: '订单金额(元)', width: 130, render: value => <strong style={{ color: '#f5222d' }}>¥{value.toLocaleString()}</strong> },
884
+ {
885
+ name: 'amount',
886
+ title: '订单金额(元)',
887
+ width: 130,
888
+ renderType: 'amount',
889
+ format: 'number-style:decimal-maximumFractionDigits:0-useGrouping:true-suffix:元'
890
+ },
827
891
  { name: 'orderDate', title: '下单日期', width: 120, format: 'date' },
828
892
  {
829
893
  name: 'status',
830
894
  title: '订单状态',
831
895
  width: 100,
832
- render: value => {
833
- const config = {
834
- 已完成: { color: 'success', text: '已完成' },
835
- 处理中: { color: 'processing', text: '处理中' },
836
- 待发货: { color: 'warning', text: '待发货' },
837
- 已取消: { color: 'default', text: '已取消' }
838
- };
839
- const { color, text } = config[value] || { color: 'default', text: value };
840
- return <Badge status={color} text={text} />;
841
- }
896
+ renderType: 'status',
897
+ getValueOf: item => orderStatusMap[item.status] || { type: 'default', text: item.status }
842
898
  }
843
899
  ];
844
900
 
@@ -941,9 +997,16 @@ render(<BaseExample />);
941
997
 
942
998
  ```jsx
943
999
  const { Table, TableView } = _TablePage;
944
- const { Flex, Badge, Tag } = antd;
1000
+ const { Flex, Tag } = antd;
945
1001
  const { useMemo } = React;
946
1002
 
1003
+ const orderStatusMap = {
1004
+ 已完成: { type: 'success', text: '已完成' },
1005
+ 处理中: { type: 'processing', text: '处理中' },
1006
+ 待发货: { type: 'warning', text: '待发货' },
1007
+ 已取消: { type: 'default', text: '已取消' }
1008
+ };
1009
+
947
1010
  const dataSource = [
948
1011
  { id: 'ORD001', customerName: '深圳市腾讯计算机系统有限公司', amount: 42500, status: '已完成', orderDate: '2024-01-15' },
949
1012
  { id: 'ORD002', customerName: '华为技术有限公司', amount: 85000, status: '处理中', orderDate: '2024-01-14' },
@@ -952,23 +1015,25 @@ const dataSource = [
952
1015
  { id: 'ORD005', customerName: '百度在线网络技术(北京)有限公司', amount: 95000, status: '已取消', orderDate: '2024-01-12' }
953
1016
  ];
954
1017
 
955
- const statusRender = value => {
956
- const config = {
957
- 已完成: { color: 'success', text: '已完成' },
958
- 处理中: { color: 'processing', text: '处理中' },
959
- 待发货: { color: 'warning', text: '待发货' },
960
- 已取消: { color: 'default', text: '已取消' }
961
- };
962
- const { color, text } = config[value] || { color: 'default', text: value };
963
- return <Badge status={color} text={text} />;
964
- };
965
-
966
1018
  const columns = [
967
- { name: 'id', title: '订单编号', width: 140, sort: { single: true } },
968
- { name: 'customerName', title: '客户名称', width: 240, sort: true },
969
- { name: 'amount', title: '订单金额(元)', width: 130, sort: true, render: value => <strong style={{ color: '#f5222d' }}>¥{value.toLocaleString()}</strong> },
1019
+ { name: 'id', title: '订单编号', width: 140, sort: { single: true }, renderType: 'small' },
1020
+ { name: 'customerName', title: '客户名称', width: 240, sort: true, renderType: 'main' },
1021
+ {
1022
+ name: 'amount',
1023
+ title: '订单金额(元)',
1024
+ width: 130,
1025
+ sort: true,
1026
+ renderType: 'amount',
1027
+ format: 'number-style:decimal-maximumFractionDigits:0-useGrouping:true-suffix:元'
1028
+ },
970
1029
  { name: 'orderDate', title: '下单日期', width: 120, sort: true, format: 'date' },
971
- { name: 'status', title: '订单状态', width: 100, render: statusRender }
1030
+ {
1031
+ name: 'status',
1032
+ title: '订单状态',
1033
+ width: 100,
1034
+ renderType: 'status',
1035
+ getValueOf: item => orderStatusMap[item.status] || { type: 'default', text: item.status }
1036
+ }
972
1037
  ];
973
1038
 
974
1039
  const SortState = ({ sort }) => (
@@ -1036,12 +1101,19 @@ render(<BaseExample />);
1036
1101
  ```
1037
1102
 
1038
1103
  - column ellipsis
1039
- - ellipsis 配置,基于 antd Typography 实现超出省略与 tooltip 展示
1104
+ - 表头 title 超出列宽自动省略、悬停 tooltip;单元格 ellipsis 配置基于 antd Typography 实现内容省略
1040
1105
  - _TablePage(@kne/current-lib_table-page)[import * as _TablePage from "@kne/table-page"],(@kne/current-lib_table-page/dist/index.css),antd(antd)
1041
1106
 
1042
1107
  ```jsx
1043
1108
  const { Table, TableView } = _TablePage;
1044
- const { Flex, Badge } = antd;
1109
+ const { Flex, Tag } = antd;
1110
+ const { useMemo } = React;
1111
+
1112
+ const orderStatusMap = {
1113
+ 已完成: { type: 'success', text: '已完成' },
1114
+ 处理中: { type: 'processing', text: '处理中' },
1115
+ 待发货: { type: 'warning', text: '待发货' }
1116
+ };
1045
1117
 
1046
1118
  const dataSource = [
1047
1119
  {
@@ -1067,53 +1139,85 @@ const dataSource = [
1067
1139
  }
1068
1140
  ];
1069
1141
 
1070
- const statusRender = value => {
1071
- const config = {
1072
- 已完成: { color: 'success', text: '已完成' },
1073
- 处理中: { color: 'processing', text: '处理中' },
1074
- 待发货: { color: 'warning', text: '待发货' }
1075
- };
1076
- const { color, text } = config[value] || { color: 'default', text: value };
1077
- return <Badge status={color} text={text} />;
1078
- };
1079
-
1080
1142
  const columns = [
1081
- { name: 'id', title: '订单编号', width: 120 },
1143
+ { name: 'id', title: '订单编号(系统流水号)', width: 110, renderType: 'small' },
1082
1144
  {
1083
1145
  name: 'customerName',
1084
- title: '客户名称',
1085
- width: 180,
1146
+ title: '客户名称(签约主体全称)',
1147
+ width: 140,
1148
+ renderType: 'main',
1086
1149
  ellipsis: true
1087
1150
  },
1088
1151
  {
1089
1152
  name: 'remark',
1090
- title: '备注',
1091
- width: 220,
1153
+ title: '备注说明(内部流转备注)',
1154
+ width: 160,
1155
+ renderType: 'description',
1092
1156
  ellipsis: { showTitle: true }
1093
1157
  },
1094
1158
  {
1095
1159
  name: 'amount',
1096
- title: '金额',
1097
- width: 100,
1098
- render: value => &#96;¥${value.toLocaleString()}&#96;
1160
+ title: '订单应付金额(含税,单位:元)',
1161
+ width: 120,
1162
+ sort: true,
1163
+ renderType: 'amount',
1164
+ format: 'number-style:decimal-maximumFractionDigits:0-useGrouping:true-suffix:元'
1099
1165
  },
1100
- { name: 'status', title: '状态', width: 90, render: statusRender }
1166
+ {
1167
+ name: 'status',
1168
+ title: '订单履约状态(业务状态)',
1169
+ width: 100,
1170
+ renderType: 'status',
1171
+ getValueOf: item => orderStatusMap[item.status] || { type: 'default', text: item.status }
1172
+ }
1101
1173
  ];
1102
1174
 
1175
+ const Tips = () => (
1176
+ <div style={{ color: '#666', fontSize: 13, lineHeight: 1.8 }}>
1177
+ <div>
1178
+ <Tag color="blue">表头省略</Tag>
1179
+ 列 <code>title</code> 超出列宽时自动单行省略,悬停 tooltip 显示完整标题;带排序的列同样生效(<code>Table</code> / <code>TableView</code> 均支持,无需额外配置)。
1180
+ </div>
1181
+ <div>
1182
+ <Tag color="green">单元格省略</Tag>
1183
+ 列配置 <code>ellipsis: true</code> 或 <code>ellipsis: {'{ showTitle: true }'}</code>,单元格内容超出时省略,悬停显示完整内容(基于 antd Typography)。
1184
+ </div>
1185
+ <div style={{ color: '#999' }}>
1186
+ 本示例刻意使用较长表头与较窄列宽,便于观察省略与 tooltip 效果;可将鼠标悬停在表头或单元格上查看。
1187
+ </div>
1188
+ </div>
1189
+ );
1190
+
1191
+ const TableExample = () => {
1192
+ const { sort, sortRender } = Table.useSort({});
1193
+ const sortedData = useMemo(() => Table.sortDataSource(dataSource, sort, columns), [sort]);
1194
+
1195
+ return (
1196
+ <div>
1197
+ <div style={{ marginBottom: 8, color: '#666' }}>Table(含排序表头省略)</div>
1198
+ <Table dataSource={sortedData} columns={columns} sortRender={sortRender} scroll={{ x: 700 }} />
1199
+ </div>
1200
+ );
1201
+ };
1202
+
1203
+ const TableViewExample = () => {
1204
+ const { sort, sortRender } = TableView.useSort({});
1205
+ const sortedData = useMemo(() => TableView.sortDataSource(dataSource, sort, columns), [sort]);
1206
+
1207
+ return (
1208
+ <div>
1209
+ <div style={{ marginBottom: 8, color: '#666' }}>TableView(含排序表头省略)</div>
1210
+ <TableView dataSource={sortedData} columns={columns} sortRender={sortRender} />
1211
+ </div>
1212
+ );
1213
+ };
1214
+
1103
1215
  const BaseExample = () => {
1104
1216
  return (
1105
1217
  <Flex vertical gap={24}>
1106
- <div style={{ color: '#666', fontSize: 13 }}>
1107
- 列配置 <code>ellipsis: true</code> 或 <code>ellipsis: {'{ showTitle: true }'}</code>,超出宽度自动省略,悬停显示完整内容(基于 antd Typography)。
1108
- </div>
1109
- <div>
1110
- <div style={{ marginBottom: 8, color: '#666' }}>Table</div>
1111
- <Table dataSource={dataSource} columns={columns} />
1112
- </div>
1113
- <div>
1114
- <div style={{ marginBottom: 8, color: '#666' }}>TableView</div>
1115
- <TableView dataSource={dataSource} columns={columns} />
1116
- </div>
1218
+ <Tips />
1219
+ <TableExample />
1220
+ <TableViewExample />
1117
1221
  </Flex>
1118
1222
  );
1119
1223
  };
@@ -1123,7 +1227,7 @@ render(<BaseExample />);
1123
1227
  ```
1124
1228
 
1125
1229
  - renderType
1126
- - 列 renderType 配置,预设 main / options / enum / description 类型与 short / small / large 尺寸修饰
1230
+ - 列 renderType 配置:main / amount / tag / status / tagList / list / options / description / enum,支持与 short / small / large 尺寸修饰组合;配合 getValueOf、format、onClick 等列属性
1127
1231
  - _TablePage(@kne/current-lib_table-page)[import * as _TablePage from "@kne/table-page"],(@kne/current-lib_table-page/dist/index.css),antd(antd)
1128
1232
 
1129
1233
  ```jsx
@@ -1210,7 +1314,7 @@ const columns = [
1210
1314
  {
1211
1315
  name: 'status',
1212
1316
  title: '状态',
1213
- renderType: 'tag',
1317
+ renderType: 'status',
1214
1318
  getValueOf: item => statusMap[item.status]
1215
1319
  },
1216
1320
  {
@@ -1239,9 +1343,25 @@ const columns = [
1239
1343
  const BaseExample = () => {
1240
1344
  return (
1241
1345
  <Flex vertical gap={24}>
1242
- <div style={{ color: '#666', fontSize: 13 }}>
1243
- 列配置 <code>renderType</code> 支持 <code>main</code> / <code>amount</code> / <code>tag</code> / <code>tagList</code> / <code>list</code> / <code>options</code> / <code>description</code> 等类型,可与尺寸修饰词组合(如 <code>tag-short</code>、<code>main-small</code>)。
1244
- 通过 <code>getValueOf</code> 返回 render 所需的数据结构,通过 <code>format</code> 做展示格式化(如金额)。
1346
+ <div style={{ color: '#666', fontSize: 13, lineHeight: 1.8 }}>
1347
+ <p>
1348
+ 列配置 <code>renderType</code> 声明列的渲染方式,无需手写 <code>render</code>。内置类型:
1349
+ </p>
1350
+ <ul style={{ margin: '8px 0', paddingLeft: 20 }}>
1351
+ <li><code>main</code> — 主信息列,支持 <code>primary</code> / <code>hover</code> / <code>onClick</code></li>
1352
+ <li><code>amount</code> — 金额列,右对齐,配合 <code>format</code> 格式化</li>
1353
+ <li><code>tag</code> — 单个 Tag,<code>getValueOf</code> 返回 <code>{'{ type, text }'}</code></li>
1354
+ <li><code>status</code> — 状态 Badge,<code>getValueOf</code> 返回 <code>{'{ type, text }'}</code></li>
1355
+ <li><code>tagList</code> — 多个 Tag 列表</li>
1356
+ <li><code>list</code> — 文本列表,可用 <code>split</code> 指定分隔符</li>
1357
+ <li><code>options</code> — 操作列,<code>getValueOf</code> 返回按钮配置数组</li>
1358
+ <li><code>description</code> — 长文本描述列</li>
1359
+ <li><code>enum</code> — 枚举值映射渲染</li>
1360
+ </ul>
1361
+ <p>
1362
+ 可与尺寸修饰词组合:<code>short</code> / <code>small</code> / <code>large</code>(如 <code>tag-short</code>、<code>status-small</code>、<code>main-large</code>)。
1363
+ 通过 <code>getValueOf</code> 传入 render 所需数据结构,通过 <code>format</code> 做日期、金额等展示格式化。
1364
+ </p>
1245
1365
  </div>
1246
1366
  <div>
1247
1367
  <div style={{ marginBottom: 8, color: '#666' }}>Table</div>
@@ -1265,7 +1385,14 @@ render(<BaseExample />);
1265
1385
 
1266
1386
  ```jsx
1267
1387
  const { Table } = _TablePage;
1268
- const { Flex, Badge, Tag } = antd;
1388
+ const { Flex, Tag } = antd;
1389
+
1390
+ const orderStatusMap = {
1391
+ 已完成: { type: 'success', text: '已完成' },
1392
+ 处理中: { type: 'processing', text: '处理中' },
1393
+ 待发货: { type: 'warning', text: '待发货' },
1394
+ 已取消: { type: 'default', text: '已取消' }
1395
+ };
1269
1396
 
1270
1397
  const dataSource = [
1271
1398
  {
@@ -1314,27 +1441,32 @@ const dataSource = [
1314
1441
  }
1315
1442
  ];
1316
1443
 
1317
- const statusRender = value => {
1318
- const config = {
1319
- 已完成: { color: 'success', text: '已完成' },
1320
- 处理中: { color: 'processing', text: '处理中' },
1321
- 待发货: { color: 'warning', text: '待发货' },
1322
- 已取消: { color: 'default', text: '已取消' }
1323
- };
1324
- const { color, text } = config[value] || { color: 'default', text: value };
1325
- return <Badge status={color} text={text} />;
1326
- };
1327
-
1328
1444
  const columns = [
1329
- { name: 'id', title: '订单编号', width: 160, min: 120, max: 240, fixed: 'left' },
1330
- { name: 'customerName', title: '客户名称', width: 200, min: 140, max: 360 },
1445
+ { name: 'id', title: '订单编号', width: 160, min: 120, max: 240, fixed: 'left', renderType: 'small' },
1446
+ { name: 'customerName', title: '客户名称', width: 200, min: 140, max: 360, renderType: 'main' },
1331
1447
  { name: 'contact', title: '联系人', width: 90, min: 70, max: 160 },
1332
1448
  { name: 'phone', title: '联系电话', width: 130, min: 110, max: 180, render: value => value.replace(/(\d{3})(\d{4})(\d{4})/, '$1-$2-$3') },
1333
- { name: 'amount', title: '订单金额(元)', width: 130, min: 100, max: 200, render: value => <strong style={{ color: '#f5222d' }}>¥{value.toLocaleString()}</strong> },
1449
+ {
1450
+ name: 'amount',
1451
+ title: '订单金额(元)',
1452
+ width: 130,
1453
+ min: 100,
1454
+ max: 200,
1455
+ renderType: 'amount',
1456
+ format: 'number-style:decimal-maximumFractionDigits:0-useGrouping:true-suffix:元'
1457
+ },
1334
1458
  { name: 'orderDate', title: '下单日期', width: 110, min: 90, max: 160, format: 'date' },
1335
1459
  { name: 'deliveryDate', title: '预计送达', width: 110, min: 90, max: 160, format: 'date' },
1336
- { name: 'status', title: '订单状态', width: 100, min: 80, max: 140, render: statusRender },
1337
- { name: 'remark', title: '备注', width: 200, min: 120, max: 400, hidden: true, ellipsis: true }
1460
+ {
1461
+ name: 'status',
1462
+ title: '订单状态',
1463
+ width: 100,
1464
+ min: 80,
1465
+ max: 140,
1466
+ renderType: 'status',
1467
+ getValueOf: item => orderStatusMap[item.status] || { type: 'default', text: item.status }
1468
+ },
1469
+ { name: 'remark', title: '备注', width: 200, min: 120, max: 400, hidden: true, renderType: 'description' }
1338
1470
  ];
1339
1471
 
1340
1472
  const Tips = () => (
@@ -1465,6 +1597,7 @@ const columns = [
1465
1597
  name: 'productName',
1466
1598
  title: '产品名称',
1467
1599
  width: 150,
1600
+ renderType: 'main',
1468
1601
  groupHeader: [{ name: 'product', title: '产品信息' }]
1469
1602
  },
1470
1603
  {