ztxkui 4.2.18-2 → 4.2.18-21
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 +57 -57
- package/dist/DemoCom/SyhDemo.d.ts +3 -0
- package/dist/DemoCom/SyhDemo.js +257 -0
- package/dist/DemoCom/TableDemo.js +8 -4
- package/dist/TableDemo/BasicTable.js +2 -1
- package/dist/TableDemo/EditableTable.js +83 -67
- package/dist/TableDemo/ProEditableTable.d.ts +21 -0
- package/dist/TableDemo/ProEditableTable.js +482 -0
- package/dist/TableDemo/data.d.ts +15 -0
- package/dist/TableDemo/data.js +33 -1
- package/dist/TableDemo/index.js +6 -5
- package/dist/components/DatePicker/data-picker.d.ts +7 -8
- package/dist/components/Menu/menu.d.ts +3 -3
- package/dist/components/PrintContainer/utils.js +3 -3
- package/dist/components/ProTable/hooks.d.ts +28 -0
- package/dist/components/ProTable/hooks.js +279 -0
- package/dist/components/ProTable/index.d.ts +8 -0
- package/dist/components/ProTable/index.js +77 -0
- package/dist/components/ProTable/interface.d.ts +51 -0
- package/dist/components/ProTable/interface.js +1 -0
- package/dist/components/Table/components/FillDown.d.ts +8 -0
- package/dist/components/Table/components/FillDown.js +10 -0
- package/dist/components/Table/components/FilterDropdown.d.ts +14 -0
- package/dist/components/Table/components/FilterDropdown.js +69 -0
- package/dist/components/Table/constants.d.ts +2 -0
- package/dist/components/Table/constants.js +2 -0
- package/dist/components/Table/hooks/useColumns.d.ts +20 -8
- package/dist/components/Table/hooks/useColumns.js +484 -182
- package/dist/components/Table/hooks/useDropRef.js +2 -1
- package/dist/components/Table/hooks/useInnerPagination.js +1 -0
- package/dist/components/Table/hooks/useSelectSubtotal.d.ts +4 -0
- package/dist/components/Table/hooks/useSelectSubtotal.js +178 -0
- package/dist/components/Table/index.d.ts +7 -0
- package/dist/components/Table/table-adddel-column.d.ts +8 -5
- package/dist/components/Table/table-adddel-column.js +15 -5
- package/dist/components/Table/table-dynamic.js +63 -5
- package/dist/components/Table/table-enhance-cell.d.ts +6 -3
- package/dist/components/Table/table-enhance-cell.js +196 -109
- package/dist/components/Table/table-enhance-row.d.ts +4 -4
- package/dist/components/Table/table-enhance-row.js +10 -11
- package/dist/components/Table/table-headTooltip.d.ts +6 -0
- package/dist/components/Table/table-headTooltip.js +13 -0
- package/dist/components/Table/table-resizable-title.d.ts +4 -5
- package/dist/components/Table/table-resizable-title.js +32 -6
- package/dist/components/Table/table-sort.d.ts +11 -0
- package/dist/components/Table/table-sort.js +65 -0
- package/dist/components/Table/table.d.ts +20 -4
- package/dist/components/Table/table.js +478 -176
- package/dist/components/Table/utils/dom.d.ts +26 -0
- package/dist/components/Table/utils/dom.js +122 -0
- package/dist/components/Table/utils/filterHandle.d.ts +1 -0
- package/dist/components/Table/utils/filterHandle.js +51 -0
- package/dist/components/Table/utils/getSummaryData.d.ts +1 -0
- package/dist/components/Table/utils/getSummaryData.js +3 -1
- package/dist/components/Table/utils/shallowEqual.d.ts +2 -0
- package/dist/components/Table/utils/shallowEqual.js +34 -0
- package/dist/components/Table/utils/validate.d.ts +1 -1
- package/dist/components/Table/utils/validate.js +5 -5
- package/dist/components/TimePicker/time-picker.d.ts +0 -1
- package/dist/components/ZtIcon/index.d.ts +1 -1
- package/dist/components/business/Common/UserForgetPassword/index.js +17 -6
- package/dist/components/business/Common/UserInfo/index.js +3 -1
- package/dist/components/business/Common/UserPassword/index.d.ts +1 -0
- package/dist/components/business/Common/UserPassword/index.js +42 -14
- package/dist/components/business/Common/validatePassword.d.ts +8 -0
- package/dist/components/business/Common/validatePassword.js +168 -0
- package/dist/components/utils/index.d.ts +1 -0
- package/dist/components/utils/index.js +20 -0
- package/dist/components/utils/useLastest.d.ts +2 -0
- package/dist/components/utils/useLastest.js +6 -0
- package/dist/index.css +96 -7
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/package.json +4 -3
|
@@ -12,6 +12,7 @@ function useDropRef(index, moverow) {
|
|
|
12
12
|
collect: function (monitor) { return ({
|
|
13
13
|
isDragging: monitor.isDragging(),
|
|
14
14
|
}); },
|
|
15
|
+
canDrag: function (monitor) { var _a; return !((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.tagName.toLowerCase().match(/input|textarea/)); },
|
|
15
16
|
}); }, [index]), drag = _a[1];
|
|
16
17
|
/**
|
|
17
18
|
* @description 定义可放置项
|
|
@@ -44,7 +45,7 @@ function useDropRef(index, moverow) {
|
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
47
|
return {
|
|
47
|
-
ref:
|
|
48
|
+
ref: ref,
|
|
48
49
|
isOver: null,
|
|
49
50
|
dropClassName: null,
|
|
50
51
|
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
import { domFind } from '../utils/dom';
|
|
3
|
+
import { plus } from 'number-precision';
|
|
4
|
+
import { copyValueHandle } from '../../utils/index';
|
|
5
|
+
export default function useSelectSubtotal(tableRef, props) {
|
|
6
|
+
var onMoveRow = props.onMoveRow, onEditableSave = props.onEditableSave;
|
|
7
|
+
var tipRef = useRef();
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
if (onMoveRow || onEditableSave) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
var tableContent = domFind(tableRef.current, '.ant-table-content');
|
|
13
|
+
if (!tableContent) {
|
|
14
|
+
tableContent = domFind(tableRef.current, '.ant-table-container');
|
|
15
|
+
}
|
|
16
|
+
var tbody = domFind(tableContent, '.ant-table-tbody');
|
|
17
|
+
var container = tbody.parentNode;
|
|
18
|
+
var $tip = tipRef.current;
|
|
19
|
+
var isDragging = false;
|
|
20
|
+
var startCell = null; // 开始选中的项
|
|
21
|
+
var lastEndCell = null; // 最终选中的项
|
|
22
|
+
var textArr = []; // 选中的文本
|
|
23
|
+
var textPositionArr = []; // 包含位置信息
|
|
24
|
+
if (!container) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
var contaienrRect = container.getBoundingClientRect();
|
|
28
|
+
var mousedownHandler = function (e) {
|
|
29
|
+
if (e.target.tagName === 'TD') {
|
|
30
|
+
isDragging = true;
|
|
31
|
+
startCell = e.target;
|
|
32
|
+
// 是否按下ctrl键 可以选取多段内容
|
|
33
|
+
if (!e.ctrlKey) {
|
|
34
|
+
clearSelections();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
container.addEventListener('mousedown', mousedownHandler);
|
|
39
|
+
var mouseupHandler = function (e) {
|
|
40
|
+
isDragging = false;
|
|
41
|
+
startCell = null;
|
|
42
|
+
lastEndCell = null;
|
|
43
|
+
if (textArr.length) {
|
|
44
|
+
// console.log(textPositionArr, textArr);
|
|
45
|
+
var result = sumArrayValues(textArr);
|
|
46
|
+
if (e.target) {
|
|
47
|
+
var rect = e.target.getBoundingClientRect();
|
|
48
|
+
$tip.style.top = rect.top - contaienrRect.top + rect.height + "px";
|
|
49
|
+
$tip.style.left = rect.left - contaienrRect.left + rect.width + "px";
|
|
50
|
+
$tip.innerText = "\u5C0F\u8BA1\uFF1A " + result + " \n \u5DF2\u9009\uFF1A" + textArr.length + "\u9879";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// 是否按下ctrl键
|
|
54
|
+
if (!e.ctrlKey) {
|
|
55
|
+
container.classList.remove('table-select-none');
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
container.addEventListener('mouseup', mouseupHandler);
|
|
59
|
+
var mousemoveHandler = function (e) {
|
|
60
|
+
if (isDragging && e.target.tagName === 'TD') {
|
|
61
|
+
if (lastEndCell !== e.target) {
|
|
62
|
+
lastEndCell = e.target;
|
|
63
|
+
if (startCell !== lastEndCell) {
|
|
64
|
+
container.classList.add('table-select-none');
|
|
65
|
+
var isCtrl = e.ctrlKey;
|
|
66
|
+
selectCells(startCell, e.target, isCtrl); // 仅在必要时更新选择
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
container.addEventListener('mousemove', mousemoveHandler);
|
|
72
|
+
var selectCells = function (start, end, isCtrl) {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
if (!isCtrl) {
|
|
75
|
+
clearSelections(); // 清除之前的选择
|
|
76
|
+
}
|
|
77
|
+
if (!start || !end)
|
|
78
|
+
return;
|
|
79
|
+
var startRow = start.parentNode.rowIndex;
|
|
80
|
+
var startCol = start.cellIndex;
|
|
81
|
+
var endRow = end.parentNode.rowIndex;
|
|
82
|
+
var endCol = end.cellIndex;
|
|
83
|
+
var initRow = Math.min(startRow, endRow);
|
|
84
|
+
var lenRow = Math.max(startRow, endRow);
|
|
85
|
+
var initCell = Math.min(startCol, endCol);
|
|
86
|
+
var lenCell = Math.max(startCol, endCol);
|
|
87
|
+
for (var i = initRow; i <= lenRow; i++) {
|
|
88
|
+
var positionArr = [];
|
|
89
|
+
for (var j = initCell; j <= lenCell; j++) {
|
|
90
|
+
var $td = (_a = container.rows[i]) === null || _a === void 0 ? void 0 : _a.cells[j];
|
|
91
|
+
if ($td && !$td.classList.contains('move-selected')) {
|
|
92
|
+
var innerText = $td.innerText;
|
|
93
|
+
textArr.push(innerText);
|
|
94
|
+
positionArr.push(innerText);
|
|
95
|
+
}
|
|
96
|
+
(_b = $td === null || $td === void 0 ? void 0 : $td.classList) === null || _b === void 0 ? void 0 : _b.add('move-selected');
|
|
97
|
+
}
|
|
98
|
+
if (positionArr.length > 0) {
|
|
99
|
+
textPositionArr.push(positionArr);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var clearSelections = function () {
|
|
104
|
+
textArr = [];
|
|
105
|
+
textPositionArr = [];
|
|
106
|
+
$tip.innerText = '';
|
|
107
|
+
$tip.style.top = '-1000px';
|
|
108
|
+
$tip.style.left = '-1000px';
|
|
109
|
+
var selectedCells = container.querySelectorAll('.move-selected');
|
|
110
|
+
selectedCells.forEach(function (cell) { return cell.classList.remove('move-selected'); });
|
|
111
|
+
};
|
|
112
|
+
var keydownHandle = function (event) {
|
|
113
|
+
// 检查按下的键是否是C键
|
|
114
|
+
var isCKey = event.key === 'c' || event.key === 'C';
|
|
115
|
+
// 检查是否按下了Ctrl键(在Windows中)或Cmd键(在Mac中)
|
|
116
|
+
var isCtrlPressed = event.ctrlKey || event.metaKey;
|
|
117
|
+
// 如果同时按下了Ctrl/Cmd键和C键,则执行你的复制操作
|
|
118
|
+
if (isCtrlPressed && isCKey && textPositionArr.length > 0) {
|
|
119
|
+
// 执行你的复制操作,例如将文本添加到剪贴板
|
|
120
|
+
var textToCopy = textPositionArr
|
|
121
|
+
.map(function (row) { return row.join('\t'); })
|
|
122
|
+
.join('\n');
|
|
123
|
+
copyValueHandle(textToCopy);
|
|
124
|
+
// 阻止浏览器默认的复制操作
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
document.addEventListener('keydown', keydownHandle);
|
|
129
|
+
return function () {
|
|
130
|
+
if (container) {
|
|
131
|
+
container.removeEventListener('mousedown', mousedownHandler);
|
|
132
|
+
container.removeEventListener('mouseup', mouseupHandler);
|
|
133
|
+
container.removeEventListener('mousemove', mousemoveHandler);
|
|
134
|
+
}
|
|
135
|
+
document.removeEventListener('keydown', keydownHandle);
|
|
136
|
+
};
|
|
137
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
138
|
+
}, []);
|
|
139
|
+
return {
|
|
140
|
+
tipRef: tipRef,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// 计算相关逻辑
|
|
144
|
+
function parseValue(value) {
|
|
145
|
+
// 移除千分符和金额符号,并替换逗号
|
|
146
|
+
value = value.replace(/[$,]/g, '').replace(/,/g, '');
|
|
147
|
+
// 如果是百分号,除以100并返回
|
|
148
|
+
if (value.endsWith('%')) {
|
|
149
|
+
return parseFloat(value) / 100;
|
|
150
|
+
}
|
|
151
|
+
// 尝试将字符串转换为数字,如果无法转换,则返回NaN
|
|
152
|
+
var parsedValue = parseFloat(value);
|
|
153
|
+
return isNaN(parsedValue) ? 0 : parsedValue;
|
|
154
|
+
}
|
|
155
|
+
function sumArrayValues(arr) {
|
|
156
|
+
var sum = 0;
|
|
157
|
+
if (arr.find(function (item) { return item.indexOf('/'); })) {
|
|
158
|
+
var newArr = arr.map(function (item) {
|
|
159
|
+
var i = item.split('/');
|
|
160
|
+
return i.map(function (item) { return parseValue(item); });
|
|
161
|
+
});
|
|
162
|
+
var result = newArr.reduce(function (prev, current) {
|
|
163
|
+
var prevLen = prev.length;
|
|
164
|
+
var currentLen = current.length;
|
|
165
|
+
if (prevLen > currentLen) {
|
|
166
|
+
return prev.map(function (item, index) { return plus(current[index] || 0, item || 0); });
|
|
167
|
+
}
|
|
168
|
+
return current.map(function (item, index) { return plus(prev[index] || 0, item || 0); });
|
|
169
|
+
}, []);
|
|
170
|
+
return result.join('/');
|
|
171
|
+
}
|
|
172
|
+
for (var i = 0; i < arr.length; i++) {
|
|
173
|
+
var value = arr[i];
|
|
174
|
+
var parsedValue = parseValue(value);
|
|
175
|
+
sum = plus(sum, parsedValue);
|
|
176
|
+
}
|
|
177
|
+
return sum;
|
|
178
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import Table from './table';
|
|
2
3
|
import { Table as AntTable } from 'antd';
|
|
3
4
|
import { ColumnType } from 'antd/lib/table';
|
|
@@ -36,6 +37,12 @@ export interface IColumnType<RecordType> extends ColumnType<RecordType> {
|
|
|
36
37
|
validate?: IValidate;
|
|
37
38
|
/** 是否添加复制当前列功能 */
|
|
38
39
|
showCopy?: boolean;
|
|
40
|
+
/**表头提示信息 */
|
|
41
|
+
headTooltip?: ReactNode;
|
|
42
|
+
/** 是否需要前端过滤 */
|
|
43
|
+
isFilter?: boolean;
|
|
44
|
+
/** 是否需要往下填充 */
|
|
45
|
+
isFillDown?: boolean;
|
|
39
46
|
}
|
|
40
47
|
export interface IColumnGroupType<RecordType> extends Omit<IColumnType<RecordType>, ''> {
|
|
41
48
|
children: ColumnsType<RecordType>;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { IProps as ITableProps } from './table';
|
|
2
3
|
interface IProps {
|
|
3
4
|
/**新增行删除行方法 */
|
|
4
|
-
onAddAndDelHandle?: (type: 'add' | 'del') => void;
|
|
5
|
+
onAddAndDelHandle?: (type: 'add' | 'del', index: number) => void;
|
|
5
6
|
/**隐藏新增icon */
|
|
6
|
-
hideAddIcon?:
|
|
7
|
+
hideAddIcon?: ITableProps<any>['hideAddIcon'];
|
|
7
8
|
/**新增icon提示文字 */
|
|
8
|
-
addIconText?:
|
|
9
|
+
addIconText?: ITableProps<any>['addIconText'];
|
|
9
10
|
/**隐藏删除icon */
|
|
10
|
-
hideDelIcon?:
|
|
11
|
+
hideDelIcon?: ITableProps<any>['hideDelIcon'];
|
|
11
12
|
/**删除icon提示文字 */
|
|
12
|
-
delIconText?:
|
|
13
|
+
delIconText?: ITableProps<any>['delIconText'];
|
|
14
|
+
record?: any;
|
|
15
|
+
index: number;
|
|
13
16
|
}
|
|
14
17
|
declare const _default: React.NamedExoticComponent<IProps>;
|
|
15
18
|
export default _default;
|
|
@@ -3,15 +3,25 @@ import { PlusOutlined, MinusOutlined } from '@ant-design/icons';
|
|
|
3
3
|
import debounce from 'lodash/debounce';
|
|
4
4
|
import { Popconfirm } from '../../index';
|
|
5
5
|
var TableAddDelColumn = function (_a) {
|
|
6
|
-
var onAddAndDelHandle = _a.onAddAndDelHandle, hideAddIcon = _a.hideAddIcon, addIconText = _a.addIconText, hideDelIcon = _a.hideDelIcon, _b = _a.delIconText, delIconText = _b === void 0 ? '是否删除该行?' : _b;
|
|
6
|
+
var onAddAndDelHandle = _a.onAddAndDelHandle, hideAddIcon = _a.hideAddIcon, addIconText = _a.addIconText, hideDelIcon = _a.hideDelIcon, _b = _a.delIconText, delIconText = _b === void 0 ? '是否删除该行?' : _b, index = _a.index, record = _a.record;
|
|
7
7
|
var onAddfn = function () {
|
|
8
|
-
onAddAndDelHandle && onAddAndDelHandle('add');
|
|
8
|
+
onAddAndDelHandle && onAddAndDelHandle('add', index);
|
|
9
9
|
};
|
|
10
|
+
var hiddenAddIcon = typeof hideAddIcon === 'function'
|
|
11
|
+
? hideAddIcon(record, index)
|
|
12
|
+
: hideAddIcon;
|
|
13
|
+
var hiddenDelIcon = typeof hideDelIcon === 'function'
|
|
14
|
+
? hideDelIcon(record, index)
|
|
15
|
+
: hideDelIcon;
|
|
10
16
|
return (React.createElement(React.Fragment, null,
|
|
11
|
-
|
|
17
|
+
hiddenAddIcon ? null : (React.createElement("div", { title: "\u65B0\u589E\u4E00\u884C", className: "zt-column__add-icon" },
|
|
12
18
|
React.createElement(PlusOutlined, { onClick: debounce(onAddfn, 500) }))),
|
|
13
|
-
|
|
14
|
-
React.createElement(Popconfirm, { title: delIconText
|
|
19
|
+
hiddenDelIcon ? null : (React.createElement("div", { title: "\u5220\u9664\u8BE5\u884C", className: "zt-column__del-icon" },
|
|
20
|
+
React.createElement(Popconfirm, { title: typeof delIconText === 'function'
|
|
21
|
+
? delIconText(record, index)
|
|
22
|
+
: delIconText, onConfirm: function () {
|
|
23
|
+
return onAddAndDelHandle && onAddAndDelHandle('del', index);
|
|
24
|
+
} },
|
|
15
25
|
React.createElement(MinusOutlined, null))))));
|
|
16
26
|
};
|
|
17
27
|
export default memo(TableAddDelColumn);
|
|
@@ -11,14 +11,52 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import React, { useState, memo, useEffect, useCallback } from 'react';
|
|
13
13
|
import { SettingOutlined } from '@ant-design/icons';
|
|
14
|
-
import {
|
|
14
|
+
import { Switch } from 'antd';
|
|
15
|
+
import { Drawer, Button, Checkbox, message, SortableCancel, Popover, } from '../../index';
|
|
15
16
|
import { useDrop } from 'react-dnd';
|
|
16
17
|
import { dynamicColumnDragType } from './constants';
|
|
17
18
|
import update from 'immutability-helper';
|
|
19
|
+
import { Select } from 'antd';
|
|
20
|
+
function DynamicItemConfig(_a) {
|
|
21
|
+
var fixed = _a.fixed, onConfigItemHandle = _a.onConfigItemHandle;
|
|
22
|
+
var _b = useState({
|
|
23
|
+
isFixed: !fixed ? false : true,
|
|
24
|
+
fixed: fixed === true ? 'left' : fixed || 'left',
|
|
25
|
+
}), config = _b[0], setConfig = _b[1];
|
|
26
|
+
var onCheckedChangeHandle = function (e) {
|
|
27
|
+
setConfig(function (state) {
|
|
28
|
+
return __assign(__assign({}, state), { isFixed: e });
|
|
29
|
+
});
|
|
30
|
+
onConfigItemHandle(__assign(__assign({}, config), { isFixed: e }));
|
|
31
|
+
};
|
|
32
|
+
var onSelectChangeHandle = function (e) {
|
|
33
|
+
setConfig(function (state) {
|
|
34
|
+
return __assign(__assign({}, state), { fixed: e });
|
|
35
|
+
});
|
|
36
|
+
onConfigItemHandle(__assign(__assign({}, config), { fixed: e }));
|
|
37
|
+
};
|
|
38
|
+
return (React.createElement("div", { style: {
|
|
39
|
+
float: 'right',
|
|
40
|
+
} },
|
|
41
|
+
React.createElement(Popover, { content: React.createElement(React.Fragment, null,
|
|
42
|
+
React.createElement(Switch, { checked: config.isFixed, onChange: onCheckedChangeHandle }),
|
|
43
|
+
React.createElement(Select, { value: config.fixed, options: [
|
|
44
|
+
{
|
|
45
|
+
label: '左',
|
|
46
|
+
value: 'left',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
label: '右',
|
|
50
|
+
value: 'right',
|
|
51
|
+
},
|
|
52
|
+
], allowClear: false, disabled: config.isFixed === false, onChange: onSelectChangeHandle })), trigger: "click", placement: "bottomRight" },
|
|
53
|
+
React.createElement(Button, { icon: React.createElement(SettingOutlined, null), shape: "circle", size: "small" }))));
|
|
54
|
+
}
|
|
18
55
|
function TableDynamic(props) {
|
|
19
56
|
var visible = props.visible, onClose = props.onClose, onReset = props.onReset, onSave = props.onSave, columns = props.columns;
|
|
20
57
|
var _a = useState(columns || []), dynamicColumns = _a[0], setDynamicColumns = _a[1];
|
|
21
58
|
var _b = useState([]), checkedValues = _b[0], setCheckedValues = _b[1];
|
|
59
|
+
var _c = useState({}), dynamicColumnConfigs = _c[0], setDynamicColumnConfigs = _c[1];
|
|
22
60
|
useEffect(function () {
|
|
23
61
|
setDynamicColumns(columns || []);
|
|
24
62
|
var _checkedValues = [];
|
|
@@ -43,7 +81,13 @@ function TableDynamic(props) {
|
|
|
43
81
|
if (checkedValues.includes(dynamicColumn.key)) {
|
|
44
82
|
dynamicColumn.hideColumn = false;
|
|
45
83
|
}
|
|
46
|
-
|
|
84
|
+
if (dynamicColumnConfigs[dynamicColumn.key]) {
|
|
85
|
+
var _a = dynamicColumnConfigs[dynamicColumn.key], isFixed = _a.isFixed, fixed = _a.fixed;
|
|
86
|
+
return __assign(__assign({}, dynamicColumn), { fixed: isFixed ? fixed : false });
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return __assign({}, dynamicColumn);
|
|
90
|
+
}
|
|
47
91
|
});
|
|
48
92
|
onClose && onClose();
|
|
49
93
|
onSave && onSave(saveResult);
|
|
@@ -75,6 +119,14 @@ function TableDynamic(props) {
|
|
|
75
119
|
var onDynamicChangeHandle = function (checkedValue) {
|
|
76
120
|
setCheckedValues(checkedValue);
|
|
77
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* @description 修改配置触发的回调
|
|
124
|
+
*/
|
|
125
|
+
var onConfigItemHandle = function (dynamicColumnConfigs) {
|
|
126
|
+
setDynamicColumnConfigs(function (state) {
|
|
127
|
+
return __assign(__assign({}, state), dynamicColumnConfigs);
|
|
128
|
+
});
|
|
129
|
+
};
|
|
78
130
|
return (React.createElement(Drawer, { placement: "right", getContainer: false, closable: false, maskClosable: false,
|
|
79
131
|
// style={{ position: 'absolute' }}
|
|
80
132
|
visible: visible, className: "zt-table__dynamic", title: React.createElement("div", null,
|
|
@@ -86,15 +138,21 @@ function TableDynamic(props) {
|
|
|
86
138
|
React.createElement(Button, { type: "default", onClick: onReset }, "\u91CD\u7F6E"),
|
|
87
139
|
React.createElement(Button, { type: "primary", onClick: onSureHandle }, "\u786E\u5B9A")) },
|
|
88
140
|
React.createElement(Checkbox.Group, { style: { width: '100%' }, value: checkedValues, onChange: onDynamicChangeHandle },
|
|
89
|
-
React.createElement(Container, { dynamicColumns: dynamicColumns, onFindItemHandle: onFindItemHandle, onMoveItemHandle: onMoveItemHandle }))));
|
|
141
|
+
React.createElement(Container, { dynamicColumns: dynamicColumns, onFindItemHandle: onFindItemHandle, onMoveItemHandle: onMoveItemHandle, onConfigItemHandle: onConfigItemHandle }))));
|
|
90
142
|
}
|
|
91
143
|
function Container(_a) {
|
|
92
|
-
var dynamicColumns = _a.dynamicColumns, onFindItemHandle = _a.onFindItemHandle, onMoveItemHandle = _a.onMoveItemHandle;
|
|
144
|
+
var dynamicColumns = _a.dynamicColumns, onFindItemHandle = _a.onFindItemHandle, onMoveItemHandle = _a.onMoveItemHandle, onConfigItemHandle = _a.onConfigItemHandle;
|
|
93
145
|
var _b = useDrop(function () { return ({ accept: dynamicColumnDragType }); }), drop = _b[1];
|
|
94
146
|
return (React.createElement("div", { ref: drop }, Array.isArray(dynamicColumns) &&
|
|
95
147
|
dynamicColumns.map(function (column, index) {
|
|
96
148
|
return column.key ? (React.createElement(SortableCancel, { type: dynamicColumnDragType, key: column.key, id: column.key, onFindItem: onFindItemHandle, onMoveItem: onMoveItemHandle },
|
|
97
|
-
React.createElement(Checkbox, { value: column.key }, column.title)
|
|
149
|
+
React.createElement(Checkbox, { value: column.key, disabled: column.isNoDynamicHide }, column.title),
|
|
150
|
+
React.createElement(DynamicItemConfig, { fixed: column.fixed, onConfigItemHandle: function (e) {
|
|
151
|
+
var _a;
|
|
152
|
+
onConfigItemHandle((_a = {},
|
|
153
|
+
_a[column.key] = e,
|
|
154
|
+
_a));
|
|
155
|
+
} }))) : null;
|
|
98
156
|
})));
|
|
99
157
|
}
|
|
100
158
|
export default memo(TableDynamic);
|
|
@@ -33,10 +33,13 @@ interface IEditableCellProps {
|
|
|
33
33
|
children: React.ReactNode;
|
|
34
34
|
dataIndex: string;
|
|
35
35
|
record: any;
|
|
36
|
-
handleSave: (record: any, index: number | undefined, dataIndex: string
|
|
36
|
+
handleSave: (record: any, index: number | undefined, dataIndex: string, otherInfo?: {
|
|
37
|
+
isInner?: boolean;
|
|
38
|
+
}) => void;
|
|
37
39
|
columns: any;
|
|
38
40
|
onTableChange: any;
|
|
39
41
|
currentpage: ICurrentPage;
|
|
42
|
+
[props: string]: any;
|
|
40
43
|
}
|
|
41
|
-
declare const
|
|
42
|
-
export default
|
|
44
|
+
declare const _default: React.NamedExoticComponent<IEditableCellProps>;
|
|
45
|
+
export default _default;
|