kts-component-invoice-operate 3.2.47 → 3.2.49

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 (200) 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/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.d.ts +0 -1
  9. package/dist/index.esm.js +5675 -7880
  10. package/dist/index.js +5675 -7880
  11. package/docs/index.md +5 -5
  12. package/docs-dist/static/arrowDown.a1cbf0d8.svg +2 -2
  13. package/docs-dist/static/arrowUp.4c482054.svg +2 -2
  14. package/docs-dist/static/fork.5431267d.svg +11 -11
  15. package/docs-dist/static/plus.44013ce3.svg +11 -11
  16. package/docs-dist/static/plus.4fd1af30.svg +11 -11
  17. package/index.html +12 -12
  18. package/package.json +60 -60
  19. package/src/Invoice/Invoice-digtal/_test/disabled/index.tsx +38 -38
  20. package/src/Invoice/Invoice-digtal/_test/easiest/index.tsx +16 -16
  21. package/src/Invoice/Invoice-digtal/_test/header/index.tsx +84 -84
  22. package/src/Invoice/Invoice-digtal/_test/importGoods/index.tsx +470 -470
  23. package/src/Invoice/Invoice-digtal/_test/importStakeholder/index.tsx +17 -17
  24. package/src/Invoice/Invoice-digtal/_test/lineCredit/index.tsx +20 -20
  25. package/src/Invoice/Invoice-digtal/_test/prefab/index.tsx +150 -150
  26. package/src/Invoice/Invoice-digtal/_test/readOnly/index.tsx +41 -41
  27. package/src/Invoice/Invoice-digtal/_test/stakeholder/index.tsx +12 -12
  28. package/src/Invoice/Invoice-digtal/_test/typeSelection/index.tsx +29 -29
  29. package/src/Invoice/Invoice-digtal/index.md +30 -30
  30. package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +94 -94
  31. package/src/Invoice/InvoiceController/InvoiceControllerState/AutoComplete/index.ts +17 -17
  32. package/src/Invoice/InvoiceController/InvoiceControllerState/BuyerState/index.tsx +88 -88
  33. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.ts +12 -12
  34. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/EndowCode/index.tsx +93 -93
  35. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IColumnsReplenish/index.ts +10 -10
  36. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +75 -75
  37. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ImportGoods/index.ts +80 -80
  38. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.ts +5 -5
  39. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.ts +9 -9
  40. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +107 -107
  41. package/src/Invoice/InvoiceController/InvoiceControllerState/Stakeholder/index.ts +10 -10
  42. package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +60 -60
  43. package/src/Invoice/InvoiceController/fns/addGood.ts +11 -11
  44. package/src/Invoice/InvoiceController/fns/addGoodDiscount.ts +125 -125
  45. package/src/Invoice/InvoiceController/fns/addGoodDiscountV2.ts +84 -84
  46. package/src/Invoice/InvoiceController/fns/delGood.ts +41 -41
  47. package/src/Invoice/InvoiceController/fns/getGoodsSearch.ts +26 -26
  48. package/src/Invoice/InvoiceController/fns/importGoodsDrawer.ts +67 -67
  49. package/src/Invoice/InvoiceController/fns/mergeDetails.ts +163 -161
  50. package/src/Invoice/InvoiceController/fns/mergeDiscount.ts +28 -28
  51. package/src/Invoice/InvoiceController/fns/saveEditGood.ts +24 -24
  52. package/src/Invoice/InvoiceController/fns/setEditGood.ts +16 -16
  53. package/src/Invoice/InvoiceController/fns/setGoods.ts +10 -10
  54. package/src/Invoice/InvoiceController/fns/updateInvoiceNo.ts +8 -8
  55. package/src/Invoice/InvoiceController/index.ts +77 -77
  56. package/src/Invoice/_test/buyerNameSearch/index.tsx +41 -41
  57. package/src/Invoice/_test/deduction/index.tsx +935 -935
  58. package/src/Invoice/_test/draft/index.tsx +40 -40
  59. package/src/Invoice/_test/easiest/index.tsx +5 -5
  60. package/src/Invoice/_test/endowCode/index.tsx +1099 -1099
  61. package/src/Invoice/_test/goodsMenuExpand/index.tsx +32 -32
  62. package/src/Invoice/_test/importBuyer/index.tsx +74 -74
  63. package/src/Invoice/_test/importGoods/index.tsx +515 -515
  64. package/src/Invoice/_test/invoiceType/index.tsx +59 -59
  65. package/src/Invoice/_test/isInvoiceNo/index.tsx +12 -12
  66. package/src/Invoice/_test/replaceHead/index.tsx +22 -22
  67. package/src/Invoice/_test/retrieveData/index.tsx +22 -22
  68. package/src/Invoice/_test/seller/index.tsx +28 -28
  69. package/src/Invoice/_test/setDataSource/index.tsx +73 -73
  70. package/src/Invoice/_test/unit/index.tsx +19 -19
  71. package/src/Invoice/index.less +29 -29
  72. package/src/Invoice/index.md +53 -53
  73. package/src/Invoice/index.tsx +165 -165
  74. package/src/Invoice/tools/calculate/index.ts +112 -112
  75. package/src/Invoice/tools/coolingFn/index.ts +17 -17
  76. package/src/Invoice/tools/evaluate/index.ts +7 -7
  77. package/src/Invoice/tools/idGenerator/index.ts +2 -2
  78. package/src/Invoice/tools/itemName/index.ts +55 -55
  79. package/src/Invoice/tools/lazyFn/index.ts +19 -19
  80. package/src/Invoice/tools/mounting/index.ts +13 -13
  81. package/src/Invoice/tools/strringFn/index.ts +40 -40
  82. package/src/Invoice/tools/useToGenerateId/index.ts +8 -8
  83. package/src/Invoice/ui/default/AddComparisonDrawer/index.tsx +149 -149
  84. package/src/Invoice/ui/default/Buyer/index.less +219 -219
  85. package/src/Invoice/ui/default/Buyer/index.tsx +114 -114
  86. package/src/Invoice/ui/default/Buyer/ui/BuyerNameInput/index.tsx +166 -166
  87. package/src/Invoice/ui/default/Buyer/ui/ImportBuyerButton/index.tsx +21 -21
  88. package/src/Invoice/ui/default/EndowCodeDrawer/index.less +8 -8
  89. package/src/Invoice/ui/default/EndowCodeDrawer/index.tsx +431 -431
  90. package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +533 -533
  91. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +664 -665
  92. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.less +20 -20
  93. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.tsx +202 -202
  94. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.less +18 -18
  95. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.tsx +58 -56
  96. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +17 -17
  97. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +128 -128
  98. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  99. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  100. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -76
  101. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -41
  102. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -34
  103. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -13
  104. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +98 -98
  105. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  106. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  107. package/src/Invoice/ui/default/GoodsList/hook/useDeduction/index.tsx +24 -24
  108. package/src/Invoice/ui/default/GoodsList/hook/useOnRow/index.tsx +39 -39
  109. package/src/Invoice/ui/default/GoodsList/hook/useRowSelection/index.tsx +111 -111
  110. package/src/Invoice/ui/default/GoodsList/hook/useWindowClick/index.tsx +23 -23
  111. package/src/Invoice/ui/default/GoodsList/index.less +177 -177
  112. package/src/Invoice/ui/default/GoodsList/index.tsx +191 -191
  113. package/src/Invoice/ui/default/GoodsList/ui/AddRowButton/index.tsx +65 -65
  114. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.less +21 -21
  115. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +244 -244
  116. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  117. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +69 -69
  118. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +58 -58
  119. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDetails/index.tsx +37 -37
  120. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDiscount/index.tsx +36 -36
  121. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/index.tsx +37 -37
  122. package/src/Invoice/ui/default/GoodsList/ui/DescribeSwitch/index.tsx +36 -36
  123. package/src/Invoice/ui/default/GoodsList/ui/Search/index.less +10 -10
  124. package/src/Invoice/ui/default/GoodsList/ui/Search/index.tsx +52 -52
  125. package/src/Invoice/ui/default/GoodsList/ui/Statistics/index.less +18 -18
  126. package/src/Invoice/ui/default/GoodsList/ui/Statistics/index.tsx +109 -109
  127. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.less +13 -13
  128. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.tsx +46 -46
  129. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.less +38 -38
  130. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.tsx +108 -108
  131. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual.o/index.less +44 -44
  132. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual.o/index.tsx +96 -96
  133. package/src/Invoice/ui/default/GoodsList/ui/TaxIncludedSwitch/index.tsx +30 -30
  134. package/src/Invoice/ui/default/ImportBuyerDrawer/index.tsx +75 -75
  135. package/src/Invoice/ui/default/ImportGoodsDrawer/index.tsx +193 -193
  136. package/src/Invoice/ui/default/InvoiceHeader/index.less +68 -68
  137. package/src/Invoice/ui/default/InvoiceHeader/index.tsx +246 -246
  138. package/src/Invoice/ui/default/Seller/index.less +113 -113
  139. package/src/Invoice/ui/default/Seller/index.tsx +98 -98
  140. package/src/Invoice/ui/default/Sign/index.less +14 -14
  141. package/src/Invoice/ui/default/Sign/index.tsx +71 -71
  142. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.ts +519 -519
  143. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/index.tsx +648 -648
  144. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/svg/plus.svg +11 -11
  145. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/Drag/index.less +20 -20
  146. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/Drag/index.tsx +186 -186
  147. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +9 -9
  148. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +50 -50
  149. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  150. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  151. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -76
  152. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -41
  153. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -34
  154. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -13
  155. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +98 -98
  156. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  157. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  158. package/src/Invoice/ui/digtal/GoodsList/hook/useOnRow/index.tsx +39 -39
  159. package/src/Invoice/ui/digtal/GoodsList/hook/useRowSelection/index.tsx +121 -121
  160. package/src/Invoice/ui/digtal/GoodsList/hook/useWindowClick/index.tsx +23 -23
  161. package/src/Invoice/ui/digtal/GoodsList/index.less +56 -56
  162. package/src/Invoice/ui/digtal/GoodsList/index.tsx +180 -180
  163. package/src/Invoice/ui/digtal/GoodsList/ui/AddRowButton/index.tsx +65 -65
  164. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +341 -341
  165. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/svg/add.svg +11 -11
  166. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  167. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +50 -50
  168. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEmptyRefill/index.tsx +35 -35
  169. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +82 -82
  170. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useReselectInvoiceType/index.tsx +57 -57
  171. package/src/Invoice/ui/digtal/GoodsList/ui/DescribeSwitch/index.tsx +36 -36
  172. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.less +11 -11
  173. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.tsx +50 -50
  174. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.less +53 -53
  175. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.tsx +99 -99
  176. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/svg/fork.svg +11 -11
  177. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.less +13 -13
  178. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.tsx +40 -40
  179. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.less +38 -38
  180. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.tsx +108 -108
  181. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual.o/index.less +44 -44
  182. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual.o/index.tsx +96 -96
  183. package/src/Invoice/ui/digtal/GoodsList/ui/TaxIncludedSwitch/index.tsx +30 -30
  184. package/src/Invoice/ui/digtal/InvoiceHeader/index.less +57 -57
  185. package/src/Invoice/ui/digtal/InvoiceHeader/index.tsx +77 -77
  186. package/src/Invoice/ui/digtal/Sign/index.less +48 -48
  187. package/src/Invoice/ui/digtal/Sign/index.tsx +89 -89
  188. package/src/Invoice/ui/digtal/Stakeholder/index.less +75 -75
  189. package/src/Invoice/ui/digtal/Stakeholder/index.tsx +388 -388
  190. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowDown.svg +2 -2
  191. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowUp.svg +2 -2
  192. package/src/Invoice/ui/digtal/Stakeholder/svg/plus.svg +11 -11
  193. package/src/InvoiceTypeModal/_test/easiest/index.tsx +31 -31
  194. package/src/InvoiceTypeModal/index.less +7 -7
  195. package/src/InvoiceTypeModal/index.md +5 -5
  196. package/src/InvoiceTypeModal/index.tsx +153 -153
  197. package/src/index.ts +9 -9
  198. package/tsconfig.json +31 -31
  199. package/typings.d.ts +3 -3
  200. package/yarn.e.lock +14331 -14331
@@ -1,388 +1,388 @@
1
-
2
- import React from 'react';
3
- import Icon from '@ant-design/icons';
4
- import { decorator } from "grey-react-box";
5
- import { Form } from "kts-components-antd-x3";
6
- import { AutoComplete, Button, Checkbox, Col, Input, InputProps, Row, Tooltip } from 'kts-xui'
7
- import { CheckboxChangeEvent } from 'kts-components-antd-x4/lib/checkbox';
8
- import { FormComponentProps } from "kts-components-antd-x3/lib/form";
9
- import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
10
- import { ReactComponent as ArrowUpSvg } from './svg/arrowUp.svg';
11
- import { ReactComponent as ArrowDownSvg } from './svg/arrowDown.svg';
12
- import { ReactComponent as PlusSvg } from './svg/plus.svg'
13
- import InvoiceController from "../../../InvoiceController";
14
- import Invoice from "../../../../Invoice";
15
- import './index.less';
16
- import classNames from 'classnames';
17
-
18
- const RULES = {
19
- companyName: (label: string) => [
20
- { required: true, message: `${label}必填` },
21
- { max: 200, message: `${label}内容超长` }
22
- ],
23
- taxId: (label: string) => [
24
- { max: 20, message: `${label}内容超长` },
25
- { pattern: /^([a-zA-Z0-9])*$/g, message: `${label}仅能数字、英文` }
26
- ],
27
- buyerTelPhone: (label: string) => [
28
- { max: 100, message: `${label}内容超长` },
29
- { pattern: /^[0-9\s\-\+]+$/g, message: `${label}仅能数字、空格、-、+` }
30
- ],
31
- sellerTelPhone: (label: string) => [
32
- { required: true, message: `${label}必填` },
33
- { max: 100, message: `${label}内容超长` },
34
- { pattern: /^[0-9\s\-\+]+$/g, message: `${label}仅能数字、空格、-、+` }
35
- ],
36
- bankName: (label: string) => [
37
- { max: 100, message: `${label}内容超长` }
38
- ],
39
- bankAccount: (label: string) => [
40
- { max: 100, message: `${label}内容超长` },
41
- { pattern: /^([0-9a-zA-Z-\s])*$/g, message: `${label}仅能数字、字母、-、空格` }
42
- ]
43
- }
44
-
45
- const formatCompanyName = (e: any) => {
46
- const value = e?.target?.value;
47
- if (value) {
48
- return value.replace('(', '(').replace(')', ')').replace(' ', '');
49
- }
50
- }
51
-
52
- export interface IStakeholder {
53
-
54
- /** 是否显示导入按钮 */
55
- isShowImportButton?: boolean;
56
-
57
- /** 点击了 */
58
- onClickImportButton?: (e: InvoiceController) => void
59
-
60
- /** 查看当前可用授信额度 */
61
- lineCredit?: React.ReactNode;
62
-
63
- /** 票种类型 */
64
- isVatNormal?: boolean;
65
- }
66
-
67
- /** 干系人 */
68
- export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.create())(props => {
69
-
70
- const { form, isShowImportButton, onClickImportButton, isVatNormal = false } = props;
71
-
72
- const [isExpand, setExpand] = React.useState(true);
73
-
74
- const { getFieldDecorator } = form;
75
-
76
- const controller = Invoice.useInvoiceController();
77
-
78
- const model = controller.useMemo(s => s.model, []);
79
-
80
- const disableds = controller.useMemo(s => s.stakeholder.disableds || [], []);
81
-
82
- const rulesMap = controller.useMemo(s => s.stakeholder.rulesMap || {}, []);
83
-
84
- const readOnly = React.useMemo(() => {
85
- if (model === 'readOnly') return true;
86
- if (model === 'prefab') return true;
87
- return false;
88
- }, [model]);
89
-
90
- const onExpand = React.useCallback(() => { setExpand(e => !e) }, []);
91
-
92
- const isReadOnly = React.useCallback(field => readOnly || disableds.indexOf(field) >= 0, [disableds, readOnly]);
93
-
94
- const getRules = React.useCallback((field, defaultRules) => {
95
- if (isReadOnly(field)) return [];
96
- return rulesMap[field] || defaultRules;
97
- }, [rulesMap, isReadOnly, isReadOnly]);
98
-
99
- controller.useForm('stakeholder', form);
100
-
101
- return (
102
- <div className={classNames("kts-invoice-operate-invoice-digtal-stakeholder", { readOnly: readOnly })} >
103
- <div>
104
- {'购买方信息'.split('').map(e => <span>{e}</span>)}
105
- {
106
- !readOnly &&
107
- <Icon
108
- className="digtal-stakeholder-expand-button"
109
- component={isExpand ? ArrowUpSvg : ArrowDownSvg}
110
- onClick={onExpand}
111
- />
112
- }
113
- </div>
114
- <div>
115
- <Form className="digtal-stakeholder-form" >
116
- <Row gutter={[16, 0]}>
117
- {/* <Col span={24} >
118
- <Form.Item label='购买方信息' colon={false}>
119
- {getFieldDecorator('naturalPersonFlag', {
120
- })(
121
- <NaturalPersonFlag readOnly={isReadOnly('naturalPersonFlag')} />
122
- )}
123
- </Form.Item>
124
- </Col> */}
125
-
126
- <Col span={24} >
127
- <Form.Item label='名称' colon={false}>
128
- {getFieldDecorator('buyerName', {
129
- rules: getRules('buyerName', RULES.companyName('购买方名称')),
130
- })(
131
- <BuyerNameInput
132
- myform={form}
133
- fieldName='buyerName'
134
- readOnly={isReadOnly('buyerName')}
135
- placeholder="请输入"
136
- autoComplete="off"
137
- suffix={
138
- isShowImportButton === true &&
139
- <Button
140
- type='link'
141
- style={{ padding: 0, width: 20 }}
142
- icon={<Icon component={PlusSvg} />}
143
- onClick={() => { onClickImportButton && onClickImportButton(controller) }}
144
- />
145
- }
146
- />
147
- )}
148
- </Form.Item>
149
- </Col>
150
-
151
- <Col span={24} >
152
- <Form.Item label='统一社会信用代码/纳税人识别号' colon={false}>
153
- {getFieldDecorator('buyerTaxId', {
154
- rules: getRules('buyerTaxId', [{ required: !isVatNormal, message: '购买方纳税人识别号必填' }, ...RULES.taxId('购买方纳税人识别号')])
155
- })(
156
- <BuyerNameInput
157
- myform={form}
158
- fieldName='buyerTaxId'
159
- readOnly={isReadOnly('buyerTaxId')}
160
- placeholder="请输入"
161
- autoComplete="off"
162
- />
163
- )}
164
- </Form.Item>
165
- </Col>
166
- {
167
- isExpand && (
168
- <>
169
- <Col span={15} >
170
- <Form.Item label='购买方地址' colon={false}>
171
- {getFieldDecorator('buyerAddress', {
172
- rules: getRules('buyerAddress', [{ max: 100, message: '购买方地址内容超长' }])
173
- })(<MyInput readOnly={isReadOnly('buyerAddress')} placeholder="请输入" autoComplete="off" />)}
174
- </Form.Item>
175
- </Col>
176
-
177
- <Col span={9} >
178
- <Form.Item label='电话' colon={false}>
179
- {getFieldDecorator('buyerPhone', {
180
- rules: getRules('buyerPhone', RULES.buyerTelPhone('购买方电话'))
181
- })(<MyInput readOnly={isReadOnly('buyerPhone')} placeholder="请输入" autoComplete="off" />)}
182
- </Form.Item>
183
- </Col>
184
-
185
- <Col span={12} >
186
- <Form.Item label='购买方开户银行' colon={false}>
187
- {getFieldDecorator('buyerBank', {
188
- rules: getRules('buyerBank', RULES.bankName('购买方开户银行'))
189
- })(<MyInput readOnly={isReadOnly('buyerBank')} placeholder="请输入" autoComplete="off" />)}
190
- </Form.Item>
191
- </Col>
192
-
193
- <Col span={12} >
194
- <Form.Item label='银行账号' colon={false}>
195
- {getFieldDecorator('buyerAccount', {
196
- rules: getRules('buyerAccount', RULES.bankAccount('购买方银行账号'))
197
- })(<MyInput readOnly={isReadOnly('buyerAccount')} placeholder="请输入" autoComplete="off" />)}
198
- </Form.Item>
199
- </Col>
200
- </>
201
- )
202
- }
203
- </Row>
204
- </Form>
205
- </div>
206
- <div>
207
- {'销售方信息'.split('').map(e => <span>{e}</span>)}
208
- {
209
- !readOnly &&
210
- <Icon
211
- className="digtal-stakeholder-expand-button"
212
- component={isExpand ? ArrowUpSvg : ArrowDownSvg}
213
- onClick={onExpand}
214
- />
215
- }
216
- </div>
217
- <div>
218
- {
219
- !readOnly && props.lineCredit &&
220
- <div style={{ marginTop: 20 }} >
221
- <Tooltip trigger="click" title={props.lineCredit} >
222
- <Button type="link" >查看当前可用授信额度</Button>
223
- </Tooltip>
224
- </div>
225
- }
226
- <Form className="digtal-stakeholder-form" >
227
- <Row gutter={[16, 0]}>
228
- <Col span={24} >
229
- <Form.Item label='名称' colon={false}>
230
- {getFieldDecorator('supplierName', {
231
- rules: getRules('supplierName', RULES.companyName('销售方名称')),
232
- getValueFromEvent: formatCompanyName
233
- })(<MyInput readOnly={isReadOnly('supplierName')} placeholder="请输入" autoComplete="off" />)}
234
- </Form.Item>
235
- </Col>
236
-
237
- <Col span={24} >
238
- <Form.Item label='统一社会信用代码/纳税人识别号' colon={false}>
239
- {getFieldDecorator('supplierTaxId', {
240
- rules: getRules('supplierTaxId', [{ required: true, message: '销售方纳税人识别号必填' }, ...RULES.taxId('销售方纳税人识别号')])
241
- })(<MyInput readOnly={isReadOnly('supplierTaxId')} placeholder="请输入" autoComplete="off" />)}
242
- </Form.Item>
243
- </Col>
244
- {
245
- isExpand && (
246
- <>
247
- <Col span={15} >
248
- <Form.Item label='销售方地址' colon={false}>
249
- {getFieldDecorator('sellerAddress', {
250
- rules: getRules('sellerAddress', [{ max: 300, message: '销售方地址内容超长' }])
251
- })(<MyInput readOnly={isReadOnly('sellerAddress')} placeholder="请输入" autoComplete="off" />)}
252
- </Form.Item>
253
- </Col>
254
-
255
- <Col span={9} >
256
- <Form.Item label='电话' colon={false}>
257
- {getFieldDecorator('sellerPhone', {
258
- rules: getRules('sellerPhone', RULES.sellerTelPhone('销售方电话'))
259
- })(<MyInput readOnly={isReadOnly('sellerPhone')} placeholder="请输入" autoComplete="off" />)}
260
- </Form.Item>
261
- </Col>
262
-
263
- <Col span={12} >
264
- <Form.Item label='销售方开户银行' colon={false}>
265
- {getFieldDecorator('sellerBank', {
266
- rules: getRules('sellerBank', RULES.bankName('销售方开户银行'))
267
- })(<MyInput readOnly={isReadOnly('sellerBank')} placeholder="请输入" autoComplete="off" />)}
268
- </Form.Item>
269
- </Col>
270
-
271
- <Col span={12} >
272
- <Form.Item label='银行账号' colon={false}>
273
- {getFieldDecorator('sellerAccount', {
274
- rules: getRules('sellerAccount', RULES.bankAccount('销售方银行账号'))
275
- })(<MyInput readOnly={isReadOnly('sellerAccount')} placeholder="请输入" autoComplete="off" />)}
276
- </Form.Item>
277
- </Col>
278
- </>
279
- )
280
- }
281
- </Row>
282
- </Form>
283
- </div>
284
- </div>
285
- )
286
- })
287
-
288
- function NaturalPersonFlag(props: {
289
- value?: 0 | 1,
290
- onChange?: (e: 0 | 1) => void
291
- readOnly?: boolean;
292
- }) {
293
-
294
- const [value, setValue] = React.useState(props.value || 0);
295
-
296
- const onChange = React.useCallback((e: CheckboxChangeEvent) => {
297
- if (props.readOnly) return;
298
- setValue(e.target.checked ? 1 : 0);
299
- props.onChange && props.onChange(e.target.checked ? 1 : 0);
300
- }, [props.onChange, props.readOnly])
301
-
302
- React.useEffect(() => {
303
- setValue(props.value || 0)
304
- }, [props.value])
305
-
306
- return (
307
- <Checkbox
308
- disabled={props.readOnly}
309
- checked={value === 1}
310
- onChange={onChange}
311
- >
312
- 是否开票给自然人
313
- </Checkbox>
314
- )
315
- }
316
-
317
- function BuyerNameInput(props: InputProps & { fieldName: string; myform: WrappedFormUtils<any> }) {
318
-
319
- const { fieldName, myform: form } = props;
320
-
321
- const controller = Invoice.useInvoiceController();
322
-
323
- const autoComplete = controller.useMemo(s => s.autoComplete, [])
324
-
325
- const [options, setOptions] = React.useState<any[]>([])
326
-
327
- const onChangeAutoComplete = React.useCallback(value => {
328
- const record = options.filter(e => e[fieldName] === value)[0] as any;
329
- if (!record || !form) return;
330
-
331
- form.setFieldsValue(record);
332
- setOptions([])
333
- }, [options, fieldName, form])
334
-
335
- const onSearch = React.useCallback(async (searchText: string) => {
336
- await Discontinue.start();
337
- try {
338
- if (fieldName === 'buyerName') {
339
- if (autoComplete.onBuyerNameSearch) {
340
- setOptions(await autoComplete.onBuyerNameSearch(searchText));
341
- }
342
- } else if (fieldName === 'buyerTaxId') {
343
- if (autoComplete.onBuyerTaxIdSearch) {
344
- setOptions(await autoComplete.onBuyerTaxIdSearch(searchText));
345
- }
346
- }
347
-
348
- } catch (error) {
349
- setOptions([]);
350
- throw error;
351
- }
352
- }, [autoComplete.onBuyerNameSearch, fieldName])
353
-
354
- if (props.readOnly) return <span>{props.value}</span>;
355
-
356
- return (
357
- <AutoComplete
358
- onSearch={onSearch}
359
- options={options.map(e => ({ value: e[fieldName] }))}
360
- onChange={onChangeAutoComplete}
361
- value={props.value}
362
- >
363
- <Input {...props} style={{ width: '100%', ...props.style }} />
364
- </AutoComplete>
365
- )
366
- }
367
-
368
- class MyInput extends React.Component<InputProps>{
369
- render() {
370
- const props = this.props;
371
- if (props.readOnly) {
372
- return <span>{props.value}</span>
373
- } else {
374
- return <Input {...props} />
375
- }
376
- }
377
- }
378
-
379
- class Discontinue {
380
-
381
- private static timer: any;
382
-
383
- static start = (interval = 200) => new Promise<void>(resolve => {
384
- clearTimeout(Discontinue.timer);
385
- Discontinue.timer = setTimeout(resolve, interval);
386
- })
387
- }
388
-
1
+
2
+ import React from 'react';
3
+ import Icon from '@ant-design/icons';
4
+ import { decorator } from "grey-react-box";
5
+ import { Form } from "kts-components-antd-x3";
6
+ import { AutoComplete, Button, Checkbox, Col, Input, InputProps, Row, Tooltip } from 'kts-xui'
7
+ import { CheckboxChangeEvent } from 'kts-components-antd-x4/lib/checkbox';
8
+ import { FormComponentProps } from "kts-components-antd-x3/lib/form";
9
+ import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
10
+ import { ReactComponent as ArrowUpSvg } from './svg/arrowUp.svg';
11
+ import { ReactComponent as ArrowDownSvg } from './svg/arrowDown.svg';
12
+ import { ReactComponent as PlusSvg } from './svg/plus.svg'
13
+ import InvoiceController from "../../../InvoiceController";
14
+ import Invoice from "../../../../Invoice";
15
+ import './index.less';
16
+ import classNames from 'classnames';
17
+
18
+ const RULES = {
19
+ companyName: (label: string) => [
20
+ { required: true, message: `${label}必填` },
21
+ { max: 200, message: `${label}内容超长` }
22
+ ],
23
+ taxId: (label: string) => [
24
+ { max: 20, message: `${label}内容超长` },
25
+ { pattern: /^([a-zA-Z0-9])*$/g, message: `${label}仅能数字、英文` }
26
+ ],
27
+ buyerTelPhone: (label: string) => [
28
+ { max: 100, message: `${label}内容超长` },
29
+ { pattern: /^[0-9\s\-\+]+$/g, message: `${label}仅能数字、空格、-、+` }
30
+ ],
31
+ sellerTelPhone: (label: string) => [
32
+ { required: true, message: `${label}必填` },
33
+ { max: 100, message: `${label}内容超长` },
34
+ { pattern: /^[0-9\s\-\+]+$/g, message: `${label}仅能数字、空格、-、+` }
35
+ ],
36
+ bankName: (label: string) => [
37
+ { max: 100, message: `${label}内容超长` }
38
+ ],
39
+ bankAccount: (label: string) => [
40
+ { max: 100, message: `${label}内容超长` },
41
+ { pattern: /^([0-9a-zA-Z-\s])*$/g, message: `${label}仅能数字、字母、-、空格` }
42
+ ]
43
+ }
44
+
45
+ const formatCompanyName = (e: any) => {
46
+ const value = e?.target?.value;
47
+ if (value) {
48
+ return value.replace('(', '(').replace(')', ')').replace(' ', '');
49
+ }
50
+ }
51
+
52
+ export interface IStakeholder {
53
+
54
+ /** 是否显示导入按钮 */
55
+ isShowImportButton?: boolean;
56
+
57
+ /** 点击了 */
58
+ onClickImportButton?: (e: InvoiceController) => void
59
+
60
+ /** 查看当前可用授信额度 */
61
+ lineCredit?: React.ReactNode;
62
+
63
+ /** 票种类型 */
64
+ isVatNormal?: boolean;
65
+ }
66
+
67
+ /** 干系人 */
68
+ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.create())(props => {
69
+
70
+ const { form, isShowImportButton, onClickImportButton, isVatNormal = false } = props;
71
+
72
+ const [isExpand, setExpand] = React.useState(true);
73
+
74
+ const { getFieldDecorator } = form;
75
+
76
+ const controller = Invoice.useInvoiceController();
77
+
78
+ const model = controller.useMemo(s => s.model, []);
79
+
80
+ const disableds = controller.useMemo(s => s.stakeholder.disableds || [], []);
81
+
82
+ const rulesMap = controller.useMemo(s => s.stakeholder.rulesMap || {}, []);
83
+
84
+ const readOnly = React.useMemo(() => {
85
+ if (model === 'readOnly') return true;
86
+ if (model === 'prefab') return true;
87
+ return false;
88
+ }, [model]);
89
+
90
+ const onExpand = React.useCallback(() => { setExpand(e => !e) }, []);
91
+
92
+ const isReadOnly = React.useCallback(field => readOnly || disableds.indexOf(field) >= 0, [disableds, readOnly]);
93
+
94
+ const getRules = React.useCallback((field, defaultRules) => {
95
+ if (isReadOnly(field)) return [];
96
+ return rulesMap[field] || defaultRules;
97
+ }, [rulesMap, isReadOnly, isReadOnly]);
98
+
99
+ controller.useForm('stakeholder', form);
100
+
101
+ return (
102
+ <div className={classNames("kts-invoice-operate-invoice-digtal-stakeholder", { readOnly: readOnly })} >
103
+ <div>
104
+ {'购买方信息'.split('').map(e => <span>{e}</span>)}
105
+ {
106
+ !readOnly &&
107
+ <Icon
108
+ className="digtal-stakeholder-expand-button"
109
+ component={isExpand ? ArrowUpSvg : ArrowDownSvg}
110
+ onClick={onExpand}
111
+ />
112
+ }
113
+ </div>
114
+ <div>
115
+ <Form className="digtal-stakeholder-form" >
116
+ <Row gutter={[16, 0]}>
117
+ {/* <Col span={24} >
118
+ <Form.Item label='购买方信息' colon={false}>
119
+ {getFieldDecorator('naturalPersonFlag', {
120
+ })(
121
+ <NaturalPersonFlag readOnly={isReadOnly('naturalPersonFlag')} />
122
+ )}
123
+ </Form.Item>
124
+ </Col> */}
125
+
126
+ <Col span={24} >
127
+ <Form.Item label='名称' colon={false}>
128
+ {getFieldDecorator('buyerName', {
129
+ rules: getRules('buyerName', RULES.companyName('购买方名称')),
130
+ })(
131
+ <BuyerNameInput
132
+ myform={form}
133
+ fieldName='buyerName'
134
+ readOnly={isReadOnly('buyerName')}
135
+ placeholder="请输入"
136
+ autoComplete="off"
137
+ suffix={
138
+ isShowImportButton === true &&
139
+ <Button
140
+ type='link'
141
+ style={{ padding: 0, width: 20 }}
142
+ icon={<Icon component={PlusSvg} />}
143
+ onClick={() => { onClickImportButton && onClickImportButton(controller) }}
144
+ />
145
+ }
146
+ />
147
+ )}
148
+ </Form.Item>
149
+ </Col>
150
+
151
+ <Col span={24} >
152
+ <Form.Item label='统一社会信用代码/纳税人识别号' colon={false}>
153
+ {getFieldDecorator('buyerTaxId', {
154
+ rules: getRules('buyerTaxId', [{ required: !isVatNormal, message: '购买方纳税人识别号必填' }, ...RULES.taxId('购买方纳税人识别号')])
155
+ })(
156
+ <BuyerNameInput
157
+ myform={form}
158
+ fieldName='buyerTaxId'
159
+ readOnly={isReadOnly('buyerTaxId')}
160
+ placeholder="请输入"
161
+ autoComplete="off"
162
+ />
163
+ )}
164
+ </Form.Item>
165
+ </Col>
166
+ {
167
+ isExpand && (
168
+ <>
169
+ <Col span={15} >
170
+ <Form.Item label='购买方地址' colon={false}>
171
+ {getFieldDecorator('buyerAddress', {
172
+ rules: getRules('buyerAddress', [{ max: 100, message: '购买方地址内容超长' }])
173
+ })(<MyInput readOnly={isReadOnly('buyerAddress')} placeholder="请输入" autoComplete="off" />)}
174
+ </Form.Item>
175
+ </Col>
176
+
177
+ <Col span={9} >
178
+ <Form.Item label='电话' colon={false}>
179
+ {getFieldDecorator('buyerPhone', {
180
+ rules: getRules('buyerPhone', RULES.buyerTelPhone('购买方电话'))
181
+ })(<MyInput readOnly={isReadOnly('buyerPhone')} placeholder="请输入" autoComplete="off" />)}
182
+ </Form.Item>
183
+ </Col>
184
+
185
+ <Col span={12} >
186
+ <Form.Item label='购买方开户银行' colon={false}>
187
+ {getFieldDecorator('buyerBank', {
188
+ rules: getRules('buyerBank', RULES.bankName('购买方开户银行'))
189
+ })(<MyInput readOnly={isReadOnly('buyerBank')} placeholder="请输入" autoComplete="off" />)}
190
+ </Form.Item>
191
+ </Col>
192
+
193
+ <Col span={12} >
194
+ <Form.Item label='银行账号' colon={false}>
195
+ {getFieldDecorator('buyerAccount', {
196
+ rules: getRules('buyerAccount', RULES.bankAccount('购买方银行账号'))
197
+ })(<MyInput readOnly={isReadOnly('buyerAccount')} placeholder="请输入" autoComplete="off" />)}
198
+ </Form.Item>
199
+ </Col>
200
+ </>
201
+ )
202
+ }
203
+ </Row>
204
+ </Form>
205
+ </div>
206
+ <div>
207
+ {'销售方信息'.split('').map(e => <span>{e}</span>)}
208
+ {
209
+ !readOnly &&
210
+ <Icon
211
+ className="digtal-stakeholder-expand-button"
212
+ component={isExpand ? ArrowUpSvg : ArrowDownSvg}
213
+ onClick={onExpand}
214
+ />
215
+ }
216
+ </div>
217
+ <div>
218
+ {
219
+ !readOnly && props.lineCredit &&
220
+ <div style={{ marginTop: 20 }} >
221
+ <Tooltip trigger="click" title={props.lineCredit} >
222
+ <Button type="link" >查看当前可用授信额度</Button>
223
+ </Tooltip>
224
+ </div>
225
+ }
226
+ <Form className="digtal-stakeholder-form" >
227
+ <Row gutter={[16, 0]}>
228
+ <Col span={24} >
229
+ <Form.Item label='名称' colon={false}>
230
+ {getFieldDecorator('supplierName', {
231
+ rules: getRules('supplierName', RULES.companyName('销售方名称')),
232
+ getValueFromEvent: formatCompanyName
233
+ })(<MyInput readOnly={isReadOnly('supplierName')} placeholder="请输入" autoComplete="off" />)}
234
+ </Form.Item>
235
+ </Col>
236
+
237
+ <Col span={24} >
238
+ <Form.Item label='统一社会信用代码/纳税人识别号' colon={false}>
239
+ {getFieldDecorator('supplierTaxId', {
240
+ rules: getRules('supplierTaxId', [{ required: true, message: '销售方纳税人识别号必填' }, ...RULES.taxId('销售方纳税人识别号')])
241
+ })(<MyInput readOnly={isReadOnly('supplierTaxId')} placeholder="请输入" autoComplete="off" />)}
242
+ </Form.Item>
243
+ </Col>
244
+ {
245
+ isExpand && (
246
+ <>
247
+ <Col span={15} >
248
+ <Form.Item label='销售方地址' colon={false}>
249
+ {getFieldDecorator('sellerAddress', {
250
+ rules: getRules('sellerAddress', [{ max: 300, message: '销售方地址内容超长' }])
251
+ })(<MyInput readOnly={isReadOnly('sellerAddress')} placeholder="请输入" autoComplete="off" />)}
252
+ </Form.Item>
253
+ </Col>
254
+
255
+ <Col span={9} >
256
+ <Form.Item label='电话' colon={false}>
257
+ {getFieldDecorator('sellerPhone', {
258
+ rules: getRules('sellerPhone', RULES.sellerTelPhone('销售方电话'))
259
+ })(<MyInput readOnly={isReadOnly('sellerPhone')} placeholder="请输入" autoComplete="off" />)}
260
+ </Form.Item>
261
+ </Col>
262
+
263
+ <Col span={12} >
264
+ <Form.Item label='销售方开户银行' colon={false}>
265
+ {getFieldDecorator('sellerBank', {
266
+ rules: getRules('sellerBank', RULES.bankName('销售方开户银行'))
267
+ })(<MyInput readOnly={isReadOnly('sellerBank')} placeholder="请输入" autoComplete="off" />)}
268
+ </Form.Item>
269
+ </Col>
270
+
271
+ <Col span={12} >
272
+ <Form.Item label='银行账号' colon={false}>
273
+ {getFieldDecorator('sellerAccount', {
274
+ rules: getRules('sellerAccount', RULES.bankAccount('销售方银行账号'))
275
+ })(<MyInput readOnly={isReadOnly('sellerAccount')} placeholder="请输入" autoComplete="off" />)}
276
+ </Form.Item>
277
+ </Col>
278
+ </>
279
+ )
280
+ }
281
+ </Row>
282
+ </Form>
283
+ </div>
284
+ </div>
285
+ )
286
+ })
287
+
288
+ function NaturalPersonFlag(props: {
289
+ value?: 0 | 1,
290
+ onChange?: (e: 0 | 1) => void
291
+ readOnly?: boolean;
292
+ }) {
293
+
294
+ const [value, setValue] = React.useState(props.value || 0);
295
+
296
+ const onChange = React.useCallback((e: CheckboxChangeEvent) => {
297
+ if (props.readOnly) return;
298
+ setValue(e.target.checked ? 1 : 0);
299
+ props.onChange && props.onChange(e.target.checked ? 1 : 0);
300
+ }, [props.onChange, props.readOnly])
301
+
302
+ React.useEffect(() => {
303
+ setValue(props.value || 0)
304
+ }, [props.value])
305
+
306
+ return (
307
+ <Checkbox
308
+ disabled={props.readOnly}
309
+ checked={value === 1}
310
+ onChange={onChange}
311
+ >
312
+ 是否开票给自然人
313
+ </Checkbox>
314
+ )
315
+ }
316
+
317
+ function BuyerNameInput(props: InputProps & { fieldName: string; myform: WrappedFormUtils<any> }) {
318
+
319
+ const { fieldName, myform: form } = props;
320
+
321
+ const controller = Invoice.useInvoiceController();
322
+
323
+ const autoComplete = controller.useMemo(s => s.autoComplete, [])
324
+
325
+ const [options, setOptions] = React.useState<any[]>([])
326
+
327
+ const onChangeAutoComplete = React.useCallback(value => {
328
+ const record = options.filter(e => e[fieldName] === value)[0] as any;
329
+ if (!record || !form) return;
330
+
331
+ form.setFieldsValue(record);
332
+ setOptions([])
333
+ }, [options, fieldName, form])
334
+
335
+ const onSearch = React.useCallback(async (searchText: string) => {
336
+ await Discontinue.start();
337
+ try {
338
+ if (fieldName === 'buyerName') {
339
+ if (autoComplete.onBuyerNameSearch) {
340
+ setOptions(await autoComplete.onBuyerNameSearch(searchText));
341
+ }
342
+ } else if (fieldName === 'buyerTaxId') {
343
+ if (autoComplete.onBuyerTaxIdSearch) {
344
+ setOptions(await autoComplete.onBuyerTaxIdSearch(searchText));
345
+ }
346
+ }
347
+
348
+ } catch (error) {
349
+ setOptions([]);
350
+ throw error;
351
+ }
352
+ }, [autoComplete.onBuyerNameSearch, fieldName])
353
+
354
+ if (props.readOnly) return <span>{props.value}</span>;
355
+
356
+ return (
357
+ <AutoComplete
358
+ onSearch={onSearch}
359
+ options={options.map(e => ({ value: e[fieldName] }))}
360
+ onChange={onChangeAutoComplete}
361
+ value={props.value}
362
+ >
363
+ <Input {...props} style={{ width: '100%', ...props.style }} />
364
+ </AutoComplete>
365
+ )
366
+ }
367
+
368
+ class MyInput extends React.Component<InputProps>{
369
+ render() {
370
+ const props = this.props;
371
+ if (props.readOnly) {
372
+ return <span>{props.value}</span>
373
+ } else {
374
+ return <Input {...props} />
375
+ }
376
+ }
377
+ }
378
+
379
+ class Discontinue {
380
+
381
+ private static timer: any;
382
+
383
+ static start = (interval = 200) => new Promise<void>(resolve => {
384
+ clearTimeout(Discontinue.timer);
385
+ Discontinue.timer = setTimeout(resolve, interval);
386
+ })
387
+ }
388
+