kts-component-invoice-operate 3.2.150 → 3.2.152

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.
@@ -24,6 +24,13 @@ export default class GoodsListState {
24
24
  isRemRow: boolean;
25
25
  /** 是否含税 */
26
26
  isTaxIncluded: boolean;
27
+ /**
28
+ * 计算类型
29
+ * @param 1: 含税金额不变
30
+ * @param 2: 不含税金额不变
31
+ * @param 3: 自动(根据含税表现isTaxIncluded)
32
+ * */
33
+ calculateType: '1' | '2' | '3';
27
34
  /** 是否显示我方 */
28
35
  isMyShow: boolean;
29
36
  /** 正在编辑的货物 */
package/dist/index.esm.js CHANGED
@@ -1098,6 +1098,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
1098
1098
  this.isAddRow = true;
1099
1099
  this.isRemRow = true;
1100
1100
  this.isTaxIncluded = true;
1101
+ this.calculateType = '3';
1101
1102
  this.isMyShow = false;
1102
1103
  this.editGood = void 0;
1103
1104
  this.form = void 0;
@@ -8799,30 +8800,51 @@ var onChangeTaxRate = lazyFn(function (controller, form, record) {
8799
8800
  record.taxFreeType = cache[record.$index].taxFreeType;
8800
8801
  cache[record.$index] = undefined;
8801
8802
  }
8802
- })(); // 是否含税
8803
+ })();
8803
8804
 
8805
+ _context8.t0 = controller.state.goodsListState.calculateType;
8806
+ _context8.next = _context8.t0 === '1' ? 10 : _context8.t0 === '2' ? 13 : _context8.t0 === '3' ? 16 : 16;
8807
+ break;
8808
+
8809
+ case 10:
8810
+ _context8.next = 12;
8811
+ return updateUnitPriceExcludingTax(controller, form, record);
8804
8812
 
8813
+ case 12:
8814
+ return _context8.abrupt("break", 24);
8815
+
8816
+ case 13:
8817
+ _context8.next = 15;
8818
+ return updateUnitPriceTax(controller, form, record);
8819
+
8820
+ case 15:
8821
+ return _context8.abrupt("break", 24);
8822
+
8823
+ case 16:
8805
8824
  if (!controller.state.goodsListState.isTaxIncluded) {
8806
- _context8.next = 12;
8825
+ _context8.next = 21;
8807
8826
  break;
8808
8827
  }
8809
8828
 
8810
- _context8.next = 10;
8829
+ _context8.next = 19;
8811
8830
  return updateUnitPriceExcludingTax(controller, form, record);
8812
8831
 
8813
- case 10:
8814
- _context8.next = 14;
8832
+ case 19:
8833
+ _context8.next = 23;
8815
8834
  break;
8816
8835
 
8817
- case 12:
8818
- _context8.next = 14;
8836
+ case 21:
8837
+ _context8.next = 23;
8819
8838
  return updateUnitPriceTax(controller, form, record);
8820
8839
 
8821
- case 14:
8822
- _context8.next = 16;
8840
+ case 23:
8841
+ return _context8.abrupt("break", 24);
8842
+
8843
+ case 24:
8844
+ _context8.next = 26;
8823
8845
  return clearCalculatingField(controller);
8824
8846
 
8825
- case 16:
8847
+ case 26:
8826
8848
  case "end":
8827
8849
  return _context8.stop();
8828
8850
  }
@@ -8877,7 +8899,7 @@ var updateUnitPriceExcludingTax = /*#__PURE__*/function () {
8877
8899
  return _context10.abrupt("return", new Promise(function (resolve) {
8878
8900
  form.validateFields( /*#__PURE__*/function () {
8879
8901
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(err, values) {
8880
- var taxAmount, lineAmountExcludeTax, priceExcludeTax, deduction;
8902
+ var taxAmount, lineAmountExcludeTax, priceExcludeTax, deduction, editGood;
8881
8903
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
8882
8904
  while (1) {
8883
8905
  switch (_context9.prev = _context9.next) {
@@ -8886,49 +8908,50 @@ var updateUnitPriceExcludingTax = /*#__PURE__*/function () {
8886
8908
  /** 税额 */
8887
8909
 
8888
8910
  /** 扣除额 */
8889
- deduction = controller.state.goodsListState.deduction; // 计算税额
8911
+ deduction = controller.state.goodsListState.deduction;
8912
+ editGood = controller.state.goodsListState.editGood; // 计算税额
8890
8913
 
8891
8914
  if (!promptErr(err.lineAmountIncludeTax) && !promptErr(err.taxRate)) {
8892
- taxAmount = countTaxAmount(values.lineAmountIncludeTax, deduction, values.taxRate);
8915
+ taxAmount = countTaxAmount(values.lineAmountIncludeTax || (editGood === null || editGood === void 0 ? void 0 : editGood.lineAmountIncludeTax), deduction, values.taxRate);
8893
8916
  }
8894
8917
 
8895
8918
  form.setFieldsValue({
8896
8919
  taxAmount: taxAmount
8897
8920
  });
8898
- _context9.next = 6;
8921
+ _context9.next = 7;
8899
8922
  return controller.setEditGood({
8900
8923
  taxAmount: taxAmount
8901
8924
  });
8902
8925
 
8903
- case 6:
8926
+ case 7:
8904
8927
  // 计算 金额(不含税)
8905
8928
  if ((taxAmount || taxAmount === 0) && !promptErr(err.lineAmountIncludeTax)) {
8906
- lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax, taxAmount);
8929
+ lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax || (editGood === null || editGood === void 0 ? void 0 : editGood.lineAmountIncludeTax), taxAmount);
8907
8930
  }
8908
8931
 
8909
8932
  form.setFieldsValue({
8910
8933
  lineAmountExcludeTax: lineAmountExcludeTax
8911
8934
  });
8912
- _context9.next = 10;
8935
+ _context9.next = 11;
8913
8936
  return controller.setEditGood({
8914
8937
  lineAmountExcludeTax: lineAmountExcludeTax
8915
8938
  });
8916
8939
 
8917
- case 10:
8940
+ case 11:
8918
8941
  // 单价(不含税)
8919
8942
  if (lineAmountExcludeTax && !promptErr(err.quantity)) {
8920
- priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity, controller.state.calculatingDigits);
8943
+ priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity || (editGood === null || editGood === void 0 ? void 0 : editGood.quantity), controller.state.calculatingDigits);
8921
8944
  }
8922
8945
 
8923
8946
  form.setFieldsValue({
8924
8947
  priceExcludeTax: priceExcludeTax
8925
8948
  });
8926
- _context9.next = 14;
8949
+ _context9.next = 15;
8927
8950
  return controller.setEditGood({
8928
8951
  priceExcludeTax: priceExcludeTax
8929
8952
  });
8930
8953
 
8931
- case 14:
8954
+ case 15:
8932
8955
  case "end":
8933
8956
  return _context9.stop();
8934
8957
  }
@@ -13003,6 +13026,11 @@ var useColumns = (function (form) {
13003
13026
  var model = controller.useMemo(function (e) {
13004
13027
  return e.model;
13005
13028
  }, []);
13029
+ /** 计算类型 */
13030
+
13031
+ var calculateType = controller.useMemo(function (e) {
13032
+ return e.goodsListState.calculateType;
13033
+ }, []);
13006
13034
  /** 是否启用拖拽 */
13007
13035
 
13008
13036
  var isStart = controller.useMemo(function (e) {
@@ -13128,7 +13156,7 @@ var useColumns = (function (form) {
13128
13156
  key: 'itemCode',
13129
13157
  width: 119,
13130
13158
  render: function render(_, record) {
13131
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13159
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13132
13160
  return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('itemCode', {
13133
13161
  initialValue: editGood.itemCode,
13134
13162
  rules: [].concat(_toConsumableArray(getReplenishRules('itemCode')), [{
@@ -13174,7 +13202,7 @@ var useColumns = (function (form) {
13174
13202
  }, "\u9879\u76EE\u540D\u79F0"),
13175
13203
  key: 'itemName',
13176
13204
  render: function render(_, record) {
13177
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13205
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13178
13206
  return /*#__PURE__*/React.createElement(Form.Item, null, /*#__PURE__*/React.createElement("div", {
13179
13207
  style: {
13180
13208
  display: 'flex'
@@ -13277,7 +13305,7 @@ var useColumns = (function (form) {
13277
13305
  key: 'itemModelName',
13278
13306
  width: 119,
13279
13307
  render: function render(_, record) {
13280
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13308
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13281
13309
  return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('itemModelName', {
13282
13310
  initialValue: isMyShow ? editGood.itemModelNameSelf : editGood.itemModelName,
13283
13311
  rules: getReplenishRules('itemModelName')
@@ -13328,7 +13356,7 @@ var useColumns = (function (form) {
13328
13356
  key: 'unit',
13329
13357
  width: 70,
13330
13358
  render: function render(_, record) {
13331
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13359
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13332
13360
  return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('unit', {
13333
13361
  initialValue: editGood.unit,
13334
13362
  rules: getReplenishRules('unit')
@@ -13386,7 +13414,7 @@ var useColumns = (function (form) {
13386
13414
  align: 'right',
13387
13415
  width: 149,
13388
13416
  render: function render(value, record) {
13389
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13417
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13390
13418
  return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('quantity', {
13391
13419
  initialValue: nonScientificNotation(editGood.quantity),
13392
13420
  getValueFromEvent: onNumberValueChange,
@@ -13481,7 +13509,7 @@ var useColumns = (function (form) {
13481
13509
  align: 'right',
13482
13510
  width: 149,
13483
13511
  render: function render(value, record) {
13484
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13512
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13485
13513
  return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('priceIncludeTax', {
13486
13514
  initialValue: nonScientificNotation(editGood.priceIncludeTax),
13487
13515
  getValueFromEvent: onNumberValueChange,
@@ -13556,7 +13584,7 @@ var useColumns = (function (form) {
13556
13584
  align: 'right',
13557
13585
  width: 149,
13558
13586
  render: function render(value, record) {
13559
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13587
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13560
13588
  return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('priceExcludeTax', {
13561
13589
  initialValue: nonScientificNotation(editGood.priceExcludeTax),
13562
13590
  getValueFromEvent: onNumberValueChange,
@@ -13631,7 +13659,7 @@ var useColumns = (function (form) {
13631
13659
  width: 119,
13632
13660
  align: 'right',
13633
13661
  render: function render(value, record) {
13634
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13662
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13635
13663
  return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('lineAmountIncludeTax', {
13636
13664
  initialValue: editGood.lineAmountIncludeTax,
13637
13665
  getValueFromEvent: onNumberValueChange,
@@ -13719,7 +13747,7 @@ var useColumns = (function (form) {
13719
13747
  align: 'right',
13720
13748
  width: 119,
13721
13749
  render: function render(value, record) {
13722
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13750
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13723
13751
  return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('lineAmountExcludeTax', {
13724
13752
  initialValue: editGood.lineAmountExcludeTax,
13725
13753
  getValueFromEvent: onNumberValueChange,
@@ -13782,7 +13810,7 @@ var useColumns = (function (form) {
13782
13810
  align: 'right',
13783
13811
  width: 75,
13784
13812
  render: function render(value, record) {
13785
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13813
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && !(model === 'prefab' && calculateType === '3')) {
13786
13814
  return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('taxRate', {
13787
13815
  initialValue: editGood.taxRate,
13788
13816
  rules: [].concat(_toConsumableArray(getReplenishRules('taxRate')), [{
@@ -14124,7 +14152,6 @@ function dcoding(v) {
14124
14152
 
14125
14153
 
14126
14154
  function isDutyFree(record) {
14127
- console.log(record);
14128
14155
  return record.taxFreeType === 1 && record.favouredPolicyName === '免税';
14129
14156
  }
14130
14157
 
@@ -14141,7 +14168,7 @@ var useOnRow = (function () {
14141
14168
  while (1) {
14142
14169
  switch (_context2.prev = _context2.next) {
14143
14170
  case 0:
14144
- if (!(model === 'prefab')) {
14171
+ if (!(model === 'readOnly')) {
14145
14172
  _context2.next = 2;
14146
14173
  break;
14147
14174
  }
@@ -14149,46 +14176,38 @@ var useOnRow = (function () {
14149
14176
  return _context2.abrupt("return");
14150
14177
 
14151
14178
  case 2:
14152
- if (!(model === 'readOnly')) {
14153
- _context2.next = 4;
14154
- break;
14155
- }
14156
-
14157
- return _context2.abrupt("return");
14158
-
14159
- case 4:
14160
14179
  editGood = controller.state.goodsListState.editGood;
14161
14180
 
14162
14181
  if (!(record.lineAttribute !== LineAttributeType$1.正常)) {
14163
- _context2.next = 7;
14182
+ _context2.next = 5;
14164
14183
  break;
14165
14184
  }
14166
14185
 
14167
14186
  return _context2.abrupt("return");
14168
14187
 
14169
- case 7:
14188
+ case 5:
14170
14189
  if (!editGood) {
14171
- _context2.next = 18;
14190
+ _context2.next = 16;
14172
14191
  break;
14173
14192
  }
14174
14193
 
14175
14194
  if (!(editGood.$index === record.$index)) {
14176
- _context2.next = 10;
14195
+ _context2.next = 8;
14177
14196
  break;
14178
14197
  }
14179
14198
 
14180
14199
  return _context2.abrupt("return");
14181
14200
 
14201
+ case 8:
14202
+ _context2.next = 10;
14203
+ return controller.saveEditGood();
14204
+
14182
14205
  case 10:
14183
14206
  _context2.next = 12;
14184
- return controller.saveEditGood();
14207
+ return controller.wait();
14185
14208
 
14186
14209
  case 12:
14187
14210
  _context2.next = 14;
14188
- return controller.wait();
14189
-
14190
- case 14:
14191
- _context2.next = 16;
14192
14211
  return controller.pipeline( /*#__PURE__*/function () {
14193
14212
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
14194
14213
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -14218,15 +14237,15 @@ var useOnRow = (function () {
14218
14237
  };
14219
14238
  }())();
14220
14239
 
14221
- case 16:
14222
- _context2.next = 20;
14240
+ case 14:
14241
+ _context2.next = 18;
14223
14242
  break;
14224
14243
 
14225
- case 18:
14226
- _context2.next = 20;
14244
+ case 16:
14245
+ _context2.next = 18;
14227
14246
  return controller.setEditGood(record);
14228
14247
 
14229
- case 20:
14248
+ case 18:
14230
14249
  case "end":
14231
14250
  return _context2.stop();
14232
14251
  }
@@ -18660,30 +18679,51 @@ var onChangeTaxRate$1 = lazyFn$2(function (controller, form, record) {
18660
18679
  record.taxFreeType = cache[record.$index].taxFreeType;
18661
18680
  cache[record.$index] = undefined;
18662
18681
  }
18663
- })(); // 是否含税
18682
+ })();
18683
+
18684
+ _context8.t0 = controller.state.goodsListState.calculateType;
18685
+ _context8.next = _context8.t0 === '1' ? 10 : _context8.t0 === '2' ? 13 : _context8.t0 === '3' ? 16 : 16;
18686
+ break;
18687
+
18688
+ case 10:
18689
+ _context8.next = 12;
18690
+ return updateUnitPriceExcludingTax$1(controller, form, record);
18691
+
18692
+ case 12:
18693
+ return _context8.abrupt("break", 24);
18664
18694
 
18695
+ case 13:
18696
+ _context8.next = 15;
18697
+ return updateUnitPriceTax$1(controller, form, record);
18698
+
18699
+ case 15:
18700
+ return _context8.abrupt("break", 24);
18665
18701
 
18702
+ case 16:
18666
18703
  if (!controller.state.goodsListState.isTaxIncluded) {
18667
- _context8.next = 12;
18704
+ _context8.next = 21;
18668
18705
  break;
18669
18706
  }
18670
18707
 
18671
- _context8.next = 10;
18708
+ _context8.next = 19;
18672
18709
  return updateUnitPriceExcludingTax$1(controller, form, record);
18673
18710
 
18674
- case 10:
18675
- _context8.next = 14;
18711
+ case 19:
18712
+ _context8.next = 23;
18676
18713
  break;
18677
18714
 
18678
- case 12:
18679
- _context8.next = 14;
18715
+ case 21:
18716
+ _context8.next = 23;
18680
18717
  return updateUnitPriceTax$1(controller, form, record);
18681
18718
 
18682
- case 14:
18683
- _context8.next = 16;
18719
+ case 23:
18720
+ return _context8.abrupt("break", 24);
18721
+
18722
+ case 24:
18723
+ _context8.next = 26;
18684
18724
  return clearCalculatingField$1(controller);
18685
18725
 
18686
- case 16:
18726
+ case 26:
18687
18727
  case "end":
18688
18728
  return _context8.stop();
18689
18729
  }
@@ -18707,7 +18747,7 @@ var updateUnitPriceExcludingTax$1 = /*#__PURE__*/function () {
18707
18747
  return _context10.abrupt("return", new Promise(function (resolve) {
18708
18748
  form.validateFields( /*#__PURE__*/function () {
18709
18749
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(err, values) {
18710
- var taxAmount, lineAmountExcludeTax, priceExcludeTax, deduction;
18750
+ var taxAmount, lineAmountExcludeTax, priceExcludeTax, deduction, editGood;
18711
18751
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
18712
18752
  while (1) {
18713
18753
  switch (_context9.prev = _context9.next) {
@@ -18717,49 +18757,50 @@ var updateUnitPriceExcludingTax$1 = /*#__PURE__*/function () {
18717
18757
  /** 税额 */
18718
18758
 
18719
18759
  /** 扣除额 */
18720
- deduction = controller.state.goodsListState.deduction; // 计算税额
18760
+ deduction = controller.state.goodsListState.deduction;
18761
+ editGood = controller.state.goodsListState.editGood; // 计算税额
18721
18762
 
18722
18763
  if (!promptErr$1(err.lineAmountIncludeTax) && !promptErr$1(err.taxRate)) {
18723
- taxAmount = countTaxAmount(values.lineAmountIncludeTax, deduction, values.taxRate);
18764
+ taxAmount = countTaxAmount(values.lineAmountIncludeTax || (editGood === null || editGood === void 0 ? void 0 : editGood.lineAmountIncludeTax), deduction, values.taxRate);
18724
18765
  }
18725
18766
 
18726
18767
  form.setFieldsValue({
18727
18768
  taxAmount: taxAmount
18728
18769
  });
18729
- _context9.next = 7;
18770
+ _context9.next = 8;
18730
18771
  return controller.setEditGood({
18731
18772
  taxAmount: taxAmount
18732
18773
  });
18733
18774
 
18734
- case 7:
18775
+ case 8:
18735
18776
  // 计算 金额(不含税)
18736
18777
  if ((taxAmount || taxAmount === 0) && !promptErr$1(err.lineAmountIncludeTax)) {
18737
- lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax, taxAmount);
18778
+ lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax || (editGood === null || editGood === void 0 ? void 0 : editGood.lineAmountIncludeTax), taxAmount);
18738
18779
  }
18739
18780
 
18740
18781
  form.setFieldsValue({
18741
18782
  lineAmountExcludeTax: lineAmountExcludeTax
18742
18783
  });
18743
- _context9.next = 11;
18784
+ _context9.next = 12;
18744
18785
  return controller.setEditGood({
18745
18786
  lineAmountExcludeTax: lineAmountExcludeTax
18746
18787
  });
18747
18788
 
18748
- case 11:
18789
+ case 12:
18749
18790
  // 单价(不含税)
18750
18791
  if (lineAmountExcludeTax && !promptErr$1(err.quantity)) {
18751
- priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity, controller.state.calculatingDigits);
18792
+ priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity || (editGood === null || editGood === void 0 ? void 0 : editGood.quantity), controller.state.calculatingDigits);
18752
18793
  }
18753
18794
 
18754
18795
  form.setFieldsValue({
18755
18796
  priceExcludeTax: priceExcludeTax
18756
18797
  });
18757
- _context9.next = 15;
18798
+ _context9.next = 16;
18758
18799
  return controller.setEditGood({
18759
18800
  priceExcludeTax: priceExcludeTax
18760
18801
  });
18761
18802
 
18762
- case 15:
18803
+ case 16:
18763
18804
  case "end":
18764
18805
  return _context9.stop();
18765
18806
  }
@@ -20999,7 +21040,6 @@ function dcoding$1(v) {
20999
21040
 
21000
21041
 
21001
21042
  function isDutyFree$1(record) {
21002
- console.log(record);
21003
21043
  return record.taxFreeType === 1 && record.favouredPolicyName === '免税';
21004
21044
  }
21005
21045
 
package/dist/index.js CHANGED
@@ -1108,6 +1108,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
1108
1108
  this.isAddRow = true;
1109
1109
  this.isRemRow = true;
1110
1110
  this.isTaxIncluded = true;
1111
+ this.calculateType = '3';
1111
1112
  this.isMyShow = false;
1112
1113
  this.editGood = void 0;
1113
1114
  this.form = void 0;
@@ -8809,30 +8810,51 @@ var onChangeTaxRate = lazyFn(function (controller, form, record) {
8809
8810
  record.taxFreeType = cache[record.$index].taxFreeType;
8810
8811
  cache[record.$index] = undefined;
8811
8812
  }
8812
- })(); // 是否含税
8813
+ })();
8813
8814
 
8815
+ _context8.t0 = controller.state.goodsListState.calculateType;
8816
+ _context8.next = _context8.t0 === '1' ? 10 : _context8.t0 === '2' ? 13 : _context8.t0 === '3' ? 16 : 16;
8817
+ break;
8818
+
8819
+ case 10:
8820
+ _context8.next = 12;
8821
+ return updateUnitPriceExcludingTax(controller, form, record);
8814
8822
 
8823
+ case 12:
8824
+ return _context8.abrupt("break", 24);
8825
+
8826
+ case 13:
8827
+ _context8.next = 15;
8828
+ return updateUnitPriceTax(controller, form, record);
8829
+
8830
+ case 15:
8831
+ return _context8.abrupt("break", 24);
8832
+
8833
+ case 16:
8815
8834
  if (!controller.state.goodsListState.isTaxIncluded) {
8816
- _context8.next = 12;
8835
+ _context8.next = 21;
8817
8836
  break;
8818
8837
  }
8819
8838
 
8820
- _context8.next = 10;
8839
+ _context8.next = 19;
8821
8840
  return updateUnitPriceExcludingTax(controller, form, record);
8822
8841
 
8823
- case 10:
8824
- _context8.next = 14;
8842
+ case 19:
8843
+ _context8.next = 23;
8825
8844
  break;
8826
8845
 
8827
- case 12:
8828
- _context8.next = 14;
8846
+ case 21:
8847
+ _context8.next = 23;
8829
8848
  return updateUnitPriceTax(controller, form, record);
8830
8849
 
8831
- case 14:
8832
- _context8.next = 16;
8850
+ case 23:
8851
+ return _context8.abrupt("break", 24);
8852
+
8853
+ case 24:
8854
+ _context8.next = 26;
8833
8855
  return clearCalculatingField(controller);
8834
8856
 
8835
- case 16:
8857
+ case 26:
8836
8858
  case "end":
8837
8859
  return _context8.stop();
8838
8860
  }
@@ -8887,7 +8909,7 @@ var updateUnitPriceExcludingTax = /*#__PURE__*/function () {
8887
8909
  return _context10.abrupt("return", new Promise(function (resolve) {
8888
8910
  form.validateFields( /*#__PURE__*/function () {
8889
8911
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(err, values) {
8890
- var taxAmount, lineAmountExcludeTax, priceExcludeTax, deduction;
8912
+ var taxAmount, lineAmountExcludeTax, priceExcludeTax, deduction, editGood;
8891
8913
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
8892
8914
  while (1) {
8893
8915
  switch (_context9.prev = _context9.next) {
@@ -8896,49 +8918,50 @@ var updateUnitPriceExcludingTax = /*#__PURE__*/function () {
8896
8918
  /** 税额 */
8897
8919
 
8898
8920
  /** 扣除额 */
8899
- deduction = controller.state.goodsListState.deduction; // 计算税额
8921
+ deduction = controller.state.goodsListState.deduction;
8922
+ editGood = controller.state.goodsListState.editGood; // 计算税额
8900
8923
 
8901
8924
  if (!promptErr(err.lineAmountIncludeTax) && !promptErr(err.taxRate)) {
8902
- taxAmount = countTaxAmount(values.lineAmountIncludeTax, deduction, values.taxRate);
8925
+ taxAmount = countTaxAmount(values.lineAmountIncludeTax || (editGood === null || editGood === void 0 ? void 0 : editGood.lineAmountIncludeTax), deduction, values.taxRate);
8903
8926
  }
8904
8927
 
8905
8928
  form.setFieldsValue({
8906
8929
  taxAmount: taxAmount
8907
8930
  });
8908
- _context9.next = 6;
8931
+ _context9.next = 7;
8909
8932
  return controller.setEditGood({
8910
8933
  taxAmount: taxAmount
8911
8934
  });
8912
8935
 
8913
- case 6:
8936
+ case 7:
8914
8937
  // 计算 金额(不含税)
8915
8938
  if ((taxAmount || taxAmount === 0) && !promptErr(err.lineAmountIncludeTax)) {
8916
- lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax, taxAmount);
8939
+ lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax || (editGood === null || editGood === void 0 ? void 0 : editGood.lineAmountIncludeTax), taxAmount);
8917
8940
  }
8918
8941
 
8919
8942
  form.setFieldsValue({
8920
8943
  lineAmountExcludeTax: lineAmountExcludeTax
8921
8944
  });
8922
- _context9.next = 10;
8945
+ _context9.next = 11;
8923
8946
  return controller.setEditGood({
8924
8947
  lineAmountExcludeTax: lineAmountExcludeTax
8925
8948
  });
8926
8949
 
8927
- case 10:
8950
+ case 11:
8928
8951
  // 单价(不含税)
8929
8952
  if (lineAmountExcludeTax && !promptErr(err.quantity)) {
8930
- priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity, controller.state.calculatingDigits);
8953
+ priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity || (editGood === null || editGood === void 0 ? void 0 : editGood.quantity), controller.state.calculatingDigits);
8931
8954
  }
8932
8955
 
8933
8956
  form.setFieldsValue({
8934
8957
  priceExcludeTax: priceExcludeTax
8935
8958
  });
8936
- _context9.next = 14;
8959
+ _context9.next = 15;
8937
8960
  return controller.setEditGood({
8938
8961
  priceExcludeTax: priceExcludeTax
8939
8962
  });
8940
8963
 
8941
- case 14:
8964
+ case 15:
8942
8965
  case "end":
8943
8966
  return _context9.stop();
8944
8967
  }
@@ -13013,6 +13036,11 @@ var useColumns = (function (form) {
13013
13036
  var model = controller.useMemo(function (e) {
13014
13037
  return e.model;
13015
13038
  }, []);
13039
+ /** 计算类型 */
13040
+
13041
+ var calculateType = controller.useMemo(function (e) {
13042
+ return e.goodsListState.calculateType;
13043
+ }, []);
13016
13044
  /** 是否启用拖拽 */
13017
13045
 
13018
13046
  var isStart = controller.useMemo(function (e) {
@@ -13138,7 +13166,7 @@ var useColumns = (function (form) {
13138
13166
  key: 'itemCode',
13139
13167
  width: 119,
13140
13168
  render: function render(_, record) {
13141
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13169
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13142
13170
  return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, null, getFieldDecorator('itemCode', {
13143
13171
  initialValue: editGood.itemCode,
13144
13172
  rules: [].concat(_toConsumableArray(getReplenishRules('itemCode')), [{
@@ -13184,7 +13212,7 @@ var useColumns = (function (form) {
13184
13212
  }, "\u9879\u76EE\u540D\u79F0"),
13185
13213
  key: 'itemName',
13186
13214
  render: function render(_, record) {
13187
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13215
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13188
13216
  return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, null, /*#__PURE__*/React__default['default'].createElement("div", {
13189
13217
  style: {
13190
13218
  display: 'flex'
@@ -13287,7 +13315,7 @@ var useColumns = (function (form) {
13287
13315
  key: 'itemModelName',
13288
13316
  width: 119,
13289
13317
  render: function render(_, record) {
13290
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13318
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13291
13319
  return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, null, getFieldDecorator('itemModelName', {
13292
13320
  initialValue: isMyShow ? editGood.itemModelNameSelf : editGood.itemModelName,
13293
13321
  rules: getReplenishRules('itemModelName')
@@ -13338,7 +13366,7 @@ var useColumns = (function (form) {
13338
13366
  key: 'unit',
13339
13367
  width: 70,
13340
13368
  render: function render(_, record) {
13341
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13369
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13342
13370
  return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, null, getFieldDecorator('unit', {
13343
13371
  initialValue: editGood.unit,
13344
13372
  rules: getReplenishRules('unit')
@@ -13396,7 +13424,7 @@ var useColumns = (function (form) {
13396
13424
  align: 'right',
13397
13425
  width: 149,
13398
13426
  render: function render(value, record) {
13399
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13427
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13400
13428
  return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, null, getFieldDecorator('quantity', {
13401
13429
  initialValue: nonScientificNotation(editGood.quantity),
13402
13430
  getValueFromEvent: onNumberValueChange,
@@ -13491,7 +13519,7 @@ var useColumns = (function (form) {
13491
13519
  align: 'right',
13492
13520
  width: 149,
13493
13521
  render: function render(value, record) {
13494
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13522
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13495
13523
  return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, null, getFieldDecorator('priceIncludeTax', {
13496
13524
  initialValue: nonScientificNotation(editGood.priceIncludeTax),
13497
13525
  getValueFromEvent: onNumberValueChange,
@@ -13566,7 +13594,7 @@ var useColumns = (function (form) {
13566
13594
  align: 'right',
13567
13595
  width: 149,
13568
13596
  render: function render(value, record) {
13569
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13597
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13570
13598
  return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, null, getFieldDecorator('priceExcludeTax', {
13571
13599
  initialValue: nonScientificNotation(editGood.priceExcludeTax),
13572
13600
  getValueFromEvent: onNumberValueChange,
@@ -13641,7 +13669,7 @@ var useColumns = (function (form) {
13641
13669
  width: 119,
13642
13670
  align: 'right',
13643
13671
  render: function render(value, record) {
13644
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13672
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13645
13673
  return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, null, getFieldDecorator('lineAmountIncludeTax', {
13646
13674
  initialValue: editGood.lineAmountIncludeTax,
13647
13675
  getValueFromEvent: onNumberValueChange,
@@ -13729,7 +13757,7 @@ var useColumns = (function (form) {
13729
13757
  align: 'right',
13730
13758
  width: 119,
13731
13759
  render: function render(value, record) {
13732
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13760
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && model !== 'prefab') {
13733
13761
  return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, null, getFieldDecorator('lineAmountExcludeTax', {
13734
13762
  initialValue: editGood.lineAmountExcludeTax,
13735
13763
  getValueFromEvent: onNumberValueChange,
@@ -13792,7 +13820,7 @@ var useColumns = (function (form) {
13792
13820
  align: 'right',
13793
13821
  width: 75,
13794
13822
  render: function render(value, record) {
13795
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index) {
13823
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && !(model === 'prefab' && calculateType === '3')) {
13796
13824
  return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, null, getFieldDecorator('taxRate', {
13797
13825
  initialValue: editGood.taxRate,
13798
13826
  rules: [].concat(_toConsumableArray(getReplenishRules('taxRate')), [{
@@ -14134,7 +14162,6 @@ function dcoding(v) {
14134
14162
 
14135
14163
 
14136
14164
  function isDutyFree(record) {
14137
- console.log(record);
14138
14165
  return record.taxFreeType === 1 && record.favouredPolicyName === '免税';
14139
14166
  }
14140
14167
 
@@ -14151,7 +14178,7 @@ var useOnRow = (function () {
14151
14178
  while (1) {
14152
14179
  switch (_context2.prev = _context2.next) {
14153
14180
  case 0:
14154
- if (!(model === 'prefab')) {
14181
+ if (!(model === 'readOnly')) {
14155
14182
  _context2.next = 2;
14156
14183
  break;
14157
14184
  }
@@ -14159,46 +14186,38 @@ var useOnRow = (function () {
14159
14186
  return _context2.abrupt("return");
14160
14187
 
14161
14188
  case 2:
14162
- if (!(model === 'readOnly')) {
14163
- _context2.next = 4;
14164
- break;
14165
- }
14166
-
14167
- return _context2.abrupt("return");
14168
-
14169
- case 4:
14170
14189
  editGood = controller.state.goodsListState.editGood;
14171
14190
 
14172
14191
  if (!(record.lineAttribute !== LineAttributeType$1.正常)) {
14173
- _context2.next = 7;
14192
+ _context2.next = 5;
14174
14193
  break;
14175
14194
  }
14176
14195
 
14177
14196
  return _context2.abrupt("return");
14178
14197
 
14179
- case 7:
14198
+ case 5:
14180
14199
  if (!editGood) {
14181
- _context2.next = 18;
14200
+ _context2.next = 16;
14182
14201
  break;
14183
14202
  }
14184
14203
 
14185
14204
  if (!(editGood.$index === record.$index)) {
14186
- _context2.next = 10;
14205
+ _context2.next = 8;
14187
14206
  break;
14188
14207
  }
14189
14208
 
14190
14209
  return _context2.abrupt("return");
14191
14210
 
14211
+ case 8:
14212
+ _context2.next = 10;
14213
+ return controller.saveEditGood();
14214
+
14192
14215
  case 10:
14193
14216
  _context2.next = 12;
14194
- return controller.saveEditGood();
14217
+ return controller.wait();
14195
14218
 
14196
14219
  case 12:
14197
14220
  _context2.next = 14;
14198
- return controller.wait();
14199
-
14200
- case 14:
14201
- _context2.next = 16;
14202
14221
  return controller.pipeline( /*#__PURE__*/function () {
14203
14222
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
14204
14223
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -14228,15 +14247,15 @@ var useOnRow = (function () {
14228
14247
  };
14229
14248
  }())();
14230
14249
 
14231
- case 16:
14232
- _context2.next = 20;
14250
+ case 14:
14251
+ _context2.next = 18;
14233
14252
  break;
14234
14253
 
14235
- case 18:
14236
- _context2.next = 20;
14254
+ case 16:
14255
+ _context2.next = 18;
14237
14256
  return controller.setEditGood(record);
14238
14257
 
14239
- case 20:
14258
+ case 18:
14240
14259
  case "end":
14241
14260
  return _context2.stop();
14242
14261
  }
@@ -18670,30 +18689,51 @@ var onChangeTaxRate$1 = lazyFn$2(function (controller, form, record) {
18670
18689
  record.taxFreeType = cache[record.$index].taxFreeType;
18671
18690
  cache[record.$index] = undefined;
18672
18691
  }
18673
- })(); // 是否含税
18692
+ })();
18693
+
18694
+ _context8.t0 = controller.state.goodsListState.calculateType;
18695
+ _context8.next = _context8.t0 === '1' ? 10 : _context8.t0 === '2' ? 13 : _context8.t0 === '3' ? 16 : 16;
18696
+ break;
18697
+
18698
+ case 10:
18699
+ _context8.next = 12;
18700
+ return updateUnitPriceExcludingTax$1(controller, form, record);
18701
+
18702
+ case 12:
18703
+ return _context8.abrupt("break", 24);
18674
18704
 
18705
+ case 13:
18706
+ _context8.next = 15;
18707
+ return updateUnitPriceTax$1(controller, form, record);
18708
+
18709
+ case 15:
18710
+ return _context8.abrupt("break", 24);
18675
18711
 
18712
+ case 16:
18676
18713
  if (!controller.state.goodsListState.isTaxIncluded) {
18677
- _context8.next = 12;
18714
+ _context8.next = 21;
18678
18715
  break;
18679
18716
  }
18680
18717
 
18681
- _context8.next = 10;
18718
+ _context8.next = 19;
18682
18719
  return updateUnitPriceExcludingTax$1(controller, form, record);
18683
18720
 
18684
- case 10:
18685
- _context8.next = 14;
18721
+ case 19:
18722
+ _context8.next = 23;
18686
18723
  break;
18687
18724
 
18688
- case 12:
18689
- _context8.next = 14;
18725
+ case 21:
18726
+ _context8.next = 23;
18690
18727
  return updateUnitPriceTax$1(controller, form, record);
18691
18728
 
18692
- case 14:
18693
- _context8.next = 16;
18729
+ case 23:
18730
+ return _context8.abrupt("break", 24);
18731
+
18732
+ case 24:
18733
+ _context8.next = 26;
18694
18734
  return clearCalculatingField$1(controller);
18695
18735
 
18696
- case 16:
18736
+ case 26:
18697
18737
  case "end":
18698
18738
  return _context8.stop();
18699
18739
  }
@@ -18717,7 +18757,7 @@ var updateUnitPriceExcludingTax$1 = /*#__PURE__*/function () {
18717
18757
  return _context10.abrupt("return", new Promise(function (resolve) {
18718
18758
  form.validateFields( /*#__PURE__*/function () {
18719
18759
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(err, values) {
18720
- var taxAmount, lineAmountExcludeTax, priceExcludeTax, deduction;
18760
+ var taxAmount, lineAmountExcludeTax, priceExcludeTax, deduction, editGood;
18721
18761
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
18722
18762
  while (1) {
18723
18763
  switch (_context9.prev = _context9.next) {
@@ -18727,49 +18767,50 @@ var updateUnitPriceExcludingTax$1 = /*#__PURE__*/function () {
18727
18767
  /** 税额 */
18728
18768
 
18729
18769
  /** 扣除额 */
18730
- deduction = controller.state.goodsListState.deduction; // 计算税额
18770
+ deduction = controller.state.goodsListState.deduction;
18771
+ editGood = controller.state.goodsListState.editGood; // 计算税额
18731
18772
 
18732
18773
  if (!promptErr$1(err.lineAmountIncludeTax) && !promptErr$1(err.taxRate)) {
18733
- taxAmount = countTaxAmount(values.lineAmountIncludeTax, deduction, values.taxRate);
18774
+ taxAmount = countTaxAmount(values.lineAmountIncludeTax || (editGood === null || editGood === void 0 ? void 0 : editGood.lineAmountIncludeTax), deduction, values.taxRate);
18734
18775
  }
18735
18776
 
18736
18777
  form.setFieldsValue({
18737
18778
  taxAmount: taxAmount
18738
18779
  });
18739
- _context9.next = 7;
18780
+ _context9.next = 8;
18740
18781
  return controller.setEditGood({
18741
18782
  taxAmount: taxAmount
18742
18783
  });
18743
18784
 
18744
- case 7:
18785
+ case 8:
18745
18786
  // 计算 金额(不含税)
18746
18787
  if ((taxAmount || taxAmount === 0) && !promptErr$1(err.lineAmountIncludeTax)) {
18747
- lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax, taxAmount);
18788
+ lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax || (editGood === null || editGood === void 0 ? void 0 : editGood.lineAmountIncludeTax), taxAmount);
18748
18789
  }
18749
18790
 
18750
18791
  form.setFieldsValue({
18751
18792
  lineAmountExcludeTax: lineAmountExcludeTax
18752
18793
  });
18753
- _context9.next = 11;
18794
+ _context9.next = 12;
18754
18795
  return controller.setEditGood({
18755
18796
  lineAmountExcludeTax: lineAmountExcludeTax
18756
18797
  });
18757
18798
 
18758
- case 11:
18799
+ case 12:
18759
18800
  // 单价(不含税)
18760
18801
  if (lineAmountExcludeTax && !promptErr$1(err.quantity)) {
18761
- priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity, controller.state.calculatingDigits);
18802
+ priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity || (editGood === null || editGood === void 0 ? void 0 : editGood.quantity), controller.state.calculatingDigits);
18762
18803
  }
18763
18804
 
18764
18805
  form.setFieldsValue({
18765
18806
  priceExcludeTax: priceExcludeTax
18766
18807
  });
18767
- _context9.next = 15;
18808
+ _context9.next = 16;
18768
18809
  return controller.setEditGood({
18769
18810
  priceExcludeTax: priceExcludeTax
18770
18811
  });
18771
18812
 
18772
- case 15:
18813
+ case 16:
18773
18814
  case "end":
18774
18815
  return _context9.stop();
18775
18816
  }
@@ -21009,7 +21050,6 @@ function dcoding$1(v) {
21009
21050
 
21010
21051
 
21011
21052
  function isDutyFree$1(record) {
21012
- console.log(record);
21013
21053
  return record.taxFreeType === 1 && record.favouredPolicyName === '免税';
21014
21054
  }
21015
21055
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.150",
3
+ "version": "3.2.152",
4
4
  "scripts": {
5
5
  "dev": "dumi dev --max-old-space-size=6096",
6
6
  "start": "dumi dev",
@@ -33,6 +33,14 @@ export default class GoodsListState {
33
33
  /** 是否含税 */
34
34
  isTaxIncluded = true;
35
35
 
36
+ /**
37
+ * 计算类型
38
+ * @param 1: 含税金额不变
39
+ * @param 2: 不含税金额不变
40
+ * @param 3: 自动(根据含税表现isTaxIncluded)
41
+ * */
42
+ calculateType: '1' | '2' | '3' = '3';
43
+
36
44
  /** 是否显示我方 */
37
45
  isMyShow = false;
38
46
 
@@ -311,11 +311,24 @@ export const onChangeTaxRate = lazyFn(
311
311
  }
312
312
  })()
313
313
 
314
- // 是否含税
315
- if (controller.state.goodsListState.isTaxIncluded) {
316
- await updateUnitPriceExcludingTax(controller, form, record);
317
- } else {
318
- await updateUnitPriceTax(controller, form, record);
314
+ switch (controller.state.goodsListState.calculateType) {
315
+ case '1':
316
+ await updateUnitPriceExcludingTax(controller, form, record);
317
+ break;
318
+
319
+ case '2':
320
+ await updateUnitPriceTax(controller, form, record);
321
+ break;
322
+
323
+ case '3':
324
+ default:
325
+ // 是否含税
326
+ if (controller.state.goodsListState.isTaxIncluded) {
327
+ await updateUnitPriceExcludingTax(controller, form, record);
328
+ } else {
329
+ await updateUnitPriceTax(controller, form, record);
330
+ }
331
+ break;
319
332
  }
320
333
 
321
334
  // 清楚 计算中启动字段
@@ -372,23 +385,25 @@ export const updateUnitPriceExcludingTax = async (controller: InvoiceController,
372
385
  /** 扣除额 */
373
386
  const deduction = controller.state.goodsListState.deduction;
374
387
 
388
+ const { editGood } = controller.state.goodsListState
389
+
375
390
  // 计算税额
376
391
  if (!promptErr(err.lineAmountIncludeTax) && !promptErr(err.taxRate)) {
377
- taxAmount = countTaxAmount(values.lineAmountIncludeTax, deduction, values.taxRate);
392
+ taxAmount = countTaxAmount(values.lineAmountIncludeTax || editGood?.lineAmountIncludeTax, deduction, values.taxRate);
378
393
  }
379
394
  form.setFieldsValue({ taxAmount });
380
395
  await controller.setEditGood({ taxAmount });
381
396
 
382
397
  // 计算 金额(不含税)
383
398
  if ((taxAmount || taxAmount === 0) && !promptErr(err.lineAmountIncludeTax)) {
384
- lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax, taxAmount);
399
+ lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax || editGood?.lineAmountIncludeTax, taxAmount);
385
400
  }
386
401
  form.setFieldsValue({ lineAmountExcludeTax });
387
402
  await controller.setEditGood({ lineAmountExcludeTax });
388
403
 
389
404
  // 单价(不含税)
390
405
  if (lineAmountExcludeTax && !promptErr(err.quantity)) {
391
- priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity, controller.state.calculatingDigits);
406
+ priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity || editGood?.quantity, controller.state.calculatingDigits);
392
407
  }
393
408
  form.setFieldsValue({ priceExcludeTax });
394
409
  await controller.setEditGood({ priceExcludeTax });
@@ -551,7 +566,7 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
551
566
  key: '你正在编辑一个货物',
552
567
  });
553
568
 
554
- return ;
569
+ return;
555
570
  }
556
571
 
557
572
  s.goodsListState.isTaxIncluded = isTaxIncluded;
@@ -625,7 +640,7 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
625
640
  s.goodsListState.goodsList = newGoodsList;
626
641
  }
627
642
  }
628
- } catch(e) {
643
+ } catch (e) {
629
644
  console.error('切换税率重新计算出错', e, s.goodsListState)
630
645
  }
631
646
  })
@@ -35,6 +35,9 @@ export default (form: WrappedFormUtils) => {
35
35
  /** 组件模式 */
36
36
  const model = controller.useMemo(e => e.model, []);
37
37
 
38
+ /** 计算类型 */
39
+ const calculateType = controller.useMemo(e => e.goodsListState.calculateType, []);
40
+
38
41
  /** 是否启用拖拽 */
39
42
  const isStart = controller.useMemo((e) => e.goodsListState.drag.isStart, []);
40
43
 
@@ -105,7 +108,7 @@ export default (form: WrappedFormUtils) => {
105
108
  key: 'itemCode',
106
109
  width: 119,
107
110
  render: (_: string, record: IGood) => {
108
- if (editGood?.$index === record.$index) {
111
+ if (editGood?.$index === record.$index && model !== 'prefab') {
109
112
  return (
110
113
  <Form.Item>
111
114
  {getFieldDecorator('itemCode', {
@@ -133,7 +136,7 @@ export default (form: WrappedFormUtils) => {
133
136
  title: <TitleText required >项目名称</TitleText>,
134
137
  key: 'itemName',
135
138
  render: (_: string, record: IGood) => {
136
- if (editGood?.$index === record.$index) {
139
+ if (editGood?.$index === record.$index && model !== 'prefab') {
137
140
  return (
138
141
  <Form.Item>
139
142
  <div style={{ display: 'flex' }} >
@@ -192,7 +195,7 @@ export default (form: WrappedFormUtils) => {
192
195
  key: 'itemModelName',
193
196
  width: 119,
194
197
  render: (_: string, record: IGood) => {
195
- if (editGood?.$index === record.$index) {
198
+ if (editGood?.$index === record.$index && model !== 'prefab') {
196
199
  return (
197
200
  <Form.Item>
198
201
  {getFieldDecorator('itemModelName', {
@@ -227,7 +230,7 @@ export default (form: WrappedFormUtils) => {
227
230
  key: 'unit',
228
231
  width: 70,
229
232
  render: (_: string, record: IGood) => {
230
- if (editGood?.$index === record.$index) {
233
+ if (editGood?.$index === record.$index && model !== 'prefab') {
231
234
  return (
232
235
  <Form.Item>
233
236
  {getFieldDecorator('unit', {
@@ -258,7 +261,7 @@ export default (form: WrappedFormUtils) => {
258
261
  align: 'right',
259
262
  width: 149,
260
263
  render: (value: string, record: IGood) => {
261
- if (editGood?.$index === record.$index) {
264
+ if (editGood?.$index === record.$index && model !== 'prefab') {
262
265
  return (
263
266
  <Form.Item>
264
267
  {getFieldDecorator('quantity', {
@@ -302,7 +305,7 @@ export default (form: WrappedFormUtils) => {
302
305
  align: 'right',
303
306
  width: 149,
304
307
  render: (value: string, record: IGood) => {
305
- if (editGood?.$index === record.$index) {
308
+ if (editGood?.$index === record.$index && model !== 'prefab') {
306
309
  return (
307
310
  <Form.Item>
308
311
  {getFieldDecorator('priceIncludeTax', {
@@ -346,7 +349,7 @@ export default (form: WrappedFormUtils) => {
346
349
  align: 'right',
347
350
  width: 149,
348
351
  render: (value: string, record: IGood) => {
349
- if (editGood?.$index === record.$index) {
352
+ if (editGood?.$index === record.$index && model !== 'prefab') {
350
353
  return (
351
354
  <Form.Item>
352
355
  {getFieldDecorator('priceExcludeTax', {
@@ -390,7 +393,7 @@ export default (form: WrappedFormUtils) => {
390
393
  width: 119,
391
394
  align: 'right',
392
395
  render: (value: string, record: IGood) => {
393
- if (editGood?.$index === record.$index) {
396
+ if (editGood?.$index === record.$index && model !== 'prefab') {
394
397
  return (
395
398
  <Form.Item>
396
399
  {getFieldDecorator('lineAmountIncludeTax', {
@@ -439,7 +442,7 @@ export default (form: WrappedFormUtils) => {
439
442
  align: 'right',
440
443
  width: 119,
441
444
  render: (value: string, record: IGood) => {
442
- if (editGood?.$index === record.$index) {
445
+ if (editGood?.$index === record.$index && model !== 'prefab') {
443
446
  return (
444
447
  <Form.Item>
445
448
  {getFieldDecorator('lineAmountExcludeTax', {
@@ -481,7 +484,7 @@ export default (form: WrappedFormUtils) => {
481
484
  align: 'right',
482
485
  width: 75,
483
486
  render: (value: string, record: IGood) => {
484
- if (editGood?.$index === record.$index) {
487
+ if (editGood?.$index === record.$index && !(model === 'prefab' && calculateType === '3')) {
485
488
  return (
486
489
  <Form.Item>
487
490
  {getFieldDecorator('taxRate', {
@@ -690,6 +693,5 @@ function dcoding(v: string): string {
690
693
 
691
694
  /** 是否免税 */
692
695
  function isDutyFree(record: IGood): boolean {
693
- console.log(record);
694
696
  return (record.taxFreeType as any) === 1 && record.favouredPolicyName === '免税';
695
697
  }
@@ -15,7 +15,7 @@ export default () => {
15
15
 
16
16
  const onClick = React.useCallback(
17
17
  async (record: IGood) => {
18
- if (model === 'prefab') return;
18
+ // if (model === 'prefab') return;
19
19
  if (model === 'readOnly') return;
20
20
 
21
21
  const editGood = controller.state.goodsListState.editGood;
@@ -315,11 +315,24 @@ export const onChangeTaxRate = lazyFn(
315
315
  }
316
316
  })()
317
317
 
318
- // 是否含税
319
- if (controller.state.goodsListState.isTaxIncluded) {
320
- await updateUnitPriceExcludingTax(controller, form, record);
321
- } else {
322
- await updateUnitPriceTax(controller, form, record);
318
+ switch (controller.state.goodsListState.calculateType) {
319
+ case '1':
320
+ await updateUnitPriceExcludingTax(controller, form, record);
321
+ break;
322
+
323
+ case '2':
324
+ await updateUnitPriceTax(controller, form, record);
325
+ break;
326
+
327
+ case '3':
328
+ default:
329
+ // 是否含税
330
+ if (controller.state.goodsListState.isTaxIncluded) {
331
+ await updateUnitPriceExcludingTax(controller, form, record);
332
+ } else {
333
+ await updateUnitPriceTax(controller, form, record);
334
+ }
335
+ break;
323
336
  }
324
337
 
325
338
  // 清楚 计算中启动字段
@@ -377,23 +390,25 @@ export const updateUnitPriceExcludingTax = async (controller: InvoiceController,
377
390
  /** 扣除额 */
378
391
  const deduction = controller.state.goodsListState.deduction;
379
392
 
393
+ const { editGood } = controller.state.goodsListState
394
+
380
395
  // 计算税额
381
396
  if (!promptErr(err.lineAmountIncludeTax) && !promptErr(err.taxRate)) {
382
- taxAmount = countTaxAmount(values.lineAmountIncludeTax, deduction, values.taxRate);
397
+ taxAmount = countTaxAmount(values.lineAmountIncludeTax || editGood?.lineAmountIncludeTax, deduction, values.taxRate);
383
398
  }
384
399
  form.setFieldsValue({ taxAmount });
385
400
  await controller.setEditGood({ taxAmount });
386
401
 
387
402
  // 计算 金额(不含税)
388
403
  if ((taxAmount || taxAmount === 0) && !promptErr(err.lineAmountIncludeTax)) {
389
- lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax, taxAmount);
404
+ lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax || editGood?.lineAmountIncludeTax, taxAmount);
390
405
  }
391
406
  form.setFieldsValue({ lineAmountExcludeTax });
392
407
  await controller.setEditGood({ lineAmountExcludeTax });
393
408
 
394
409
  // 单价(不含税)
395
410
  if (lineAmountExcludeTax && !promptErr(err.quantity)) {
396
- priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity, controller.state.calculatingDigits);
411
+ priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity || editGood?.quantity, controller.state.calculatingDigits);
397
412
  }
398
413
  form.setFieldsValue({ priceExcludeTax });
399
414
  await controller.setEditGood({ priceExcludeTax });
@@ -645,7 +645,6 @@ function dcoding(v: string): string {
645
645
 
646
646
  /** 是否免税 */
647
647
  function isDutyFree(record: IGood): boolean {
648
- console.log(record);
649
648
  return (record.taxFreeType as any) === 1 && record.favouredPolicyName === '免税';
650
649
  }
651
650