zmdms-webui 2.0.3 → 2.0.6
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/table/components/FilterDropdown.js +1 -1
- package/dist/es/table/excel.js +2 -3
- package/dist/es/table/hooks.js +48 -4
- package/dist/es/table/table.js +10 -6
- package/dist/es/table/useColumns.js +15 -9
- package/dist/es/table/utils.js +117 -18
- package/dist/es/uploadlist/interface.d.ts +2 -0
- package/dist/es/uploadlist/uploadList.js +11 -8
- package/dist/es/uploadlist/uploadTable.js +9 -7
- package/package.json +1 -1
|
@@ -2,9 +2,9 @@ import { __assign } from '../../_virtual/_tslib.js';
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo, useEffect, useState } from 'react';
|
|
4
4
|
import { useLatest } from 'ahooks';
|
|
5
|
+
import myMessage from '../../message/index.js';
|
|
5
6
|
import MemoInput from '../../input/input.js';
|
|
6
7
|
import ButtonCom from '../../button/button.js';
|
|
7
|
-
import myMessage from '../../message/index.js';
|
|
8
8
|
import { Checkbox, Tooltip } from 'antd';
|
|
9
9
|
import QuestionCircleOutlined from '../../node_modules/@ant-design/icons/es/icons/QuestionCircleOutlined.js';
|
|
10
10
|
|
package/dist/es/table/excel.js
CHANGED
|
@@ -502,7 +502,6 @@ function applyExcelStyles(worksheet, data, numKeys, columns, headerRowCount, has
|
|
|
502
502
|
var isSubtotal = rowData.__is_summary__;
|
|
503
503
|
for (var c = 1; c <= totalCols; c++) {
|
|
504
504
|
var cell = worksheet.getCell(headerRowCount + rowIndex + 1, c);
|
|
505
|
-
var currentColumn = columns && Array.isArray(columns) ? columns[c - 1] : undefined;
|
|
506
505
|
var base = isSubtotal ? summaryStyle : normalStyle;
|
|
507
506
|
var columnAlign = columns && Array.isArray(columns)
|
|
508
507
|
? (_c = columns[c - 1]) === null || _c === void 0 ? void 0 : _c.align
|
|
@@ -562,8 +561,8 @@ function useExcelExport(records, config) {
|
|
|
562
561
|
var columns = config.columns, isAutoMerge = config.isAutoMerge, columnHeaders = config.columnHeaders, summaryConfig = config.summaryConfig;
|
|
563
562
|
var mergeKeys = useMergeKeys(columns, isAutoMerge);
|
|
564
563
|
var numKeys = useNumKeys(columns);
|
|
565
|
-
var exportFunction = useMemoizedFn(function (fileName,
|
|
566
|
-
var topDescription = _a.topDescription, topDescriptionRowHeight = _a.topDescriptionRowHeight, time = _a.time;
|
|
564
|
+
var exportFunction = useMemoizedFn(function (fileName, options) {
|
|
565
|
+
var _a = options || {}, topDescription = _a.topDescription, topDescriptionRowHeight = _a.topDescriptionRowHeight, time = _a.time;
|
|
567
566
|
if (!fileName.includes(".xlsx")) {
|
|
568
567
|
fileName = fileName + ".xlsx";
|
|
569
568
|
}
|
package/dist/es/table/hooks.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { __assign, __spreadArray } from '../_virtual/_tslib.js';
|
|
2
2
|
import { useCallback, useRef, useState, useEffect, useMemo } from 'react';
|
|
3
|
+
import { useMemoizedFn } from 'ahooks';
|
|
3
4
|
import update from '../node_modules/immutability-helper/index.js';
|
|
4
5
|
import { getInnerIndex } from './useInnerPagination.js';
|
|
5
6
|
import { flattenRecordsOptimized } from './utils.js';
|
|
6
7
|
import { IS_SUMMARY, MERGE_INDEX, MERGE_ROW_SPANS } from './constant.js';
|
|
7
|
-
import {
|
|
8
|
+
import { filterHandle } from './components/FilterDropdown.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @param dataSourceRef 数据引用
|
|
@@ -398,7 +399,7 @@ var useNumKeys = function (columns) {
|
|
|
398
399
|
* 自动合并的一些处理
|
|
399
400
|
*/
|
|
400
401
|
function useAutoMerge(dataSource, columns, _a) {
|
|
401
|
-
var isAutoMerge = _a.isAutoMerge, isDimensionDynamic = _a.isDimensionDynamic;
|
|
402
|
+
var isAutoMerge = _a.isAutoMerge, isDimensionDynamic = _a.isDimensionDynamic, order = _a.order;
|
|
402
403
|
// 计算需要合并的字段key集合
|
|
403
404
|
var mergeKeys = useMergeKeys(columns, isAutoMerge);
|
|
404
405
|
var firstMergeKey = mergeKeys === null || mergeKeys === void 0 ? void 0 : mergeKeys[0];
|
|
@@ -422,7 +423,7 @@ function useAutoMerge(dataSource, columns, _a) {
|
|
|
422
423
|
if (!mergeKeys)
|
|
423
424
|
return dataSource;
|
|
424
425
|
else {
|
|
425
|
-
var newDataSource_2 = flattenRecordsOptimized(__spreadArray([], (dataSource || []), true), mergeKeys, dimensionSummaryKeys, summaryKeys, isDimensionDynamic);
|
|
426
|
+
var newDataSource_2 = flattenRecordsOptimized(__spreadArray([], (dataSource || []), true), mergeKeys, dimensionSummaryKeys, summaryKeys, isDimensionDynamic, order);
|
|
426
427
|
return newDataSource_2;
|
|
427
428
|
}
|
|
428
429
|
}
|
|
@@ -433,6 +434,7 @@ function useAutoMerge(dataSource, columns, _a) {
|
|
|
433
434
|
dimensionSummaryKeys,
|
|
434
435
|
summaryKeys,
|
|
435
436
|
isDimensionDynamic,
|
|
437
|
+
order,
|
|
436
438
|
]);
|
|
437
439
|
var newColumns = useMemo(function () {
|
|
438
440
|
var _columns = columns;
|
|
@@ -517,6 +519,48 @@ function useMergeAddAndDel(_a) {
|
|
|
517
519
|
return addAndDelProps;
|
|
518
520
|
}, [addAndDelProps, isAutoMerge, firstMergeKey]);
|
|
519
521
|
return [newRowSelection, newAddAndDelProps];
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* 自定义处理过滤逻辑
|
|
525
|
+
*/
|
|
526
|
+
function useCustomFilter(dataSource) {
|
|
527
|
+
var _a = useState(), filterConfig = _a[0], setFilterConfig = _a[1];
|
|
528
|
+
var newDataSource = useMemo(function () {
|
|
529
|
+
if (!filterConfig)
|
|
530
|
+
return dataSource;
|
|
531
|
+
return dataSource.filter(function (item) {
|
|
532
|
+
var keys = Object.keys(filterConfig);
|
|
533
|
+
for (var i = 0; i < keys.length; i++) {
|
|
534
|
+
var key = keys[i];
|
|
535
|
+
var filter = filterConfig[key];
|
|
536
|
+
if (filter.input) {
|
|
537
|
+
if (!filterHandle(filter.input, item, key)) {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (filter.checkbox && filter.checkbox.length > 0) {
|
|
542
|
+
var flag = false;
|
|
543
|
+
for (var _a = 0, _b = filter.checkbox; _a < _b.length; _a++) {
|
|
544
|
+
var value = _b[_a];
|
|
545
|
+
if (filterHandle(value, item, key)) {
|
|
546
|
+
flag = true;
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (!flag) {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return true;
|
|
556
|
+
});
|
|
557
|
+
}, [dataSource, filterConfig]);
|
|
558
|
+
var handleFilterConfigChange = useMemoizedFn(function (value) {
|
|
559
|
+
setFilterConfig(function (oldValue) {
|
|
560
|
+
return __assign(__assign({}, oldValue), value);
|
|
561
|
+
});
|
|
562
|
+
});
|
|
563
|
+
return [newDataSource, handleFilterConfigChange];
|
|
520
564
|
}
|
|
521
565
|
|
|
522
|
-
export { useAddAndDelChange, useAutoMerge, useCalcScrollY, useCustomSort, useEditChange, useMergeAddAndDel, useMergeKeys, useMoveRowChange, useNumKeys, useScuRfresh };
|
|
566
|
+
export { useAddAndDelChange, useAutoMerge, useCalcScrollY, useCustomFilter, useCustomSort, useEditChange, useMergeAddAndDel, useMergeKeys, useMoveRowChange, useNumKeys, useScuRfresh };
|
package/dist/es/table/table.js
CHANGED
|
@@ -17,7 +17,7 @@ import { useColumns } from './useColumns.js';
|
|
|
17
17
|
import { useDynamicListByColumns } from './useDynamicListByColumns.js';
|
|
18
18
|
import useSummary from './useSummary.js';
|
|
19
19
|
import useInnerPagination, { getInnerIndex } from './useInnerPagination.js';
|
|
20
|
-
import { useScuRfresh, useCustomSort, useCalcScrollY, useEditChange, useMoveRowChange, useAddAndDelChange, useAutoMerge } from './hooks.js';
|
|
20
|
+
import { useScuRfresh, useCustomSort, useCalcScrollY, useEditChange, useMoveRowChange, useAddAndDelChange, useCustomFilter, useAutoMerge } from './hooks.js';
|
|
21
21
|
import { HTML5Backend } from '../node_modules/react-dnd-html5-backend/dist/index.js';
|
|
22
22
|
import { VList, scrollTo } from '../node_modules/virtuallist-antd/dist/index.es.js';
|
|
23
23
|
import useTableValidate, { tableValidate } from './useTableValidate.js';
|
|
@@ -129,8 +129,10 @@ var Table = function (props) {
|
|
|
129
129
|
currentPage: currentPage,
|
|
130
130
|
filterConfigRef: filterConfigRef,
|
|
131
131
|
});
|
|
132
|
+
// 表格内部自定义处理过滤,不走antd内部
|
|
133
|
+
var _u = useCustomFilter(currentTableDataSource), filterDataSource = _u[0], handleFilterConfigChange = _u[1];
|
|
132
134
|
// 处理列配置信息 得到新的列配置信息
|
|
133
|
-
var
|
|
135
|
+
var _v = useColumns(columns, {
|
|
134
136
|
// 动态列配置相关信息
|
|
135
137
|
dynamicKey: dynamicKey,
|
|
136
138
|
isRemeberFilter: isRemeberFilter,
|
|
@@ -171,12 +173,14 @@ var Table = function (props) {
|
|
|
171
173
|
headerAlign: headerAlign,
|
|
172
174
|
mode: mode,
|
|
173
175
|
isAutoMerge: isAutoMerge,
|
|
174
|
-
|
|
176
|
+
handleFilterConfigChange: handleFilterConfigChange,
|
|
177
|
+
}), _newColumns = _v.newColumns, newRowSelection = _v.rowSelection;
|
|
175
178
|
// 处理表格合并和维度
|
|
176
|
-
var
|
|
179
|
+
var _w = useAutoMerge(filterDataSource, _newColumns, {
|
|
177
180
|
isAutoMerge: isAutoMerge,
|
|
178
181
|
isDimensionDynamic: isDimensionDynamic,
|
|
179
|
-
|
|
182
|
+
order: order,
|
|
183
|
+
}), newDataSource = _w[0], newColumns = _w[1];
|
|
180
184
|
// 内部表格总结栏
|
|
181
185
|
var getSummaryHandle = useSummary(summaryConfig, newColumns, {
|
|
182
186
|
summaryFixed: summaryFixed,
|
|
@@ -186,7 +190,7 @@ var Table = function (props) {
|
|
|
186
190
|
isDel: isDel,
|
|
187
191
|
});
|
|
188
192
|
// 表格验证
|
|
189
|
-
var
|
|
193
|
+
var _x = useTableValidate(), tableRef = _x.tableRef, getCurrentTable = _x.getCurrentTable, clearErrorClass = _x.clearErrorClass;
|
|
190
194
|
// 虚拟滚动选项
|
|
191
195
|
var vComponents = useMemo(function () {
|
|
192
196
|
if (virtualKey) {
|
|
@@ -26,7 +26,7 @@ import ModalComponent from '../modal/modal.js';
|
|
|
26
26
|
function useColumns(columns, options) {
|
|
27
27
|
var _this = this;
|
|
28
28
|
var _a, _b;
|
|
29
|
-
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, filterConfigRef = options.filterConfigRef, rowSelection = options.rowSelection, addAndDelProps = options.addAndDelProps, headerAlign = options.headerAlign, mode = options.mode, isAutoMerge = options.isAutoMerge;
|
|
29
|
+
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, filterConfigRef = options.filterConfigRef, rowSelection = options.rowSelection, addAndDelProps = options.addAndDelProps, headerAlign = options.headerAlign, mode = options.mode, isAutoMerge = options.isAutoMerge, handleFilterConfigChange = options.handleFilterConfigChange;
|
|
30
30
|
var newColumns = getTableColumns(columns, currentDynamicList).columns;
|
|
31
31
|
// 处理自动合并的加减和选择框
|
|
32
32
|
var _c = useMergeAddAndDel({
|
|
@@ -109,27 +109,30 @@ function useColumns(columns, options) {
|
|
|
109
109
|
_column.filterDropdown = function (_a) {
|
|
110
110
|
var selectedKeys = _a.selectedKeys, setSelectedKeys = _a.setSelectedKeys, confirm = _a.confirm, clearFilters = _a.clearFilters;
|
|
111
111
|
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) {
|
|
112
|
-
var _a;
|
|
113
|
-
var
|
|
112
|
+
var _a, _b;
|
|
113
|
+
var _c;
|
|
114
114
|
// 实时记录下当前的值
|
|
115
115
|
var filteredValue = createFilterValue(filter === null || filter === void 0 ? void 0 : filter.input, filter === null || filter === void 0 ? void 0 : filter.checkbox);
|
|
116
116
|
filterConfigRef.current = (_a = {},
|
|
117
117
|
_a[_key] = filteredValue,
|
|
118
118
|
_a);
|
|
119
|
+
handleFilterConfigChange === null || handleFilterConfigChange === void 0 ? void 0 : handleFilterConfigChange((_b = {},
|
|
120
|
+
_b[_key] = filter,
|
|
121
|
+
_b));
|
|
119
122
|
if (!isRemeberFilter) {
|
|
120
123
|
return;
|
|
121
124
|
}
|
|
122
125
|
// 如果有持久化 那么更新持久化数据
|
|
123
|
-
var
|
|
126
|
+
var _d = getColumnsItem({
|
|
124
127
|
currentDynamicList: currentDynamicList,
|
|
125
128
|
currentKey: _key,
|
|
126
129
|
keyIndex: keyIndex,
|
|
127
|
-
}), result =
|
|
130
|
+
}), result = _d.result, newList = _d.newList;
|
|
128
131
|
if (result) {
|
|
129
132
|
result.filter = filter;
|
|
130
133
|
}
|
|
131
134
|
if (dynamicKey) {
|
|
132
|
-
(
|
|
135
|
+
(_c = dynamicSettingRef === null || dynamicSettingRef === void 0 ? void 0 : dynamicSettingRef.current) === null || _c === void 0 ? void 0 : _c.updateList(newList);
|
|
133
136
|
}
|
|
134
137
|
else {
|
|
135
138
|
onCurrentListChange === null || onCurrentListChange === void 0 ? void 0 : onCurrentListChange(newList);
|
|
@@ -145,9 +148,12 @@ function useColumns(columns, options) {
|
|
|
145
148
|
_column.filteredValue = filteredValue;
|
|
146
149
|
}
|
|
147
150
|
_column.filterIcon = function () { return jsx(SearchOutlined, {}); };
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
+
// 自动合并单元格的情况下,不进行内部过滤
|
|
152
|
+
if (!isAutoMerge) {
|
|
153
|
+
_column.onFilter = function (value, record) {
|
|
154
|
+
return filterHandle(value, record, _key);
|
|
155
|
+
};
|
|
156
|
+
}
|
|
151
157
|
_column.onFilterDropdownOpenChange = function (visible) {
|
|
152
158
|
if (visible) {
|
|
153
159
|
setTimeout(function () {
|
package/dist/es/table/utils.js
CHANGED
|
@@ -449,7 +449,7 @@ function startColumnInsertTableData(options) {
|
|
|
449
449
|
* @param summaryKeys 合计字段
|
|
450
450
|
* @param isDimensionDynamic 维度合并
|
|
451
451
|
*/
|
|
452
|
-
function flattenRecordsOptimized(records, mergeKeys, dimensionSummaryKeys, summaryKeys, isDimensionDynamic) {
|
|
452
|
+
function flattenRecordsOptimized(records, mergeKeys, dimensionSummaryKeys, summaryKeys, isDimensionDynamic, order) {
|
|
453
453
|
var _a;
|
|
454
454
|
if (!records ||
|
|
455
455
|
records.length === 0 ||
|
|
@@ -458,14 +458,27 @@ function flattenRecordsOptimized(records, mergeKeys, dimensionSummaryKeys, summa
|
|
|
458
458
|
return records;
|
|
459
459
|
}
|
|
460
460
|
// 0. 首先根据维度字段对数据进行排序
|
|
461
|
-
var result =
|
|
462
|
-
|
|
463
|
-
|
|
461
|
+
var result = [];
|
|
462
|
+
// 如果order没有排序方向,但isDimensionDynamic为true,则按维度字段排序
|
|
463
|
+
if (isDimensionDynamic) {
|
|
464
|
+
result = sortByDimensions(__spreadArray([], records, true), mergeKeys);
|
|
465
|
+
}
|
|
466
|
+
// 否则保持原样
|
|
467
|
+
else {
|
|
468
|
+
result = __spreadArray([], records, true);
|
|
469
|
+
}
|
|
464
470
|
// 1. 如果开启了维度合并,按所有 mergeKeys 的组合来计算合计值
|
|
465
471
|
if (isDimensionDynamic && mergeKeys.length > 0) {
|
|
466
472
|
var groupedResult = groupByLastMergeKey(result, mergeKeys, summaryKeys);
|
|
467
473
|
result = groupedResult;
|
|
468
474
|
}
|
|
475
|
+
// 如果order有排序方向,则按order排序
|
|
476
|
+
result = sortRecords({
|
|
477
|
+
records: result,
|
|
478
|
+
// 开启自定义维度后因为最后一个维度字段会合并为一行,所以可以不排序最后一个维度字段
|
|
479
|
+
mergeKeys: isDimensionDynamic ? mergeKeys.slice(0, -1) : mergeKeys,
|
|
480
|
+
order: order,
|
|
481
|
+
});
|
|
469
482
|
// 2. 首先插入维度合计行
|
|
470
483
|
if (dimensionSummaryKeys &&
|
|
471
484
|
dimensionSummaryKeys.length > 0 &&
|
|
@@ -565,22 +578,108 @@ function flattenRecordsOptimized(records, mergeKeys, dimensionSummaryKeys, summa
|
|
|
565
578
|
}
|
|
566
579
|
return result;
|
|
567
580
|
}
|
|
581
|
+
function sortRecords(_a) {
|
|
582
|
+
var records = _a.records, mergeKeys = _a.mergeKeys, order = _a.order;
|
|
583
|
+
var result = [];
|
|
584
|
+
if (order && order.order) {
|
|
585
|
+
result = sortByDimensions(__spreadArray([], records, true), mergeKeys, order);
|
|
586
|
+
}
|
|
587
|
+
// 否则保持原样
|
|
588
|
+
else {
|
|
589
|
+
result = __spreadArray([], records, true);
|
|
590
|
+
}
|
|
591
|
+
return result;
|
|
592
|
+
}
|
|
568
593
|
/**
|
|
569
594
|
* 根据维度字段对数据进行排序
|
|
570
595
|
* 确保相同维度值的记录连续排列,以便正确进行合并处理
|
|
596
|
+
* @param records 数据记录
|
|
597
|
+
* @param dimensionKeys 维度字段
|
|
598
|
+
* @param order 排序配置
|
|
571
599
|
*/
|
|
572
|
-
function sortByDimensions(records, dimensionKeys) {
|
|
600
|
+
function sortByDimensions(records, dimensionKeys, order) {
|
|
573
601
|
return records.sort(function (a, b) {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
var
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
if (
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
602
|
+
// 如果有排序配置且有排序方向
|
|
603
|
+
if (order && order.order && order.field) {
|
|
604
|
+
var field = order.field, sortOrder = order.order;
|
|
605
|
+
// 找到排序字段在维度字段中的位置
|
|
606
|
+
var sortFieldIndex = dimensionKeys.indexOf(field);
|
|
607
|
+
if (sortFieldIndex !== -1) {
|
|
608
|
+
// 先按维度字段排序到排序字段之前的字段
|
|
609
|
+
for (var i = 0; i < sortFieldIndex; i++) {
|
|
610
|
+
var key = dimensionKeys[i];
|
|
611
|
+
var valueA_1 = a[key] || "";
|
|
612
|
+
var valueB_1 = b[key] || "";
|
|
613
|
+
// 字符串比较
|
|
614
|
+
if (valueA_1 < valueB_1)
|
|
615
|
+
return -1;
|
|
616
|
+
if (valueA_1 > valueB_1)
|
|
617
|
+
return 1;
|
|
618
|
+
// 如果当前字段相等,继续比较下一个字段
|
|
619
|
+
}
|
|
620
|
+
// 按排序字段进行排序
|
|
621
|
+
var valueA = a[field] || "";
|
|
622
|
+
var valueB = b[field] || "";
|
|
623
|
+
var compareResult = 0;
|
|
624
|
+
if (valueA < valueB)
|
|
625
|
+
compareResult = -1;
|
|
626
|
+
else if (valueA > valueB)
|
|
627
|
+
compareResult = 1;
|
|
628
|
+
if (compareResult !== 0) {
|
|
629
|
+
return sortOrder === "ascend" ? compareResult : -compareResult;
|
|
630
|
+
}
|
|
631
|
+
// 如果排序字段相等,继续按后面的维度字段排序
|
|
632
|
+
for (var i = sortFieldIndex + 1; i < dimensionKeys.length; i++) {
|
|
633
|
+
var key = dimensionKeys[i];
|
|
634
|
+
var valueA_2 = a[key] || "";
|
|
635
|
+
var valueB_2 = b[key] || "";
|
|
636
|
+
// 字符串比较
|
|
637
|
+
if (valueA_2 < valueB_2)
|
|
638
|
+
return -1;
|
|
639
|
+
if (valueA_2 > valueB_2)
|
|
640
|
+
return 1;
|
|
641
|
+
// 如果当前字段相等,继续比较下一个字段
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
// 如果排序字段不在维度字段中,按原逻辑排序维度字段
|
|
646
|
+
for (var i = 0; i < dimensionKeys.length; i++) {
|
|
647
|
+
var key = dimensionKeys[i];
|
|
648
|
+
var valueA_3 = a[key] || "";
|
|
649
|
+
var valueB_3 = b[key] || "";
|
|
650
|
+
// 字符串比较
|
|
651
|
+
if (valueA_3 < valueB_3)
|
|
652
|
+
return -1;
|
|
653
|
+
if (valueA_3 > valueB_3)
|
|
654
|
+
return 1;
|
|
655
|
+
// 如果当前字段相等,继续比较下一个字段
|
|
656
|
+
}
|
|
657
|
+
// 最后按排序字段排序
|
|
658
|
+
var valueA = a[field] || "";
|
|
659
|
+
var valueB = b[field] || "";
|
|
660
|
+
var compareResult = 0;
|
|
661
|
+
if (valueA < valueB)
|
|
662
|
+
compareResult = -1;
|
|
663
|
+
else if (valueA > valueB)
|
|
664
|
+
compareResult = 1;
|
|
665
|
+
if (compareResult !== 0) {
|
|
666
|
+
return sortOrder === "ascend" ? compareResult : -compareResult;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
// 没有排序配置,按原逻辑排序
|
|
672
|
+
for (var i = 0; i < dimensionKeys.length; i++) {
|
|
673
|
+
var key = dimensionKeys[i];
|
|
674
|
+
var valueA = a[key] || "";
|
|
675
|
+
var valueB = b[key] || "";
|
|
676
|
+
// 字符串比较
|
|
677
|
+
if (valueA < valueB)
|
|
678
|
+
return -1;
|
|
679
|
+
if (valueA > valueB)
|
|
680
|
+
return 1;
|
|
681
|
+
// 如果当前字段相等,继续比较下一个字段
|
|
682
|
+
}
|
|
584
683
|
}
|
|
585
684
|
return 0; // 所有字段都相等
|
|
586
685
|
});
|
|
@@ -591,7 +690,8 @@ function sortByDimensions(records, dimensionKeys) {
|
|
|
591
690
|
*/
|
|
592
691
|
function insertDimensionSummaryRows(records, allDimensionKeys, // 完整的维度字段列表
|
|
593
692
|
dimensionSummaryKeys, // 需要合计的维度字段
|
|
594
|
-
summaryKeys
|
|
693
|
+
summaryKeys, order // 排序配置
|
|
694
|
+
) {
|
|
595
695
|
var result = __spreadArray([], records, true);
|
|
596
696
|
// 按维度层级从深到浅处理
|
|
597
697
|
for (var i = dimensionSummaryKeys.length - 1; i >= 0; i--) {
|
|
@@ -616,8 +716,7 @@ summaryKeys) {
|
|
|
616
716
|
summaryKeys, currentDimensionIndex);
|
|
617
717
|
newResult.push(summaryRow);
|
|
618
718
|
}
|
|
619
|
-
|
|
620
|
-
result = sortByDimensions(newResult, allDimensionKeys);
|
|
719
|
+
result = newResult;
|
|
621
720
|
}
|
|
622
721
|
return result;
|
|
623
722
|
}
|
|
@@ -31,7 +31,7 @@ var MAXSIZE = 104857600; // 100 * 1024 * 1024
|
|
|
31
31
|
*/
|
|
32
32
|
var UploadList = function (props, ref) {
|
|
33
33
|
var _a;
|
|
34
|
-
var children = props.children, btnText = props.btnText, className = props.className, _b = props.showTip, showTip = _b === void 0 ? true : _b, _c = props.maxSize, maxSize = _c === void 0 ? MAXSIZE : _c, showTable = props.showTable, acceptList = props.acceptList, beforeUpload = props.beforeUpload, onChange = props.onChange, PROPS_API_BASEURL = props.API_BASEURL, PROPS_FILE_API_BASEURL = props.FILE_API_BASEURL, action = props.action, headers = props.headers, data = props.data, userName = props.userName, fileList = props.fileList, isPublic = props.isPublic, _d = props.maxPreviewSize, maxPreviewSize = _d === void 0 ? MAX_PREVIEW_SIZE : _d, isPreview = props.isPreview, isDownload = props.isDownload, isDelete = props.isDelete, _e = props.zipName, zipName =
|
|
34
|
+
var children = props.children, btnText = props.btnText, className = props.className, _b = props.showTip, showTip = _b === void 0 ? true : _b, _c = props.maxSize, maxSize = _c === void 0 ? MAXSIZE : _c, showTable = props.showTable, acceptList = props.acceptList, beforeUpload = props.beforeUpload, onChange = props.onChange, PROPS_API_BASEURL = props.API_BASEURL, PROPS_FILE_API_BASEURL = props.FILE_API_BASEURL, action = props.action, headers = props.headers, data = props.data, userName = props.userName, fileList = props.fileList, isPublic = props.isPublic, _d = props.maxPreviewSize, maxPreviewSize = _d === void 0 ? MAX_PREVIEW_SIZE : _d, isPreview = props.isPreview, isDownload = props.isDownload, isDelete = props.isDelete, _e = props.filePreview, filePreview = _e === void 0 ? true : _e, _f = props.zipName, zipName = _f === void 0 ? "\u6279\u91CF\u4E0B\u8F7D-".concat(Date.now(), ".zip") : _f, isImage = props.isImage, imgCropProps = props.imgCropProps, _g = props.imgWidth, imgWidth = _g === void 0 ? 110 : _g, _h = props.imgHeight, imgHeight = _h === void 0 ? 110 : _h, customRenderBtn = props.customRenderBtn, disAllowDuplicateFile = props.disAllowDuplicateFile, fieldNames = props.fieldNames, tableColumns = props.tableColumns, onBeforeDownloadValidate = props.onBeforeDownloadValidate, onBeforePreviewValidate = props.onBeforePreviewValidate, onBeforeDeleteValidate = props.onBeforeDeleteValidate, resetProps = __rest(props, ["children", "btnText", "className", "showTip", "maxSize", "showTable", "acceptList", "beforeUpload", "onChange", "API_BASEURL", "FILE_API_BASEURL", "action", "headers", "data", "userName", "fileList", "isPublic", "maxPreviewSize", "isPreview", "isDownload", "isDelete", "filePreview", "zipName", "isImage", "imgCropProps", "imgWidth", "imgHeight", "customRenderBtn", "disAllowDuplicateFile", "fieldNames", "tableColumns", "onBeforeDownloadValidate", "onBeforePreviewValidate", "onBeforeDeleteValidate"]);
|
|
35
35
|
var maxCount = resetProps.maxCount, listType = resetProps.listType, method = resetProps.method;
|
|
36
36
|
var imgSizeClassName = "temporary-className-".concat(imgWidth, "-").concat(imgHeight);
|
|
37
37
|
var classes = classNames("ztxk-upload", className, (_a = {},
|
|
@@ -41,7 +41,7 @@ var UploadList = function (props, ref) {
|
|
|
41
41
|
var tableRef = useRef({});
|
|
42
42
|
var modalRef = useRef({});
|
|
43
43
|
var imgCropModalRef = useRef();
|
|
44
|
-
var
|
|
44
|
+
var _j = useState(), imgSrc = _j[0], setImgSrc = _j[1];
|
|
45
45
|
useEffect(function () {
|
|
46
46
|
if (!isImage) {
|
|
47
47
|
return;
|
|
@@ -59,7 +59,7 @@ var UploadList = function (props, ref) {
|
|
|
59
59
|
};
|
|
60
60
|
}, [imgHeight, imgSizeClassName, imgWidth, isImage]);
|
|
61
61
|
var newFieldNames = getField(fieldNames);
|
|
62
|
-
var
|
|
62
|
+
var _k = useBaseContext(), apiBaseUrl = _k.apiBaseUrl, fileBaseUrl = _k.fileBaseUrl;
|
|
63
63
|
var API_BASEURL = PROPS_API_BASEURL ? PROPS_API_BASEURL : apiBaseUrl;
|
|
64
64
|
var FILE_API_BASEURL = PROPS_FILE_API_BASEURL
|
|
65
65
|
? PROPS_FILE_API_BASEURL
|
|
@@ -75,7 +75,7 @@ var UploadList = function (props, ref) {
|
|
|
75
75
|
fileList: fileList,
|
|
76
76
|
});
|
|
77
77
|
// 文件改变逻辑
|
|
78
|
-
var
|
|
78
|
+
var _l = useOnChange({
|
|
79
79
|
onChange: onChange,
|
|
80
80
|
userName: userName,
|
|
81
81
|
fileList: fileList,
|
|
@@ -84,15 +84,15 @@ var UploadList = function (props, ref) {
|
|
|
84
84
|
API_BASEURL: API_BASEURL,
|
|
85
85
|
newFieldNames: newFieldNames,
|
|
86
86
|
listType: listType,
|
|
87
|
-
}), onChangeHandle =
|
|
87
|
+
}), onChangeHandle = _l.onChangeHandle, innerFileList = _l.innerFileList, setInnerFileList = _l.setInnerFileList;
|
|
88
88
|
// 基础参数
|
|
89
|
-
var
|
|
89
|
+
var _m = useBasicInfo({
|
|
90
90
|
action: action,
|
|
91
91
|
API_BASEURL: API_BASEURL,
|
|
92
92
|
headers: headers,
|
|
93
93
|
data: data,
|
|
94
94
|
isPublic: isPublic,
|
|
95
|
-
}), fileAction =
|
|
95
|
+
}), fileAction = _m.fileAction, fileHeaders = _m.fileHeaders, fileData = _m.fileData;
|
|
96
96
|
// 表格需要的附件列表数据
|
|
97
97
|
var uploadTableData = useUploadTableData({
|
|
98
98
|
fileList: innerFileList,
|
|
@@ -208,6 +208,9 @@ var UploadList = function (props, ref) {
|
|
|
208
208
|
}); };
|
|
209
209
|
// 图片预览
|
|
210
210
|
var onPreview = function (file) {
|
|
211
|
+
if (!filePreview) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
211
214
|
if (isImage) {
|
|
212
215
|
var url = createDownloadLink(file.attachId, {
|
|
213
216
|
API_BASEURL: API_BASEURL,
|
|
@@ -385,7 +388,7 @@ var UploadList = function (props, ref) {
|
|
|
385
388
|
onClick: function (e) {
|
|
386
389
|
onBatchDownloadHandle(e.key);
|
|
387
390
|
},
|
|
388
|
-
}, placement: "bottomLeft" }, { children: jsx(ButtonCom, __assign({ type: "primary" }, { children: "\u6279\u91CF\u4E0B\u8F7D" })) }))) : null, customRenderBtn, showTable ? (jsx(UploadTable, { dataSource: uploadTableData, action: fileAction, headers: fileHeaders, data: fileData, method: method, setInnerFileList: setInnerFileList, isPublic: isPublic, API_BASEURL: API_BASEURL, FILE_API_BASEURL: FILE_API_BASEURL, maxPreviewSize: maxPreviewSize, isPreview: isPreview, isDelete: isDelete, isDownload: isDownload, ref: tableRef, listType: listType, tableColumns: tableColumns, onBeforeDeleteValidate: onBeforeDeleteValidate, onBeforeDownloadValidate: onBeforeDownloadValidate, onBeforePreviewValidate: onBeforePreviewValidate })) : null, isPreview && !showTable && !isImage ? (jsx(UploadListDetail, { dataSource: uploadTableData, action: fileAction, headers: fileHeaders, data: fileData, method: method, setInnerFileList: setInnerFileList, isPublic: isPublic, API_BASEURL: API_BASEURL, FILE_API_BASEURL: FILE_API_BASEURL, maxPreviewSize: maxPreviewSize, isPreview: isPreview, isDelete: isDelete, isDownload: isDownload, ref: tableRef, listType: listType, tableColumns: tableColumns, onBeforeDeleteValidate: onBeforeDeleteValidate, onBeforeDownloadValidate: onBeforeDownloadValidate, onBeforePreviewValidate: onBeforePreviewValidate })) : null, isImage && (jsx(ModalComponent, __assign({ ref: modalRef, footer: null, width: "520px" }, { children: jsx("div", __assign({ style: {
|
|
391
|
+
}, placement: "bottomLeft" }, { children: jsx(ButtonCom, __assign({ type: "primary" }, { children: "\u6279\u91CF\u4E0B\u8F7D" })) }))) : null, customRenderBtn, showTable ? (jsx(UploadTable, { dataSource: uploadTableData, action: fileAction, headers: fileHeaders, data: fileData, method: method, setInnerFileList: setInnerFileList, isPublic: isPublic, API_BASEURL: API_BASEURL, FILE_API_BASEURL: FILE_API_BASEURL, maxPreviewSize: maxPreviewSize, isPreview: isPreview, filePreview: filePreview, isDelete: isDelete, isDownload: isDownload, ref: tableRef, listType: listType, tableColumns: tableColumns, onBeforeDeleteValidate: onBeforeDeleteValidate, onBeforeDownloadValidate: onBeforeDownloadValidate, onBeforePreviewValidate: onBeforePreviewValidate })) : null, isPreview && !showTable && !isImage ? (jsx(UploadListDetail, { dataSource: uploadTableData, action: fileAction, headers: fileHeaders, data: fileData, method: method, setInnerFileList: setInnerFileList, isPublic: isPublic, API_BASEURL: API_BASEURL, FILE_API_BASEURL: FILE_API_BASEURL, maxPreviewSize: maxPreviewSize, isPreview: isPreview, isDelete: isDelete, isDownload: isDownload, ref: tableRef, listType: listType, tableColumns: tableColumns, onBeforeDeleteValidate: onBeforeDeleteValidate, onBeforeDownloadValidate: onBeforeDownloadValidate, onBeforePreviewValidate: onBeforePreviewValidate })) : null, isImage && (jsx(ModalComponent, __assign({ ref: modalRef, footer: null, width: "520px" }, { children: jsx("div", __assign({ style: {
|
|
389
392
|
textAlign: "center",
|
|
390
393
|
} }, { children: jsx("img", { src: imgSrc, alt: "\u9884\u89C8", style: {
|
|
391
394
|
maxWidth: "400px",
|
|
@@ -13,7 +13,7 @@ import myMessage from '../message/index.js';
|
|
|
13
13
|
import { Progress } from 'antd';
|
|
14
14
|
|
|
15
15
|
var UploadTable = function (_a, ref) {
|
|
16
|
-
var dataSource = _a.dataSource, action = _a.action, headers = _a.headers, data = _a.data, method = _a.method, setInnerFileList = _a.setInnerFileList, isPublic = _a.isPublic, _b = _a.API_BASEURL, API_BASEURL = _b === void 0 ? "" : _b, _c = _a.FILE_API_BASEURL, FILE_API_BASEURL = _c === void 0 ? "" : _c, maxPreviewSize = _a.maxPreviewSize, isPreview = _a.isPreview, isDelete = _a.isDelete, isDownload = _a.isDownload; _a.listType; var tableColumns = _a.tableColumns, onBeforeDownloadValidate = _a.onBeforeDownloadValidate, onBeforePreviewValidate = _a.onBeforePreviewValidate, onBeforeDeleteValidate = _a.onBeforeDeleteValidate;
|
|
16
|
+
var dataSource = _a.dataSource, action = _a.action, headers = _a.headers, data = _a.data, method = _a.method, setInnerFileList = _a.setInnerFileList, isPublic = _a.isPublic, _b = _a.API_BASEURL, API_BASEURL = _b === void 0 ? "" : _b, _c = _a.FILE_API_BASEURL, FILE_API_BASEURL = _c === void 0 ? "" : _c, maxPreviewSize = _a.maxPreviewSize, isPreview = _a.isPreview, filePreview = _a.filePreview, isDelete = _a.isDelete, isDownload = _a.isDownload; _a.listType; var tableColumns = _a.tableColumns, onBeforeDownloadValidate = _a.onBeforeDownloadValidate, onBeforePreviewValidate = _a.onBeforePreviewValidate, onBeforeDeleteValidate = _a.onBeforeDeleteValidate;
|
|
17
17
|
var _d = useState(false), loading = _d[0], setLoading = _d[1];
|
|
18
18
|
var _e = useState(), checked = _e[0], setChecked = _e[1];
|
|
19
19
|
var isDownloadSingleBoolean = isDownload;
|
|
@@ -182,7 +182,7 @@ var UploadTable = function (_a, ref) {
|
|
|
182
182
|
key: "attachName",
|
|
183
183
|
align: "left",
|
|
184
184
|
render: function (text, record, index) {
|
|
185
|
-
return (jsx(ButtonCom, __assign({ type: "link", onClick: function () { return operationCallback("preview", record, index); }, style: { textAlign: "left" } }, { children: text })));
|
|
185
|
+
return !filePreview ? (text) : (jsx(ButtonCom, __assign({ type: "link", onClick: function () { return operationCallback("preview", record, index); }, style: { textAlign: "left" } }, { children: text })));
|
|
186
186
|
},
|
|
187
187
|
};
|
|
188
188
|
var fileSizeColumn = {
|
|
@@ -311,11 +311,13 @@ var UploadTable = function (_a, ref) {
|
|
|
311
311
|
loading: loading,
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
314
|
+
if (filePreview) {
|
|
315
|
+
statusBtnConfig.push({
|
|
316
|
+
name: "预览",
|
|
317
|
+
type: "preview",
|
|
318
|
+
loading: onBeforePreviewValidate ? loading : undefined,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
319
321
|
if (isDeleteSingleBoolean) {
|
|
320
322
|
statusBtnConfig.push({
|
|
321
323
|
name: "删除",
|