ztxkui 10.0.74 → 10.0.75

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;
@@ -472,7 +472,14 @@ function getNewColumns(basicConfig, editableConfig, dynamicConfig, otherConfig)
472
472
  var value = text;
473
473
  if (text == null || text === '')
474
474
  return '— —';
475
- else if (_column.dateFormat)
475
+ if (_column.title.includes('单价')) {
476
+ return priceOrAmountFormat(text, _column.precision || precisions.price);
477
+ }
478
+ else if (_column.title.includes('金额') ||
479
+ _column.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' }, children)));
51
+ React.createElement("span", { className: showDiff ? 'zt-item--text zt-item--text-diff' : 'zt-item--text' }, getChildren())));
34
52
  };
35
53
  export default Item;
@@ -10,6 +10,10 @@ export interface IZtxkConfig {
10
10
  serviceNames?: {
11
11
  mdmServiceName?: string;
12
12
  };
13
+ precisions: {
14
+ price: number;
15
+ amount: number;
16
+ };
13
17
  }
14
18
  declare const ZtxkContext: React.Context<IZtxkConfig>;
15
19
  export default ZtxkContext;
@@ -9,6 +9,10 @@ var ztxkConfig = {
9
9
  serviceNames: {
10
10
  mdmServiceName: '/zmdms-mdm-data',
11
11
  },
12
+ precisions: {
13
+ price: 2,
14
+ amount: 2,
15
+ },
12
16
  };
13
17
  var ZtxkContext = React.createContext(ztxkConfig);
14
18
  export default ZtxkContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "10.0.74",
3
+ "version": "10.0.75",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",