ztxkui 4.2.23-567 → 4.2.23-569
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.
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import 'react-contexify/dist/ReactContexify.min.css';
|
|
3
|
-
declare const TableMenu: ({ menuId, columns, originColumns, tableRef, virtualTableKey, onEditableSave, }: {
|
|
3
|
+
declare const TableMenu: ({ menuId, columns, originColumns, tableRef, virtualTableKey, onEditableSave, isContextMenuFullscreen, }: {
|
|
4
4
|
menuId: any;
|
|
5
5
|
columns: any;
|
|
6
6
|
originColumns: any;
|
|
7
7
|
tableRef: any;
|
|
8
8
|
virtualTableKey: any;
|
|
9
9
|
onEditableSave: any;
|
|
10
|
+
isContextMenuFullscreen: any;
|
|
10
11
|
}) => JSX.Element;
|
|
11
12
|
export default TableMenu;
|
|
@@ -17,7 +17,7 @@ import screenfull from 'screenfull';
|
|
|
17
17
|
import TableEnhanceCell from './table-enhance-cell';
|
|
18
18
|
import { Modal, Descriptions, Button } from '../../index.build';
|
|
19
19
|
var TableMenu = function (_a) {
|
|
20
|
-
var menuId = _a.menuId, columns = _a.columns, originColumns = _a.originColumns, tableRef = _a.tableRef, virtualTableKey = _a.virtualTableKey, onEditableSave = _a.onEditableSave;
|
|
20
|
+
var menuId = _a.menuId, columns = _a.columns, originColumns = _a.originColumns, tableRef = _a.tableRef, virtualTableKey = _a.virtualTableKey, onEditableSave = _a.onEditableSave, isContextMenuFullscreen = _a.isContextMenuFullscreen;
|
|
21
21
|
var _b = useState(false), visible = _b[0], setVisible = _b[1];
|
|
22
22
|
var _c = useState(undefined), record = _c[0], setRecord = _c[1];
|
|
23
23
|
var _d = useState(-1), recordIndex = _d[0], setRecordIndex = _d[1];
|
|
@@ -29,12 +29,17 @@ var TableMenu = function (_a) {
|
|
|
29
29
|
})
|
|
30
30
|
.map(function (item) {
|
|
31
31
|
var originItem = originColumns.find(function (originItem) { return originItem.key === item.key; });
|
|
32
|
+
console.log(originItem, item);
|
|
32
33
|
return {
|
|
33
34
|
key: item.key,
|
|
34
35
|
label: (originItem === null || originItem === void 0 ? void 0 : originItem.title) || item.title,
|
|
35
36
|
render: originItem === null || originItem === void 0 ? void 0 : originItem.render,
|
|
36
37
|
onCell: item.onCell,
|
|
37
38
|
editable: item.editable,
|
|
39
|
+
validate: (item === null || item === void 0 ? void 0 : item.validate) ||
|
|
40
|
+
(originItem === null || originItem === void 0 ? void 0 : originItem.validate) ||
|
|
41
|
+
(item === null || item === void 0 ? void 0 : item.required) ||
|
|
42
|
+
(originItem === null || originItem === void 0 ? void 0 : originItem.required),
|
|
38
43
|
};
|
|
39
44
|
});
|
|
40
45
|
function onMenuItemClick(e) {
|
|
@@ -112,13 +117,15 @@ var TableMenu = function (_a) {
|
|
|
112
117
|
}
|
|
113
118
|
// 如果item.render 返回的不是ReactElement,那么就使用span来包裹
|
|
114
119
|
// 做列合并时,render返回的是一个对象
|
|
115
|
-
return (React.createElement(Descriptions.Item, { key: item.key, label:
|
|
120
|
+
return (React.createElement(Descriptions.Item, { key: item.key, label: React.createElement("span", { style: { display: 'flex', alignItems: 'center' } },
|
|
121
|
+
React.createElement("span", { style: { color: 'red' } }, item.validate ? '*' : ''),
|
|
122
|
+
item.label) }, isValidElement(renderItem) ? (renderItem) : isValidElement(renderItem === null || renderItem === void 0 ? void 0 : renderItem.children) ? (renderItem === null || renderItem === void 0 ? void 0 : renderItem.children) : (React.createElement("span", { title: currentRecord[item.key] }, currentRecord[item.key]))));
|
|
116
123
|
});
|
|
117
124
|
}
|
|
118
125
|
return (React.createElement(React.Fragment, null,
|
|
119
126
|
React.createElement(Menu, { id: menuId },
|
|
120
127
|
React.createElement(Item, { data: "detail", onClick: onMenuItemClick }, i18next.t('查看明细')),
|
|
121
|
-
onEditableSave ? null : (React.createElement(Item, { data: "fullscreen", onClick: onMenuItemClick }, isFull ? i18next.t('退出全屏') : i18next.t('全屏')))),
|
|
128
|
+
onEditableSave || !isContextMenuFullscreen ? null : (React.createElement(Item, { data: "fullscreen", onClick: onMenuItemClick }, isFull ? i18next.t('退出全屏') : i18next.t('全屏')))),
|
|
122
129
|
React.createElement(Modal, { width: '800px', title: i18next.t('详情'), visible: visible, onCancel: onCancel, stick: true, loading: false, footer: React.createElement("div", { style: { textAlign: 'right', paddingRight: '10px' } },
|
|
123
130
|
React.createElement(Button, { type: "primary", onClick: onCancel }, i18next.t('关闭'))), getContainer: false },
|
|
124
131
|
React.createElement("div", { style: { maxHeight: '70vh', overflow: 'auto' } },
|
|
@@ -110,6 +110,8 @@ export interface IProps<RecordType> extends Omit<TableProps<RecordType>, 'column
|
|
|
110
110
|
defaultTableSummaryCollapseShow?: boolean;
|
|
111
111
|
/** 是否默认显示操作按钮组更多 */
|
|
112
112
|
defaultTableOperationBtnGroupShowMore?: boolean;
|
|
113
|
+
/** 右键是否显示全屏功能 */
|
|
114
|
+
isContextMenuFullscreen?: boolean;
|
|
113
115
|
}
|
|
114
116
|
/**
|
|
115
117
|
* TodoList
|
|
@@ -134,8 +134,8 @@ export function usePrevious(value) {
|
|
|
134
134
|
function Table(props) {
|
|
135
135
|
var _this = this;
|
|
136
136
|
var _a, _b, _c;
|
|
137
|
-
var className = props.className, scroll = props.scroll, _d = props.pagination, pagination = _d === void 0 ? false : _d, _e = props.bordered, bordered = _e === void 0 ? true : _e, _columns = props.columns, initColumns = props.initColumns, dataSource = props.dataSource, onAddAndDelHandle = props.onAddAndDelHandle, hideAddIcon = props.hideAddIcon, addIconText = props.addIconText, hideDelIcon = props.hideDelIcon, showDelAllBtn = props.showDelAllBtn, delAllChange = props.delAllChange, delIconText = props.delIconText, hiddenColumnDynamicIcon = props.hiddenColumnDynamicIcon, showColumnDynamic = props.showColumnDynamic, showColumnDynamicKey = props.showColumnDynamicKey, summaryConfig = props.summaryConfig, summaryFixed = props.summaryFixed, summary = props.summary, onMoveRow = props.onMoveRow, onEditableSave = props.onEditableSave, onDynamicChange = props.onDynamicChange, _f = props.isResizableColumn, isResizableColumn = _f === void 0 ? true : _f, configInfo = props.configInfo, tableHandleRef = props.tableHandleRef, tableName = props.tableName, isFlex = props.isFlex, onTableChange = props.onTableChange, rowSelection = props.rowSelection, showInnerPagination = props.showInnerPagination, defaultInnerPageSize = props.defaultInnerPageSize, virtualTableKey = props.virtualTableKey, _g = props.isSort, isSort = _g === void 0 ? true : _g, onSortChange = props.onSortChange, onFillDownChange = props.onFillDownChange, isInitSaveColumnDynamic = props.isInitSaveColumnDynamic, _h = props.isAutoClearSort, isAutoClearSort = _h === void 0 ? true : _h, isHeaderTitleWrap = props.isHeaderTitleWrap, isExternalSort = props.isExternalSort, onRow = props.onRow, isContextMenu = props.isContextMenu, diffData = props.diffData, _j = props.isDiffDataIncludeEmpty, isDiffDataIncludeEmpty = _j === void 0 ? true : _j, diffDataColor = props.diffDataColor, deptParams = props.deptParams, _k = props.isNumberInputThousandth, isNumberInputThousandth = _k === void 0 ? true : _k, _l = props.isNumberInputAlignRight, isNumberInputAlignRight = _l === void 0 ? true : _l, updateData = props.updateData, isRecordScrollPosition = props.isRecordScrollPosition, scrollPositionKey = props.scrollPositionKey, isTableSummaryCollapse = props.isTableSummaryCollapse, defaultTableSummaryCollapseShow = props.defaultTableSummaryCollapseShow, defaultTableOperationBtnGroupShowMore = props.defaultTableOperationBtnGroupShowMore, restProps = __rest(props, ["className", "scroll", "pagination", "bordered", "columns", "initColumns", "dataSource", "onAddAndDelHandle", "hideAddIcon", "addIconText", "hideDelIcon", "showDelAllBtn", "delAllChange", "delIconText", "hiddenColumnDynamicIcon", "showColumnDynamic", "showColumnDynamicKey", "summaryConfig", "summaryFixed", "summary", "onMoveRow", "onEditableSave", "onDynamicChange", "isResizableColumn", "configInfo", "tableHandleRef", "tableName", "isFlex", "onTableChange", "rowSelection", "showInnerPagination", "defaultInnerPageSize", "virtualTableKey", "isSort", "onSortChange", "onFillDownChange", "isInitSaveColumnDynamic", "isAutoClearSort", "isHeaderTitleWrap", "isExternalSort", "onRow", "isContextMenu", "diffData", "isDiffDataIncludeEmpty", "diffDataColor", "deptParams", "isNumberInputThousandth", "isNumberInputAlignRight", "updateData", "isRecordScrollPosition", "scrollPositionKey", "isTableSummaryCollapse", "defaultTableSummaryCollapseShow", "defaultTableOperationBtnGroupShowMore"]);
|
|
138
|
-
var
|
|
137
|
+
var className = props.className, scroll = props.scroll, _d = props.pagination, pagination = _d === void 0 ? false : _d, _e = props.bordered, bordered = _e === void 0 ? true : _e, _columns = props.columns, initColumns = props.initColumns, dataSource = props.dataSource, onAddAndDelHandle = props.onAddAndDelHandle, hideAddIcon = props.hideAddIcon, addIconText = props.addIconText, hideDelIcon = props.hideDelIcon, showDelAllBtn = props.showDelAllBtn, delAllChange = props.delAllChange, delIconText = props.delIconText, hiddenColumnDynamicIcon = props.hiddenColumnDynamicIcon, showColumnDynamic = props.showColumnDynamic, showColumnDynamicKey = props.showColumnDynamicKey, summaryConfig = props.summaryConfig, summaryFixed = props.summaryFixed, summary = props.summary, onMoveRow = props.onMoveRow, onEditableSave = props.onEditableSave, onDynamicChange = props.onDynamicChange, _f = props.isResizableColumn, isResizableColumn = _f === void 0 ? true : _f, configInfo = props.configInfo, tableHandleRef = props.tableHandleRef, tableName = props.tableName, isFlex = props.isFlex, onTableChange = props.onTableChange, rowSelection = props.rowSelection, showInnerPagination = props.showInnerPagination, defaultInnerPageSize = props.defaultInnerPageSize, virtualTableKey = props.virtualTableKey, _g = props.isSort, isSort = _g === void 0 ? true : _g, onSortChange = props.onSortChange, onFillDownChange = props.onFillDownChange, isInitSaveColumnDynamic = props.isInitSaveColumnDynamic, _h = props.isAutoClearSort, isAutoClearSort = _h === void 0 ? true : _h, isHeaderTitleWrap = props.isHeaderTitleWrap, isExternalSort = props.isExternalSort, onRow = props.onRow, isContextMenu = props.isContextMenu, diffData = props.diffData, _j = props.isDiffDataIncludeEmpty, isDiffDataIncludeEmpty = _j === void 0 ? true : _j, diffDataColor = props.diffDataColor, deptParams = props.deptParams, _k = props.isNumberInputThousandth, isNumberInputThousandth = _k === void 0 ? true : _k, _l = props.isNumberInputAlignRight, isNumberInputAlignRight = _l === void 0 ? true : _l, updateData = props.updateData, isRecordScrollPosition = props.isRecordScrollPosition, scrollPositionKey = props.scrollPositionKey, isTableSummaryCollapse = props.isTableSummaryCollapse, defaultTableSummaryCollapseShow = props.defaultTableSummaryCollapseShow, defaultTableOperationBtnGroupShowMore = props.defaultTableOperationBtnGroupShowMore, _m = props.isContextMenuFullscreen, isContextMenuFullscreen = _m === void 0 ? true : _m, restProps = __rest(props, ["className", "scroll", "pagination", "bordered", "columns", "initColumns", "dataSource", "onAddAndDelHandle", "hideAddIcon", "addIconText", "hideDelIcon", "showDelAllBtn", "delAllChange", "delIconText", "hiddenColumnDynamicIcon", "showColumnDynamic", "showColumnDynamicKey", "summaryConfig", "summaryFixed", "summary", "onMoveRow", "onEditableSave", "onDynamicChange", "isResizableColumn", "configInfo", "tableHandleRef", "tableName", "isFlex", "onTableChange", "rowSelection", "showInnerPagination", "defaultInnerPageSize", "virtualTableKey", "isSort", "onSortChange", "onFillDownChange", "isInitSaveColumnDynamic", "isAutoClearSort", "isHeaderTitleWrap", "isExternalSort", "onRow", "isContextMenu", "diffData", "isDiffDataIncludeEmpty", "diffDataColor", "deptParams", "isNumberInputThousandth", "isNumberInputAlignRight", "updateData", "isRecordScrollPosition", "scrollPositionKey", "isTableSummaryCollapse", "defaultTableSummaryCollapseShow", "defaultTableOperationBtnGroupShowMore", "isContextMenuFullscreen"]);
|
|
138
|
+
var _o = useBaseContext(), isEnableDecimalByDept = _o.isEnableDecimalByDept, contextIsTableSummaryCollapse = _o.isTableSummaryCollapse, isTableSummaryCollapseDefaultShow = _o.isTableSummaryCollapseDefaultShow, isOperationBtnGroupShowMoreDefault = _o.isOperationBtnGroupShowMoreDefault, isTableEditShowContextMenu = _o.isTableEditShowContextMenu;
|
|
139
139
|
// 如果开启了表格列过滤
|
|
140
140
|
var isHasFilterRef = useRef(false);
|
|
141
141
|
var deptParamsRef = useLastest(deptParams);
|
|
@@ -146,19 +146,19 @@ function Table(props) {
|
|
|
146
146
|
'zt-table--flex': isFlex,
|
|
147
147
|
'zt-table-header-title--wrap': isHeaderTitleWrap,
|
|
148
148
|
});
|
|
149
|
-
var
|
|
149
|
+
var _p = useState(false), dynamicVisible = _p[0], setDynamicVisible = _p[1];
|
|
150
150
|
var showDynamicHandle = useCallback(function () { return setDynamicVisible(true); }, []);
|
|
151
151
|
var hideDynamicHandle = useCallback(function () { return setDynamicVisible(false); }, []);
|
|
152
152
|
var dataSourceRef = useRef();
|
|
153
153
|
var preDataSource = usePrevious(dataSource);
|
|
154
|
-
var
|
|
154
|
+
var _q = useState(), sortDataSource = _q[0], setSortDataSource = _q[1];
|
|
155
155
|
var isTableEditShowContextMenuBool = getFinalValue(isTableEditShowContextMenu, isContextMenu);
|
|
156
156
|
// 非编辑表格默认加上全屏功能
|
|
157
157
|
var menuId = useState(isTableEditShowContextMenuBool || !props.onEditableSave
|
|
158
158
|
? 'menuId-' + Math.floor(Math.random() * 100000000)
|
|
159
159
|
: undefined)[0];
|
|
160
160
|
// 内部分页相关配置
|
|
161
|
-
var
|
|
161
|
+
var _r = useInnerPagination(showInnerPagination, defaultInnerPageSize), paginationConfig = _r.paginationConfig, currentPage = _r.currentPage, setCurrent = _r.setCurrent, pageSize = _r.pageSize;
|
|
162
162
|
var rowSelectionDataSource = useRef({});
|
|
163
163
|
var myScroll = useMemo(function () {
|
|
164
164
|
if (scroll) {
|
|
@@ -213,7 +213,7 @@ function Table(props) {
|
|
|
213
213
|
// 表头放大镜的条件
|
|
214
214
|
var filterSearchValuesRef = useRef({});
|
|
215
215
|
// 2023-05-04 自定义表格排序方法
|
|
216
|
-
var
|
|
216
|
+
var _s = useState(), customOrder = _s[0], setCustomOrder = _s[1];
|
|
217
217
|
var customSortHandle = useCallback(function (info, options) {
|
|
218
218
|
if (Array.isArray(expandableDataSource) &&
|
|
219
219
|
expandableDataSource.length > 1) {
|
|
@@ -399,12 +399,12 @@ function Table(props) {
|
|
|
399
399
|
var menuShow = useContextMenu({
|
|
400
400
|
id: menuId,
|
|
401
401
|
}).show;
|
|
402
|
-
var
|
|
402
|
+
var _t = useScrollPosition({
|
|
403
403
|
tableRef: tableRef,
|
|
404
404
|
isRecordScrollPosition: isRecordScrollPosition,
|
|
405
405
|
virtualTableKey: virtualTableKey,
|
|
406
406
|
storageKey: scrollPositionKey || virtualTableKey || showColumnDynamicKey,
|
|
407
|
-
}), removeScrollPosition =
|
|
407
|
+
}), removeScrollPosition = _t.removeScrollPosition, setTableScroll = _t.setTableScroll;
|
|
408
408
|
// 记录需要控制小数位数的字段(再小计的时候,需要控制小数位数)
|
|
409
409
|
var decimalFieldsRef = useRef({});
|
|
410
410
|
// 记录自动小数位(数据有几位小数就显示几位小数,影响小计)
|
|
@@ -415,7 +415,7 @@ function Table(props) {
|
|
|
415
415
|
*/
|
|
416
416
|
var isTableOperationBtnGroupShowMore = getFinalValue(isOperationBtnGroupShowMoreDefault, defaultTableOperationBtnGroupShowMore);
|
|
417
417
|
var onFillDownChangeRef = useLastest(onFillDownChange);
|
|
418
|
-
var
|
|
418
|
+
var _u = useColumns({
|
|
419
419
|
columns: _columns,
|
|
420
420
|
hiddenColumnDynamicIcon: hiddenColumnDynamicIcon,
|
|
421
421
|
showColumnDynamic: showColumnDynamic,
|
|
@@ -454,7 +454,7 @@ function Table(props) {
|
|
|
454
454
|
decimalFieldsRef: decimalFieldsRef,
|
|
455
455
|
autoDecimalFieldsRef: autoDecimalFieldsRef,
|
|
456
456
|
isTableOperationBtnGroupShowMore: isTableOperationBtnGroupShowMore,
|
|
457
|
-
}), newColumns =
|
|
457
|
+
}), newColumns = _u.newColumns, dynamicColumns = _u.dynamicColumns, refreshColumnsHandle = _u.refreshColumnsHandle;
|
|
458
458
|
/**
|
|
459
459
|
* 做一些监听
|
|
460
460
|
*/
|
|
@@ -723,7 +723,7 @@ function Table(props) {
|
|
|
723
723
|
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
724
724
|
// }, [sortDataSource, expandableDataSource]);
|
|
725
725
|
// 为了兼容外部使用受控模式调用。
|
|
726
|
-
var
|
|
726
|
+
var _v = useState([]), innerRowSelection = _v[0], setInnerRowSelection = _v[1];
|
|
727
727
|
// 如果传入了默认值,但是没有 传入受控值 需要设置下默认值
|
|
728
728
|
var isFirstRowSelectionRef = useRef(false);
|
|
729
729
|
useEffect(function () {
|
|
@@ -1126,7 +1126,7 @@ function Table(props) {
|
|
|
1126
1126
|
// 表格合计
|
|
1127
1127
|
var _isTableSummaryCollapse = getFinalValue(contextIsTableSummaryCollapse, isTableSummaryCollapse);
|
|
1128
1128
|
var isTableSummaryCollapseDefault = getFinalValue(isTableSummaryCollapseDefaultShow, defaultTableSummaryCollapseShow);
|
|
1129
|
-
var
|
|
1129
|
+
var _w = useTableSummaryCollapse(tableRef, isTableSummaryCollapseDefault), showSummary = _w.showSummary, renderTableSummaryCollapse = _w.renderTableSummaryCollapse;
|
|
1130
1130
|
var onSummaryHandle = useCallback(function (pageData) {
|
|
1131
1131
|
var _a;
|
|
1132
1132
|
var _b = rowSelectionDataSource.current || {}, isChange = _b.isChange, selectedRowKeys = _b.selectedRowKeys, selectedRows = _b.selectedRows;
|
|
@@ -1260,7 +1260,7 @@ function Table(props) {
|
|
|
1260
1260
|
summary: summaryConfig ? onSummaryHandle : summary, rowSelection: rowSelection ? rowSelectionObj : rowSelection }, restProps)),
|
|
1261
1261
|
showColumnDynamic && dynamicVisible && (React.createElement(TableDynamic, { visible: dynamicVisible, onClose: hideDynamicHandle, onSave: saveDynamicHandle, onReset: resetDynamicHandle, columns: dynamicColumns, dynamicStorageKey: showColumnDynamicKey, innerDynamicList: initColumns || _columns || [], newColumns: newColumns }))),
|
|
1262
1262
|
React.createElement("div", { ref: tipRef, className: "table-subtotal--tip" }),
|
|
1263
|
-
menuId && (React.createElement(TableMenu, { menuId: menuId, columns: newColumns, originColumns: _columns, tableRef: tableRef, virtualTableKey: virtualTableKey, onEditableSave: props.onEditableSave })))));
|
|
1263
|
+
menuId && (React.createElement(TableMenu, { menuId: menuId, columns: newColumns, originColumns: _columns, tableRef: tableRef, virtualTableKey: virtualTableKey, onEditableSave: props.onEditableSave, isContextMenuFullscreen: isContextMenuFullscreen })))));
|
|
1264
1264
|
}
|
|
1265
1265
|
// export default memo(Table, (prevProps, nextProps) => {
|
|
1266
1266
|
// return shallowEqual(prevProps, nextProps);
|