cloud-b2b 1.1.52 → 1.1.54
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/es/Area/Area.js +141 -0
- package/es/Card/Card.js +19 -0
- package/es/CodeInput/CodeInput.js +123 -0
- package/es/Control/Control.js +444 -0
- package/es/Control/event.js +43 -0
- package/es/Enhance/Dialogs.js +52 -0
- package/es/Enhance/Loading.js +131 -0
- package/{src → es}/Enhance/index.js +6 -8
- package/es/Header/Header.js +162 -0
- package/es/Header/Vertical.js +106 -0
- package/es/ImageView/ImageView.js +100 -0
- package/es/Indent/Indent.js +19 -0
- package/es/InpurCascader/InputCascader.js +108 -0
- package/es/InputEditor/InputEditor.js +173 -0
- package/es/InputSearch/InputSearch.js +266 -0
- package/es/InputSelect/InputSelect.js +160 -0
- package/es/InputTreeSelect/InputTreeSelect.js +121 -0
- package/es/InputWriting/InputWriting.js +85 -0
- package/es/Layout/Layout.js +201 -0
- package/es/LayoutLink/LayoutLink.js +73 -0
- package/es/Link/Link.js +85 -0
- package/es/Loading/Loading.js +13 -0
- package/es/Loading2/Loading2.js +9 -0
- package/es/ModalWithDrag/ModalWithDrag.js +29 -0
- package/{src → es}/ModalWithDrag/drag.js +116 -128
- package/es/NumberInput/NumberInput.js +200 -0
- package/es/Search/Search.js +497 -0
- package/es/Sidebar/Sidebar.js +144 -0
- package/es/Sidebar2/Sidebar.js +165 -0
- package/es/SuperForm/SuperForm.js +598 -0
- package/es/SuperForm2/SuperForm.js +687 -0
- package/es/SuperIcon/SuperIcon.js +27 -0
- package/es/SuperPagination/SuperPagination.js +109 -0
- package/es/SuperTab/SuperTab.js +107 -0
- package/es/SuperTab2/SuperTab2.js +145 -0
- package/es/SuperTable/DragSortRow.js +97 -0
- package/es/SuperTable/FilterDropDown.js +164 -0
- package/es/SuperTable/SuperTable.js +808 -0
- package/es/SuperTable/fixed.js +34 -0
- package/es/SuperTable2/SuperTable2.js +894 -0
- package/es/SuperTable2/SuperTableCell.js +198 -0
- package/es/SuperTable3/FilterDropDown.js +164 -0
- package/es/SuperTable3/SuperTable.js +665 -0
- package/es/SuperTable3/fixed.js +34 -0
- package/es/SuperToolbar/SuperToolbar.js +195 -0
- package/es/SuperUpload/SuperUpload.js +356 -0
- package/es/Title/Title.js +33 -0
- package/es/Viewer/ImageViews.js +258 -0
- package/es/Viewer/Viewer.js +122 -0
- package/es/WingBlank/WingBlank.js +16 -0
- package/es/helper.js +240 -0
- package/{src → es}/history.js +6 -6
- package/es/index.js +37 -0
- package/es/variables.js +6 -0
- package/lib/Area/Area.js +149 -0
- package/lib/Area/package.json +6 -0
- package/lib/Card/Card.js +27 -0
- package/lib/Card/package.json +6 -0
- package/lib/CodeInput/CodeInput.js +131 -0
- package/lib/CodeInput/package.json +6 -0
- package/lib/Control/Control.js +450 -0
- package/lib/Control/event.js +51 -0
- package/lib/Control/package.json +6 -0
- package/lib/Enhance/Dialogs.js +60 -0
- package/lib/Enhance/Loading.js +138 -0
- package/lib/Enhance/index.js +25 -0
- package/lib/Enhance/package.json +6 -0
- package/lib/Header/Header.js +169 -0
- package/lib/Header/Header.less +95 -0
- package/lib/Header/Vertical.js +114 -0
- package/lib/Header/Vertical.less +60 -0
- package/lib/Header/package.json +6 -0
- package/lib/ImageView/ImageView.js +108 -0
- package/lib/ImageView/ImageView.less +14 -0
- package/lib/ImageView/package.json +6 -0
- package/lib/Indent/Indent.js +27 -0
- package/lib/Indent/package.json +6 -0
- package/lib/InpurCascader/InputCascader.js +115 -0
- package/lib/InpurCascader/package.json +6 -0
- package/lib/InputEditor/InputEditor.js +181 -0
- package/lib/InputEditor/inputEditor.less +8 -0
- package/lib/InputEditor/package.json +6 -0
- package/lib/InputSearch/InputSearch.js +274 -0
- package/lib/InputSearch/package.json +6 -0
- package/lib/InputSelect/InputSelect.js +168 -0
- package/lib/InputSelect/package.json +6 -0
- package/lib/InputTreeSelect/InputTreeSelect.js +128 -0
- package/lib/InputTreeSelect/package.json +6 -0
- package/lib/InputWriting/InputWriting.js +93 -0
- package/lib/InputWriting/package.json +6 -0
- package/lib/Layout/Layout.js +209 -0
- package/lib/Layout/Layout.less +28 -0
- package/lib/Layout/package.json +6 -0
- package/lib/LayoutLink/LayoutLink.js +86 -0
- package/lib/LayoutLink/LayoutLink.less +53 -0
- package/lib/LayoutLink/package.json +6 -0
- package/lib/Link/Link.js +93 -0
- package/lib/Link/package.json +6 -0
- package/lib/Loading/Loading.js +21 -0
- package/lib/Loading/Loading.less +13 -0
- package/lib/Loading/package.json +6 -0
- package/lib/Loading2/Loading2.js +17 -0
- package/lib/Loading2/Loading2.less +19 -0
- package/lib/Loading2/package.json +6 -0
- package/lib/ModalWithDrag/ModalWithDrag.js +37 -0
- package/lib/ModalWithDrag/ModalWithDrag.less +6 -0
- package/lib/ModalWithDrag/drag.js +124 -0
- package/lib/ModalWithDrag/package.json +6 -0
- package/lib/NumberInput/NumberInput.js +208 -0
- package/lib/NumberInput/package.json +6 -0
- package/lib/Search/Search.js +510 -0
- package/lib/Search/Search.less +63 -0
- package/lib/Search/package.json +6 -0
- package/lib/Sidebar/Sidebar.js +152 -0
- package/lib/Sidebar/Sidebar.less +78 -0
- package/lib/Sidebar/package.json +6 -0
- package/lib/Sidebar2/Sidebar.js +173 -0
- package/lib/Sidebar2/Sidebar.less +153 -0
- package/lib/Sidebar2/package.json +6 -0
- package/lib/SuperForm/SuperForm.js +610 -0
- package/lib/SuperForm/SuperForm.less +52 -0
- package/lib/SuperForm/package.json +6 -0
- package/lib/SuperForm2/SuperForm.js +699 -0
- package/lib/SuperForm2/SuperForm.less +52 -0
- package/lib/SuperForm2/package.json +6 -0
- package/lib/SuperIcon/SuperIcon.js +35 -0
- package/lib/SuperIcon/package.json +6 -0
- package/lib/SuperPagination/SuperPagination.js +117 -0
- package/lib/SuperPagination/package.json +6 -0
- package/lib/SuperTab/SuperTab.js +115 -0
- package/lib/SuperTab/SuperTab.less +43 -0
- package/lib/SuperTab/package.json +6 -0
- package/lib/SuperTab2/SuperTab2.js +153 -0
- package/lib/SuperTab2/SuperTab2.less +18 -0
- package/lib/SuperTab2/package.json +6 -0
- package/lib/SuperTable/DragSortRow.js +105 -0
- package/lib/SuperTable/DragSortRow.less +17 -0
- package/lib/SuperTable/FilterDropDown.js +172 -0
- package/lib/SuperTable/FilterDropDown.less +30 -0
- package/lib/SuperTable/SuperTable.js +816 -0
- package/lib/SuperTable/SuperTable.less +132 -0
- package/lib/SuperTable/fixed.js +42 -0
- package/lib/SuperTable/package.json +6 -0
- package/lib/SuperTable2/SuperTable2.js +907 -0
- package/lib/SuperTable2/SuperTable2.less +118 -0
- package/lib/SuperTable2/SuperTableCell.js +203 -0
- package/lib/SuperTable2/package.json +6 -0
- package/lib/SuperTable3/FilterDropDown.js +172 -0
- package/lib/SuperTable3/FilterDropDown.less +29 -0
- package/lib/SuperTable3/SuperTable.js +673 -0
- package/lib/SuperTable3/SuperTable.less +99 -0
- package/lib/SuperTable3/fixed.js +42 -0
- package/lib/SuperTable3/package.json +6 -0
- package/lib/SuperToolbar/SuperToolbar.js +203 -0
- package/lib/SuperToolbar/SuperToolbar.less +17 -0
- package/lib/SuperToolbar/package.json +6 -0
- package/lib/SuperUpload/SuperUpload.js +368 -0
- package/lib/SuperUpload/SuperUpload.less +28 -0
- package/lib/SuperUpload/package.json +6 -0
- package/lib/Title/Title.js +41 -0
- package/lib/Title/Title.less +35 -0
- package/lib/Title/package.json +6 -0
- package/lib/Viewer/ImageViews.js +266 -0
- package/lib/Viewer/Viewer.js +130 -0
- package/lib/Viewer/Viewer.less +67 -0
- package/lib/Viewer/imgView.less +59 -0
- package/lib/Viewer/package.json +7 -0
- package/lib/WingBlank/WingBlank.js +24 -0
- package/lib/WingBlank/WingBlank.less +12 -0
- package/lib/WingBlank/package.json +6 -0
- package/lib/adjust.less +89 -0
- package/lib/helper.js +246 -0
- package/lib/history.js +12 -0
- package/lib/index.js +271 -0
- package/lib/index.less +31 -0
- package/lib/style.less +30 -0
- package/lib/variables.js +14 -0
- package/lib/variables.less +73 -0
- package/package.json +22 -44
- package/src/Area/Area.js +0 -94
- package/src/Card/Card.js +0 -16
- package/src/CodeInput/CodeInput.js +0 -76
- package/src/Control/Control.js +0 -338
- package/src/Control/event.js +0 -45
- package/src/Enhance/Dialogs.js +0 -24
- package/src/Enhance/Loading.js +0 -83
- package/src/Header/Header.js +0 -149
- package/src/Header/Vertical.js +0 -74
- package/src/ImageView/ImageView.js +0 -62
- package/src/Indent/Indent.js +0 -12
- package/src/InpurCascader/InputCascader.js +0 -83
- package/src/InputEditor/InputEditor.js +0 -93
- package/src/InputSearch/InputSearch.js +0 -186
- package/src/InputSelect/InputSelect.js +0 -103
- package/src/InputTreeSelect/InputTreeSelect.js +0 -87
- package/src/InputWriting/InputWriting.js +0 -65
- package/src/Layout/Layout.js +0 -121
- package/src/LayoutLink/LayoutLink.js +0 -59
- package/src/Link/Link.js +0 -57
- package/src/Loading/Loading.js +0 -15
- package/src/Loading2/Loading2.js +0 -15
- package/src/ModalWithDrag/ModalWithDrag.js +0 -17
- package/src/NumberInput/NumberInput.js +0 -137
- package/src/Search/Search.js +0 -368
- package/src/Sidebar/Sidebar.js +0 -111
- package/src/Sidebar2/Sidebar.js +0 -143
- package/src/SuperForm/SuperForm.js +0 -516
- package/src/SuperForm2/SuperForm.js +0 -588
- package/src/SuperIcon/SuperIcon.js +0 -14
- package/src/SuperPagination/SuperPagination.js +0 -65
- package/src/SuperTab/SuperTab.js +0 -84
- package/src/SuperTab2/SuperTab2.js +0 -94
- package/src/SuperTable/DragSortRow.js +0 -62
- package/src/SuperTable/FilterDropDown.js +0 -111
- package/src/SuperTable/SuperTable.js +0 -590
- package/src/SuperTable/fixed.js +0 -34
- package/src/SuperTable2/SuperTable2.js +0 -600
- package/src/SuperTable2/SuperTableCell.js +0 -144
- package/src/SuperTable3/FilterDropDown.js +0 -111
- package/src/SuperTable3/SuperTable.js +0 -498
- package/src/SuperTable3/fixed.js +0 -34
- package/src/SuperToolbar/SuperToolbar.js +0 -128
- package/src/SuperUpload/SuperUpload.js +0 -137
- package/src/Title/Title.js +0 -18
- package/src/Viewer/ImageViews.js +0 -220
- package/src/Viewer/Viewer.js +0 -97
- package/src/WingBlank/WingBlank.js +0 -14
- package/src/helper.js +0 -185
- package/src/index.js +0 -38
- package/src/variables.js +0 -5
- package/test/index.html +0 -10
- package/test/test.js +0 -16
- package/test/test.less +0 -12
- package/test/webpack.config.js +0 -71
- package/tools/babel.config.js +0 -14
- package/tools/build.js +0 -70
- package/tools/publish.js +0 -9
- package/tools/util.js +0 -53
- /package/{src → es}/Area/package.json +0 -0
- /package/{src → es}/Card/package.json +0 -0
- /package/{src → es}/CodeInput/package.json +0 -0
- /package/{src → es}/Control/package.json +0 -0
- /package/{src → es}/Enhance/package.json +0 -0
- /package/{src → es}/Header/Header.less +0 -0
- /package/{src → es}/Header/Vertical.less +0 -0
- /package/{src → es}/Header/package.json +0 -0
- /package/{src → es}/ImageView/ImageView.less +0 -0
- /package/{src → es}/ImageView/package.json +0 -0
- /package/{src → es}/Indent/package.json +0 -0
- /package/{src → es}/InpurCascader/package.json +0 -0
- /package/{src → es}/InputEditor/inputEditor.less +0 -0
- /package/{src → es}/InputEditor/package.json +0 -0
- /package/{src → es}/InputSearch/package.json +0 -0
- /package/{src → es}/InputSelect/package.json +0 -0
- /package/{src → es}/InputTreeSelect/package.json +0 -0
- /package/{src → es}/InputWriting/package.json +0 -0
- /package/{src → es}/Layout/Layout.less +0 -0
- /package/{src → es}/Layout/package.json +0 -0
- /package/{src → es}/LayoutLink/LayoutLink.less +0 -0
- /package/{src → es}/LayoutLink/package.json +0 -0
- /package/{src → es}/Link/package.json +0 -0
- /package/{src → es}/Loading/Loading.less +0 -0
- /package/{src → es}/Loading/package.json +0 -0
- /package/{src → es}/Loading2/Loading2.less +0 -0
- /package/{src → es}/Loading2/package.json +0 -0
- /package/{src → es}/ModalWithDrag/ModalWithDrag.less +0 -0
- /package/{src → es}/ModalWithDrag/package.json +0 -0
- /package/{src → es}/NumberInput/package.json +0 -0
- /package/{src → es}/Search/Search.less +0 -0
- /package/{src → es}/Search/package.json +0 -0
- /package/{src → es}/Sidebar/Sidebar.less +0 -0
- /package/{src → es}/Sidebar/package.json +0 -0
- /package/{src → es}/Sidebar2/Sidebar.less +0 -0
- /package/{src → es}/Sidebar2/package.json +0 -0
- /package/{src → es}/SuperForm/SuperForm.less +0 -0
- /package/{src → es}/SuperForm/package.json +0 -0
- /package/{src → es}/SuperForm2/SuperForm.less +0 -0
- /package/{src → es}/SuperForm2/package.json +0 -0
- /package/{src → es}/SuperIcon/package.json +0 -0
- /package/{src → es}/SuperPagination/package.json +0 -0
- /package/{src → es}/SuperTab/SuperTab.less +0 -0
- /package/{src → es}/SuperTab/package.json +0 -0
- /package/{src → es}/SuperTab2/SuperTab2.less +0 -0
- /package/{src → es}/SuperTab2/package.json +0 -0
- /package/{src → es}/SuperTable/DragSortRow.less +0 -0
- /package/{src → es}/SuperTable/FilterDropDown.less +0 -0
- /package/{src → es}/SuperTable/SuperTable.less +0 -0
- /package/{src → es}/SuperTable/package.json +0 -0
- /package/{src → es}/SuperTable2/SuperTable2.less +0 -0
- /package/{src → es}/SuperTable2/package.json +0 -0
- /package/{src → es}/SuperTable3/FilterDropDown.less +0 -0
- /package/{src → es}/SuperTable3/SuperTable.less +0 -0
- /package/{src → es}/SuperTable3/package.json +0 -0
- /package/{src → es}/SuperToolbar/SuperToolbar.less +0 -0
- /package/{src → es}/SuperToolbar/package.json +0 -0
- /package/{src → es}/SuperUpload/SuperUpload.less +0 -0
- /package/{src → es}/SuperUpload/package.json +0 -0
- /package/{src → es}/Title/Title.less +0 -0
- /package/{src → es}/Title/package.json +0 -0
- /package/{src → es}/Viewer/Viewer.less +0 -0
- /package/{src → es}/Viewer/imgView.less +0 -0
- /package/{src → es}/Viewer/package.json +0 -0
- /package/{src → es}/WingBlank/WingBlank.less +0 -0
- /package/{src → es}/WingBlank/package.json +0 -0
- /package/{src → es}/adjust.less +0 -0
- /package/{src → es}/style.less +0 -0
- /package/{src → es}/variables.less +0 -0
|
@@ -1,590 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import ReactDOM from 'react-dom';
|
|
4
|
-
import {getTitle} from '../Control';
|
|
5
|
-
import {Table, Tooltip} from 'antd';
|
|
6
|
-
import FilterDropDown from './FilterDropDown';
|
|
7
|
-
import fixed from './fixed';
|
|
8
|
-
import DragSortRow from './DragSortRow';
|
|
9
|
-
import variables from '../variables';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* sorter: [可选],不传表示该列不支持排序;为string表示按字符串排序;为number表示按数字大小排序
|
|
13
|
-
* filter: [可选],是否支持过滤,默认为false
|
|
14
|
-
* link: [可选],为true表示超链接,内容来至items;为字符串表示超链接,内容就是该字符串;为字符串‘list’表示超链接数组,内容就是该items对应key对象数组的linkTitleKey属性拼接
|
|
15
|
-
* linkTitleKey: [可选],当link为'list'表示超链接组时,该值表示要拼接展示的属性key值
|
|
16
|
-
* isDateFilterByStartAndEnd: [可选],为true时做过滤操作会显示时间段搜索,默认为false
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
const ColType = {
|
|
20
|
-
key: PropTypes.string.isRequired,
|
|
21
|
-
title: PropTypes.string,
|
|
22
|
-
align: PropTypes.oneOf(['left', 'center', 'right']),
|
|
23
|
-
sorter: PropTypes.oneOf(['string', 'number']),
|
|
24
|
-
filter: PropTypes.bool,
|
|
25
|
-
hide: PropTypes.bool,
|
|
26
|
-
options: PropTypes.array,
|
|
27
|
-
link: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
28
|
-
linkTitleKey: PropTypes.string,
|
|
29
|
-
noWrap: PropTypes.bool,
|
|
30
|
-
isDateFilterByStartAndEnd: PropTypes.bool,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const ItemType = {
|
|
34
|
-
checked: PropTypes.bool
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* onCheck:点击复选框时触发,原型func(isAll, checked, rowIndex);isolation为true时,原型为onCheck(checkedRows)
|
|
39
|
-
* onRadio: 点击单选按钮时触发,原型为func(checkedRows)
|
|
40
|
-
* onDoubleClick: 行双击时触发,原型func(rowIndex)
|
|
41
|
-
* onLink: 点击超链接时触发,原型为func(key, rowIndex, item)
|
|
42
|
-
* onTableChange: 排序信息改变时触发,原型为func(sortInfo, filterInfo)
|
|
43
|
-
* onMoveRow:行拖曳排序时触发,原型为func(dragIndex, targetIndex)
|
|
44
|
-
*/
|
|
45
|
-
const CallbackType = {
|
|
46
|
-
onCheck: PropTypes.func,
|
|
47
|
-
onRadio: PropTypes.func,
|
|
48
|
-
onDoubleClick: PropTypes.func,
|
|
49
|
-
onLink: PropTypes.func,
|
|
50
|
-
onTableChange: PropTypes.func,
|
|
51
|
-
onMoveRow: PropTypes.func
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* checkbox: [可选],是否有复选框,默认为true
|
|
56
|
-
* isPaging: [可选],是否分页,默认为false
|
|
57
|
-
* radio: [可选],是否为单选按钮,当checkbox为true时生效,默认值为false
|
|
58
|
-
* isolation: [可选],为true时,复选框的选中行采用checkedRows存储
|
|
59
|
-
* checkedRows: [可选],选中的行数,radio为true时生效
|
|
60
|
-
* index: [可选],是否有序号,默认值为true
|
|
61
|
-
* indexTitle:[可选],序号标题,默认为'序号'
|
|
62
|
-
* sortInfo: [可选],排序信息,默认为null
|
|
63
|
-
* filterInfo: [可选],过滤信息,默认为null
|
|
64
|
-
* maxHeight: [可选],设置表格的最大高度
|
|
65
|
-
* dragSort: [可选], 为true表示支持行拖曳排序,且不支持行单击选中复选或单选按钮和双击事件,默认为false
|
|
66
|
-
* isEmphasized: [可选],是否强调,行字体加粗显示;要实现字体加粗显示除了isEmphasized设置为true之外,加粗行数据里要设置__isEmphasized为true
|
|
67
|
-
* isWeaken: [可选],是否弱化行字体置灰显示,除了isWeaken设置为true之外,置灰行数据里要设置__isWeaken为true
|
|
68
|
-
* pageTotal: [可选], 为true表示开启表格末行自动汇总表格列数据,默认为false || searchTotal,当开启时,需要汇总的列需设置属性total为true,当dragSort为true时,该选项失效
|
|
69
|
-
* searchTotal: [可选], 表格汇总数据对象,该属性不为空时pageTotal默认开启,当dragSort为true时,该选项失效
|
|
70
|
-
*/
|
|
71
|
-
class SuperTable extends React.Component {
|
|
72
|
-
static propTypes = {
|
|
73
|
-
cols: PropTypes.arrayOf(PropTypes.shape(ColType)).isRequired,
|
|
74
|
-
items: PropTypes.arrayOf(PropTypes.shape(ItemType)).isRequired,
|
|
75
|
-
isPaging:PropTypes.bool,
|
|
76
|
-
checkbox: PropTypes.bool,
|
|
77
|
-
radio: PropTypes.bool,
|
|
78
|
-
isolation: PropTypes.bool,
|
|
79
|
-
checkedRows: PropTypes.array,
|
|
80
|
-
index: PropTypes.bool,
|
|
81
|
-
indexTitle: PropTypes.string,
|
|
82
|
-
sortInfo: PropTypes.object,
|
|
83
|
-
filterInfo: PropTypes.object,
|
|
84
|
-
maxHeight: PropTypes.string,
|
|
85
|
-
callback: PropTypes.shape(CallbackType),
|
|
86
|
-
isEmphasized: PropTypes.bool,
|
|
87
|
-
isWeaken: PropTypes.bool,
|
|
88
|
-
dragSort: PropTypes.bool,
|
|
89
|
-
pageTotal: PropTypes.bool,
|
|
90
|
-
searchTotal: PropTypes.object,
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
state = {filterVisibleKey: ''};
|
|
94
|
-
|
|
95
|
-
onTableChange = (pagination, filters, sorter) => {
|
|
96
|
-
const {onTableChange} = this.props.callback || {};
|
|
97
|
-
const {filterInfo=null} = this.props;
|
|
98
|
-
onTableChange && onTableChange(sorter, filterInfo);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
onChange = (selectedKeyArr=[]) => {
|
|
102
|
-
const {onCheck} = this.props.callback || {};
|
|
103
|
-
if (onCheck) {
|
|
104
|
-
const {items=[], isWeaken=false, pageTotal, searchTotal} = this.props;
|
|
105
|
-
let offset = 0;
|
|
106
|
-
pageTotal && offset--;
|
|
107
|
-
searchTotal && offset--;
|
|
108
|
-
const realSlectedList = selectedKeyArr.length > items.length ? selectedKeyArr.slice(0, selectedKeyArr.length + offset) : selectedKeyArr;
|
|
109
|
-
const selectedKeys = isWeaken ? realSlectedList.filter(o => !items[o].__isWeaken) : realSlectedList;
|
|
110
|
-
const newItems = isWeaken ? items.filter(o => !o.__isWeaken) : items;
|
|
111
|
-
if (selectedKeys.length === 0) {
|
|
112
|
-
onCheck(true, false, -1);
|
|
113
|
-
} else if (selectedKeys.length === newItems.length) {
|
|
114
|
-
const checked = newItems.every(o => o.checked);
|
|
115
|
-
onCheck(true, !checked, -1);
|
|
116
|
-
} else {
|
|
117
|
-
const defaultSelectedKeys = this.getSelectedRowKeys(newItems);
|
|
118
|
-
if (selectedKeys.length > defaultSelectedKeys.length) {
|
|
119
|
-
if (this.props.isPaging && selectedKeys.length - defaultSelectedKeys.length > 1) {
|
|
120
|
-
return onCheck(true, true, -1);
|
|
121
|
-
}
|
|
122
|
-
onCheck(false, true, selectedKeys[selectedKeys.length - 1]);
|
|
123
|
-
} else {
|
|
124
|
-
const index = defaultSelectedKeys.findIndex(key => !selectedKeys.some(select => select === key));
|
|
125
|
-
onCheck(false, false, defaultSelectedKeys[index]);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
onCheckChange = (selectedKeys) => {
|
|
132
|
-
const {onCheck} = this.props.callback || {};
|
|
133
|
-
onCheck && onCheck(selectedKeys);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
onRadioChange = (selectedKeys) => {
|
|
137
|
-
const {onRadio} = this.props.callback || {};
|
|
138
|
-
onRadio && onRadio(selectedKeys);
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
onRadioRowClick = (record) => {
|
|
142
|
-
const {onRadio} = this.props.callback || {};
|
|
143
|
-
onRadio && onRadio([record.key]);
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
onRowClick = (record) => {
|
|
147
|
-
const {isWeaken=false, items} = this.props;
|
|
148
|
-
if (items.length <= record.key) return;
|
|
149
|
-
clearTimeout(this.timer);
|
|
150
|
-
this.timer = setTimeout(() => {
|
|
151
|
-
const {onCheck} = this.props.callback || {};
|
|
152
|
-
if (onCheck) {
|
|
153
|
-
const {isolation, checkedRows=[]} = this.props;
|
|
154
|
-
if (isolation) {
|
|
155
|
-
if (checkedRows.includes(record.key)) {
|
|
156
|
-
onCheck(checkedRows.filter(key => record.key !== key));
|
|
157
|
-
} else {
|
|
158
|
-
onCheck(checkedRows.concat(record.key));
|
|
159
|
-
}
|
|
160
|
-
} else {
|
|
161
|
-
const checked = isWeaken && items[record.key].__isWeaken ? false : !record.checked;
|
|
162
|
-
onCheck(false, checked, record.key);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}, 250);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
onDoubleClick = (record) => {
|
|
169
|
-
clearTimeout(this.timer);
|
|
170
|
-
const {onDoubleClick} = this.props.callback || {};
|
|
171
|
-
onDoubleClick && onDoubleClick(record.key);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
onLink = (key, index, item, e) => {
|
|
175
|
-
const {onLink} = this.props.callback || {};
|
|
176
|
-
onLink && onLink(key, index, item);
|
|
177
|
-
e.stopPropagation();
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
onLinkDouble = (e) => {
|
|
181
|
-
e.stopPropagation();
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
onMoveRow = (dragIndex, targetIndex) => {
|
|
185
|
-
const {onMoveRow} = this.props.callback || {};
|
|
186
|
-
onMoveRow && onMoveRow(dragIndex, targetIndex);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
getSelectedRowKeys = (items) => {
|
|
190
|
-
return items.reduce((result, item, index) => {
|
|
191
|
-
item.checked && result.push(index);
|
|
192
|
-
return result;
|
|
193
|
-
}, []);
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
getIndexInfo = (items=[]) => {
|
|
197
|
-
const {index=true, indexTitle='序号'} = this.props;
|
|
198
|
-
return index ? [{key: 'index', title: indexTitle, render: (text, record, index) => (items[record.key].__totalIndexTitle || index + 1)}] : [];
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
setSortInfo = (col, sortInfo) => {
|
|
202
|
-
if (col.sorter === 'string') {
|
|
203
|
-
col.sortOrder = sortInfo.columnKey === col.key && sortInfo.order;
|
|
204
|
-
col.sorter = (row1, row2) => {
|
|
205
|
-
const a = !col.link ? row1[col.key] : row1[col.key].props.children;
|
|
206
|
-
const b = !col.link ? row2[col.key] : row2[col.key].props.children;
|
|
207
|
-
if (a > b) {
|
|
208
|
-
return 1;
|
|
209
|
-
} else if (a === b) {
|
|
210
|
-
return 0;
|
|
211
|
-
} else {
|
|
212
|
-
return -1;
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
} else if (col.sorter === 'number') {
|
|
216
|
-
col.sortOrder = sortInfo.columnKey === col.key && sortInfo.order;
|
|
217
|
-
col.sorter = (a, b) => a[col.key] - b[col.key];
|
|
218
|
-
} else {
|
|
219
|
-
delete col.sorter;
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
setFilterInfo = (col, filterInfo, visibleKey) => {
|
|
224
|
-
if (col.filter) {
|
|
225
|
-
const {isDateFilterByStartAndEnd=false} = col;
|
|
226
|
-
const onSearch = (value) => {
|
|
227
|
-
const {onTableChange} = this.props.callback || {};
|
|
228
|
-
const {sortInfo=null} = this.props;
|
|
229
|
-
const newFilterInfo = Object.assign({}, filterInfo, {[col.key]: value});
|
|
230
|
-
this.setState({filterVisibleKey: ''});
|
|
231
|
-
onTableChange && onTableChange(sortInfo, newFilterInfo);
|
|
232
|
-
};
|
|
233
|
-
const value = filterInfo[col.key];
|
|
234
|
-
col.filteredValue = value ? [value] : null;
|
|
235
|
-
col.filterDropdownVisible = visibleKey === col.key;
|
|
236
|
-
const onClose = () => {
|
|
237
|
-
this.setState({filterVisibleKey: ''});
|
|
238
|
-
};
|
|
239
|
-
col.filterDropdown = <FilterDropDown {...{value, onSearch, onClose, isDateFilterByStartAndEnd}} />;
|
|
240
|
-
col.onFilterDropdownVisibleChange = (visible) => {
|
|
241
|
-
if (isDateFilterByStartAndEnd) {
|
|
242
|
-
visible && this.setState({filterVisibleKey: col.key});
|
|
243
|
-
} else {
|
|
244
|
-
this.setState({filterVisibleKey: visible ? col.key : ''});
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
col.onFilter = (value, record) => {
|
|
248
|
-
const items = this.getItems();
|
|
249
|
-
if (items[record.key].__total) return true;
|
|
250
|
-
const content = !col.link ? record[col.key] : record[col.key].props.children;
|
|
251
|
-
if(!col.isDateFilterByStartAndEnd){
|
|
252
|
-
const con = Array.isArray(content) ? content : String(content);
|
|
253
|
-
return con.includes(value);
|
|
254
|
-
} else {
|
|
255
|
-
return !((value.start && new Date(value.start) > new Date(content)) || (value.end && value.end < content));
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
delete col.filter;
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
linkList = (key, index, item, linkTitleKey='fileName') => {
|
|
263
|
-
const list = item[key] || [];
|
|
264
|
-
return (
|
|
265
|
-
<div>
|
|
266
|
-
{list.map((item2, index2) => {
|
|
267
|
-
const split = index2 === list.length-1 ? '' : ',';
|
|
268
|
-
const onClick = this.onLink.bind(null, key, index, item2);
|
|
269
|
-
return <a key={index2} onClick={onClick} onDoubleClick={this.onLinkDouble}>{`${item2[linkTitleKey]}${split}`}</a>;
|
|
270
|
-
})}
|
|
271
|
-
</div>
|
|
272
|
-
)
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
waring = (key,index,item,warningKey) => {
|
|
276
|
-
const text = item[key] ? item[key] : '';
|
|
277
|
-
const color = item[warningKey] == 1 ?'red' :'rgba(0, 0, 0, 0.65)';
|
|
278
|
-
return (
|
|
279
|
-
<div>
|
|
280
|
-
<p style={{color:color}}>{text.title ? text.title : text}</p>
|
|
281
|
-
</div>
|
|
282
|
-
)
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
defaultList = (key,index,item,text,link) => {
|
|
286
|
-
const onClick = this.onLink.bind(null, key, index, item);
|
|
287
|
-
if (link && (typeof link === 'string')) {
|
|
288
|
-
return <a onClick={onClick} onDoubleClick={this.onLinkDouble}>{text}</a>;
|
|
289
|
-
}
|
|
290
|
-
return (
|
|
291
|
-
<div>
|
|
292
|
-
<p>{text}</p>
|
|
293
|
-
</div>
|
|
294
|
-
)
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
getColumns = (cols, items) => {
|
|
298
|
-
const {sortInfo, filterInfo} = this.props;
|
|
299
|
-
const {filterVisibleKey} = this.state;
|
|
300
|
-
return this.getIndexInfo(items).concat(cols.filter(col => !col.hide)).map(({...col}) => {
|
|
301
|
-
col.dataIndex = col.key;
|
|
302
|
-
col.className = col.key === 'index' ? 'ant-table-selection-column' : (col.align ? variables('SuperTable')[col.align] : '');
|
|
303
|
-
col.noWrap && (col.className = variables('SuperTable').noWrap);
|
|
304
|
-
this.setSortInfo(col, sortInfo || {});
|
|
305
|
-
this.setFilterInfo(col, filterInfo || {}, filterVisibleKey);
|
|
306
|
-
|
|
307
|
-
if(col.defaultValue){
|
|
308
|
-
col.render = (text, record, index) => this.defaultList(col.key, index, items[index],col.defaultValue,col.link)
|
|
309
|
-
}else if (col.link === 'list') {
|
|
310
|
-
col.render = (text, record, index) => this.linkList(col.key, index, items[index], col.linkTitleKey);
|
|
311
|
-
}else if (col.link && (typeof col.link === 'string')) {
|
|
312
|
-
col.render = (text, record, index) => this.link(col.key, index, items[index], col.link);
|
|
313
|
-
}else if(col.isWarning){
|
|
314
|
-
col.render = (text, record, index) => this.waring(col.key, index, items[index],col.warningKey);
|
|
315
|
-
}else if (col.tooltip) {
|
|
316
|
-
col.render = (text, record, index) => this.tooltip(col.key, index, items[index], col);
|
|
317
|
-
}
|
|
318
|
-
return col;
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
getText = (value, options) => {
|
|
323
|
-
if (Array.isArray(value)) {
|
|
324
|
-
return value.map(v => getTitle(v, options)).toString();
|
|
325
|
-
} else {
|
|
326
|
-
return getTitle(value, options);
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
link = (key, index, item, text) => {
|
|
331
|
-
const onClick = this.onLink.bind(null, key, index, item);
|
|
332
|
-
return <a onClick={onClick} onDoubleClick={this.onLinkDouble}>{text}</a>;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
tooltip = (key, index, item, {tooltip:tipLen, options}) => {
|
|
336
|
-
const text = this.getText(item[key], options);
|
|
337
|
-
const needTip = tipLen > 1 && text && typeof text === 'string' && text.length > tipLen;
|
|
338
|
-
return needTip ? (
|
|
339
|
-
<Tooltip title={text}>
|
|
340
|
-
<span>{text.slice(0, tipLen) + '...'}</span>
|
|
341
|
-
</Tooltip>
|
|
342
|
-
) : <span>{Array.isArray(text) ? text.join(',') : text}</span>;
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
getImgSrc = (value, options) => {
|
|
346
|
-
const index = options.findIndex(obj => obj.value == value);
|
|
347
|
-
return index === -1 ? null : options[index].img;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
*
|
|
352
|
-
* @param item{array}:列数据
|
|
353
|
-
* @param key{string}:字段key
|
|
354
|
-
* @param options{array}:字段options
|
|
355
|
-
* @param dataSource{string,array}:数据源,如果列数据有多层则用此决定
|
|
356
|
-
*/
|
|
357
|
-
getSourceText = (item,key,options,dataSource) => {
|
|
358
|
-
let value = {};
|
|
359
|
-
if(typeof dataSource === 'string'){
|
|
360
|
-
value = item[dataSource] || {};
|
|
361
|
-
}else if(Array.isArray(dataSource)){
|
|
362
|
-
dataSource.forEach((source,index) => {
|
|
363
|
-
/*如果字段重复则用dataSource取到结果,key不作为取字段的标准*/
|
|
364
|
-
if(index === 0){
|
|
365
|
-
value = item[source] || {};
|
|
366
|
-
}else {
|
|
367
|
-
value = value[source] || {}
|
|
368
|
-
}
|
|
369
|
-
})
|
|
370
|
-
}
|
|
371
|
-
/*如果上面已经取到结果则不进入*/
|
|
372
|
-
if(typeof value !== 'string'){
|
|
373
|
-
value = value[key];
|
|
374
|
-
}
|
|
375
|
-
return this.getText(value, options);
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
getDataSource = (items, cols) => {
|
|
380
|
-
return items.map((item, index) => {
|
|
381
|
-
return cols.reduce((result, {key, options, link, icon,dataSource}) => {
|
|
382
|
-
if (link) {
|
|
383
|
-
if (typeof link === 'boolean') {
|
|
384
|
-
result[key] = this.link(key, index, item, this.getText(item[key], options));
|
|
385
|
-
}
|
|
386
|
-
} else if (icon) { //单独的icon列,icon=true数据值根据options获得显示的图片url
|
|
387
|
-
const src = this.getImgSrc(item[key], options);
|
|
388
|
-
const onClick = this.onLink.bind(null, key, index, item);
|
|
389
|
-
result[key] = src ? <img src={src} onClick={onClick} /> : '';
|
|
390
|
-
} else if(dataSource){
|
|
391
|
-
result[key] = this.getSourceText(item,key,options,dataSource);
|
|
392
|
-
}else {
|
|
393
|
-
result[key] = this.getText(item[key], options);
|
|
394
|
-
}
|
|
395
|
-
return result;
|
|
396
|
-
}, {key: index, checked: !!item.checked});
|
|
397
|
-
});
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
getPropsByCheckbox = (items) => {
|
|
401
|
-
const {checkbox=true, radio=false, isolation, checkedRows=[],isEmphasized=false, isWeaken=true} = this.props;
|
|
402
|
-
const rowClassName1 = (record) => {
|
|
403
|
-
if (items[record.key].__total) return variables('SuperTable').totalRow;
|
|
404
|
-
if(items[record.key].__warningRow) return variables('SuperTable').warningRow;
|
|
405
|
-
return checkedRows.includes(record.key) ? variables('SuperTable').select : '';
|
|
406
|
-
};
|
|
407
|
-
const rowClassName2 = (record) => {
|
|
408
|
-
if (items[record.key].__total) return variables('SuperTable').totalRow;
|
|
409
|
-
if(items[record.key].__warningRow) return variables('SuperTable').warningRow;
|
|
410
|
-
if (isEmphasized && items[record.key].__isEmphasized) {
|
|
411
|
-
return items[record.key].checked ? variables('SuperTable').emphasizedSelectRow : variables('SuperTable').emphasizedUnselectRow;
|
|
412
|
-
}
|
|
413
|
-
if (isWeaken && items[record.key].__isWeaken) {
|
|
414
|
-
return items[record.key].checked ? variables('SuperTable').weakenedSelectRow : variables('SuperTable').weakenedUnselectRow;
|
|
415
|
-
}
|
|
416
|
-
return items[record.key].checked ? variables('SuperTable').select : '';
|
|
417
|
-
};
|
|
418
|
-
if (checkbox) {
|
|
419
|
-
if (radio) {
|
|
420
|
-
return {
|
|
421
|
-
rowClassName: rowClassName1,
|
|
422
|
-
onRowClick: this.onRadioRowClick,
|
|
423
|
-
rowSelection: {
|
|
424
|
-
type: 'radio',
|
|
425
|
-
selectedRowKeys: checkedRows,
|
|
426
|
-
onChange: this.onRadioChange
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
} else if (isolation) {
|
|
430
|
-
return {
|
|
431
|
-
rowClassName: rowClassName1,
|
|
432
|
-
onRowClick: this.onRowClick,
|
|
433
|
-
rowSelection: {
|
|
434
|
-
selectedRowKeys: checkedRows,
|
|
435
|
-
onChange: this.onCheckChange,
|
|
436
|
-
getCheckboxProps: (record) => {
|
|
437
|
-
const checked = checkedRows.includes(record.key);
|
|
438
|
-
return {
|
|
439
|
-
checked,
|
|
440
|
-
disabled: items[record.key].__isWeaken,
|
|
441
|
-
style: items[record.key].__total ? {display: 'none'} : {}
|
|
442
|
-
}
|
|
443
|
-
},
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
} else {
|
|
447
|
-
return {
|
|
448
|
-
rowClassName: rowClassName2,
|
|
449
|
-
onRowClick: this.onRowClick,
|
|
450
|
-
rowSelection: {
|
|
451
|
-
selectedRowKeys: this.getSelectedRowKeys(items),
|
|
452
|
-
onChange: this.onChange,
|
|
453
|
-
getCheckboxProps: (record) => {
|
|
454
|
-
const checked = isWeaken && items[record.key].__isWeaken ? false : !!record.checked;
|
|
455
|
-
return {
|
|
456
|
-
checked,
|
|
457
|
-
disabled: items[record.key].__isWeaken,
|
|
458
|
-
style: items[record.key].__total ? {display: 'none'} : {}
|
|
459
|
-
}
|
|
460
|
-
},
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
} else {
|
|
465
|
-
return {
|
|
466
|
-
rowClassName: rowClassName2,
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
getRowProps = (onRowClick) => {
|
|
472
|
-
return (record) => {
|
|
473
|
-
return {
|
|
474
|
-
onClick: () => onRowClick && onRowClick(record),
|
|
475
|
-
onDoubleClick: () => this.onDoubleClick(record)
|
|
476
|
-
};
|
|
477
|
-
};
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
getRowPropsForDrag = () => {
|
|
481
|
-
return (record, index) => {
|
|
482
|
-
return {
|
|
483
|
-
index,
|
|
484
|
-
onMoveRow: this.onMoveRow
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
getItems = () => {
|
|
490
|
-
const {items, cols, dragSort = false, pageTotal = false, searchTotal} = this.props;
|
|
491
|
-
let resItems = items;
|
|
492
|
-
if (!dragSort && items.length > 1) {
|
|
493
|
-
if (pageTotal || searchTotal) {
|
|
494
|
-
const totalItem = cols.reduce((result, {key, total=false}) => {
|
|
495
|
-
if (total) {
|
|
496
|
-
result[key] = parseFloat(Number(items.reduce((result, item) => parseFloat(String(item[key] || 0)) + result, 0)).toFixed(4));
|
|
497
|
-
}
|
|
498
|
-
return result;
|
|
499
|
-
}, {__total: true, __totalIndexTitle: '本页汇总'});
|
|
500
|
-
resItems = resItems.concat([totalItem]);
|
|
501
|
-
}
|
|
502
|
-
if (searchTotal) {
|
|
503
|
-
resItems = resItems.concat([{...searchTotal, __total: true, __totalIndexTitle: '查询汇总'}]);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
return resItems;
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
toTotalFooter = () => {
|
|
510
|
-
const {cols, items, isolation, checkedRows} = this.props;
|
|
511
|
-
const totalCols = cols.filter(item => item.total);
|
|
512
|
-
if (totalCols.length > 0) {
|
|
513
|
-
const checkedItems = isolation ? items.filter((item, index) => checkedRows.includes(index)) : items.filter(item => item.checked);
|
|
514
|
-
const countItems = checkedItems.length ? checkedItems : items;
|
|
515
|
-
const totalItems = totalCols.map(({title, key, props={}}) => {
|
|
516
|
-
const value = countItems.reduce((result, item) => parseFloat((result + Number(item[key] || 0)).toFixed(props.precision || 6)), 0);
|
|
517
|
-
return {title, value};
|
|
518
|
-
});
|
|
519
|
-
return (
|
|
520
|
-
<div style={{height: '36px',lineHeight: '36px'}}>
|
|
521
|
-
<span style={{marginRight: `15px`}}>{checkedItems.length ? '【当页勾选汇总】' : '【当页汇总】'}</span>
|
|
522
|
-
{totalItems.map(({title, value}, index) => {
|
|
523
|
-
return (
|
|
524
|
-
<span key={index} style={{marginRight: `10px`}}>
|
|
525
|
-
<span>{title}: </span>
|
|
526
|
-
<span style={{color: '#01a4ff'}}>{value}</span>
|
|
527
|
-
</span>
|
|
528
|
-
)
|
|
529
|
-
})}
|
|
530
|
-
</div>
|
|
531
|
-
);
|
|
532
|
-
} else {
|
|
533
|
-
return null;
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
getProps = () => {
|
|
538
|
-
const {cols, isPaging=false, isEmphasized=false, isWeaken=false, dragSort ,footer = null} = this.props;
|
|
539
|
-
const items = this.getItems();
|
|
540
|
-
const {onRowClick, ...extraProps} = this.getPropsByCheckbox(items);
|
|
541
|
-
const renderProps = {
|
|
542
|
-
className: !isEmphasized || !isWeaken ? variables('SuperTable') : variables('SuperTable').noTransition,
|
|
543
|
-
columns: this.getColumns(cols, items),
|
|
544
|
-
dataSource: this.getDataSource(items, cols),
|
|
545
|
-
size: 'small',
|
|
546
|
-
pagination: isPaging,
|
|
547
|
-
scroll: {x: true},
|
|
548
|
-
onChange: this.onTableChange,
|
|
549
|
-
onRow: dragSort ? this.getRowPropsForDrag(): this.getRowProps(onRowClick),
|
|
550
|
-
components: dragSort ? {body: {row: DragSortRow}} : {},
|
|
551
|
-
footer: footer ? footer : this.toTotalFooter,
|
|
552
|
-
...extraProps
|
|
553
|
-
};
|
|
554
|
-
return renderProps;
|
|
555
|
-
};
|
|
556
|
-
|
|
557
|
-
setScroll = () => {
|
|
558
|
-
const {maxHeight, pageTotal, searchTotal} = this.props;
|
|
559
|
-
if (maxHeight && this.getItems().length) {
|
|
560
|
-
const root = ReactDOM.findDOMNode(this);
|
|
561
|
-
const container = root.getElementsByClassName('ant-table-body')[0];
|
|
562
|
-
const header = root.getElementsByClassName('ant-table-thead')[0];
|
|
563
|
-
|
|
564
|
-
const tbody = root.getElementsByClassName('ant-table-tbody')[0];
|
|
565
|
-
const pageTotalOffset = searchTotal ? 2 : 1;
|
|
566
|
-
const pageTotalElement = pageTotal && tbody && tbody.children ? tbody.children[tbody.children.length - pageTotalOffset] : null;
|
|
567
|
-
const searchTotalElement = searchTotal && tbody && tbody.children ? tbody.children[tbody.children.length - 1] : null;
|
|
568
|
-
fixed(container, header, maxHeight, {pageTotalElement, searchTotalElement});
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
shouldComponentUpdate(props, state) {
|
|
573
|
-
const keys = ['cols', 'items', 'maxHeight', 'checkedRows', 'sortInfo', 'filterInfo'];
|
|
574
|
-
return keys.some(key => props[key] !== this.props[key]) || state.filterVisibleKey !== this.state.filterVisibleKey;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
componentDidMount() {
|
|
578
|
-
this.setScroll();
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
componentDidUpdate() {
|
|
582
|
-
this.setScroll();
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
render() {
|
|
586
|
-
return <Table {...this.getProps()} key={this.props.items.length} />;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
export default SuperTable;
|
package/src/SuperTable/fixed.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const isFirefox = () => {
|
|
3
|
-
return navigator.userAgent.indexOf('Firefox') > 0;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
const getComputedStyle = (element) => {
|
|
7
|
-
return window.getComputedStyle ? window.getComputedStyle(element, null) : element.currentStyle;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const fixed = (container, header, maxHeight, totalFooter={}) => {
|
|
11
|
-
container.style.overflowY = 'auto';
|
|
12
|
-
container.style.maxHeight = maxHeight;
|
|
13
|
-
if (isFirefox()) {
|
|
14
|
-
container.style.position = 'relative';
|
|
15
|
-
header.style.top = '0';
|
|
16
|
-
header.style.position = 'sticky';
|
|
17
|
-
header.style.zIndex = '1';
|
|
18
|
-
} else {
|
|
19
|
-
header.parentNode.appendChild(header);
|
|
20
|
-
}
|
|
21
|
-
const containerHeight = Number(getComputedStyle(container).height.replace('px', ''))
|
|
22
|
-
const translateHeight = containerHeight - 10 - container.scrollHeight;
|
|
23
|
-
const {pageTotalElement, searchTotalElement} = totalFooter;
|
|
24
|
-
pageTotalElement && (pageTotalElement.style.transform = `translateY(${translateHeight + container.scrollTop}px)`);
|
|
25
|
-
searchTotalElement && (searchTotalElement.style.transform = `translateY(${translateHeight + container.scrollTop}px)`);
|
|
26
|
-
container.onscroll = () => {
|
|
27
|
-
if (container.scrollTop + containerHeight - 10 > container.scrollHeight) return;
|
|
28
|
-
!isFirefox() && (header.style.transform = `translateY(${container.scrollTop}px)`);
|
|
29
|
-
pageTotalElement && (pageTotalElement.style.transform = `translateY(${translateHeight + container.scrollTop}px)`);
|
|
30
|
-
searchTotalElement && (searchTotalElement.style.transform = `translateY(${translateHeight + container.scrollTop}px)`);
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default fixed;
|