kts-component-invoice-operate 3.2.48 → 3.2.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/.dumi/theme/builtins/API.tsx +66 -66
  2. package/.editorconfig +16 -16
  3. package/.fatherrc.ts +4 -4
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +8 -8
  7. package/README.md +5 -5
  8. package/dist/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.d.ts +0 -1
  9. package/dist/index.esm.js +5666 -7879
  10. package/dist/index.js +5666 -7879
  11. package/docs/index.md +5 -5
  12. package/docs-dist/static/arrowDown.a1cbf0d8.svg +2 -2
  13. package/docs-dist/static/arrowUp.4c482054.svg +2 -2
  14. package/docs-dist/static/fork.5431267d.svg +11 -11
  15. package/docs-dist/static/plus.44013ce3.svg +11 -11
  16. package/docs-dist/static/plus.4fd1af30.svg +11 -11
  17. package/index.html +12 -12
  18. package/package.json +60 -60
  19. package/src/Invoice/Invoice-digtal/_test/disabled/index.tsx +38 -38
  20. package/src/Invoice/Invoice-digtal/_test/easiest/index.tsx +16 -16
  21. package/src/Invoice/Invoice-digtal/_test/header/index.tsx +84 -84
  22. package/src/Invoice/Invoice-digtal/_test/importGoods/index.tsx +470 -470
  23. package/src/Invoice/Invoice-digtal/_test/importStakeholder/index.tsx +17 -17
  24. package/src/Invoice/Invoice-digtal/_test/lineCredit/index.tsx +20 -20
  25. package/src/Invoice/Invoice-digtal/_test/prefab/index.tsx +150 -150
  26. package/src/Invoice/Invoice-digtal/_test/readOnly/index.tsx +41 -41
  27. package/src/Invoice/Invoice-digtal/_test/stakeholder/index.tsx +12 -12
  28. package/src/Invoice/Invoice-digtal/_test/typeSelection/index.tsx +29 -29
  29. package/src/Invoice/Invoice-digtal/index.md +30 -30
  30. package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +94 -94
  31. package/src/Invoice/InvoiceController/InvoiceControllerState/AutoComplete/index.ts +17 -17
  32. package/src/Invoice/InvoiceController/InvoiceControllerState/BuyerState/index.tsx +88 -88
  33. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.ts +12 -12
  34. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/EndowCode/index.tsx +93 -93
  35. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IColumnsReplenish/index.ts +10 -10
  36. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +75 -75
  37. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ImportGoods/index.ts +80 -80
  38. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.ts +5 -5
  39. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.ts +9 -9
  40. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +107 -107
  41. package/src/Invoice/InvoiceController/InvoiceControllerState/Stakeholder/index.ts +10 -10
  42. package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +60 -60
  43. package/src/Invoice/InvoiceController/fns/addGood.ts +11 -11
  44. package/src/Invoice/InvoiceController/fns/addGoodDiscount.ts +125 -125
  45. package/src/Invoice/InvoiceController/fns/addGoodDiscountV2.ts +84 -84
  46. package/src/Invoice/InvoiceController/fns/delGood.ts +41 -41
  47. package/src/Invoice/InvoiceController/fns/getGoodsSearch.ts +26 -26
  48. package/src/Invoice/InvoiceController/fns/importGoodsDrawer.ts +67 -67
  49. package/src/Invoice/InvoiceController/fns/mergeDetails.ts +163 -163
  50. package/src/Invoice/InvoiceController/fns/mergeDiscount.ts +28 -28
  51. package/src/Invoice/InvoiceController/fns/saveEditGood.ts +24 -24
  52. package/src/Invoice/InvoiceController/fns/setEditGood.ts +16 -16
  53. package/src/Invoice/InvoiceController/fns/setGoods.ts +10 -10
  54. package/src/Invoice/InvoiceController/fns/updateInvoiceNo.ts +8 -8
  55. package/src/Invoice/InvoiceController/index.ts +77 -77
  56. package/src/Invoice/_test/buyerNameSearch/index.tsx +41 -41
  57. package/src/Invoice/_test/deduction/index.tsx +935 -935
  58. package/src/Invoice/_test/draft/index.tsx +40 -40
  59. package/src/Invoice/_test/easiest/index.tsx +5 -5
  60. package/src/Invoice/_test/endowCode/index.tsx +1099 -1099
  61. package/src/Invoice/_test/goodsMenuExpand/index.tsx +32 -32
  62. package/src/Invoice/_test/importBuyer/index.tsx +74 -74
  63. package/src/Invoice/_test/importGoods/index.tsx +515 -515
  64. package/src/Invoice/_test/invoiceType/index.tsx +59 -59
  65. package/src/Invoice/_test/isInvoiceNo/index.tsx +12 -12
  66. package/src/Invoice/_test/replaceHead/index.tsx +22 -22
  67. package/src/Invoice/_test/retrieveData/index.tsx +22 -22
  68. package/src/Invoice/_test/seller/index.tsx +28 -28
  69. package/src/Invoice/_test/setDataSource/index.tsx +73 -73
  70. package/src/Invoice/_test/unit/index.tsx +19 -19
  71. package/src/Invoice/index.less +29 -29
  72. package/src/Invoice/index.md +53 -53
  73. package/src/Invoice/index.tsx +165 -165
  74. package/src/Invoice/tools/calculate/index.ts +112 -112
  75. package/src/Invoice/tools/coolingFn/index.ts +17 -17
  76. package/src/Invoice/tools/evaluate/index.ts +7 -7
  77. package/src/Invoice/tools/idGenerator/index.ts +2 -2
  78. package/src/Invoice/tools/itemName/index.ts +55 -55
  79. package/src/Invoice/tools/lazyFn/index.ts +19 -19
  80. package/src/Invoice/tools/mounting/index.ts +13 -13
  81. package/src/Invoice/tools/strringFn/index.ts +40 -40
  82. package/src/Invoice/tools/useToGenerateId/index.ts +8 -8
  83. package/src/Invoice/ui/default/AddComparisonDrawer/index.tsx +149 -149
  84. package/src/Invoice/ui/default/Buyer/index.less +219 -219
  85. package/src/Invoice/ui/default/Buyer/index.tsx +114 -114
  86. package/src/Invoice/ui/default/Buyer/ui/BuyerNameInput/index.tsx +166 -166
  87. package/src/Invoice/ui/default/Buyer/ui/ImportBuyerButton/index.tsx +21 -21
  88. package/src/Invoice/ui/default/EndowCodeDrawer/index.less +8 -8
  89. package/src/Invoice/ui/default/EndowCodeDrawer/index.tsx +431 -431
  90. package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +533 -533
  91. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +664 -665
  92. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.less +20 -20
  93. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.tsx +202 -202
  94. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.less +18 -18
  95. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.tsx +58 -56
  96. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +17 -17
  97. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +128 -128
  98. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  99. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  100. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -76
  101. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -41
  102. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -34
  103. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -13
  104. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +98 -98
  105. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  106. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  107. package/src/Invoice/ui/default/GoodsList/hook/useDeduction/index.tsx +24 -24
  108. package/src/Invoice/ui/default/GoodsList/hook/useOnRow/index.tsx +39 -39
  109. package/src/Invoice/ui/default/GoodsList/hook/useRowSelection/index.tsx +111 -111
  110. package/src/Invoice/ui/default/GoodsList/hook/useWindowClick/index.tsx +23 -23
  111. package/src/Invoice/ui/default/GoodsList/index.less +177 -177
  112. package/src/Invoice/ui/default/GoodsList/index.tsx +191 -191
  113. package/src/Invoice/ui/default/GoodsList/ui/AddRowButton/index.tsx +65 -65
  114. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.less +21 -21
  115. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +244 -244
  116. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  117. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +69 -69
  118. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +58 -58
  119. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDetails/index.tsx +37 -37
  120. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDiscount/index.tsx +36 -36
  121. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/index.tsx +37 -37
  122. package/src/Invoice/ui/default/GoodsList/ui/DescribeSwitch/index.tsx +36 -36
  123. package/src/Invoice/ui/default/GoodsList/ui/Search/index.less +10 -10
  124. package/src/Invoice/ui/default/GoodsList/ui/Search/index.tsx +52 -52
  125. package/src/Invoice/ui/default/GoodsList/ui/Statistics/index.less +18 -18
  126. package/src/Invoice/ui/default/GoodsList/ui/Statistics/index.tsx +109 -109
  127. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.less +13 -13
  128. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.tsx +46 -46
  129. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.less +38 -38
  130. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.tsx +108 -108
  131. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual.o/index.less +44 -44
  132. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual.o/index.tsx +96 -96
  133. package/src/Invoice/ui/default/GoodsList/ui/TaxIncludedSwitch/index.tsx +30 -30
  134. package/src/Invoice/ui/default/ImportBuyerDrawer/index.tsx +75 -75
  135. package/src/Invoice/ui/default/ImportGoodsDrawer/index.tsx +193 -193
  136. package/src/Invoice/ui/default/InvoiceHeader/index.less +68 -68
  137. package/src/Invoice/ui/default/InvoiceHeader/index.tsx +246 -246
  138. package/src/Invoice/ui/default/Seller/index.less +113 -113
  139. package/src/Invoice/ui/default/Seller/index.tsx +98 -98
  140. package/src/Invoice/ui/default/Sign/index.less +14 -14
  141. package/src/Invoice/ui/default/Sign/index.tsx +71 -71
  142. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.ts +519 -519
  143. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/index.tsx +648 -648
  144. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/svg/plus.svg +11 -11
  145. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/Drag/index.less +20 -20
  146. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/Drag/index.tsx +186 -186
  147. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +9 -9
  148. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +50 -50
  149. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  150. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  151. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -76
  152. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -41
  153. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -34
  154. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -13
  155. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +98 -98
  156. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  157. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  158. package/src/Invoice/ui/digtal/GoodsList/hook/useOnRow/index.tsx +39 -39
  159. package/src/Invoice/ui/digtal/GoodsList/hook/useRowSelection/index.tsx +121 -121
  160. package/src/Invoice/ui/digtal/GoodsList/hook/useWindowClick/index.tsx +23 -23
  161. package/src/Invoice/ui/digtal/GoodsList/index.less +56 -56
  162. package/src/Invoice/ui/digtal/GoodsList/index.tsx +180 -180
  163. package/src/Invoice/ui/digtal/GoodsList/ui/AddRowButton/index.tsx +65 -65
  164. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +341 -341
  165. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/svg/add.svg +11 -11
  166. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  167. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +50 -50
  168. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEmptyRefill/index.tsx +35 -35
  169. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +82 -82
  170. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useReselectInvoiceType/index.tsx +57 -57
  171. package/src/Invoice/ui/digtal/GoodsList/ui/DescribeSwitch/index.tsx +36 -36
  172. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.less +11 -11
  173. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.tsx +50 -50
  174. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.less +53 -53
  175. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.tsx +99 -99
  176. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/svg/fork.svg +11 -11
  177. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.less +13 -13
  178. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.tsx +40 -40
  179. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.less +38 -38
  180. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.tsx +108 -108
  181. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual.o/index.less +44 -44
  182. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual.o/index.tsx +96 -96
  183. package/src/Invoice/ui/digtal/GoodsList/ui/TaxIncludedSwitch/index.tsx +30 -30
  184. package/src/Invoice/ui/digtal/InvoiceHeader/index.less +57 -57
  185. package/src/Invoice/ui/digtal/InvoiceHeader/index.tsx +77 -77
  186. package/src/Invoice/ui/digtal/Sign/index.less +48 -48
  187. package/src/Invoice/ui/digtal/Sign/index.tsx +89 -89
  188. package/src/Invoice/ui/digtal/Stakeholder/index.less +75 -75
  189. package/src/Invoice/ui/digtal/Stakeholder/index.tsx +388 -388
  190. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowDown.svg +2 -2
  191. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowUp.svg +2 -2
  192. package/src/Invoice/ui/digtal/Stakeholder/svg/plus.svg +11 -11
  193. package/src/InvoiceTypeModal/_test/easiest/index.tsx +31 -31
  194. package/src/InvoiceTypeModal/index.less +7 -7
  195. package/src/InvoiceTypeModal/index.md +5 -5
  196. package/src/InvoiceTypeModal/index.tsx +153 -153
  197. package/src/index.ts +9 -9
  198. package/tsconfig.json +31 -31
  199. package/typings.d.ts +3 -3
  200. package/yarn.e.lock +14331 -14331
@@ -1,431 +1,431 @@
1
- import React from 'react';
2
- import Invoice from '../../..';
3
- import { Button, Drawer, Select, Modal, Input as InputAntd, Form, Tree, message } from 'kts-components-antd-x3';
4
- import { chain, bignumber } from 'mathjs';
5
- import { Input, NumberPicker } from '@formily/antd-components';
6
- import { format15 } from '../GoodsList/hook/useColumns/autoFillFn';
7
- import { LineAttributeType } from '../../../InvoiceController';
8
- import IGood from '../../../InvoiceController/InvoiceControllerState/GoodsListState/IGood';
9
- import { countTaxAmount } from '../../../tools/calculate';
10
- import { bytesLnegth, cutStr } from '../../../tools/strringFn';
11
- import {
12
- SchemaForm,
13
- FormButtonGroup,
14
- createAsyncFormActions,
15
- SchemaMarkupField as Field,
16
- FormEffectHooks,
17
- } from '@formily/antd';
18
- import './index.less';
19
-
20
- const { TreeNode } = Tree;
21
- const { confirm } = Modal;
22
-
23
- export default () => {
24
- const controller = Invoice.useInvoiceController();
25
-
26
- const visible = controller.useMemo(s => s.goodsListState.endowCode.endowcodeGoodIndex.length > 0, []);
27
-
28
- const [defaultValue, setDefaultValue] = React.useState<IGood>();
29
-
30
- const onClose = React.useCallback(() => {
31
- controller.pipeline(async (s) => {
32
- s.goodsListState.endowCode.endowcodeGoodIndex = [];
33
- })();
34
- }, [controller]);
35
-
36
- // 计算赋码默认值
37
- React.useEffect(() => {
38
- if (visible) {
39
- controller.pipeline(async s => {
40
- const endowcodeGoodIndex = s.goodsListState.endowCode.endowcodeGoodIndex.filter(i => {
41
- const good = s.goodsListState.goodsMap.get(i);
42
- if (!good) return false;
43
-
44
- return good.lineAttribute !== LineAttributeType.折扣行;
45
- })
46
-
47
- const good = s.goodsListState.goodsMap.get(s.goodsListState.endowCode.endowcodeGoodIndex[0]);
48
- if (!good) return;
49
-
50
- const getDefaultValue = s.goodsListState.endowCode.getDefaultValue;
51
- if (getDefaultValue) {
52
- setDefaultValue(await getDefaultValue({ ...good }, endowcodeGoodIndex.length));
53
- } else {
54
- if (endowcodeGoodIndex.length === 1) {
55
- setDefaultValue(good);
56
- } else {
57
- setDefaultValue({ taxRate: good.taxRate } as any);
58
- }
59
- }
60
- })()
61
- } else {
62
- setDefaultValue(undefined);
63
- }
64
- }, [visible])
65
-
66
- return (
67
- <Drawer
68
- title="赋码"
69
- placement="right"
70
- destroyOnClose={true}
71
- closable={false}
72
- width={383}
73
- onClose={onClose}
74
- visible={visible}
75
- >
76
- {defaultValue && <DrawerBody defaultValue={defaultValue} />}
77
- </Drawer>
78
- );
79
- };
80
-
81
- const DrawerBody = (props: { defaultValue: IGood }) => {
82
-
83
- const controller = Invoice.useInvoiceController();
84
-
85
- const { defaultValue } = props;
86
-
87
- const actions = React.useMemo(() => createAsyncFormActions(), []);
88
-
89
- /** 免税类型 是否需要 */
90
- const isTaxFreeTypeNeeded = controller.useMemo(s => s.goodsListState.endowCode.isTaxFreeTypeNeeded, []);
91
-
92
- /** 税率 是否禁用 */
93
- const readOnlyTaxRate = controller.useMemo(s => {
94
- if (s.goodsListState.endowCode.getReadOnlyTaxRate) {
95
- return s.goodsListState.endowCode.getReadOnlyTaxRate(s.goodsListState);
96
- } else {
97
- return false;
98
- }
99
- }, [])
100
-
101
- /** 优惠政策 是否禁用 */
102
- const readOnlyFavouredPolicy = controller.useMemo(s => {
103
- if (s.goodsListState.endowCode.getReadOnlyFavouredPolicy) {
104
- return s.goodsListState.endowCode.getReadOnlyFavouredPolicy(s.goodsListState);
105
- } else {
106
- return false;
107
- }
108
- }, [])
109
-
110
- /** 税率列表 */
111
- const taxRateList = controller.useMemo(s => s.goodsListState.taxRateList.map((e) => ({ label: `${e}%`, value: e })), []);
112
-
113
- /** 免税类型 列表 */
114
- const taxFreeTypeList = controller.useMemo(s => s.goodsListState.endowCode.taxFreeTypeList, []);
115
-
116
- /** 优惠政策类型列表 */
117
- const favouredPolicyNameList = controller.useMemo(s => s.goodsListState.endowCode.favouredPolicyNameList, []);
118
-
119
- /** 优惠政策类型列表 */
120
- // const getTaxCategoryCodeTree = controller.useMemo(s => s.goodsListState.endowCode.getTaxCategoryCodeTree, []);
121
-
122
- /** 税率 */
123
- const [taxRate, setTaxRate] = React.useState<number>(0);
124
-
125
- /** 税收分类编码 选择组件 */
126
- const ShowSearch = React.useCallback(props => {
127
-
128
- const [dataSource, setDataSource] = React.useState<any[]>([]);
129
-
130
- const onSearch = React.useCallback(async e => {
131
- const arr = await controller.state.goodsListState.endowCode.getTaxCategoryCodeList(e);
132
- setDataSource(arr);
133
- }, [])
134
-
135
- const onChange = React.useCallback((value: string) => {
136
- if (props.onChange) {
137
- props.onChange(value);
138
- }
139
-
140
- const info = dataSource.filter(i => i.value === value)[0];
141
- if (!info) return;
142
-
143
- !readOnlyTaxRate && actions.setFieldState('taxRate', async s => {
144
- if (info.taxRate || info.taxRate === 0) {
145
- s.value = info.taxRate
146
- }
147
- });
148
-
149
- actions.setFieldState('shorthand', async (s) => {
150
- if (info.shorthand) {
151
- s.value = info.shorthand
152
- }
153
- });
154
- }, [actions, dataSource, readOnlyTaxRate])
155
-
156
- return (
157
- <Select
158
- {...props}
159
- showSearch
160
- showArrow={false}
161
- notFoundContent={null}
162
- filterOption={false}
163
- onSearch={onSearch}
164
- onChange={onChange}
165
- >
166
- {dataSource.map(e => <Select.Option key={e.value} value={e.value}>{e.label}</Select.Option>)}
167
- </Select>
168
- )
169
- }, [controller, actions])
170
-
171
- /** 税收分类编码 选择组件2 */
172
- const ShowSearch2 = React.useCallback(props => {
173
-
174
- // 是否显示
175
- const [visible, setVisible] = React.useState(false);
176
-
177
- // 税收分类编码树
178
- const [list, setList] = React.useState<any[]>();
179
-
180
- // 搜索条件
181
- const [filter, setFilter] = React.useState<{
182
- /** 税收分类编码 */
183
- taxCategoryCode?: string,
184
-
185
- /** 货物和劳务名称/简称 */
186
- val?: string
187
- }>();
188
-
189
- /** 创建 树节点 */
190
- const createTreeNode = React.useCallback(() => {
191
- if (!list) return <></>;
192
-
193
- return ctn(list);
194
-
195
- function title(label: string) {
196
- if (!filter) return label;
197
- label = (filter.taxCategoryCode ? label.split(new RegExp(filter.taxCategoryCode, 'g')) : [label]).join(`<span style="color: #1890ff;">${filter.taxCategoryCode}</span>`);
198
- label = (filter.val ? label.split(new RegExp(filter.val, 'g')) : [label]).join(`<span style="color: #1890ff;">${filter.val}</span>`);
199
- return <span dangerouslySetInnerHTML={{ __html: label }} />
200
- }
201
-
202
- function ctn(l: any[], p = '0') {
203
- if (!l || !l.length) return [<></>];
204
- return l.filter(e => e.pid === p).map(e => {
205
- return (
206
- <TreeNode title={title(e.label)} key={e.id}>
207
- {ctn(l, e.id)}
208
- </TreeNode>
209
- )
210
- })
211
- }
212
- }, [list, filter])
213
-
214
- /** 点击了节点 */
215
- const onSelect = React.useCallback((e: string[]) => {
216
- const id = e[0];
217
-
218
- // 是否叶子节点
219
- if (list?.filter(e => e.pid === id).length !== 0) { return; }
220
-
221
- const info = list?.filter(e => e.id === id)[0];
222
-
223
- !readOnlyTaxRate && actions.setFieldState('taxRate', async s => {
224
- if (info.taxRate || info.taxRate === 0) {
225
- s.value = info.taxRate
226
- }
227
- });
228
-
229
- actions.setFieldState('taxClassificationCode', async s => {
230
- if (info.id) {
231
- s.value = info.id
232
- }
233
- });
234
-
235
- actions.setFieldState('shorthand', async (s) => {
236
- if (info.shorthand) {
237
- s.value = info.shorthand
238
- }
239
- });
240
-
241
- setVisible(false);
242
- }, [list, actions, readOnlyTaxRate])
243
-
244
- React.useEffect(() => {
245
- (async () => {
246
- const fn = controller.state.goodsListState.endowCode.getTaxCategoryCodeTree || (async () => []);
247
- const list = await fn(filter?.taxCategoryCode, filter?.val);
248
- setList(list || []);
249
- })()
250
- }, [filter])
251
-
252
- React.useEffect(() => {
253
- if (visible) {
254
- setList([])
255
- }
256
- }, [visible])
257
-
258
- return (
259
- <>
260
- <InputAntd readOnly value={props.value} addonAfter={<Button size="small" type="link" onClick={() => { setVisible(true) }} >点击选择</Button>} />
261
- <Drawer
262
- title="税收分类编码"
263
- visible={visible}
264
- width={500}
265
- onClose={() => { setVisible(false) }}
266
- >
267
- <Form key={`${visible}`} >
268
- <Form.Item label="产品或服务简称" >
269
- <InputAntd onChange={e => { setFilter({ ...filter, val: e.target.value }) }} />
270
- </Form.Item>
271
- <Form.Item label="税收分类编码">
272
- <InputAntd onChange={e => { setFilter({ ...filter, taxCategoryCode: e.target.value }) }} />
273
- </Form.Item>
274
- </Form>
275
- {
276
- (list && list.length > 0)
277
- ? <Tree
278
- defaultExpandAll
279
- selectedKeys={[]}
280
- onSelect={onSelect}
281
- >
282
- {createTreeNode()}
283
- </Tree>
284
- : <span style={{ color: '#00000073' }} >请输入“产品或服务简称”或“税收分类编码”查找数据。</span>
285
- }
286
- </Drawer>
287
- </>
288
- )
289
- }, [controller, actions])
290
-
291
- // 是否享受优惠政策
292
- const [favouredPolicyMark, setFavouredPolicyMark] = React.useState<number>(0);
293
-
294
- // 确定
295
- const onSubmit = React.useCallback(values => {
296
- controller.pipeline(async s => {
297
-
298
- const endowCodeGood = s.goodsListState.endowCode.endowcodeGoodIndex.map(e => s.goodsListState.goodsMap.get(e));
299
-
300
- // 赋码
301
- endowCodeGood.forEach(good => {
302
- if (!good) return;
303
-
304
- good.shorthand = values.shorthand;
305
- good.taxClassificationCode = values.taxClassificationCode;
306
- good.taxRate = values.taxRate;
307
- good.taxFreeType = values.taxFreeType;
308
- good.favouredPolicyMark = values.favouredPolicyMark;
309
- good.favouredPolicyName = values.favouredPolicyName;
310
-
311
- const taxRate = chain(bignumber(values.taxRate)).dotDivide(bignumber(100)).add(bignumber(1)).done();
312
-
313
- // 是否含税
314
- const lineAmountExcludeTax = chain(bignumber(good.lineAmountIncludeTax)).dotDivide(taxRate).done();
315
- const priceExcludeTax = good.priceIncludeTax ? chain(bignumber(good.priceIncludeTax)).dotDivide(taxRate).done() : undefined
316
-
317
- good.lineAmountExcludeTax = lineAmountExcludeTax.toNumber().toFixed(2);
318
- good.priceExcludeTax = (priceExcludeTax ? format15(priceExcludeTax.toNumber(), s.calculatingDigits) : undefined) || undefined;
319
-
320
- good.taxAmount = countTaxAmount(good.lineAmountIncludeTax || 0, s.goodsListState.deduction, values.taxRate);
321
- });
322
-
323
- s.goodsListState.goodsList = s.goodsListState.goodsList.slice();
324
- s.goodsListState.endowCode.endowcodeGoodIndex = [];
325
- })();
326
- }, [controller]);
327
-
328
- const effects = React.useCallback(() => {
329
- // 税率变化
330
- FormEffectHooks.onFieldValueChange$('taxRate').subscribe((e) => {
331
- setTaxRate(e.value);
332
- actions.setFieldState('taxFreeType', async (s) => {
333
- if (e.value !== 0)
334
- s.value = undefined;
335
- });
336
- });
337
-
338
- // 是否享受优惠政策
339
- FormEffectHooks.onFieldValueChange$('favouredPolicyMark').subscribe((e) => {
340
- setFavouredPolicyMark(e.value);
341
- actions.setFieldState('favouredPolicyName', async (s) => {
342
- if (e.value === 0)
343
- s.value = undefined;
344
- });
345
- });
346
- }, [actions]);
347
-
348
- // 更新 税收分类编码列表
349
- React.useEffect(() => {
350
- if (controller.getTaxCategoryCodeList) controller.getTaxCategoryCodeList();
351
- }, [controller]);
352
-
353
- return (
354
- <SchemaForm actions={actions} previewPlaceholder=" " components={{ ...components, showSearch: !!controller.state.goodsListState.endowCode.getTaxCategoryCodeTree ? ShowSearch2 : ShowSearch }} effects={effects}>
355
- <FormButtonGroup>
356
- <Field
357
- name="taxClassificationCode"
358
- type="showSearch"
359
- title="税收分类编码"
360
- // enum={taxCategoryCodeList}
361
- default={defaultValue?.taxClassificationCode}
362
- x-rules={[{ message: '请选择税收分类编码', required: true }]}
363
- />
364
- <Field
365
- name="shorthand"
366
- type="string"
367
- readOnly
368
- default={defaultValue?.shorthand}
369
- title="商品和服务分类简称"
370
- />
371
- <Field
372
- name="taxRate"
373
- type="string"
374
- title="税率"
375
- x-component-props={{ disabled: readOnlyTaxRate }}
376
- default={defaultValue?.taxRate ?? 0}
377
- enum={taxRateList}
378
- x-rules={[{ message: '请选择税率', required: true }]}
379
- />
380
- {taxRate === 0 && isTaxFreeTypeNeeded &&
381
- <Field
382
- name="taxFreeType"
383
- type="string"
384
- title="免税类型"
385
- x-component-props={{ disabled: readOnlyTaxRate }}
386
- default={defaultValue?.taxFreeType}
387
- enum={taxFreeTypeList}
388
- x-rules={[{ message: '请选择免税类型', required: true }]}
389
- />
390
- }
391
- <Field
392
- name="favouredPolicyMark"
393
- type="number"
394
- title="是否享受优惠政策"
395
- x-component-props={{ disabled: readOnlyFavouredPolicy }}
396
- enum={[
397
- { label: '是', value: 1 },
398
- { label: '否', value: 0 },
399
- ]}
400
- default={defaultValue?.favouredPolicyMark ?? 0}
401
- x-rules={[{ message: '请选择是否享受优惠政策', required: true }]}
402
- />
403
- {favouredPolicyMark === 1 &&
404
- <Field
405
- name="favouredPolicyName"
406
- type="string"
407
- title="优惠政策类型"
408
- x-component-props={{ disabled: readOnlyFavouredPolicy }}
409
- enum={favouredPolicyNameList}
410
- default={defaultValue?.favouredPolicyName}
411
- x-rules={[{ message: '请选择是否享受优惠政策', required: true }]}
412
- />
413
- }
414
- </FormButtonGroup>
415
-
416
- <span className="kts-invoice-operate-goods-endow-code-button-list">
417
- <Button onClick={() => { actions.submit(onSubmit) }} type="primary">
418
- 确定
419
- </Button>
420
- <Button onClick={() => { controller.pipeline(async s => (s.goodsListState.endowCode.endowcodeGoodIndex = []))() }}>
421
- 取消
422
- </Button>
423
- </span>
424
- </SchemaForm>
425
- );
426
- };
427
-
428
- const components = {
429
- string: Input,
430
- number: NumberPicker,
431
- };
1
+ import React from 'react';
2
+ import Invoice from '../../..';
3
+ import { Button, Drawer, Select, Modal, Input as InputAntd, Form, Tree, message } from 'kts-components-antd-x3';
4
+ import { chain, bignumber } from 'mathjs';
5
+ import { Input, NumberPicker } from '@formily/antd-components';
6
+ import { format15 } from '../GoodsList/hook/useColumns/autoFillFn';
7
+ import { LineAttributeType } from '../../../InvoiceController';
8
+ import IGood from '../../../InvoiceController/InvoiceControllerState/GoodsListState/IGood';
9
+ import { countTaxAmount } from '../../../tools/calculate';
10
+ import { bytesLnegth, cutStr } from '../../../tools/strringFn';
11
+ import {
12
+ SchemaForm,
13
+ FormButtonGroup,
14
+ createAsyncFormActions,
15
+ SchemaMarkupField as Field,
16
+ FormEffectHooks,
17
+ } from '@formily/antd';
18
+ import './index.less';
19
+
20
+ const { TreeNode } = Tree;
21
+ const { confirm } = Modal;
22
+
23
+ export default () => {
24
+ const controller = Invoice.useInvoiceController();
25
+
26
+ const visible = controller.useMemo(s => s.goodsListState.endowCode.endowcodeGoodIndex.length > 0, []);
27
+
28
+ const [defaultValue, setDefaultValue] = React.useState<IGood>();
29
+
30
+ const onClose = React.useCallback(() => {
31
+ controller.pipeline(async (s) => {
32
+ s.goodsListState.endowCode.endowcodeGoodIndex = [];
33
+ })();
34
+ }, [controller]);
35
+
36
+ // 计算赋码默认值
37
+ React.useEffect(() => {
38
+ if (visible) {
39
+ controller.pipeline(async s => {
40
+ const endowcodeGoodIndex = s.goodsListState.endowCode.endowcodeGoodIndex.filter(i => {
41
+ const good = s.goodsListState.goodsMap.get(i);
42
+ if (!good) return false;
43
+
44
+ return good.lineAttribute !== LineAttributeType.折扣行;
45
+ })
46
+
47
+ const good = s.goodsListState.goodsMap.get(s.goodsListState.endowCode.endowcodeGoodIndex[0]);
48
+ if (!good) return;
49
+
50
+ const getDefaultValue = s.goodsListState.endowCode.getDefaultValue;
51
+ if (getDefaultValue) {
52
+ setDefaultValue(await getDefaultValue({ ...good }, endowcodeGoodIndex.length));
53
+ } else {
54
+ if (endowcodeGoodIndex.length === 1) {
55
+ setDefaultValue(good);
56
+ } else {
57
+ setDefaultValue({ taxRate: good.taxRate } as any);
58
+ }
59
+ }
60
+ })()
61
+ } else {
62
+ setDefaultValue(undefined);
63
+ }
64
+ }, [visible])
65
+
66
+ return (
67
+ <Drawer
68
+ title="赋码"
69
+ placement="right"
70
+ destroyOnClose={true}
71
+ closable={false}
72
+ width={383}
73
+ onClose={onClose}
74
+ visible={visible}
75
+ >
76
+ {defaultValue && <DrawerBody defaultValue={defaultValue} />}
77
+ </Drawer>
78
+ );
79
+ };
80
+
81
+ const DrawerBody = (props: { defaultValue: IGood }) => {
82
+
83
+ const controller = Invoice.useInvoiceController();
84
+
85
+ const { defaultValue } = props;
86
+
87
+ const actions = React.useMemo(() => createAsyncFormActions(), []);
88
+
89
+ /** 免税类型 是否需要 */
90
+ const isTaxFreeTypeNeeded = controller.useMemo(s => s.goodsListState.endowCode.isTaxFreeTypeNeeded, []);
91
+
92
+ /** 税率 是否禁用 */
93
+ const readOnlyTaxRate = controller.useMemo(s => {
94
+ if (s.goodsListState.endowCode.getReadOnlyTaxRate) {
95
+ return s.goodsListState.endowCode.getReadOnlyTaxRate(s.goodsListState);
96
+ } else {
97
+ return false;
98
+ }
99
+ }, [])
100
+
101
+ /** 优惠政策 是否禁用 */
102
+ const readOnlyFavouredPolicy = controller.useMemo(s => {
103
+ if (s.goodsListState.endowCode.getReadOnlyFavouredPolicy) {
104
+ return s.goodsListState.endowCode.getReadOnlyFavouredPolicy(s.goodsListState);
105
+ } else {
106
+ return false;
107
+ }
108
+ }, [])
109
+
110
+ /** 税率列表 */
111
+ const taxRateList = controller.useMemo(s => s.goodsListState.taxRateList.map((e) => ({ label: `${e}%`, value: e })), []);
112
+
113
+ /** 免税类型 列表 */
114
+ const taxFreeTypeList = controller.useMemo(s => s.goodsListState.endowCode.taxFreeTypeList, []);
115
+
116
+ /** 优惠政策类型列表 */
117
+ const favouredPolicyNameList = controller.useMemo(s => s.goodsListState.endowCode.favouredPolicyNameList, []);
118
+
119
+ /** 优惠政策类型列表 */
120
+ // const getTaxCategoryCodeTree = controller.useMemo(s => s.goodsListState.endowCode.getTaxCategoryCodeTree, []);
121
+
122
+ /** 税率 */
123
+ const [taxRate, setTaxRate] = React.useState<number>(0);
124
+
125
+ /** 税收分类编码 选择组件 */
126
+ const ShowSearch = React.useCallback(props => {
127
+
128
+ const [dataSource, setDataSource] = React.useState<any[]>([]);
129
+
130
+ const onSearch = React.useCallback(async e => {
131
+ const arr = await controller.state.goodsListState.endowCode.getTaxCategoryCodeList(e);
132
+ setDataSource(arr);
133
+ }, [])
134
+
135
+ const onChange = React.useCallback((value: string) => {
136
+ if (props.onChange) {
137
+ props.onChange(value);
138
+ }
139
+
140
+ const info = dataSource.filter(i => i.value === value)[0];
141
+ if (!info) return;
142
+
143
+ !readOnlyTaxRate && actions.setFieldState('taxRate', async s => {
144
+ if (info.taxRate || info.taxRate === 0) {
145
+ s.value = info.taxRate
146
+ }
147
+ });
148
+
149
+ actions.setFieldState('shorthand', async (s) => {
150
+ if (info.shorthand) {
151
+ s.value = info.shorthand
152
+ }
153
+ });
154
+ }, [actions, dataSource, readOnlyTaxRate])
155
+
156
+ return (
157
+ <Select
158
+ {...props}
159
+ showSearch
160
+ showArrow={false}
161
+ notFoundContent={null}
162
+ filterOption={false}
163
+ onSearch={onSearch}
164
+ onChange={onChange}
165
+ >
166
+ {dataSource.map(e => <Select.Option key={e.value} value={e.value}>{e.label}</Select.Option>)}
167
+ </Select>
168
+ )
169
+ }, [controller, actions])
170
+
171
+ /** 税收分类编码 选择组件2 */
172
+ const ShowSearch2 = React.useCallback(props => {
173
+
174
+ // 是否显示
175
+ const [visible, setVisible] = React.useState(false);
176
+
177
+ // 税收分类编码树
178
+ const [list, setList] = React.useState<any[]>();
179
+
180
+ // 搜索条件
181
+ const [filter, setFilter] = React.useState<{
182
+ /** 税收分类编码 */
183
+ taxCategoryCode?: string,
184
+
185
+ /** 货物和劳务名称/简称 */
186
+ val?: string
187
+ }>();
188
+
189
+ /** 创建 树节点 */
190
+ const createTreeNode = React.useCallback(() => {
191
+ if (!list) return <></>;
192
+
193
+ return ctn(list);
194
+
195
+ function title(label: string) {
196
+ if (!filter) return label;
197
+ label = (filter.taxCategoryCode ? label.split(new RegExp(filter.taxCategoryCode, 'g')) : [label]).join(`<span style="color: #1890ff;">${filter.taxCategoryCode}</span>`);
198
+ label = (filter.val ? label.split(new RegExp(filter.val, 'g')) : [label]).join(`<span style="color: #1890ff;">${filter.val}</span>`);
199
+ return <span dangerouslySetInnerHTML={{ __html: label }} />
200
+ }
201
+
202
+ function ctn(l: any[], p = '0') {
203
+ if (!l || !l.length) return [<></>];
204
+ return l.filter(e => e.pid === p).map(e => {
205
+ return (
206
+ <TreeNode title={title(e.label)} key={e.id}>
207
+ {ctn(l, e.id)}
208
+ </TreeNode>
209
+ )
210
+ })
211
+ }
212
+ }, [list, filter])
213
+
214
+ /** 点击了节点 */
215
+ const onSelect = React.useCallback((e: string[]) => {
216
+ const id = e[0];
217
+
218
+ // 是否叶子节点
219
+ if (list?.filter(e => e.pid === id).length !== 0) { return; }
220
+
221
+ const info = list?.filter(e => e.id === id)[0];
222
+
223
+ !readOnlyTaxRate && actions.setFieldState('taxRate', async s => {
224
+ if (info.taxRate || info.taxRate === 0) {
225
+ s.value = info.taxRate
226
+ }
227
+ });
228
+
229
+ actions.setFieldState('taxClassificationCode', async s => {
230
+ if (info.id) {
231
+ s.value = info.id
232
+ }
233
+ });
234
+
235
+ actions.setFieldState('shorthand', async (s) => {
236
+ if (info.shorthand) {
237
+ s.value = info.shorthand
238
+ }
239
+ });
240
+
241
+ setVisible(false);
242
+ }, [list, actions, readOnlyTaxRate])
243
+
244
+ React.useEffect(() => {
245
+ (async () => {
246
+ const fn = controller.state.goodsListState.endowCode.getTaxCategoryCodeTree || (async () => []);
247
+ const list = await fn(filter?.taxCategoryCode, filter?.val);
248
+ setList(list || []);
249
+ })()
250
+ }, [filter])
251
+
252
+ React.useEffect(() => {
253
+ if (visible) {
254
+ setList([])
255
+ }
256
+ }, [visible])
257
+
258
+ return (
259
+ <>
260
+ <InputAntd readOnly value={props.value} addonAfter={<Button size="small" type="link" onClick={() => { setVisible(true) }} >点击选择</Button>} />
261
+ <Drawer
262
+ title="税收分类编码"
263
+ visible={visible}
264
+ width={500}
265
+ onClose={() => { setVisible(false) }}
266
+ >
267
+ <Form key={`${visible}`} >
268
+ <Form.Item label="产品或服务简称" >
269
+ <InputAntd onChange={e => { setFilter({ ...filter, val: e.target.value }) }} />
270
+ </Form.Item>
271
+ <Form.Item label="税收分类编码">
272
+ <InputAntd onChange={e => { setFilter({ ...filter, taxCategoryCode: e.target.value }) }} />
273
+ </Form.Item>
274
+ </Form>
275
+ {
276
+ (list && list.length > 0)
277
+ ? <Tree
278
+ defaultExpandAll
279
+ selectedKeys={[]}
280
+ onSelect={onSelect}
281
+ >
282
+ {createTreeNode()}
283
+ </Tree>
284
+ : <span style={{ color: '#00000073' }} >请输入“产品或服务简称”或“税收分类编码”查找数据。</span>
285
+ }
286
+ </Drawer>
287
+ </>
288
+ )
289
+ }, [controller, actions])
290
+
291
+ // 是否享受优惠政策
292
+ const [favouredPolicyMark, setFavouredPolicyMark] = React.useState<number>(0);
293
+
294
+ // 确定
295
+ const onSubmit = React.useCallback(values => {
296
+ controller.pipeline(async s => {
297
+
298
+ const endowCodeGood = s.goodsListState.endowCode.endowcodeGoodIndex.map(e => s.goodsListState.goodsMap.get(e));
299
+
300
+ // 赋码
301
+ endowCodeGood.forEach(good => {
302
+ if (!good) return;
303
+
304
+ good.shorthand = values.shorthand;
305
+ good.taxClassificationCode = values.taxClassificationCode;
306
+ good.taxRate = values.taxRate;
307
+ good.taxFreeType = values.taxFreeType;
308
+ good.favouredPolicyMark = values.favouredPolicyMark;
309
+ good.favouredPolicyName = values.favouredPolicyName;
310
+
311
+ const taxRate = chain(bignumber(values.taxRate)).dotDivide(bignumber(100)).add(bignumber(1)).done();
312
+
313
+ // 是否含税
314
+ const lineAmountExcludeTax = chain(bignumber(good.lineAmountIncludeTax)).dotDivide(taxRate).done();
315
+ const priceExcludeTax = good.priceIncludeTax ? chain(bignumber(good.priceIncludeTax)).dotDivide(taxRate).done() : undefined
316
+
317
+ good.lineAmountExcludeTax = lineAmountExcludeTax.toNumber().toFixed(2);
318
+ good.priceExcludeTax = (priceExcludeTax ? format15(priceExcludeTax.toNumber(), s.calculatingDigits) : undefined) || undefined;
319
+
320
+ good.taxAmount = countTaxAmount(good.lineAmountIncludeTax || 0, s.goodsListState.deduction, values.taxRate);
321
+ });
322
+
323
+ s.goodsListState.goodsList = s.goodsListState.goodsList.slice();
324
+ s.goodsListState.endowCode.endowcodeGoodIndex = [];
325
+ })();
326
+ }, [controller]);
327
+
328
+ const effects = React.useCallback(() => {
329
+ // 税率变化
330
+ FormEffectHooks.onFieldValueChange$('taxRate').subscribe((e) => {
331
+ setTaxRate(e.value);
332
+ actions.setFieldState('taxFreeType', async (s) => {
333
+ if (e.value !== 0)
334
+ s.value = undefined;
335
+ });
336
+ });
337
+
338
+ // 是否享受优惠政策
339
+ FormEffectHooks.onFieldValueChange$('favouredPolicyMark').subscribe((e) => {
340
+ setFavouredPolicyMark(e.value);
341
+ actions.setFieldState('favouredPolicyName', async (s) => {
342
+ if (e.value === 0)
343
+ s.value = undefined;
344
+ });
345
+ });
346
+ }, [actions]);
347
+
348
+ // 更新 税收分类编码列表
349
+ React.useEffect(() => {
350
+ if (controller.getTaxCategoryCodeList) controller.getTaxCategoryCodeList();
351
+ }, [controller]);
352
+
353
+ return (
354
+ <SchemaForm actions={actions} previewPlaceholder=" " components={{ ...components, showSearch: !!controller.state.goodsListState.endowCode.getTaxCategoryCodeTree ? ShowSearch2 : ShowSearch }} effects={effects}>
355
+ <FormButtonGroup>
356
+ <Field
357
+ name="taxClassificationCode"
358
+ type="showSearch"
359
+ title="税收分类编码"
360
+ // enum={taxCategoryCodeList}
361
+ default={defaultValue?.taxClassificationCode}
362
+ x-rules={[{ message: '请选择税收分类编码', required: true }]}
363
+ />
364
+ <Field
365
+ name="shorthand"
366
+ type="string"
367
+ readOnly
368
+ default={defaultValue?.shorthand}
369
+ title="商品和服务分类简称"
370
+ />
371
+ <Field
372
+ name="taxRate"
373
+ type="string"
374
+ title="税率"
375
+ x-component-props={{ disabled: readOnlyTaxRate }}
376
+ default={defaultValue?.taxRate ?? 0}
377
+ enum={taxRateList}
378
+ x-rules={[{ message: '请选择税率', required: true }]}
379
+ />
380
+ {taxRate === 0 && isTaxFreeTypeNeeded &&
381
+ <Field
382
+ name="taxFreeType"
383
+ type="string"
384
+ title="免税类型"
385
+ x-component-props={{ disabled: readOnlyTaxRate }}
386
+ default={defaultValue?.taxFreeType}
387
+ enum={taxFreeTypeList}
388
+ x-rules={[{ message: '请选择免税类型', required: true }]}
389
+ />
390
+ }
391
+ <Field
392
+ name="favouredPolicyMark"
393
+ type="number"
394
+ title="是否享受优惠政策"
395
+ x-component-props={{ disabled: readOnlyFavouredPolicy }}
396
+ enum={[
397
+ { label: '是', value: 1 },
398
+ { label: '否', value: 0 },
399
+ ]}
400
+ default={defaultValue?.favouredPolicyMark ?? 0}
401
+ x-rules={[{ message: '请选择是否享受优惠政策', required: true }]}
402
+ />
403
+ {favouredPolicyMark === 1 &&
404
+ <Field
405
+ name="favouredPolicyName"
406
+ type="string"
407
+ title="优惠政策类型"
408
+ x-component-props={{ disabled: readOnlyFavouredPolicy }}
409
+ enum={favouredPolicyNameList}
410
+ default={defaultValue?.favouredPolicyName}
411
+ x-rules={[{ message: '请选择是否享受优惠政策', required: true }]}
412
+ />
413
+ }
414
+ </FormButtonGroup>
415
+
416
+ <span className="kts-invoice-operate-goods-endow-code-button-list">
417
+ <Button onClick={() => { actions.submit(onSubmit) }} type="primary">
418
+ 确定
419
+ </Button>
420
+ <Button onClick={() => { controller.pipeline(async s => (s.goodsListState.endowCode.endowcodeGoodIndex = []))() }}>
421
+ 取消
422
+ </Button>
423
+ </span>
424
+ </SchemaForm>
425
+ );
426
+ };
427
+
428
+ const components = {
429
+ string: Input,
430
+ number: NumberPicker,
431
+ };