kts-component-invoice-operate 3.2.117 → 3.2.118-1

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.
@@ -2,6 +2,7 @@ import './index.less';
2
2
  import React from 'react';
3
3
  import InvoiceController from './InvoiceController';
4
4
  import * as calculator from './tools/calculate';
5
+ import * as utils from './tools/utils';
5
6
  import GoodsList from './ui/default/GoodsList';
6
7
  import Seller from './ui/default/Seller';
7
8
  import Buyer from './ui/default/Buyer';
@@ -53,6 +54,8 @@ export default class Invoice extends React.PureComponent<IInvoiceProps> {
53
54
  static idGenerator: () => string;
54
55
  /** 金额计算方法 */
55
56
  static calculator: typeof calculator;
57
+ /** 工具方法 */
58
+ static utils: typeof utils;
56
59
  /** 获取控制器钩子 */
57
60
  static useInvoiceController: () => InvoiceController;
58
61
  render(): JSX.Element;
@@ -0,0 +1 @@
1
+ export * as Money from './money';
@@ -0,0 +1,2 @@
1
+ /** 数字转中文 */
2
+ export declare const toStringChinese: (value: any) => string;
package/dist/index.esm.js CHANGED
@@ -9547,6 +9547,102 @@ function useToGenerateId(controller) {
9547
9547
  }, [goodsList]);
9548
9548
  }
9549
9549
 
9550
+ /** 数字转中文 */
9551
+ var toStringChinese = function toStringChinese(value) {
9552
+ var numberValue = Math.round(value * 100).toString(); // 数字金额
9553
+
9554
+ var chineseValue = ''; // 转换后的汉字金额
9555
+
9556
+ var String1 = '零壹贰叁肆伍陆柒捌玖'; // 汉字数字
9557
+
9558
+ var String2 = '万仟佰拾亿仟佰拾万仟佰拾圆角分'; // 对应单位
9559
+
9560
+ var len = numberValue.length; // numberValue 的字符串长度
9561
+
9562
+ var Ch1; // 数字的汉语读法
9563
+
9564
+ var Ch2; // 数字位的汉字读法
9565
+
9566
+ var nZero = 0; // 用来计算连续的零值的个数
9567
+
9568
+ var String3; // 指定位置的数值
9569
+
9570
+ if (len > 15) {
9571
+ alert('超出计算范围');
9572
+ return '';
9573
+ }
9574
+
9575
+ if (parseFloat(numberValue) === 0) {
9576
+ chineseValue = '零圆整';
9577
+ return chineseValue;
9578
+ }
9579
+
9580
+ String2 = String2.substr(String2.length - len, len); // 取出对应位数的STRING2的值
9581
+
9582
+ for (var i = 0; i < len; i++) {
9583
+ String3 = parseInt(numberValue.substr(i, 1), 10); // 取出需转换的某一位的值
9584
+
9585
+ if (i !== len - 3 && i !== len - 7 && i !== len - 11 && i !== len - 15) {
9586
+ if (String3 === 0) {
9587
+ Ch1 = '';
9588
+ Ch2 = '';
9589
+ nZero++;
9590
+ } else if (String3 !== 0 && nZero !== 0) {
9591
+ Ch1 = '零' + String1.substr(String3, 1);
9592
+ Ch2 = String2.substr(i, 1);
9593
+ nZero = 0;
9594
+ } else {
9595
+ Ch1 = String1.substr(String3, 1);
9596
+ Ch2 = String2.substr(i, 1);
9597
+ nZero = 0;
9598
+ }
9599
+ } else {
9600
+ // 该位是万亿,亿,万,元位等关键位
9601
+ if (String3 !== 0 && nZero !== 0) {
9602
+ Ch1 = '零' + String1.substr(String3, 1);
9603
+ Ch2 = String2.substr(i, 1);
9604
+ nZero = 0;
9605
+ } else if (String3 !== 0 && nZero === 0) {
9606
+ Ch1 = String1.substr(String3, 1);
9607
+ Ch2 = String2.substr(i, 1);
9608
+ nZero = 0;
9609
+ } else if (String3 === 0 && nZero >= 3) {
9610
+ Ch1 = '';
9611
+ Ch2 = '';
9612
+ nZero++;
9613
+ } else {
9614
+ Ch1 = '';
9615
+ Ch2 = String2.substr(i, 1);
9616
+ nZero++;
9617
+ }
9618
+
9619
+ if (i === len - 11 || i === len - 3) {
9620
+ // 如果该位是亿位或元位,则必须写上
9621
+ Ch2 = String2.substr(i, 1);
9622
+ }
9623
+ }
9624
+
9625
+ chineseValue = chineseValue + Ch1 + Ch2;
9626
+ }
9627
+
9628
+ if (String3 === 0) {
9629
+ // 最后一位(分)为0时,加上“整”
9630
+ chineseValue += '整';
9631
+ }
9632
+
9633
+ return chineseValue;
9634
+ };
9635
+
9636
+ var index = /*#__PURE__*/Object.freeze({
9637
+ __proto__: null,
9638
+ toStringChinese: toStringChinese
9639
+ });
9640
+
9641
+ var utils = /*#__PURE__*/Object.freeze({
9642
+ __proto__: null,
9643
+ Money: index
9644
+ });
9645
+
9550
9646
  var _defs, _path, _path2, _path3;
9551
9647
 
9552
9648
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -9906,8 +10002,6 @@ function TableVirtual (props) {
9906
10002
  var css_248z$3 = ".kts-invoice-operate-goods-list-statistics {\n background: #fafafa;\n overflow-y: scroll;\n}\n.kts-invoice-operate-goods-list-statistics .kts-invoice-operate-goods-list-statistics-row {\n height: 30px;\n line-height: 30px;\n border-bottom: 1px solid #e8e8e8;\n display: flex;\n}\n.kts-invoice-operate-goods-list-statistics .kts-invoice-operate-goods-list-statistics-row > div {\n border-right: 1px solid #e8e8e8;\n}\n.kts-invoice-operate-goods-list-statistics .kts-invoice-operate-goods-list-statistics-row > div label {\n padding: 0 10px;\n}\n";
9907
10003
  styleInject(css_248z$3);
9908
10004
 
9909
- var nzhcn = require('nzh').cn;
9910
-
9911
10005
  var Statistics = (function () {
9912
10006
  var controller = Invoice.useInvoiceController();
9913
10007
  /** 是否不含税) */
@@ -10033,9 +10127,7 @@ var Statistics = (function () {
10033
10127
  flex: 5,
10034
10128
  border: 'none'
10035
10129
  }
10036
- }, /*#__PURE__*/React.createElement("label", null, "\u4EF7\u7A0E\u5408\u8BA1\uFF08\u5927\u5199\uFF09"), /*#__PURE__*/React.createElement("label", null, nzhcn.toMoney(lineAmountIncludeTax, {
10037
- outSymbol: false
10038
- }))), /*#__PURE__*/React.createElement("div", {
10130
+ }, /*#__PURE__*/React.createElement("label", null, "\u4EF7\u7A0E\u5408\u8BA1\uFF08\u5927\u5199\uFF09"), /*#__PURE__*/React.createElement("label", null, toStringChinese(lineAmountIncludeTax))), /*#__PURE__*/React.createElement("div", {
10039
10131
  style: {
10040
10132
  flex: 5,
10041
10133
  border: 'none'
@@ -17334,8 +17426,6 @@ function SvgFork(props) {
17334
17426
  var css_248z$j = ".kts-invoice-operate-goods-list-statistics-digtal {\n overflow-y: scroll;\n /* 设置滚动条滑块颜色 */\n}\n.kts-invoice-operate-goods-list-statistics-digtal::-webkit-scrollbar-track {\n background-color: #f1f1f1;\n}\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total-tax,\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total {\n height: 42px;\n display: flex;\n align-items: center;\n}\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total-tax > div:first-child,\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total > div:first-child {\n width: 225px;\n color: #9F613E;\n font-family: PingFang SC;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total-tax {\n border-top: 2px solid #9F613E;\n}\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total-tax > div:first-child {\n border-right: 2px solid #9F613E;\n}\n";
17335
17427
  styleInject(css_248z$j);
17336
17428
 
17337
- var nzhcn$1 = require('nzh').cn;
17338
-
17339
17429
  var Statistics$1 = (function () {
17340
17430
  var controller = Invoice.useInvoiceController();
17341
17431
  /** 是否不含税) */
@@ -17446,9 +17536,7 @@ var Statistics$1 = (function () {
17446
17536
  fontWeight: 'bold',
17447
17537
  marginLeft: 4
17448
17538
  }
17449
- }, nzhcn$1.toMoney(lineAmountIncludeTax, {
17450
- outSymbol: false
17451
- }))), /*#__PURE__*/React.createElement("div", {
17539
+ }, toStringChinese(lineAmountIncludeTax))), /*#__PURE__*/React.createElement("div", {
17452
17540
  style: {
17453
17541
  flex: 1
17454
17542
  }
@@ -20390,18 +20478,15 @@ var MyItemNameDiv$1 = /*#__PURE__*/function (_React$Component3) {
20390
20478
  return /*#__PURE__*/React.createElement(Tooltip$1, {
20391
20479
  title: valueT
20392
20480
  }, /*#__PURE__*/React.createElement("span", {
20393
- style: {
20394
- padding: '0 10px',
20481
+ style: _objectSpread2(_objectSpread2({}, MyItemNameStyle), {}, {
20395
20482
  color: '#0074ff'
20396
- }
20483
+ })
20397
20484
  }, valueT));
20398
20485
  } else {
20399
20486
  return /*#__PURE__*/React.createElement(Tooltip$1, {
20400
20487
  title: valueF
20401
20488
  }, /*#__PURE__*/React.createElement("span", {
20402
- style: {
20403
- padding: '0 10px'
20404
- }
20489
+ style: MyItemNameStyle
20405
20490
  }, valueF));
20406
20491
  }
20407
20492
  } else {
@@ -20409,18 +20494,16 @@ var MyItemNameDiv$1 = /*#__PURE__*/function (_React$Component3) {
20409
20494
  return /*#__PURE__*/React.createElement(Tooltip$1, {
20410
20495
  title: valueF
20411
20496
  }, /*#__PURE__*/React.createElement("span", {
20412
- style: {
20413
- padding: '0 10px'
20414
- }
20497
+ style: MyItemNameStyle
20415
20498
  }, valueF));
20416
20499
  } else {
20417
20500
  return /*#__PURE__*/React.createElement(Tooltip$1, {
20418
- title: valueT
20501
+ title: valueT,
20502
+ style: MyItemNameStyle
20419
20503
  }, /*#__PURE__*/React.createElement("span", {
20420
- style: {
20421
- padding: '0 10px',
20504
+ style: _objectSpread2(_objectSpread2({}, MyItemNameStyle), {}, {
20422
20505
  color: '#0074ff'
20423
- }
20506
+ })
20424
20507
  }, valueT));
20425
20508
  }
20426
20509
  }
@@ -20462,6 +20545,15 @@ function dcoding$1(v) {
20462
20545
  }).join('');
20463
20546
  }
20464
20547
 
20548
+ var MyItemNameStyle = {
20549
+ padding: '0px 10px',
20550
+ whiteSpace: 'nowrap',
20551
+ overflow: 'hidden',
20552
+ width: "100%",
20553
+ display: 'block',
20554
+ textOverflow: 'ellipsis'
20555
+ };
20556
+
20465
20557
  var useOnRow$1 = (function () {
20466
20558
  /** 控制器 */
20467
20559
  var controller = Invoice.useInvoiceController();
@@ -23755,6 +23847,8 @@ var Invoice = /*#__PURE__*/function (_React$PureComponent) {
23755
23847
 
23756
23848
  /** 金额计算方法 */
23757
23849
 
23850
+ /** 工具方法 */
23851
+
23758
23852
  /** 获取控制器钩子 */
23759
23853
  function render() {
23760
23854
  if (this.props.invoiceType === 'digtal') {
@@ -23782,6 +23876,7 @@ Invoice.SignDigtal = SignDigtal;
23782
23876
  Invoice.GoodsListDigtal = GoodsList$1;
23783
23877
  Invoice.idGenerator = idGenerator;
23784
23878
  Invoice.calculator = calculator;
23879
+ Invoice.utils = utils;
23785
23880
 
23786
23881
  Invoice.useInvoiceController = function () {
23787
23882
  return React.useContext(InvoiceContext);
package/dist/index.js CHANGED
@@ -9557,6 +9557,102 @@ function useToGenerateId(controller) {
9557
9557
  }, [goodsList]);
9558
9558
  }
9559
9559
 
9560
+ /** 数字转中文 */
9561
+ var toStringChinese = function toStringChinese(value) {
9562
+ var numberValue = Math.round(value * 100).toString(); // 数字金额
9563
+
9564
+ var chineseValue = ''; // 转换后的汉字金额
9565
+
9566
+ var String1 = '零壹贰叁肆伍陆柒捌玖'; // 汉字数字
9567
+
9568
+ var String2 = '万仟佰拾亿仟佰拾万仟佰拾圆角分'; // 对应单位
9569
+
9570
+ var len = numberValue.length; // numberValue 的字符串长度
9571
+
9572
+ var Ch1; // 数字的汉语读法
9573
+
9574
+ var Ch2; // 数字位的汉字读法
9575
+
9576
+ var nZero = 0; // 用来计算连续的零值的个数
9577
+
9578
+ var String3; // 指定位置的数值
9579
+
9580
+ if (len > 15) {
9581
+ alert('超出计算范围');
9582
+ return '';
9583
+ }
9584
+
9585
+ if (parseFloat(numberValue) === 0) {
9586
+ chineseValue = '零圆整';
9587
+ return chineseValue;
9588
+ }
9589
+
9590
+ String2 = String2.substr(String2.length - len, len); // 取出对应位数的STRING2的值
9591
+
9592
+ for (var i = 0; i < len; i++) {
9593
+ String3 = parseInt(numberValue.substr(i, 1), 10); // 取出需转换的某一位的值
9594
+
9595
+ if (i !== len - 3 && i !== len - 7 && i !== len - 11 && i !== len - 15) {
9596
+ if (String3 === 0) {
9597
+ Ch1 = '';
9598
+ Ch2 = '';
9599
+ nZero++;
9600
+ } else if (String3 !== 0 && nZero !== 0) {
9601
+ Ch1 = '零' + String1.substr(String3, 1);
9602
+ Ch2 = String2.substr(i, 1);
9603
+ nZero = 0;
9604
+ } else {
9605
+ Ch1 = String1.substr(String3, 1);
9606
+ Ch2 = String2.substr(i, 1);
9607
+ nZero = 0;
9608
+ }
9609
+ } else {
9610
+ // 该位是万亿,亿,万,元位等关键位
9611
+ if (String3 !== 0 && nZero !== 0) {
9612
+ Ch1 = '零' + String1.substr(String3, 1);
9613
+ Ch2 = String2.substr(i, 1);
9614
+ nZero = 0;
9615
+ } else if (String3 !== 0 && nZero === 0) {
9616
+ Ch1 = String1.substr(String3, 1);
9617
+ Ch2 = String2.substr(i, 1);
9618
+ nZero = 0;
9619
+ } else if (String3 === 0 && nZero >= 3) {
9620
+ Ch1 = '';
9621
+ Ch2 = '';
9622
+ nZero++;
9623
+ } else {
9624
+ Ch1 = '';
9625
+ Ch2 = String2.substr(i, 1);
9626
+ nZero++;
9627
+ }
9628
+
9629
+ if (i === len - 11 || i === len - 3) {
9630
+ // 如果该位是亿位或元位,则必须写上
9631
+ Ch2 = String2.substr(i, 1);
9632
+ }
9633
+ }
9634
+
9635
+ chineseValue = chineseValue + Ch1 + Ch2;
9636
+ }
9637
+
9638
+ if (String3 === 0) {
9639
+ // 最后一位(分)为0时,加上“整”
9640
+ chineseValue += '整';
9641
+ }
9642
+
9643
+ return chineseValue;
9644
+ };
9645
+
9646
+ var index = /*#__PURE__*/Object.freeze({
9647
+ __proto__: null,
9648
+ toStringChinese: toStringChinese
9649
+ });
9650
+
9651
+ var utils = /*#__PURE__*/Object.freeze({
9652
+ __proto__: null,
9653
+ Money: index
9654
+ });
9655
+
9560
9656
  var _defs, _path, _path2, _path3;
9561
9657
 
9562
9658
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -9916,8 +10012,6 @@ function TableVirtual (props) {
9916
10012
  var css_248z$3 = ".kts-invoice-operate-goods-list-statistics {\n background: #fafafa;\n overflow-y: scroll;\n}\n.kts-invoice-operate-goods-list-statistics .kts-invoice-operate-goods-list-statistics-row {\n height: 30px;\n line-height: 30px;\n border-bottom: 1px solid #e8e8e8;\n display: flex;\n}\n.kts-invoice-operate-goods-list-statistics .kts-invoice-operate-goods-list-statistics-row > div {\n border-right: 1px solid #e8e8e8;\n}\n.kts-invoice-operate-goods-list-statistics .kts-invoice-operate-goods-list-statistics-row > div label {\n padding: 0 10px;\n}\n";
9917
10013
  styleInject(css_248z$3);
9918
10014
 
9919
- var nzhcn = require('nzh').cn;
9920
-
9921
10015
  var Statistics = (function () {
9922
10016
  var controller = Invoice.useInvoiceController();
9923
10017
  /** 是否不含税) */
@@ -10043,9 +10137,7 @@ var Statistics = (function () {
10043
10137
  flex: 5,
10044
10138
  border: 'none'
10045
10139
  }
10046
- }, /*#__PURE__*/React__default['default'].createElement("label", null, "\u4EF7\u7A0E\u5408\u8BA1\uFF08\u5927\u5199\uFF09"), /*#__PURE__*/React__default['default'].createElement("label", null, nzhcn.toMoney(lineAmountIncludeTax, {
10047
- outSymbol: false
10048
- }))), /*#__PURE__*/React__default['default'].createElement("div", {
10140
+ }, /*#__PURE__*/React__default['default'].createElement("label", null, "\u4EF7\u7A0E\u5408\u8BA1\uFF08\u5927\u5199\uFF09"), /*#__PURE__*/React__default['default'].createElement("label", null, toStringChinese(lineAmountIncludeTax))), /*#__PURE__*/React__default['default'].createElement("div", {
10049
10141
  style: {
10050
10142
  flex: 5,
10051
10143
  border: 'none'
@@ -17344,8 +17436,6 @@ function SvgFork(props) {
17344
17436
  var css_248z$j = ".kts-invoice-operate-goods-list-statistics-digtal {\n overflow-y: scroll;\n /* 设置滚动条滑块颜色 */\n}\n.kts-invoice-operate-goods-list-statistics-digtal::-webkit-scrollbar-track {\n background-color: #f1f1f1;\n}\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total-tax,\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total {\n height: 42px;\n display: flex;\n align-items: center;\n}\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total-tax > div:first-child,\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total > div:first-child {\n width: 225px;\n color: #9F613E;\n font-family: PingFang SC;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total-tax {\n border-top: 2px solid #9F613E;\n}\n.kts-invoice-operate-goods-list-statistics-digtal .statistics-digtal-total-tax > div:first-child {\n border-right: 2px solid #9F613E;\n}\n";
17345
17437
  styleInject(css_248z$j);
17346
17438
 
17347
- var nzhcn$1 = require('nzh').cn;
17348
-
17349
17439
  var Statistics$1 = (function () {
17350
17440
  var controller = Invoice.useInvoiceController();
17351
17441
  /** 是否不含税) */
@@ -17456,9 +17546,7 @@ var Statistics$1 = (function () {
17456
17546
  fontWeight: 'bold',
17457
17547
  marginLeft: 4
17458
17548
  }
17459
- }, nzhcn$1.toMoney(lineAmountIncludeTax, {
17460
- outSymbol: false
17461
- }))), /*#__PURE__*/React__default['default'].createElement("div", {
17549
+ }, toStringChinese(lineAmountIncludeTax))), /*#__PURE__*/React__default['default'].createElement("div", {
17462
17550
  style: {
17463
17551
  flex: 1
17464
17552
  }
@@ -20400,18 +20488,15 @@ var MyItemNameDiv$1 = /*#__PURE__*/function (_React$Component3) {
20400
20488
  return /*#__PURE__*/React__default['default'].createElement(ktsXui.Tooltip, {
20401
20489
  title: valueT
20402
20490
  }, /*#__PURE__*/React__default['default'].createElement("span", {
20403
- style: {
20404
- padding: '0 10px',
20491
+ style: _objectSpread2(_objectSpread2({}, MyItemNameStyle), {}, {
20405
20492
  color: '#0074ff'
20406
- }
20493
+ })
20407
20494
  }, valueT));
20408
20495
  } else {
20409
20496
  return /*#__PURE__*/React__default['default'].createElement(ktsXui.Tooltip, {
20410
20497
  title: valueF
20411
20498
  }, /*#__PURE__*/React__default['default'].createElement("span", {
20412
- style: {
20413
- padding: '0 10px'
20414
- }
20499
+ style: MyItemNameStyle
20415
20500
  }, valueF));
20416
20501
  }
20417
20502
  } else {
@@ -20419,18 +20504,16 @@ var MyItemNameDiv$1 = /*#__PURE__*/function (_React$Component3) {
20419
20504
  return /*#__PURE__*/React__default['default'].createElement(ktsXui.Tooltip, {
20420
20505
  title: valueF
20421
20506
  }, /*#__PURE__*/React__default['default'].createElement("span", {
20422
- style: {
20423
- padding: '0 10px'
20424
- }
20507
+ style: MyItemNameStyle
20425
20508
  }, valueF));
20426
20509
  } else {
20427
20510
  return /*#__PURE__*/React__default['default'].createElement(ktsXui.Tooltip, {
20428
- title: valueT
20511
+ title: valueT,
20512
+ style: MyItemNameStyle
20429
20513
  }, /*#__PURE__*/React__default['default'].createElement("span", {
20430
- style: {
20431
- padding: '0 10px',
20514
+ style: _objectSpread2(_objectSpread2({}, MyItemNameStyle), {}, {
20432
20515
  color: '#0074ff'
20433
- }
20516
+ })
20434
20517
  }, valueT));
20435
20518
  }
20436
20519
  }
@@ -20472,6 +20555,15 @@ function dcoding$1(v) {
20472
20555
  }).join('');
20473
20556
  }
20474
20557
 
20558
+ var MyItemNameStyle = {
20559
+ padding: '0px 10px',
20560
+ whiteSpace: 'nowrap',
20561
+ overflow: 'hidden',
20562
+ width: "100%",
20563
+ display: 'block',
20564
+ textOverflow: 'ellipsis'
20565
+ };
20566
+
20475
20567
  var useOnRow$1 = (function () {
20476
20568
  /** 控制器 */
20477
20569
  var controller = Invoice.useInvoiceController();
@@ -23765,6 +23857,8 @@ var Invoice = /*#__PURE__*/function (_React$PureComponent) {
23765
23857
 
23766
23858
  /** 金额计算方法 */
23767
23859
 
23860
+ /** 工具方法 */
23861
+
23768
23862
  /** 获取控制器钩子 */
23769
23863
  function render() {
23770
23864
  if (this.props.invoiceType === 'digtal') {
@@ -23792,6 +23886,7 @@ Invoice.SignDigtal = SignDigtal;
23792
23886
  Invoice.GoodsListDigtal = GoodsList$1;
23793
23887
  Invoice.idGenerator = idGenerator;
23794
23888
  Invoice.calculator = calculator;
23889
+ Invoice.utils = utils;
23795
23890
 
23796
23891
  Invoice.useInvoiceController = function () {
23797
23892
  return React__default['default'].useContext(InvoiceContext);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.117",
3
+ "version": "3.2.118-1",
4
4
  "scripts": {
5
5
  "dev": "dumi dev",
6
6
  "start": "dumi dev",
@@ -5,6 +5,7 @@ import InvoiceController from './InvoiceController';
5
5
  import useToGenerateId from './tools/useToGenerateId';
6
6
  import idGenerator from './tools/idGenerator';
7
7
  import * as calculator from './tools/calculate';
8
+ import * as utils from './tools/utils';
8
9
 
9
10
  import InvoiceHeader from './ui/default/InvoiceHeader';
10
11
  import GoodsList from './ui/default/GoodsList';
@@ -93,6 +94,9 @@ export default class Invoice extends React.PureComponent<IInvoiceProps> {
93
94
  /** 金额计算方法 */
94
95
  static calculator = calculator;
95
96
 
97
+ /** 工具方法 */
98
+ static utils = utils;
99
+
96
100
  /** 获取控制器钩子 */
97
101
  static useInvoiceController = () => { return React.useContext(InvoiceContext) };
98
102
 
@@ -0,0 +1 @@
1
+ export * as Money from './money';
@@ -0,0 +1,66 @@
1
+ /** 数字转中文 */
2
+ export const toStringChinese = (value: any) => {
3
+ let numberValue = Math.round(value * 100).toString(); // 数字金额
4
+ let chineseValue = ''; // 转换后的汉字金额
5
+ let String1 = '零壹贰叁肆伍陆柒捌玖'; // 汉字数字
6
+ let String2 = '万仟佰拾亿仟佰拾万仟佰拾圆角分'; // 对应单位
7
+ let len = numberValue.length; // numberValue 的字符串长度
8
+ let Ch1; // 数字的汉语读法
9
+ let Ch2; // 数字位的汉字读法
10
+ let nZero = 0; // 用来计算连续的零值的个数
11
+ let String3; // 指定位置的数值
12
+ if (len > 15) {
13
+ alert('超出计算范围');
14
+ return '';
15
+ }
16
+
17
+ if (parseFloat(numberValue) === 0) {
18
+ chineseValue = '零圆整';
19
+ return chineseValue;
20
+ }
21
+ String2 = String2.substr(String2.length - len, len); // 取出对应位数的STRING2的值
22
+ for (let i = 0; i < len; i++) {
23
+ String3 = parseInt(numberValue.substr(i, 1), 10); // 取出需转换的某一位的值
24
+ if (i !== (len - 3) && i !== (len - 7) && i !== (len - 11) && i !== (len - 15)) {
25
+ if (String3 === 0) {
26
+ Ch1 = '';
27
+ Ch2 = '';
28
+ nZero++;
29
+ } else if (String3 !== 0 && nZero !== 0) {
30
+ Ch1 = '零' + String1.substr(String3, 1);
31
+ Ch2 = String2.substr(i, 1);
32
+ nZero = 0;
33
+ } else {
34
+ Ch1 = String1.substr(String3, 1);
35
+ Ch2 = String2.substr(i, 1);
36
+ nZero = 0;
37
+ }
38
+ } else { // 该位是万亿,亿,万,元位等关键位
39
+ if (String3 !== 0 && nZero !== 0) {
40
+ Ch1 = '零' + String1.substr(String3, 1);
41
+ Ch2 = String2.substr(i, 1);
42
+ nZero = 0;
43
+ } else if (String3 !== 0 && nZero === 0) {
44
+ Ch1 = String1.substr(String3, 1);
45
+ Ch2 = String2.substr(i, 1);
46
+ nZero = 0;
47
+ } else if (String3 === 0 && nZero >= 3) {
48
+ Ch1 = '';
49
+ Ch2 = '';
50
+ nZero++;
51
+ } else {
52
+ Ch1 = '';
53
+ Ch2 = String2.substr(i, 1);
54
+ nZero++;
55
+ }
56
+ if (i === (len - 11) || i === (len - 3)) { // 如果该位是亿位或元位,则必须写上
57
+ Ch2 = String2.substr(i, 1);
58
+ }
59
+ }
60
+ chineseValue = chineseValue + Ch1 + Ch2;
61
+ }
62
+ if (String3 === 0) { // 最后一位(分)为0时,加上“整”
63
+ chineseValue += '整';
64
+ }
65
+ return chineseValue;
66
+ };
@@ -4,8 +4,8 @@ import { chain, bignumber } from 'mathjs';
4
4
  import { LineAttributeType } from '../../../../../../Invoice/InvoiceController';
5
5
  import Invoice from '../../../../..';
6
6
  import './index.less';
7
+ import { Money } from '../../../../../tools/utils';
7
8
 
8
- const nzhcn = require('nzh').cn;
9
9
 
10
10
  export default () => {
11
11
  const controller = Invoice.useInvoiceController();
@@ -101,7 +101,7 @@ export default () => {
101
101
  <div style={{ flex: 5, border: 'none' }}>
102
102
  <label>价税合计(大写)</label>
103
103
  <label>
104
- {nzhcn.toMoney(lineAmountIncludeTax, { outSymbol: false })}
104
+ {Money.toStringChinese(lineAmountIncludeTax)}
105
105
  </label>
106
106
  </div>
107
107
  <div style={{ flex: 5, border: 'none' }}>
@@ -137,17 +137,6 @@ export default (form: WrappedFormUtils) => {
137
137
  }}
138
138
  />
139
139
  )}
140
- {/* <div className="kts-invoice-operate-goods-list-able-list-itemName-import">
141
- {controller.getGoodsList && model !== 'readOnly' && (
142
- <Tooltip title="点击从商品管理中添加商品信息">
143
- <Button
144
- onClick={controller.pipeline(async s => { s.goodsListState.importGoods.isVisibleDrawer = true })}
145
- type="link"
146
- icon="plus-circle"
147
- />
148
- </Tooltip>
149
- )}
150
- </div> */}
151
140
  </div>
152
141
  </Form.Item>
153
142
  );
@@ -533,7 +522,7 @@ export default (form: WrappedFormUtils) => {
533
522
  }
534
523
  })
535
524
  // 是否启动拖拽
536
- .filter(e => e.key !=='drag' || isStart)
525
+ .filter(e => e.key !== 'drag' || isStart)
537
526
  // 只读
538
527
  .filter(e => {
539
528
  if (model === 'readOnly') {
@@ -603,13 +592,13 @@ class MyItemNameDiv extends React.Component<{ valueT?: React.ReactNode, valueF?:
603
592
  if (valueT) {
604
593
  return (
605
594
  <Tooltip title={valueT}>
606
- <span style={{ padding: '0 10px', color: '#0074ff' }}>{valueT}</span>
595
+ <span style={{ ...MyItemNameStyle, color: '#0074ff' }}>{valueT}</span>
607
596
  </Tooltip>
608
597
  )
609
598
  } else {
610
599
  return (
611
600
  <Tooltip title={valueF}>
612
- <span style={{ padding: '0 10px' }}>{valueF}</span>
601
+ <span style={MyItemNameStyle}>{valueF}</span>
613
602
  </Tooltip>
614
603
  )
615
604
  }
@@ -617,13 +606,13 @@ class MyItemNameDiv extends React.Component<{ valueT?: React.ReactNode, valueF?:
617
606
  if (valueF) {
618
607
  return (
619
608
  <Tooltip title={valueF}>
620
- <span style={{ padding: '0 10px' }}>{valueF}</span>
609
+ <span style={MyItemNameStyle}>{valueF}</span>
621
610
  </Tooltip>
622
611
  )
623
612
  } else {
624
613
  return (
625
- <Tooltip title={valueT}>
626
- <span style={{ padding: '0 10px', color: '#0074ff' }}>{valueT}</span>
614
+ <Tooltip title={valueT} style={MyItemNameStyle}>
615
+ <span style={{ ...MyItemNameStyle, color: '#0074ff' }}>{valueT}</span>
627
616
  </Tooltip>
628
617
  )
629
618
  }
@@ -648,3 +637,12 @@ function ucoding(v: string): string {
648
637
  function dcoding(v: string): string {
649
638
  return v.split('U').map(e => e ? String.fromCharCode(parseInt(e.replace('E', ''))) : '').join('');
650
639
  }
640
+
641
+ const MyItemNameStyle: any = {
642
+ padding: '0px 10px',
643
+ whiteSpace: 'nowrap',
644
+ overflow: 'hidden',
645
+ width: "100%",
646
+ display: 'block',
647
+ textOverflow: 'ellipsis'
648
+ }
@@ -4,9 +4,9 @@ import { } from 'kts-components-antd-x3';
4
4
  import { ReactComponent as ForkSvg } from './svg/fork.svg';
5
5
  import { chain, bignumber } from 'mathjs';
6
6
  import Invoice from '../../../../..';
7
+ import { Money } from '../../../../../tools/utils';
7
8
  import './index.less';
8
9
 
9
- const nzhcn = require('nzh').cn;
10
10
 
11
11
  export default () => {
12
12
  const controller = Invoice.useInvoiceController();
@@ -88,7 +88,7 @@ export default () => {
88
88
  <div>价税合计(大写)</div>
89
89
  <div style={{ paddingLeft: 30 }} >
90
90
  <Icon style={{fontSize: 16}} component={ForkSvg} />
91
- <span style={{ fontWeight: 'bold', marginLeft: 4 }} >{nzhcn.toMoney(lineAmountIncludeTax, { outSymbol: false })}</span>
91
+ <span style={{ fontWeight: 'bold', marginLeft: 4 }} >{Money.toStringChinese(lineAmountIncludeTax)}</span>
92
92
  </div>
93
93
  <div style={{ flex: 1 }} />
94
94
  <div style={{ width: 90, color: '#9F613E' }} >(小写)</div>