ztxkui 4.2.23-330 → 4.2.23-331
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/UI/Table/DefaultTable.js +1 -1
- package/dist/UI/Table/data.js +1 -1
- package/dist/components/PrintBox/demoComponents/index.js +4 -1
- package/dist/components/PrintBox/hooks/useCreatePdf.d.ts +3 -0
- package/dist/components/PrintBox/hooks/useCreatePdf.js +6 -10
- package/dist/components/PrintBox/interface.d.ts +2 -0
- package/dist/components/PrintBox/pdf/water.js +1 -0
- package/dist/components/Table/hooks/useSelectSubtotal.js +33 -16
- package/dist/components/Table/table.js +5 -1
- package/package.json +1 -1
|
@@ -180,7 +180,7 @@ function useColumns() {
|
|
|
180
180
|
}
|
|
181
181
|
export default function DefaultTable() {
|
|
182
182
|
var columns = useColumns().columns;
|
|
183
|
-
var _a = useState(data1
|
|
183
|
+
var _a = useState(data1), data = _a[0], setData = _a[1];
|
|
184
184
|
var _b = useState(1), key = _b[0], setKey = _b[1];
|
|
185
185
|
var handleRef = useRef({});
|
|
186
186
|
var _c = useRememberCheckData(handleRef), checkedData = _c.checkedData, setCheckedData = _c.setCheckedData, selections = _c.selections, changeCheckedDataHandle = _c.changeCheckedDataHandle;
|
package/dist/UI/Table/data.js
CHANGED
|
@@ -106,7 +106,10 @@ var Demo = function () {
|
|
|
106
106
|
case 0:
|
|
107
107
|
_f.trys.push([0, 3, , 4]);
|
|
108
108
|
return [4 /*yield*/, ((_b = (_a = printRef.current) === null || _a === void 0 ? void 0 : _a.innerExportCanvasPdfHandler) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
109
|
-
isDownload:
|
|
109
|
+
isDownload: true,
|
|
110
|
+
pdfConfig: {
|
|
111
|
+
orientation: 'p',
|
|
112
|
+
},
|
|
110
113
|
}))];
|
|
111
114
|
case 1:
|
|
112
115
|
pdfObj = _f.sent();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ICanvasPdfProps } from '../interface';
|
|
2
2
|
import { IHtmlToPdfConfig } from '../pdf/htmlToPdf';
|
|
3
|
+
import { IPdfConfig } from '../pdf/pdf';
|
|
3
4
|
/**
|
|
4
5
|
* html生成canvas生成PDF
|
|
5
6
|
*/
|
|
@@ -35,7 +36,9 @@ interface ICreateCanvasPdfOption extends ICreatePdfOption {
|
|
|
35
36
|
insertFooter?: IHtmlToPdfConfig['insertFooter'];
|
|
36
37
|
/** 页脚距离上边的距离 */
|
|
37
38
|
footerTopMargin?: IHtmlToPdfConfig['footerTopMargin'];
|
|
39
|
+
pdfConfig?: IPdfConfig;
|
|
38
40
|
}
|
|
39
41
|
interface ICreateHtmlPdfOption extends ICreatePdfOption {
|
|
42
|
+
pdfConfig?: IPdfConfig;
|
|
40
43
|
}
|
|
41
44
|
export {};
|
|
@@ -75,11 +75,11 @@ export default function useCreatePdf(props) {
|
|
|
75
75
|
isAutoDownload: isAutoSeal,
|
|
76
76
|
}).getFontHandler;
|
|
77
77
|
var createCanvasPdfHandler = useMemoizedFn(function (option) { return __awaiter(_this, void 0, void 0, function () {
|
|
78
|
-
var _a, isDownload, isWater, pdfOptions, result, result_1, err_1;
|
|
78
|
+
var _a, isDownload, isWater, pdfConfig, pdfOptions, result, result_1, err_1;
|
|
79
79
|
return __generator(this, function (_b) {
|
|
80
80
|
switch (_b.label) {
|
|
81
81
|
case 0:
|
|
82
|
-
_a = option || {}, isDownload = _a.isDownload, isWater = _a.isWater, pdfOptions = __rest(_a, ["isDownload", "isWater"]);
|
|
82
|
+
_a = option || {}, isDownload = _a.isDownload, isWater = _a.isWater, pdfConfig = _a.pdfConfig, pdfOptions = __rest(_a, ["isDownload", "isWater", "pdfConfig"]);
|
|
83
83
|
return [4 /*yield*/, canExecuteClickHandle('导出PDF操作不能继续,请联系管理员!', 'canvasPdf')];
|
|
84
84
|
case 1:
|
|
85
85
|
result = _b.sent();
|
|
@@ -91,9 +91,7 @@ export default function useCreatePdf(props) {
|
|
|
91
91
|
_b.trys.push([2, 6, , 7]);
|
|
92
92
|
return [4 /*yield*/, htmlToPdf(__assign({ pageDom: pageDom, waterConfig: isWater ? waterConfig : undefined,
|
|
93
93
|
// isDownload: isCanvasPdfDownload ? true : false,
|
|
94
|
-
isDownload: isDownload, pdfConfig: {
|
|
95
|
-
orientation: 'l',
|
|
96
|
-
}, useCanvas: true }, pdfOptions))];
|
|
94
|
+
isDownload: isDownload, pdfConfig: __assign({ orientation: 'l' }, pdfConfig), useCanvas: true }, pdfOptions))];
|
|
97
95
|
case 3:
|
|
98
96
|
result_1 = _b.sent();
|
|
99
97
|
if (!onExecuteClick) return [3 /*break*/, 5];
|
|
@@ -114,11 +112,11 @@ export default function useCreatePdf(props) {
|
|
|
114
112
|
});
|
|
115
113
|
}); });
|
|
116
114
|
var createHtmlPdfHandler = useMemoizedFn(function (option) { return __awaiter(_this, void 0, void 0, function () {
|
|
117
|
-
var _a, isDownload, isWater, result, result_2, err_2;
|
|
115
|
+
var _a, isDownload, isWater, pdfConfig, result, result_2, err_2;
|
|
118
116
|
return __generator(this, function (_b) {
|
|
119
117
|
switch (_b.label) {
|
|
120
118
|
case 0:
|
|
121
|
-
_a = option || {}, isDownload = _a.isDownload, isWater = _a.isWater;
|
|
119
|
+
_a = option || {}, isDownload = _a.isDownload, isWater = _a.isWater, pdfConfig = _a.pdfConfig;
|
|
122
120
|
return [4 /*yield*/, canExecuteClickHandle('生成PDF操作不能继续,请联系管理员!', 'domPdf')];
|
|
123
121
|
case 1:
|
|
124
122
|
result = _b.sent();
|
|
@@ -133,9 +131,7 @@ export default function useCreatePdf(props) {
|
|
|
133
131
|
waterConfig: isWater ? waterConfig : undefined,
|
|
134
132
|
// isDownload: isCanvasPdfDownload ? true : false,
|
|
135
133
|
isDownload: isDownload,
|
|
136
|
-
pdfConfig: {
|
|
137
|
-
orientation: 'l',
|
|
138
|
-
},
|
|
134
|
+
pdfConfig: __assign({ orientation: 'l' }, pdfConfig),
|
|
139
135
|
useCanvas: false,
|
|
140
136
|
fileBinary: fontTTF,
|
|
141
137
|
})];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IHtmlToPdfConfig } from './pdf/htmlToPdf';
|
|
3
|
+
import { IPdfConfig } from './pdf/pdf';
|
|
3
4
|
export interface IPrintBoxProps extends ICommonProps, IBrowserPrintProps, ICanvasPdfProps {
|
|
4
5
|
children: React.ReactNode;
|
|
5
6
|
}
|
|
@@ -78,6 +79,7 @@ export interface ICanvasPdfProps extends ICommonProps {
|
|
|
78
79
|
insertFooter?: IHtmlToPdfConfig['insertFooter'];
|
|
79
80
|
/** 页脚距离上边的距离 */
|
|
80
81
|
footerTopMargin?: IHtmlToPdfConfig['footerTopMargin'];
|
|
82
|
+
pdfConfig?: IPdfConfig;
|
|
81
83
|
}
|
|
82
84
|
export interface IPrintBoxRef {
|
|
83
85
|
/** 创建canvasPdf方法 */
|
|
@@ -89,6 +89,7 @@ function getTextWidth(text, fontOption) {
|
|
|
89
89
|
div.style.visibility = 'hidden'; // 隐藏该元素,不影响页面显示
|
|
90
90
|
div.style.overflow = 'hidden'; // 防止滚动条出现
|
|
91
91
|
div.style.color = (font === null || font === void 0 ? void 0 : font.color) || 'rgba(0, 0, 0, 0)';
|
|
92
|
+
div.style.padding = '0 5px';
|
|
92
93
|
div.style.fontSize = (font === null || font === void 0 ? void 0 : font.fontSize) || 14;
|
|
93
94
|
div.style.fontWeight = (font === null || font === void 0 ? void 0 : font.fontWeight) || 'normal';
|
|
94
95
|
div.style.fontStyle = (font === null || font === void 0 ? void 0 : font.fontStyle) || 'normal';
|
|
@@ -3,9 +3,12 @@ import { domFind } from '../utils/dom';
|
|
|
3
3
|
import { plus } from 'number-precision';
|
|
4
4
|
import { copyValueHandle } from '../../utils/index';
|
|
5
5
|
export default function useSelectSubtotal(tableRef, props) {
|
|
6
|
-
var onMoveRow = props.onMoveRow, onEditableSave = props.onEditableSave;
|
|
6
|
+
var onMoveRow = props.onMoveRow, onEditableSave = props.onEditableSave, dataSource = props.dataSource;
|
|
7
7
|
var tipRef = useRef();
|
|
8
|
+
var rowResultRef = useRef();
|
|
9
|
+
// 数据发送变更时,动态计算单元格位置信息
|
|
8
10
|
useEffect(function () {
|
|
11
|
+
console.time('触发计算');
|
|
9
12
|
if (onMoveRow || onEditableSave) {
|
|
10
13
|
return;
|
|
11
14
|
}
|
|
@@ -15,15 +18,6 @@ export default function useSelectSubtotal(tableRef, props) {
|
|
|
15
18
|
}
|
|
16
19
|
var tbody = domFind(tableContent, '.ant-table-tbody');
|
|
17
20
|
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
21
|
// 找到每个单元格实际对应的坐标
|
|
28
22
|
var cellPosition = function () {
|
|
29
23
|
var rowsLen = container.rows.length;
|
|
@@ -82,7 +76,30 @@ export default function useSelectSubtotal(tableRef, props) {
|
|
|
82
76
|
}
|
|
83
77
|
return rowResult;
|
|
84
78
|
};
|
|
85
|
-
|
|
79
|
+
rowResultRef.current = cellPosition();
|
|
80
|
+
console.timeEnd('触发计算');
|
|
81
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
82
|
+
}, [dataSource]);
|
|
83
|
+
useEffect(function () {
|
|
84
|
+
if (onMoveRow || onEditableSave) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
var tableContent = domFind(tableRef.current, '.ant-table-content');
|
|
88
|
+
if (!tableContent) {
|
|
89
|
+
tableContent = domFind(tableRef.current, '.ant-table-container');
|
|
90
|
+
}
|
|
91
|
+
var tbody = domFind(tableContent, '.ant-table-tbody');
|
|
92
|
+
var container = tbody.parentNode;
|
|
93
|
+
var $tip = tipRef.current;
|
|
94
|
+
var isDragging = false;
|
|
95
|
+
var startCell = null; // 开始选中的项
|
|
96
|
+
var lastEndCell = null; // 最终选中的项
|
|
97
|
+
var textArr = []; // 选中的文本
|
|
98
|
+
var textPositionArr = []; // 包含位置信息
|
|
99
|
+
if (!container) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
var rowResult = rowResultRef.current;
|
|
86
103
|
var mousedownHandler = function (e) {
|
|
87
104
|
if (e.target.tagName === 'TD') {
|
|
88
105
|
isDragging = true;
|
|
@@ -143,7 +160,7 @@ export default function useSelectSubtotal(tableRef, props) {
|
|
|
143
160
|
};
|
|
144
161
|
container.addEventListener('mousemove', mousemoveHandler);
|
|
145
162
|
var selectCells = function (start, end, isCtrl) {
|
|
146
|
-
var _a, _b;
|
|
163
|
+
var _a, _b, _c, _d, _e, _f;
|
|
147
164
|
if (!isCtrl) {
|
|
148
165
|
clearSelections(); // 清除之前的选择
|
|
149
166
|
}
|
|
@@ -153,13 +170,13 @@ export default function useSelectSubtotal(tableRef, props) {
|
|
|
153
170
|
var startCol = start.cellIndex;
|
|
154
171
|
var endRow = end.parentNode.rowIndex;
|
|
155
172
|
var endCol = end.cellIndex;
|
|
156
|
-
var startCell = rowResult[startRow - 1].find(function (item) {
|
|
173
|
+
var startCell = (_b = (_a = rowResult[startRow - 1]) === null || _a === void 0 ? void 0 : _a.find) === null || _b === void 0 ? void 0 : _b.call(_a, function (item) {
|
|
157
174
|
return item.td === start;
|
|
158
175
|
});
|
|
159
176
|
if (startCell) {
|
|
160
177
|
startCol = startCell.cellIndex;
|
|
161
178
|
}
|
|
162
|
-
var endCell = rowResult[endRow - 1].find(function (item) {
|
|
179
|
+
var endCell = (_d = (_c = rowResult[endRow - 1]) === null || _c === void 0 ? void 0 : _c.find) === null || _d === void 0 ? void 0 : _d.call(_c, function (item) {
|
|
163
180
|
return item.td === end;
|
|
164
181
|
});
|
|
165
182
|
if (endCell) {
|
|
@@ -179,13 +196,13 @@ export default function useSelectSubtotal(tableRef, props) {
|
|
|
179
196
|
var positionArr = [];
|
|
180
197
|
for (var j = initCell; j <= lenCell; j++) {
|
|
181
198
|
// const $td = container.rows[i]?.cells[j];
|
|
182
|
-
var $td = (
|
|
199
|
+
var $td = (_e = rowResult[i - 1][j]) === null || _e === void 0 ? void 0 : _e.td;
|
|
183
200
|
if ($td && !$td.classList.contains('move-selected')) {
|
|
184
201
|
var innerText = $td.innerText;
|
|
185
202
|
textArr.push(innerText);
|
|
186
203
|
positionArr.push(innerText);
|
|
187
204
|
}
|
|
188
|
-
(
|
|
205
|
+
(_f = $td === null || $td === void 0 ? void 0 : $td.classList) === null || _f === void 0 ? void 0 : _f.add('move-selected');
|
|
189
206
|
}
|
|
190
207
|
if (positionArr.length > 0) {
|
|
191
208
|
textPositionArr.push(positionArr);
|
|
@@ -985,7 +985,11 @@ function Table(props) {
|
|
|
985
985
|
tableResizableTitle,
|
|
986
986
|
vComponents,
|
|
987
987
|
]);
|
|
988
|
-
var tipRef = useSelectSubtotal(tableRef, {
|
|
988
|
+
var tipRef = useSelectSubtotal(tableRef, {
|
|
989
|
+
onMoveRow: onMoveRow,
|
|
990
|
+
onEditableSave: onEditableSave,
|
|
991
|
+
dataSource: sortDataSource ? sortDataSource : expandableDataSource,
|
|
992
|
+
}).tipRef;
|
|
989
993
|
return (React.createElement(React.Fragment, null,
|
|
990
994
|
React.createElement("div", { className: isFlex ? 'zt-table-flex' : '', style: isFlex
|
|
991
995
|
? { position: 'relative', overflow: 'hidden', flex: 1 }
|