kts-component-invoice-operate 3.2.121 → 3.2.123

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.
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  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
- import { chain as chain$1, bignumber, format as format$1, create, all } from 'mathjs';
4
+ import { chain as chain$1, bignumber, format as format$1, create, all, equal } from 'mathjs';
5
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$1, Col as Col$1 } from 'kts-components-antd-x3';
6
6
  import { v4 } from 'uuid';
7
7
  import { message as message$1, TableManual, Switch, AutoComplete as AutoComplete$1, Popover, Dropdown as Dropdown$1, Row, Col, Button as Button$1, Tooltip as Tooltip$1, Checkbox as Checkbox$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, Tree as Tree$1 } from 'kts-xui';
@@ -1089,6 +1089,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
1089
1089
  this.deduction = 0;
1090
1090
  this.goodMax = void 0;
1091
1091
  this.isSwitchTax = void 0;
1092
+ this.isRecalculateWhenSwitchTax = false;
1092
1093
  this.isAddDiscount = void 0;
1093
1094
  this.isAddRow = true;
1094
1095
  this.isRemRow = true;
@@ -9331,6 +9332,177 @@ var onChangeItemCode = /*#__PURE__*/function () {
9331
9332
  return _ref18.apply(this, arguments);
9332
9333
  };
9333
9334
  }();
9335
+ /** 修改了含税开关 重新计算 */
9336
+
9337
+ var onChangeSwitchTax = /*#__PURE__*/function () {
9338
+ var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(controller, isTaxIncluded) {
9339
+ var calculatingDigits;
9340
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
9341
+ while (1) {
9342
+ switch (_context22.prev = _context22.next) {
9343
+ case 0:
9344
+ if (controller.state.goodsListState.isRecalculateWhenSwitchTax) {
9345
+ _context22.next = 3;
9346
+ break;
9347
+ }
9348
+
9349
+ controller.pipeline( /*#__PURE__*/function () {
9350
+ var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(s) {
9351
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
9352
+ while (1) {
9353
+ switch (_context20.prev = _context20.next) {
9354
+ case 0:
9355
+ s.goodsListState = _objectSpread2(_objectSpread2({}, s.goodsListState), {}, {
9356
+ isTaxIncluded: isTaxIncluded
9357
+ });
9358
+
9359
+ case 1:
9360
+ case "end":
9361
+ return _context20.stop();
9362
+ }
9363
+ }
9364
+ }, _callee20);
9365
+ }));
9366
+
9367
+ return function (_x40) {
9368
+ return _ref21.apply(this, arguments);
9369
+ };
9370
+ }())();
9371
+ return _context22.abrupt("return");
9372
+
9373
+ case 3:
9374
+ calculatingDigits = controller.state.calculatingDigits;
9375
+ _context22.next = 6;
9376
+ return controller.saveEditGood();
9377
+
9378
+ case 6:
9379
+ _context22.next = 8;
9380
+ return controller.wait();
9381
+
9382
+ case 8:
9383
+ _context22.next = 10;
9384
+ return controller.run( /*#__PURE__*/function () {
9385
+ var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(s) {
9386
+ var _s$goodsListState, needRefresh, newGoodsList;
9387
+
9388
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
9389
+ while (1) {
9390
+ switch (_context21.prev = _context21.next) {
9391
+ case 0:
9392
+ if (!s.goodsListState.editGood) {
9393
+ _context21.next = 3;
9394
+ break;
9395
+ }
9396
+
9397
+ message.error({
9398
+ content: '你正在编辑一个货物',
9399
+ key: '你正在编辑一个货物'
9400
+ });
9401
+ return _context21.abrupt("return");
9402
+
9403
+ case 3:
9404
+ s.goodsListState.isTaxIncluded = isTaxIncluded;
9405
+
9406
+ try {
9407
+ needRefresh = false;
9408
+
9409
+ if (((_s$goodsListState = s.goodsListState) === null || _s$goodsListState === void 0 ? void 0 : _s$goodsListState.goodsList) && s.goodsListState.goodsList.length) {
9410
+ newGoodsList = s.goodsListState.goodsList.map(function (good) {
9411
+ var sourceQuantity = good.quantity,
9412
+ sourcePriceExcludeTax = good.priceExcludeTax,
9413
+ sourcePriceIncludeTax = good.priceIncludeTax,
9414
+ sourceLineAmountExcludeTax = good.lineAmountExcludeTax,
9415
+ sourceLineAmountIncludeTax = good.lineAmountIncludeTax,
9416
+ taxRate = good.taxRate;
9417
+
9418
+ if (isTaxIncluded) {
9419
+ if (!sourceQuantity && sourceQuantity !== 0) return good;
9420
+ if (!sourcePriceIncludeTax && sourcePriceIncludeTax !== 0) return good;
9421
+ if (!taxRate && taxRate !== 0) return good;
9422
+
9423
+ if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
9424
+ return good;
9425
+ } else {
9426
+ needRefresh = true;
9427
+ }
9428
+
9429
+ var quantity = format15(sourceQuantity, calculatingDigits);
9430
+ var priceIncludeTax = format15(sourcePriceIncludeTax, calculatingDigits);
9431
+ var lineAmountIncludeTax = format2(evaluate("".concat(priceIncludeTax, " * ").concat(quantity)));
9432
+ var taxAmount = countTaxAmount(lineAmountIncludeTax, controller.state.goodsListState.deduction, taxRate);
9433
+ var lineAmountExcludeTax = countAmountExcludeTax(lineAmountIncludeTax, taxAmount);
9434
+ var priceExcludeTax = countPrice(lineAmountExcludeTax, quantity, controller.state.calculatingDigits);
9435
+ return _objectSpread2(_objectSpread2({}, good), {}, {
9436
+ lineAmountExcludeTax: lineAmountExcludeTax,
9437
+ lineAmountIncludeTax: lineAmountIncludeTax,
9438
+ taxAmount: taxAmount,
9439
+ priceExcludeTax: priceExcludeTax
9440
+ });
9441
+ } else {
9442
+ if (!sourceQuantity && sourceQuantity !== 0) return good;
9443
+ if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
9444
+ if (!taxRate && taxRate !== 0) return good;
9445
+
9446
+ if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
9447
+ return good;
9448
+ } else {
9449
+ needRefresh = true;
9450
+ }
9451
+
9452
+ var _quantity5 = format15(sourceQuantity, calculatingDigits);
9453
+
9454
+ var _priceExcludeTax3 = format15(sourcePriceExcludeTax, calculatingDigits);
9455
+
9456
+ var _lineAmountExcludeTax3 = format2(evaluate("".concat(_priceExcludeTax3, " * ").concat(_quantity5)));
9457
+
9458
+ var _lineAmountIncludeTax3 = format2(evaluate("".concat(_lineAmountExcludeTax3, " * (1+(").concat(taxRate, "/100))")));
9459
+
9460
+ var _priceIncludeTax3 = format15(evaluate("".concat(_lineAmountIncludeTax3, " / ").concat(_quantity5)), calculatingDigits);
9461
+
9462
+ var _taxAmount = evaluate("".concat(_lineAmountIncludeTax3, " - ").concat(_lineAmountExcludeTax3));
9463
+
9464
+ return _objectSpread2(_objectSpread2({}, good), {}, {
9465
+ lineAmountExcludeTax: _lineAmountExcludeTax3,
9466
+ lineAmountIncludeTax: _lineAmountIncludeTax3,
9467
+ taxAmount: _taxAmount,
9468
+ priceIncludeTax: _priceIncludeTax3
9469
+ });
9470
+ }
9471
+ });
9472
+
9473
+ if (needRefresh) {
9474
+ s.goodsListState.goodsList = newGoodsList;
9475
+ }
9476
+ }
9477
+ } catch (e) {
9478
+ console.error('切换税率重新计算出错', e, s.goodsListState);
9479
+ }
9480
+
9481
+ case 5:
9482
+ case "end":
9483
+ return _context21.stop();
9484
+ }
9485
+ }
9486
+ }, _callee21);
9487
+ }));
9488
+
9489
+ return function (_x41) {
9490
+ return _ref22.apply(this, arguments);
9491
+ };
9492
+ }());
9493
+
9494
+ case 10:
9495
+ case "end":
9496
+ return _context22.stop();
9497
+ }
9498
+ }
9499
+ }, _callee22);
9500
+ }));
9501
+
9502
+ return function onChangeSwitchTax(_x38, _x39) {
9503
+ return _ref20.apply(this, arguments);
9504
+ };
9505
+ }();
9334
9506
 
9335
9507
  /**
9336
9508
  * 删除一个货物
@@ -10240,28 +10412,7 @@ var TaxIncludedSwitch = (function () {
10240
10412
  return e.goodsListState.isSwitchTax;
10241
10413
  }, []);
10242
10414
  var onChange = React.useCallback(function (e) {
10243
- controller.pipeline( /*#__PURE__*/function () {
10244
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
10245
- return _regeneratorRuntime().wrap(function _callee$(_context) {
10246
- while (1) {
10247
- switch (_context.prev = _context.next) {
10248
- case 0:
10249
- s.goodsListState = _objectSpread2(_objectSpread2({}, s.goodsListState), {}, {
10250
- isTaxIncluded: e
10251
- });
10252
-
10253
- case 1:
10254
- case "end":
10255
- return _context.stop();
10256
- }
10257
- }
10258
- }, _callee);
10259
- }));
10260
-
10261
- return function (_x) {
10262
- return _ref.apply(this, arguments);
10263
- };
10264
- }())();
10415
+ onChangeSwitchTax(controller, e);
10265
10416
  }, []);
10266
10417
  return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("label", {
10267
10418
  style: {
@@ -17158,7 +17309,7 @@ var SignDigtal = decorator(Form.create())(function (props) {
17158
17309
  }
17159
17310
  }) : /*#__PURE__*/React.createElement(MyDiv$1, {
17160
17311
  style: {
17161
- whiteSpace: 'pre'
17312
+ whiteSpace: 'pre-wrap'
17162
17313
  }
17163
17314
  })))), /*#__PURE__*/React.createElement(Form, {
17164
17315
  layout: 'inline',
@@ -17656,734 +17807,329 @@ function _rollBottom$1() {
17656
17807
  return _rollBottom$1.apply(this, arguments);
17657
17808
  }
17658
17809
 
17659
- var TaxIncludedSwitch$1 = (function () {
17660
- var controller = Invoice.useInvoiceController();
17661
- /** 是否含税 */
17662
-
17663
- var isTaxIncluded = controller.useMemo(function (e) {
17664
- return e.goodsListState.isTaxIncluded;
17665
- }, []);
17666
- /** 是否可以切换(含税/不含税)状态 */
17667
-
17668
- var isSwitchTax = controller.useMemo(function (e) {
17669
- return e.goodsListState.isSwitchTax;
17670
- }, []);
17671
- var onChange = React.useCallback(function (e) {
17672
- controller.pipeline( /*#__PURE__*/function () {
17673
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
17674
- return _regeneratorRuntime().wrap(function _callee$(_context) {
17675
- while (1) {
17676
- switch (_context.prev = _context.next) {
17677
- case 0:
17678
- s.goodsListState = _objectSpread2(_objectSpread2({}, s.goodsListState), {}, {
17679
- isTaxIncluded: e
17680
- });
17681
-
17682
- case 1:
17683
- case "end":
17684
- return _context.stop();
17685
- }
17686
- }
17687
- }, _callee);
17688
- }));
17810
+ /** 延迟函数 */
17689
17811
 
17690
- return function (_x) {
17691
- return _ref.apply(this, arguments);
17692
- };
17693
- }())();
17694
- }, []);
17695
- return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("label", {
17696
- style: {
17697
- marginRight: 2
17812
+ var lazyFn$2 = function lazyFn(fn) {
17813
+ var delayed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
17814
+ var timer;
17815
+ return function () {
17816
+ for (var _len = arguments.length, par = new Array(_len), _key = 0; _key < _len; _key++) {
17817
+ par[_key] = arguments[_key];
17698
17818
  }
17699
- }, "\u542B\u7A0E"), /*#__PURE__*/React.createElement(Switch, {
17700
- disabled: isSwitchTax === false,
17701
- checked: isTaxIncluded,
17702
- defaultChecked: true,
17703
- onChange: onChange
17704
- }));
17705
- });
17706
-
17707
- var _path$6;
17708
17819
 
17709
- function _extends$8() { _extends$8 = 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$8.apply(this, arguments); }
17820
+ clearTimeout(timer);
17821
+ timer = setTimeout(function () {
17822
+ timer = undefined;
17823
+ fn.apply(null, par);
17824
+ }, delayed);
17825
+ };
17826
+ };
17710
17827
 
17711
- function SvgMagnifier$1(props) {
17712
- return /*#__PURE__*/createElement("svg", _extends$8({
17713
- className: "magnifier_svg__icon",
17714
- viewBox: "0 0 1024 1024",
17715
- xmlns: "http://www.w3.org/2000/svg",
17716
- width: 200,
17717
- height: 200
17718
- }, props), _path$6 || (_path$6 = /*#__PURE__*/createElement("path", {
17719
- d: "M985.781 918.594L820.773 765.526c27.373-32.973 49.655-69.577 66.437-109.258 22.933-54.219 34.56-111.795 34.56-171.13 0-59.333-11.627-116.91-34.56-171.13-22.143-52.354-53.838-99.365-94.2-139.729s-87.377-72.056-139.73-94.199c-54.219-22.933-111.795-34.561-171.13-34.561S365.24 57.148 311.022 80.08c-52.354 22.143-99.365 53.837-139.73 94.2s-72.057 87.375-94.2 139.73c-22.932 54.218-34.56 111.795-34.56 171.13 0 59.334 11.628 116.91 34.56 171.129 22.144 52.354 53.838 99.365 94.2 139.729s87.376 72.057 139.73 94.2c54.219 22.933 111.795 34.56 171.13 34.56s116.91-11.627 171.13-34.56c45.352-19.181 86.686-45.543 123.171-78.487l165.803 153.804a31.886 31.886 0 0021.756 8.54c8.593 0 17.163-3.442 23.467-10.238 12.019-12.956 11.26-33.205-1.698-45.223zm-503.63-57.836c-207.117 0-375.62-168.502-375.62-375.62 0-207.117 168.503-375.62 375.62-375.62s375.62 168.503 375.62 375.62c0 207.118-168.503 375.62-375.62 375.62z"
17720
- })));
17721
- }
17828
+ var promptErrV$1 = {};
17829
+ /** 提示错误 */
17722
17830
 
17723
- var css_248z$k = ".kts-invoice-operate-goods-list-able .kts-invoice-operate-goods-list-search {\n width: 350px;\n border-radius: 999px;\n}\n.kts-invoice-operate-goods-list-able .kts-invoice-operate-goods-list-search input {\n border-radius: 999px;\n border-color: #b8b8b8;\n font-size: 12px;\n}\n";
17724
- styleInject(css_248z$k);
17831
+ var promptErr$1 = function promptErr(err) {
17832
+ if (!err) return false;
17833
+ if (err.errors[0].message === 'lineAmountIncludeTax need to revalidate') return true;
17834
+ if (err.errors[0].message === 'lineAmountExcludeTax need to revalidate') return true;
17835
+ if (err.errors[0].message === 'priceIncludeTax need to revalidate') return true;
17836
+ if (err.errors[0].message === 'priceExcludeTax need to revalidate') return true;
17725
17837
 
17726
- function Search$1() {
17727
- var controller = Invoice.useInvoiceController();
17838
+ if (new Date().getTime() - promptErrV$1.t > 2000 || err.errors[0].message !== promptErrV$1.m) {
17839
+ promptErrV$1.t = new Date().getTime();
17840
+ promptErrV$1.m = err.errors[0].message;
17841
+ message.error({
17842
+ content: err.errors[0].message,
17843
+ duration: 2
17844
+ });
17845
+ }
17728
17846
 
17729
- var _React$useState = React.useState(''),
17730
- _React$useState2 = _slicedToArray(_React$useState, 2),
17731
- value = _React$useState2[0],
17732
- setValue = _React$useState2[1];
17847
+ return true;
17848
+ };
17849
+ /** 清除计算中启动字段 */
17733
17850
 
17734
- var readOnly = controller.useMemo(function (s) {
17735
- return !!s.goodsListState.editGood;
17736
- }, []);
17737
- /** 是否含税 */
17738
17851
 
17739
- var isTaxIncluded = controller.useMemo(function (s) {
17740
- return s.goodsListState.isTaxIncluded;
17741
- }, []);
17742
- var onClick = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
17743
- return _regeneratorRuntime().wrap(function _callee$(_context) {
17852
+ var clearCalculatingField$1 = /*#__PURE__*/function () {
17853
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(controller) {
17854
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
17744
17855
  while (1) {
17745
- switch (_context.prev = _context.next) {
17856
+ switch (_context2.prev = _context2.next) {
17746
17857
  case 0:
17747
- _context.next = 2;
17748
- return controller.saveEditGood();
17749
-
17750
- case 2:
17751
- _context.next = 4;
17752
- return controller.wait();
17858
+ return _context2.abrupt("return", controller.run( /*#__PURE__*/function () {
17859
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
17860
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
17861
+ while (1) {
17862
+ switch (_context.prev = _context.next) {
17863
+ case 0:
17864
+ return _context.abrupt("return", s.calculatingField = '');
17753
17865
 
17754
- case 4:
17755
- if (!controller.state.goodsListState.editGood) {
17756
- _context.next = 7;
17757
- break;
17758
- }
17866
+ case 1:
17867
+ case "end":
17868
+ return _context.stop();
17869
+ }
17870
+ }
17871
+ }, _callee);
17872
+ }));
17759
17873
 
17760
- message$1.error({
17761
- content: '你正在编辑一个货物',
17762
- key: '你正在编辑一个货物'
17763
- });
17764
- return _context.abrupt("return");
17874
+ return function (_x2) {
17875
+ return _ref2.apply(this, arguments);
17876
+ };
17877
+ }()));
17765
17878
 
17766
- case 7:
17879
+ case 1:
17767
17880
  case "end":
17768
- return _context.stop();
17881
+ return _context2.stop();
17769
17882
  }
17770
17883
  }
17771
- }, _callee);
17772
- })), []);
17773
- React.useEffect(function () {
17774
- controller.run( /*#__PURE__*/function () {
17775
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
17776
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
17777
- while (1) {
17778
- switch (_context2.prev = _context2.next) {
17779
- case 0:
17780
- s.goodsListState.searchValue = value.trim();
17781
-
17782
- case 1:
17783
- case "end":
17784
- return _context2.stop();
17785
- }
17786
- }
17787
- }, _callee2);
17788
- }));
17884
+ }, _callee2);
17885
+ }));
17789
17886
 
17790
- return function (_x) {
17791
- return _ref2.apply(this, arguments);
17792
- };
17793
- }());
17794
- }, [value, controller]);
17795
- return /*#__PURE__*/React.createElement(Input$1, {
17796
- readOnly: readOnly,
17797
- value: value,
17798
- className: "kts-invoice-operate-goods-list-search",
17799
- placeholder: "\u8BF7\u60A8\u8F93\u5165\u9879\u76EE\u540D\u79F0\u3001\u89C4\u683C\u578B\u53F7\u3001\u91D1\u989D(".concat(isTaxIncluded ? '含税' : '不含税', ")\u641C\u7D22"),
17800
- prefix: /*#__PURE__*/React.createElement(Icon$1, {
17801
- component: SvgMagnifier$1,
17802
- style: {
17803
- color: "#b8b8b8"
17804
- }
17805
- }),
17806
- onChange: function onChange(e) {
17807
- setValue(e.target.value);
17808
- },
17809
- onClick: onClick
17810
- });
17811
- }
17812
-
17813
- var css_248z$l = ".kts-invoice-operate-goods-list-itemName-drag-container-u {\n position: relative;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-u::after {\n content: \" \";\n width: 100%;\n height: 2px;\n background: #0074ff;\n position: absolute;\n left: 0;\n top: 0;\n z-index: 9999;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-d {\n position: relative;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-d::after {\n content: \" \";\n width: 100%;\n height: 2px;\n background: #0074ff;\n position: absolute;\n left: 0;\n bottom: 0;\n z-index: 9999;\n}\n";
17814
- styleInject(css_248z$l);
17815
-
17816
- function TableRow$1(props) {
17817
- var rowKey = props['data-row-key'];
17818
- var controller = Invoice.useInvoiceController();
17819
- var goodsMap = controller.useMemo(function (s) {
17820
- return s.goodsListState.goodsMap;
17821
- }, []);
17822
- /** 当前拖动中的货品索引 */
17823
-
17824
- var site = controller.useMemo(function (s) {
17825
- return s.goodsListState.drag.site;
17826
- }, []);
17827
- var current = controller.useMemo(function (s) {
17828
- return s.goodsListState.drag.current;
17829
- }, []);
17830
- var container = controller.useMemo(function (s) {
17831
- return s.goodsListState.drag.container;
17832
- }, []);
17833
- var discount = React.useMemo(function () {
17834
- var i = goodsMap.get(rowKey);
17835
- if (!i) return undefined;
17887
+ return function clearCalculatingField(_x) {
17888
+ return _ref.apply(this, arguments);
17889
+ };
17890
+ }();
17891
+ /** 数量改变了 */
17836
17892
 
17837
- if (i.lineAttribute === LineAttributeType$1.折扣行) {
17838
- return 'kts-invoice-operate-goods-be-discount';
17839
- } else if (i.lineAttribute === LineAttributeType$1.被折扣行) {
17840
- return 'kts-invoice-operate-goods-discount';
17841
- } else {
17842
- return undefined;
17843
- }
17844
- }, [rowKey, goodsMap]);
17845
- return rowKey === current && current ? /*#__PURE__*/React.createElement("tr", {
17846
- style: {
17847
- height: 50,
17848
- position: 'relative'
17849
- }
17850
- }, /*#__PURE__*/React.createElement("div", {
17851
- style: {
17852
- height: 0.5,
17853
- width: '100%',
17854
- background: '#E6E6E6',
17855
- position: 'absolute',
17856
- bottom: 0
17857
- }
17858
- })) :
17859
- /*#__PURE__*/
17860
- // <tr {...props} className={classnames(props.className, discount, (rowKey === container && current) ? 'kts-invoice-operate-goods-list-itemName-drag-container' : '')} />
17861
- React.createElement("tr", _objectSpread2(_objectSpread2({}, props), {}, {
17862
- className: classNames(props.className, discount, rowKey === container && current ? 'kts-invoice-operate-goods-list-itemName-drag-container-' + site : undefined)
17863
- }));
17864
- }
17893
+ var onChangeQuantity$1 = lazyFn$2(function (controller, form, record) {
17894
+ form.validateFields( /*#__PURE__*/function () {
17895
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(err, values) {
17896
+ var calculatingDigits, quantity, priceIncludeTax, lineAmountIncludeTax, _lineAmountIncludeTax, _priceIncludeTax, priceExcludeTax, lineAmountExcludeTax, _lineAmountExcludeTax, _priceExcludeTax;
17865
17897
 
17866
- var _g$2, _defs$4;
17898
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
17899
+ while (1) {
17900
+ switch (_context3.prev = _context3.next) {
17901
+ case 0:
17902
+ err = err || {};
17867
17903
 
17868
- function _extends$9() { _extends$9 = 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$9.apply(this, arguments); }
17904
+ if (!(!values.quantity && values.quantity !== 0)) {
17905
+ _context3.next = 7;
17906
+ break;
17907
+ }
17869
17908
 
17870
- function SvgPlus$1(props) {
17871
- return /*#__PURE__*/createElement("svg", _extends$9({
17872
- xmlns: "http://www.w3.org/2000/svg",
17873
- width: 16,
17874
- height: 15
17875
- }, props), _g$2 || (_g$2 = /*#__PURE__*/createElement("g", {
17876
- clipPath: "url(#plus_svg__clip0_715_360)"
17877
- }, /*#__PURE__*/createElement("path", {
17878
- d: "M8 14.531A7.031 7.031 0 118 .468a7.031 7.031 0 010 14.063zm0-.937A6.094 6.094 0 108 1.406a6.094 6.094 0 000 12.188z"
17879
- }), /*#__PURE__*/createElement("path", {
17880
- d: "M4.25 7.969a.469.469 0 010-.938h7.5a.47.47 0 010 .938h-7.5z"
17881
- }), /*#__PURE__*/createElement("path", {
17882
- d: "M7.531 3.75a.469.469 0 01.938 0v7.5a.47.47 0 01-.938 0v-7.5z"
17883
- }))), _defs$4 || (_defs$4 = /*#__PURE__*/createElement("defs", null, /*#__PURE__*/createElement("clipPath", {
17884
- id: "plus_svg__clip0_715_360"
17885
- }, /*#__PURE__*/createElement("path", {
17886
- transform: "translate(.5)",
17887
- d: "M0 0h15v15H0z"
17888
- })))));
17889
- }
17909
+ _context3.next = 4;
17910
+ return controller.setEditGood({
17911
+ quantity: undefined
17912
+ });
17890
17913
 
17891
- var Text$5 = Typography.Text;
17892
- var TitleText$1 = (function (props) {
17893
- var rules = props.rules,
17894
- children = props.children;
17895
- var required = React.useMemo(function () {
17896
- return (rules === null || rules === void 0 ? void 0 : rules.some(function (e) {
17897
- return !!e.required;
17898
- })) || props.required;
17899
- }, [rules, props.required]);
17900
- return /*#__PURE__*/React.createElement(React.Fragment, null, required ? /*#__PURE__*/React.createElement(Text$5, {
17901
- type: "danger"
17902
- }, "*") : /*#__PURE__*/React.createElement(React.Fragment, null), children);
17903
- });
17914
+ case 4:
17915
+ _context3.next = 6;
17916
+ return clearCalculatingField$1(controller);
17904
17917
 
17905
- var css_248z$m = ".kts-invoice-operate-goods-list-itemName-input {\n display: flex;\n flex: 1;\n padding-left: 0;\n height: 31px;\n}\n";
17906
- styleInject(css_248z$m);
17918
+ case 6:
17919
+ return _context3.abrupt("return");
17907
17920
 
17908
- function ItemNameInput$1(props) {
17909
- var controller = Invoice.useInvoiceController();
17910
- var autoComplete = controller.useMemo(function (s) {
17911
- return s.autoComplete;
17912
- }, []);
17921
+ case 7:
17922
+ if (!err.quantity) {
17923
+ _context3.next = 11;
17924
+ break;
17925
+ }
17913
17926
 
17914
- var _React$useState = React.useState([]),
17915
- _React$useState2 = _slicedToArray(_React$useState, 2),
17916
- options = _React$useState2[0],
17917
- setOptions = _React$useState2[1];
17927
+ _context3.next = 10;
17928
+ return clearCalculatingField$1(controller);
17918
17929
 
17919
- var _React$useState3 = React.useState(null),
17920
- _React$useState4 = _slicedToArray(_React$useState3, 2),
17921
- selectLine = _React$useState4[0],
17922
- setSelectLine = _React$useState4[1];
17930
+ case 10:
17931
+ return _context3.abrupt("return");
17923
17932
 
17924
- var onChange = React.useCallback(function (e) {
17925
- var event = _objectSpread2({}, e);
17933
+ case 11:
17934
+ calculatingDigits = controller.state.calculatingDigits;
17935
+ quantity = format15(values.quantity, calculatingDigits);
17936
+ _context3.next = 16;
17937
+ return controller.setEditGood({
17938
+ quantity: quantity
17939
+ });
17926
17940
 
17927
- props.onChange && props.onChange(event);
17928
- }, []);
17929
- var onBlur = React.useCallback( /*#__PURE__*/function () {
17930
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchText) {
17931
- var taxCategoryData, params;
17932
- return _regeneratorRuntime().wrap(function _callee$(_context) {
17933
- while (1) {
17934
- switch (_context.prev = _context.next) {
17935
- case 0:
17936
- _context.prev = 0;
17941
+ case 16:
17942
+ form.setFieldsValue({
17943
+ quantity: quantity
17944
+ }); // 是否含税
17937
17945
 
17938
- if (!autoComplete.onItemNameBlur) {
17939
- _context.next = 8;
17946
+ if (!controller.state.goodsListState.isTaxIncluded) {
17947
+ _context3.next = 36;
17940
17948
  break;
17941
17949
  }
17942
17950
 
17943
- if (selectLine === null || selectLine === void 0 ? void 0 : selectLine.shorthand) {
17944
- _context.next = 7;
17951
+ if (!(!err.priceIncludeTax && values.priceIncludeTax)) {
17952
+ _context3.next = 26;
17945
17953
  break;
17946
17954
  }
17947
17955
 
17948
- _context.next = 5;
17949
- return autoComplete.onItemNameBlur(searchText);
17956
+ // 可以找到 单价(含税)
17957
+ priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
17958
+ lineAmountIncludeTax = format2(evaluate("".concat(priceIncludeTax, " * ").concat(quantity)));
17959
+ form.setFieldsValue({
17960
+ lineAmountIncludeTax: lineAmountIncludeTax
17961
+ });
17962
+ _context3.next = 24;
17963
+ return controller.setEditGood({
17964
+ lineAmountIncludeTax: lineAmountIncludeTax
17965
+ });
17950
17966
 
17951
- case 5:
17952
- taxCategoryData = _context.sent;
17967
+ case 24:
17968
+ _context3.next = 32;
17969
+ break;
17953
17970
 
17954
- if (taxCategoryData && taxCategoryData[0]) {
17955
- params = {
17956
- taxClassificationCode: taxCategoryData[0].taxCategoryCode,
17957
- shorthand: taxCategoryData[0].shorthand
17958
- };
17959
- controller.itemNameBlur(params);
17971
+ case 26:
17972
+ if (!(!err.lineAmountIncludeTax && values.lineAmountIncludeTax)) {
17973
+ _context3.next = 32;
17974
+ break;
17960
17975
  }
17961
17976
 
17962
- case 7:
17963
- setSelectLine(null);
17977
+ // 可以找到 金额(含税)
17978
+ _lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
17979
+ _priceIncludeTax = format15(evaluate("".concat(_lineAmountIncludeTax, " / ").concat(quantity)), calculatingDigits);
17980
+ form.setFieldsValue({
17981
+ priceIncludeTax: _priceIncludeTax
17982
+ });
17983
+ _context3.next = 32;
17984
+ return controller.setEditGood({
17985
+ priceIncludeTax: _priceIncludeTax
17986
+ });
17964
17987
 
17965
- case 8:
17966
- _context.next = 13;
17967
- break;
17988
+ case 32:
17989
+ _context3.next = 34;
17990
+ return updateUnitPriceExcludingTax$1(controller, form, record);
17968
17991
 
17969
- case 10:
17970
- _context.prev = 10;
17971
- _context.t0 = _context["catch"](0);
17972
- throw _context.t0;
17992
+ case 34:
17993
+ _context3.next = 52;
17994
+ break;
17973
17995
 
17974
- case 13:
17975
- case "end":
17976
- return _context.stop();
17977
- }
17978
- }
17979
- }, _callee, null, [[0, 10]]);
17980
- }));
17996
+ case 36:
17997
+ if (!(!err.priceExcludeTax && values.priceExcludeTax)) {
17998
+ _context3.next = 44;
17999
+ break;
18000
+ }
17981
18001
 
17982
- return function (_x) {
17983
- return _ref.apply(this, arguments);
17984
- };
17985
- }(), [autoComplete.onItemNameBlur, selectLine, props.editGood]);
17986
- var onChangeAutoComplete = React.useCallback(function (itemName) {
17987
- var record = options.filter(function (e) {
17988
- return e.itemName === itemName;
17989
- })[0];
17990
- if (!record) return;
17991
- controller.importGoodsDrawer(record);
17992
- }, [options, controller]);
17993
- var onSearch = React.useCallback( /*#__PURE__*/function () {
17994
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(searchText) {
17995
- var list;
17996
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
17997
- while (1) {
17998
- switch (_context2.prev = _context2.next) {
17999
- case 0:
18000
- _context2.prev = 0;
18002
+ // 可以找到 单价(不含税)
18003
+ priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
18004
+ lineAmountExcludeTax = format2(evaluate("".concat(quantity, " * ").concat(priceExcludeTax)));
18005
+ form.setFieldsValue({
18006
+ lineAmountExcludeTax: lineAmountExcludeTax
18007
+ });
18008
+ _context3.next = 42;
18009
+ return controller.setEditGood({
18010
+ lineAmountExcludeTax: lineAmountExcludeTax,
18011
+ quantity: quantity
18012
+ });
18001
18013
 
18002
- if (!autoComplete.onItemNameSearch) {
18003
- _context2.next = 9;
18014
+ case 42:
18015
+ _context3.next = 50;
18016
+ break;
18017
+
18018
+ case 44:
18019
+ if (!(!err.lineAmountExcludeTax && values.lineAmountExcludeTax)) {
18020
+ _context3.next = 50;
18004
18021
  break;
18005
18022
  }
18006
18023
 
18007
- _context2.t0 = _toConsumableArray;
18008
- _context2.next = 5;
18009
- return autoComplete.onItemNameSearch(searchText);
18010
-
18011
- case 5:
18012
- _context2.t1 = _context2.sent;
18013
- list = (0, _context2.t0)(_context2.t1);
18014
- console.log('===> list', list);
18015
- setOptions(list);
18024
+ // 可以找到 金额(不含税)
18025
+ _lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
18026
+ _priceExcludeTax = format15(evaluate("".concat(_lineAmountExcludeTax, " / ").concat(quantity)), calculatingDigits);
18027
+ form.setFieldsValue({
18028
+ priceExcludeTax: _priceExcludeTax
18029
+ });
18030
+ _context3.next = 50;
18031
+ return controller.setEditGood({
18032
+ priceExcludeTax: _priceExcludeTax,
18033
+ quantity: quantity
18034
+ });
18016
18035
 
18017
- case 9:
18018
- _context2.next = 15;
18019
- break;
18036
+ case 50:
18037
+ _context3.next = 52;
18038
+ return updateUnitPriceTax$1(controller, form, record);
18020
18039
 
18021
- case 11:
18022
- _context2.prev = 11;
18023
- _context2.t2 = _context2["catch"](0);
18024
- setOptions([]);
18025
- throw _context2.t2;
18040
+ case 52:
18041
+ _context3.next = 54;
18042
+ return clearCalculatingField$1(controller);
18026
18043
 
18027
- case 15:
18044
+ case 54:
18028
18045
  case "end":
18029
- return _context2.stop();
18046
+ return _context3.stop();
18030
18047
  }
18031
18048
  }
18032
- }, _callee2, null, [[0, 11]]);
18049
+ }, _callee3);
18033
18050
  }));
18034
18051
 
18035
- return function (_x2) {
18036
- return _ref2.apply(this, arguments);
18052
+ return function (_x3, _x4) {
18053
+ return _ref3.apply(this, arguments);
18037
18054
  };
18038
- }(), [autoComplete.onItemNameSearch]);
18039
- console.log('===> options', options);
18040
- return /*#__PURE__*/React.createElement("div", {
18041
- className: 'kts-invoice-operate-goods-list-itemName-input'
18042
- }, props.shorthand && /*#__PURE__*/React.createElement("span", {
18043
- style: {
18044
- alignSelf: 'center',
18045
- fontSize: 12
18046
- }
18047
- }, "*", props.shorthand, "*"), /*#__PURE__*/React.createElement(AutoComplete$1, {
18048
- onSearch: onSearch,
18049
- value: props.value,
18050
- options: options.map(function (e) {
18051
- return {
18052
- value: e.itemName
18053
- };
18054
- }),
18055
- onSelect: onChangeAutoComplete
18056
- }, /*#__PURE__*/React.createElement(Input$1, {
18057
- style: {
18058
- height: '100%'
18059
- },
18060
- onChange: onChange,
18061
- suffix: props.suffix,
18062
- onBlur: onBlur
18063
- })));
18064
- }
18065
-
18066
- /** 延迟函数 */
18067
-
18068
- var lazyFn$2 = function lazyFn(fn) {
18069
- var delayed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
18070
- var timer;
18071
- return function () {
18072
- for (var _len = arguments.length, par = new Array(_len), _key = 0; _key < _len; _key++) {
18073
- par[_key] = arguments[_key];
18074
- }
18075
-
18076
- clearTimeout(timer);
18077
- timer = setTimeout(function () {
18078
- timer = undefined;
18079
- fn.apply(null, par);
18080
- }, delayed);
18081
- };
18082
- };
18083
-
18084
- var promptErrV$1 = {};
18085
- /** 提示错误 */
18086
-
18087
- var promptErr$1 = function promptErr(err) {
18088
- if (!err) return false;
18089
- if (err.errors[0].message === 'lineAmountIncludeTax need to revalidate') return true;
18090
- if (err.errors[0].message === 'lineAmountExcludeTax need to revalidate') return true;
18091
- if (err.errors[0].message === 'priceIncludeTax need to revalidate') return true;
18092
- if (err.errors[0].message === 'priceExcludeTax need to revalidate') return true;
18093
-
18094
- if (new Date().getTime() - promptErrV$1.t > 2000 || err.errors[0].message !== promptErrV$1.m) {
18095
- promptErrV$1.t = new Date().getTime();
18096
- promptErrV$1.m = err.errors[0].message;
18097
- message.error({
18098
- content: err.errors[0].message,
18099
- duration: 2
18100
- });
18101
- }
18102
-
18103
- return true;
18104
- };
18105
- /** 清除计算中启动字段 */
18106
-
18107
-
18108
- var clearCalculatingField$1 = /*#__PURE__*/function () {
18109
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(controller) {
18110
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
18111
- while (1) {
18112
- switch (_context2.prev = _context2.next) {
18113
- case 0:
18114
- return _context2.abrupt("return", controller.run( /*#__PURE__*/function () {
18115
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
18116
- return _regeneratorRuntime().wrap(function _callee$(_context) {
18117
- while (1) {
18118
- switch (_context.prev = _context.next) {
18119
- case 0:
18120
- return _context.abrupt("return", s.calculatingField = '');
18121
-
18122
- case 1:
18123
- case "end":
18124
- return _context.stop();
18125
- }
18126
- }
18127
- }, _callee);
18128
- }));
18129
-
18130
- return function (_x2) {
18131
- return _ref2.apply(this, arguments);
18132
- };
18133
- }()));
18134
-
18135
- case 1:
18136
- case "end":
18137
- return _context2.stop();
18138
- }
18139
- }
18140
- }, _callee2);
18141
- }));
18142
-
18143
- return function clearCalculatingField(_x) {
18144
- return _ref.apply(this, arguments);
18145
- };
18146
- }();
18147
- /** 数量改变了 */
18055
+ }());
18056
+ }, 1000);
18057
+ /** 单价(含税) */
18148
18058
 
18149
- var onChangeQuantity$1 = lazyFn$2(function (controller, form, record) {
18059
+ var onChangePriceIncludeTax$1 = lazyFn$2(function (controller, form, record) {
18150
18060
  form.validateFields( /*#__PURE__*/function () {
18151
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(err, values) {
18152
- var calculatingDigits, quantity, priceIncludeTax, lineAmountIncludeTax, _lineAmountIncludeTax, _priceIncludeTax, priceExcludeTax, lineAmountExcludeTax, _lineAmountExcludeTax, _priceExcludeTax;
18061
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(err, values) {
18062
+ var calculatingDigits, priceIncludeTax, quantity, lineAmountIncludeTax, _lineAmountIncludeTax2, _quantity;
18153
18063
 
18154
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
18064
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
18155
18065
  while (1) {
18156
- switch (_context3.prev = _context3.next) {
18066
+ switch (_context4.prev = _context4.next) {
18157
18067
  case 0:
18158
18068
  err = err || {};
18159
18069
 
18160
- if (!(!values.quantity && values.quantity !== 0)) {
18161
- _context3.next = 7;
18070
+ if (!(!values.priceIncludeTax && values.priceIncludeTax !== 0)) {
18071
+ _context4.next = 7;
18162
18072
  break;
18163
18073
  }
18164
18074
 
18165
- _context3.next = 4;
18075
+ _context4.next = 4;
18166
18076
  return controller.setEditGood({
18167
- quantity: undefined
18077
+ priceIncludeTax: undefined,
18078
+ priceExcludeTax: undefined
18168
18079
  });
18169
18080
 
18170
18081
  case 4:
18171
- _context3.next = 6;
18082
+ _context4.next = 6;
18172
18083
  return clearCalculatingField$1(controller);
18173
18084
 
18174
18085
  case 6:
18175
- return _context3.abrupt("return");
18086
+ return _context4.abrupt("return");
18176
18087
 
18177
18088
  case 7:
18178
- if (!err.quantity) {
18179
- _context3.next = 11;
18089
+ if (!err.priceIncludeTax) {
18090
+ _context4.next = 11;
18180
18091
  break;
18181
18092
  }
18182
18093
 
18183
- _context3.next = 10;
18094
+ _context4.next = 10;
18184
18095
  return clearCalculatingField$1(controller);
18185
18096
 
18186
18097
  case 10:
18187
- return _context3.abrupt("return");
18098
+ return _context4.abrupt("return");
18188
18099
 
18189
18100
  case 11:
18190
18101
  calculatingDigits = controller.state.calculatingDigits;
18191
- quantity = format15(values.quantity, calculatingDigits);
18192
- _context3.next = 16;
18102
+ priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
18103
+ _context4.next = 15;
18193
18104
  return controller.setEditGood({
18194
- quantity: quantity
18105
+ priceIncludeTax: priceIncludeTax
18195
18106
  });
18196
18107
 
18197
- case 16:
18108
+ case 15:
18198
18109
  form.setFieldsValue({
18199
- quantity: quantity
18200
- }); // 是否含税
18201
-
18202
- if (!controller.state.goodsListState.isTaxIncluded) {
18203
- _context3.next = 36;
18204
- break;
18205
- }
18110
+ priceIncludeTax: priceIncludeTax
18111
+ }); // 是否有数量
18206
18112
 
18207
- if (!(!err.priceIncludeTax && values.priceIncludeTax)) {
18208
- _context3.next = 26;
18113
+ if (!(!err.quantity && values.quantity)) {
18114
+ _context4.next = 24;
18209
18115
  break;
18210
18116
  }
18211
18117
 
18212
- // 可以找到 单价(含税)
18213
- priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
18214
- lineAmountIncludeTax = format2(evaluate("".concat(priceIncludeTax, " * ").concat(quantity)));
18118
+ quantity = format15(values.quantity, calculatingDigits);
18119
+ lineAmountIncludeTax = format2(evaluate("".concat(quantity, " * ").concat(priceIncludeTax)));
18215
18120
  form.setFieldsValue({
18216
18121
  lineAmountIncludeTax: lineAmountIncludeTax
18217
18122
  });
18218
- _context3.next = 24;
18123
+ _context4.next = 22;
18219
18124
  return controller.setEditGood({
18220
18125
  lineAmountIncludeTax: lineAmountIncludeTax
18221
18126
  });
18222
18127
 
18223
- case 24:
18224
- _context3.next = 32;
18128
+ case 22:
18129
+ _context4.next = 30;
18225
18130
  break;
18226
18131
 
18227
- case 26:
18228
- if (!(!err.lineAmountIncludeTax && values.lineAmountIncludeTax)) {
18229
- _context3.next = 32;
18230
- break;
18231
- }
18232
-
18233
- // 可以找到 金额(含税)
18234
- _lineAmountIncludeTax = format2(values.lineAmountIncludeTax);
18235
- _priceIncludeTax = format15(evaluate("".concat(_lineAmountIncludeTax, " / ").concat(quantity)), calculatingDigits);
18236
- form.setFieldsValue({
18237
- priceIncludeTax: _priceIncludeTax
18238
- });
18239
- _context3.next = 32;
18240
- return controller.setEditGood({
18241
- priceIncludeTax: _priceIncludeTax
18242
- });
18243
-
18244
- case 32:
18245
- _context3.next = 34;
18246
- return updateUnitPriceExcludingTax$1(controller, form, record);
18247
-
18248
- case 34:
18249
- _context3.next = 52;
18250
- break;
18251
-
18252
- case 36:
18253
- if (!(!err.priceExcludeTax && values.priceExcludeTax)) {
18254
- _context3.next = 44;
18255
- break;
18256
- }
18257
-
18258
- priceExcludeTax = format15(values.priceExcludeTax, calculatingDigits);
18259
- lineAmountExcludeTax = format2(evaluate("".concat(quantity, " * ").concat(priceExcludeTax)));
18260
- form.setFieldsValue({
18261
- lineAmountExcludeTax: lineAmountExcludeTax
18262
- });
18263
- _context3.next = 42;
18264
- return controller.setEditGood({
18265
- lineAmountExcludeTax: lineAmountExcludeTax,
18266
- quantity: quantity
18267
- });
18268
-
18269
- case 42:
18270
- _context3.next = 50;
18271
- break;
18272
-
18273
- case 44:
18274
- if (!(!err.lineAmountExcludeTax && values.lineAmountExcludeTax)) {
18275
- _context3.next = 50;
18276
- break;
18277
- }
18278
-
18279
- _lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
18280
- _priceExcludeTax = format15(evaluate("".concat(_lineAmountExcludeTax, " / ").concat(quantity)), calculatingDigits);
18281
- form.setFieldsValue({
18282
- priceExcludeTax: _priceExcludeTax
18283
- });
18284
- _context3.next = 50;
18285
- return controller.setEditGood({
18286
- priceExcludeTax: _priceExcludeTax,
18287
- quantity: quantity
18288
- });
18289
-
18290
- case 50:
18291
- _context3.next = 52;
18292
- return updateUnitPriceTax$1(controller, form, record);
18293
-
18294
- case 52:
18295
- _context3.next = 54;
18296
- return clearCalculatingField$1(controller);
18297
-
18298
- case 54:
18299
- case "end":
18300
- return _context3.stop();
18301
- }
18302
- }
18303
- }, _callee3);
18304
- }));
18305
-
18306
- return function (_x3, _x4) {
18307
- return _ref3.apply(this, arguments);
18308
- };
18309
- }());
18310
- }, 1000);
18311
- /** 单价(含税) */
18312
-
18313
- var onChangePriceIncludeTax$1 = lazyFn$2(function (controller, form, record) {
18314
- form.validateFields( /*#__PURE__*/function () {
18315
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(err, values) {
18316
- var calculatingDigits, priceIncludeTax, quantity, lineAmountIncludeTax, _lineAmountIncludeTax2, _quantity;
18317
-
18318
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
18319
- while (1) {
18320
- switch (_context4.prev = _context4.next) {
18321
- case 0:
18322
- err = err || {};
18323
-
18324
- if (!(!values.priceIncludeTax && values.priceIncludeTax !== 0)) {
18325
- _context4.next = 7;
18326
- break;
18327
- }
18328
-
18329
- _context4.next = 4;
18330
- return controller.setEditGood({
18331
- priceIncludeTax: undefined,
18332
- priceExcludeTax: undefined
18333
- });
18334
-
18335
- case 4:
18336
- _context4.next = 6;
18337
- return clearCalculatingField$1(controller);
18338
-
18339
- case 6:
18340
- return _context4.abrupt("return");
18341
-
18342
- case 7:
18343
- if (!err.priceIncludeTax) {
18344
- _context4.next = 11;
18345
- break;
18346
- }
18347
-
18348
- _context4.next = 10;
18349
- return clearCalculatingField$1(controller);
18350
-
18351
- case 10:
18352
- return _context4.abrupt("return");
18353
-
18354
- case 11:
18355
- calculatingDigits = controller.state.calculatingDigits;
18356
- priceIncludeTax = format15(values.priceIncludeTax, calculatingDigits);
18357
- _context4.next = 15;
18358
- return controller.setEditGood({
18359
- priceIncludeTax: priceIncludeTax
18360
- });
18361
-
18362
- case 15:
18363
- form.setFieldsValue({
18364
- priceIncludeTax: priceIncludeTax
18365
- }); // 是否有数量
18366
-
18367
- if (!(!err.quantity && values.quantity)) {
18368
- _context4.next = 24;
18369
- break;
18370
- }
18371
-
18372
- quantity = format15(values.quantity, calculatingDigits);
18373
- lineAmountIncludeTax = format2(evaluate("".concat(quantity, " * ").concat(priceIncludeTax)));
18374
- form.setFieldsValue({
18375
- lineAmountIncludeTax: lineAmountIncludeTax
18376
- });
18377
- _context4.next = 22;
18378
- return controller.setEditGood({
18379
- lineAmountIncludeTax: lineAmountIncludeTax
18380
- });
18381
-
18382
- case 22:
18383
- _context4.next = 30;
18384
- break;
18385
-
18386
- case 24:
18132
+ case 24:
18387
18133
  if (!(!err.lineAmountIncludeTax && values.lineAmountIncludeTax)) {
18388
18134
  _context4.next = 30;
18389
18135
  break;
@@ -18830,6 +18576,7 @@ var updateUnitPriceExcludingTax$1 = /*#__PURE__*/function () {
18830
18576
  while (1) {
18831
18577
  switch (_context9.prev = _context9.next) {
18832
18578
  case 0:
18579
+ console.log('含税 => 更新(不含税');
18833
18580
  err = err || {};
18834
18581
  /** 税额 */
18835
18582
 
@@ -18843,12 +18590,12 @@ var updateUnitPriceExcludingTax$1 = /*#__PURE__*/function () {
18843
18590
  form.setFieldsValue({
18844
18591
  taxAmount: taxAmount
18845
18592
  });
18846
- _context9.next = 6;
18593
+ _context9.next = 7;
18847
18594
  return controller.setEditGood({
18848
18595
  taxAmount: taxAmount
18849
18596
  });
18850
18597
 
18851
- case 6:
18598
+ case 7:
18852
18599
  // 计算 金额(不含税)
18853
18600
  if ((taxAmount || taxAmount === 0) && !promptErr$1(err.lineAmountIncludeTax)) {
18854
18601
  lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax, taxAmount);
@@ -18857,12 +18604,12 @@ var updateUnitPriceExcludingTax$1 = /*#__PURE__*/function () {
18857
18604
  form.setFieldsValue({
18858
18605
  lineAmountExcludeTax: lineAmountExcludeTax
18859
18606
  });
18860
- _context9.next = 10;
18607
+ _context9.next = 11;
18861
18608
  return controller.setEditGood({
18862
18609
  lineAmountExcludeTax: lineAmountExcludeTax
18863
18610
  });
18864
18611
 
18865
- case 10:
18612
+ case 11:
18866
18613
  // 单价(不含税)
18867
18614
  if (lineAmountExcludeTax && !promptErr$1(err.quantity)) {
18868
18615
  priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity, controller.state.calculatingDigits);
@@ -18871,12 +18618,12 @@ var updateUnitPriceExcludingTax$1 = /*#__PURE__*/function () {
18871
18618
  form.setFieldsValue({
18872
18619
  priceExcludeTax: priceExcludeTax
18873
18620
  });
18874
- _context9.next = 14;
18621
+ _context9.next = 15;
18875
18622
  return controller.setEditGood({
18876
18623
  priceExcludeTax: priceExcludeTax
18877
18624
  });
18878
18625
 
18879
- case 14:
18626
+ case 15:
18880
18627
  case "end":
18881
18628
  return _context9.stop();
18882
18629
  }
@@ -18919,10 +18666,11 @@ var updateUnitPriceTax$1 = /*#__PURE__*/function () {
18919
18666
  while (1) {
18920
18667
  switch (_context11.prev = _context11.next) {
18921
18668
  case 0:
18669
+ console.log('不含税 => 更新(含税)');
18922
18670
  err = err || {};
18923
18671
 
18924
18672
  if (!(!err.taxRat && (values.taxRate || values.taxRate === 0) && !promptErr$1(err.lineAmountExcludeTax) && (values.lineAmountExcludeTax || values.lineAmountExcludeTax === 0))) {
18925
- _context11.next = 17;
18673
+ _context11.next = 18;
18926
18674
  break;
18927
18675
  }
18928
18676
 
@@ -18930,175 +18678,748 @@ var updateUnitPriceTax$1 = /*#__PURE__*/function () {
18930
18678
 
18931
18679
  lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
18932
18680
  lineAmountIncludeTax = format2(evaluate("".concat(lineAmountExcludeTax, " * (1+(").concat(values.taxRate, "/100))")));
18933
- _context11.next = 7;
18681
+ _context11.next = 8;
18934
18682
  return controller.setEditGood({
18935
18683
  lineAmountIncludeTax: lineAmountIncludeTax
18936
18684
  });
18937
18685
 
18938
- case 7:
18686
+ case 8:
18939
18687
  if (!(!err.quantity && values.quantity)) {
18940
- _context11.next = 11;
18688
+ _context11.next = 12;
18941
18689
  break;
18942
18690
  }
18943
18691
 
18944
18692
  priceIncludeTax = format15(evaluate("".concat(lineAmountIncludeTax, " / ").concat(values.quantity)), calculatingDigits);
18945
- _context11.next = 11;
18693
+ _context11.next = 12;
18946
18694
  return controller.setEditGood({
18947
18695
  priceIncludeTax: priceIncludeTax
18948
18696
  });
18949
18697
 
18950
- case 11:
18698
+ case 12:
18951
18699
  // 税额 = 金额(含税)-金额(不含税)
18952
18700
  taxAmount = evaluate("".concat(lineAmountIncludeTax, " - ").concat(lineAmountExcludeTax));
18953
18701
  form.setFieldsValue({
18954
18702
  taxAmount: taxAmount
18955
18703
  });
18956
- _context11.next = 15;
18704
+ _context11.next = 16;
18957
18705
  return controller.setEditGood({
18958
18706
  taxAmount: taxAmount
18959
18707
  });
18960
18708
 
18961
- case 15:
18962
- _context11.next = 20;
18709
+ case 16:
18710
+ _context11.next = 21;
18711
+ break;
18712
+
18713
+ case 18:
18714
+ form.setFieldsValue({
18715
+ taxAmount: undefined
18716
+ });
18717
+ _context11.next = 21;
18718
+ return controller.setEditGood({
18719
+ taxAmount: undefined
18720
+ });
18721
+
18722
+ case 21:
18723
+ // 单价(含税) = 单价(不含税) * (1+税率)
18724
+ // if (
18725
+ // !err.taxRat &&
18726
+ // (values.taxRate || values.taxRate === 0) &&
18727
+ // !promptErr(err.priceExcludeTax) &&
18728
+ // (values.priceExcludeTax || values.priceExcludeTax === 0)
18729
+ // ) {
18730
+ // const priceExcludeTax = format15(values.priceExcludeTax);
18731
+ // const priceIncludeTax = format15(evaluate(`${priceExcludeTax} * (1+(${values.taxRate}/100))`));
18732
+ // await controller.setEditGood({ priceIncludeTax });
18733
+ // }
18734
+ resolve(undefined);
18735
+
18736
+ case 22:
18737
+ case "end":
18738
+ return _context11.stop();
18739
+ }
18740
+ }
18741
+ }, _callee11);
18742
+ }));
18743
+
18744
+ return function (_x23, _x24) {
18745
+ return _ref12.apply(this, arguments);
18746
+ };
18747
+ }());
18748
+ }));
18749
+
18750
+ case 1:
18751
+ case "end":
18752
+ return _context12.stop();
18753
+ }
18754
+ }
18755
+ }, _callee12);
18756
+ }));
18757
+
18758
+ return function updateUnitPriceTax(_x20, _x21, _x22) {
18759
+ return _ref11.apply(this, arguments);
18760
+ };
18761
+ }();
18762
+ /** 修改了 项目名称 */
18763
+
18764
+ var onChangeItemName$1 = /*#__PURE__*/function () {
18765
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(controller, form, record) {
18766
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
18767
+ while (1) {
18768
+ switch (_context17.prev = _context17.next) {
18769
+ case 0:
18770
+ controller.run( /*#__PURE__*/function () {
18771
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(s) {
18772
+ var value;
18773
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
18774
+ while (1) {
18775
+ switch (_context16.prev = _context16.next) {
18776
+ case 0:
18777
+ value = form.getFieldsValue().itemName;
18778
+
18779
+ if (!s.goodsListState.isMyShow) {
18780
+ _context16.next = 10;
18963
18781
  break;
18782
+ }
18783
+
18784
+ _context16.next = 4;
18785
+ return controller.setEditGood({
18786
+ itemNameSelf: value
18787
+ });
18788
+
18789
+ case 4:
18790
+ _context16.t0 = record.itemName;
18791
+
18792
+ if (!_context16.t0) {
18793
+ _context16.next = 8;
18794
+ break;
18795
+ }
18796
+
18797
+ _context16.next = 8;
18798
+ return controller.setEditGood({
18799
+ itemName: record.itemName
18800
+ });
18801
+
18802
+ case 8:
18803
+ _context16.next = 16;
18804
+ break;
18805
+
18806
+ case 10:
18807
+ _context16.next = 12;
18808
+ return controller.setEditGood({
18809
+ itemName: value
18810
+ });
18811
+
18812
+ case 12:
18813
+ _context16.t1 = record.itemNameSelf;
18814
+
18815
+ if (!_context16.t1) {
18816
+ _context16.next = 16;
18817
+ break;
18818
+ }
18819
+
18820
+ _context16.next = 16;
18821
+ return controller.setEditGood({
18822
+ itemNameSelf: record.itemNameSelf
18823
+ });
18824
+
18825
+ case 16:
18826
+ case "end":
18827
+ return _context16.stop();
18828
+ }
18829
+ }
18830
+ }, _callee16);
18831
+ }));
18832
+
18833
+ return function (_x33) {
18834
+ return _ref17.apply(this, arguments);
18835
+ };
18836
+ }());
18837
+
18838
+ case 1:
18839
+ case "end":
18840
+ return _context17.stop();
18841
+ }
18842
+ }
18843
+ }, _callee17);
18844
+ }));
18845
+
18846
+ return function onChangeItemName(_x30, _x31, _x32) {
18847
+ return _ref16.apply(this, arguments);
18848
+ };
18849
+ }();
18850
+ /** 修改了含税开关 重新计算 */
18851
+
18852
+ var onChangeSwitchTax$1 = /*#__PURE__*/function () {
18853
+ var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(controller, isTaxIncluded) {
18854
+ var calculatingDigits;
18855
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
18856
+ while (1) {
18857
+ switch (_context20.prev = _context20.next) {
18858
+ case 0:
18859
+ if (controller.state.goodsListState.isRecalculateWhenSwitchTax) {
18860
+ _context20.next = 3;
18861
+ break;
18862
+ }
18863
+
18864
+ controller.pipeline( /*#__PURE__*/function () {
18865
+ var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(s) {
18866
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
18867
+ while (1) {
18868
+ switch (_context18.prev = _context18.next) {
18869
+ case 0:
18870
+ s.goodsListState = _objectSpread2(_objectSpread2({}, s.goodsListState), {}, {
18871
+ isTaxIncluded: isTaxIncluded
18872
+ });
18873
+
18874
+ case 1:
18875
+ case "end":
18876
+ return _context18.stop();
18877
+ }
18878
+ }
18879
+ }, _callee18);
18880
+ }));
18881
+
18882
+ return function (_x36) {
18883
+ return _ref19.apply(this, arguments);
18884
+ };
18885
+ }())();
18886
+ return _context20.abrupt("return");
18887
+
18888
+ case 3:
18889
+ calculatingDigits = controller.state.calculatingDigits;
18890
+ _context20.next = 6;
18891
+ return controller.saveEditGood();
18892
+
18893
+ case 6:
18894
+ _context20.next = 8;
18895
+ return controller.wait();
18896
+
18897
+ case 8:
18898
+ _context20.next = 10;
18899
+ return controller.run( /*#__PURE__*/function () {
18900
+ var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(s) {
18901
+ var _s$goodsListState, needRefresh, newGoodsList;
18902
+
18903
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
18904
+ while (1) {
18905
+ switch (_context19.prev = _context19.next) {
18906
+ case 0:
18907
+ if (!s.goodsListState.editGood) {
18908
+ _context19.next = 3;
18909
+ break;
18910
+ }
18911
+
18912
+ message.error({
18913
+ content: '你正在编辑一个货物',
18914
+ key: '你正在编辑一个货物'
18915
+ });
18916
+ return _context19.abrupt("return");
18917
+
18918
+ case 3:
18919
+ s.goodsListState.isTaxIncluded = isTaxIncluded;
18920
+
18921
+ try {
18922
+ needRefresh = false;
18923
+
18924
+ if (((_s$goodsListState = s.goodsListState) === null || _s$goodsListState === void 0 ? void 0 : _s$goodsListState.goodsList) && s.goodsListState.goodsList.length) {
18925
+ newGoodsList = s.goodsListState.goodsList.map(function (good) {
18926
+ var sourceQuantity = good.quantity,
18927
+ sourcePriceExcludeTax = good.priceExcludeTax,
18928
+ sourcePriceIncludeTax = good.priceIncludeTax,
18929
+ sourceLineAmountExcludeTax = good.lineAmountExcludeTax,
18930
+ sourceLineAmountIncludeTax = good.lineAmountIncludeTax,
18931
+ taxRate = good.taxRate;
18932
+
18933
+ if (isTaxIncluded) {
18934
+ if (!sourceQuantity && sourceQuantity !== 0) return good;
18935
+ if (!sourcePriceIncludeTax && sourcePriceIncludeTax !== 0) return good;
18936
+ if (!taxRate && taxRate !== 0) return good;
18937
+
18938
+ if (sourcePriceExcludeTax && sourceLineAmountExcludeTax && equal(countPrice(sourceLineAmountExcludeTax, sourceQuantity) || 0, sourcePriceExcludeTax)) {
18939
+ return good;
18940
+ } else {
18941
+ needRefresh = true;
18942
+ }
18943
+
18944
+ var quantity = format15(sourceQuantity, calculatingDigits);
18945
+ var priceIncludeTax = format15(sourcePriceIncludeTax, calculatingDigits);
18946
+ var lineAmountIncludeTax = format2(evaluate("".concat(priceIncludeTax, " * ").concat(quantity)));
18947
+ var taxAmount = countTaxAmount(lineAmountIncludeTax, controller.state.goodsListState.deduction, taxRate);
18948
+ var lineAmountExcludeTax = countAmountExcludeTax(lineAmountIncludeTax, taxAmount);
18949
+ var priceExcludeTax = countPrice(lineAmountExcludeTax, quantity, controller.state.calculatingDigits);
18950
+ return _objectSpread2(_objectSpread2({}, good), {}, {
18951
+ lineAmountExcludeTax: lineAmountExcludeTax,
18952
+ lineAmountIncludeTax: lineAmountIncludeTax,
18953
+ taxAmount: taxAmount,
18954
+ priceExcludeTax: priceExcludeTax
18955
+ });
18956
+ } else {
18957
+ if (!sourceQuantity && sourceQuantity !== 0) return good;
18958
+ if (!sourcePriceExcludeTax && sourcePriceExcludeTax !== 0) return good;
18959
+ if (!taxRate && taxRate !== 0) return good;
18960
+
18961
+ if (sourcePriceIncludeTax && sourceLineAmountIncludeTax && equal(countPrice(sourceLineAmountIncludeTax, sourceQuantity) || 0, sourcePriceIncludeTax)) {
18962
+ return good;
18963
+ } else {
18964
+ needRefresh = true;
18965
+ }
18966
+
18967
+ var _quantity5 = format15(sourceQuantity, calculatingDigits);
18968
+
18969
+ var _priceExcludeTax3 = format15(sourcePriceExcludeTax, calculatingDigits);
18970
+
18971
+ var _lineAmountExcludeTax3 = format2(evaluate("".concat(_priceExcludeTax3, " * ").concat(_quantity5)));
18972
+
18973
+ var _lineAmountIncludeTax3 = format2(evaluate("".concat(_lineAmountExcludeTax3, " * (1+(").concat(taxRate, "/100))")));
18974
+
18975
+ var _priceIncludeTax3 = format15(evaluate("".concat(_lineAmountIncludeTax3, " / ").concat(_quantity5)), calculatingDigits);
18976
+
18977
+ var _taxAmount = evaluate("".concat(_lineAmountIncludeTax3, " - ").concat(_lineAmountExcludeTax3));
18978
+
18979
+ return _objectSpread2(_objectSpread2({}, good), {}, {
18980
+ lineAmountExcludeTax: _lineAmountExcludeTax3,
18981
+ lineAmountIncludeTax: _lineAmountIncludeTax3,
18982
+ taxAmount: _taxAmount,
18983
+ priceIncludeTax: _priceIncludeTax3
18984
+ });
18985
+ }
18986
+ });
18987
+
18988
+ if (needRefresh) {
18989
+ s.goodsListState.goodsList = newGoodsList;
18990
+ }
18991
+ }
18992
+ } catch (e) {
18993
+ console.error('切换税率重新计算出错', e, s.goodsListState);
18994
+ }
18995
+
18996
+ case 5:
18997
+ case "end":
18998
+ return _context19.stop();
18999
+ }
19000
+ }
19001
+ }, _callee19);
19002
+ }));
19003
+
19004
+ return function (_x37) {
19005
+ return _ref20.apply(this, arguments);
19006
+ };
19007
+ }());
19008
+
19009
+ case 10:
19010
+ case "end":
19011
+ return _context20.stop();
19012
+ }
19013
+ }
19014
+ }, _callee20);
19015
+ }));
19016
+
19017
+ return function onChangeSwitchTax(_x34, _x35) {
19018
+ return _ref18.apply(this, arguments);
19019
+ };
19020
+ }();
19021
+
19022
+ var TaxIncludedSwitch$1 = (function () {
19023
+ var controller = Invoice.useInvoiceController();
19024
+ /** 是否含税 */
19025
+
19026
+ var isTaxIncluded = controller.useMemo(function (e) {
19027
+ return e.goodsListState.isTaxIncluded;
19028
+ }, []);
19029
+ /** 是否可以切换(含税/不含税)状态 */
19030
+
19031
+ var isSwitchTax = controller.useMemo(function (e) {
19032
+ return e.goodsListState.isSwitchTax;
19033
+ }, []);
19034
+ var onChange = React.useCallback( /*#__PURE__*/function () {
19035
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
19036
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
19037
+ while (1) {
19038
+ switch (_context.prev = _context.next) {
19039
+ case 0:
19040
+ onChangeSwitchTax$1(controller, e);
19041
+
19042
+ case 1:
19043
+ case "end":
19044
+ return _context.stop();
19045
+ }
19046
+ }
19047
+ }, _callee);
19048
+ }));
19049
+
19050
+ return function (_x) {
19051
+ return _ref.apply(this, arguments);
19052
+ };
19053
+ }(), []);
19054
+ return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("label", {
19055
+ style: {
19056
+ marginRight: 2
19057
+ }
19058
+ }, "\u542B\u7A0E"), /*#__PURE__*/React.createElement(Switch, {
19059
+ disabled: isSwitchTax === false,
19060
+ checked: isTaxIncluded,
19061
+ defaultChecked: true,
19062
+ onChange: onChange
19063
+ }));
19064
+ });
19065
+
19066
+ var _path$6;
19067
+
19068
+ function _extends$8() { _extends$8 = 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$8.apply(this, arguments); }
19069
+
19070
+ function SvgMagnifier$1(props) {
19071
+ return /*#__PURE__*/createElement("svg", _extends$8({
19072
+ className: "magnifier_svg__icon",
19073
+ viewBox: "0 0 1024 1024",
19074
+ xmlns: "http://www.w3.org/2000/svg",
19075
+ width: 200,
19076
+ height: 200
19077
+ }, props), _path$6 || (_path$6 = /*#__PURE__*/createElement("path", {
19078
+ d: "M985.781 918.594L820.773 765.526c27.373-32.973 49.655-69.577 66.437-109.258 22.933-54.219 34.56-111.795 34.56-171.13 0-59.333-11.627-116.91-34.56-171.13-22.143-52.354-53.838-99.365-94.2-139.729s-87.377-72.056-139.73-94.199c-54.219-22.933-111.795-34.561-171.13-34.561S365.24 57.148 311.022 80.08c-52.354 22.143-99.365 53.837-139.73 94.2s-72.057 87.375-94.2 139.73c-22.932 54.218-34.56 111.795-34.56 171.13 0 59.334 11.628 116.91 34.56 171.129 22.144 52.354 53.838 99.365 94.2 139.729s87.376 72.057 139.73 94.2c54.219 22.933 111.795 34.56 171.13 34.56s116.91-11.627 171.13-34.56c45.352-19.181 86.686-45.543 123.171-78.487l165.803 153.804a31.886 31.886 0 0021.756 8.54c8.593 0 17.163-3.442 23.467-10.238 12.019-12.956 11.26-33.205-1.698-45.223zm-503.63-57.836c-207.117 0-375.62-168.502-375.62-375.62 0-207.117 168.503-375.62 375.62-375.62s375.62 168.503 375.62 375.62c0 207.118-168.503 375.62-375.62 375.62z"
19079
+ })));
19080
+ }
19081
+
19082
+ var css_248z$k = ".kts-invoice-operate-goods-list-able .kts-invoice-operate-goods-list-search {\n width: 350px;\n border-radius: 999px;\n}\n.kts-invoice-operate-goods-list-able .kts-invoice-operate-goods-list-search input {\n border-radius: 999px;\n border-color: #b8b8b8;\n font-size: 12px;\n}\n";
19083
+ styleInject(css_248z$k);
19084
+
19085
+ function Search$1() {
19086
+ var controller = Invoice.useInvoiceController();
19087
+
19088
+ var _React$useState = React.useState(''),
19089
+ _React$useState2 = _slicedToArray(_React$useState, 2),
19090
+ value = _React$useState2[0],
19091
+ setValue = _React$useState2[1];
19092
+
19093
+ var readOnly = controller.useMemo(function (s) {
19094
+ return !!s.goodsListState.editGood;
19095
+ }, []);
19096
+ /** 是否含税 */
19097
+
19098
+ var isTaxIncluded = controller.useMemo(function (s) {
19099
+ return s.goodsListState.isTaxIncluded;
19100
+ }, []);
19101
+ var onClick = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
19102
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
19103
+ while (1) {
19104
+ switch (_context.prev = _context.next) {
19105
+ case 0:
19106
+ _context.next = 2;
19107
+ return controller.saveEditGood();
19108
+
19109
+ case 2:
19110
+ _context.next = 4;
19111
+ return controller.wait();
19112
+
19113
+ case 4:
19114
+ if (!controller.state.goodsListState.editGood) {
19115
+ _context.next = 7;
19116
+ break;
19117
+ }
19118
+
19119
+ message$1.error({
19120
+ content: '你正在编辑一个货物',
19121
+ key: '你正在编辑一个货物'
19122
+ });
19123
+ return _context.abrupt("return");
19124
+
19125
+ case 7:
19126
+ case "end":
19127
+ return _context.stop();
19128
+ }
19129
+ }
19130
+ }, _callee);
19131
+ })), []);
19132
+ React.useEffect(function () {
19133
+ controller.run( /*#__PURE__*/function () {
19134
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
19135
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
19136
+ while (1) {
19137
+ switch (_context2.prev = _context2.next) {
19138
+ case 0:
19139
+ s.goodsListState.searchValue = value.trim();
19140
+
19141
+ case 1:
19142
+ case "end":
19143
+ return _context2.stop();
19144
+ }
19145
+ }
19146
+ }, _callee2);
19147
+ }));
19148
+
19149
+ return function (_x) {
19150
+ return _ref2.apply(this, arguments);
19151
+ };
19152
+ }());
19153
+ }, [value, controller]);
19154
+ return /*#__PURE__*/React.createElement(Input$1, {
19155
+ readOnly: readOnly,
19156
+ value: value,
19157
+ className: "kts-invoice-operate-goods-list-search",
19158
+ placeholder: "\u8BF7\u60A8\u8F93\u5165\u9879\u76EE\u540D\u79F0\u3001\u89C4\u683C\u578B\u53F7\u3001\u91D1\u989D(".concat(isTaxIncluded ? '含税' : '不含税', ")\u641C\u7D22"),
19159
+ prefix: /*#__PURE__*/React.createElement(Icon$1, {
19160
+ component: SvgMagnifier$1,
19161
+ style: {
19162
+ color: "#b8b8b8"
19163
+ }
19164
+ }),
19165
+ onChange: function onChange(e) {
19166
+ setValue(e.target.value);
19167
+ },
19168
+ onClick: onClick
19169
+ });
19170
+ }
19171
+
19172
+ var css_248z$l = ".kts-invoice-operate-goods-list-itemName-drag-container-u {\n position: relative;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-u::after {\n content: \" \";\n width: 100%;\n height: 2px;\n background: #0074ff;\n position: absolute;\n left: 0;\n top: 0;\n z-index: 9999;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-d {\n position: relative;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-d::after {\n content: \" \";\n width: 100%;\n height: 2px;\n background: #0074ff;\n position: absolute;\n left: 0;\n bottom: 0;\n z-index: 9999;\n}\n";
19173
+ styleInject(css_248z$l);
19174
+
19175
+ function TableRow$1(props) {
19176
+ var rowKey = props['data-row-key'];
19177
+ var controller = Invoice.useInvoiceController();
19178
+ var goodsMap = controller.useMemo(function (s) {
19179
+ return s.goodsListState.goodsMap;
19180
+ }, []);
19181
+ /** 当前拖动中的货品索引 */
19182
+
19183
+ var site = controller.useMemo(function (s) {
19184
+ return s.goodsListState.drag.site;
19185
+ }, []);
19186
+ var current = controller.useMemo(function (s) {
19187
+ return s.goodsListState.drag.current;
19188
+ }, []);
19189
+ var container = controller.useMemo(function (s) {
19190
+ return s.goodsListState.drag.container;
19191
+ }, []);
19192
+ var discount = React.useMemo(function () {
19193
+ var i = goodsMap.get(rowKey);
19194
+ if (!i) return undefined;
19195
+
19196
+ if (i.lineAttribute === LineAttributeType$1.折扣行) {
19197
+ return 'kts-invoice-operate-goods-be-discount';
19198
+ } else if (i.lineAttribute === LineAttributeType$1.被折扣行) {
19199
+ return 'kts-invoice-operate-goods-discount';
19200
+ } else {
19201
+ return undefined;
19202
+ }
19203
+ }, [rowKey, goodsMap]);
19204
+ return rowKey === current && current ? /*#__PURE__*/React.createElement("tr", {
19205
+ style: {
19206
+ height: 50,
19207
+ position: 'relative'
19208
+ }
19209
+ }, /*#__PURE__*/React.createElement("div", {
19210
+ style: {
19211
+ height: 0.5,
19212
+ width: '100%',
19213
+ background: '#E6E6E6',
19214
+ position: 'absolute',
19215
+ bottom: 0
19216
+ }
19217
+ })) :
19218
+ /*#__PURE__*/
19219
+ // <tr {...props} className={classnames(props.className, discount, (rowKey === container && current) ? 'kts-invoice-operate-goods-list-itemName-drag-container' : '')} />
19220
+ React.createElement("tr", _objectSpread2(_objectSpread2({}, props), {}, {
19221
+ className: classNames(props.className, discount, rowKey === container && current ? 'kts-invoice-operate-goods-list-itemName-drag-container-' + site : undefined)
19222
+ }));
19223
+ }
19224
+
19225
+ var _g$2, _defs$4;
19226
+
19227
+ function _extends$9() { _extends$9 = 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$9.apply(this, arguments); }
19228
+
19229
+ function SvgPlus$1(props) {
19230
+ return /*#__PURE__*/createElement("svg", _extends$9({
19231
+ xmlns: "http://www.w3.org/2000/svg",
19232
+ width: 16,
19233
+ height: 15
19234
+ }, props), _g$2 || (_g$2 = /*#__PURE__*/createElement("g", {
19235
+ clipPath: "url(#plus_svg__clip0_715_360)"
19236
+ }, /*#__PURE__*/createElement("path", {
19237
+ d: "M8 14.531A7.031 7.031 0 118 .468a7.031 7.031 0 010 14.063zm0-.937A6.094 6.094 0 108 1.406a6.094 6.094 0 000 12.188z"
19238
+ }), /*#__PURE__*/createElement("path", {
19239
+ d: "M4.25 7.969a.469.469 0 010-.938h7.5a.47.47 0 010 .938h-7.5z"
19240
+ }), /*#__PURE__*/createElement("path", {
19241
+ d: "M7.531 3.75a.469.469 0 01.938 0v7.5a.47.47 0 01-.938 0v-7.5z"
19242
+ }))), _defs$4 || (_defs$4 = /*#__PURE__*/createElement("defs", null, /*#__PURE__*/createElement("clipPath", {
19243
+ id: "plus_svg__clip0_715_360"
19244
+ }, /*#__PURE__*/createElement("path", {
19245
+ transform: "translate(.5)",
19246
+ d: "M0 0h15v15H0z"
19247
+ })))));
19248
+ }
19249
+
19250
+ var Text$5 = Typography.Text;
19251
+ var TitleText$1 = (function (props) {
19252
+ var rules = props.rules,
19253
+ children = props.children;
19254
+ var required = React.useMemo(function () {
19255
+ return (rules === null || rules === void 0 ? void 0 : rules.some(function (e) {
19256
+ return !!e.required;
19257
+ })) || props.required;
19258
+ }, [rules, props.required]);
19259
+ return /*#__PURE__*/React.createElement(React.Fragment, null, required ? /*#__PURE__*/React.createElement(Text$5, {
19260
+ type: "danger"
19261
+ }, "*") : /*#__PURE__*/React.createElement(React.Fragment, null), children);
19262
+ });
19263
+
19264
+ var css_248z$m = ".kts-invoice-operate-goods-list-itemName-input {\n display: flex;\n flex: 1;\n padding-left: 0;\n height: 31px;\n}\n";
19265
+ styleInject(css_248z$m);
18964
19266
 
18965
- case 17:
18966
- form.setFieldsValue({
18967
- taxAmount: undefined
18968
- });
18969
- _context11.next = 20;
18970
- return controller.setEditGood({
18971
- taxAmount: undefined
18972
- });
19267
+ function ItemNameInput$1(props) {
19268
+ var controller = Invoice.useInvoiceController();
19269
+ var autoComplete = controller.useMemo(function (s) {
19270
+ return s.autoComplete;
19271
+ }, []);
18973
19272
 
18974
- case 20:
18975
- // 单价(含税) = 单价(不含税) * (1+税率)
18976
- // if (
18977
- // !err.taxRat &&
18978
- // (values.taxRate || values.taxRate === 0) &&
18979
- // !promptErr(err.priceExcludeTax) &&
18980
- // (values.priceExcludeTax || values.priceExcludeTax === 0)
18981
- // ) {
18982
- // const priceExcludeTax = format15(values.priceExcludeTax);
18983
- // const priceIncludeTax = format15(evaluate(`${priceExcludeTax} * (1+(${values.taxRate}/100))`));
18984
- // await controller.setEditGood({ priceIncludeTax });
18985
- // }
18986
- resolve(undefined);
19273
+ var _React$useState = React.useState([]),
19274
+ _React$useState2 = _slicedToArray(_React$useState, 2),
19275
+ options = _React$useState2[0],
19276
+ setOptions = _React$useState2[1];
18987
19277
 
18988
- case 21:
18989
- case "end":
18990
- return _context11.stop();
18991
- }
18992
- }
18993
- }, _callee11);
18994
- }));
19278
+ var _React$useState3 = React.useState(null),
19279
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
19280
+ selectLine = _React$useState4[0],
19281
+ setSelectLine = _React$useState4[1];
18995
19282
 
18996
- return function (_x23, _x24) {
18997
- return _ref12.apply(this, arguments);
18998
- };
18999
- }());
19000
- }));
19283
+ var onChange = React.useCallback(function (e) {
19284
+ var event = _objectSpread2({}, e);
19001
19285
 
19002
- case 1:
19003
- case "end":
19004
- return _context12.stop();
19005
- }
19006
- }
19007
- }, _callee12);
19008
- }));
19286
+ props.onChange && props.onChange(event);
19287
+ }, []);
19288
+ var onBlur = React.useCallback( /*#__PURE__*/function () {
19289
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchText) {
19290
+ var taxCategoryData, params;
19291
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
19292
+ while (1) {
19293
+ switch (_context.prev = _context.next) {
19294
+ case 0:
19295
+ _context.prev = 0;
19009
19296
 
19010
- return function updateUnitPriceTax(_x20, _x21, _x22) {
19011
- return _ref11.apply(this, arguments);
19012
- };
19013
- }();
19014
- /** 修改了 项目名称 */
19297
+ if (!autoComplete.onItemNameBlur) {
19298
+ _context.next = 8;
19299
+ break;
19300
+ }
19015
19301
 
19016
- var onChangeItemName$1 = /*#__PURE__*/function () {
19017
- var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(controller, form, record) {
19018
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
19019
- while (1) {
19020
- switch (_context17.prev = _context17.next) {
19021
- case 0:
19022
- controller.run( /*#__PURE__*/function () {
19023
- var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(s) {
19024
- var value;
19025
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
19026
- while (1) {
19027
- switch (_context16.prev = _context16.next) {
19028
- case 0:
19029
- value = form.getFieldsValue().itemName;
19302
+ if (selectLine === null || selectLine === void 0 ? void 0 : selectLine.shorthand) {
19303
+ _context.next = 7;
19304
+ break;
19305
+ }
19030
19306
 
19031
- if (!s.goodsListState.isMyShow) {
19032
- _context16.next = 10;
19033
- break;
19034
- }
19307
+ _context.next = 5;
19308
+ return autoComplete.onItemNameBlur(searchText);
19035
19309
 
19036
- _context16.next = 4;
19037
- return controller.setEditGood({
19038
- itemNameSelf: value
19039
- });
19310
+ case 5:
19311
+ taxCategoryData = _context.sent;
19040
19312
 
19041
- case 4:
19042
- _context16.t0 = record.itemName;
19313
+ if (taxCategoryData && taxCategoryData[0]) {
19314
+ params = {
19315
+ taxClassificationCode: taxCategoryData[0].taxCategoryCode,
19316
+ shorthand: taxCategoryData[0].shorthand
19317
+ };
19318
+ controller.itemNameBlur(params);
19319
+ }
19043
19320
 
19044
- if (!_context16.t0) {
19045
- _context16.next = 8;
19046
- break;
19047
- }
19321
+ case 7:
19322
+ setSelectLine(null);
19048
19323
 
19049
- _context16.next = 8;
19050
- return controller.setEditGood({
19051
- itemName: record.itemName
19052
- });
19324
+ case 8:
19325
+ _context.next = 13;
19326
+ break;
19053
19327
 
19054
- case 8:
19055
- _context16.next = 16;
19056
- break;
19328
+ case 10:
19329
+ _context.prev = 10;
19330
+ _context.t0 = _context["catch"](0);
19331
+ throw _context.t0;
19057
19332
 
19058
- case 10:
19059
- _context16.next = 12;
19060
- return controller.setEditGood({
19061
- itemName: value
19062
- });
19333
+ case 13:
19334
+ case "end":
19335
+ return _context.stop();
19336
+ }
19337
+ }
19338
+ }, _callee, null, [[0, 10]]);
19339
+ }));
19063
19340
 
19064
- case 12:
19065
- _context16.t1 = record.itemNameSelf;
19341
+ return function (_x) {
19342
+ return _ref.apply(this, arguments);
19343
+ };
19344
+ }(), [autoComplete.onItemNameBlur, selectLine, props.editGood]);
19345
+ var onChangeAutoComplete = React.useCallback(function (itemName) {
19346
+ var record = options.filter(function (e) {
19347
+ return e.itemName === itemName;
19348
+ })[0];
19349
+ if (!record) return;
19350
+ controller.importGoodsDrawer(record);
19351
+ }, [options, controller]);
19352
+ var onSearch = React.useCallback( /*#__PURE__*/function () {
19353
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(searchText) {
19354
+ var list;
19355
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
19356
+ while (1) {
19357
+ switch (_context2.prev = _context2.next) {
19358
+ case 0:
19359
+ _context2.prev = 0;
19066
19360
 
19067
- if (!_context16.t1) {
19068
- _context16.next = 16;
19069
- break;
19070
- }
19361
+ if (!autoComplete.onItemNameSearch) {
19362
+ _context2.next = 9;
19363
+ break;
19364
+ }
19071
19365
 
19072
- _context16.next = 16;
19073
- return controller.setEditGood({
19074
- itemNameSelf: record.itemNameSelf
19075
- });
19366
+ _context2.t0 = _toConsumableArray;
19367
+ _context2.next = 5;
19368
+ return autoComplete.onItemNameSearch(searchText);
19076
19369
 
19077
- case 16:
19078
- case "end":
19079
- return _context16.stop();
19080
- }
19081
- }
19082
- }, _callee16);
19083
- }));
19370
+ case 5:
19371
+ _context2.t1 = _context2.sent;
19372
+ list = (0, _context2.t0)(_context2.t1);
19373
+ console.log('===> list', list);
19374
+ setOptions(list);
19084
19375
 
19085
- return function (_x33) {
19086
- return _ref17.apply(this, arguments);
19087
- };
19088
- }());
19376
+ case 9:
19377
+ _context2.next = 15;
19378
+ break;
19089
19379
 
19090
- case 1:
19091
- case "end":
19092
- return _context17.stop();
19380
+ case 11:
19381
+ _context2.prev = 11;
19382
+ _context2.t2 = _context2["catch"](0);
19383
+ setOptions([]);
19384
+ throw _context2.t2;
19385
+
19386
+ case 15:
19387
+ case "end":
19388
+ return _context2.stop();
19389
+ }
19093
19390
  }
19094
- }
19095
- }, _callee17);
19096
- }));
19391
+ }, _callee2, null, [[0, 11]]);
19392
+ }));
19097
19393
 
19098
- return function onChangeItemName(_x30, _x31, _x32) {
19099
- return _ref16.apply(this, arguments);
19100
- };
19101
- }();
19394
+ return function (_x2) {
19395
+ return _ref2.apply(this, arguments);
19396
+ };
19397
+ }(), [autoComplete.onItemNameSearch]);
19398
+ return /*#__PURE__*/React.createElement("div", {
19399
+ className: 'kts-invoice-operate-goods-list-itemName-input'
19400
+ }, props.shorthand && /*#__PURE__*/React.createElement("span", {
19401
+ style: {
19402
+ alignSelf: 'center',
19403
+ fontSize: 12
19404
+ }
19405
+ }, "*", props.shorthand, "*"), /*#__PURE__*/React.createElement(AutoComplete$1, {
19406
+ onSearch: onSearch,
19407
+ value: props.value,
19408
+ options: options.map(function (e) {
19409
+ return {
19410
+ value: e.itemName
19411
+ };
19412
+ }),
19413
+ onSelect: onChangeAutoComplete
19414
+ }, /*#__PURE__*/React.createElement(Input$1, {
19415
+ style: {
19416
+ height: '100%'
19417
+ },
19418
+ onChange: onChange,
19419
+ suffix: props.suffix,
19420
+ onBlur: onBlur
19421
+ })));
19422
+ }
19102
19423
 
19103
19424
  var _path$7;
19104
19425
 
@@ -23310,14 +23631,17 @@ var DrawerBody$3 = function DrawerBody(props) {
23310
23631
  good.taxRate = values.taxRate;
23311
23632
  good.taxFreeType = values.taxFreeType;
23312
23633
  good.favouredPolicyMark = values.favouredPolicyMark;
23313
- good.favouredPolicyName = values.favouredPolicyName;
23314
- var taxRate = chain$1(bignumber(values.taxRate)).dotDivide(bignumber(100)).add(bignumber(1)).done(); // 是否含税
23634
+ good.favouredPolicyName = values.favouredPolicyName; // 无论是否含税,都保持价税合计不变
23315
23635
 
23316
- var lineAmountExcludeTax = chain$1(bignumber(good.lineAmountIncludeTax)).dotDivide(taxRate).done();
23317
- var priceExcludeTax = good.priceIncludeTax ? chain$1(bignumber(good.priceIncludeTax)).dotDivide(taxRate).done() : undefined;
23318
- good.lineAmountExcludeTax = lineAmountExcludeTax.toNumber().toFixed(2);
23319
- good.priceExcludeTax = (priceExcludeTax ? format15(priceExcludeTax.toNumber(), s.calculatingDigits) : undefined) || undefined;
23320
23636
  good.taxAmount = countTaxAmount(good.lineAmountIncludeTax || 0, s.goodsListState.deduction, values.taxRate);
23637
+
23638
+ if (good.taxAmount || good.taxAmount === 0) {
23639
+ good.lineAmountExcludeTax = countAmountExcludeTax(good.lineAmountIncludeTax || 0, good.taxAmount);
23640
+ }
23641
+
23642
+ if (good.lineAmountExcludeTax && good.quantity) {
23643
+ good.priceExcludeTax = countPrice(good.lineAmountExcludeTax, good.quantity, controller.state.calculatingDigits);
23644
+ }
23321
23645
  });
23322
23646
  s.goodsListState.goodsList = s.goodsListState.goodsList.slice();
23323
23647
  s.goodsListState.endowCode.endowcodeGoodIndex = [];