kts-component-invoice-operate 3.2.80 → 3.2.82

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 (204) 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 +8 -8
  8. package/dist/index.esm.js +637 -657
  9. package/dist/index.js +634 -654
  10. package/docs/index.md +5 -5
  11. package/docs-dist/static/arrowDown.a1cbf0d8.svg +2 -2
  12. package/docs-dist/static/arrowUp.4c482054.svg +2 -2
  13. package/docs-dist/static/fork.5431267d.svg +11 -11
  14. package/docs-dist/static/plus.44013ce3.svg +11 -11
  15. package/docs-dist/static/plus.4fd1af30.svg +11 -11
  16. package/index.html +12 -12
  17. package/package.json +61 -61
  18. package/src/Invoice/Invoice-digtal/_test/disabled/index.tsx +38 -38
  19. package/src/Invoice/Invoice-digtal/_test/easiest/index.tsx +16 -16
  20. package/src/Invoice/Invoice-digtal/_test/header/index.tsx +84 -84
  21. package/src/Invoice/Invoice-digtal/_test/importGoods/index.tsx +470 -470
  22. package/src/Invoice/Invoice-digtal/_test/importStakeholder/index.tsx +17 -17
  23. package/src/Invoice/Invoice-digtal/_test/lineCredit/index.tsx +20 -20
  24. package/src/Invoice/Invoice-digtal/_test/prefab/index.tsx +150 -150
  25. package/src/Invoice/Invoice-digtal/_test/readOnly/index.tsx +42 -42
  26. package/src/Invoice/Invoice-digtal/_test/stakeholder/index.tsx +12 -12
  27. package/src/Invoice/Invoice-digtal/_test/typeSelection/index.tsx +29 -29
  28. package/src/Invoice/Invoice-digtal/index.md +30 -30
  29. package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +94 -94
  30. package/src/Invoice/InvoiceController/InvoiceControllerState/AutoComplete/index.ts +17 -17
  31. package/src/Invoice/InvoiceController/InvoiceControllerState/BuyerState/index.tsx +88 -88
  32. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.ts +15 -15
  33. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/EndowCode/index.tsx +104 -104
  34. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IColumnsReplenish/index.ts +10 -10
  35. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +78 -78
  36. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ImportGoods/index.ts +80 -80
  37. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.ts +7 -7
  38. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.ts +9 -9
  39. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +113 -113
  40. package/src/Invoice/InvoiceController/InvoiceControllerState/Stakeholder/index.ts +13 -13
  41. package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +65 -65
  42. package/src/Invoice/InvoiceController/fns/addGood.ts +11 -11
  43. package/src/Invoice/InvoiceController/fns/addGoodDiscount.ts +126 -126
  44. package/src/Invoice/InvoiceController/fns/addGoodDiscountV2.ts +85 -85
  45. package/src/Invoice/InvoiceController/fns/delGood.ts +41 -41
  46. package/src/Invoice/InvoiceController/fns/getGoodsSearch.ts +26 -26
  47. package/src/Invoice/InvoiceController/fns/importGoodsDrawer.ts +79 -79
  48. package/src/Invoice/InvoiceController/fns/mergeDetails.ts +165 -165
  49. package/src/Invoice/InvoiceController/fns/mergeDiscount.ts +28 -28
  50. package/src/Invoice/InvoiceController/fns/saveEditGood.ts +24 -24
  51. package/src/Invoice/InvoiceController/fns/setEditGood.ts +16 -16
  52. package/src/Invoice/InvoiceController/fns/setGoods.ts +10 -10
  53. package/src/Invoice/InvoiceController/fns/updateInvoiceNo.ts +8 -8
  54. package/src/Invoice/InvoiceController/index.ts +77 -77
  55. package/src/Invoice/_test/buyerNameSearch/index.tsx +42 -42
  56. package/src/Invoice/_test/deduction/index.tsx +935 -935
  57. package/src/Invoice/_test/draft/index.tsx +40 -40
  58. package/src/Invoice/_test/easiest/index.tsx +5 -5
  59. package/src/Invoice/_test/endowCode/index.tsx +1071 -1071
  60. package/src/Invoice/_test/goodsMenuExpand/index.tsx +32 -32
  61. package/src/Invoice/_test/importBuyer/index.tsx +74 -74
  62. package/src/Invoice/_test/importGoods/index.tsx +1078 -516
  63. package/src/Invoice/_test/invoiceType/index.tsx +59 -59
  64. package/src/Invoice/_test/isInvoiceNo/index.tsx +12 -12
  65. package/src/Invoice/_test/replaceHead/index.tsx +22 -22
  66. package/src/Invoice/_test/retrieveData/index.tsx +22 -22
  67. package/src/Invoice/_test/seller/index.tsx +28 -28
  68. package/src/Invoice/_test/setDataSource/index.tsx +66 -66
  69. package/src/Invoice/_test/unit/index.tsx +19 -19
  70. package/src/Invoice/index.less +29 -29
  71. package/src/Invoice/index.md +53 -53
  72. package/src/Invoice/index.tsx +165 -165
  73. package/src/Invoice/tools/calculate/index.ts +112 -112
  74. package/src/Invoice/tools/coolingFn/index.ts +17 -17
  75. package/src/Invoice/tools/evaluate/index.ts +7 -7
  76. package/src/Invoice/tools/idGenerator/index.ts +2 -2
  77. package/src/Invoice/tools/itemName/index.ts +55 -55
  78. package/src/Invoice/tools/lazyFn/index.ts +19 -19
  79. package/src/Invoice/tools/mounting/index.ts +13 -13
  80. package/src/Invoice/tools/strringFn/index.ts +40 -40
  81. package/src/Invoice/tools/useToGenerateId/index.ts +8 -8
  82. package/src/Invoice/ui/default/AddComparisonDrawer/index.tsx +149 -149
  83. package/src/Invoice/ui/default/Buyer/index.less +219 -219
  84. package/src/Invoice/ui/default/Buyer/index.tsx +114 -114
  85. package/src/Invoice/ui/default/Buyer/ui/BuyerNameInput/index.tsx +166 -166
  86. package/src/Invoice/ui/default/Buyer/ui/ImportBuyerButton/index.tsx +21 -21
  87. package/src/Invoice/ui/default/EndowCodeDrawer/index.less +8 -8
  88. package/src/Invoice/ui/default/EndowCodeDrawer/index.tsx +543 -552
  89. package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +533 -533
  90. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +664 -664
  91. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.less +20 -20
  92. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.tsx +205 -205
  93. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.less +18 -18
  94. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.tsx +47 -47
  95. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +17 -17
  96. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +75 -75
  97. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  98. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  99. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -76
  100. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +45 -45
  101. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +38 -38
  102. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -13
  103. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +98 -98
  104. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  105. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  106. package/src/Invoice/ui/default/GoodsList/hook/useDeduction/index.tsx +24 -24
  107. package/src/Invoice/ui/default/GoodsList/hook/useOnRow/index.tsx +39 -39
  108. package/src/Invoice/ui/default/GoodsList/hook/useRowSelection/index.tsx +111 -111
  109. package/src/Invoice/ui/default/GoodsList/hook/useWindowClick/index.tsx +23 -23
  110. package/src/Invoice/ui/default/GoodsList/index.less +179 -179
  111. package/src/Invoice/ui/default/GoodsList/index.tsx +205 -205
  112. package/src/Invoice/ui/default/GoodsList/ui/AddRowButton/index.tsx +65 -65
  113. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.less +21 -21
  114. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +244 -244
  115. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  116. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +69 -69
  117. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +65 -65
  118. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDetails/index.tsx +91 -91
  119. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDiscount/index.tsx +36 -36
  120. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useSalesDiscount/index.tsx +110 -110
  121. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useSalesGifts/index.tsx +75 -75
  122. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/index.tsx +37 -37
  123. package/src/Invoice/ui/default/GoodsList/ui/DescribeSwitch/index.tsx +36 -36
  124. package/src/Invoice/ui/default/GoodsList/ui/Search/index.less +10 -10
  125. package/src/Invoice/ui/default/GoodsList/ui/Search/index.tsx +52 -52
  126. package/src/Invoice/ui/default/GoodsList/ui/Statistics/index.less +18 -18
  127. package/src/Invoice/ui/default/GoodsList/ui/Statistics/index.tsx +109 -109
  128. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.less +28 -28
  129. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.tsx +57 -57
  130. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.less +38 -38
  131. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.tsx +108 -108
  132. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual.o/index.less +44 -44
  133. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual.o/index.tsx +96 -96
  134. package/src/Invoice/ui/default/GoodsList/ui/TaxIncludedSwitch/index.tsx +30 -30
  135. package/src/Invoice/ui/default/ImportBuyerDrawer/index.tsx +75 -75
  136. package/src/Invoice/ui/default/ImportGoodsDrawer/index.tsx +201 -201
  137. package/src/Invoice/ui/default/InvoiceHeader/index.less +68 -68
  138. package/src/Invoice/ui/default/InvoiceHeader/index.tsx +246 -246
  139. package/src/Invoice/ui/default/Seller/index.less +113 -113
  140. package/src/Invoice/ui/default/Seller/index.tsx +98 -98
  141. package/src/Invoice/ui/default/Sign/index.less +14 -14
  142. package/src/Invoice/ui/default/Sign/index.tsx +71 -71
  143. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.ts +519 -519
  144. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/index.tsx +648 -648
  145. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/svg/plus.svg +11 -11
  146. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/Drag/index.less +20 -20
  147. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/Drag/index.tsx +205 -205
  148. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +9 -9
  149. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +50 -50
  150. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  151. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  152. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -76
  153. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -41
  154. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -34
  155. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -13
  156. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +98 -98
  157. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  158. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  159. package/src/Invoice/ui/digtal/GoodsList/hook/useOnRow/index.tsx +39 -39
  160. package/src/Invoice/ui/digtal/GoodsList/hook/useRowSelection/index.tsx +121 -121
  161. package/src/Invoice/ui/digtal/GoodsList/hook/useWindowClick/index.tsx +23 -23
  162. package/src/Invoice/ui/digtal/GoodsList/index.less +56 -56
  163. package/src/Invoice/ui/digtal/GoodsList/index.tsx +180 -180
  164. package/src/Invoice/ui/digtal/GoodsList/ui/AddRowButton/index.tsx +65 -65
  165. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +339 -339
  166. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/svg/add.svg +11 -11
  167. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  168. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +50 -50
  169. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEmptyRefill/index.tsx +35 -35
  170. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +82 -82
  171. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useReselectInvoiceType/index.tsx +57 -57
  172. package/src/Invoice/ui/digtal/GoodsList/ui/DescribeSwitch/index.tsx +36 -36
  173. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.less +11 -11
  174. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.tsx +50 -50
  175. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.less +53 -53
  176. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.tsx +99 -99
  177. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/svg/fork.svg +11 -11
  178. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.less +28 -28
  179. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.tsx +53 -53
  180. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.less +38 -38
  181. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.tsx +108 -108
  182. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual.o/index.less +44 -44
  183. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual.o/index.tsx +96 -96
  184. package/src/Invoice/ui/digtal/GoodsList/ui/TaxIncludedSwitch/index.tsx +30 -30
  185. package/src/Invoice/ui/digtal/InvoiceHeader/index.less +57 -57
  186. package/src/Invoice/ui/digtal/InvoiceHeader/index.tsx +77 -77
  187. package/src/Invoice/ui/digtal/Sign/index.less +48 -48
  188. package/src/Invoice/ui/digtal/Sign/index.tsx +99 -99
  189. package/src/Invoice/ui/digtal/Stakeholder/index.less +75 -75
  190. package/src/Invoice/ui/digtal/Stakeholder/index.tsx +394 -394
  191. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowDown.svg +2 -2
  192. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowUp.svg +2 -2
  193. package/src/Invoice/ui/digtal/Stakeholder/svg/plus.svg +11 -11
  194. package/src/InvoiceTypeModal/_test/easiest/index.tsx +31 -31
  195. package/src/InvoiceTypeModal/index.less +7 -7
  196. package/src/InvoiceTypeModal/index.md +5 -5
  197. package/src/InvoiceTypeModal/index.tsx +153 -153
  198. package/src/TaxClassificationCodeModal/_test/easiest/index.tsx +177 -178
  199. package/src/TaxClassificationCodeModal/index.md +6 -6
  200. package/src/TaxClassificationCodeModal/index.tsx +67 -67
  201. package/src/index.ts +12 -12
  202. package/tsconfig.json +31 -31
  203. package/typings.d.ts +3 -3
  204. package/yarn.e.lock +14331 -14331
@@ -1,649 +1,649 @@
1
-
2
- import React from 'react';
3
- import Icon from '@ant-design/icons';
4
- import { Form } from 'kts-components-antd-x3';
5
- import { ReactComponent as PlusSvg } from './svg/plus.svg'
6
- import { AutoComplete, Select, Button, Input, Spin, Tooltip, InputProps } from 'kts-xui';
7
- import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
8
- import { getItemNameWithShorthand } from '../../../../../tools/itemName';
9
- import { IGood, LineAttributeType } from '../../../../../InvoiceController';
10
- import Invoice from '../../../../..';
11
- import TitleText from './ui/TitleText';
12
- import ItemNameInput from './ui/ItemNameInput';
13
- import {
14
- onChangeQuantity,
15
- onChangePriceIncludeTax,
16
- onChangePriceExcludeTax,
17
- onChangeLineAmountIncludeTax,
18
- onChangeLineAmountExcludeTax,
19
- onChangeTaxRate,
20
- onChangeItemName,
21
- } from './autoFillFn';
22
- import Drag from './ui/Drag';
23
-
24
- export default (form: WrappedFormUtils) => {
25
- const { getFieldDecorator, getFieldValue } = form;
26
-
27
- const controller = Invoice.useInvoiceController();
28
-
29
- /** 是否含税 */
30
- const isTaxIncluded = controller.useMemo(e => e.goodsListState.isTaxIncluded, []);
31
-
32
- /** 组件模式 */
33
- const model = controller.useMemo(e => e.model, []);
34
-
35
- /** 是否显示我方 */
36
- const isMyShow = controller.useMemo(e => e.goodsListState.isMyShow, []);
37
-
38
- /** 正在编辑的货物 */
39
- const editGood = controller.useMemo((e) => e.goodsListState.editGood, []);
40
-
41
- /** 是否启用拖拽 */
42
- const isStart = controller.useMemo((e) => e.goodsListState.drag.isStart, []);
43
-
44
- /** 搜索条件 */
45
- const searchValue = controller.useMemo((e) => e.goodsListState.searchValue, []);
46
-
47
- /** 税率列表 */
48
- const taxRateList = controller.useMemo((e) => e.goodsListState.taxRateList, []);
49
-
50
- /** 单位列表 */
51
- const unitList = controller.useMemo((e) => e.goodsListState.unitList, []);
52
-
53
- /** 商品表格补充配置 */
54
- const columnsReplenish = controller.useMemo((e) => e.goodsListState.columnsReplenish, []);
55
-
56
- /** 扣除额 */
57
- const deduction = controller.useMemo((e) => e.goodsListState.deduction, []);
58
-
59
- /** 计算中启动字段 */
60
- const changeField = controller.useMemo((e) => e.calculatingField, []);
61
-
62
- /** 计算中启动字段 */
63
- const setChangeField = React.useCallback((value: string) => controller.run(async s => { s.calculatingField = value }), []);
64
-
65
- const onNumberValueChange = React.useCallback((e) => {
66
- const value = e?.target?.value;
67
- if (value) {
68
- return value.replace(/[^0-9-\.]/g, '');
69
- }
70
- }, [])
71
-
72
- /** 获取补充校验规则 */
73
- const getReplenishRules = React.useCallback((id: string) => {
74
- return columnsReplenish[id] ? columnsReplenish[id].rules || [] : []
75
- }, [columnsReplenish])
76
-
77
- /** 金额整数位限制,不传默认9位 */
78
- const priceIntegerDigit = controller.useMemo((e) => e.priceIntegerDigit || 9, []);
79
-
80
- /** 表头 */
81
- const columns = React.useMemo(() => {
82
- return [
83
- {
84
- title: ' ',
85
- key: 'drag',
86
- width: 40,
87
- align: 'center',
88
- render: (_: any, record: IGood) => <Drag record={record} />
89
- },
90
- {
91
- title: '序号',
92
- key: 'serialNo',
93
- dataIndex: 'serialNo',
94
- width: 50,
95
- render: (e: number) => <span style={{ padding: '0 10px' }}>{e}</span>,
96
- },
97
- {
98
- title: <TitleText required >项目名称</TitleText>,
99
- key: 'itemName',
100
- render: (_: string, record: IGood) => {
101
- if (editGood?.$index === record.$index) {
102
- return (
103
- <Form.Item>
104
- <div style={{ display: 'flex' }} >
105
- {getFieldDecorator('itemName', {
106
- initialValue: isMyShow ? record.itemNameSelf : record.itemName,
107
- rules: [
108
- ...getReplenishRules('itemName'),
109
- {
110
- validator: async (_, __, callback) => {
111
- await controller.wait();
112
- const value = controller.state.goodsListState.editGood;
113
- if (!value?.itemName && !value?.itemNameSelf) {
114
- callback('项目名称不能为空');
115
- } else {
116
- return;
117
- }
118
- }
119
- }
120
- ]
121
- })(
122
- <ItemNameInput
123
- shorthand={editGood.shorthand}
124
- suffix={
125
- <Tooltip title="点击从商品管理中添加商品信息">
126
- <Button
127
- type="link"
128
- style={{ padding: 0, width: 20, fontSize: 20, fill: '#0074ff' }}
129
- icon={<PlusSvg />}
130
- onClick={controller.pipeline(async s => { s.goodsListState.importGoods.isVisibleDrawer = true })}
131
- />
132
- </Tooltip>
133
- }
134
- onChange={() => {
135
- onChangeItemName(controller, form, record);
136
- }}
137
- />
138
- )}
139
- {/* <div className="kts-invoice-operate-goods-list-able-list-itemName-import">
140
- {controller.getGoodsList && model !== 'readOnly' && (
141
- <Tooltip title="点击从商品管理中添加商品信息">
142
- <Button
143
- onClick={controller.pipeline(async s => { s.goodsListState.importGoods.isVisibleDrawer = true })}
144
- type="link"
145
- icon="plus-circle"
146
- />
147
- </Tooltip>
148
- )}
149
- </div> */}
150
- </div>
151
- </Form.Item>
152
- );
153
- } else {
154
- return (
155
- <span>
156
- {record.lineAttribute === LineAttributeType.折扣行 ? <span className='goods-list-digtal-discount-tag'>折扣</span> : <></>}
157
- <MyItemNameDiv
158
- valueT={formatSearch(getItemNameWithShorthand({ shorthand: record.shorthand, full: record.itemNameSelf || '' }), searchValue)}
159
- valueF={formatSearch(getItemNameWithShorthand({ shorthand: record.shorthand, full: record.itemName || '' }), searchValue)}
160
- isMyShow={isMyShow}
161
- />
162
- </span>
163
- )
164
- }
165
- },
166
- },
167
- {
168
- title: <TitleText rules={columnsReplenish['itemModelName']?.rules} >规格型号</TitleText>,
169
- key: 'itemModelName',
170
- width: 119,
171
- render: (_: string, record: IGood) => {
172
- if (editGood?.$index === record.$index) {
173
- return (
174
- <Form.Item>
175
- {getFieldDecorator('itemModelName', {
176
- initialValue: isMyShow ? editGood.itemModelNameSelf : editGood.itemModelName,
177
- rules: getReplenishRules('itemModelName'),
178
- })(
179
- <MyInput
180
- onChange={async () => {
181
- await controller.wait()
182
- const key = isMyShow ? 'itemModelNameSelf' : 'itemModelName';
183
- const value = {} as any;
184
- value[key] = form.getFieldsValue().itemModelName;
185
- controller.setEditGood(value);
186
- }}
187
- />,
188
- )}
189
- </Form.Item>
190
- );
191
- } else {
192
- return (
193
- <MyItemNameDiv
194
- valueT={formatSearch(record.itemModelNameSelf, searchValue)}
195
- valueF={formatSearch(record.itemModelName, searchValue)}
196
- isMyShow={isMyShow}
197
- />
198
- )
199
- }
200
- },
201
- },
202
- {
203
- title: <TitleText rules={columnsReplenish['unit']?.rules} >单位</TitleText>,
204
- key: 'unit',
205
- width: 70,
206
- render: (_: string, record: IGood) => {
207
- if (editGood?.$index === record.$index) {
208
- return (
209
- <Form.Item>
210
- {getFieldDecorator('unit', {
211
- initialValue: editGood.unit,
212
- rules: getReplenishRules('unit'),
213
- })(
214
- <AutoComplete
215
- style={{ width: '100%' }}
216
- dataSource={unitList}
217
- onChange={async () => {
218
- await controller.wait()
219
- // const key = isMyShow ? 'unit' : 'unitOther';
220
- // const value = {} as any;
221
- // value[key] = form.getFieldsValue().unit;
222
- controller.setEditGood({ unit: form.getFieldsValue().unit });
223
- }}
224
- />,
225
- )}
226
- </Form.Item>
227
- );
228
- } else {
229
- return <span style={{ padding: '0 10px' }}>{record.unit}</span>;
230
- }
231
- },
232
- },
233
- {
234
- title: <TitleText rules={columnsReplenish['quantity']?.rules} >数量</TitleText>,
235
- dataIndex: 'quantity',
236
- key: 'quantity',
237
- align: 'right',
238
- width: 149,
239
- render: (value: string, record: IGood) => {
240
- if (editGood?.$index === record.$index) {
241
- return (
242
- <Form.Item>
243
- {getFieldDecorator('quantity', {
244
- initialValue: editGood.quantity,
245
- getValueFromEvent: onNumberValueChange,
246
- rules: [
247
- ...getReplenishRules('quantity'),
248
- { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '数量必须为数字' },
249
- {
250
- validator: async (_, value, callback) => {
251
- await controller.wait();
252
- const isvalue = !!value || value === 0;
253
- const isPrice = !!getFieldValue(isTaxIncluded ? 'priceIncludeTax' : 'priceExcludeTax') || getFieldValue(isTaxIncluded ? 'priceIncludeTax' : 'priceExcludeTax') === 0;
254
- if (isvalue || isPrice === isvalue) return;
255
- callback('请输入数量');
256
- }
257
- }
258
- ],
259
- })(
260
- <MyInput
261
- style={{ textAlign: 'right' }}
262
- maxLength={16}
263
- loading={isCipher(changeField, "quantity")}
264
- onChange={async () => {
265
- setChangeField('quantity');
266
- await onChangeQuantity(controller, form, record);
267
- }}
268
- />,
269
- )}
270
- </Form.Item>
271
- );
272
- } else {
273
- return <span style={{ padding: '0 10px' }}>{value}</span>;
274
- }
275
- },
276
- },
277
- {
278
- title: <TitleText rules={columnsReplenish['priceIncludeTax']?.rules} >单价(含税)</TitleText>,
279
- dataIndex: 'priceIncludeTax',
280
- key: 'priceIncludeTax',
281
- align: 'right',
282
- width: 149,
283
- render: (value: string, record: IGood) => {
284
- if (editGood?.$index === record.$index) {
285
- return (
286
- <Form.Item>
287
- {getFieldDecorator('priceIncludeTax', {
288
- initialValue: editGood.priceIncludeTax,
289
- getValueFromEvent: onNumberValueChange,
290
- rules: [
291
- ...getReplenishRules('priceIncludeTax'),
292
- { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '单价必须为数字' },
293
- {
294
- validator: async (_, value, callback) => {
295
- await controller.wait();
296
- const isQuantity = !!getFieldValue('quantity') || getFieldValue('quantity') === 0;
297
- const isvalue = !!value || value === 0;
298
- if (isvalue || isQuantity === isvalue) return;
299
- callback('请输入单价');
300
- }
301
- }
302
- ],
303
- })(
304
- <MyInput
305
- style={{ textAlign: 'right' }}
306
- maxLength={16}
307
- loading={isCipher(changeField, 'priceIncludeTax')}
308
- onChange={() => {
309
- setChangeField('priceIncludeTax');
310
- onChangePriceIncludeTax(controller, form, record);
311
- }}
312
- />,
313
- )}
314
- </Form.Item>
315
- );
316
- } else {
317
- return <span style={{ padding: '0 10px' }}>{value}</span>;
318
- }
319
- },
320
- },
321
- {
322
- title: <TitleText rules={columnsReplenish['priceExcludeTax']?.rules} >单价(不含税)</TitleText>,
323
- dataIndex: 'priceExcludeTax',
324
- key: 'priceExcludeTax',
325
- align: 'right',
326
- width: 149,
327
- render: (value: string, record: IGood) => {
328
- if (editGood?.$index === record.$index) {
329
- return (
330
- <Form.Item>
331
- {getFieldDecorator('priceExcludeTax', {
332
- initialValue: editGood.priceExcludeTax,
333
- getValueFromEvent: onNumberValueChange,
334
- rules: [
335
- ...getReplenishRules('priceExcludeTax'),
336
- { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '单价必须为数字' },
337
- {
338
- validator: async (_, value, callback) => {
339
- await controller.wait();
340
- const isQuantity = !!getFieldValue('quantity') || getFieldValue('quantity') === 0;
341
- const isvalue = !!value || value === 0;
342
- if (isvalue || isQuantity === isvalue) return;
343
- callback('请输入单价');
344
- }
345
- }
346
- ],
347
- })(
348
- <MyInput
349
- style={{ textAlign: 'right' }}
350
- maxLength={16}
351
- loading={isCipher(changeField, 'priceExcludeTax')}
352
- onChange={() => {
353
- setChangeField('priceExcludeTax');
354
- onChangePriceExcludeTax(controller, form, record);
355
- }}
356
- />,
357
- )}
358
- </Form.Item>
359
- );
360
- } else {
361
- return <span style={{ padding: '0 10px' }}>{value}</span>;
362
- }
363
- },
364
- },
365
- {
366
- title: <TitleText required >金额(含税)</TitleText>,
367
- dataIndex: 'lineAmountIncludeTax',
368
- key: 'lineAmountIncludeTax',
369
- width: 119,
370
- align: 'right',
371
- render: (value: string, record: IGood) => {
372
- if (editGood?.$index === record.$index) {
373
- return (
374
- <Form.Item>
375
- {getFieldDecorator('lineAmountIncludeTax', {
376
- initialValue: editGood.lineAmountIncludeTax,
377
- getValueFromEvent: onNumberValueChange,
378
- rules: [
379
- ...getReplenishRules('lineAmountIncludeTax'),
380
- { required: true, message: '金额不能为空' },
381
- { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '金额必须为数字' },
382
- {
383
- validator: async (_, value, callback) => {
384
- if (`${value}`.split('.')[0].length > priceIntegerDigit) {
385
- callback(`金额整数部分不能大于${priceIntegerDigit}位,小数点后最多2位`);
386
- }
387
- }
388
- },
389
- {
390
- validator: async (_, value, callback) => {
391
- if (deduction && parseFloat(value) <= deduction) {
392
- callback('扣除额不能大于等于价税合计');
393
- }
394
- }
395
- },
396
- ],
397
- })(
398
- <MyInput
399
- style={{ textAlign: 'right' }}
400
- loading={isCipher(changeField, 'lineAmountIncludeTax')}
401
- onChange={() => {
402
- setChangeField('lineAmountIncludeTax');
403
- onChangeLineAmountIncludeTax(controller, form, record);
404
- }}
405
- />,
406
- )}
407
- </Form.Item>
408
- );
409
- } else {
410
- return <span style={{ padding: '0 10px' }}>{formatSearch(parseFloat(value).toFixed(2), searchValue)}</span>;
411
- }
412
- },
413
- },
414
- {
415
- title: <TitleText required >金额(不含税)</TitleText>,
416
- dataIndex: 'lineAmountExcludeTax',
417
- key: 'lineAmountExcludeTax',
418
- align: 'right',
419
- width: 119,
420
- render: (value: string, record: IGood) => {
421
- if (editGood?.$index === record.$index) {
422
- return (
423
- <Form.Item>
424
- {getFieldDecorator('lineAmountExcludeTax', {
425
- initialValue: editGood.lineAmountExcludeTax,
426
- getValueFromEvent: onNumberValueChange,
427
- rules: [
428
- ...getReplenishRules('lineAmountExcludeTax'),
429
- { required: true, message: '金额不能为空' },
430
- { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '金额必须为数字' },
431
- {
432
- validator: async (_, value: string, callback) => {
433
- if (`${value}`.split('.')[0].length > priceIntegerDigit) {
434
- callback(`金额整数部分不能大于${priceIntegerDigit}位,小数点后最多2位`);
435
- }
436
- }
437
- },
438
- ],
439
- })(
440
- <MyInput
441
- style={{ textAlign: 'right' }}
442
- loading={isCipher(changeField, 'lineAmountExcludeTax')}
443
- onChange={() => {
444
- setChangeField('lineAmountExcludeTax');
445
- onChangeLineAmountExcludeTax(controller, form, record);
446
- }}
447
- />,
448
- )}
449
- </Form.Item>
450
- );
451
- } else {
452
- return <span style={{ padding: '0 10px' }}>{formatSearch(parseFloat(value).toFixed(2), searchValue)}</span>;
453
- }
454
- },
455
- },
456
- {
457
- title: <TitleText required >税率%</TitleText>,
458
- dataIndex: 'taxRate',
459
- key: 'taxRate',
460
- align: 'right',
461
- width: 70,
462
- render: (value: string, record: IGood) => {
463
- if (editGood?.$index === record.$index) {
464
- return (
465
- <Form.Item>
466
- {getFieldDecorator('taxRate', {
467
- initialValue: editGood.taxRate,
468
- rules: [
469
- ...getReplenishRules('taxRate'),
470
- { required: true, message: ' ' },
471
- { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: ' ' },
472
- ],
473
- })(
474
- <Select
475
- className="kts-invoice-operate-goods-list-table-tax-rate"
476
- // dropdownMenuStyle={{ textAlign: "right" }}
477
- showArrow={false}
478
- style={{ width: '100%' }}
479
- onChange={() => {
480
- setChangeField('taxRate');
481
- onChangeTaxRate(controller, form, record);
482
- }}
483
- >
484
- {taxRateList.map((e, i) => {
485
- return (
486
- <Select.Option key={i} value={e}>
487
- {e}%
488
- </Select.Option>
489
- );
490
- })}
491
- </Select>,
492
- )}
493
- </Form.Item>
494
- );
495
- } else {
496
- return <span style={{ padding: '0 10px' }}>{value}%</span>;
497
- }
498
- },
499
- },
500
- {
501
- title: <TitleText rules={columnsReplenish['taxAmount']?.rules} >税额</TitleText>,
502
- dataIndex: 'taxAmount',
503
- key: 'taxAmount',
504
- align: 'right',
505
- width: 119,
506
- render: (value: string, record: IGood) => {
507
- if (editGood?.$index === record.$index) {
508
- return getFieldDecorator('taxAmount', {
509
- initialValue: editGood.taxAmount,
510
- rules: getReplenishRules('taxAmount'),
511
- })(<MyDiv loading={isCipher(changeField, 'taxAmount')} />);
512
- } else {
513
- return <span style={{ padding: '0 10px' }}>{parseFloat(value).toFixed(2)}</span>;
514
- }
515
- },
516
- },
517
- // {
518
- // title: '操作',
519
- // key: 'operating',
520
- // align: 'right',
521
- // width: 130,
522
- // fixed: 'right',
523
- // render: (_value: string, record: IGood) => <RowMenu key={record.lineAttribute} goods={record} />,
524
- // },
525
- ]
526
- // 含税不含税
527
- .filter((e) => {
528
- if (isTaxIncluded) {
529
- return !(e.key === 'priceExcludeTax' || e.key === 'lineAmountExcludeTax');
530
- } else {
531
- return !(e.key === 'priceIncludeTax' || e.key === 'lineAmountIncludeTax');
532
- }
533
- })
534
- // 是否启动拖拽
535
- .filter(e => e.key !=='drag' || isStart)
536
- // 只读
537
- .filter(e => {
538
- if (model === 'readOnly') {
539
- return e.key !== 'operating';
540
- } else {
541
- return true;
542
- }
543
- })
544
- .map((e) => {
545
- return {
546
- ...e,
547
- ellipsis: true,
548
- };
549
- }) as any[];
550
- }, [isTaxIncluded, editGood, controller, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, isStart]);
551
-
552
- // React.useEffect(() => {
553
- // clearTimeout(t)
554
- // const t = setTimeout(() => { setChangeField('') }, 1000);
555
- // return () => { clearTimeout(t) }
556
- // }, [changeField]);
557
-
558
- return columns;
559
- };
560
-
561
- /** 字段 */
562
- function isCipher(name?: string, field?: string) {
563
- if (!name || !field) return false;
564
- return name !== field;
565
- }
566
-
567
- class MyInput extends React.Component<InputProps & { loading?: boolean }> {
568
- render() {
569
- if (this.props.loading) {
570
- return (
571
- <Spin size="small">
572
- <Input {...this.props} autoComplete="off" />
573
- </Spin>
574
- )
575
- } else {
576
- return <Input {...this.props} autoComplete="off" />
577
- }
578
- }
579
- }
580
-
581
- class MyDiv extends React.Component<{ value?: any, loading?: boolean }> {
582
-
583
- render() {
584
- if (this.props.loading) {
585
- return (
586
- <Spin size="small">
587
- <span style={{ padding: '0 10px' }}>{this.props.value}</span>
588
- </Spin>
589
- )
590
- } else {
591
- return <span style={{ padding: '0 10px' }}>{this.props.value}</span>
592
- }
593
- }
594
- }
595
-
596
- class MyItemNameDiv extends React.Component<{ valueT?: React.ReactNode, valueF?: React.ReactNode, isMyShow: boolean }> {
597
- render(): React.ReactNode {
598
-
599
- const { isMyShow, valueT, valueF } = this.props;
600
-
601
- if (isMyShow) {
602
- if (valueT) {
603
- return (
604
- <Tooltip title={valueT}>
605
- <span style={{ padding: '0 10px', color: '#0074ff' }}>{valueT}</span>
606
- </Tooltip>
607
- )
608
- } else {
609
- return (
610
- <Tooltip title={valueF}>
611
- <span style={{ padding: '0 10px' }}>{valueF}</span>
612
- </Tooltip>
613
- )
614
- }
615
- } else {
616
- if (valueF) {
617
- return (
618
- <Tooltip title={valueF}>
619
- <span style={{ padding: '0 10px' }}>{valueF}</span>
620
- </Tooltip>
621
- )
622
- } else {
623
- return (
624
- <Tooltip title={valueT}>
625
- <span style={{ padding: '0 10px', color: '#0074ff' }}>{valueT}</span>
626
- </Tooltip>
627
- )
628
- }
629
- }
630
- }
631
- }
632
-
633
- /** 格式搜索结果 */
634
- function formatSearch(value?: string, search?: string) {
635
- if (!value || !search) return value;
636
-
637
- const __html = ucoding(value).split(new RegExp(ucoding(search), 'g')).map(e => dcoding(e)).join(`<span class="kts-invoice-operate-goods-list-table-search-protrude" >${search}</span>`);
638
- return <span dangerouslySetInnerHTML={{ __html }} />
639
- }
640
-
641
- /** 编码 */
642
- function ucoding(v: string): string {
643
- return v.split('').map(e => `U${e.charCodeAt(0)}E`).join('');
644
- }
645
-
646
- /** 解码 */
647
- function dcoding(v: string): string {
648
- return v.split('U').map(e => e ? String.fromCharCode(parseInt(e.replace('E', ''))) : '').join('');
1
+
2
+ import React from 'react';
3
+ import Icon from '@ant-design/icons';
4
+ import { Form } from 'kts-components-antd-x3';
5
+ import { ReactComponent as PlusSvg } from './svg/plus.svg'
6
+ import { AutoComplete, Select, Button, Input, Spin, Tooltip, InputProps } from 'kts-xui';
7
+ import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
8
+ import { getItemNameWithShorthand } from '../../../../../tools/itemName';
9
+ import { IGood, LineAttributeType } from '../../../../../InvoiceController';
10
+ import Invoice from '../../../../..';
11
+ import TitleText from './ui/TitleText';
12
+ import ItemNameInput from './ui/ItemNameInput';
13
+ import {
14
+ onChangeQuantity,
15
+ onChangePriceIncludeTax,
16
+ onChangePriceExcludeTax,
17
+ onChangeLineAmountIncludeTax,
18
+ onChangeLineAmountExcludeTax,
19
+ onChangeTaxRate,
20
+ onChangeItemName,
21
+ } from './autoFillFn';
22
+ import Drag from './ui/Drag';
23
+
24
+ export default (form: WrappedFormUtils) => {
25
+ const { getFieldDecorator, getFieldValue } = form;
26
+
27
+ const controller = Invoice.useInvoiceController();
28
+
29
+ /** 是否含税 */
30
+ const isTaxIncluded = controller.useMemo(e => e.goodsListState.isTaxIncluded, []);
31
+
32
+ /** 组件模式 */
33
+ const model = controller.useMemo(e => e.model, []);
34
+
35
+ /** 是否显示我方 */
36
+ const isMyShow = controller.useMemo(e => e.goodsListState.isMyShow, []);
37
+
38
+ /** 正在编辑的货物 */
39
+ const editGood = controller.useMemo((e) => e.goodsListState.editGood, []);
40
+
41
+ /** 是否启用拖拽 */
42
+ const isStart = controller.useMemo((e) => e.goodsListState.drag.isStart, []);
43
+
44
+ /** 搜索条件 */
45
+ const searchValue = controller.useMemo((e) => e.goodsListState.searchValue, []);
46
+
47
+ /** 税率列表 */
48
+ const taxRateList = controller.useMemo((e) => e.goodsListState.taxRateList, []);
49
+
50
+ /** 单位列表 */
51
+ const unitList = controller.useMemo((e) => e.goodsListState.unitList, []);
52
+
53
+ /** 商品表格补充配置 */
54
+ const columnsReplenish = controller.useMemo((e) => e.goodsListState.columnsReplenish, []);
55
+
56
+ /** 扣除额 */
57
+ const deduction = controller.useMemo((e) => e.goodsListState.deduction, []);
58
+
59
+ /** 计算中启动字段 */
60
+ const changeField = controller.useMemo((e) => e.calculatingField, []);
61
+
62
+ /** 计算中启动字段 */
63
+ const setChangeField = React.useCallback((value: string) => controller.run(async s => { s.calculatingField = value }), []);
64
+
65
+ const onNumberValueChange = React.useCallback((e) => {
66
+ const value = e?.target?.value;
67
+ if (value) {
68
+ return value.replace(/[^0-9-\.]/g, '');
69
+ }
70
+ }, [])
71
+
72
+ /** 获取补充校验规则 */
73
+ const getReplenishRules = React.useCallback((id: string) => {
74
+ return columnsReplenish[id] ? columnsReplenish[id].rules || [] : []
75
+ }, [columnsReplenish])
76
+
77
+ /** 金额整数位限制,不传默认9位 */
78
+ const priceIntegerDigit = controller.useMemo((e) => e.priceIntegerDigit || 9, []);
79
+
80
+ /** 表头 */
81
+ const columns = React.useMemo(() => {
82
+ return [
83
+ {
84
+ title: ' ',
85
+ key: 'drag',
86
+ width: 40,
87
+ align: 'center',
88
+ render: (_: any, record: IGood) => <Drag record={record} />
89
+ },
90
+ {
91
+ title: '序号',
92
+ key: 'serialNo',
93
+ dataIndex: 'serialNo',
94
+ width: 50,
95
+ render: (e: number) => <span style={{ padding: '0 10px' }}>{e}</span>,
96
+ },
97
+ {
98
+ title: <TitleText required >项目名称</TitleText>,
99
+ key: 'itemName',
100
+ render: (_: string, record: IGood) => {
101
+ if (editGood?.$index === record.$index) {
102
+ return (
103
+ <Form.Item>
104
+ <div style={{ display: 'flex' }} >
105
+ {getFieldDecorator('itemName', {
106
+ initialValue: isMyShow ? record.itemNameSelf : record.itemName,
107
+ rules: [
108
+ ...getReplenishRules('itemName'),
109
+ {
110
+ validator: async (_, __, callback) => {
111
+ await controller.wait();
112
+ const value = controller.state.goodsListState.editGood;
113
+ if (!value?.itemName && !value?.itemNameSelf) {
114
+ callback('项目名称不能为空');
115
+ } else {
116
+ return;
117
+ }
118
+ }
119
+ }
120
+ ]
121
+ })(
122
+ <ItemNameInput
123
+ shorthand={editGood.shorthand}
124
+ suffix={
125
+ <Tooltip title="点击从商品管理中添加商品信息">
126
+ <Button
127
+ type="link"
128
+ style={{ padding: 0, width: 20, fontSize: 20, fill: '#0074ff' }}
129
+ icon={<PlusSvg />}
130
+ onClick={controller.pipeline(async s => { s.goodsListState.importGoods.isVisibleDrawer = true })}
131
+ />
132
+ </Tooltip>
133
+ }
134
+ onChange={() => {
135
+ onChangeItemName(controller, form, record);
136
+ }}
137
+ />
138
+ )}
139
+ {/* <div className="kts-invoice-operate-goods-list-able-list-itemName-import">
140
+ {controller.getGoodsList && model !== 'readOnly' && (
141
+ <Tooltip title="点击从商品管理中添加商品信息">
142
+ <Button
143
+ onClick={controller.pipeline(async s => { s.goodsListState.importGoods.isVisibleDrawer = true })}
144
+ type="link"
145
+ icon="plus-circle"
146
+ />
147
+ </Tooltip>
148
+ )}
149
+ </div> */}
150
+ </div>
151
+ </Form.Item>
152
+ );
153
+ } else {
154
+ return (
155
+ <span>
156
+ {record.lineAttribute === LineAttributeType.折扣行 ? <span className='goods-list-digtal-discount-tag'>折扣</span> : <></>}
157
+ <MyItemNameDiv
158
+ valueT={formatSearch(getItemNameWithShorthand({ shorthand: record.shorthand, full: record.itemNameSelf || '' }), searchValue)}
159
+ valueF={formatSearch(getItemNameWithShorthand({ shorthand: record.shorthand, full: record.itemName || '' }), searchValue)}
160
+ isMyShow={isMyShow}
161
+ />
162
+ </span>
163
+ )
164
+ }
165
+ },
166
+ },
167
+ {
168
+ title: <TitleText rules={columnsReplenish['itemModelName']?.rules} >规格型号</TitleText>,
169
+ key: 'itemModelName',
170
+ width: 119,
171
+ render: (_: string, record: IGood) => {
172
+ if (editGood?.$index === record.$index) {
173
+ return (
174
+ <Form.Item>
175
+ {getFieldDecorator('itemModelName', {
176
+ initialValue: isMyShow ? editGood.itemModelNameSelf : editGood.itemModelName,
177
+ rules: getReplenishRules('itemModelName'),
178
+ })(
179
+ <MyInput
180
+ onChange={async () => {
181
+ await controller.wait()
182
+ const key = isMyShow ? 'itemModelNameSelf' : 'itemModelName';
183
+ const value = {} as any;
184
+ value[key] = form.getFieldsValue().itemModelName;
185
+ controller.setEditGood(value);
186
+ }}
187
+ />,
188
+ )}
189
+ </Form.Item>
190
+ );
191
+ } else {
192
+ return (
193
+ <MyItemNameDiv
194
+ valueT={formatSearch(record.itemModelNameSelf, searchValue)}
195
+ valueF={formatSearch(record.itemModelName, searchValue)}
196
+ isMyShow={isMyShow}
197
+ />
198
+ )
199
+ }
200
+ },
201
+ },
202
+ {
203
+ title: <TitleText rules={columnsReplenish['unit']?.rules} >单位</TitleText>,
204
+ key: 'unit',
205
+ width: 70,
206
+ render: (_: string, record: IGood) => {
207
+ if (editGood?.$index === record.$index) {
208
+ return (
209
+ <Form.Item>
210
+ {getFieldDecorator('unit', {
211
+ initialValue: editGood.unit,
212
+ rules: getReplenishRules('unit'),
213
+ })(
214
+ <AutoComplete
215
+ style={{ width: '100%' }}
216
+ dataSource={unitList}
217
+ onChange={async () => {
218
+ await controller.wait()
219
+ // const key = isMyShow ? 'unit' : 'unitOther';
220
+ // const value = {} as any;
221
+ // value[key] = form.getFieldsValue().unit;
222
+ controller.setEditGood({ unit: form.getFieldsValue().unit });
223
+ }}
224
+ />,
225
+ )}
226
+ </Form.Item>
227
+ );
228
+ } else {
229
+ return <span style={{ padding: '0 10px' }}>{record.unit}</span>;
230
+ }
231
+ },
232
+ },
233
+ {
234
+ title: <TitleText rules={columnsReplenish['quantity']?.rules} >数量</TitleText>,
235
+ dataIndex: 'quantity',
236
+ key: 'quantity',
237
+ align: 'right',
238
+ width: 149,
239
+ render: (value: string, record: IGood) => {
240
+ if (editGood?.$index === record.$index) {
241
+ return (
242
+ <Form.Item>
243
+ {getFieldDecorator('quantity', {
244
+ initialValue: editGood.quantity,
245
+ getValueFromEvent: onNumberValueChange,
246
+ rules: [
247
+ ...getReplenishRules('quantity'),
248
+ { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '数量必须为数字' },
249
+ {
250
+ validator: async (_, value, callback) => {
251
+ await controller.wait();
252
+ const isvalue = !!value || value === 0;
253
+ const isPrice = !!getFieldValue(isTaxIncluded ? 'priceIncludeTax' : 'priceExcludeTax') || getFieldValue(isTaxIncluded ? 'priceIncludeTax' : 'priceExcludeTax') === 0;
254
+ if (isvalue || isPrice === isvalue) return;
255
+ callback('请输入数量');
256
+ }
257
+ }
258
+ ],
259
+ })(
260
+ <MyInput
261
+ style={{ textAlign: 'right' }}
262
+ maxLength={16}
263
+ loading={isCipher(changeField, "quantity")}
264
+ onChange={async () => {
265
+ setChangeField('quantity');
266
+ await onChangeQuantity(controller, form, record);
267
+ }}
268
+ />,
269
+ )}
270
+ </Form.Item>
271
+ );
272
+ } else {
273
+ return <span style={{ padding: '0 10px' }}>{value}</span>;
274
+ }
275
+ },
276
+ },
277
+ {
278
+ title: <TitleText rules={columnsReplenish['priceIncludeTax']?.rules} >单价(含税)</TitleText>,
279
+ dataIndex: 'priceIncludeTax',
280
+ key: 'priceIncludeTax',
281
+ align: 'right',
282
+ width: 149,
283
+ render: (value: string, record: IGood) => {
284
+ if (editGood?.$index === record.$index) {
285
+ return (
286
+ <Form.Item>
287
+ {getFieldDecorator('priceIncludeTax', {
288
+ initialValue: editGood.priceIncludeTax,
289
+ getValueFromEvent: onNumberValueChange,
290
+ rules: [
291
+ ...getReplenishRules('priceIncludeTax'),
292
+ { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '单价必须为数字' },
293
+ {
294
+ validator: async (_, value, callback) => {
295
+ await controller.wait();
296
+ const isQuantity = !!getFieldValue('quantity') || getFieldValue('quantity') === 0;
297
+ const isvalue = !!value || value === 0;
298
+ if (isvalue || isQuantity === isvalue) return;
299
+ callback('请输入单价');
300
+ }
301
+ }
302
+ ],
303
+ })(
304
+ <MyInput
305
+ style={{ textAlign: 'right' }}
306
+ maxLength={16}
307
+ loading={isCipher(changeField, 'priceIncludeTax')}
308
+ onChange={() => {
309
+ setChangeField('priceIncludeTax');
310
+ onChangePriceIncludeTax(controller, form, record);
311
+ }}
312
+ />,
313
+ )}
314
+ </Form.Item>
315
+ );
316
+ } else {
317
+ return <span style={{ padding: '0 10px' }}>{value}</span>;
318
+ }
319
+ },
320
+ },
321
+ {
322
+ title: <TitleText rules={columnsReplenish['priceExcludeTax']?.rules} >单价(不含税)</TitleText>,
323
+ dataIndex: 'priceExcludeTax',
324
+ key: 'priceExcludeTax',
325
+ align: 'right',
326
+ width: 149,
327
+ render: (value: string, record: IGood) => {
328
+ if (editGood?.$index === record.$index) {
329
+ return (
330
+ <Form.Item>
331
+ {getFieldDecorator('priceExcludeTax', {
332
+ initialValue: editGood.priceExcludeTax,
333
+ getValueFromEvent: onNumberValueChange,
334
+ rules: [
335
+ ...getReplenishRules('priceExcludeTax'),
336
+ { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '单价必须为数字' },
337
+ {
338
+ validator: async (_, value, callback) => {
339
+ await controller.wait();
340
+ const isQuantity = !!getFieldValue('quantity') || getFieldValue('quantity') === 0;
341
+ const isvalue = !!value || value === 0;
342
+ if (isvalue || isQuantity === isvalue) return;
343
+ callback('请输入单价');
344
+ }
345
+ }
346
+ ],
347
+ })(
348
+ <MyInput
349
+ style={{ textAlign: 'right' }}
350
+ maxLength={16}
351
+ loading={isCipher(changeField, 'priceExcludeTax')}
352
+ onChange={() => {
353
+ setChangeField('priceExcludeTax');
354
+ onChangePriceExcludeTax(controller, form, record);
355
+ }}
356
+ />,
357
+ )}
358
+ </Form.Item>
359
+ );
360
+ } else {
361
+ return <span style={{ padding: '0 10px' }}>{value}</span>;
362
+ }
363
+ },
364
+ },
365
+ {
366
+ title: <TitleText required >金额(含税)</TitleText>,
367
+ dataIndex: 'lineAmountIncludeTax',
368
+ key: 'lineAmountIncludeTax',
369
+ width: 119,
370
+ align: 'right',
371
+ render: (value: string, record: IGood) => {
372
+ if (editGood?.$index === record.$index) {
373
+ return (
374
+ <Form.Item>
375
+ {getFieldDecorator('lineAmountIncludeTax', {
376
+ initialValue: editGood.lineAmountIncludeTax,
377
+ getValueFromEvent: onNumberValueChange,
378
+ rules: [
379
+ ...getReplenishRules('lineAmountIncludeTax'),
380
+ { required: true, message: '金额不能为空' },
381
+ { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '金额必须为数字' },
382
+ {
383
+ validator: async (_, value, callback) => {
384
+ if (`${value}`.split('.')[0].length > priceIntegerDigit) {
385
+ callback(`金额整数部分不能大于${priceIntegerDigit}位,小数点后最多2位`);
386
+ }
387
+ }
388
+ },
389
+ {
390
+ validator: async (_, value, callback) => {
391
+ if (deduction && parseFloat(value) <= deduction) {
392
+ callback('扣除额不能大于等于价税合计');
393
+ }
394
+ }
395
+ },
396
+ ],
397
+ })(
398
+ <MyInput
399
+ style={{ textAlign: 'right' }}
400
+ loading={isCipher(changeField, 'lineAmountIncludeTax')}
401
+ onChange={() => {
402
+ setChangeField('lineAmountIncludeTax');
403
+ onChangeLineAmountIncludeTax(controller, form, record);
404
+ }}
405
+ />,
406
+ )}
407
+ </Form.Item>
408
+ );
409
+ } else {
410
+ return <span style={{ padding: '0 10px' }}>{formatSearch(parseFloat(value).toFixed(2), searchValue)}</span>;
411
+ }
412
+ },
413
+ },
414
+ {
415
+ title: <TitleText required >金额(不含税)</TitleText>,
416
+ dataIndex: 'lineAmountExcludeTax',
417
+ key: 'lineAmountExcludeTax',
418
+ align: 'right',
419
+ width: 119,
420
+ render: (value: string, record: IGood) => {
421
+ if (editGood?.$index === record.$index) {
422
+ return (
423
+ <Form.Item>
424
+ {getFieldDecorator('lineAmountExcludeTax', {
425
+ initialValue: editGood.lineAmountExcludeTax,
426
+ getValueFromEvent: onNumberValueChange,
427
+ rules: [
428
+ ...getReplenishRules('lineAmountExcludeTax'),
429
+ { required: true, message: '金额不能为空' },
430
+ { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '金额必须为数字' },
431
+ {
432
+ validator: async (_, value: string, callback) => {
433
+ if (`${value}`.split('.')[0].length > priceIntegerDigit) {
434
+ callback(`金额整数部分不能大于${priceIntegerDigit}位,小数点后最多2位`);
435
+ }
436
+ }
437
+ },
438
+ ],
439
+ })(
440
+ <MyInput
441
+ style={{ textAlign: 'right' }}
442
+ loading={isCipher(changeField, 'lineAmountExcludeTax')}
443
+ onChange={() => {
444
+ setChangeField('lineAmountExcludeTax');
445
+ onChangeLineAmountExcludeTax(controller, form, record);
446
+ }}
447
+ />,
448
+ )}
449
+ </Form.Item>
450
+ );
451
+ } else {
452
+ return <span style={{ padding: '0 10px' }}>{formatSearch(parseFloat(value).toFixed(2), searchValue)}</span>;
453
+ }
454
+ },
455
+ },
456
+ {
457
+ title: <TitleText required >税率%</TitleText>,
458
+ dataIndex: 'taxRate',
459
+ key: 'taxRate',
460
+ align: 'right',
461
+ width: 70,
462
+ render: (value: string, record: IGood) => {
463
+ if (editGood?.$index === record.$index) {
464
+ return (
465
+ <Form.Item>
466
+ {getFieldDecorator('taxRate', {
467
+ initialValue: editGood.taxRate,
468
+ rules: [
469
+ ...getReplenishRules('taxRate'),
470
+ { required: true, message: ' ' },
471
+ { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: ' ' },
472
+ ],
473
+ })(
474
+ <Select
475
+ className="kts-invoice-operate-goods-list-table-tax-rate"
476
+ // dropdownMenuStyle={{ textAlign: "right" }}
477
+ showArrow={false}
478
+ style={{ width: '100%' }}
479
+ onChange={() => {
480
+ setChangeField('taxRate');
481
+ onChangeTaxRate(controller, form, record);
482
+ }}
483
+ >
484
+ {taxRateList.map((e, i) => {
485
+ return (
486
+ <Select.Option key={i} value={e}>
487
+ {e}%
488
+ </Select.Option>
489
+ );
490
+ })}
491
+ </Select>,
492
+ )}
493
+ </Form.Item>
494
+ );
495
+ } else {
496
+ return <span style={{ padding: '0 10px' }}>{value}%</span>;
497
+ }
498
+ },
499
+ },
500
+ {
501
+ title: <TitleText rules={columnsReplenish['taxAmount']?.rules} >税额</TitleText>,
502
+ dataIndex: 'taxAmount',
503
+ key: 'taxAmount',
504
+ align: 'right',
505
+ width: 119,
506
+ render: (value: string, record: IGood) => {
507
+ if (editGood?.$index === record.$index) {
508
+ return getFieldDecorator('taxAmount', {
509
+ initialValue: editGood.taxAmount,
510
+ rules: getReplenishRules('taxAmount'),
511
+ })(<MyDiv loading={isCipher(changeField, 'taxAmount')} />);
512
+ } else {
513
+ return <span style={{ padding: '0 10px' }}>{parseFloat(value).toFixed(2)}</span>;
514
+ }
515
+ },
516
+ },
517
+ // {
518
+ // title: '操作',
519
+ // key: 'operating',
520
+ // align: 'right',
521
+ // width: 130,
522
+ // fixed: 'right',
523
+ // render: (_value: string, record: IGood) => <RowMenu key={record.lineAttribute} goods={record} />,
524
+ // },
525
+ ]
526
+ // 含税不含税
527
+ .filter((e) => {
528
+ if (isTaxIncluded) {
529
+ return !(e.key === 'priceExcludeTax' || e.key === 'lineAmountExcludeTax');
530
+ } else {
531
+ return !(e.key === 'priceIncludeTax' || e.key === 'lineAmountIncludeTax');
532
+ }
533
+ })
534
+ // 是否启动拖拽
535
+ .filter(e => e.key !=='drag' || isStart)
536
+ // 只读
537
+ .filter(e => {
538
+ if (model === 'readOnly') {
539
+ return e.key !== 'operating';
540
+ } else {
541
+ return true;
542
+ }
543
+ })
544
+ .map((e) => {
545
+ return {
546
+ ...e,
547
+ ellipsis: true,
548
+ };
549
+ }) as any[];
550
+ }, [isTaxIncluded, editGood, controller, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, isStart]);
551
+
552
+ // React.useEffect(() => {
553
+ // clearTimeout(t)
554
+ // const t = setTimeout(() => { setChangeField('') }, 1000);
555
+ // return () => { clearTimeout(t) }
556
+ // }, [changeField]);
557
+
558
+ return columns;
559
+ };
560
+
561
+ /** 字段 */
562
+ function isCipher(name?: string, field?: string) {
563
+ if (!name || !field) return false;
564
+ return name !== field;
565
+ }
566
+
567
+ class MyInput extends React.Component<InputProps & { loading?: boolean }> {
568
+ render() {
569
+ if (this.props.loading) {
570
+ return (
571
+ <Spin size="small">
572
+ <Input {...this.props} autoComplete="off" />
573
+ </Spin>
574
+ )
575
+ } else {
576
+ return <Input {...this.props} autoComplete="off" />
577
+ }
578
+ }
579
+ }
580
+
581
+ class MyDiv extends React.Component<{ value?: any, loading?: boolean }> {
582
+
583
+ render() {
584
+ if (this.props.loading) {
585
+ return (
586
+ <Spin size="small">
587
+ <span style={{ padding: '0 10px' }}>{this.props.value}</span>
588
+ </Spin>
589
+ )
590
+ } else {
591
+ return <span style={{ padding: '0 10px' }}>{this.props.value}</span>
592
+ }
593
+ }
594
+ }
595
+
596
+ class MyItemNameDiv extends React.Component<{ valueT?: React.ReactNode, valueF?: React.ReactNode, isMyShow: boolean }> {
597
+ render(): React.ReactNode {
598
+
599
+ const { isMyShow, valueT, valueF } = this.props;
600
+
601
+ if (isMyShow) {
602
+ if (valueT) {
603
+ return (
604
+ <Tooltip title={valueT}>
605
+ <span style={{ padding: '0 10px', color: '#0074ff' }}>{valueT}</span>
606
+ </Tooltip>
607
+ )
608
+ } else {
609
+ return (
610
+ <Tooltip title={valueF}>
611
+ <span style={{ padding: '0 10px' }}>{valueF}</span>
612
+ </Tooltip>
613
+ )
614
+ }
615
+ } else {
616
+ if (valueF) {
617
+ return (
618
+ <Tooltip title={valueF}>
619
+ <span style={{ padding: '0 10px' }}>{valueF}</span>
620
+ </Tooltip>
621
+ )
622
+ } else {
623
+ return (
624
+ <Tooltip title={valueT}>
625
+ <span style={{ padding: '0 10px', color: '#0074ff' }}>{valueT}</span>
626
+ </Tooltip>
627
+ )
628
+ }
629
+ }
630
+ }
631
+ }
632
+
633
+ /** 格式搜索结果 */
634
+ function formatSearch(value?: string, search?: string) {
635
+ if (!value || !search) return value;
636
+
637
+ const __html = ucoding(value).split(new RegExp(ucoding(search), 'g')).map(e => dcoding(e)).join(`<span class="kts-invoice-operate-goods-list-table-search-protrude" >${search}</span>`);
638
+ return <span dangerouslySetInnerHTML={{ __html }} />
639
+ }
640
+
641
+ /** 编码 */
642
+ function ucoding(v: string): string {
643
+ return v.split('').map(e => `U${e.charCodeAt(0)}E`).join('');
644
+ }
645
+
646
+ /** 解码 */
647
+ function dcoding(v: string): string {
648
+ return v.split('U').map(e => e ? String.fromCharCode(parseInt(e.replace('E', ''))) : '').join('');
649
649
  }