ztxkui 10.0.74 → 10.0.76
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.
|
@@ -14,10 +14,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
14
14
|
to[j] = from[i];
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
|
-
import React, { useCallback, useState, useRef, useMemo } from 'react';
|
|
17
|
+
import React, { useCallback, useState, useRef, useMemo, useContext, } from 'react';
|
|
18
18
|
import { unstable_batchedUpdates } from 'react-dom';
|
|
19
19
|
import Button from '../../Button';
|
|
20
|
-
import { Popconfirm } from '../../../index';
|
|
20
|
+
import { Popconfirm, ZtxkContext } from '../../../index';
|
|
21
21
|
import { PicRightOutlined, MinusSquareOutlined } from '@ant-design/icons';
|
|
22
22
|
import TableAddDelColumn from '../table-adddel-column';
|
|
23
23
|
import TableHeadTooltip from '../table-headTooltip';
|
|
@@ -211,7 +211,7 @@ export function setDynamicKey(dynamicStorageKey, value) {
|
|
|
211
211
|
localStorage.setItem(LOCALSTORAGE_LRU_KEY, JSON.stringify(lruKeys));
|
|
212
212
|
}
|
|
213
213
|
function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig) {
|
|
214
|
-
var columns = basicConfig.columns, newColumnsRef = basicConfig.newColumnsRef, showColumnDynamic = basicConfig.showColumnDynamic, showColumnDynamicKey = basicConfig.showColumnDynamicKey, configInfo = basicConfig.configInfo, currentDataSource = basicConfig.currentDataSource, preDataSource = basicConfig.preDataSource, rowKey = basicConfig.rowKey, dataSourceRef = basicConfig.dataSourceRef, expandableChildrenColumnName = basicConfig.expandableChildrenColumnName, upDateColumnsRef = basicConfig.upDateColumnsRef, setUpDateColumnsRef = basicConfig.setUpDateColumnsRef, isUpDateColumnsRef = basicConfig.isUpDateColumnsRef, setIsUpDateColumnsRef = basicConfig.setIsUpDateColumnsRef;
|
|
214
|
+
var columns = basicConfig.columns, newColumnsRef = basicConfig.newColumnsRef, showColumnDynamic = basicConfig.showColumnDynamic, showColumnDynamicKey = basicConfig.showColumnDynamicKey, configInfo = basicConfig.configInfo, currentDataSource = basicConfig.currentDataSource, preDataSource = basicConfig.preDataSource, rowKey = basicConfig.rowKey, dataSourceRef = basicConfig.dataSourceRef, expandableChildrenColumnName = basicConfig.expandableChildrenColumnName, upDateColumnsRef = basicConfig.upDateColumnsRef, setUpDateColumnsRef = basicConfig.setUpDateColumnsRef, isUpDateColumnsRef = basicConfig.isUpDateColumnsRef, setIsUpDateColumnsRef = basicConfig.setIsUpDateColumnsRef, precisions = basicConfig.precisions;
|
|
215
215
|
var onEditableSave = editableConfig.onEditableSave, onTableChange = editableConfig.onTableChange, currentPage = editableConfig.currentPage;
|
|
216
216
|
var ColumnDynamicCom = dynamicConfig.ColumnDynamicCom, DelAllCom = dynamicConfig.DelAllCom, onAddAndDelHandleMemo = dynamicConfig.onAddAndDelHandleMemo, onAddAndDelHandle = dynamicConfig.onAddAndDelHandle, hideAddIcon = dynamicConfig.hideAddIcon, addIconText = dynamicConfig.addIconText, hideDelIcon = dynamicConfig.hideDelIcon, delIconText = dynamicConfig.delIconText;
|
|
217
217
|
var copyByKey = otherConfig.copyByKey, myCatchColumns = otherConfig.myCatchColumns, customSortHandle = otherConfig.customSortHandle, customOrder = otherConfig.customOrder, setCustomOrder = otherConfig.setCustomOrder, isSort = otherConfig.isSort, menuShow = otherConfig.menuShow, getMenuInfoByCell = otherConfig.getMenuInfoByCell;
|
|
@@ -401,7 +401,7 @@ function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig)
|
|
|
401
401
|
_newColumns.push(_column);
|
|
402
402
|
}
|
|
403
403
|
// 添加render字段
|
|
404
|
-
appendRender(_column);
|
|
404
|
+
appendRender(_column, col.title);
|
|
405
405
|
// 添加表头提示信息
|
|
406
406
|
if (_column.headTooltip) {
|
|
407
407
|
_column.title = (React.createElement(TableHeadTooltip, { headTooltip: _column.headTooltip }, _column.title));
|
|
@@ -456,23 +456,30 @@ function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig)
|
|
|
456
456
|
_newColumns: _newColumns,
|
|
457
457
|
_dynamicColumns: _dynamicColumns,
|
|
458
458
|
};
|
|
459
|
-
function appendRender(_column) {
|
|
459
|
+
function appendRender(_column, title) {
|
|
460
460
|
if (!_column.render) {
|
|
461
461
|
if (_column.children) {
|
|
462
462
|
_column.children.forEach(function (item) {
|
|
463
|
-
appendRender(item);
|
|
463
|
+
appendRender(item, item.title);
|
|
464
464
|
});
|
|
465
465
|
}
|
|
466
466
|
else {
|
|
467
|
-
_column.render = returnRender(_column);
|
|
467
|
+
_column.render = returnRender(_column, title);
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
|
-
function returnRender(_column) {
|
|
470
|
+
function returnRender(_column, title) {
|
|
471
471
|
return function (text, record, index) {
|
|
472
472
|
var value = text;
|
|
473
473
|
if (text == null || text === '')
|
|
474
474
|
return '— —';
|
|
475
|
-
|
|
475
|
+
if (typeof title === 'string' && title.includes('单价')) {
|
|
476
|
+
return priceOrAmountFormat(text, _column.precision || precisions.price);
|
|
477
|
+
}
|
|
478
|
+
else if (typeof title === 'string' &&
|
|
479
|
+
(title.includes('金额') || title.includes('税额'))) {
|
|
480
|
+
return priceOrAmountFormat(text, _column.precision || precisions.amount);
|
|
481
|
+
}
|
|
482
|
+
if (_column.dateFormat)
|
|
476
483
|
return dayjs(text).format(_column.dateFormat);
|
|
477
484
|
if (_column.precision)
|
|
478
485
|
value = exactRound(text, _column.precision);
|
|
@@ -481,10 +488,15 @@ function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig)
|
|
|
481
488
|
return value;
|
|
482
489
|
};
|
|
483
490
|
}
|
|
491
|
+
function priceOrAmountFormat(text, precision) {
|
|
492
|
+
text = text === null || text === void 0 ? void 0 : text.replaceAll(',', '');
|
|
493
|
+
return toThousand(exactRound(text, precision));
|
|
494
|
+
}
|
|
484
495
|
}
|
|
485
496
|
}
|
|
486
497
|
function useColumns(props) {
|
|
487
498
|
var columns = props.columns, hiddenColumnDynamicIcon = props.hiddenColumnDynamicIcon, showColumnDynamic = props.showColumnDynamic, showColumnDynamicKey = props.showColumnDynamicKey, onAddAndDelHandle = props.onAddAndDelHandle, hideAddIcon = props.hideAddIcon, showDelAllBtn = props.showDelAllBtn, delAllChange = props.delAllChange, addIconText = props.addIconText, hideDelIcon = props.hideDelIcon, delIconText = props.delIconText, showDynamicHandle = props.showDynamicHandle, onEditableSave = props.onEditableSave, configInfo = props.configInfo, copyByKey = props.copyByKey, onTableChange = props.onTableChange, currentPage = props.currentPage, currentDataSource = props.currentDataSource, preDataSource = props.preDataSource, rowKey = props.rowKey, dataSourceRef = props.dataSourceRef, expandableChildrenColumnName = props.expandableChildrenColumnName, customSortHandle = props.customSortHandle, customOrder = props.customOrder, setCustomOrder = props.setCustomOrder, isSort = props.isSort, menuShow = props.menuShow, getMenuInfoByCell = props.getMenuInfoByCell;
|
|
499
|
+
var precisions = useContext(ZtxkContext).precisions;
|
|
488
500
|
var newColumnsRef = useRef();
|
|
489
501
|
var _a = useAsyncSetValue(columns), upDateColumnsRef = _a[0], setUpDateColumnsRef = _a[1];
|
|
490
502
|
var _b = useAsyncSetValue(false), isUpDateColumnsRef = _b[0], setIsUpDateColumnsRef = _b[1];
|
|
@@ -524,6 +536,7 @@ function useColumns(props) {
|
|
|
524
536
|
setUpDateColumnsRef: setUpDateColumnsRef,
|
|
525
537
|
isUpDateColumnsRef: isUpDateColumnsRef,
|
|
526
538
|
setIsUpDateColumnsRef: setIsUpDateColumnsRef,
|
|
539
|
+
precisions: precisions,
|
|
527
540
|
}, {
|
|
528
541
|
onEditableSave: onEditableSave,
|
|
529
542
|
onTableChange: onTableChange,
|
|
@@ -578,6 +591,7 @@ function useColumns(props) {
|
|
|
578
591
|
isSort,
|
|
579
592
|
menuShow,
|
|
580
593
|
getMenuInfoByCell,
|
|
594
|
+
precisions,
|
|
581
595
|
]);
|
|
582
596
|
var _c = useState(false), refreshColumns = _c[0], setRefreshColumns = _c[1];
|
|
583
597
|
var _d = useState([]), myCatchColumns = _d[0], setMyCatchColumns = _d[1];
|
|
@@ -20,16 +20,34 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import React from 'react';
|
|
23
|
+
import React, { useContext } from 'react';
|
|
24
24
|
import { Col } from 'antd';
|
|
25
25
|
import classNames from 'classnames';
|
|
26
|
+
import { toThousand, exactRound } from 'ztxkutils/dist/tools';
|
|
27
|
+
import ZtxkContext from '../../utils/ZtxkContext';
|
|
28
|
+
function priceOrAmountFormat(text, precision) {
|
|
29
|
+
text = text === null || text === void 0 ? void 0 : text.replaceAll(',', '');
|
|
30
|
+
return toThousand(exactRound(text, precision));
|
|
31
|
+
}
|
|
26
32
|
var Item = function (_a) {
|
|
27
33
|
var children = _a.children, className = _a.className, title = _a.title, showDiff = _a.showDiff, restProps = __rest(_a, ["children", "className", "title", "showDiff"]);
|
|
28
34
|
var classes = classNames('zt-item', className);
|
|
35
|
+
var precisions = useContext(ZtxkContext).precisions;
|
|
36
|
+
function getChildren() {
|
|
37
|
+
if (title.includes('单价')) {
|
|
38
|
+
return priceOrAmountFormat(children, precisions.price);
|
|
39
|
+
}
|
|
40
|
+
else if (title.includes('金额') || title.includes('税额')) {
|
|
41
|
+
return priceOrAmountFormat(children, precisions.amount);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return children;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
29
47
|
return (React.createElement(Col, __assign({ className: classes }, restProps),
|
|
30
48
|
React.createElement("span", { className: "zt-item--title" },
|
|
31
49
|
title,
|
|
32
50
|
"\uFF1A"),
|
|
33
|
-
React.createElement("span", { className: showDiff ? 'zt-item--text zt-item--text-diff' : 'zt-item--text' },
|
|
51
|
+
React.createElement("span", { className: showDiff ? 'zt-item--text zt-item--text-diff' : 'zt-item--text' }, getChildren())));
|
|
34
52
|
};
|
|
35
53
|
export default Item;
|