ztxkui 4.2.23-601 → 4.2.23-603
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.
|
@@ -359,6 +359,7 @@ function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig)
|
|
|
359
359
|
_columns.forEach(function (column) {
|
|
360
360
|
var dataIndex = column.dataIndex || column.key;
|
|
361
361
|
if (typeof dataIndex === 'string' &&
|
|
362
|
+
!column.disablePrecisionControl &&
|
|
362
363
|
(isCustomDecimalField === null || isCustomDecimalField === void 0 ? void 0 : isCustomDecimalField(dataIndex, column))) {
|
|
363
364
|
autoDecimalFieldsRef.current[dataIndex] = {
|
|
364
365
|
autoDecimal: true,
|
|
@@ -379,7 +380,10 @@ function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig)
|
|
|
379
380
|
// 当前字段是否需要控制小数位(前提是必须要有物料描述字段并且传入了部门参数)
|
|
380
381
|
var isDecimal = false;
|
|
381
382
|
var dataIndex = col.dataIndex || col.key;
|
|
382
|
-
if (materialDescField &&
|
|
383
|
+
if (materialDescField &&
|
|
384
|
+
isDecimalField &&
|
|
385
|
+
typeof dataIndex === 'string' &&
|
|
386
|
+
!col.disablePrecisionControl) {
|
|
383
387
|
isDecimal = isDecimalField(dataIndex, col);
|
|
384
388
|
}
|
|
385
389
|
// 自定义设置小数位数
|
|
@@ -503,6 +507,7 @@ function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig)
|
|
|
503
507
|
isHasFilterRef: isHasFilterRef,
|
|
504
508
|
getPrecision: getPrecision,
|
|
505
509
|
disableExeclCopy: disableExeclCopy_1,
|
|
510
|
+
disablePrecisionControl: _column.disablePrecisionControl,
|
|
506
511
|
});
|
|
507
512
|
} });
|
|
508
513
|
// 兼容下拉框滚动行为
|
|
@@ -769,15 +774,20 @@ function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig)
|
|
|
769
774
|
_column.render = function (text, record, index) {
|
|
770
775
|
var percisionResult = getPrecision ? getPrecision === null || getPrecision === void 0 ? void 0 : getPrecision(record) : null;
|
|
771
776
|
var renderOption = {};
|
|
772
|
-
if (percisionResult) {
|
|
777
|
+
if (percisionResult != null) {
|
|
773
778
|
renderOption.precision = percisionResult;
|
|
774
779
|
}
|
|
780
|
+
else if (_column.disablePrecisionControl &&
|
|
781
|
+
typeof _column.precision === 'number') {
|
|
782
|
+
renderOption.precision = _column.precision;
|
|
783
|
+
}
|
|
775
784
|
var selfResult = selfRender_1(text, record, index, renderOption);
|
|
776
785
|
try {
|
|
777
786
|
// 如果命中了自定义显示字段,并且命中了是数字
|
|
778
787
|
var dataIndex = _column.dataIndex || _column.key;
|
|
779
788
|
var title = columnTitle !== null && columnTitle !== void 0 ? columnTitle : _column.title;
|
|
780
|
-
if (
|
|
789
|
+
if (!_column.disablePrecisionControl &&
|
|
790
|
+
(isCustomDecimalField === null || isCustomDecimalField === void 0 ? void 0 : isCustomDecimalField(dataIndex, __assign(__assign({}, _column), { title: title })))) {
|
|
781
791
|
// 去掉千分符 还是数字的话
|
|
782
792
|
var newValue = typeof selfResult === 'string'
|
|
783
793
|
? selfResult.replace(/,/g, '')
|
|
@@ -870,10 +880,10 @@ function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig)
|
|
|
870
880
|
else if (_column.dateFormat) {
|
|
871
881
|
return dayjs(text).format(_column.dateFormat);
|
|
872
882
|
}
|
|
873
|
-
if (percisionResult) {
|
|
883
|
+
if (percisionResult != null) {
|
|
874
884
|
value = exactRound(text, percisionResult);
|
|
875
885
|
}
|
|
876
|
-
else if (_column.precision) {
|
|
886
|
+
else if (_column.precision != null) {
|
|
877
887
|
value = exactRound(text, _column.precision);
|
|
878
888
|
}
|
|
879
889
|
if (_column.thousand) {
|
|
@@ -883,7 +893,8 @@ function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig)
|
|
|
883
893
|
// 如果命中了自定义显示字段,并且命中了是数字
|
|
884
894
|
var dataIndex = _column.dataIndex || _column.key;
|
|
885
895
|
var title = columnTitle !== null && columnTitle !== void 0 ? columnTitle : _column.title;
|
|
886
|
-
if (
|
|
896
|
+
if (!_column.disablePrecisionControl &&
|
|
897
|
+
(isCustomDecimalField === null || isCustomDecimalField === void 0 ? void 0 : isCustomDecimalField(dataIndex, __assign(__assign({}, _column), { title: title })))) {
|
|
887
898
|
// 去掉千分符 还是数字的话
|
|
888
899
|
var newValue_1 = typeof value === 'string' ? (_a = value === null || value === void 0 ? void 0 : value.replace) === null || _a === void 0 ? void 0 : _a.call(value, /,/g, '') : value;
|
|
889
900
|
if (isNumber(newValue_1) && isNumber(text)) {
|
|
@@ -55,6 +55,8 @@ export interface IColumnType<RecordType> extends Omit<ColumnType<RecordType>, 'r
|
|
|
55
55
|
dateFormat?: string;
|
|
56
56
|
/**精度 */
|
|
57
57
|
precision?: number;
|
|
58
|
+
/**是否禁用精度控制(包括isDecimalField、precisionHandle、isCustomDecimalField等动态精度处理)*/
|
|
59
|
+
disablePrecisionControl?: boolean;
|
|
58
60
|
/**是否加上千分符 */
|
|
59
61
|
thousand?: boolean;
|
|
60
62
|
/**表头别名 */
|
|
@@ -56,6 +56,8 @@ interface IEditableCellProps {
|
|
|
56
56
|
onTableChange: any;
|
|
57
57
|
currentpage: ICurrentPage;
|
|
58
58
|
noTdWrap?: boolean;
|
|
59
|
+
/**是否禁用动态精度控制(保留静态 precision)*/
|
|
60
|
+
disablePrecisionControl?: boolean;
|
|
59
61
|
[props: string]: any;
|
|
60
62
|
}
|
|
61
63
|
declare const _default: React.NamedExoticComponent<IEditableCellProps>;
|
|
@@ -137,7 +137,7 @@ export function transformData(data, config) {
|
|
|
137
137
|
return newData;
|
|
138
138
|
}
|
|
139
139
|
var TableEnhanceCell = function (_a) {
|
|
140
|
-
var title = _a.title, index = _a.index, editable = _a.editable, editableConfig = _a.editableConfig, children = _a.children, dataIndex = _a.dataIndex, record = _a.record, handleSave = _a.handleSave, dataSource = _a.dataSource, onTableChange = _a.onTableChange, columns = _a.columns, currentpage = _a.currentpage, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, rowKey = _a.rowKey, expandableChildrenColumnName = _a.expandableChildrenColumnName, isHasFilterRef = _a.isHasFilterRef, getPrecision = _a.getPrecision, disableExeclCopy = _a.disableExeclCopy, noTdWrap = _a.noTdWrap, restProps = __rest(_a, ["title", "index", "editable", "editableConfig", "children", "dataIndex", "record", "handleSave", "dataSource", "onTableChange", "columns", "currentpage", "onMouseEnter", "onMouseLeave", "rowKey", "expandableChildrenColumnName", "isHasFilterRef", "getPrecision", "disableExeclCopy", "noTdWrap"]);
|
|
140
|
+
var title = _a.title, index = _a.index, editable = _a.editable, editableConfig = _a.editableConfig, children = _a.children, dataIndex = _a.dataIndex, record = _a.record, handleSave = _a.handleSave, dataSource = _a.dataSource, onTableChange = _a.onTableChange, columns = _a.columns, currentpage = _a.currentpage, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, rowKey = _a.rowKey, expandableChildrenColumnName = _a.expandableChildrenColumnName, isHasFilterRef = _a.isHasFilterRef, getPrecision = _a.getPrecision, disableExeclCopy = _a.disableExeclCopy, disablePrecisionControl = _a.disablePrecisionControl, noTdWrap = _a.noTdWrap, restProps = __rest(_a, ["title", "index", "editable", "editableConfig", "children", "dataIndex", "record", "handleSave", "dataSource", "onTableChange", "columns", "currentpage", "onMouseEnter", "onMouseLeave", "rowKey", "expandableChildrenColumnName", "isHasFilterRef", "getPrecision", "disableExeclCopy", "disablePrecisionControl", "noTdWrap"]);
|
|
141
141
|
var tdRef = useRef();
|
|
142
142
|
var valueRef = useRef({});
|
|
143
143
|
var _b = useState(), val = _b[0], setVal = _b[1];
|
|
@@ -378,15 +378,20 @@ var TableEnhanceCell = function (_a) {
|
|
|
378
378
|
selectData = data();
|
|
379
379
|
}
|
|
380
380
|
var precisionResult = precision;
|
|
381
|
-
//
|
|
382
|
-
if (
|
|
383
|
-
|
|
384
|
-
|
|
381
|
+
// 禁用动态精度控制时,直接使用静态 precision
|
|
382
|
+
if (!disablePrecisionControl) {
|
|
383
|
+
// 这个配置的优先级最高
|
|
384
|
+
if (getPrecisionRef.current) {
|
|
385
|
+
try {
|
|
386
|
+
var dynamicPrecision = getPrecisionRef.current(record);
|
|
387
|
+
precisionResult =
|
|
388
|
+
dynamicPrecision != null ? dynamicPrecision : precision;
|
|
389
|
+
}
|
|
390
|
+
catch (err) { }
|
|
391
|
+
}
|
|
392
|
+
else if (precisionHandle) {
|
|
393
|
+
precisionResult = precisionHandle(record);
|
|
385
394
|
}
|
|
386
|
-
catch (err) { }
|
|
387
|
-
}
|
|
388
|
-
else if (precisionHandle) {
|
|
389
|
-
precisionResult = precisionHandle(record);
|
|
390
395
|
}
|
|
391
396
|
if (maxHandle && maxHandle instanceof Function) {
|
|
392
397
|
var result = maxHandle(record, { precision: precisionResult });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ztxkui",
|
|
3
|
-
"version": "4.2.23-
|
|
3
|
+
"version": "4.2.23-603",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "React components library",
|
|
6
6
|
"author": "zt-front-end",
|
|
@@ -111,4 +111,4 @@
|
|
|
111
111
|
"react-dom": ">=16.9.0",
|
|
112
112
|
"ztxkutils": ">=2.1.1"
|
|
113
113
|
}
|
|
114
|
-
}
|
|
114
|
+
}
|