ztxkui 10.0.75 → 10.0.77

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.
@@ -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,27 +456,27 @@ 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
- if (_column.title.includes('单价')) {
475
+ if (typeof title === 'string' && title.includes('单价')) {
476
476
  return priceOrAmountFormat(text, _column.precision || precisions.price);
477
477
  }
478
- else if (_column.title.includes('金额') ||
479
- _column.title.includes('税额')) {
478
+ else if (typeof title === 'string' &&
479
+ (title.includes('金额') || title.includes('税额'))) {
480
480
  return priceOrAmountFormat(text, _column.precision || precisions.amount);
481
481
  }
482
482
  if (_column.dateFormat)
@@ -9,12 +9,30 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import React from 'react';
12
+ import React, { useContext } from 'react';
13
13
  import { Col } from 'antd';
14
14
  import classNames from 'classnames';
15
+ import { toThousand, exactRound } from 'ztxkutils/dist/tools';
16
+ import ZtxkContext from '../../utils/ZtxkContext';
17
+ function priceOrAmountFormat(text, precision) {
18
+ text = text === null || text === void 0 ? void 0 : text.replaceAll(',', '');
19
+ return toThousand(exactRound(text, precision));
20
+ }
15
21
  var Item = function (_a) {
16
22
  var children = _a.children, className = _a.className, title = _a.title, _b = _a.colon, colon = _b === void 0 ? true : _b, span = _a.span, titleSpan = _a.titleSpan, titleProps = _a.titleProps, textProps = _a.textProps, showDiff = _a.showDiff, _c = _a.isEllipsis, isEllipsis = _c === void 0 ? true : _c, isBlod = _a.isBlod;
17
23
  var classes = classNames('zt-new-grid-item', className);
24
+ var precisions = useContext(ZtxkContext).precisions;
25
+ function getChildren() {
26
+ if (title.includes('单价')) {
27
+ return priceOrAmountFormat(children, precisions.price);
28
+ }
29
+ else if (title.includes('金额') || title.includes('税额')) {
30
+ return priceOrAmountFormat(children, precisions.amount);
31
+ }
32
+ else {
33
+ return children;
34
+ }
35
+ }
18
36
  return (React.createElement(React.Fragment, null,
19
37
  React.createElement(Col, __assign({ className: classes + ' zt-new-grid-item--title',
20
38
  // span={titleSpan ? titleSpan : Math.ceil(span * 0.3)}
@@ -33,6 +51,6 @@ var Item = function (_a) {
33
51
  ? ' zt-new-grid-item--text-ellipsis'
34
52
  : ' zt-new-grid-item--text-noellipsis')),
35
53
  // span={titleSpan ? span - titleSpan : span - Math.ceil(span * 0.3)}
36
- span: titleSpan ? span - titleSpan : span - 3, title: typeof children === 'string' ? children : undefined, style: { fontWeight: isBlod ? 'bold' : 'normal' } }, textProps), children)));
54
+ span: titleSpan ? span - titleSpan : span - 3, title: typeof children === 'string' ? children : undefined, style: { fontWeight: isBlod ? 'bold' : 'normal' } }, textProps), getChildren())));
37
55
  };
38
56
  export default Item;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "10.0.75",
3
+ "version": "10.0.77",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",