zmdms-webui 1.3.1 → 1.3.2
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/es/dynamicsetting/interface.d.ts +11 -3
- package/dist/es/node_modules/@ant-design/icons/es/components/AntdIcon.js +1 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/ArrowsAltOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/CaretDownOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/CaretUpOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/CheckCircleOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/CheckOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/CloseOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/CopyOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/DoubleRightOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/DownOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/DownloadOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/ExclamationCircleOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/LoadingOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/LogoutOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/MenuOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/MinusCircleOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/MinusOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/MinusSquareOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/PicRightOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/PlusOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/PlusSquareOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/QuestionCircleOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/SearchOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/SettingOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/ShrinkOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/SwapOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/UploadOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/UserOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/icons/VerticalAlignBottomOutlined.js +5 -2
- package/dist/es/node_modules/@ant-design/icons/es/utils.js +1 -1
- package/dist/es/table/components/EnhanceBodyCell.js +26 -6
- package/dist/es/table/components/FilterDropdown.js +218 -0
- package/dist/es/table/components/PopoverIcon.js +3 -0
- package/dist/es/table/components/TitleOperation.js +5 -5
- package/dist/es/table/components/table-header-operation/CopyColumn.js +18 -0
- package/dist/es/table/components/{FillDown.js → table-header-operation/FillDown.js} +2 -2
- package/dist/es/table/hooks.js +19 -14
- package/dist/es/table/index.css +1 -1
- package/dist/es/table/interface.d.ts +75 -3
- package/dist/es/table/table.js +33 -25
- package/dist/es/table/useColumns.js +236 -54
- package/dist/es/table/utils.js +290 -7
- package/dist/index.dark.css +1 -1
- package/dist/index.default.css +1 -1
- package/package.json +2 -2
- package/dist/es/table/components/CopyIcon.js +0 -15
package/dist/es/table/table.js
CHANGED
|
@@ -11,17 +11,17 @@ import './components/ColumnAddDel.js';
|
|
|
11
11
|
import './components/TitleOperation.js';
|
|
12
12
|
import { TABLE_DYNAMIC_KEY, INNER_TABLE_PAGINATION_POSITION, INNER_TABLE_PAGINATION_PAGESIZEOPTIONS } from './constant.js';
|
|
13
13
|
import './components/PopoverIcon.js';
|
|
14
|
+
import { useLatest } from 'ahooks';
|
|
14
15
|
import { useParseColumns } from './useParseColumns.js';
|
|
15
16
|
import { useColumns } from './useColumns.js';
|
|
16
17
|
import { useDynamicListByColumns } from './useDynamicListByColumns.js';
|
|
17
18
|
import useSummary from './useSummary.js';
|
|
18
19
|
import useInnerPagination, { getInnerIndex } from './useInnerPagination.js';
|
|
19
|
-
import { useScuRfresh, useEditChange, useMoveRowChange, useAddAndDelChange
|
|
20
|
+
import { useScuRfresh, useCustomSort, useEditChange, useMoveRowChange, useAddAndDelChange } from './hooks.js';
|
|
20
21
|
import { HTML5Backend } from '../node_modules/react-dnd-html5-backend/dist/index.js';
|
|
21
22
|
import { VList, scrollTo } from '../node_modules/virtuallist-antd/dist/index.es.js';
|
|
22
23
|
import useTableValidate, { tableValidate } from './useTableValidate.js';
|
|
23
24
|
import TitleDirectionColumn from './components/TitleDirectionColumn.js';
|
|
24
|
-
import { useLatest } from 'ahooks';
|
|
25
25
|
import DynamicSetting from '../dynamicsetting/dynamicSetting.js';
|
|
26
26
|
import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js';
|
|
27
27
|
|
|
@@ -34,31 +34,44 @@ import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js'
|
|
|
34
34
|
// completed: 实现虚拟滚动配置
|
|
35
35
|
// completed: 实现表头自定义伸缩
|
|
36
36
|
// completed: 排序功能优化
|
|
37
|
-
//
|
|
37
|
+
// completed: 过滤功能
|
|
38
|
+
// TODO: 实现从execl复制到表格中的功能
|
|
38
39
|
var Table = function (props) {
|
|
39
40
|
// console.log("表格渲染");
|
|
40
|
-
var className = props.className, _a = props.bordered, bordered = _a === void 0 ? true : _a, _b = props.pagination, pagination = _b === void 0 ? false : _b, isFlex = props.isFlex; props.tablePreferences; var dynamicKey = props.dynamicKey, hiddenDynamicIcon = props.hiddenDynamicIcon, _columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, hiddenAddBtnHandle = props.hiddenAddBtnHandle,
|
|
41
|
-
// 做一些前置处理
|
|
42
|
-
// 比如过滤某些列 不做展示
|
|
43
|
-
var columns = useParseColumns(_columns);
|
|
41
|
+
var className = props.className, _a = props.bordered, bordered = _a === void 0 ? true : _a, _b = props.pagination, pagination = _b === void 0 ? false : _b, isFlex = props.isFlex; props.tablePreferences; var dynamicKey = props.dynamicKey, isRemeberFilter = props.isRemeberFilter, _c = props.isOrderUpdateData, isOrderUpdateData = _c === void 0 ? true : _c, hiddenDynamicIcon = props.hiddenDynamicIcon, _columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, hiddenAddBtnHandle = props.hiddenAddBtnHandle, _d = props.isTheadTitleAdd, isTheadTitleAdd = _d === void 0 ? true : _d, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, delPopTitle = props.delPopTitle, hiddenDelBtnHandle = props.hiddenDelBtnHandle, _e = props.isDelAll, isDelAll = _e === void 0 ? true : _e, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _f = props.summaryFixed, summaryFixed = _f === void 0 ? true : _f, isInnerPagination = props.isInnerPagination, _g = props.innerPaginationPageSize, innerPaginationPageSize = _g === void 0 ? 30 : _g, _h = props.innerPaginationPosition, innerPaginationPosition = _h === void 0 ? INNER_TABLE_PAGINATION_POSITION : _h, _j = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _j === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _j, innerPaginationConfig = props.innerPaginationConfig, tableRefHandle = props.tableRefHandle, tableName = props.tableName, serviceOrder = props.serviceOrder, differences = props.differences, virtualKey = props.virtualKey, _k = props.isResizableColumn, isResizableColumn = _k === void 0 ? true : _k, _l = props.isResizableTitleEllipsis, isResizableTitleEllipsis = _l === void 0 ? true : _l, _m = props.isRealTimeValidate, isRealTimeValidate = _m === void 0 ? true : _m, isMarginTop = props.isMarginTop, isMarginBottom = props.isMarginBottom, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "isRemeberFilter", "isOrderUpdateData", "hiddenDynamicIcon", "columns", "dataSource", "onTableChange", "isEdit", "isMove", "isAdd", "hiddenAddBtnHandle", "isTheadTitleAdd", "addMode", "addCallback", "isDel", "delPopTitle", "hiddenDelBtnHandle", "isDelAll", "isAddAndDelAuto", "summaryConfig", "summaryFixed", "isInnerPagination", "innerPaginationPageSize", "innerPaginationPosition", "innerPaginationPageSizeOptions", "innerPaginationConfig", "tableRefHandle", "tableName", "serviceOrder", "differences", "virtualKey", "isResizableColumn", "isResizableTitleEllipsis", "isRealTimeValidate", "isMarginTop", "isMarginBottom"]);
|
|
44
42
|
var classes = classNames("ztxk-table", className, {
|
|
45
43
|
"ztxk-table--flex": isFlex,
|
|
46
44
|
});
|
|
45
|
+
// 针对SCU和增减行 做特殊处理
|
|
46
|
+
var _o = useScuRfresh(), refreshScuCell = _o.refreshScuCell, getRefreshScuCell = _o.getRefreshScuCell;
|
|
47
|
+
// 做一些前置处理
|
|
48
|
+
// 比如过滤某些列 不做展示
|
|
49
|
+
var columns = useParseColumns(_columns);
|
|
50
|
+
// 得到动态列配置信息
|
|
51
|
+
var _p = useDynamicListByColumns(columns, dynamicKey), defaultDynamicList = _p.defaultDynamicList, onCurrentListChange = _p.onCurrentListChange, currentDynamicList = _p.currentDynamicList, dynamicSettingRef = _p.dynamicSettingRef;
|
|
52
|
+
// 因为内部分页需要知晓当前页面的数据展示,要不然数据排序就跟内部分页没关系了
|
|
53
|
+
// 自定义排序方法
|
|
54
|
+
var _q = useCustomSort(dataSource, onTableChange, {
|
|
55
|
+
refreshScuCell: refreshScuCell,
|
|
56
|
+
rowKey: props === null || props === void 0 ? void 0 : props.rowKey,
|
|
57
|
+
serviceOrder: serviceOrder,
|
|
58
|
+
isOrderUpdateData: isOrderUpdateData,
|
|
59
|
+
}), order = _q.order, setOrder = _q.setOrder, customSortHandle = _q.customSortHandle, sortDataSource = _q.sortDataSource;
|
|
60
|
+
// 当前表格展示的数据
|
|
61
|
+
// 如果开启了前端排序的话,排序后的数据,可能会影响到很多地方。
|
|
62
|
+
// 所以后续操作的数据 应该用
|
|
63
|
+
var currentTableDataSource = sortDataSource ? sortDataSource : dataSource;
|
|
47
64
|
// 将表格数据 在 Ref中 存储一份
|
|
48
|
-
var dataSourceRef = useLatest(
|
|
65
|
+
var dataSourceRef = useLatest(currentTableDataSource);
|
|
49
66
|
var hiddenDelBtnHandleRef = useLatest(hiddenDelBtnHandle);
|
|
50
67
|
var hiddenAddBtnHandleRef = useLatest(hiddenAddBtnHandle);
|
|
51
|
-
// 得到动态列配置信息
|
|
52
|
-
var _m = useDynamicListByColumns(columns, dynamicKey), defaultDynamicList = _m.defaultDynamicList, onCurrentListChange = _m.onCurrentListChange, currentDynamicList = _m.currentDynamicList, dynamicSettingRef = _m.dynamicSettingRef;
|
|
53
|
-
// 针对SCU和增减行 做特殊处理
|
|
54
|
-
var _o = useScuRfresh(), refreshScuCell = _o.refreshScuCell, getRefreshScuCell = _o.getRefreshScuCell;
|
|
55
68
|
// 内部分页相关配置
|
|
56
|
-
var
|
|
69
|
+
var _r = useInnerPagination(isInnerPagination, innerPaginationPageSize, {
|
|
57
70
|
innerPaginationPosition: innerPaginationPosition,
|
|
58
71
|
innerPaginationPageSizeOptions: innerPaginationPageSizeOptions,
|
|
59
72
|
innerPaginationConfig: innerPaginationConfig,
|
|
60
|
-
dataSource:
|
|
61
|
-
}), paginationConfig =
|
|
73
|
+
dataSource: currentTableDataSource,
|
|
74
|
+
}), paginationConfig = _r.paginationConfig, currentPage = _r.currentPage, setCurrent = _r.setCurrent, pageSize = _r.pageSize;
|
|
62
75
|
// 内部表格编辑事件
|
|
63
76
|
var onEditableSave = useEditChange(dataSourceRef, onTableChange);
|
|
64
77
|
// 内部表格拖拽事件
|
|
@@ -76,22 +89,16 @@ var Table = function (props) {
|
|
|
76
89
|
isAddAndDelAuto: isAddAndDelAuto,
|
|
77
90
|
currentPage: currentPage,
|
|
78
91
|
});
|
|
79
|
-
// 自定义排序方法
|
|
80
|
-
var _q = useCustomSort(dataSource, onTableChange, {
|
|
81
|
-
refreshScuCell: refreshScuCell,
|
|
82
|
-
currentPage: currentPage,
|
|
83
|
-
rowKey: props === null || props === void 0 ? void 0 : props.rowKey,
|
|
84
|
-
serviceOrder: serviceOrder,
|
|
85
|
-
}), order = _q.order, setOrder = _q.setOrder, customSortHandle = _q.customSortHandle, sortDataSource = _q.sortDataSource;
|
|
86
92
|
// 处理列配置信息 得到新的列配置信息
|
|
87
93
|
var newColumns = useColumns(columns, {
|
|
88
94
|
// 动态列配置相关信息
|
|
89
95
|
dynamicKey: dynamicKey,
|
|
96
|
+
isRemeberFilter: isRemeberFilter,
|
|
90
97
|
hiddenDynamicIcon: hiddenDynamicIcon,
|
|
91
98
|
currentDynamicList: currentDynamicList,
|
|
92
99
|
dynamicSettingRef: dynamicSettingRef,
|
|
93
100
|
onCurrentListChange: onCurrentListChange,
|
|
94
|
-
dataSource:
|
|
101
|
+
dataSource: currentTableDataSource,
|
|
95
102
|
dataSourceRef: dataSourceRef,
|
|
96
103
|
onEditableSave: onEditableSave,
|
|
97
104
|
isEdit: isEdit,
|
|
@@ -117,6 +124,7 @@ var Table = function (props) {
|
|
|
117
124
|
hiddenDelBtnHandleRef: hiddenDelBtnHandleRef,
|
|
118
125
|
// 是否隐藏某一列的增加按钮
|
|
119
126
|
hiddenAddBtnHandleRef: hiddenAddBtnHandleRef,
|
|
127
|
+
rowKey: props.rowKey,
|
|
120
128
|
}).newColumns;
|
|
121
129
|
// 内部表格总结栏
|
|
122
130
|
var getSummaryHandle = useSummary(summaryConfig, newColumns, {
|
|
@@ -127,7 +135,7 @@ var Table = function (props) {
|
|
|
127
135
|
isDel: isDel,
|
|
128
136
|
});
|
|
129
137
|
// 表格验证
|
|
130
|
-
var
|
|
138
|
+
var _s = useTableValidate(), tableRef = _s.tableRef, getCurrentTable = _s.getCurrentTable, clearErrorClass = _s.clearErrorClass;
|
|
131
139
|
// 虚拟滚动选项
|
|
132
140
|
var vComponents = useMemo(function () {
|
|
133
141
|
var _a;
|
|
@@ -249,7 +257,7 @@ var Table = function (props) {
|
|
|
249
257
|
};
|
|
250
258
|
});
|
|
251
259
|
// 表格
|
|
252
|
-
var SingleTable = (jsx(Table$1, __assign({ className: classes, bordered: bordered, dataSource:
|
|
260
|
+
var SingleTable = (jsx(Table$1, __assign({ className: classes, bordered: bordered, dataSource: currentTableDataSource, columns: newColumns, components: componentsMemo, onRow: onRow, summary: getSummaryHandle, pagination: isInnerPagination
|
|
253
261
|
? pagination
|
|
254
262
|
? pagination
|
|
255
263
|
: paginationConfig
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { __assign, __spreadArray } from '../_virtual/_tslib.js';
|
|
1
|
+
import { __assign, __spreadArray, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
4
|
-
import '
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
import { getTableColumns, getFilterRecords, startColumnInsertTableData, parsePasteData } from './utils.js';
|
|
5
5
|
import '../node_modules/classnames/index.js';
|
|
6
6
|
import 'ahooks';
|
|
7
7
|
import './components/EnhanceHeaderCell.js';
|
|
@@ -10,22 +10,31 @@ import ColumnAddDel, { ColumnDelAll, ColumnAdd } from './components/ColumnAddDel
|
|
|
10
10
|
import TitleOperation from './components/TitleOperation.js';
|
|
11
11
|
import SortTitle from './components/SortTitle.js';
|
|
12
12
|
import PopoverIcon from './components/PopoverIcon.js';
|
|
13
|
+
import FilterDropdown, { createFilterValue, filterHandle } from './components/FilterDropdown.js';
|
|
13
14
|
import { PLACEHOLDER_NULL } from '../config/constant.js';
|
|
15
|
+
import SearchOutlined from '../node_modules/@ant-design/icons/es/icons/SearchOutlined.js';
|
|
14
16
|
|
|
15
17
|
// 处理columns
|
|
16
18
|
// 根据传入的一些信息 重新生成新的columns配置
|
|
17
19
|
// 不适用column里面的dataIndex字段,使用key字段
|
|
18
20
|
function useColumns(columns, options) {
|
|
21
|
+
var _this = this;
|
|
19
22
|
var _a, _b;
|
|
20
|
-
var dynamicKey = options.dynamicKey, hiddenDynamicIcon = options.hiddenDynamicIcon, currentDynamicList = options.currentDynamicList, dataSourceRef = options.dataSourceRef, onEditableSave = options.onEditableSave, isEdit = options.isEdit, isAdd = options.isAdd, isTheadTitleAdd = options.isTheadTitleAdd, isDel = options.isDel, delPopTitle = options.delPopTitle, dynamicSettingRef = options.dynamicSettingRef, onCurrentListChange = options.onCurrentListChange, onAddAndDel = options.onAddAndDel, getRefreshScuCell = options.getRefreshScuCell, isDelAll = options.isDelAll, currentPage = options.currentPage, onTableChange = options.onTableChange, order = options.order, setOrder = options.setOrder, customSortHandle = options.customSortHandle, isResizableColumn = options.isResizableColumn, isResizableTitleEllipsis = options.isResizableTitleEllipsis, isRealTimeValidate = options.isRealTimeValidate, hiddenDelBtnHandleRef = options.hiddenDelBtnHandleRef, hiddenAddBtnHandleRef = options.hiddenAddBtnHandleRef;
|
|
21
|
-
var newColumns = getTableColumns(columns, currentDynamicList);
|
|
23
|
+
var dynamicKey = options.dynamicKey, isRemeberFilter = options.isRemeberFilter, hiddenDynamicIcon = options.hiddenDynamicIcon, currentDynamicList = options.currentDynamicList, dataSource = options.dataSource, dataSourceRef = options.dataSourceRef, onEditableSave = options.onEditableSave, isEdit = options.isEdit, isAdd = options.isAdd, isTheadTitleAdd = options.isTheadTitleAdd, isDel = options.isDel, delPopTitle = options.delPopTitle, dynamicSettingRef = options.dynamicSettingRef, onCurrentListChange = options.onCurrentListChange, onAddAndDel = options.onAddAndDel, getRefreshScuCell = options.getRefreshScuCell, isDelAll = options.isDelAll, currentPage = options.currentPage, onTableChange = options.onTableChange, order = options.order, setOrder = options.setOrder, customSortHandle = options.customSortHandle, isResizableColumn = options.isResizableColumn, isResizableTitleEllipsis = options.isResizableTitleEllipsis, isRealTimeValidate = options.isRealTimeValidate, hiddenDelBtnHandleRef = options.hiddenDelBtnHandleRef, hiddenAddBtnHandleRef = options.hiddenAddBtnHandleRef, rowKey = options.rowKey;
|
|
24
|
+
var newColumns = getTableColumns(columns, currentDynamicList).columns;
|
|
25
|
+
// 表头过滤的一些配置(获取表头过滤的input的输入框的引用)
|
|
26
|
+
var searchValueInputRef = useRef(null);
|
|
27
|
+
// 记录表头过滤的一些配置(通过ref记录,key => filter) 复制整列时,需要先走过滤
|
|
28
|
+
var filterConfigRef = useRef({});
|
|
22
29
|
// 循环遍历 neColumns 根据一些内容进行处理
|
|
23
30
|
var myNewColumns = [];
|
|
24
31
|
var enhanceColumnHandle = function (_column, options) {
|
|
25
|
-
var _a
|
|
26
|
-
var
|
|
32
|
+
var _a;
|
|
33
|
+
var _b, _c, _d, _e, _f;
|
|
34
|
+
var isCopy = _column.isCopy, editable = _column.editable, editableConfig = _column.editableConfig, title = _column.title, key = _column.key, validate = _column.validate, isRequire = _column.isRequire, isFillDown = _column.isFillDown, isOrder = _column.isOrder, isStress = _column.isStress, popoverText = _column.popoverText, showType = _column.showType, isFilter = _column.isFilter, __dynamicItem__ = _column.__dynamicItem__;
|
|
35
|
+
// 表格列,唯一key
|
|
27
36
|
var _key = key ? key : _column === null || _column === void 0 ? void 0 : _column.dataIndex;
|
|
28
|
-
var
|
|
37
|
+
var _g = (options || {}).keyIndex, keyIndex = _g === void 0 ? [] : _g;
|
|
29
38
|
var isRequireNode = isRequire ? (jsx("i", __assign({ className: "ztxk-column--required" }, { children: "*" }))) : null;
|
|
30
39
|
if (showType) {
|
|
31
40
|
_column.className = _column.className
|
|
@@ -35,7 +44,7 @@ function useColumns(columns, options) {
|
|
|
35
44
|
// 添加气泡提示
|
|
36
45
|
if (popoverText) {
|
|
37
46
|
_column.title = (jsxs(Fragment, { children: [typeof _column.title === "function"
|
|
38
|
-
? (
|
|
47
|
+
? (_b = _column.title) === null || _b === void 0 ? void 0 : _b.call(_column, {})
|
|
39
48
|
: _column.title, jsx(PopoverIcon, { text: popoverText })] }));
|
|
40
49
|
}
|
|
41
50
|
// 添加自定义排序
|
|
@@ -65,8 +74,74 @@ function useColumns(columns, options) {
|
|
|
65
74
|
justifyContent: "space-between",
|
|
66
75
|
flex: "1",
|
|
67
76
|
} }, { children: [jsx("div", __assign({ style: { flexGrow: 1, textAlign: _column.align }, className: isStress ? "ztxk-table--title-stress" : undefined }, { children: typeof _column.title === "function"
|
|
68
|
-
? (
|
|
69
|
-
: _column.title })), jsx(TitleOperation, { copyKey: isCopy === true ? _key : isCopy, dataSourceRef: dataSourceRef, isFillDown: isFillDown, dataKey: _key, onTableChange: onTableChange })] })));
|
|
77
|
+
? (_c = _column.title) === null || _c === void 0 ? void 0 : _c.call(_column, {})
|
|
78
|
+
: _column.title })), jsx(TitleOperation, { copyKey: isCopy === true ? _key : isCopy, dataSourceRef: dataSourceRef, isFillDown: isFillDown, dataKey: _key, onTableChange: onTableChange, filterConfigRef: filterConfigRef })] })));
|
|
79
|
+
}
|
|
80
|
+
// 20240802
|
|
81
|
+
// 列头增加过滤功能
|
|
82
|
+
if (isFilter) {
|
|
83
|
+
var input_1 = (_d = __dynamicItem__ === null || __dynamicItem__ === void 0 ? void 0 : __dynamicItem__.filter) === null || _d === void 0 ? void 0 : _d.input;
|
|
84
|
+
var checkbox_1 = (_e = __dynamicItem__ === null || __dynamicItem__ === void 0 ? void 0 : __dynamicItem__.filter) === null || _e === void 0 ? void 0 : _e.checkbox;
|
|
85
|
+
// 组合生成过滤数据
|
|
86
|
+
var filteredValue = createFilterValue(input_1, checkbox_1);
|
|
87
|
+
/**
|
|
88
|
+
* 自定义渲染视图
|
|
89
|
+
* @param selectedKeys string[] 搜索的值数组
|
|
90
|
+
* @param setSelectedKeys 设置方法
|
|
91
|
+
* @param confirm 确认提交
|
|
92
|
+
* @param clearFilters 确认清楚
|
|
93
|
+
* @returns
|
|
94
|
+
*/
|
|
95
|
+
_column.filterDropdown = function (_a) {
|
|
96
|
+
var selectedKeys = _a.selectedKeys, setSelectedKeys = _a.setSelectedKeys, confirm = _a.confirm, clearFilters = _a.clearFilters;
|
|
97
|
+
return (jsx(FilterDropdown, { dataSource: dataSource, dataSourceRef: dataSourceRef, filterKey: _key, selectedKeys: selectedKeys, setSelectedKeys: setSelectedKeys, confirm: confirm, clearFilters: clearFilters, searchValueInputRef: searchValueInputRef, defaultFilterSearchValue: isRemeberFilter ? input_1 : undefined, defaultFilterSearchCheckboxValue: isRemeberFilter ? checkbox_1 : undefined, onFilterChange: function (filter) {
|
|
98
|
+
var _a;
|
|
99
|
+
var _b;
|
|
100
|
+
// 实时记录下当前的值
|
|
101
|
+
var filteredValue = createFilterValue(filter === null || filter === void 0 ? void 0 : filter.input, filter === null || filter === void 0 ? void 0 : filter.checkbox);
|
|
102
|
+
filterConfigRef.current = (_a = {},
|
|
103
|
+
_a[_key] = filteredValue,
|
|
104
|
+
_a);
|
|
105
|
+
if (!isRemeberFilter) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
// 如果有持久化 那么更新持久化数据
|
|
109
|
+
var _c = getColumnsItem({
|
|
110
|
+
currentDynamicList: currentDynamicList,
|
|
111
|
+
currentKey: _key,
|
|
112
|
+
keyIndex: keyIndex,
|
|
113
|
+
}), result = _c.result, newList = _c.newList;
|
|
114
|
+
if (result) {
|
|
115
|
+
result.filter = filter;
|
|
116
|
+
}
|
|
117
|
+
if (dynamicKey) {
|
|
118
|
+
(_b = dynamicSettingRef === null || dynamicSettingRef === void 0 ? void 0 : dynamicSettingRef.current) === null || _b === void 0 ? void 0 : _b.updateList(newList);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
onCurrentListChange === null || onCurrentListChange === void 0 ? void 0 : onCurrentListChange(newList);
|
|
122
|
+
}
|
|
123
|
+
} }));
|
|
124
|
+
};
|
|
125
|
+
// 持久化
|
|
126
|
+
if (isRemeberFilter) {
|
|
127
|
+
// 初始记录下当前的值
|
|
128
|
+
filterConfigRef.current = (_a = {},
|
|
129
|
+
_a[_key] = filteredValue,
|
|
130
|
+
_a);
|
|
131
|
+
_column.filteredValue = filteredValue;
|
|
132
|
+
}
|
|
133
|
+
_column.filterIcon = function () { return jsx(SearchOutlined, {}); };
|
|
134
|
+
_column.onFilter = function (value, record) {
|
|
135
|
+
return filterHandle(value, record, _key);
|
|
136
|
+
};
|
|
137
|
+
_column.onFilterDropdownOpenChange = function (visible) {
|
|
138
|
+
if (visible) {
|
|
139
|
+
setTimeout(function () {
|
|
140
|
+
var _a;
|
|
141
|
+
(_a = searchValueInputRef.current) === null || _a === void 0 ? void 0 : _a.select();
|
|
142
|
+
}, 100);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
70
145
|
}
|
|
71
146
|
var justifyContent = {
|
|
72
147
|
center: "center",
|
|
@@ -82,16 +157,93 @@ function useColumns(columns, options) {
|
|
|
82
157
|
? justifyContent[_column.align]
|
|
83
158
|
: undefined,
|
|
84
159
|
} }, { children: [isRequireNode, jsx("div", __assign({ style: { flexGrow: 1 }, className: isStress ? "ztxk-table--title-stress" : undefined }, { children: typeof _column.title === "function"
|
|
85
|
-
? (
|
|
160
|
+
? (_f = _column.title) === null || _f === void 0 ? void 0 : _f.call(_column, {})
|
|
86
161
|
: _column.title }))] })));
|
|
87
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* 定义粘贴方法
|
|
165
|
+
* 1. 处理粘贴板数据(生成一个以行为基准的数组)
|
|
166
|
+
* 2. 获取一些关键信息:列配置、开始粘贴的列、源数据、当前展示数据(可能过滤了)
|
|
167
|
+
* 3. 处理超出表格行、列的粘贴行为(自动截取掉粘贴多出来的数据)
|
|
168
|
+
* 4. 通过循环查找下一列(因为如果横向有多个的话需要横向扩展)
|
|
169
|
+
* 5. 横向列查找超出逻辑处理
|
|
170
|
+
* 6. 记录粘贴数据、更新数据、触发change方法
|
|
171
|
+
* @param e 粘贴事件对象(如果传入一个错误的值,默认会通过navigator.clipboard中取)
|
|
172
|
+
* @param index 开始的行索引
|
|
173
|
+
*/
|
|
174
|
+
var insertTableFromClipboard = function (e, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
175
|
+
var dataIndex, index, _a, isUpdate, verticalTextList, columns_1, column, filterDataSource, _b, pasteConfig, newDataSource, oldDataSource, err_1;
|
|
176
|
+
var _c, _d, _e;
|
|
177
|
+
return __generator(this, function (_f) {
|
|
178
|
+
switch (_f.label) {
|
|
179
|
+
case 0:
|
|
180
|
+
dataIndex = _key;
|
|
181
|
+
index = options.index, _a = options.isUpdate, isUpdate = _a === void 0 ? true : _a;
|
|
182
|
+
_f.label = 1;
|
|
183
|
+
case 1:
|
|
184
|
+
_f.trys.push([1, 3, , 4]);
|
|
185
|
+
return [4 /*yield*/, parsePasteData(e, {
|
|
186
|
+
maxRow: ((_c = currentPage === null || currentPage === void 0 ? void 0 : currentPage.current) === null || _c === void 0 ? void 0 : _c.pageSize)
|
|
187
|
+
? ((_d = currentPage === null || currentPage === void 0 ? void 0 : currentPage.current) === null || _d === void 0 ? void 0 : _d.pageSize) - index
|
|
188
|
+
: ((_e = dataSourceRef.current) === null || _e === void 0 ? void 0 : _e.length) - index,
|
|
189
|
+
})];
|
|
190
|
+
case 2:
|
|
191
|
+
verticalTextList = _f.sent();
|
|
192
|
+
if (verticalTextList.length > 0) {
|
|
193
|
+
// 阻止默认行为,接管粘贴操作
|
|
194
|
+
e.preventDefault();
|
|
195
|
+
columns_1 = newColumns;
|
|
196
|
+
column = _column;
|
|
197
|
+
filterDataSource = getFilterRecords(dataSourceRef.current, filterConfigRef.current);
|
|
198
|
+
_b = startColumnInsertTableData({
|
|
199
|
+
verticalTextList: verticalTextList,
|
|
200
|
+
startColumn: column,
|
|
201
|
+
columns: columns_1,
|
|
202
|
+
startIndex: index,
|
|
203
|
+
startDataIndex: dataIndex,
|
|
204
|
+
rowKey: rowKey,
|
|
205
|
+
realDataSource: dataSourceRef.current,
|
|
206
|
+
currentDataSource: filterDataSource,
|
|
207
|
+
}), pasteConfig = _b.pasteConfig, newDataSource = _b.newDataSource, oldDataSource = _b.oldDataSource;
|
|
208
|
+
if (isUpdate) {
|
|
209
|
+
onTableChange &&
|
|
210
|
+
onTableChange(newDataSource, oldDataSource, {
|
|
211
|
+
type: "paste",
|
|
212
|
+
pasteConfig: pasteConfig,
|
|
213
|
+
currentIndex: index,
|
|
214
|
+
field: dataIndex,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return [2 /*return*/, {
|
|
218
|
+
newDataSource: newDataSource,
|
|
219
|
+
oldDataSource: oldDataSource,
|
|
220
|
+
pasteConfig: pasteConfig,
|
|
221
|
+
}];
|
|
222
|
+
}
|
|
223
|
+
return [2 /*return*/, {
|
|
224
|
+
newDataSource: dataSourceRef.current,
|
|
225
|
+
oldDataSource: dataSourceRef.current,
|
|
226
|
+
pasteConfig: {},
|
|
227
|
+
}];
|
|
228
|
+
case 3:
|
|
229
|
+
err_1 = _f.sent();
|
|
230
|
+
console.log("粘贴事件内部错误", err_1);
|
|
231
|
+
return [2 /*return*/, {
|
|
232
|
+
newDataSource: dataSourceRef.current,
|
|
233
|
+
oldDataSource: dataSourceRef.current,
|
|
234
|
+
pasteConfig: {},
|
|
235
|
+
}];
|
|
236
|
+
case 4: return [2 /*return*/];
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}); };
|
|
88
240
|
// 如果列添加可编辑配置
|
|
89
241
|
// 只要开启了编辑列 并且设置了验证,全部交给内部处理
|
|
90
242
|
if ((editable || validate) && isEdit) {
|
|
91
243
|
var _onCell_1 = _column.onCell;
|
|
92
244
|
_column.onCell = function (record, index) {
|
|
93
245
|
var result = _onCell_1 ? _onCell_1(record, index) : {};
|
|
94
|
-
return __assign({ record: record, index: index, editable: editable, editableConfig: editableConfig, dataIndex: _key, title: title, onEditableSave: onEditableSave, currentPage: currentPage, isValidate: validate ? true : false, dataSourceRef: dataSourceRef, validate: validate, isRealTimeValidate: isRealTimeValidate }, result);
|
|
246
|
+
return __assign({ record: record, index: index, editable: editable, editableConfig: editableConfig, dataIndex: _key, title: title, onEditableSave: onEditableSave, currentPage: currentPage, isValidate: validate ? true : false, dataSourceRef: dataSourceRef, validate: validate, isRealTimeValidate: isRealTimeValidate, insertTableFromClipboard: insertTableFromClipboard }, result);
|
|
95
247
|
};
|
|
96
248
|
}
|
|
97
249
|
// 处理配置了scu的相关逻辑
|
|
@@ -113,58 +265,36 @@ function useColumns(columns, options) {
|
|
|
113
265
|
return text == null || text === "" ? PLACEHOLDER_NULL : text;
|
|
114
266
|
};
|
|
115
267
|
}
|
|
268
|
+
if (_column.render) {
|
|
269
|
+
var options_1 = {
|
|
270
|
+
insertTableFromClipboard: insertTableFromClipboard,
|
|
271
|
+
};
|
|
272
|
+
var __render__1 = _column.render;
|
|
273
|
+
// 代理render方法,像外部传入一些事件给外部调用
|
|
274
|
+
_column.render = function (text, record, index) {
|
|
275
|
+
return __render__1(text, record, index, options_1);
|
|
276
|
+
};
|
|
277
|
+
}
|
|
116
278
|
// 如果配置了伸缩列
|
|
117
279
|
if (isResizableColumn) {
|
|
118
280
|
_column.onHeaderCell = function (column) { return ({
|
|
119
281
|
width: column.width,
|
|
120
282
|
isResizableTitleEllipsis: isResizableTitleEllipsis,
|
|
121
283
|
onResize: (function (e, _a) {
|
|
122
|
-
var _b
|
|
284
|
+
var _b;
|
|
123
285
|
var size = _a.size;
|
|
124
|
-
//
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// 如果这是顶层
|
|
132
|
-
if (keyIndex.length === 0) {
|
|
133
|
-
if (item.key === _key) {
|
|
134
|
-
result = item;
|
|
135
|
-
return "break";
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
// 需要递归按层级查找到目标
|
|
140
|
-
// 找到最顶层
|
|
141
|
-
if (item.key === keyIndex[0]) {
|
|
142
|
-
var pList_1 = item.children || [];
|
|
143
|
-
keyIndex.slice(1).forEach(function (k) {
|
|
144
|
-
var _a;
|
|
145
|
-
pList_1 =
|
|
146
|
-
((_a = pList_1 === null || pList_1 === void 0 ? void 0 : pList_1.find(function (pItem) { return pItem.key === k; })) === null || _a === void 0 ? void 0 : _a.children) || [];
|
|
147
|
-
});
|
|
148
|
-
// 找到最终目标
|
|
149
|
-
var lastResult = pList_1.find(function (pItem) { return pItem.key === _key; });
|
|
150
|
-
if (lastResult) {
|
|
151
|
-
result = lastResult;
|
|
152
|
-
}
|
|
153
|
-
return "break";
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
for (var i = 0; i < (newList === null || newList === void 0 ? void 0 : newList.length); i++) {
|
|
158
|
-
var state_1 = _loop_1(i);
|
|
159
|
-
if (state_1 === "break")
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
286
|
+
// 获取当前列配置项
|
|
287
|
+
var _c = getColumnsItem({
|
|
288
|
+
currentDynamicList: currentDynamicList,
|
|
289
|
+
currentKey: _key,
|
|
290
|
+
keyIndex: keyIndex,
|
|
291
|
+
}), result = _c.result, newList = _c.newList;
|
|
292
|
+
// 修改当前列宽度
|
|
163
293
|
if (result) {
|
|
164
294
|
result.width = size.width;
|
|
165
295
|
}
|
|
166
296
|
if (dynamicKey) {
|
|
167
|
-
(
|
|
297
|
+
(_b = dynamicSettingRef === null || dynamicSettingRef === void 0 ? void 0 : dynamicSettingRef.current) === null || _b === void 0 ? void 0 : _b.updateList(newList);
|
|
168
298
|
}
|
|
169
299
|
else {
|
|
170
300
|
onCurrentListChange === null || onCurrentListChange === void 0 ? void 0 : onCurrentListChange(newList);
|
|
@@ -232,6 +362,58 @@ function useColumns(columns, options) {
|
|
|
232
362
|
return {
|
|
233
363
|
newColumns: myNewColumns,
|
|
234
364
|
};
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* 通过一些信息 找到当前的columnItem
|
|
368
|
+
*/
|
|
369
|
+
function getColumnsItem(options) {
|
|
370
|
+
var _a;
|
|
371
|
+
var currentDynamicList = options.currentDynamicList, keyIndex = options.keyIndex, currentKey = options.currentKey;
|
|
372
|
+
// 更新columns配置 这里应该不需要用loadsh来深拷贝数据
|
|
373
|
+
var newList = (_a = currentDynamicList === null || currentDynamicList === void 0 ? void 0 : currentDynamicList.map) === null || _a === void 0 ? void 0 : _a.call(currentDynamicList, function (item) { return (__assign({}, item)); });
|
|
374
|
+
var result = null;
|
|
375
|
+
// 递归查找
|
|
376
|
+
if (Array.isArray(newList)) {
|
|
377
|
+
var _loop_1 = function (i) {
|
|
378
|
+
var item = newList[i];
|
|
379
|
+
// 如果这是顶层
|
|
380
|
+
if (keyIndex.length === 0) {
|
|
381
|
+
if (item.key === currentKey) {
|
|
382
|
+
result = item;
|
|
383
|
+
return "break";
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
// 需要递归按层级查找到目标
|
|
388
|
+
// 找到最顶层
|
|
389
|
+
if (item.key === keyIndex[0]) {
|
|
390
|
+
var pList_1 = item.children || [];
|
|
391
|
+
keyIndex.slice(1).forEach(function (k) {
|
|
392
|
+
var _a;
|
|
393
|
+
pList_1 =
|
|
394
|
+
((_a = pList_1 === null || pList_1 === void 0 ? void 0 : pList_1.find(function (pItem) { return pItem.key === k; })) === null || _a === void 0 ? void 0 : _a.children) || [];
|
|
395
|
+
});
|
|
396
|
+
// 找到最终目标
|
|
397
|
+
var lastResult = pList_1.find(function (pItem) { return pItem.key === currentKey; });
|
|
398
|
+
if (lastResult) {
|
|
399
|
+
result = lastResult;
|
|
400
|
+
}
|
|
401
|
+
return "break";
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
for (var i = 0; i < (newList === null || newList === void 0 ? void 0 : newList.length); i++) {
|
|
406
|
+
var state_1 = _loop_1(i);
|
|
407
|
+
if (state_1 === "break")
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return {
|
|
412
|
+
// 当前key对应的数据
|
|
413
|
+
result: result,
|
|
414
|
+
// 一个崭新的当前数据列表
|
|
415
|
+
newList: newList,
|
|
416
|
+
};
|
|
235
417
|
}
|
|
236
418
|
|
|
237
419
|
export { useColumns };
|