kts-component-invoice-operate 1.0.98 → 1.0.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/.dumi/theme/builtins/API.tsx +66 -66
  2. package/.editorconfig +16 -16
  3. package/.fatherrc.ts +4 -4
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +8 -8
  7. package/README.md +5 -5
  8. package/dist/Invoice/tools/coolingFn/index.d.ts +8 -0
  9. package/dist/Invoice/tools/strringFn/index.d.ts +7 -0
  10. package/dist/index.esm.js +154 -30
  11. package/dist/index.js +153 -29
  12. package/docs-dist/404.html +1 -1
  13. package/docs-dist/index.html +1 -1
  14. package/docs-dist/umi.css +2 -2
  15. package/docs-dist/umi.js +1 -1
  16. package/package.json +1 -1
  17. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/EndowCode.tsx +71 -71
  18. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood.ts +57 -57
  19. package/src/Invoice/InvoiceController/fns/addGood.ts +11 -11
  20. package/src/Invoice/InvoiceController/fns/delGood.ts +45 -45
  21. package/src/Invoice/InvoiceController/fns/saveEditGood.ts +23 -23
  22. package/src/Invoice/InvoiceController/fns/setEditGood.ts +16 -16
  23. package/src/Invoice/InvoiceController/fns/updateInvoiceNo.ts +8 -8
  24. package/src/Invoice/InvoiceController/index.ts +57 -57
  25. package/src/Invoice/_test/draft/index.tsx +2 -3
  26. package/src/Invoice/_test/easiest/index.tsx +5 -5
  27. package/src/Invoice/_test/importBuyer/index.tsx +74 -74
  28. package/src/Invoice/_test/isInvoiceNo/index.tsx +12 -12
  29. package/src/Invoice/_test/setDataSource/index.tsx +22 -22
  30. package/src/Invoice/_test/unit/index.tsx +19 -19
  31. package/src/Invoice/index.less +12 -12
  32. package/src/Invoice/index.tsx +104 -104
  33. package/src/Invoice/tools/coolingFn/index.ts +18 -0
  34. package/src/Invoice/tools/evaluate/index.ts +7 -7
  35. package/src/Invoice/tools/strringFn/index.ts +41 -0
  36. package/src/Invoice/ui/EndowCodeDrawer/index.less +8 -8
  37. package/src/Invoice/ui/EndowCodeDrawer/index.tsx +40 -14
  38. package/src/Invoice/ui/GoodsList/ui/EndowCodeButton/index.tsx +3 -8
  39. package/src/Invoice/ui/ImportBuyerDrawer/index.tsx +1 -1
  40. package/src/Invoice/ui/ImportGoodsDrawer/index.tsx +0 -1
  41. package/src/Invoice/ui/InvoiceHeader/index.tsx +13 -8
  42. package/tsconfig.json +31 -31
  43. package/typings.d.ts +3 -3
@@ -1,66 +1,66 @@
1
- import React, { useContext } from 'react';
2
- import type { IApiComponentProps } from 'dumi/theme';
3
- import { context, useApiData, AnchorLink } from 'dumi/theme';
4
-
5
- const LOCALE_TEXTS = {
6
- 'zh-CN': {
7
- name: '属性名',
8
- description: '描述',
9
- type: '类型',
10
- default: '默认值',
11
- required: '(必选)',
12
- },
13
- 'en-US': {
14
- name: 'Name',
15
- description: 'Description',
16
- type: 'Type',
17
- default: 'Default',
18
- required: '(required)',
19
- },
20
- };
21
-
22
- export default ({
23
- name,
24
- identifier,
25
- export: expt,
26
- }: IApiComponentProps & { name: string }) => {
27
- const data = useApiData(identifier);
28
- const { locale } = useContext(context);
29
- const texts = /^zh|cn$/i.test(locale)
30
- ? LOCALE_TEXTS['zh-CN']
31
- : LOCALE_TEXTS['en-US'];
32
-
33
- return (
34
- <>
35
- <p>{name}</p>
36
- {data && (
37
- <table style={{ marginTop: 24 }}>
38
- <thead>
39
- <tr>
40
- <th>{texts.name}</th>
41
- <th>{texts.description}</th>
42
- <th>{texts.type}</th>
43
- <th>{texts.default}</th>
44
- </tr>
45
- </thead>
46
- <tbody>
47
- {data[expt]?.map((row) => (
48
- <tr key={row.identifier}>
49
- <td>{row.identifier}</td>
50
- <td>{row.description || '--'}</td>
51
- <td>
52
- <code>{row.type}</code>
53
- </td>
54
- <td>
55
- <code>
56
- {row.default || (row.required && texts.required) || '--'}
57
- </code>
58
- </td>
59
- </tr>
60
- ))}
61
- </tbody>
62
- </table>
63
- )}
64
- </>
65
- );
66
- };
1
+ import React, { useContext } from 'react';
2
+ import type { IApiComponentProps } from 'dumi/theme';
3
+ import { context, useApiData, AnchorLink } from 'dumi/theme';
4
+
5
+ const LOCALE_TEXTS = {
6
+ 'zh-CN': {
7
+ name: '属性名',
8
+ description: '描述',
9
+ type: '类型',
10
+ default: '默认值',
11
+ required: '(必选)',
12
+ },
13
+ 'en-US': {
14
+ name: 'Name',
15
+ description: 'Description',
16
+ type: 'Type',
17
+ default: 'Default',
18
+ required: '(required)',
19
+ },
20
+ };
21
+
22
+ export default ({
23
+ name,
24
+ identifier,
25
+ export: expt,
26
+ }: IApiComponentProps & { name: string }) => {
27
+ const data = useApiData(identifier);
28
+ const { locale } = useContext(context);
29
+ const texts = /^zh|cn$/i.test(locale)
30
+ ? LOCALE_TEXTS['zh-CN']
31
+ : LOCALE_TEXTS['en-US'];
32
+
33
+ return (
34
+ <>
35
+ <p>{name}</p>
36
+ {data && (
37
+ <table style={{ marginTop: 24 }}>
38
+ <thead>
39
+ <tr>
40
+ <th>{texts.name}</th>
41
+ <th>{texts.description}</th>
42
+ <th>{texts.type}</th>
43
+ <th>{texts.default}</th>
44
+ </tr>
45
+ </thead>
46
+ <tbody>
47
+ {data[expt]?.map((row) => (
48
+ <tr key={row.identifier}>
49
+ <td>{row.identifier}</td>
50
+ <td>{row.description || '--'}</td>
51
+ <td>
52
+ <code>{row.type}</code>
53
+ </td>
54
+ <td>
55
+ <code>
56
+ {row.default || (row.required && texts.required) || '--'}
57
+ </code>
58
+ </td>
59
+ </tr>
60
+ ))}
61
+ </tbody>
62
+ </table>
63
+ )}
64
+ </>
65
+ );
66
+ };
package/.editorconfig CHANGED
@@ -1,16 +1,16 @@
1
- # http://editorconfig.org
2
- root = true
3
-
4
- [*]
5
- indent_style = space
6
- indent_size = 2
7
- end_of_line = lf
8
- charset = utf-8
9
- trim_trailing_whitespace = true
10
- insert_final_newline = true
11
-
12
- [*.md]
13
- trim_trailing_whitespace = false
14
-
15
- [Makefile]
16
- indent_style = tab
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = false
14
+
15
+ [Makefile]
16
+ indent_style = tab
package/.fatherrc.ts CHANGED
@@ -1,4 +1,4 @@
1
- export default {
2
- esm: 'rollup',
3
- cjs: 'rollup',
4
- };
1
+ export default {
2
+ esm: 'rollup',
3
+ cjs: 'rollup',
4
+ };
package/.prettierignore CHANGED
@@ -1,7 +1,7 @@
1
- **/*.svg
2
- **/*.ejs
3
- **/*.html
4
- package.json
5
- .umi
6
- .umi-production
7
- .umi-test
1
+ **/*.svg
2
+ **/*.ejs
3
+ **/*.html
4
+ package.json
5
+ .umi
6
+ .umi-production
7
+ .umi-test
package/.prettierrc CHANGED
@@ -1,11 +1,11 @@
1
- {
2
- "singleQuote": true,
3
- "trailingComma": "all",
4
- "printWidth": 80,
5
- "overrides": [
6
- {
7
- "files": ".prettierrc",
8
- "options": { "parser": "json" }
9
- }
10
- ]
11
- }
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "all",
4
+ "printWidth": 80,
5
+ "overrides": [
6
+ {
7
+ "files": ".prettierrc",
8
+ "options": { "parser": "json" }
9
+ }
10
+ ]
11
+ }
package/.umirc.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { defineConfig } from 'dumi';
2
-
3
- export default defineConfig({
4
- locales: [['zh-CN', '中文']],
5
- title: '发票组件',
6
- outputPath: 'docs-dist',
7
- publicPath:'/docs-dist/',
8
- });
1
+ import { defineConfig } from 'dumi';
2
+
3
+ export default defineConfig({
4
+ locales: [['zh-CN', '中文']],
5
+ title: '发票组件',
6
+ outputPath: 'docs-dist',
7
+ publicPath:'/docs-dist/',
8
+ });
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # kts-component-invoice-operate
2
-
3
- 文档地址:http://kts-component-invoice-operate.dev.kingxunlian.com/
4
-
5
-
1
+ # kts-component-invoice-operate
2
+
3
+ 文档地址:http://kts-component-invoice-operate.dev.kingxunlian.com/
4
+
5
+
6
6
  南湖:https://lanhuapp.com/web/#/item/project/detailDetach?pid=7daf94b0-9aa7-4372-89a7-226f389b021d&project_id=7daf94b0-9aa7-4372-89a7-226f389b021d&image_id=3bc42812-5718-4aa5-b088-5bc7e0c9a62f&fromEditor=true
@@ -0,0 +1,8 @@
1
+ declare const _default: (key: string | undefined, delayed: number | undefined, fn: Function) => void;
2
+ /**
3
+ * 有冷却时间的函数
4
+ * @param fn 方法
5
+ * @param key 方法key
6
+ * @param delayed 冷却时间
7
+ */
8
+ export default _default;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 判断一个字符串得字节长度
3
+ * @param str
4
+ * @returns
5
+ */
6
+ export declare function bytesLnegth(str: string): number;
7
+ export declare function cutStr(str: string, L: number): string | undefined;
package/dist/index.esm.js CHANGED
@@ -2,11 +2,11 @@ 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 } 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, Modal } from 'kts-components-antd-x3';
6
6
  import { v4 } from 'uuid';
7
7
  import classnames from 'classnames';
8
- import { createAsyncFormActions, FormEffectHooks, SchemaForm, FormButtonGroup, SchemaMarkupField } from '@formily/antd';
9
8
  import { Input as Input$1, NumberPicker } from '@formily/antd-components';
9
+ import { createAsyncFormActions, FormEffectHooks, SchemaForm, FormButtonGroup, SchemaMarkupField } from '@formily/antd';
10
10
 
11
11
  function ownKeys(object, enumerableOnly) {
12
12
  var keys = Object.keys(object);
@@ -1176,21 +1176,33 @@ var InvoiceHeader = decorator(Form.create())(function (props) {
1176
1176
  return '增值税电子专用发票';
1177
1177
  }, [props.typeOption, props.title, typeIndex]);
1178
1178
  var fieldExpand = React.useMemo(function () {
1179
- var fieldExpand = [{
1180
- label: '发票代码 :',
1181
- render: function render(form) {
1182
- return form.getFieldDecorator('code', {
1183
- initialValue: props.defaultCode
1184
- })( /*#__PURE__*/React.createElement(FormSpanString, null));
1185
- }
1186
- }, {
1187
- label: '发票号码 :',
1188
- render: function render(form) {
1189
- return form.getFieldDecorator('no', {
1190
- initialValue: props.defaultNo
1191
- })( /*#__PURE__*/React.createElement(FormSpanString, null));
1192
- }
1193
- }];
1179
+ var fieldExpand = [];
1180
+
1181
+ if (!props.fieldExpand || props.fieldExpand.some(function (e) {
1182
+ return "".concat(e.label).replace(" :", '') === '发票代码';
1183
+ }) === false) {
1184
+ fieldExpand.push({
1185
+ label: '发票代码 :',
1186
+ render: function render(form) {
1187
+ return form.getFieldDecorator('code', {
1188
+ initialValue: props.defaultCode
1189
+ })( /*#__PURE__*/React.createElement(FormSpanString, null));
1190
+ }
1191
+ });
1192
+ }
1193
+
1194
+ if (!props.fieldExpand || props.fieldExpand.some(function (e) {
1195
+ return "".concat(e.label).replace(" :", '') === '发票号码';
1196
+ }) === false) {
1197
+ fieldExpand.push({
1198
+ label: '发票号码 :',
1199
+ render: function render(form) {
1200
+ return form.getFieldDecorator('no', {
1201
+ initialValue: props.defaultNo
1202
+ })( /*#__PURE__*/React.createElement(FormSpanString, null));
1203
+ }
1204
+ });
1205
+ }
1194
1206
 
1195
1207
  if (props.defaultInvoicingDate) {
1196
1208
  fieldExpand.push({
@@ -2091,6 +2103,29 @@ var DrawerBody = decorator(Form.create())(function (props) {
2091
2103
  }, "\u4FDD\u5B58")));
2092
2104
  });
2093
2105
 
2106
+ var keys = {};
2107
+ /**
2108
+ * 有冷却时间的函数
2109
+ * @param fn 方法
2110
+ * @param key 方法key
2111
+ * @param delayed 冷却时间
2112
+ */
2113
+
2114
+ var coolingFn = (function () {
2115
+ var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
2116
+ var delayed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
2117
+ var fn = arguments.length > 2 ? arguments[2] : undefined;
2118
+
2119
+ if (keys[key]) {
2120
+ return;
2121
+ } else {
2122
+ fn();
2123
+ keys[key] = setTimeout(function () {
2124
+ delete keys[key];
2125
+ }, delayed);
2126
+ }
2127
+ });
2128
+
2094
2129
  var EndowCodeButton = (function () {
2095
2130
  var controller = default_1.useInvoiceController();
2096
2131
  /** 是否禁用 */
@@ -2123,9 +2158,8 @@ var EndowCodeButton = (function () {
2123
2158
  break;
2124
2159
  }
2125
2160
 
2126
- message.error({
2127
- content: '不能给正在编辑的货物赋码',
2128
- key: '不能给正在编辑的货物赋码'
2161
+ coolingFn('不能给正在编辑的货物赋码', 3000, function () {
2162
+ message.error('不能给正在编辑的货物赋码');
2129
2163
  });
2130
2164
  return _context.abrupt("return");
2131
2165
 
@@ -2141,9 +2175,8 @@ var EndowCodeButton = (function () {
2141
2175
  break;
2142
2176
  }
2143
2177
 
2144
- message.error({
2145
- content: '商品税率不一致不能操作批量赋码',
2146
- key: '商品税率不一致不能操作批量赋码'
2178
+ coolingFn('商品税率不一致不能操作批量赋码', 3000, function () {
2179
+ message.error('商品税率不一致不能操作批量赋码');
2147
2180
  });
2148
2181
  return _context.abrupt("return");
2149
2182
 
@@ -4932,7 +4965,7 @@ var ImportBuyerDrawer = (function () {
4932
4965
  return /*#__PURE__*/React.createElement(Drawer, {
4933
4966
  title: "\u8D2D\u65B9\u5217\u8868",
4934
4967
  placement: "right",
4935
- closable: false,
4968
+ // closable={false}
4936
4969
  destroyOnClose: true,
4937
4970
  width: 983,
4938
4971
  onClose: onClose,
@@ -5064,7 +5097,6 @@ var ImportGoodsDrawer = (function () {
5064
5097
  placement: "right",
5065
5098
  // closable={false}
5066
5099
  destroyOnClose: true,
5067
- maskClosable: true,
5068
5100
  width: 983,
5069
5101
  onClose: onClose,
5070
5102
  visible: visible
@@ -5203,9 +5235,61 @@ var getPriceExcludeTax = function getPriceExcludeTax(s, record) {
5203
5235
  return format15(evaluate("".concat(record.priceIncludeTax, " / (1+").concat(s.taxRate, "/100)")));
5204
5236
  };
5205
5237
 
5238
+ /**
5239
+ * 判断一个字符串得字节长度
5240
+ * @param str
5241
+ * @returns
5242
+ */
5243
+ function bytesLnegth(str) {
5244
+ var count = str.length;
5245
+
5246
+ for (var i = 0; i < str.length; i++) {
5247
+ if (str.charCodeAt(i) > 255) {
5248
+ count++;
5249
+ }
5250
+ }
5251
+
5252
+ return count;
5253
+ }
5254
+ /*
5255
+ * param str 要截取的字符串
5256
+ * param L 要截取的字节长度,注意是字节不是字符,一个汉字两个字节
5257
+ * return 截取后的字符串
5258
+ */
5259
+
5260
+ function cutStr(str, L) {
5261
+ var result = '',
5262
+ strlen = str.length,
5263
+ // 字符串长度
5264
+ chrlen = str.replace(/[^\x00-\xff]/g, '**').length; // 字节长度
5265
+
5266
+ if (chrlen <= L) {
5267
+ return str;
5268
+ }
5269
+
5270
+ for (var i = 0, j = 0; i < strlen; i++) {
5271
+ var chr = str.charAt(i);
5272
+
5273
+ if (/[\x00-\xff]/.test(chr)) {
5274
+ j++; // ascii码为0-255,一个字符就是一个字节的长度
5275
+ } else {
5276
+ j += 2; // ascii码为0-255以外,一个字符就是两个字节的长度
5277
+ }
5278
+
5279
+ if (j <= L) {
5280
+ // 当加上当前字符以后,如果总字节长度小于等于L,则将当前字符真实的+在result后
5281
+ result += chr;
5282
+ } else {
5283
+ // 反之则说明result已经是不拆分字符的情况下最接近L的值了,直接返回
5284
+ return result;
5285
+ }
5286
+ }
5287
+ }
5288
+
5206
5289
  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";
5207
5290
  styleInject(css_248z$a);
5208
5291
 
5292
+ var confirm = Modal.confirm;
5209
5293
  var EndowCodeDrawer = (function () {
5210
5294
  var controller = default_1.useInvoiceController();
5211
5295
  var visible = controller.useMemo(function (s) {
@@ -5475,12 +5559,16 @@ var DrawerBody$3 = function DrawerBody(props) {
5475
5559
  var onSubmit = React.useCallback(function (values) {
5476
5560
  controller.pipeline( /*#__PURE__*/function () {
5477
5561
  var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(s) {
5562
+ var endowCodeGood;
5478
5563
  return regeneratorRuntime.wrap(function _callee6$(_context6) {
5479
5564
  while (1) {
5480
5565
  switch (_context6.prev = _context6.next) {
5481
5566
  case 0:
5482
- s.goodsListState.endowCode.endowcodeGoodIndex.forEach(function (e) {
5483
- var good = s.goodsListState.goodsMap.get(e);
5567
+ endowCodeGood = s.goodsListState.endowCode.endowcodeGoodIndex.map(function (e) {
5568
+ return s.goodsListState.goodsMap.get(e);
5569
+ }); // 赋码
5570
+
5571
+ endowCodeGood.forEach(function (good) {
5484
5572
  if (!good) return; // const name = getItemName(good.itemName, values.shorthand);
5485
5573
 
5486
5574
  good.itemName = getItemName$1(good.itemName, values.shorthand); // `*${values.shorthand}*${name}`;
@@ -5505,11 +5593,43 @@ var DrawerBody$3 = function DrawerBody(props) {
5505
5593
  }
5506
5594
 
5507
5595
  good.taxAmount = chain$1(bignumber(good.lineAmountIncludeTax)).subtract(bignumber(good.lineAmountExcludeTax)).done().toNumber();
5508
- });
5596
+ }); //截取名称
5597
+
5598
+ if (!endowCodeGood.some(function (e) {
5599
+ return bytesLnegth((e === null || e === void 0 ? void 0 : e.itemName) || '') > 92;
5600
+ })) {
5601
+ _context6.next = 5;
5602
+ break;
5603
+ }
5604
+
5605
+ _context6.next = 5;
5606
+ return function () {
5607
+ return new Promise(function (resolve) {
5608
+ confirm({
5609
+ title: '温馨提示',
5610
+ content: '商品名称长度过长,是否截取名称',
5611
+ okText: '确定',
5612
+ cancelText: '取消',
5613
+ onOk: function onOk() {
5614
+ endowCodeGood.forEach(function (e) {
5615
+ if (e && e.itemName) {
5616
+ e.itemName = cutStr(e.itemName, 91);
5617
+ }
5618
+ });
5619
+ resolve();
5620
+ },
5621
+ onCancel: function onCancel() {
5622
+ resolve();
5623
+ }
5624
+ });
5625
+ });
5626
+ }();
5627
+
5628
+ case 5:
5509
5629
  s.goodsListState.goodsList = s.goodsListState.goodsList.slice();
5510
5630
  s.goodsListState.endowCode.endowcodeGoodIndex = [];
5511
5631
 
5512
- case 3:
5632
+ case 7:
5513
5633
  case "end":
5514
5634
  return _context6.stop();
5515
5635
  }
@@ -5700,7 +5820,11 @@ var getShorthand = function getShorthand(value) {
5700
5820
 
5701
5821
  var getItemName$1 = function getItemName(value, shorthand) {
5702
5822
  if (!value) value = '';
5703
- if (!shorthand) return value;
5823
+
5824
+ if (!shorthand) {
5825
+ return value.replace(/\*[^*]+\*/, "");
5826
+ }
5827
+
5704
5828
  var arr = value.match(/\*[^*]+\*/);
5705
5829
 
5706
5830
  if (arr) {