kts-component-invoice-operate 1.0.105 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,11 +3,24 @@ import IGood from './IGood';
3
3
  export default class EndowCode {
4
4
  /** 准备赋码的货物索引列表 */
5
5
  endowcodeGoodIndex: number[];
6
- /** 获取 税收分类编码列表 */
6
+ /**
7
+ * 获取 税收分类编码列表 (弃用)
8
+ * @deprecated 请使用 getTaxCategoryCodeTree 替换
9
+ * */
7
10
  getTaxCategoryCodeList: (value: string) => Promise<{
8
11
  value: string;
9
12
  label: string;
10
13
  }[]>;
14
+ /**
15
+ * 获取 税收分类编码树
16
+ * @param taxCategoryCode 税收分类编码
17
+ * @param val val
18
+ * @returns 税收分类编码树
19
+ */
20
+ getTaxCategoryCodeTree: (taxCategoryCode?: string, val?: string) => Promise<{
21
+ id: string;
22
+ pid: string;
23
+ }[]>;
11
24
  /** 税率 是否可以编辑 */
12
25
  getReadOnlyTaxRate?: (value?: GoodsListState) => boolean;
13
26
  /**
package/dist/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import 'kts-components-antd-x3/dist/kts-components-antd-x3.css';
2
2
  import React, { createElement } from 'react';
3
3
  import GreyReactBox, { decorator } from 'grey-react-box';
4
4
  import { chain as chain$1, bignumber, create, all } from 'mathjs';
5
- import { message, Form, Input, Icon, Tag, Select, Row, Col, Table, Button, Switch, Typography, Drawer, Menu, Dropdown, AutoComplete, Spin, Checkbox, Descriptions, Modal } from 'kts-components-antd-x3';
5
+ import { message, Form, Input, Icon, Tag, Select, Row, Col, Table, Button, Switch, Typography, Drawer, Menu, Dropdown, AutoComplete, Spin, Checkbox, Descriptions, Tree, Modal } from 'kts-components-antd-x3';
6
6
  import { v4 } from 'uuid';
7
7
  import classnames from 'classnames';
8
8
  import { Input as Input$1, NumberPicker } from '@formily/antd-components';
@@ -586,6 +586,20 @@ var EndowCode = function EndowCode() {
586
586
  }
587
587
  }, _callee);
588
588
  }));
589
+ this.getTaxCategoryCodeTree = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
590
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
591
+ while (1) {
592
+ switch (_context2.prev = _context2.next) {
593
+ case 0:
594
+ return _context2.abrupt("return", []);
595
+
596
+ case 1:
597
+ case "end":
598
+ return _context2.stop();
599
+ }
600
+ }
601
+ }, _callee2);
602
+ }));
589
603
  this.getReadOnlyTaxRate = void 0;
590
604
  this.getDefaultValue = void 0;
591
605
  this.readOnlyTaxRateMap = {
@@ -1858,8 +1872,8 @@ var AddDiscountRowButton = decorator(Form.create())(function (props) {
1858
1872
  }
1859
1873
 
1860
1874
  message.error({
1861
- content: '不跟给编辑状态的行增加折扣!',
1862
- key: '不跟给编辑状态的行增加折扣!'
1875
+ content: '不能给编辑状态的行增加折扣!',
1876
+ key: '不能给编辑状态的行增加折扣!'
1863
1877
  });
1864
1878
  return _context2.abrupt("return");
1865
1879
 
@@ -3529,6 +3543,11 @@ var useColumns = (function (form) {
3529
3543
  var unitList = controller.useMemo(function (e) {
3530
3544
  return e.goodsListState.unitList;
3531
3545
  }, []);
3546
+ /** 扣除额 */
3547
+
3548
+ var deduction = controller.useMemo(function (e) {
3549
+ return e.goodsListState.deduction;
3550
+ }, []);
3532
3551
  /** 变动的字段 */
3533
3552
 
3534
3553
  var _React$useState = React.useState(''),
@@ -3913,6 +3932,31 @@ var useColumns = (function (form) {
3913
3932
  return _validator4.apply(this, arguments);
3914
3933
  }
3915
3934
 
3935
+ return validator;
3936
+ }()
3937
+ }, {
3938
+ validator: function () {
3939
+ var _validator5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(_, value, callback) {
3940
+ return regeneratorRuntime.wrap(function _callee6$(_context6) {
3941
+ while (1) {
3942
+ switch (_context6.prev = _context6.next) {
3943
+ case 0:
3944
+ if (deduction && parseFloat(value) <= deduction) {
3945
+ callback('扣除额不能大于等于价税合计');
3946
+ }
3947
+
3948
+ case 1:
3949
+ case "end":
3950
+ return _context6.stop();
3951
+ }
3952
+ }
3953
+ }, _callee6);
3954
+ }));
3955
+
3956
+ function validator(_x14, _x15, _x16) {
3957
+ return _validator5.apply(this, arguments);
3958
+ }
3959
+
3916
3960
  return validator;
3917
3961
  }()
3918
3962
  }]
@@ -3954,10 +3998,10 @@ var useColumns = (function (form) {
3954
3998
  message: '金额必须为数字'
3955
3999
  }, {
3956
4000
  validator: function () {
3957
- var _validator5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(_, value, callback) {
3958
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
4001
+ var _validator6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(_, value, callback) {
4002
+ return regeneratorRuntime.wrap(function _callee7$(_context7) {
3959
4003
  while (1) {
3960
- switch (_context6.prev = _context6.next) {
4004
+ switch (_context7.prev = _context7.next) {
3961
4005
  case 0:
3962
4006
  if ("".concat(value).split('.')[0].length > 9) {
3963
4007
  callback('金额整数部分不能大于9位,小数点后最多2位');
@@ -3965,14 +4009,14 @@ var useColumns = (function (form) {
3965
4009
 
3966
4010
  case 1:
3967
4011
  case "end":
3968
- return _context6.stop();
4012
+ return _context7.stop();
3969
4013
  }
3970
4014
  }
3971
- }, _callee6);
4015
+ }, _callee7);
3972
4016
  }));
3973
4017
 
3974
- function validator(_x14, _x15, _x16) {
3975
- return _validator5.apply(this, arguments);
4018
+ function validator(_x17, _x18, _x19) {
4019
+ return _validator6.apply(this, arguments);
3976
4020
  }
3977
4021
 
3978
4022
  return validator;
@@ -4083,7 +4127,7 @@ var useColumns = (function (form) {
4083
4127
  ellipsis: true
4084
4128
  });
4085
4129
  });
4086
- }, [isTaxIncluded, editGood, controller, changeField]);
4130
+ }, [isTaxIncluded, editGood, controller, changeField, deduction]);
4087
4131
  React.useEffect(function () {
4088
4132
  if (!changeField) return;
4089
4133
  var t = setTimeout(function () {
@@ -5499,6 +5543,7 @@ function cutStr(str, L) {
5499
5543
  var css_248z$a = ".kts-invoice-operate-goods-endow-code-button-list {\n display: flex;\n flex-direction: column;\n}\n.kts-invoice-operate-goods-endow-code-button-list > button {\n margin-bottom: 10px;\n}\n";
5500
5544
  styleInject(css_248z$a);
5501
5545
 
5546
+ var TreeNode = Tree.TreeNode;
5502
5547
  var confirm = Modal.confirm;
5503
5548
  var EndowCodeDrawer = (function () {
5504
5549
  var controller = default_1.useInvoiceController();
@@ -5758,21 +5803,221 @@ var DrawerBody$3 = function DrawerBody(props) {
5758
5803
  value: e.value
5759
5804
  }, e.label);
5760
5805
  }));
5806
+ }, [controller, actions]);
5807
+ /** 税收分类编码 选择组件2 */
5808
+
5809
+ var ShowSearch2 = React.useCallback(function (props) {
5810
+ // 是否显示
5811
+ var _React$useState7 = React.useState(false),
5812
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
5813
+ visible = _React$useState8[0],
5814
+ setVisible = _React$useState8[1]; // 税收分类编码树
5815
+
5816
+
5817
+ var _React$useState9 = React.useState(),
5818
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
5819
+ list = _React$useState10[0],
5820
+ setList = _React$useState10[1]; // 搜索条件
5821
+
5822
+
5823
+ var _React$useState11 = React.useState(),
5824
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
5825
+ filter = _React$useState12[0],
5826
+ setFilter = _React$useState12[1];
5827
+ /** 创建 树节点 */
5828
+
5829
+
5830
+ var createTreeNode = React.useCallback(function () {
5831
+ if (!list) return /*#__PURE__*/React.createElement(React.Fragment, null);
5832
+ return ctn(list);
5833
+
5834
+ function ctn(l) {
5835
+ var p = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';
5836
+ if (!l || !l.length) return [/*#__PURE__*/React.createElement(React.Fragment, null)];
5837
+ var ls = l.filter(function (e) {
5838
+ return e.pid === p;
5839
+ });
5840
+ debugger;
5841
+ return l.filter(function (e) {
5842
+ return e.pid === p;
5843
+ }).map(function (e) {
5844
+ return /*#__PURE__*/React.createElement(TreeNode, {
5845
+ title: e.label,
5846
+ key: e.id
5847
+ }, ctn(l, e.id));
5848
+ });
5849
+ }
5850
+ }, [list]);
5851
+ /** 点击了节点 */
5852
+
5853
+ var onSelect = React.useCallback(function (e) {
5854
+ var id = e[0]; // 是否叶子节点
5855
+
5856
+ if ((list === null || list === void 0 ? void 0 : list.filter(function (e) {
5857
+ return e.pid === id;
5858
+ }).length) !== 0) {
5859
+ return;
5860
+ }
5861
+
5862
+ var info = list === null || list === void 0 ? void 0 : list.filter(function (e) {
5863
+ return e.id === id;
5864
+ })[0];
5865
+ !readOnlyTaxRate && actions.setFieldState('taxRate', /*#__PURE__*/function () {
5866
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(s) {
5867
+ return regeneratorRuntime.wrap(function _callee6$(_context6) {
5868
+ while (1) {
5869
+ switch (_context6.prev = _context6.next) {
5870
+ case 0:
5871
+ if (info.taxRate || info.taxRate === 0) {
5872
+ s.value = info.taxRate;
5873
+ }
5874
+
5875
+ case 1:
5876
+ case "end":
5877
+ return _context6.stop();
5878
+ }
5879
+ }
5880
+ }, _callee6);
5881
+ }));
5882
+
5883
+ return function (_x6) {
5884
+ return _ref6.apply(this, arguments);
5885
+ };
5886
+ }());
5887
+ actions.setFieldState('taxClassificationCode', /*#__PURE__*/function () {
5888
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(s) {
5889
+ return regeneratorRuntime.wrap(function _callee7$(_context7) {
5890
+ while (1) {
5891
+ switch (_context7.prev = _context7.next) {
5892
+ case 0:
5893
+ if (info.id) {
5894
+ s.value = info.id;
5895
+ }
5896
+
5897
+ case 1:
5898
+ case "end":
5899
+ return _context7.stop();
5900
+ }
5901
+ }
5902
+ }, _callee7);
5903
+ }));
5904
+
5905
+ return function (_x7) {
5906
+ return _ref7.apply(this, arguments);
5907
+ };
5908
+ }());
5909
+ actions.setFieldState('shorthand', /*#__PURE__*/function () {
5910
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(s) {
5911
+ return regeneratorRuntime.wrap(function _callee8$(_context8) {
5912
+ while (1) {
5913
+ switch (_context8.prev = _context8.next) {
5914
+ case 0:
5915
+ if (info.shorthand) {
5916
+ s.value = info.shorthand;
5917
+ }
5918
+
5919
+ case 1:
5920
+ case "end":
5921
+ return _context8.stop();
5922
+ }
5923
+ }
5924
+ }, _callee8);
5925
+ }));
5926
+
5927
+ return function (_x8) {
5928
+ return _ref8.apply(this, arguments);
5929
+ };
5930
+ }());
5931
+ setVisible(false);
5932
+ }, [list, actions, readOnlyTaxRate]);
5933
+ React.useEffect(function () {
5934
+ _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
5935
+ return regeneratorRuntime.wrap(function _callee9$(_context9) {
5936
+ while (1) {
5937
+ switch (_context9.prev = _context9.next) {
5938
+ case 0:
5939
+ _context9.t0 = setList;
5940
+ _context9.next = 3;
5941
+ return controller.state.goodsListState.endowCode.getTaxCategoryCodeTree(filter === null || filter === void 0 ? void 0 : filter.taxCategoryCode, filter === null || filter === void 0 ? void 0 : filter.val);
5942
+
5943
+ case 3:
5944
+ _context9.t1 = _context9.sent;
5945
+
5946
+ if (_context9.t1) {
5947
+ _context9.next = 6;
5948
+ break;
5949
+ }
5950
+
5951
+ _context9.t1 = [];
5952
+
5953
+ case 6:
5954
+ _context9.t2 = _context9.t1;
5955
+ (0, _context9.t0)(_context9.t2);
5956
+
5957
+ case 8:
5958
+ case "end":
5959
+ return _context9.stop();
5960
+ }
5961
+ }
5962
+ }, _callee9);
5963
+ }))();
5964
+ }, [filter]);
5965
+ React.useEffect(function () {
5966
+ if (visible) {
5967
+ setList([]);
5968
+ }
5969
+ }, [visible]);
5970
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Input, {
5971
+ readOnly: true,
5972
+ value: props.value,
5973
+ onClick: function onClick() {
5974
+ setVisible(true);
5975
+ }
5976
+ }), /*#__PURE__*/React.createElement(Drawer, {
5977
+ title: "\u7A0E\u6536\u5206\u7C7B\u7F16\u7801",
5978
+ visible: visible,
5979
+ width: 500,
5980
+ onClose: function onClose() {
5981
+ setVisible(false);
5982
+ }
5983
+ }, /*#__PURE__*/React.createElement(Form, {
5984
+ key: "".concat(visible)
5985
+ }, /*#__PURE__*/React.createElement(Form.Item, {
5986
+ label: "\u4EA7\u54C1\u6216\u670D\u52A1\u7B80\u79F0"
5987
+ }, /*#__PURE__*/React.createElement(Input, {
5988
+ onChange: function onChange(e) {
5989
+ setFilter(_objectSpread2(_objectSpread2({}, filter), {}, {
5990
+ val: e.target.value
5991
+ }));
5992
+ }
5993
+ })), /*#__PURE__*/React.createElement(Form.Item, {
5994
+ label: "\u7A0E\u6536\u5206\u7C7B\u7F16\u7801"
5995
+ }, /*#__PURE__*/React.createElement(Input, {
5996
+ onChange: function onChange(e) {
5997
+ setFilter(_objectSpread2(_objectSpread2({}, filter), {}, {
5998
+ taxCategoryCode: e.target.value
5999
+ }));
6000
+ }
6001
+ }))), list && list.length > 0 && /*#__PURE__*/React.createElement(Tree, {
6002
+ defaultExpandAll: true,
6003
+ selectedKeys: [],
6004
+ onSelect: onSelect
6005
+ }, createTreeNode())));
5761
6006
  }, [controller, actions]); // 是否享受优惠政策
5762
6007
 
5763
- var _React$useState7 = React.useState(0),
5764
- _React$useState8 = _slicedToArray(_React$useState7, 2),
5765
- favouredPolicyMark = _React$useState8[0],
5766
- setFavouredPolicyMark = _React$useState8[1]; // 确定
6008
+ var _React$useState13 = React.useState(0),
6009
+ _React$useState14 = _slicedToArray(_React$useState13, 2),
6010
+ favouredPolicyMark = _React$useState14[0],
6011
+ setFavouredPolicyMark = _React$useState14[1]; // 确定
5767
6012
 
5768
6013
 
5769
6014
  var onSubmit = React.useCallback(function (values) {
5770
6015
  controller.pipeline( /*#__PURE__*/function () {
5771
- var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(s) {
6016
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(s) {
5772
6017
  var endowCodeGood;
5773
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
6018
+ return regeneratorRuntime.wrap(function _callee10$(_context10) {
5774
6019
  while (1) {
5775
- switch (_context6.prev = _context6.next) {
6020
+ switch (_context10.prev = _context10.next) {
5776
6021
  case 0:
5777
6022
  endowCodeGood = s.goodsListState.endowCode.endowcodeGoodIndex.map(function (e) {
5778
6023
  return s.goodsListState.goodsMap.get(e);
@@ -5808,11 +6053,11 @@ var DrawerBody$3 = function DrawerBody(props) {
5808
6053
  if (!endowCodeGood.some(function (e) {
5809
6054
  return bytesLnegth((e === null || e === void 0 ? void 0 : e.itemName) || '') > 92;
5810
6055
  })) {
5811
- _context6.next = 5;
6056
+ _context10.next = 5;
5812
6057
  break;
5813
6058
  }
5814
6059
 
5815
- _context6.next = 5;
6060
+ _context10.next = 5;
5816
6061
  return function () {
5817
6062
  return new Promise(function (resolve) {
5818
6063
  confirm({
@@ -5841,14 +6086,14 @@ var DrawerBody$3 = function DrawerBody(props) {
5841
6086
 
5842
6087
  case 7:
5843
6088
  case "end":
5844
- return _context6.stop();
6089
+ return _context10.stop();
5845
6090
  }
5846
6091
  }
5847
- }, _callee6);
6092
+ }, _callee10);
5848
6093
  }));
5849
6094
 
5850
- return function (_x6) {
5851
- return _ref6.apply(this, arguments);
6095
+ return function (_x9) {
6096
+ return _ref10.apply(this, arguments);
5852
6097
  };
5853
6098
  }())();
5854
6099
  }, [controller]);
@@ -5857,23 +6102,23 @@ var DrawerBody$3 = function DrawerBody(props) {
5857
6102
  FormEffectHooks.onFieldValueChange$('taxRate').subscribe(function (e) {
5858
6103
  setTaxRate(e.value);
5859
6104
  actions.setFieldState('taxFreeType', /*#__PURE__*/function () {
5860
- var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(s) {
5861
- return regeneratorRuntime.wrap(function _callee7$(_context7) {
6105
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(s) {
6106
+ return regeneratorRuntime.wrap(function _callee11$(_context11) {
5862
6107
  while (1) {
5863
- switch (_context7.prev = _context7.next) {
6108
+ switch (_context11.prev = _context11.next) {
5864
6109
  case 0:
5865
6110
  if (e.value !== 0) s.value = undefined;
5866
6111
 
5867
6112
  case 1:
5868
6113
  case "end":
5869
- return _context7.stop();
6114
+ return _context11.stop();
5870
6115
  }
5871
6116
  }
5872
- }, _callee7);
6117
+ }, _callee11);
5873
6118
  }));
5874
6119
 
5875
- return function (_x7) {
5876
- return _ref7.apply(this, arguments);
6120
+ return function (_x10) {
6121
+ return _ref11.apply(this, arguments);
5877
6122
  };
5878
6123
  }());
5879
6124
  }); // 是否享受优惠政策
@@ -5881,23 +6126,23 @@ var DrawerBody$3 = function DrawerBody(props) {
5881
6126
  FormEffectHooks.onFieldValueChange$('favouredPolicyMark').subscribe(function (e) {
5882
6127
  setFavouredPolicyMark(e.value);
5883
6128
  actions.setFieldState('favouredPolicyName', /*#__PURE__*/function () {
5884
- var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(s) {
5885
- return regeneratorRuntime.wrap(function _callee8$(_context8) {
6129
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12(s) {
6130
+ return regeneratorRuntime.wrap(function _callee12$(_context12) {
5886
6131
  while (1) {
5887
- switch (_context8.prev = _context8.next) {
6132
+ switch (_context12.prev = _context12.next) {
5888
6133
  case 0:
5889
6134
  if (e.value === 0) s.value = undefined;
5890
6135
 
5891
6136
  case 1:
5892
6137
  case "end":
5893
- return _context8.stop();
6138
+ return _context12.stop();
5894
6139
  }
5895
6140
  }
5896
- }, _callee8);
6141
+ }, _callee12);
5897
6142
  }));
5898
6143
 
5899
- return function (_x8) {
5900
- return _ref8.apply(this, arguments);
6144
+ return function (_x11) {
6145
+ return _ref12.apply(this, arguments);
5901
6146
  };
5902
6147
  }());
5903
6148
  });
@@ -5909,7 +6154,7 @@ var DrawerBody$3 = function DrawerBody(props) {
5909
6154
  return /*#__PURE__*/React.createElement(SchemaForm, {
5910
6155
  actions: actions,
5911
6156
  components: _objectSpread2(_objectSpread2({}, components), {}, {
5912
- showSearch: ShowSearch
6157
+ showSearch: ShowSearch2
5913
6158
  }),
5914
6159
  effects: effects
5915
6160
  }, /*#__PURE__*/React.createElement(FormButtonGroup, null, /*#__PURE__*/React.createElement(SchemaMarkupField, {
@@ -5986,23 +6231,23 @@ var DrawerBody$3 = function DrawerBody(props) {
5986
6231
  }, "\u786E\u5B9A"), /*#__PURE__*/React.createElement(Button, {
5987
6232
  onClick: function onClick() {
5988
6233
  controller.pipeline( /*#__PURE__*/function () {
5989
- var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(s) {
5990
- return regeneratorRuntime.wrap(function _callee9$(_context9) {
6234
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13(s) {
6235
+ return regeneratorRuntime.wrap(function _callee13$(_context13) {
5991
6236
  while (1) {
5992
- switch (_context9.prev = _context9.next) {
6237
+ switch (_context13.prev = _context13.next) {
5993
6238
  case 0:
5994
- return _context9.abrupt("return", s.goodsListState.endowCode.endowcodeGoodIndex = []);
6239
+ return _context13.abrupt("return", s.goodsListState.endowCode.endowcodeGoodIndex = []);
5995
6240
 
5996
6241
  case 1:
5997
6242
  case "end":
5998
- return _context9.stop();
6243
+ return _context13.stop();
5999
6244
  }
6000
6245
  }
6001
- }, _callee9);
6246
+ }, _callee13);
6002
6247
  }));
6003
6248
 
6004
- return function (_x9) {
6005
- return _ref9.apply(this, arguments);
6249
+ return function (_x12) {
6250
+ return _ref13.apply(this, arguments);
6006
6251
  };
6007
6252
  }())();
6008
6253
  }