kts-component-invoice-operate 3.2.103 → 3.2.104

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