kts-component-invoice-operate 3.2.181-2 → 3.2.181-21

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.
Files changed (27) hide show
  1. package/dist/Invoice/InvoiceController/InvoiceControllerState/BuyerState/index.d.ts +1 -0
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.d.ts +1 -0
  3. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
  4. package/dist/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.d.ts +1 -1
  5. package/dist/index.esm.js +961 -387
  6. package/dist/index.js +952 -378
  7. package/package.json +1 -1
  8. package/src/Invoice/InvoiceController/InvoiceControllerState/BuyerState/index.tsx +7 -0
  9. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +2 -0
  10. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +2 -1
  11. package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +1 -1
  12. package/src/Invoice/InvoiceController/fns/importGoodsDrawer.ts +2 -3
  13. package/src/Invoice/tools/calculate/index.ts +1 -1
  14. package/src/Invoice/ui/default/Buyer/ui/BuyerNameInput/index.tsx +2 -2
  15. package/src/Invoice/ui/default/EndowCodeDrawer/index.tsx +1 -2
  16. package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +92 -36
  17. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +43 -14
  18. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +4 -1
  19. package/src/Invoice/ui/default/GoodsList/index.tsx +6 -6
  20. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +449 -139
  21. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +3 -3
  22. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/index.tsx +1 -1
  23. package/src/Invoice/ui/default/ImportBuyerDrawer/index.tsx +1 -1
  24. package/src/Invoice/ui/default/ImportGoodsDrawer/index.tsx +27 -14
  25. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +9 -2
  26. package/src/Invoice/ui/digtal/Sign/index.tsx +2 -2
  27. package/src/Invoice/ui/digtal/Stakeholder/index.tsx +28 -17
package/dist/index.esm.js CHANGED
@@ -2,9 +2,9 @@ import 'kts-components-antd-x3/dist/kts-components-antd-x3.css';
2
2
  import React, { createElement, createContext, useContext, useEffect, forwardRef, Children, isValidElement } from 'react';
3
3
  import GreyReactBox, { decorator } from 'grey-react-box';
4
4
  import { chain as chain$1, bignumber, format as format$1, create, all, equal } from 'mathjs';
5
- import { message, Form, Input, Icon as Icon$1, Tag as Tag$1, Select, Button, Tooltip, Switch as Switch$1, Typography, Menu, Dropdown, AutoComplete as AutoComplete$2, Spin, Checkbox, Drawer, Descriptions, Empty, Divider, Popover as Popover$1, Table as Table$1, Tree, Modal as Modal$1, Row as Row$2, Col as Col$2 } from 'kts-components-antd-x3';
5
+ import { message, Form, Input, Icon as Icon$1, Tag as Tag$1, Select, Button, Tooltip, Switch as Switch$1, Typography, Menu, Dropdown, AutoComplete as AutoComplete$2, Spin, Checkbox, Descriptions, Empty, Divider, Popover as Popover$1, Drawer as Drawer$1, Table as Table$1, Tree, Modal as Modal$1, Row as Row$2, Col as Col$2 } from 'kts-components-antd-x3';
6
6
  import { v4 } from 'uuid';
7
- import { message as message$1, TableManual, Switch, AutoComplete as AutoComplete$1, Popover, Button as Button$1, Dropdown as Dropdown$1, Row, Col, Checkbox as Checkbox$1, Tooltip as Tooltip$1, Input as Input$1, Select as Select$1, Spin as Spin$1, Menu as Menu$1, Form as Form$1, Drawer as Drawer$1, Space, Radio, InputNumber, Popconfirm, Modal, Cascader as Cascader$1, Tree as Tree$1, Card, FormReadOnly } from 'kts-xui';
7
+ import { message as message$1, TableManual, Switch, AutoComplete as AutoComplete$1, Popover, Button as Button$1, Form as Form$1, Drawer, Space, Radio, InputNumber, Dropdown as Dropdown$1, Row, Col, Input as Input$1, Checkbox as Checkbox$1, Tooltip as Tooltip$1, Select as Select$1, Spin as Spin$1, Menu as Menu$1, Popconfirm, Modal, Cascader as Cascader$1, Tree as Tree$1, Card, FormReadOnly } from 'kts-xui';
8
8
  import classnames from 'classnames';
9
9
  import { Table } from 'kts-components-antd-x4-v4';
10
10
  import { render } from 'react-dom';
@@ -1121,6 +1121,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
1121
1121
  this.isAddDiscount = void 0;
1122
1122
  this.isAddRow = true;
1123
1123
  this.isRemRow = true;
1124
+ this.isBatchRemRow = true;
1124
1125
  this.isTaxIncluded = true;
1125
1126
  this.calculateType = '3';
1126
1127
  this.isMyShow = false;
@@ -1180,6 +1181,10 @@ var BuyerState = /*#__PURE__*/_createClass(function BuyerState() {
1180
1181
  title: '公司名称',
1181
1182
  dataIndex: 'buyerName',
1182
1183
  key: 'buyerName'
1184
+ }, {
1185
+ title: '客户代码',
1186
+ dataIndex: 'customerCode',
1187
+ key: 'customerCode'
1183
1188
  }, {
1184
1189
  title: '纳税人识别号',
1185
1190
  dataIndex: 'buyerNo',
@@ -8487,12 +8492,70 @@ var clearCalculatingField = /*#__PURE__*/function () {
8487
8492
  };
8488
8493
  }();
8489
8494
  /** 数量改变了 */
8495
+ // export const onChangeQuantity = lazyFn(
8496
+ // (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
8497
+ // form.validateFields(async (err, values) => {
8498
+ // err = err || {};
8499
+ // if (!values.quantity && values.quantity !== 0) {
8500
+ // await controller.setEditGood({ quantity: undefined });
8501
+ // await clearCalculatingField(controller);
8502
+ // return;
8503
+ // }
8504
+ // if (err.quantity) {
8505
+ // await clearCalculatingField(controller);
8506
+ // return
8507
+ // };
8508
+ // const calculatingDigits = controller.state.calculatingDigits;
8509
+ // const quantity = format15(values.quantity, calculatingDigits);
8510
+ // await controller.setEditGood({ quantity });
8511
+ // form.setFieldsValue({ quantity });
8512
+ // // 是否含税
8513
+ // if (controller.state.goodsListState.isTaxIncluded) {
8514
+ // // 含税
8515
+ // if (!err.priceIncludeTax && values.priceIncludeTax) {
8516
+ // // 可以找到 单价(含税)
8517
+ // const priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
8518
+ // const lineAmountIncludeTax = format2(evaluate(`${priceIncludeTax} * ${quantity}`));
8519
+ // form.setFieldsValue({ lineAmountIncludeTax });
8520
+ // await controller.setEditGood({ lineAmountIncludeTax });
8521
+ // } else if (!err.lineAmountIncludeTax && values.lineAmountIncludeTax) {
8522
+ // // 可以找到 金额(含税)
8523
+ // const lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
8524
+ // const priceIncludeTax = format15(
8525
+ // evaluate(`${lineAmountIncludeTax} / ${quantity}`),
8526
+ // calculatingDigits);
8527
+ // form.setFieldsValue({ priceIncludeTax });
8528
+ // await controller.setEditGood({ priceIncludeTax });
8529
+ // }
8530
+ // // 更新不含税
8531
+ // await updateUnitPriceExcludingTax(controller, form, record);
8532
+ // } else {
8533
+ // // 不含税
8534
+ // if (!err.priceExcludeTax && values.priceExcludeTax) {
8535
+ // const priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
8536
+ // const lineAmountExcludeTax = format2(evaluate(`${quantity} * ${priceExcludeTax}`));
8537
+ // form.setFieldsValue({ lineAmountExcludeTax });
8538
+ // await controller.setEditGood({ lineAmountExcludeTax, quantity });
8539
+ // } else if (!err.lineAmountExcludeTax && values.lineAmountExcludeTax) {
8540
+ // const lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
8541
+ // const priceExcludeTax = format15(evaluate(`${lineAmountExcludeTax} / ${quantity}`), calculatingDigits);
8542
+ // form.setFieldsValue({ priceExcludeTax });
8543
+ // await controller.setEditGood({ priceExcludeTax, quantity });
8544
+ // }
8545
+ // // 更新含税
8546
+ // await updateUnitPriceTax(controller, form, record);
8547
+ // }
8548
+ // // 清楚 计算中启动字段
8549
+ // await clearCalculatingField(controller);
8550
+ // });
8551
+ // },
8552
+ // 1000,
8553
+ // );
8490
8554
 
8491
8555
  var onChangeQuantity = lazyFn(function (controller, form, record) {
8492
8556
  form.validateFields( /*#__PURE__*/function () {
8493
8557
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(err, values) {
8494
- var calculatingDigits, quantity, priceIncludeTax, lineAmountIncludeTax, _lineAmountIncludeTax, _priceIncludeTax, priceExcludeTax, lineAmountExcludeTax, _lineAmountExcludeTax, _priceExcludeTax;
8495
-
8558
+ var calculatingDigits, quantity, lineAmountIncludeTax, priceIncludeTax, lineAmountExcludeTax, priceExcludeTax;
8496
8559
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
8497
8560
  while (1) {
8498
8561
  switch (_context3.prev = _context3.next) {
@@ -8531,113 +8594,69 @@ var onChangeQuantity = lazyFn(function (controller, form, record) {
8531
8594
  case 11:
8532
8595
  calculatingDigits = controller.state.calculatingDigits;
8533
8596
  quantity = format15(values.quantity, calculatingDigits);
8534
- _context3.next = 16;
8597
+ _context3.next = 15;
8535
8598
  return controller.setEditGood({
8536
8599
  quantity: quantity
8537
8600
  });
8538
8601
 
8539
- case 16:
8602
+ case 15:
8540
8603
  form.setFieldsValue({
8541
8604
  quantity: quantity
8542
8605
  }); // 是否含税
8543
8606
 
8544
8607
  if (!controller.state.goodsListState.isTaxIncluded) {
8545
- _context3.next = 36;
8546
- break;
8547
- }
8548
-
8549
- if (!(!err.priceIncludeTax && values.priceIncludeTax)) {
8550
- _context3.next = 26;
8608
+ _context3.next = 27;
8551
8609
  break;
8552
8610
  }
8553
8611
 
8554
- // 可以找到 单价(含税)
8555
- priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
8556
- lineAmountIncludeTax = format2(evaluate("".concat(priceIncludeTax, " * ").concat(quantity)));
8557
- form.setFieldsValue({
8558
- lineAmountIncludeTax: lineAmountIncludeTax
8559
- });
8560
- _context3.next = 24;
8561
- return controller.setEditGood({
8562
- lineAmountIncludeTax: lineAmountIncludeTax
8563
- });
8564
-
8565
- case 24:
8566
- _context3.next = 32;
8567
- break;
8568
-
8569
- case 26:
8570
8612
  if (!(!err.lineAmountIncludeTax && values.lineAmountIncludeTax)) {
8571
- _context3.next = 32;
8613
+ _context3.next = 23;
8572
8614
  break;
8573
8615
  }
8574
8616
 
8575
- // 可以找到 金额(含税)
8576
- _lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
8577
- _priceIncludeTax = format15(evaluate("".concat(_lineAmountIncludeTax, " / ").concat(quantity)), calculatingDigits);
8617
+ lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
8618
+ priceIncludeTax = format15(evaluate("".concat(lineAmountIncludeTax, " / ").concat(quantity)), 8);
8578
8619
  form.setFieldsValue({
8579
- priceIncludeTax: _priceIncludeTax
8620
+ priceIncludeTax: priceIncludeTax
8580
8621
  });
8581
- _context3.next = 32;
8622
+ _context3.next = 23;
8582
8623
  return controller.setEditGood({
8583
- priceIncludeTax: _priceIncludeTax
8624
+ priceIncludeTax: priceIncludeTax
8584
8625
  });
8585
8626
 
8586
- case 32:
8587
- _context3.next = 34;
8627
+ case 23:
8628
+ _context3.next = 25;
8588
8629
  return updateUnitPriceExcludingTax(controller, form, record);
8589
8630
 
8590
- case 34:
8591
- _context3.next = 52;
8592
- break;
8593
-
8594
- case 36:
8595
- if (!(!err.priceExcludeTax && values.priceExcludeTax)) {
8596
- _context3.next = 44;
8597
- break;
8598
- }
8599
-
8600
- priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
8601
- lineAmountExcludeTax = format2(evaluate("".concat(quantity, " * ").concat(priceExcludeTax)));
8602
- form.setFieldsValue({
8603
- lineAmountExcludeTax: lineAmountExcludeTax
8604
- });
8605
- _context3.next = 42;
8606
- return controller.setEditGood({
8607
- lineAmountExcludeTax: lineAmountExcludeTax,
8608
- quantity: quantity
8609
- });
8610
-
8611
- case 42:
8612
- _context3.next = 50;
8631
+ case 25:
8632
+ _context3.next = 35;
8613
8633
  break;
8614
8634
 
8615
- case 44:
8635
+ case 27:
8616
8636
  if (!(!err.lineAmountExcludeTax && values.lineAmountExcludeTax)) {
8617
- _context3.next = 50;
8637
+ _context3.next = 33;
8618
8638
  break;
8619
8639
  }
8620
8640
 
8621
- _lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
8622
- _priceExcludeTax = format15(evaluate("".concat(_lineAmountExcludeTax, " / ").concat(quantity)), calculatingDigits);
8641
+ lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
8642
+ priceExcludeTax = format15(evaluate("".concat(lineAmountExcludeTax, " / ").concat(quantity)), 8);
8623
8643
  form.setFieldsValue({
8624
- priceExcludeTax: _priceExcludeTax
8644
+ priceExcludeTax: priceExcludeTax
8625
8645
  });
8626
- _context3.next = 50;
8646
+ _context3.next = 33;
8627
8647
  return controller.setEditGood({
8628
- priceExcludeTax: _priceExcludeTax,
8629
- quantity: quantity
8648
+ priceExcludeTax: priceExcludeTax
8630
8649
  });
8631
8650
 
8632
- case 50:
8633
- _context3.next = 52;
8651
+ case 33:
8652
+ _context3.next = 35;
8634
8653
  return updateUnitPriceTax(controller, form, record);
8635
8654
 
8636
- case 52:
8637
- _context3.next = 54;
8655
+ case 35:
8656
+ _context3.next = 37;
8638
8657
  return clearCalculatingField(controller);
8639
8658
 
8640
- case 54:
8659
+ case 37:
8641
8660
  case "end":
8642
8661
  return _context3.stop();
8643
8662
  }
@@ -8655,7 +8674,7 @@ var onChangeQuantity = lazyFn(function (controller, form, record) {
8655
8674
  var onChangePriceIncludeTax = lazyFn(function (controller, form, record) {
8656
8675
  form.validateFields( /*#__PURE__*/function () {
8657
8676
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(err, values) {
8658
- var calculatingDigits, priceIncludeTax, quantity, lineAmountIncludeTax, _lineAmountIncludeTax2, _quantity;
8677
+ var calculatingDigits, priceIncludeTax, quantity, lineAmountIncludeTax, _lineAmountIncludeTax, _quantity;
8659
8678
 
8660
8679
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
8661
8680
  while (1) {
@@ -8695,7 +8714,7 @@ var onChangePriceIncludeTax = lazyFn(function (controller, form, record) {
8695
8714
 
8696
8715
  case 11:
8697
8716
  calculatingDigits = controller.state.calculatingDigits;
8698
- priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
8717
+ priceIncludeTax = format15(values.priceIncludeTax, 8);
8699
8718
  _context4.next = 15;
8700
8719
  return controller.setEditGood({
8701
8720
  priceIncludeTax: priceIncludeTax
@@ -8731,8 +8750,8 @@ var onChangePriceIncludeTax = lazyFn(function (controller, form, record) {
8731
8750
  break;
8732
8751
  }
8733
8752
 
8734
- _lineAmountIncludeTax2 = format2(values.lineAmountIncludeTax);
8735
- _quantity = format15(evaluate("".concat(_lineAmountIncludeTax2, " / ").concat(priceIncludeTax)), calculatingDigits);
8753
+ _lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
8754
+ _quantity = format15(evaluate("".concat(_lineAmountIncludeTax, " / ").concat(priceIncludeTax)), calculatingDigits);
8736
8755
  form.setFieldsValue({
8737
8756
  quantity: _quantity
8738
8757
  });
@@ -8767,7 +8786,7 @@ var onChangePriceIncludeTax = lazyFn(function (controller, form, record) {
8767
8786
  var onChangePriceExcludeTax = lazyFn(function (controller, form, record) {
8768
8787
  form.validateFields( /*#__PURE__*/function () {
8769
8788
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(err, values) {
8770
- var calculatingDigits, priceExcludeTax, quantity, lineAmountExcludeTax, _lineAmountExcludeTax2, _quantity2;
8789
+ var calculatingDigits, priceExcludeTax, quantity, lineAmountExcludeTax, _lineAmountExcludeTax, _quantity2;
8771
8790
 
8772
8791
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
8773
8792
  while (1) {
@@ -8807,7 +8826,7 @@ var onChangePriceExcludeTax = lazyFn(function (controller, form, record) {
8807
8826
 
8808
8827
  case 11:
8809
8828
  calculatingDigits = controller.state.calculatingDigits;
8810
- priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
8829
+ priceExcludeTax = format15(values.priceExcludeTax, 8);
8811
8830
  _context5.next = 15;
8812
8831
  return controller.setEditGood({
8813
8832
  priceExcludeTax: priceExcludeTax
@@ -8843,8 +8862,8 @@ var onChangePriceExcludeTax = lazyFn(function (controller, form, record) {
8843
8862
  break;
8844
8863
  }
8845
8864
 
8846
- _lineAmountExcludeTax2 = format2(values.lineAmountExcludeTax);
8847
- _quantity2 = format15(evaluate("".concat(_lineAmountExcludeTax2, " / ").concat(priceExcludeTax)), calculatingDigits);
8865
+ _lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
8866
+ _quantity2 = format15(evaluate("".concat(_lineAmountExcludeTax, " / ").concat(priceExcludeTax)), calculatingDigits);
8848
8867
  form.setFieldsValue({
8849
8868
  quantity: _quantity2
8850
8869
  });
@@ -8879,7 +8898,7 @@ var onChangePriceExcludeTax = lazyFn(function (controller, form, record) {
8879
8898
  var onChangeLineAmountIncludeTax = lazyFn(function (controller, form, record) {
8880
8899
  form.validateFields( /*#__PURE__*/function () {
8881
8900
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(err, values) {
8882
- var calculatingDigits, lineAmountIncludeTax, quantity, priceIncludeTax, _priceIncludeTax2, _quantity3;
8901
+ var calculatingDigits, lineAmountIncludeTax, quantity, priceIncludeTax, _priceIncludeTax, _quantity3;
8883
8902
 
8884
8903
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
8885
8904
  while (1) {
@@ -8928,7 +8947,7 @@ var onChangeLineAmountIncludeTax = lazyFn(function (controller, form, record) {
8928
8947
  }
8929
8948
 
8930
8949
  quantity = format15(values.quantity, calculatingDigits);
8931
- priceIncludeTax = format15(evaluate("".concat(lineAmountIncludeTax, " / ").concat(quantity)), calculatingDigits);
8950
+ priceIncludeTax = format15(evaluate("".concat(lineAmountIncludeTax, " / ").concat(quantity)), 8);
8932
8951
  form.setFieldsValue({
8933
8952
  priceIncludeTax: priceIncludeTax
8934
8953
  });
@@ -8947,8 +8966,8 @@ var onChangeLineAmountIncludeTax = lazyFn(function (controller, form, record) {
8947
8966
  break;
8948
8967
  }
8949
8968
 
8950
- _priceIncludeTax2 = format15(values.priceIncludeTax, calculatingDigits);
8951
- _quantity3 = format15(evaluate("".concat(lineAmountIncludeTax, " / ").concat(_priceIncludeTax2)), calculatingDigits);
8969
+ _priceIncludeTax = format15(values.priceIncludeTax, 8);
8970
+ _quantity3 = format15(evaluate("".concat(lineAmountIncludeTax, " / ").concat(_priceIncludeTax)), calculatingDigits);
8952
8971
  form.setFieldsValue({
8953
8972
  quantity: _quantity3
8954
8973
  });
@@ -8983,7 +9002,7 @@ var onChangeLineAmountIncludeTax = lazyFn(function (controller, form, record) {
8983
9002
  var onChangeLineAmountExcludeTax = lazyFn(function (controller, form, record) {
8984
9003
  form.validateFields( /*#__PURE__*/function () {
8985
9004
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(err, values) {
8986
- var calculatingDigits, lineAmountExcludeTax, quantity, priceExcludeTax, _priceExcludeTax2, _quantity4;
9005
+ var calculatingDigits, lineAmountExcludeTax, quantity, priceExcludeTax, _priceExcludeTax, _quantity4;
8987
9006
 
8988
9007
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
8989
9008
  while (1) {
@@ -9032,7 +9051,7 @@ var onChangeLineAmountExcludeTax = lazyFn(function (controller, form, record) {
9032
9051
  }
9033
9052
 
9034
9053
  quantity = format15(values.quantity, calculatingDigits);
9035
- priceExcludeTax = format15(evaluate("".concat(lineAmountExcludeTax, " / ").concat(quantity)), calculatingDigits);
9054
+ priceExcludeTax = format15(evaluate("".concat(lineAmountExcludeTax, " / ").concat(quantity)), 8);
9036
9055
  form.setFieldsValue({
9037
9056
  priceExcludeTax: priceExcludeTax
9038
9057
  });
@@ -9051,8 +9070,8 @@ var onChangeLineAmountExcludeTax = lazyFn(function (controller, form, record) {
9051
9070
  break;
9052
9071
  }
9053
9072
 
9054
- _priceExcludeTax2 = format15(values.priceExcludeTax, calculatingDigits);
9055
- _quantity4 = format15(evaluate("".concat(lineAmountExcludeTax, " / ").concat(_priceExcludeTax2)), calculatingDigits);
9073
+ _priceExcludeTax = format15(values.priceExcludeTax, 8);
9074
+ _quantity4 = format15(evaluate("".concat(lineAmountExcludeTax, " / ").concat(_priceExcludeTax)), calculatingDigits);
9056
9075
  form.setFieldsValue({
9057
9076
  quantity: _quantity4
9058
9077
  });
@@ -9336,7 +9355,7 @@ var updateUnitPriceTax = /*#__PURE__*/function () {
9336
9355
  break;
9337
9356
  }
9338
9357
 
9339
- priceIncludeTax = format15(evaluate("".concat(lineAmountIncludeTax, " / ").concat(values.quantity)), calculatingDigits);
9358
+ priceIncludeTax = format15(evaluate("".concat(lineAmountIncludeTax, " / ").concat(values.quantity)), 8);
9340
9359
  _context11.next = 11;
9341
9360
  return controller.setEditGood({
9342
9361
  priceIncludeTax: priceIncludeTax
@@ -9774,11 +9793,11 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
9774
9793
  }
9775
9794
 
9776
9795
  var quantity = format15(sourceQuantity, calculatingDigits);
9777
- var priceIncludeTax = format15(sourcePriceIncludeTax, calculatingDigits);
9796
+ var priceIncludeTax = format15(sourcePriceIncludeTax, 8);
9778
9797
  var lineAmountIncludeTax = format2(evaluate("".concat(priceIncludeTax, " * ").concat(quantity)));
9779
9798
  var taxAmount = countTaxAmount(lineAmountIncludeTax, controller.state.goodsListState.deduction, taxRate);
9780
9799
  var lineAmountExcludeTax = countAmountExcludeTax(lineAmountIncludeTax, taxAmount);
9781
- var priceExcludeTax = countPrice(lineAmountExcludeTax, quantity, controller.state.calculatingDigits);
9800
+ var priceExcludeTax = countPrice(lineAmountExcludeTax, quantity, 8);
9782
9801
  return _objectSpread2(_objectSpread2({}, good), {}, {
9783
9802
  lineAmountExcludeTax: lineAmountExcludeTax,
9784
9803
  lineAmountIncludeTax: lineAmountIncludeTax,
@@ -9798,21 +9817,21 @@ var onChangeSwitchTax = /*#__PURE__*/function () {
9798
9817
 
9799
9818
  var _quantity5 = format15(sourceQuantity, calculatingDigits);
9800
9819
 
9801
- var _priceExcludeTax3 = format15(sourcePriceExcludeTax, calculatingDigits);
9820
+ var _priceExcludeTax2 = format15(sourcePriceExcludeTax, 8);
9802
9821
 
9803
- var _lineAmountExcludeTax3 = format2(evaluate("".concat(_priceExcludeTax3, " * ").concat(_quantity5)));
9822
+ var _lineAmountExcludeTax2 = format2(evaluate("".concat(_priceExcludeTax2, " * ").concat(_quantity5)));
9804
9823
 
9805
- var _lineAmountIncludeTax3 = format2(evaluate("".concat(_lineAmountExcludeTax3, " * (1+(").concat(taxRate, "/100))")));
9824
+ var _lineAmountIncludeTax2 = format2(evaluate("".concat(_lineAmountExcludeTax2, " * (1+(").concat(taxRate, "/100))")));
9806
9825
 
9807
- var _priceIncludeTax3 = format15(evaluate("".concat(_lineAmountIncludeTax3, " / ").concat(_quantity5)), calculatingDigits);
9826
+ var _priceIncludeTax2 = format15(evaluate("".concat(_lineAmountIncludeTax2, " / ").concat(_quantity5)), 8);
9808
9827
 
9809
- var _taxAmount = evaluate("".concat(_lineAmountIncludeTax3, " - ").concat(_lineAmountExcludeTax3));
9828
+ var _taxAmount = evaluate("".concat(_lineAmountIncludeTax2, " - ").concat(_lineAmountExcludeTax2));
9810
9829
 
9811
9830
  return _objectSpread2(_objectSpread2({}, good), {}, {
9812
- lineAmountExcludeTax: _lineAmountExcludeTax3,
9813
- lineAmountIncludeTax: _lineAmountIncludeTax3,
9831
+ lineAmountExcludeTax: _lineAmountExcludeTax2,
9832
+ lineAmountIncludeTax: _lineAmountIncludeTax2,
9814
9833
  taxAmount: _taxAmount,
9815
- priceIncludeTax: _priceIncludeTax3
9834
+ priceIncludeTax: _priceIncludeTax2
9816
9835
  });
9817
9836
  }
9818
9837
  });
@@ -11100,6 +11119,8 @@ function SvgSpot(props) {
11100
11119
  }
11101
11120
 
11102
11121
  var useDelItem = (function (goods) {
11122
+ var _goods$referenceLines;
11123
+
11103
11124
  var controller = Invoice.useInvoiceController();
11104
11125
  var model = controller.useMemo(function (s) {
11105
11126
  return s.model;
@@ -11111,6 +11132,10 @@ var useDelItem = (function (goods) {
11111
11132
  controller.delGood(goods.$index);
11112
11133
  }, [controller, goods.$index]);
11113
11134
 
11135
+ if (goods.lineAttribute === LineAttributeType$1.正常 && (goods === null || goods === void 0 ? void 0 : goods.referenceLines) && (goods === null || goods === void 0 ? void 0 : (_goods$referenceLines = goods.referenceLines) === null || _goods$referenceLines === void 0 ? void 0 : _goods$referenceLines.length) > 0) {
11136
+ return undefined;
11137
+ }
11138
+
11114
11139
  if (goods.lineAttribute === LineAttributeType$1.被折扣行) {
11115
11140
  return undefined;
11116
11141
  }
@@ -13995,15 +14020,17 @@ var useColumns = (function (form) {
13995
14020
  render: function render(value, record) {
13996
14021
  if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13997
14022
  return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('priceIncludeTax', {
13998
- initialValue: nonScientificNotation(editGood.priceIncludeTax),
14023
+ initialValue: nonScientificNotation(editGood.priceIncludeTax, 8),
13999
14024
  getValueFromEvent: onNumberValueChange,
14000
- rules: [].concat(_toConsumableArray(getReplenishRules('priceIncludeTax')), [{
14001
- pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/,
14002
- message: '单价必须为数字'
14025
+ rules: [].concat(_toConsumableArray(getReplenishRules('priceIncludeTax')), [// { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '单价必须为数字' },
14026
+ // { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '金额必须为数字' },
14027
+ {
14028
+ pattern: /^[+-]?(0|([1-9]\d*))(\.\d{1,8})?$/,
14029
+ message: '单价必须为数字且最多保留8位小数'
14003
14030
  }, {
14004
14031
  validator: function () {
14005
14032
  var _validator3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_, value, callback) {
14006
- var isQuantity, isvalue;
14033
+ var quantity, isQuantityValid, isValueValid;
14007
14034
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
14008
14035
  while (1) {
14009
14036
  switch (_context9.prev = _context9.next) {
@@ -14012,20 +14039,39 @@ var useColumns = (function (form) {
14012
14039
  return controller.wait();
14013
14040
 
14014
14041
  case 2:
14015
- isQuantity = !!getFieldValue('quantity') || getFieldValue('quantity') === 0;
14016
- isvalue = !!value || value === 0;
14017
-
14018
- if (!(isvalue || isQuantity === isvalue)) {
14019
- _context9.next = 6;
14042
+ // const isQuantity = !!getFieldValue('quantity') || getFieldValue('quantity') === 0;
14043
+ // const isvalue = !!value || value === 0;
14044
+ // if (isvalue || isQuantity === isvalue) return;
14045
+ // callback('请输入单价');
14046
+ quantity = getFieldValue('quantity');
14047
+ isQuantityValid = quantity !== undefined && quantity !== null && quantity !== '';
14048
+ isValueValid = value !== undefined && value !== null && value !== ''; // if (isValueValid && isQuantityValid) return;
14049
+ // 允许两者都为空
14050
+
14051
+ if (!(!isValueValid && !isQuantityValid)) {
14052
+ _context9.next = 7;
14020
14053
  break;
14021
14054
  }
14022
14055
 
14023
14056
  return _context9.abrupt("return");
14024
14057
 
14025
- case 6:
14026
- callback('请输入单价');
14027
-
14028
14058
  case 7:
14059
+ if (isValueValid) {
14060
+ _context9.next = 9;
14061
+ break;
14062
+ }
14063
+
14064
+ return _context9.abrupt("return", callback('金额不能为空'));
14065
+
14066
+ case 9:
14067
+ if (isQuantityValid) {
14068
+ _context9.next = 11;
14069
+ break;
14070
+ }
14071
+
14072
+ return _context9.abrupt("return", callback('数量不能为空'));
14073
+
14074
+ case 11:
14029
14075
  case "end":
14030
14076
  return _context9.stop();
14031
14077
  }
@@ -14056,7 +14102,7 @@ var useColumns = (function (form) {
14056
14102
  style: {
14057
14103
  padding: '0 10px'
14058
14104
  }
14059
- }, nonScientificNotation(value));
14105
+ }, nonScientificNotation(value, 8));
14060
14106
  }
14061
14107
  }
14062
14108
  }, {
@@ -14070,15 +14116,16 @@ var useColumns = (function (form) {
14070
14116
  render: function render(value, record) {
14071
14117
  if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
14072
14118
  return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('priceExcludeTax', {
14073
- initialValue: nonScientificNotation(editGood.priceExcludeTax),
14119
+ initialValue: nonScientificNotation(editGood.priceExcludeTax, 8),
14074
14120
  getValueFromEvent: onNumberValueChange,
14075
- rules: [].concat(_toConsumableArray(getReplenishRules('priceExcludeTax')), [{
14076
- pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/,
14077
- message: '单价必须为数字'
14121
+ rules: [].concat(_toConsumableArray(getReplenishRules('priceExcludeTax')), [// { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '单价必须为数字' },
14122
+ {
14123
+ pattern: /^[+-]?(0|([1-9]\d*))(\.\d{1,8})?$/,
14124
+ message: '单价必须为数字且最多保留8位小数'
14078
14125
  }, {
14079
14126
  validator: function () {
14080
14127
  var _validator4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_, value, callback) {
14081
- var isQuantity, isvalue;
14128
+ var quantity, isQuantityValid, isValueValid;
14082
14129
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
14083
14130
  while (1) {
14084
14131
  switch (_context10.prev = _context10.next) {
@@ -14087,20 +14134,39 @@ var useColumns = (function (form) {
14087
14134
  return controller.wait();
14088
14135
 
14089
14136
  case 2:
14090
- isQuantity = !!getFieldValue('quantity') || getFieldValue('quantity') === 0;
14091
- isvalue = !!value || value === 0;
14092
-
14093
- if (!(isvalue || isQuantity === isvalue)) {
14094
- _context10.next = 6;
14137
+ // const isQuantity = !!getFieldValue('quantity') || getFieldValue('quantity') === 0;
14138
+ // const isvalue = !!value || value === 0;
14139
+ // if (isvalue || isQuantity === isvalue) return;
14140
+ // callback('请输入单价');
14141
+ quantity = getFieldValue('quantity');
14142
+ isQuantityValid = quantity !== undefined && quantity !== null && quantity !== '';
14143
+ isValueValid = value !== undefined && value !== null && value !== ''; // if (isValueValid && isQuantityValid) return;
14144
+ // 允许两者都为空
14145
+
14146
+ if (!(!isValueValid && !isQuantityValid)) {
14147
+ _context10.next = 7;
14095
14148
  break;
14096
14149
  }
14097
14150
 
14098
14151
  return _context10.abrupt("return");
14099
14152
 
14100
- case 6:
14101
- callback('请输入单价');
14102
-
14103
14153
  case 7:
14154
+ if (isValueValid) {
14155
+ _context10.next = 9;
14156
+ break;
14157
+ }
14158
+
14159
+ return _context10.abrupt("return", callback('金额不能为空'));
14160
+
14161
+ case 9:
14162
+ if (isQuantityValid) {
14163
+ _context10.next = 11;
14164
+ break;
14165
+ }
14166
+
14167
+ return _context10.abrupt("return", callback('数量不能为空'));
14168
+
14169
+ case 11:
14104
14170
  case "end":
14105
14171
  return _context10.stop();
14106
14172
  }
@@ -14131,7 +14197,7 @@ var useColumns = (function (form) {
14131
14197
  style: {
14132
14198
  padding: '0 10px'
14133
14199
  }
14134
- }, nonScientificNotation(value));
14200
+ }, nonScientificNotation(value, 8));
14135
14201
  }
14136
14202
  }
14137
14203
  }, {
@@ -15308,6 +15374,9 @@ var useDelRowButton = (function () {
15308
15374
  var isRemRow = controller.useMemo(function (s) {
15309
15375
  return s.goodsListState.isRemRow;
15310
15376
  }, []);
15377
+ var isBatchRemRow = controller.useMemo(function (s) {
15378
+ return s.goodsListState.isBatchRemRow;
15379
+ }, []);
15311
15380
  /** 是否禁用 */
15312
15381
 
15313
15382
  var disabled = controller.useMemo(function (s) {
@@ -15364,6 +15433,7 @@ var useDelRowButton = (function () {
15364
15433
  }, " \u5220\u9664\u884C ");
15365
15434
  }, [model, onClick, disabled]);
15366
15435
  var button = React.useMemo(function () {
15436
+ if (isBatchRemRow === false) return /*#__PURE__*/React.createElement(React.Fragment, null);
15367
15437
  if (isRemRow === false) return /*#__PURE__*/React.createElement(React.Fragment, null);
15368
15438
  if (model === 'prefab') return /*#__PURE__*/React.createElement(React.Fragment, null);
15369
15439
  if (model === 'readOnly') return /*#__PURE__*/React.createElement(React.Fragment, null);
@@ -15371,39 +15441,13 @@ var useDelRowButton = (function () {
15371
15441
  onClick: onClick,
15372
15442
  disabled: disabled
15373
15443
  }, "\u6279\u91CF\u5220\u9664");
15374
- }, [model, onClick, disabled, isRemRow]);
15444
+ }, [model, onClick, disabled, isRemRow, isBatchRemRow]);
15375
15445
  return {
15376
15446
  button: button,
15377
15447
  menuItem: menuItem
15378
15448
  };
15379
15449
  });
15380
15450
 
15381
- /** 延迟函数 */
15382
- var lazyFn$1 = (function (fn) {
15383
- var delayed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
15384
- // let timer: any = 0;
15385
- // return (...par: any[]) => {
15386
- // if (timer === 0) {
15387
- // timer = setTimeout(() => {
15388
- // fn.apply(null, par);
15389
- // timer = 0;
15390
- // }, delayed);
15391
- // }
15392
- // }
15393
- var timer;
15394
- return function () {
15395
- for (var _len = arguments.length, par = new Array(_len), _key = 0; _key < _len; _key++) {
15396
- par[_key] = arguments[_key];
15397
- }
15398
-
15399
- if (timer) return;
15400
- timer = setTimeout(function () {
15401
- timer = undefined;
15402
- fn.apply(null, par);
15403
- }, delayed);
15404
- };
15405
- });
15406
-
15407
15451
  var css_248z$b = ".kts-invoice-operate-goods-list-add-discount-row .ktsAnt3x-drawer-wrapper-body {\n display: flex;\n flex-direction: column;\n}\n.kts-invoice-operate-goods-list-add-discount-row .ktsAnt3x-drawer-wrapper-body .ktsAnt3x-drawer-body {\n flex: 1;\n display: flex;\n flex-direction: column;\n}\n.kts-invoice-operate-goods-list-add-discount-row .ktsAnt3x-drawer-wrapper-body .ktsAnt3x-drawer-body .add-discount-row-body {\n flex: 1;\n overflow: auto;\n}\n.kts-invoice-operate-goods-list-add-discount-row .ktsAnt3x-drawer-wrapper-body .ktsAnt3x-drawer-body .add-discount-row-footer {\n flex: none;\n}\n";
15408
15452
  styleInject(css_248z$b);
15409
15453
 
@@ -15427,10 +15471,8 @@ var useAddDiscountRowButton = (function () {
15427
15471
  return s.goodsListState.isAddDiscount;
15428
15472
  }, []);
15429
15473
  /** 是否开启抽屉 */
15474
+ // const visible = controller.useMemo(s => s.goodsListState.discountGoodIndex.length > 0, []);
15430
15475
 
15431
- var visible = controller.useMemo(function (s) {
15432
- return s.goodsListState.discountGoodIndex.length > 0;
15433
- }, []);
15434
15476
  /** 是否禁用 按钮 */
15435
15477
 
15436
15478
  var disabled = controller.useMemo(function (s) {
@@ -15567,221 +15609,692 @@ var useAddDiscountRowButton = (function () {
15567
15609
  onClick: onClick,
15568
15610
  disabled: disabled
15569
15611
  }, "\u6DFB\u52A0\u6298\u6263\u884C") : undefined;
15570
- }, [isAddDiscount, disabled, onClick]);
15571
- var drawer = React.useMemo(function () {
15572
- return /*#__PURE__*/React.createElement(Drawer, {
15573
- className: "kts-invoice-operate-goods-list-add-discount-row",
15574
- width: 540,
15575
- title: "\u6DFB\u52A0\u6298\u6263\u884C",
15576
- placement: "right",
15577
- destroyOnClose: true,
15578
- onClose: onClose,
15579
- visible: visible
15580
- }, /*#__PURE__*/React.createElement(DrawerBody, null));
15581
- }, [visible, onClose]);
15582
- return {
15583
- menuItem: menuItem,
15584
- drawer: drawer
15585
- };
15586
- });
15587
- var DrawerBody = decorator(Form.create())(function (props) {
15588
- var form = props.form;
15589
- var getFieldDecorator = form.getFieldDecorator;
15590
- var controller = Invoice.useInvoiceController();
15591
- /** 选中的货物索引列表 */
15612
+ }, [isAddDiscount, disabled, onClick]); // const drawer = React.useMemo(() => {
15613
+ // return (
15614
+ // <Drawer
15615
+ // className="kts-invoice-operate-goods-list-add-discount-row"
15616
+ // width={540}
15617
+ // title="添加折扣行"
15618
+ // placement="right"
15619
+ // destroyOnClose={true}
15620
+ // onClose={onClose}
15621
+ // visible={visible}
15622
+ // >
15623
+ // <DrawerBody />
15624
+ // </Drawer>
15625
+ // )
15626
+ // }, [visible, onClose])
15627
+ // 添加折扣(批量)
15592
15628
 
15593
- var discountGoodIndex = controller.useMemo(function (s) {
15594
- return s.goodsListState.discountGoodIndex;
15595
- }, []);
15596
- /** 金额合计 */
15629
+ /** 是否启用 */
15597
15630
 
15598
- var lineAmountSum = controller.useMemo(function (s) {
15599
- var sum = chain(0);
15631
+ var isEnable = React.useMemo(function () {
15632
+ if (model === 'readOnly') return false;
15633
+ if (model === 'prefab') return false;
15634
+ return !(isAddDiscount === false);
15635
+ }, [isAddDiscount, model]);
15636
+ /** 准备添加折扣的货物索引列表 */
15600
15637
 
15601
- if (s.goodsListState.isTaxIncluded) {
15602
- s.goodsListState.discountGoodIndex.forEach(function (e) {
15603
- var goods = s.goodsListState.goodsMap.get(e);
15604
- sum = sum.add((goods === null || goods === void 0 ? void 0 : goods.lineAmountIncludeTax) || 0);
15605
- });
15606
- } else {
15607
- s.goodsListState.discountGoodIndex.forEach(function (e) {
15608
- var goods = s.goodsListState.goodsMap.get(e);
15609
- sum = sum.add((goods === null || goods === void 0 ? void 0 : goods.lineAmountExcludeTax) || 0);
15610
- });
15611
- }
15638
+ var discountGoodIndex = controller.useMemo(function (s) {
15639
+ return s.goodsListState.discountGoodIndex || [];
15640
+ }, []); // 抽屉开启状态
15612
15641
 
15613
- return sum.done();
15614
- }, []);
15615
- /** 关闭抽屉 */
15642
+ var open = React.useMemo(function () {
15643
+ return discountGoodIndex.length > 0;
15644
+ }, [discountGoodIndex]);
15645
+ /** 打开抽屉 */
15616
15646
 
15617
- var onClose = React.useCallback(function () {
15618
- controller.pipeline( /*#__PURE__*/function () {
15619
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(s) {
15620
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
15621
- while (1) {
15622
- switch (_context4.prev = _context4.next) {
15623
- case 0:
15624
- s.goodsListState.discountGoodIndex = [];
15647
+ var onOpen = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
15648
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
15649
+ while (1) {
15650
+ switch (_context5.prev = _context5.next) {
15651
+ case 0:
15652
+ _context5.next = 2;
15653
+ return controller.saveEditGood();
15625
15654
 
15626
- case 1:
15627
- case "end":
15628
- return _context4.stop();
15629
- }
15630
- }
15631
- }, _callee4);
15632
- }));
15655
+ case 2:
15656
+ _context5.next = 4;
15657
+ return controller.wait();
15633
15658
 
15634
- return function (_x3) {
15635
- return _ref4.apply(this, arguments);
15636
- };
15637
- }())();
15638
- }, []);
15639
- /** 点击了保存 */
15640
-
15641
- var onClickSave = React.useCallback(function () {
15642
- form.validateFields(function (err, values) {
15643
- if (err) return;
15644
- var discolineAmountunt = parseFloat(parseFloat(values.discolineAmountunt).toFixed(2));
15645
- var discount = parseFloat(parseFloat(values.discount).toFixed(4));
15646
- var indexList = discountGoodIndex;
15647
- controller.pipeline( /*#__PURE__*/function () {
15648
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(s) {
15649
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
15650
- while (1) {
15651
- switch (_context5.prev = _context5.next) {
15652
- case 0:
15653
- s.goodsListState.discountGoodIndex = [];
15659
+ case 4:
15660
+ _context5.next = 6;
15661
+ return controller.run( /*#__PURE__*/function () {
15662
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(s) {
15663
+ var isOk;
15664
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
15665
+ while (1) {
15666
+ switch (_context4.prev = _context4.next) {
15667
+ case 0:
15668
+ // 不能给编辑状态的行增加折扣!
15669
+ isOk = s.goodsListState.editGood && s.goodsListState.selectedGoodIndex.indexOf(s.goodsListState.editGood.$index) >= 0;
15654
15670
 
15655
- case 1:
15656
- case "end":
15657
- return _context5.stop();
15658
- }
15659
- }
15660
- }, _callee5);
15661
- }));
15671
+ if (!isOk) {
15672
+ _context4.next = 4;
15673
+ break;
15674
+ }
15662
15675
 
15663
- return function (_x4) {
15664
- return _ref5.apply(this, arguments);
15665
- };
15666
- }())();
15667
- controller.addGoodDiscount({
15668
- indexList: indexList,
15669
- discount: discount,
15670
- discolineAmountunt: discolineAmountunt
15671
- });
15676
+ message.error({
15677
+ content: '不能给编辑状态的行增加折扣!',
15678
+ key: '不能给编辑状态的行增加折扣!'
15679
+ });
15680
+ return _context4.abrupt("return");
15681
+
15682
+ case 4:
15683
+ if (isContinuityNum(s.goodsListState.selectedGoodIndex.map(function (e) {
15684
+ var _s$goodsListState$goo;
15685
+
15686
+ return ((_s$goodsListState$goo = s.goodsListState.goodsMap.get(e)) === null || _s$goodsListState$goo === void 0 ? void 0 : _s$goodsListState$goo.serialNo) || -2;
15687
+ }).sort(function (a, b) {
15688
+ return a - b;
15689
+ }))) {
15690
+ _context4.next = 7;
15691
+ break;
15692
+ }
15693
+
15694
+ message.error({
15695
+ content: '项目不连续,不允许添加折扣',
15696
+ key: '项目不连续,不允许添加折扣'
15697
+ });
15698
+ return _context4.abrupt("return");
15699
+
15700
+ case 7:
15701
+ // 不允许重复添加折扣
15702
+ isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
15703
+ var _s$goodsListState$goo2;
15704
+
15705
+ return ((_s$goodsListState$goo2 = s.goodsListState.goodsMap.get($index)) === null || _s$goodsListState$goo2 === void 0 ? void 0 : _s$goodsListState$goo2.lineAttribute) !== LineAttributeType$1.正常;
15706
+ });
15707
+
15708
+ if (!isOk) {
15709
+ _context4.next = 11;
15710
+ break;
15711
+ }
15712
+
15713
+ message.error({
15714
+ content: '不允许重复添加折扣',
15715
+ key: '不允许重复添加折扣'
15716
+ });
15717
+ return _context4.abrupt("return");
15718
+
15719
+ case 11:
15720
+ if (!(areAllValuesEqual(s.goodsListState.selectedGoodIndex.map(function (e) {
15721
+ var _s$goodsListState$goo3;
15722
+
15723
+ return (_s$goodsListState$goo3 = s.goodsListState.goodsMap.get(e)) === null || _s$goodsListState$goo3 === void 0 ? void 0 : _s$goodsListState$goo3.taxRate;
15724
+ })) === false)) {
15725
+ _context4.next = 14;
15726
+ break;
15727
+ }
15728
+
15729
+ message.error({
15730
+ content: '存在不同税率,不允许同时添加折扣',
15731
+ key: '存在不同税率,不允许同时添加折扣'
15732
+ });
15733
+ return _context4.abrupt("return");
15734
+
15735
+ case 14:
15736
+ // 添加折扣时项目金额不能为空或零
15737
+ isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
15738
+ var good = s.goodsListState.goodsMap.get($index);
15739
+ return "".concat(good === null || good === void 0 ? void 0 : good.lineAmountIncludeTax) === '0';
15740
+ });
15741
+
15742
+ if (!isOk) {
15743
+ _context4.next = 18;
15744
+ break;
15745
+ }
15746
+
15747
+ message.error({
15748
+ content: '添加折扣时项目金额不能为空或零',
15749
+ key: '添加折扣时项目金额不能为空或零'
15750
+ });
15751
+ return _context4.abrupt("return");
15752
+
15753
+ case 18:
15754
+ // 零税率需要设置免税类型,请在赋码中设置!
15755
+ isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
15756
+ var good = s.goodsListState.goodsMap.get($index);
15757
+ return !good || good.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !good.taxFreeType;
15758
+ });
15759
+
15760
+ if (!isOk) {
15761
+ _context4.next = 22;
15762
+ break;
15763
+ }
15764
+
15765
+ message.error({
15766
+ content: '零税率需要设置免税类型,请在赋码中设置!',
15767
+ key: '零税率需要设置免税类型,请在赋码中设置!'
15768
+ });
15769
+ return _context4.abrupt("return");
15770
+
15771
+ case 22:
15772
+ s.goodsListState.discountGoodIndex = s.goodsListState.selectedGoodIndex.slice();
15773
+
15774
+ case 23:
15775
+ case "end":
15776
+ return _context4.stop();
15777
+ }
15778
+ }
15779
+ }, _callee4);
15780
+ }));
15781
+
15782
+ return function (_x3) {
15783
+ return _ref5.apply(this, arguments);
15784
+ };
15785
+ }());
15786
+
15787
+ case 6:
15788
+ case "end":
15789
+ return _context5.stop();
15790
+ }
15791
+ }
15792
+ }, _callee5);
15793
+ })), [controller]);
15794
+ var button = React.useMemo(function () {
15795
+ if (isEnable) {
15796
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
15797
+ size: 'small',
15798
+ onClick: onOpen,
15799
+ disabled: disabled
15800
+ }, "\u6DFB\u52A0\u6298\u6263"), /*#__PURE__*/React.createElement(AddDiscountRowDrawer, {
15801
+ open: open,
15802
+ onClose: onClose
15803
+ }));
15804
+ } else {
15805
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
15806
+ }
15807
+ }, [open, onOpen, onClose, isEnable, disabled]);
15808
+ return {
15809
+ menuItem: menuItem,
15810
+ button: button
15811
+ };
15812
+ }); // 批量折扣弹窗
15813
+
15814
+ /** 添加折扣行的抽屉 */
15815
+
15816
+ function AddDiscountRowDrawer(props) {
15817
+ var open = props.open,
15818
+ onClose = props.onClose;
15819
+
15820
+ var _Form1$useForm = Form$1.useForm(),
15821
+ _Form1$useForm2 = _slicedToArray(_Form1$useForm, 1),
15822
+ form = _Form1$useForm2[0];
15823
+
15824
+ var _React$useState = React.useState(),
15825
+ _React$useState2 = _slicedToArray(_React$useState, 2),
15826
+ formValues = _React$useState2[0],
15827
+ setFormValues = _React$useState2[1];
15828
+ /** 控制器 */
15829
+
15830
+
15831
+ var controller = Invoice.useInvoiceController();
15832
+ /** 货物字典 */
15833
+
15834
+ var goodsMap = controller.useMemo(function (s) {
15835
+ return s.goodsListState.goodsMap;
15836
+ }, []);
15837
+ /** 准备添加折扣的货物索引列表 */
15838
+
15839
+ var discountGoodIndex = controller.useMemo(function (s) {
15840
+ return s.goodsListState.discountGoodIndex || [];
15841
+ }, []);
15842
+ /** 准备添加折扣的货物列表 */
15843
+
15844
+ var discountGood = React.useMemo(function () {
15845
+ return discountGoodIndex.map(function (e) {
15846
+ return goodsMap.get(e);
15672
15847
  });
15673
- }, [controller, form, discountGoodIndex]);
15674
- /** 折扣率变化 */
15848
+ }, [discountGoodIndex, goodsMap]);
15849
+ /** 总金额 */
15675
15850
 
15676
- var onChangeDiscount = React.useCallback(lazyFn$1(function (e) {
15677
- form.validateFields(function (err, values) {
15678
- if (err && err.discount) return;
15679
- var discolineAmountunt = evaluate("".concat(lineAmountSum, " * (").concat(values.discount, "/100)")).toFixed(2);
15680
- form.setFieldsValue({
15681
- discolineAmountunt: discolineAmountunt
15682
- });
15851
+ var totalAmount = React.useMemo(function () {
15852
+ var sum = 0;
15853
+ discountGood.forEach(function (e) {
15854
+ var _e$lineAmountIncludeT;
15855
+
15856
+ sum += (_e$lineAmountIncludeT = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT !== void 0 ? _e$lineAmountIncludeT : 0;
15683
15857
  });
15684
- }, 300), [form, lineAmountSum]);
15685
- /** 折扣变化 */
15686
-
15687
- var onChangeDiscolineAmountunt = React.useCallback(lazyFn$1(function (e) {
15688
- form.validateFields(function (err, values) {
15689
- if (err && err.discolineAmountunt) return;
15690
- var discolineAmountunt = parseFloat(values.discolineAmountunt).toFixed(2);
15691
- var discount = evaluate("(".concat(discolineAmountunt, " / ").concat(lineAmountSum, ") * 100")).toFixed(4);
15858
+ return sum;
15859
+ }, [discountGood]);
15860
+ /** 表单变化 */
15861
+
15862
+ var onChangeForm = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
15863
+ var values;
15864
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
15865
+ while (1) {
15866
+ switch (_context6.prev = _context6.next) {
15867
+ case 0:
15868
+ _context6.next = 2;
15869
+ return form.getFieldsValue();
15870
+
15871
+ case 2:
15872
+ values = _context6.sent;
15873
+ setFormValues(values);
15874
+
15875
+ case 4:
15876
+ case "end":
15877
+ return _context6.stop();
15878
+ }
15879
+ }
15880
+ }, _callee6);
15881
+ })), [form]);
15882
+ /** 点击了确认 */
15883
+
15884
+ var onDefine = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
15885
+ var values, totalDiscoline, discolinesSum, discolines, surplus, i;
15886
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
15887
+ while (1) {
15888
+ switch (_context8.prev = _context8.next) {
15889
+ case 0:
15890
+ _context8.next = 2;
15891
+ return form.validateFields();
15892
+
15893
+ case 2:
15894
+ values = _context8.sent;
15895
+ // 折扣总金额
15896
+ totalDiscoline = values.discolineType === '1' ? chain(bignumber(values.discolineValue)) : chain(bignumber(totalAmount)).multiply(bignumber(values.discolineValue)).multiply(bignumber(0.01));
15897
+ discolinesSum = chain(bignumber(0)); // 每行的折扣金额
15898
+
15899
+ discolines = discountGood.map(function (e, i) {
15900
+ var _e$lineAmountIncludeT2;
15901
+
15902
+ // 折扣金额占比
15903
+ var share = chain(bignumber((_e$lineAmountIncludeT2 = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT2 !== void 0 ? _e$lineAmountIncludeT2 : 0)).divide(bignumber(totalAmount)); // 折扣金额
15904
+
15905
+ var value = totalDiscoline.multiply(share.done()).multiply(bignumber(100)).round().divide(bignumber(100)).done();
15906
+ discolinesSum = discolinesSum.add(value);
15907
+ return value.toNumber();
15908
+ }); // 剩余折扣金额
15909
+
15910
+ surplus = totalDiscoline.subtract(discolinesSum.done()); // 补充剩余折扣金
15911
+
15912
+ i = 0;
15913
+
15914
+ case 8:
15915
+ if (!(i < discolines.length)) {
15916
+ _context8.next = 16;
15917
+ break;
15918
+ }
15919
+
15920
+ if (!surplus.smaller(0.01).done()) {
15921
+ _context8.next = 11;
15922
+ break;
15923
+ }
15924
+
15925
+ return _context8.abrupt("break", 16);
15926
+
15927
+ case 11:
15928
+ discolines[i] = chain(bignumber(discolines[i])).add(bignumber(0.01)).done().toNumber();
15929
+ surplus = surplus.subtract(bignumber(0.01));
15930
+
15931
+ case 13:
15932
+ i++;
15933
+ _context8.next = 8;
15934
+ break;
15935
+
15936
+ case 16:
15937
+ _context8.next = 18;
15938
+ return controller.addGoodDiscountV2(discolines.map(function (e, i) {
15939
+ var _discountGood$i;
15940
+
15941
+ return {
15942
+ $index: (_discountGood$i = discountGood[i]) === null || _discountGood$i === void 0 ? void 0 : _discountGood$i.$index,
15943
+ discolineAmountunt: e
15944
+ };
15945
+ }));
15946
+
15947
+ case 18:
15948
+ _context8.next = 20;
15949
+ return controller.run( /*#__PURE__*/function () {
15950
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(s) {
15951
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
15952
+ while (1) {
15953
+ switch (_context7.prev = _context7.next) {
15954
+ case 0:
15955
+ s.goodsListState.selectedGoodIndex = [];
15956
+
15957
+ case 1:
15958
+ case "end":
15959
+ return _context7.stop();
15960
+ }
15961
+ }
15962
+ }, _callee7);
15963
+ }));
15964
+
15965
+ return function (_x4) {
15966
+ return _ref8.apply(this, arguments);
15967
+ };
15968
+ }());
15969
+
15970
+ case 20:
15971
+ // 关闭抽屉
15972
+ onClose();
15973
+
15974
+ case 21:
15975
+ case "end":
15976
+ return _context8.stop();
15977
+ }
15978
+ }
15979
+ }, _callee8);
15980
+ })), [discountGood, form, totalAmount, onClose, controller]); // 打开抽屉时 重置form
15981
+
15982
+ React.useEffect(function () {
15983
+ if (open) {
15984
+ form.resetFields();
15692
15985
  form.setFieldsValue({
15693
- discount: discount
15986
+ discolineType: '1',
15987
+ discolineValue: undefined
15988
+ }); // 强制设置初始值
15989
+
15990
+ setFormValues({
15991
+ discolineType: '1'
15694
15992
  });
15695
- });
15696
- }, 300), [form, lineAmountSum]);
15697
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
15698
- className: "add-discount-row-body"
15699
- }, /*#__PURE__*/React.createElement("p", null, "\u5F53\u524D\u9009\u62E9", /*#__PURE__*/React.createElement(Text$3, {
15700
- type: "danger"
15701
- }, discountGoodIndex.length), "\u884C\u88AB\u6298\u6263\u5546\u54C1\u884C\uFF0C\u91D1\u989D\u5408\u8BA1\xA5", /*#__PURE__*/React.createElement(Text$3, {
15702
- type: "danger"
15703
- }, lineAmountSum.toFixed(2))), /*#__PURE__*/React.createElement(Form.Item, {
15704
- label: "\u6298\u6263\u7387\uFF1A"
15705
- }, getFieldDecorator('discount', {
15993
+ }
15994
+ }, [open]); // 切换 折扣方式 清空折扣值
15995
+
15996
+ React.useEffect(function () {
15997
+ form.setFieldsValue(_objectSpread2(_objectSpread2({}, formValues), {}, {
15998
+ discolineValue: undefined
15999
+ }));
16000
+ }, [formValues === null || formValues === void 0 ? void 0 : formValues.discolineType]);
16001
+ return /*#__PURE__*/React.createElement(Drawer, {
16002
+ title: "\u6DFB\u52A0\u6298\u6263",
16003
+ placement: "right",
16004
+ width: 350,
16005
+ onClose: onClose,
16006
+ open: open,
16007
+ footer: /*#__PURE__*/React.createElement(Space, {
16008
+ size: "middle",
16009
+ style: {
16010
+ display: 'flex',
16011
+ justifyContent: 'end'
16012
+ }
16013
+ }, /*#__PURE__*/React.createElement(Button, {
16014
+ onClick: onDefine,
16015
+ type: 'primary'
16016
+ }, "\u786E\u5B9A"), /*#__PURE__*/React.createElement(Button, {
16017
+ onClick: onClose
16018
+ }, "\u53D6\u6D88"))
16019
+ }, /*#__PURE__*/React.createElement(Form$1, {
16020
+ form: form,
16021
+ layout: 'vertical',
16022
+ onChange: onChangeForm
16023
+ }, /*#__PURE__*/React.createElement(Form$1.Item, {
16024
+ label: "\u5546\u54C1\u91D1\u989D\uFF08\u542B\u7A0E\uFF09"
16025
+ }, totalAmount.toFixed(2), "\uFF08\u5171 ", discountGood.length, " \u884C\uFF09"), /*#__PURE__*/React.createElement(Form$1.Item, {
16026
+ label: "\u6298\u6263\u65B9\u5F0F",
16027
+ name: 'discolineType',
16028
+ initialValue: '1'
16029
+ }, /*#__PURE__*/React.createElement(Radio.Group, {
16030
+ options: [{
16031
+ label: '按金额折扣',
16032
+ value: '1'
16033
+ }, {
16034
+ label: '按比例折扣',
16035
+ value: '2'
16036
+ }]
16037
+ })), (formValues === null || formValues === void 0 ? void 0 : formValues.discolineType) === '2' ? /*#__PURE__*/React.createElement(Form$1.Item, {
16038
+ label: "\u6298\u6263\u6BD4\u4F8B\uFF08%\uFF09\uFF08\u542B\u7A0E\uFF09",
16039
+ name: 'discolineValue',
15706
16040
  rules: [{
15707
16041
  required: true,
15708
- message: '请输入折扣金额'
15709
- }, {
15710
- pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/,
15711
- message: '请输入数字'
16042
+ message: '必填'
15712
16043
  }, {
15713
- validator: function validator(_, value, callback) {
15714
- var _value$match;
16044
+ validator: function () {
16045
+ var _validator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_, value) {
16046
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
16047
+ while (1) {
16048
+ switch (_context9.prev = _context9.next) {
16049
+ case 0:
16050
+ if (!isNaN(parseFloat(value))) {
16051
+ _context9.next = 2;
16052
+ break;
16053
+ }
15715
16054
 
15716
- if (!value) {
15717
- callback();
15718
- return;
15719
- }
16055
+ return _context9.abrupt("return");
15720
16056
 
15721
- if (!((_value$match = value.match(/^[+-]?(0|([1-9]\d*))(\.\d+)?$/)) === null || _value$match === void 0 ? void 0 : _value$match.length)) {
15722
- callback();
15723
- return;
15724
- }
16057
+ case 2:
16058
+ if (!(value <= 0)) {
16059
+ _context9.next = 4;
16060
+ break;
16061
+ }
16062
+
16063
+ throw new Error('需大于0');
15725
16064
 
15726
- if (parseFloat(value) > 100 || parseFloat(value) < 0) {
15727
- callback('请输入大于0小于100的数字');
16065
+ case 4:
16066
+ if (!(value > 100)) {
16067
+ _context9.next = 6;
16068
+ break;
16069
+ }
16070
+
16071
+ throw new Error('不可以大于100');
16072
+
16073
+ case 6:
16074
+ case "end":
16075
+ return _context9.stop();
16076
+ }
16077
+ }
16078
+ }, _callee9);
16079
+ }));
16080
+
16081
+ function validator(_x5, _x6) {
16082
+ return _validator.apply(this, arguments);
15728
16083
  }
15729
16084
 
15730
- callback();
15731
- }
16085
+ return validator;
16086
+ }()
15732
16087
  }]
15733
- })( /*#__PURE__*/React.createElement(Input, {
15734
- placeholder: "\u8BF7\u8F93\u5165\u5927\u4E8E0\u5C0F\u4E8E100\u7684\u6570\u5B57",
15735
- suffix: "%",
15736
- onChange: onChangeDiscount
15737
- }))), /*#__PURE__*/React.createElement(Form.Item, {
15738
- label: "\u6298\u6263\u91D1\u989D\uFF1A"
15739
- }, getFieldDecorator('discolineAmountunt', {
16088
+ }, /*#__PURE__*/React.createElement(InputNumber, {
16089
+ style: {
16090
+ width: '100%'
16091
+ }
16092
+ })) : /*#__PURE__*/React.createElement(Form$1.Item, {
16093
+ label: "\u6298\u6263\u91D1\u989D\uFF08\u5143\uFF09\uFF08\u542B\u7A0E\uFF09",
16094
+ name: 'discolineValue',
15740
16095
  rules: [{
15741
16096
  required: true,
15742
- message: '请输入折扣金额'
15743
- }, {
15744
- pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/,
15745
- message: '请输入数字'
16097
+ message: '必填'
15746
16098
  }, {
15747
- validator: function validator(_, value, callback) {
15748
- var _value$match2;
16099
+ validator: function () {
16100
+ var _validator2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_, value) {
16101
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
16102
+ while (1) {
16103
+ switch (_context10.prev = _context10.next) {
16104
+ case 0:
16105
+ if (!isNaN(parseFloat(value))) {
16106
+ _context10.next = 2;
16107
+ break;
16108
+ }
15749
16109
 
15750
- if (!value) {
15751
- callback();
15752
- return;
15753
- }
16110
+ return _context10.abrupt("return");
15754
16111
 
15755
- if (!((_value$match2 = value.match(/^[+-]?(0|([1-9]\d*))(\.\d+)?$/)) === null || _value$match2 === void 0 ? void 0 : _value$match2.length)) {
15756
- callback();
15757
- return;
15758
- }
16112
+ case 2:
16113
+ if (!(value <= 0)) {
16114
+ _context10.next = 4;
16115
+ break;
16116
+ }
16117
+
16118
+ throw new Error('需大于0');
16119
+
16120
+ case 4:
16121
+ if (!(value > totalAmount)) {
16122
+ _context10.next = 6;
16123
+ break;
16124
+ }
16125
+
16126
+ throw new Error('不可以大于商品金额');
16127
+
16128
+ case 6:
16129
+ case "end":
16130
+ return _context10.stop();
16131
+ }
16132
+ }
16133
+ }, _callee10);
16134
+ }));
15759
16135
 
15760
- if (parseFloat(value) > lineAmountSum || parseFloat(value) <= 0) {
15761
- callback('请输入大于0小于金额合计的数字');
16136
+ function validator(_x7, _x8) {
16137
+ return _validator2.apply(this, arguments);
15762
16138
  }
15763
16139
 
15764
- callback();
15765
- }
16140
+ return validator;
16141
+ }()
15766
16142
  }]
15767
- })( /*#__PURE__*/React.createElement(Input, {
15768
- placeholder: "\u8BF7\u8F93\u5165\u5927\u4E8E0\u5C0F\u4E8E\u91D1\u989D\u5408\u8BA1\u7684\u6570\u5B57",
15769
- suffix: "\xA5",
15770
- onChange: onChangeDiscolineAmountunt
15771
- })))), /*#__PURE__*/React.createElement("div", {
15772
- className: "add-discount-row-footer"
15773
- }, /*#__PURE__*/React.createElement(Button, {
15774
- block: true,
16143
+ }, /*#__PURE__*/React.createElement(InputNumber, {
15775
16144
  style: {
15776
- marginBottom: 12
15777
- },
15778
- onClick: onClose
15779
- }, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
15780
- type: "primary",
15781
- block: true,
15782
- onClick: onClickSave
15783
- }, "\u4FDD\u5B58")));
15784
- });
16145
+ width: '100%'
16146
+ }
16147
+ }))));
16148
+ }
16149
+ /** 判断数组是否连续 */
16150
+
16151
+
16152
+ function isContinuityNum(array) {
16153
+ var i = array[0];
16154
+ var isContinuation = true;
16155
+
16156
+ for (var e in array) {
16157
+ if (array[e] != i) {
16158
+ isContinuation = false;
16159
+ break;
16160
+ }
16161
+
16162
+ i++;
16163
+ }
16164
+
16165
+ return isContinuation;
16166
+ }
16167
+ /** 数组的值是否相等 */
16168
+
16169
+
16170
+ function areAllValuesEqual(arr) {
16171
+ for (var i = 1; i < arr.length; i++) {
16172
+ if (arr[i] !== arr[0]) {
16173
+ return false;
16174
+ }
16175
+ }
16176
+
16177
+ return true;
16178
+ } // const DrawerBody = decorator<{}, FormComponentProps>(Form.create())((props) => {
16179
+ // const { form } = props;
16180
+ // const { getFieldDecorator } = form;
16181
+ // const controller = Invoice.useInvoiceController();
16182
+ // /** 选中的货物索引列表 */
16183
+ // const discountGoodIndex = controller.useMemo(s => s.goodsListState.discountGoodIndex, []);
16184
+ // /** 金额合计 */
16185
+ // const lineAmountSum = controller.useMemo((s) => {
16186
+ // let sum = chain(0);
16187
+ // if (s.goodsListState.isTaxIncluded) {
16188
+ // s.goodsListState.discountGoodIndex.forEach((e) => {
16189
+ // const goods = s.goodsListState.goodsMap.get(e);
16190
+ // sum = sum.add(goods?.lineAmountIncludeTax || 0);
16191
+ // });
16192
+ // } else {
16193
+ // s.goodsListState.discountGoodIndex.forEach((e) => {
16194
+ // const goods = s.goodsListState.goodsMap.get(e);
16195
+ // sum = sum.add(goods?.lineAmountExcludeTax || 0);
16196
+ // });
16197
+ // }
16198
+ // return sum.done();
16199
+ // }, []);
16200
+ // /** 关闭抽屉 */
16201
+ // const onClose = React.useCallback(() => {
16202
+ // controller.pipeline(async (s) => { s.goodsListState.discountGoodIndex = [] })();
16203
+ // }, []);
16204
+ // /** 点击了保存 */
16205
+ // const onClickSave = React.useCallback(() => {
16206
+ // form.validateFields((err, values) => {
16207
+ // if (err) return;
16208
+ // const discolineAmountunt = parseFloat(parseFloat(values.discolineAmountunt).toFixed(2));
16209
+ // const discount = parseFloat(parseFloat(values.discount).toFixed(4));
16210
+ // const indexList = discountGoodIndex;
16211
+ // controller.pipeline(async s => { s.goodsListState.discountGoodIndex = []; })();
16212
+ // controller.addGoodDiscount({ indexList, discount, discolineAmountunt });
16213
+ // });
16214
+ // }, [controller, form, discountGoodIndex]);
16215
+ // /** 折扣率变化 */
16216
+ // const onChangeDiscount = React.useCallback(
16217
+ // lazyFn((e: React.ChangeEvent<HTMLInputElement>) => {
16218
+ // form.validateFields((err, values) => {
16219
+ // if (err && err.discount) return;
16220
+ // const discolineAmountunt = evaluate(`${lineAmountSum} * (${values.discount}/100)`).toFixed(2);
16221
+ // form.setFieldsValue({ discolineAmountunt });
16222
+ // });
16223
+ // }, 300),
16224
+ // [form, lineAmountSum],
16225
+ // );
16226
+ // /** 折扣变化 */
16227
+ // const onChangeDiscolineAmountunt = React.useCallback(
16228
+ // lazyFn((e: React.ChangeEvent<HTMLInputElement>) => {
16229
+ // form.validateFields((err, values) => {
16230
+ // if (err && err.discolineAmountunt) return;
16231
+ // const discolineAmountunt = parseFloat(values.discolineAmountunt).toFixed(2);
16232
+ // const discount = evaluate(`(${discolineAmountunt} / ${lineAmountSum}) * 100`).toFixed(4);
16233
+ // form.setFieldsValue({ discount });
16234
+ // });
16235
+ // }, 300),
16236
+ // [form, lineAmountSum],
16237
+ // );
16238
+ // return (
16239
+ // <>
16240
+ // <div className="add-discount-row-body">
16241
+ // <p>
16242
+ // 当前选择<Text type="danger">{discountGoodIndex.length}</Text>
16243
+ // 行被折扣商品行,金额合计¥
16244
+ // <Text type="danger">{lineAmountSum.toFixed(2)}</Text>
16245
+ // </p>
16246
+ // <Form.Item label="折扣率:">
16247
+ // {getFieldDecorator('discount', {
16248
+ // rules: [
16249
+ // { required: true, message: '请输入折扣金额' },
16250
+ // { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '请输入数字' },
16251
+ // {
16252
+ // validator: (_, value: string, callback) => {
16253
+ // if (!value) { callback(); return; }
16254
+ // if (!value.match(/^[+-]?(0|([1-9]\d*))(\.\d+)?$/)?.length) { callback(); return; }
16255
+ // if (parseFloat(value) > 100 || parseFloat(value) < 0) { callback('请输入大于0小于100的数字'); }
16256
+ // callback();
16257
+ // },
16258
+ // },
16259
+ // ],
16260
+ // })(
16261
+ // <Input
16262
+ // placeholder="请输入大于0小于100的数字"
16263
+ // suffix="%"
16264
+ // onChange={onChangeDiscount}
16265
+ // />,
16266
+ // )}
16267
+ // </Form.Item>
16268
+ // <Form.Item label="折扣金额:">
16269
+ // {getFieldDecorator('discolineAmountunt', {
16270
+ // rules: [
16271
+ // { required: true, message: '请输入折扣金额' },
16272
+ // { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '请输入数字' },
16273
+ // {
16274
+ // validator: (_, value: string, callback) => {
16275
+ // if (!value) { callback(); return; }
16276
+ // if (!value.match(/^[+-]?(0|([1-9]\d*))(\.\d+)?$/)?.length) { callback(); return; }
16277
+ // if (parseFloat(value) > lineAmountSum || parseFloat(value) <= 0) { callback('请输入大于0小于金额合计的数字'); }
16278
+ // callback();
16279
+ // },
16280
+ // },
16281
+ // ],
16282
+ // })(
16283
+ // <Input
16284
+ // placeholder="请输入大于0小于金额合计的数字"
16285
+ // suffix="¥"
16286
+ // onChange={onChangeDiscolineAmountunt}
16287
+ // />,
16288
+ // )}
16289
+ // </Form.Item>
16290
+ // </div>
16291
+ // <div className="add-discount-row-footer">
16292
+ // <Button block style={{ marginBottom: 12 }} onClick={onClose}>取消</Button>
16293
+ // <Button type="primary" block onClick={onClickSave}>保存</Button>
16294
+ // </div>
16295
+ // </>
16296
+ // );
16297
+ // });
15785
16298
 
15786
16299
  /** 全单合并明细 */
15787
16300
 
@@ -16602,7 +17115,7 @@ var Main = decorator(Form.create())(function (props) {
16602
17115
  className: "kts-invoice-operate-goods-list-able"
16603
17116
  }, /*#__PURE__*/React.createElement("div", {
16604
17117
  className: "kts-invoice-operate-goods-list-able-list"
16605
- }, /*#__PURE__*/React.createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, salesDiscount.button, salesGifts.button, /*#__PURE__*/React.createElement(Search, null)), /*#__PURE__*/React.createElement("div", {
17118
+ }, /*#__PURE__*/React.createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, addDiscountRowButton.button, mergeDetails.button, mergeDiscount.button, salesDiscount.button, salesGifts.button, /*#__PURE__*/React.createElement(Search, null)), /*#__PURE__*/React.createElement("div", {
16606
17119
  className: "kts-invoice-operate-goods-list-able-extend"
16607
17120
  }, props.menuExpansion, /*#__PURE__*/React.createElement(DescribeSwitch, null), /*#__PURE__*/React.createElement(TaxIncludedSwitch, null))), /*#__PURE__*/React.createElement("div", {
16608
17121
  className: classnames('kts-invoice-operate-goods-list-table', {
@@ -17549,18 +18062,41 @@ var Stakeholder$1 = decorator(Form.create())(function (props) {
17549
18062
  className: "digtal-stakeholder-expand-button",
17550
18063
  component: isExpand ? SvgArrowUp : SvgArrowDown,
17551
18064
  onClick: onExpand
17552
- })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
18065
+ })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Form, {
18066
+ className: "digtal-stakeholder-form"
18067
+ }, /*#__PURE__*/React.createElement(Row, {
18068
+ gutter: [16, 0],
18069
+ className: 'natural-person-flag',
17553
18070
  style: {
17554
- marginTop: 20
17555
- },
17556
- className: 'natural-person-flag'
18071
+ paddingRight: 0
18072
+ }
18073
+ }, /*#__PURE__*/React.createElement(Col, {
18074
+ span: 24,
18075
+ style: {
18076
+ display: 'flex',
18077
+ marginBottom: '15px'
18078
+ }
17557
18079
  }, props.isNaturalPerson === true && /*#__PURE__*/React.createElement(Form.Item, {
17558
18080
  colon: false
17559
18081
  }, getFieldDecorator('naturalPersonFlag', {})( /*#__PURE__*/React.createElement(NaturalPersonFlag, {
17560
18082
  readOnly: isReadOnly('naturalPersonFlag')
17561
- })))), /*#__PURE__*/React.createElement(Form, {
17562
- className: "digtal-stakeholder-form"
17563
- }, /*#__PURE__*/React.createElement(Row, {
18083
+ }))), /*#__PURE__*/React.createElement("div", {
18084
+ style: {
18085
+ flex: 1
18086
+ }
18087
+ }, /*#__PURE__*/React.createElement(Form.Item, {
18088
+ label: "\u5BA2\u6237\u4EE3\u7801",
18089
+ colon: false
18090
+ }, getFieldDecorator('buyerCode', {
18091
+ rules: [{
18092
+ required: true,
18093
+ message: '客户代码必填'
18094
+ }]
18095
+ })( /*#__PURE__*/React.createElement(Input$1, {
18096
+ style: {
18097
+ width: '100%'
18098
+ }
18099
+ })))))), /*#__PURE__*/React.createElement(Row, {
17564
18100
  gutter: [16, 0]
17565
18101
  }, /*#__PURE__*/React.createElement(Col, {
17566
18102
  span: 24
@@ -19275,7 +19811,7 @@ function _rollBottom$1() {
19275
19811
 
19276
19812
  /** 延迟函数 */
19277
19813
 
19278
- var lazyFn$2 = function lazyFn(fn) {
19814
+ var lazyFn$1 = function lazyFn(fn) {
19279
19815
  var delayed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
19280
19816
  var timer;
19281
19817
  return function () {
@@ -19356,7 +19892,7 @@ var clearCalculatingField$1 = /*#__PURE__*/function () {
19356
19892
  }();
19357
19893
  /** 数量改变了 */
19358
19894
 
19359
- var onChangeQuantity$1 = lazyFn$2(function (controller, form, record) {
19895
+ var onChangeQuantity$1 = lazyFn$1(function (controller, form, record) {
19360
19896
  form.validateFields( /*#__PURE__*/function () {
19361
19897
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(err, values) {
19362
19898
  var calculatingDigits, quantity, priceIncludeTax, lineAmountIncludeTax, _lineAmountIncludeTax, _priceIncludeTax, priceExcludeTax, lineAmountExcludeTax, _lineAmountExcludeTax, _priceExcludeTax;
@@ -19522,7 +20058,7 @@ var onChangeQuantity$1 = lazyFn$2(function (controller, form, record) {
19522
20058
  }, 1000);
19523
20059
  /** 单价(含税) */
19524
20060
 
19525
- var onChangePriceIncludeTax$1 = lazyFn$2(function (controller, form, record) {
20061
+ var onChangePriceIncludeTax$1 = lazyFn$1(function (controller, form, record) {
19526
20062
  form.validateFields( /*#__PURE__*/function () {
19527
20063
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(err, values) {
19528
20064
  var calculatingDigits, priceIncludeTax, quantity, lineAmountIncludeTax, _lineAmountIncludeTax2, _quantity;
@@ -19634,7 +20170,7 @@ var onChangePriceIncludeTax$1 = lazyFn$2(function (controller, form, record) {
19634
20170
  }, 1000);
19635
20171
  /** 单价(不含税) */
19636
20172
 
19637
- var onChangePriceExcludeTax$1 = lazyFn$2(function (controller, form, record) {
20173
+ var onChangePriceExcludeTax$1 = lazyFn$1(function (controller, form, record) {
19638
20174
  form.validateFields( /*#__PURE__*/function () {
19639
20175
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(err, values) {
19640
20176
  var calculatingDigits, priceExcludeTax, quantity, lineAmountExcludeTax, _lineAmountExcludeTax2, _quantity2;
@@ -19746,7 +20282,7 @@ var onChangePriceExcludeTax$1 = lazyFn$2(function (controller, form, record) {
19746
20282
  }, 1000);
19747
20283
  /** 金额(含税) */
19748
20284
 
19749
- var onChangeLineAmountIncludeTax$1 = lazyFn$2(function (controller, form, record) {
20285
+ var onChangeLineAmountIncludeTax$1 = lazyFn$1(function (controller, form, record) {
19750
20286
  form.validateFields( /*#__PURE__*/function () {
19751
20287
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(err, values) {
19752
20288
  var calculatingDigits, lineAmountIncludeTax, quantity, priceIncludeTax, _priceIncludeTax2, _quantity3;
@@ -19850,7 +20386,7 @@ var onChangeLineAmountIncludeTax$1 = lazyFn$2(function (controller, form, record
19850
20386
  }, 1000);
19851
20387
  /** 金额(不含税) */
19852
20388
 
19853
- var onChangeLineAmountExcludeTax$1 = lazyFn$2(function (controller, form, record) {
20389
+ var onChangeLineAmountExcludeTax$1 = lazyFn$1(function (controller, form, record) {
19854
20390
  form.validateFields( /*#__PURE__*/function () {
19855
20391
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(err, values) {
19856
20392
  var calculatingDigits, lineAmountExcludeTax, quantity, priceExcludeTax, _priceExcludeTax2, _quantity4;
@@ -19954,7 +20490,7 @@ var onChangeLineAmountExcludeTax$1 = lazyFn$2(function (controller, form, record
19954
20490
  }, 1000);
19955
20491
  /** 税率 */
19956
20492
 
19957
- var onChangeTaxRate$1 = lazyFn$2(function (controller, form, record) {
20493
+ var onChangeTaxRate$1 = lazyFn$1(function (controller, form, record) {
19958
20494
  form.validateFields( /*#__PURE__*/function () {
19959
20495
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(err, values) {
19960
20496
  var taxRate;
@@ -20049,7 +20585,7 @@ var onChangeTaxRate$1 = lazyFn$2(function (controller, form, record) {
20049
20585
  }, 1000);
20050
20586
  /** 税额 */
20051
20587
 
20052
- var onChangeTaxAmount = lazyFn$2(function (controller, form, record) {
20588
+ var onChangeTaxAmount = lazyFn$1(function (controller, form, record) {
20053
20589
  /** 金额(不含税) */
20054
20590
  var lineAmountExcludeTax;
20055
20591
  form.validateFields( /*#__PURE__*/function () {
@@ -23137,7 +23673,7 @@ var useAddDiscountRowButton$1 = (function () {
23137
23673
  return _context.abrupt("return");
23138
23674
 
23139
23675
  case 4:
23140
- if (isContinuityNum(s.goodsListState.selectedGoodIndex.map(function (e) {
23676
+ if (isContinuityNum$1(s.goodsListState.selectedGoodIndex.map(function (e) {
23141
23677
  var _s$goodsListState$goo;
23142
23678
 
23143
23679
  return ((_s$goodsListState$goo = s.goodsListState.goodsMap.get(e)) === null || _s$goodsListState$goo === void 0 ? void 0 : _s$goodsListState$goo.serialNo) || -2;
@@ -23174,7 +23710,7 @@ var useAddDiscountRowButton$1 = (function () {
23174
23710
  return _context.abrupt("return");
23175
23711
 
23176
23712
  case 11:
23177
- if (!(areAllValuesEqual(s.goodsListState.selectedGoodIndex.map(function (e) {
23713
+ if (!(areAllValuesEqual$1(s.goodsListState.selectedGoodIndex.map(function (e) {
23178
23714
  var _s$goodsListState$goo3;
23179
23715
 
23180
23716
  return (_s$goodsListState$goo3 = s.goodsListState.goodsMap.get(e)) === null || _s$goodsListState$goo3 === void 0 ? void 0 : _s$goodsListState$goo3.taxRate;
@@ -23290,7 +23826,7 @@ var useAddDiscountRowButton$1 = (function () {
23290
23826
  size: 'small',
23291
23827
  onClick: onOpen,
23292
23828
  disabled: disabled
23293
- }, "\u6DFB\u52A0\u6298\u6263"), /*#__PURE__*/React.createElement(AddDiscountRowDrawer, {
23829
+ }, "\u6DFB\u52A0\u6298\u6263"), /*#__PURE__*/React.createElement(AddDiscountRowDrawer$1, {
23294
23830
  open: open,
23295
23831
  onClose: onClose
23296
23832
  }));
@@ -23304,7 +23840,7 @@ var useAddDiscountRowButton$1 = (function () {
23304
23840
  });
23305
23841
  /** 添加折扣行的抽屉 */
23306
23842
 
23307
- function AddDiscountRowDrawer(props) {
23843
+ function AddDiscountRowDrawer$1(props) {
23308
23844
  var open = props.open,
23309
23845
  onClose = props.onClose;
23310
23846
 
@@ -23351,13 +23887,19 @@ function AddDiscountRowDrawer(props) {
23351
23887
  /** 表单变化 */
23352
23888
 
23353
23889
  var onChangeForm = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
23890
+ var values;
23354
23891
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
23355
23892
  while (1) {
23356
23893
  switch (_context4.prev = _context4.next) {
23357
23894
  case 0:
23358
- setFormValues(form.getFieldsValue());
23895
+ _context4.next = 2;
23896
+ return form.getFieldsValue();
23359
23897
 
23360
- case 1:
23898
+ case 2:
23899
+ values = _context4.sent;
23900
+ setFormValues(values);
23901
+
23902
+ case 4:
23361
23903
  case "end":
23362
23904
  return _context4.stop();
23363
23905
  }
@@ -23467,7 +24009,14 @@ function AddDiscountRowDrawer(props) {
23467
24009
  React.useEffect(function () {
23468
24010
  if (open) {
23469
24011
  form.resetFields();
23470
- setFormValues(form.getFieldsValue());
24012
+ form.setFieldsValue({
24013
+ discolineType: '1',
24014
+ discolineValue: undefined
24015
+ }); // 强制设置初始值
24016
+
24017
+ setFormValues({
24018
+ discolineType: '1'
24019
+ }); // 强制设置formValues的初始状态
23471
24020
  }
23472
24021
  }, [open]); // 切换 折扣方式 清空折扣值
23473
24022
 
@@ -23476,7 +24025,7 @@ function AddDiscountRowDrawer(props) {
23476
24025
  discolineValue: undefined
23477
24026
  }));
23478
24027
  }, [formValues === null || formValues === void 0 ? void 0 : formValues.discolineType]);
23479
- return /*#__PURE__*/React.createElement(Drawer$1, {
24028
+ return /*#__PURE__*/React.createElement(Drawer, {
23480
24029
  title: "\u6DFB\u52A0\u6298\u6263",
23481
24030
  placement: "right",
23482
24031
  width: 350,
@@ -23497,7 +24046,10 @@ function AddDiscountRowDrawer(props) {
23497
24046
  }, /*#__PURE__*/React.createElement(Form$1, {
23498
24047
  form: form,
23499
24048
  layout: 'vertical',
23500
- onChange: onChangeForm
24049
+ onChange: onChangeForm,
24050
+ initialValues: {
24051
+ discolineType: '1'
24052
+ }
23501
24053
  }, /*#__PURE__*/React.createElement(Form$1.Item, {
23502
24054
  label: "\u5546\u54C1\u91D1\u989D\uFF08\u542B\u7A0E\uFF09"
23503
24055
  }, totalAmount.toFixed(2), "\uFF08\u5171 ", discountGood.length, " \u884C\uFF09"), /*#__PURE__*/React.createElement(Form$1.Item, {
@@ -23627,7 +24179,7 @@ function AddDiscountRowDrawer(props) {
23627
24179
  /** 判断数组是否连续 */
23628
24180
 
23629
24181
 
23630
- function isContinuityNum(array) {
24182
+ function isContinuityNum$1(array) {
23631
24183
  var i = array[0];
23632
24184
  var isContinuation = true;
23633
24185
 
@@ -23645,7 +24197,7 @@ function isContinuityNum(array) {
23645
24197
  /** 数组的值是否相等 */
23646
24198
 
23647
24199
 
23648
- function areAllValuesEqual(arr) {
24200
+ function areAllValuesEqual$1(arr) {
23649
24201
  for (var i = 1; i < arr.length; i++) {
23650
24202
  if (arr[i] !== arr[0]) {
23651
24203
  return false;
@@ -26224,7 +26776,7 @@ var ImportBuyerDrawer = (function () {
26224
26776
  };
26225
26777
  }())();
26226
26778
  }, [controller]);
26227
- return /*#__PURE__*/React.createElement(Drawer, {
26779
+ return /*#__PURE__*/React.createElement(Drawer$1, {
26228
26780
  title: "\u8D2D\u65B9\u5217\u8868",
26229
26781
  placement: "right",
26230
26782
  // closable={false}
@@ -26232,10 +26784,10 @@ var ImportBuyerDrawer = (function () {
26232
26784
  width: 983,
26233
26785
  onClose: onClose,
26234
26786
  visible: visible
26235
- }, topExpand, /*#__PURE__*/React.createElement(DrawerBody$1, null));
26787
+ }, topExpand, /*#__PURE__*/React.createElement(DrawerBody, null));
26236
26788
  });
26237
26789
 
26238
- var DrawerBody$1 = function DrawerBody() {
26790
+ var DrawerBody = function DrawerBody() {
26239
26791
  var controller = Invoice.useInvoiceController();
26240
26792
  var columns = controller.useMemo(function (e) {
26241
26793
  return e.buyerState.columns;
@@ -26353,7 +26905,7 @@ var ImportGoodsDrawer = (function () {
26353
26905
  };
26354
26906
  }())();
26355
26907
  }, [controller]);
26356
- return /*#__PURE__*/React.createElement(Drawer, {
26908
+ return /*#__PURE__*/React.createElement(Drawer$1, {
26357
26909
  title: "\u5546\u54C1\u5217\u8868",
26358
26910
  placement: "right",
26359
26911
  // closable={false}
@@ -26365,10 +26917,10 @@ var ImportGoodsDrawer = (function () {
26365
26917
  style: {
26366
26918
  marginBottom: 10
26367
26919
  }
26368
- }, topExpand), /*#__PURE__*/React.createElement(DrawerBody$2, null));
26920
+ }, topExpand), /*#__PURE__*/React.createElement(DrawerBody$1, null));
26369
26921
  });
26370
26922
 
26371
- var DrawerBody$2 = function DrawerBody() {
26923
+ var DrawerBody$1 = function DrawerBody() {
26372
26924
  var controller = Invoice.useInvoiceController();
26373
26925
  var columns = controller.useMemo(function (s) {
26374
26926
  return s.goodsListState.importGoods.columns;
@@ -26387,6 +26939,11 @@ var DrawerBody$2 = function DrawerBody() {
26387
26939
  }
26388
26940
  });
26389
26941
  }, [controller]);
26942
+
26943
+ var roundTo8Decimals = function roundTo8Decimals(num) {
26944
+ return Math.round(num * 1e8) / 1e8;
26945
+ };
26946
+
26390
26947
  return /*#__PURE__*/React.createElement(Table$1, {
26391
26948
  bordered: true,
26392
26949
  size: "small",
@@ -26403,6 +26960,8 @@ var DrawerBody$2 = function DrawerBody() {
26403
26960
  onClick: function onClick() {
26404
26961
  controller.run( /*#__PURE__*/function () {
26405
26962
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
26963
+ var _s$goodsListState$edi, _s$goodsListState$edi2, _s$goodsListState$edi3, _s$goodsListState$edi4, _s$goodsListState$edi5, _s$goodsListState$edi6, _s$goodsListState$edi7, _s$goodsListState$edi8, _s$goodsListState$edi9, _s$goodsListState$edi10, _s$goodsListState$edi11, _s$goodsListState$edi12, _s$goodsListState$edi13, _s$goodsListState$edi14, _s$goodsListState$edi15, _s$goodsListState$edi16;
26964
+
26406
26965
  var between, editGood;
26407
26966
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
26408
26967
  while (1) {
@@ -26439,17 +26998,32 @@ var DrawerBody$2 = function DrawerBody() {
26439
26998
  // 导入时清空之前输入的值,使用导入的单价和税率(参考税局系统)
26440
26999
  record.quantity = undefined;
26441
27000
  record.lineAmountExcludeTax = undefined;
26442
- record.lineAmountIncludeTax = undefined; // 中间数据
27001
+ record.lineAmountIncludeTax = undefined; // console.log('s.goodsListState.editGood1:', s.goodsListState.editGood);
27002
+ // 光电定制化功能:无论是否有值都替换 itemCode, itemName, shorthand, taxCategoryCode, taxClassificationCode;
27003
+ // 如果其他输入框有值就不替换,没值就替换:itemModelName, lineAmountExcludeTax, lineAmountIncludeTax,lineAttribute,priceExcludeTax,
27004
+ // priceIncludeTax,quantity, serialNo, taxAmount, taxRate, unit
27005
+ // 中间数据
27006
+
27007
+ between = _objectSpread2({}, record); // console.log(':between:', between);
26443
27008
 
26444
- between = _objectSpread2({}, record);
26445
27009
  between.itemName = getItemName(record, s.goodsListState.editGood);
26446
27010
  between.itemCode = getItemCode(record, s.goodsListState.editGood);
26447
27011
  between.itemNameOther = getItemNameOther(record, s.goodsListState.editGood); // 设置编辑货物
26448
27012
 
26449
- editGood = s.goodsListState.editGood = _objectSpread2(_objectSpread2({}, s.goodsListState.editGood), {}, {
26450
- itemModelName: undefined,
26451
- itemModelNameSelf: undefined
26452
- }, between);
27013
+ editGood = s.goodsListState.editGood = _objectSpread2(_objectSpread2(_objectSpread2({}, s.goodsListState.editGood), between), {}, {
27014
+ itemModelName: (_s$goodsListState$edi = (_s$goodsListState$edi2 = s.goodsListState.editGood) === null || _s$goodsListState$edi2 === void 0 ? void 0 : _s$goodsListState$edi2.itemModelName) !== null && _s$goodsListState$edi !== void 0 ? _s$goodsListState$edi : between.itemModelName,
27015
+ itemModelNameSelf: (_s$goodsListState$edi3 = (_s$goodsListState$edi4 = s.goodsListState.editGood) === null || _s$goodsListState$edi4 === void 0 ? void 0 : _s$goodsListState$edi4.itemModelNameSelf) !== null && _s$goodsListState$edi3 !== void 0 ? _s$goodsListState$edi3 : between.itemModelNameSelf,
27016
+ lineAmountExcludeTax: (_s$goodsListState$edi5 = (_s$goodsListState$edi6 = s.goodsListState.editGood) === null || _s$goodsListState$edi6 === void 0 ? void 0 : _s$goodsListState$edi6.lineAmountExcludeTax) !== null && _s$goodsListState$edi5 !== void 0 ? _s$goodsListState$edi5 : between.lineAmountExcludeTax,
27017
+ lineAmountIncludeTax: (_s$goodsListState$edi7 = (_s$goodsListState$edi8 = s.goodsListState.editGood) === null || _s$goodsListState$edi8 === void 0 ? void 0 : _s$goodsListState$edi8.lineAmountIncludeTax) !== null && _s$goodsListState$edi7 !== void 0 ? _s$goodsListState$edi7 : between.lineAmountIncludeTax,
27018
+ priceExcludeTax: roundTo8Decimals((_s$goodsListState$edi9 = (_s$goodsListState$edi10 = s.goodsListState.editGood) === null || _s$goodsListState$edi10 === void 0 ? void 0 : _s$goodsListState$edi10.priceExcludeTax) !== null && _s$goodsListState$edi9 !== void 0 ? _s$goodsListState$edi9 : between.priceExcludeTax),
27019
+ priceIncludeTax: roundTo8Decimals((_s$goodsListState$edi11 = (_s$goodsListState$edi12 = s.goodsListState.editGood) === null || _s$goodsListState$edi12 === void 0 ? void 0 : _s$goodsListState$edi12.priceIncludeTax) !== null && _s$goodsListState$edi11 !== void 0 ? _s$goodsListState$edi11 : between.priceIncludeTax),
27020
+ quantity: (_s$goodsListState$edi13 = (_s$goodsListState$edi14 = s.goodsListState.editGood) === null || _s$goodsListState$edi14 === void 0 ? void 0 : _s$goodsListState$edi14.quantity) !== null && _s$goodsListState$edi13 !== void 0 ? _s$goodsListState$edi13 : between.quantity,
27021
+ unit: (_s$goodsListState$edi15 = (_s$goodsListState$edi16 = s.goodsListState.editGood) === null || _s$goodsListState$edi16 === void 0 ? void 0 : _s$goodsListState$edi16.unit) !== null && _s$goodsListState$edi15 !== void 0 ? _s$goodsListState$edi15 : between.unit // serialNo:s.goodsListState.editGood?.itemModelName ?? between.itemModelName,
27022
+ // taxAmount:s.goodsListState.editGood?.itemModelName ?? between.itemModelName,
27023
+ // taxRate:s.goodsListState.editGood?.itemModelName ?? between.itemModelName,
27024
+ // lineAttribute:s.goodsListState.editGood?.lineAttribute,
27025
+
27026
+ });
26453
27027
 
26454
27028
  if (editGood.taxRate) {
26455
27029
  editGood.taxRate = dutyFree(controller, editGood.taxRate, s.goodsListState.form, editGood);
@@ -26459,7 +27033,7 @@ var DrawerBody$2 = function DrawerBody() {
26459
27033
  editGood.priceIncludeTax = undefined;
26460
27034
  editGood.priceExcludeTax = undefined;
26461
27035
  } else {
26462
- editGood.priceExcludeTax = getPriceExcludeTax$1(editGood, record, s.calculatingDigits);
27036
+ editGood.priceExcludeTax = editGood.priceExcludeTax || getPriceExcludeTax$1(editGood, record, 8);
26463
27037
  }
26464
27038
 
26465
27039
  if (editGood.quantity && editGood.priceIncludeTax) {
@@ -26477,7 +27051,7 @@ var DrawerBody$2 = function DrawerBody() {
26477
27051
  // s.goodsListState.form.setFieldsValue({
26478
27052
  // ...editGood,
26479
27053
  // });
26480
- // }
27054
+ // }
26481
27055
 
26482
27056
  s.goodsListState.importGoods.isVisibleDrawer = false;
26483
27057
 
@@ -26701,7 +27275,7 @@ var EndowCodeDrawer = (function () {
26701
27275
  setDefaultValue(undefined);
26702
27276
  }
26703
27277
  }, [visible]);
26704
- return /*#__PURE__*/React.createElement(Drawer, {
27278
+ return /*#__PURE__*/React.createElement(Drawer$1, {
26705
27279
  title: "\u8D4B\u7801",
26706
27280
  placement: "right",
26707
27281
  destroyOnClose: true,
@@ -26709,12 +27283,12 @@ var EndowCodeDrawer = (function () {
26709
27283
  width: 383,
26710
27284
  onClose: onClose,
26711
27285
  visible: visible
26712
- }, defaultValue && /*#__PURE__*/React.createElement(DrawerBody$3, {
27286
+ }, defaultValue && /*#__PURE__*/React.createElement(DrawerBody$2, {
26713
27287
  defaultValue: defaultValue
26714
27288
  }));
26715
27289
  });
26716
27290
 
26717
- var DrawerBody$3 = function DrawerBody(props) {
27291
+ var DrawerBody$2 = function DrawerBody(props) {
26718
27292
  var _defaultValue$taxRate, _defaultValue$favoure;
26719
27293
 
26720
27294
  var controller = Invoice.useInvoiceController();
@@ -27040,7 +27614,7 @@ var DrawerBody$3 = function DrawerBody(props) {
27040
27614
  setVisible(true);
27041
27615
  }
27042
27616
  }, "\u70B9\u51FB\u9009\u62E9")
27043
- }), /*#__PURE__*/React.createElement(Drawer, {
27617
+ }), /*#__PURE__*/React.createElement(Drawer$1, {
27044
27618
  title: "\u7A0E\u6536\u5206\u7C7B\u7F16\u7801",
27045
27619
  visible: visible,
27046
27620
  width: 500,
@@ -27792,7 +28366,7 @@ function AddComparisonDrawer() {
27792
28366
  }));
27793
28367
  }
27794
28368
  }, [good]);
27795
- return /*#__PURE__*/React.createElement(Drawer$1, {
28369
+ return /*#__PURE__*/React.createElement(Drawer, {
27796
28370
  width: 500,
27797
28371
  onClose: onClose,
27798
28372
  placement: "right",
@@ -28140,7 +28714,7 @@ function TaxClassificationModal(props) {
28140
28714
  taxDesc: props === null || props === void 0 ? void 0 : (_props$info5 = props.info) === null || _props$info5 === void 0 ? void 0 : _props$info5.taxDesc
28141
28715
  }));
28142
28716
  }, [props === null || props === void 0 ? void 0 : (_props$info6 = props.info) === null || _props$info6 === void 0 ? void 0 : _props$info6.key]);
28143
- return /*#__PURE__*/React.createElement(Drawer$1, {
28717
+ return /*#__PURE__*/React.createElement(Drawer, {
28144
28718
  title: "\u5546\u54C1\u548C\u670D\u52A1\u7A0E\u6536\u5206\u7C7B\u7F16\u7801",
28145
28719
  placement: "right",
28146
28720
  open: props.open,