@nokecy/qc-ui 1.1.57 → 1.1.58
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/cjs/ag-grid-plus/ag-gridPlus.js +14 -20
- package/dist/cjs/ag-grid-plus/utils/aggregation.d.ts +9 -0
- package/dist/cjs/ag-grid-plus/utils/aggregation.js +15 -1
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.d.ts +4 -2
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +14 -7
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +16 -22
- package/dist/esm/ag-grid-plus/utils/aggregation.d.ts +9 -0
- package/dist/esm/ag-grid-plus/utils/aggregation.js +14 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.d.ts +4 -2
- package/dist/esm/ag-grid-plus/utils/columnProcessors.js +13 -7
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -441,11 +441,10 @@ function AgGridPlus(props) {
|
|
|
441
441
|
// 辅助函数: 获取数据类型
|
|
442
442
|
var getDataType = function getDataType(data, colName, valueEnum) {
|
|
443
443
|
if (typeof data[colName] === 'number') {
|
|
444
|
-
//
|
|
445
|
-
var shouldCalculate = !valueEnum || valueEnum.length === 0;
|
|
444
|
+
// 数值只用于列对齐;底部合计必须由 calculateType 显式声明。@author nokecy
|
|
446
445
|
return {
|
|
447
446
|
type: "number",
|
|
448
|
-
calculateType:
|
|
447
|
+
calculateType: valueEnum !== null && valueEnum !== void 0 && valueEnum.length ? false : undefined
|
|
449
448
|
};
|
|
450
449
|
}
|
|
451
450
|
return undefined;
|
|
@@ -473,11 +472,11 @@ function AgGridPlus(props) {
|
|
|
473
472
|
return (0, _columnProcessors.processEnumColumn)(col, dataType);
|
|
474
473
|
}
|
|
475
474
|
if (col.type || typeof col.cellRenderer == "string") {
|
|
476
|
-
return
|
|
475
|
+
return (0, _columnProcessors.mergeInferredColumnType)(col, dataType);
|
|
477
476
|
}
|
|
478
477
|
//@ts-ignore
|
|
479
478
|
if (col !== null && col !== void 0 && col.ellipsis) {
|
|
480
|
-
return _objectSpread(_objectSpread({}, col), {}, {
|
|
479
|
+
return _objectSpread(_objectSpread({}, (0, _columnProcessors.mergeInferredColumnType)(col, dataType)), {}, {
|
|
481
480
|
cellRenderer: function cellRenderer(_ref) {
|
|
482
481
|
var value = _ref.value;
|
|
483
482
|
return /*#__PURE__*/_react.default.createElement(Text, {
|
|
@@ -494,12 +493,12 @@ function AgGridPlus(props) {
|
|
|
494
493
|
});
|
|
495
494
|
}
|
|
496
495
|
if (col.cellRenderer) {
|
|
497
|
-
return _objectSpread(_objectSpread({}, col), {}, {
|
|
496
|
+
return _objectSpread(_objectSpread({}, (0, _columnProcessors.mergeInferredColumnType)(col, dataType)), {}, {
|
|
498
497
|
customCellRenderer: col.cellRenderer,
|
|
499
498
|
cellRenderer: cellRenderer
|
|
500
499
|
});
|
|
501
500
|
}
|
|
502
|
-
return _objectSpread(_objectSpread(
|
|
501
|
+
return _objectSpread(_objectSpread({}, (0, _columnProcessors.mergeInferredColumnType)(col, dataType)), {}, {
|
|
503
502
|
customCellRenderer: col.cellRenderer,
|
|
504
503
|
cellRenderer: cellRenderer
|
|
505
504
|
});
|
|
@@ -949,6 +948,7 @@ function AgGridPlus(props) {
|
|
|
949
948
|
}
|
|
950
949
|
};
|
|
951
950
|
var calculateSum = (0, _react.useCallback)(function () {
|
|
951
|
+
if (props.pinnedBottomRowData !== undefined) return;
|
|
952
952
|
var displayedData = [];
|
|
953
953
|
if (apiRef.current) {
|
|
954
954
|
apiRef.current.forEachNodeAfterFilter(function (node) {
|
|
@@ -960,22 +960,16 @@ function AgGridPlus(props) {
|
|
|
960
960
|
(_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.setGridOption('pinnedBottomRowData', undefined);
|
|
961
961
|
return;
|
|
962
962
|
}
|
|
963
|
-
var calcColFields =
|
|
964
|
-
return col.calculateType;
|
|
965
|
-
}).map(function (col) {
|
|
966
|
-
return {
|
|
967
|
-
field: col.field,
|
|
968
|
-
calculateType: col.calculateType,
|
|
969
|
-
transactionAmount: col.transactionAmount || 2,
|
|
970
|
-
formatWithCommas: col.formatWithCommas
|
|
971
|
-
};
|
|
972
|
-
});
|
|
963
|
+
var calcColFields = (0, _aggregation.getCalculationColumns)(allColDefs);
|
|
973
964
|
if (calcColFields.length > 0) {
|
|
974
965
|
var _apiRef$current5;
|
|
975
966
|
var calculatedValues = (0, _aggregation.computeAggregationRow)(calcColFields, displayedData);
|
|
976
967
|
(_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 || _apiRef$current5.setGridOption('pinnedBottomRowData', calculatedValues);
|
|
968
|
+
} else {
|
|
969
|
+
var _apiRef$current6;
|
|
970
|
+
(_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 || _apiRef$current6.setGridOption('pinnedBottomRowData', undefined);
|
|
977
971
|
}
|
|
978
|
-
}, [allColDefs]);
|
|
972
|
+
}, [allColDefs, props.pinnedBottomRowData]);
|
|
979
973
|
var onFilterChanged = function onFilterChanged(event) {
|
|
980
974
|
calculateSum();
|
|
981
975
|
};
|
|
@@ -1369,8 +1363,8 @@ function AgGridPlus(props) {
|
|
|
1369
1363
|
},
|
|
1370
1364
|
onDragStopped: function onDragStopped(e) {
|
|
1371
1365
|
if (apiRef.current) {
|
|
1372
|
-
var _apiRef$
|
|
1373
|
-
var _columnState = (_apiRef$
|
|
1366
|
+
var _apiRef$current7;
|
|
1367
|
+
var _columnState = (_apiRef$current7 = apiRef.current) === null || _apiRef$current7 === void 0 ? void 0 : _apiRef$current7.getColumnState();
|
|
1374
1368
|
setColumnState(_columnState);
|
|
1375
1369
|
|
|
1376
1370
|
// onColumnStateChanged && onColumnStateChanged(columnState)
|
|
@@ -9,6 +9,15 @@ export interface CalculationColumnConfig {
|
|
|
9
9
|
formatWithCommas?: boolean;
|
|
10
10
|
cellRenderer?: any;
|
|
11
11
|
}
|
|
12
|
+
export interface CalculationColumnDefinition {
|
|
13
|
+
field?: string;
|
|
14
|
+
calculateType?: CalculationColumnConfig['calculateType'] | false;
|
|
15
|
+
transactionAmount?: number;
|
|
16
|
+
formatWithCommas?: boolean;
|
|
17
|
+
children?: CalculationColumnDefinition[];
|
|
18
|
+
}
|
|
19
|
+
/** 分组表头只是展示结构;原生固定合计行要读取所有叶子数值列。@author nokecy */
|
|
20
|
+
export declare const getCalculationColumns: (columns: CalculationColumnDefinition[]) => CalculationColumnConfig[];
|
|
12
21
|
export declare const isValidNumber: (value: any) => boolean;
|
|
13
22
|
export declare const sumField: (field: string, data: any[]) => number;
|
|
14
23
|
export declare const avgField: (field: string, data: any[]) => number;
|
|
@@ -4,7 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.sumField = exports.stdDevField = exports.isValidNumber = exports.formatWithCommas = exports.computeAggregationRow = exports.avgField = void 0;
|
|
7
|
+
exports.sumField = exports.stdDevField = exports.isValidNumber = exports.getCalculationColumns = exports.formatWithCommas = exports.computeAggregationRow = exports.avgField = void 0;
|
|
8
8
|
var _lodash = _interopRequireWildcard(require("lodash"));
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -13,6 +13,20 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
13
13
|
* @author nokecy
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
/** 分组表头只是展示结构;原生固定合计行要读取所有叶子数值列。@author nokecy */
|
|
17
|
+
var getCalculationColumns = exports.getCalculationColumns = function getCalculationColumns(columns) {
|
|
18
|
+
return columns.flatMap(function (column) {
|
|
19
|
+
var _column$transactionAm;
|
|
20
|
+
if (column.children) return getCalculationColumns(column.children);
|
|
21
|
+
if (!column.field || !column.calculateType) return [];
|
|
22
|
+
return [{
|
|
23
|
+
field: column.field,
|
|
24
|
+
calculateType: column.calculateType,
|
|
25
|
+
transactionAmount: (_column$transactionAm = column.transactionAmount) !== null && _column$transactionAm !== void 0 ? _column$transactionAm : 2,
|
|
26
|
+
formatWithCommas: column.formatWithCommas
|
|
27
|
+
}];
|
|
28
|
+
});
|
|
29
|
+
};
|
|
16
30
|
var isValidNumber = exports.isValidNumber = function isValidNumber(value) {
|
|
17
31
|
return typeof value === 'number' && !isNaN(value);
|
|
18
32
|
};
|
|
@@ -56,8 +56,8 @@ export declare function inferDataType(data: any, colName: string, valueEnum?: Va
|
|
|
56
56
|
* 早先是把整个 dataType 摊进 colDef,等于给列设了 type:"number"——而注册的 columnTypes 里
|
|
57
57
|
* 根本没有叫 number 的类型,这个字段一直没生效。
|
|
58
58
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* 普通数值列右对齐;合计另由 calculateType 显式控制。
|
|
60
|
+
* 用 valueEnum 表示分类的数值列(状态码之类)不动。
|
|
61
61
|
*
|
|
62
62
|
* @author nokecy
|
|
63
63
|
*/
|
|
@@ -65,6 +65,8 @@ export declare function toColumnType(dataType?: DataTypeInference): {
|
|
|
65
65
|
calculateType?: any;
|
|
66
66
|
type?: string;
|
|
67
67
|
};
|
|
68
|
+
/** 显式列类型只控制显示方式,不遮蔽数值对齐或显式合计配置。@author nokecy */
|
|
69
|
+
export declare function mergeInferredColumnType<T extends object>(column: T, dataType?: DataTypeInference): T & ReturnType<typeof toColumnType>;
|
|
68
70
|
/**
|
|
69
71
|
* 处理枚举列定义 —— **枚举列渲染的唯一实现**。
|
|
70
72
|
*
|
|
@@ -9,6 +9,7 @@ exports.createCellRenderer = createCellRenderer;
|
|
|
9
9
|
exports.filterHiddenColumns = filterHiddenColumns;
|
|
10
10
|
exports.handleGridPlusColumnState = handleGridPlusColumnState;
|
|
11
11
|
exports.inferDataType = inferDataType;
|
|
12
|
+
exports.mergeInferredColumnType = mergeInferredColumnType;
|
|
12
13
|
exports.processEllipsisColumn = processEllipsisColumn;
|
|
13
14
|
exports.processEnumColumn = processEnumColumn;
|
|
14
15
|
exports.toColumnType = toColumnType;
|
|
@@ -75,11 +76,10 @@ function handleGridPlusColumnState(columnState) {
|
|
|
75
76
|
function inferDataType(data, colName, valueEnum) {
|
|
76
77
|
var value = data[colName];
|
|
77
78
|
if (typeof value === 'number') {
|
|
78
|
-
//
|
|
79
|
-
var shouldCalculate = !valueEnum || valueEnum.length === 0;
|
|
79
|
+
// 数值只决定对齐;合计必须由列定义显式声明。@author nokecy
|
|
80
80
|
return {
|
|
81
81
|
type: 'number',
|
|
82
|
-
calculateType:
|
|
82
|
+
calculateType: valueEnum !== null && valueEnum !== void 0 && valueEnum.length ? false : undefined
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
if (typeof value === 'boolean') {
|
|
@@ -104,17 +104,19 @@ function inferDataType(data, colName, valueEnum) {
|
|
|
104
104
|
* 早先是把整个 dataType 摊进 colDef,等于给列设了 type:"number"——而注册的 columnTypes 里
|
|
105
105
|
* 根本没有叫 number 的类型,这个字段一直没生效。
|
|
106
106
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
107
|
+
* 普通数值列右对齐;合计另由 calculateType 显式控制。
|
|
108
|
+
* 用 valueEnum 表示分类的数值列(状态码之类)不动。
|
|
109
109
|
*
|
|
110
110
|
* @author nokecy
|
|
111
111
|
*/
|
|
112
112
|
function toColumnType(dataType) {
|
|
113
113
|
if (!dataType) return {};
|
|
114
|
-
if (dataType.type === 'number' && dataType.calculateType) {
|
|
115
|
-
return {
|
|
114
|
+
if (dataType.type === 'number' && dataType.calculateType !== false) {
|
|
115
|
+
return dataType.calculateType ? {
|
|
116
116
|
calculateType: dataType.calculateType,
|
|
117
117
|
type: 'rightAligned'
|
|
118
|
+
} : {
|
|
119
|
+
type: 'rightAligned'
|
|
118
120
|
};
|
|
119
121
|
}
|
|
120
122
|
return {
|
|
@@ -122,6 +124,11 @@ function toColumnType(dataType) {
|
|
|
122
124
|
};
|
|
123
125
|
}
|
|
124
126
|
|
|
127
|
+
/** 显式列类型只控制显示方式,不遮蔽数值对齐或显式合计配置。@author nokecy */
|
|
128
|
+
function mergeInferredColumnType(column, dataType) {
|
|
129
|
+
return _objectSpread(_objectSpread({}, toColumnType(dataType)), column);
|
|
130
|
+
}
|
|
131
|
+
|
|
125
132
|
/**
|
|
126
133
|
* 处理枚举列定义 —— **枚举列渲染的唯一实现**。
|
|
127
134
|
*
|
|
@@ -36,7 +36,7 @@ import ToolBar from "./toolBar";
|
|
|
36
36
|
import SettingItem from "./settingItem";
|
|
37
37
|
import { RedoOutlined, FilterOutlined } from '@ant-design/icons';
|
|
38
38
|
import { convertFilterModel, dateTimeValueFormatter, dateValueFormatter, flatten, toTree } from "./utils";
|
|
39
|
-
import {
|
|
39
|
+
import { mergeInferredColumnType, processEnumColumn } from "./utils/columnProcessors";
|
|
40
40
|
import AdvancedQueryBuilder from "./queryForm/AdvancedQueryBuilder";
|
|
41
41
|
import { v4 as uuidv4 } from 'uuid';
|
|
42
42
|
import Setting from "./setting";
|
|
@@ -55,7 +55,7 @@ import { QueryFormContext } from "./context/queryFormContext";
|
|
|
55
55
|
import { useGridSchemes } from "./context/useSchemeManager";
|
|
56
56
|
import { useSchemeDataFlow } from "./context/useSchemeDataFlow";
|
|
57
57
|
import { extractItemsOrder, extractHiddenFields } from "./shared/utils/schemeDataMigration";
|
|
58
|
-
import { computeAggregationRow } from "./utils/aggregation";
|
|
58
|
+
import { computeAggregationRow, getCalculationColumns } from "./utils/aggregation";
|
|
59
59
|
import { sortFormItemsByOrder, filterHiddenFormItems } from "./utils/queryFormDerivation";
|
|
60
60
|
import { filterVisibleSelectedRows } from "./utils/rowSelection";
|
|
61
61
|
import { buildFilterString, pageToSkipCount } from "./utils/requestParams";
|
|
@@ -433,11 +433,10 @@ function AgGridPlus(props) {
|
|
|
433
433
|
// 辅助函数: 获取数据类型
|
|
434
434
|
var getDataType = function getDataType(data, colName, valueEnum) {
|
|
435
435
|
if (typeof data[colName] === 'number') {
|
|
436
|
-
//
|
|
437
|
-
var shouldCalculate = !valueEnum || valueEnum.length === 0;
|
|
436
|
+
// 数值只用于列对齐;底部合计必须由 calculateType 显式声明。@author nokecy
|
|
438
437
|
return {
|
|
439
438
|
type: "number",
|
|
440
|
-
calculateType:
|
|
439
|
+
calculateType: valueEnum !== null && valueEnum !== void 0 && valueEnum.length ? false : undefined
|
|
441
440
|
};
|
|
442
441
|
}
|
|
443
442
|
return undefined;
|
|
@@ -465,11 +464,11 @@ function AgGridPlus(props) {
|
|
|
465
464
|
return processEnumColumn(col, dataType);
|
|
466
465
|
}
|
|
467
466
|
if (col.type || typeof col.cellRenderer == "string") {
|
|
468
|
-
return
|
|
467
|
+
return mergeInferredColumnType(col, dataType);
|
|
469
468
|
}
|
|
470
469
|
//@ts-ignore
|
|
471
470
|
if (col !== null && col !== void 0 && col.ellipsis) {
|
|
472
|
-
return _objectSpread(_objectSpread({}, col), {}, {
|
|
471
|
+
return _objectSpread(_objectSpread({}, mergeInferredColumnType(col, dataType)), {}, {
|
|
473
472
|
cellRenderer: function cellRenderer(_ref) {
|
|
474
473
|
var value = _ref.value;
|
|
475
474
|
return /*#__PURE__*/React.createElement(Text, {
|
|
@@ -486,12 +485,12 @@ function AgGridPlus(props) {
|
|
|
486
485
|
});
|
|
487
486
|
}
|
|
488
487
|
if (col.cellRenderer) {
|
|
489
|
-
return _objectSpread(_objectSpread({}, col), {}, {
|
|
488
|
+
return _objectSpread(_objectSpread({}, mergeInferredColumnType(col, dataType)), {}, {
|
|
490
489
|
customCellRenderer: col.cellRenderer,
|
|
491
490
|
cellRenderer: cellRenderer
|
|
492
491
|
});
|
|
493
492
|
}
|
|
494
|
-
return _objectSpread(_objectSpread(
|
|
493
|
+
return _objectSpread(_objectSpread({}, mergeInferredColumnType(col, dataType)), {}, {
|
|
495
494
|
customCellRenderer: col.cellRenderer,
|
|
496
495
|
cellRenderer: cellRenderer
|
|
497
496
|
});
|
|
@@ -941,6 +940,7 @@ function AgGridPlus(props) {
|
|
|
941
940
|
}
|
|
942
941
|
};
|
|
943
942
|
var calculateSum = useCallback(function () {
|
|
943
|
+
if (props.pinnedBottomRowData !== undefined) return;
|
|
944
944
|
var displayedData = [];
|
|
945
945
|
if (apiRef.current) {
|
|
946
946
|
apiRef.current.forEachNodeAfterFilter(function (node) {
|
|
@@ -952,22 +952,16 @@ function AgGridPlus(props) {
|
|
|
952
952
|
(_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.setGridOption('pinnedBottomRowData', undefined);
|
|
953
953
|
return;
|
|
954
954
|
}
|
|
955
|
-
var calcColFields = allColDefs
|
|
956
|
-
return col.calculateType;
|
|
957
|
-
}).map(function (col) {
|
|
958
|
-
return {
|
|
959
|
-
field: col.field,
|
|
960
|
-
calculateType: col.calculateType,
|
|
961
|
-
transactionAmount: col.transactionAmount || 2,
|
|
962
|
-
formatWithCommas: col.formatWithCommas
|
|
963
|
-
};
|
|
964
|
-
});
|
|
955
|
+
var calcColFields = getCalculationColumns(allColDefs);
|
|
965
956
|
if (calcColFields.length > 0) {
|
|
966
957
|
var _apiRef$current5;
|
|
967
958
|
var calculatedValues = computeAggregationRow(calcColFields, displayedData);
|
|
968
959
|
(_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 || _apiRef$current5.setGridOption('pinnedBottomRowData', calculatedValues);
|
|
960
|
+
} else {
|
|
961
|
+
var _apiRef$current6;
|
|
962
|
+
(_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 || _apiRef$current6.setGridOption('pinnedBottomRowData', undefined);
|
|
969
963
|
}
|
|
970
|
-
}, [allColDefs]);
|
|
964
|
+
}, [allColDefs, props.pinnedBottomRowData]);
|
|
971
965
|
var onFilterChanged = function onFilterChanged(event) {
|
|
972
966
|
calculateSum();
|
|
973
967
|
};
|
|
@@ -1361,8 +1355,8 @@ function AgGridPlus(props) {
|
|
|
1361
1355
|
},
|
|
1362
1356
|
onDragStopped: function onDragStopped(e) {
|
|
1363
1357
|
if (apiRef.current) {
|
|
1364
|
-
var _apiRef$
|
|
1365
|
-
var _columnState = (_apiRef$
|
|
1358
|
+
var _apiRef$current7;
|
|
1359
|
+
var _columnState = (_apiRef$current7 = apiRef.current) === null || _apiRef$current7 === void 0 ? void 0 : _apiRef$current7.getColumnState();
|
|
1366
1360
|
setColumnState(_columnState);
|
|
1367
1361
|
|
|
1368
1362
|
// onColumnStateChanged && onColumnStateChanged(columnState)
|
|
@@ -9,6 +9,15 @@ export interface CalculationColumnConfig {
|
|
|
9
9
|
formatWithCommas?: boolean;
|
|
10
10
|
cellRenderer?: any;
|
|
11
11
|
}
|
|
12
|
+
export interface CalculationColumnDefinition {
|
|
13
|
+
field?: string;
|
|
14
|
+
calculateType?: CalculationColumnConfig['calculateType'] | false;
|
|
15
|
+
transactionAmount?: number;
|
|
16
|
+
formatWithCommas?: boolean;
|
|
17
|
+
children?: CalculationColumnDefinition[];
|
|
18
|
+
}
|
|
19
|
+
/** 分组表头只是展示结构;原生固定合计行要读取所有叶子数值列。@author nokecy */
|
|
20
|
+
export declare const getCalculationColumns: (columns: CalculationColumnDefinition[]) => CalculationColumnConfig[];
|
|
12
21
|
export declare const isValidNumber: (value: any) => boolean;
|
|
13
22
|
export declare const sumField: (field: string, data: any[]) => number;
|
|
14
23
|
export declare const avgField: (field: string, data: any[]) => number;
|
|
@@ -5,6 +5,20 @@ import _, { uniqueId } from 'lodash';
|
|
|
5
5
|
* @author nokecy
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/** 分组表头只是展示结构;原生固定合计行要读取所有叶子数值列。@author nokecy */
|
|
9
|
+
export var getCalculationColumns = function getCalculationColumns(columns) {
|
|
10
|
+
return columns.flatMap(function (column) {
|
|
11
|
+
var _column$transactionAm;
|
|
12
|
+
if (column.children) return getCalculationColumns(column.children);
|
|
13
|
+
if (!column.field || !column.calculateType) return [];
|
|
14
|
+
return [{
|
|
15
|
+
field: column.field,
|
|
16
|
+
calculateType: column.calculateType,
|
|
17
|
+
transactionAmount: (_column$transactionAm = column.transactionAmount) !== null && _column$transactionAm !== void 0 ? _column$transactionAm : 2,
|
|
18
|
+
formatWithCommas: column.formatWithCommas
|
|
19
|
+
}];
|
|
20
|
+
});
|
|
21
|
+
};
|
|
8
22
|
export var isValidNumber = function isValidNumber(value) {
|
|
9
23
|
return typeof value === 'number' && !isNaN(value);
|
|
10
24
|
};
|
|
@@ -56,8 +56,8 @@ export declare function inferDataType(data: any, colName: string, valueEnum?: Va
|
|
|
56
56
|
* 早先是把整个 dataType 摊进 colDef,等于给列设了 type:"number"——而注册的 columnTypes 里
|
|
57
57
|
* 根本没有叫 number 的类型,这个字段一直没生效。
|
|
58
58
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* 普通数值列右对齐;合计另由 calculateType 显式控制。
|
|
60
|
+
* 用 valueEnum 表示分类的数值列(状态码之类)不动。
|
|
61
61
|
*
|
|
62
62
|
* @author nokecy
|
|
63
63
|
*/
|
|
@@ -65,6 +65,8 @@ export declare function toColumnType(dataType?: DataTypeInference): {
|
|
|
65
65
|
calculateType?: any;
|
|
66
66
|
type?: string;
|
|
67
67
|
};
|
|
68
|
+
/** 显式列类型只控制显示方式,不遮蔽数值对齐或显式合计配置。@author nokecy */
|
|
69
|
+
export declare function mergeInferredColumnType<T extends object>(column: T, dataType?: DataTypeInference): T & ReturnType<typeof toColumnType>;
|
|
68
70
|
/**
|
|
69
71
|
* 处理枚举列定义 —— **枚举列渲染的唯一实现**。
|
|
70
72
|
*
|
|
@@ -60,11 +60,10 @@ export function handleGridPlusColumnState(columnState) {
|
|
|
60
60
|
export function inferDataType(data, colName, valueEnum) {
|
|
61
61
|
var value = data[colName];
|
|
62
62
|
if (typeof value === 'number') {
|
|
63
|
-
//
|
|
64
|
-
var shouldCalculate = !valueEnum || valueEnum.length === 0;
|
|
63
|
+
// 数值只决定对齐;合计必须由列定义显式声明。@author nokecy
|
|
65
64
|
return {
|
|
66
65
|
type: 'number',
|
|
67
|
-
calculateType:
|
|
66
|
+
calculateType: valueEnum !== null && valueEnum !== void 0 && valueEnum.length ? false : undefined
|
|
68
67
|
};
|
|
69
68
|
}
|
|
70
69
|
if (typeof value === 'boolean') {
|
|
@@ -89,17 +88,19 @@ export function inferDataType(data, colName, valueEnum) {
|
|
|
89
88
|
* 早先是把整个 dataType 摊进 colDef,等于给列设了 type:"number"——而注册的 columnTypes 里
|
|
90
89
|
* 根本没有叫 number 的类型,这个字段一直没生效。
|
|
91
90
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
91
|
+
* 普通数值列右对齐;合计另由 calculateType 显式控制。
|
|
92
|
+
* 用 valueEnum 表示分类的数值列(状态码之类)不动。
|
|
94
93
|
*
|
|
95
94
|
* @author nokecy
|
|
96
95
|
*/
|
|
97
96
|
export function toColumnType(dataType) {
|
|
98
97
|
if (!dataType) return {};
|
|
99
|
-
if (dataType.type === 'number' && dataType.calculateType) {
|
|
100
|
-
return {
|
|
98
|
+
if (dataType.type === 'number' && dataType.calculateType !== false) {
|
|
99
|
+
return dataType.calculateType ? {
|
|
101
100
|
calculateType: dataType.calculateType,
|
|
102
101
|
type: 'rightAligned'
|
|
102
|
+
} : {
|
|
103
|
+
type: 'rightAligned'
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
106
|
return {
|
|
@@ -107,6 +108,11 @@ export function toColumnType(dataType) {
|
|
|
107
108
|
};
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
/** 显式列类型只控制显示方式,不遮蔽数值对齐或显式合计配置。@author nokecy */
|
|
112
|
+
export function mergeInferredColumnType(column, dataType) {
|
|
113
|
+
return _objectSpread(_objectSpread({}, toColumnType(dataType)), column);
|
|
114
|
+
}
|
|
115
|
+
|
|
110
116
|
/**
|
|
111
117
|
* 处理枚举列定义 —— **枚举列渲染的唯一实现**。
|
|
112
118
|
*
|