kts-component-invoice-operate 3.2.16 → 3.2.18

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 (191) 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/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
  9. package/dist/Invoice/InvoiceController/fns/mergeDetails.d.ts +2 -0
  10. package/dist/Invoice/InvoiceController/index.d.ts +2 -0
  11. package/dist/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDetails/index.d.ts +6 -0
  12. package/dist/index.esm.js +6995 -4737
  13. package/dist/index.js +6994 -4736
  14. package/docs/index.md +5 -5
  15. package/docs-dist/static/arrowDown.a1cbf0d8.svg +2 -2
  16. package/docs-dist/static/arrowUp.4c482054.svg +2 -2
  17. package/docs-dist/static/fork.5431267d.svg +11 -11
  18. package/docs-dist/static/plus.44013ce3.svg +11 -11
  19. package/docs-dist/static/plus.4fd1af30.svg +11 -11
  20. package/index.html +12 -12
  21. package/package.json +60 -60
  22. package/src/Invoice/Invoice-digtal/_test/disabled/index.tsx +38 -38
  23. package/src/Invoice/Invoice-digtal/_test/easiest/index.tsx +16 -16
  24. package/src/Invoice/Invoice-digtal/_test/header/index.tsx +17 -17
  25. package/src/Invoice/Invoice-digtal/_test/importGoods/index.tsx +470 -470
  26. package/src/Invoice/Invoice-digtal/_test/importStakeholder/index.tsx +17 -17
  27. package/src/Invoice/Invoice-digtal/_test/lineCredit/index.tsx +20 -20
  28. package/src/Invoice/Invoice-digtal/_test/prefab/index.tsx +150 -150
  29. package/src/Invoice/Invoice-digtal/_test/readOnly/index.tsx +41 -41
  30. package/src/Invoice/Invoice-digtal/_test/stakeholder/index.tsx +12 -12
  31. package/src/Invoice/Invoice-digtal/_test/typeSelection/index.tsx +29 -29
  32. package/src/Invoice/Invoice-digtal/index.md +30 -30
  33. package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +94 -94
  34. package/src/Invoice/InvoiceController/InvoiceControllerState/BuyerState/index.tsx +88 -88
  35. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/EndowCode/index.tsx +93 -93
  36. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IColumnsReplenish/index.ts +10 -10
  37. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +75 -75
  38. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ImportGoods/index.ts +80 -80
  39. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.ts +5 -5
  40. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.ts +9 -9
  41. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +97 -94
  42. package/src/Invoice/InvoiceController/InvoiceControllerState/Stakeholder/index.ts +10 -10
  43. package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +56 -56
  44. package/src/Invoice/InvoiceController/fns/addGood.ts +11 -11
  45. package/src/Invoice/InvoiceController/fns/addGoodDiscount.ts +125 -125
  46. package/src/Invoice/InvoiceController/fns/addGoodDiscountV2.ts +84 -84
  47. package/src/Invoice/InvoiceController/fns/delGood.ts +41 -41
  48. package/src/Invoice/InvoiceController/fns/getGoodsSearch.ts +23 -23
  49. package/src/Invoice/InvoiceController/fns/mergeDetails.ts +125 -0
  50. package/src/Invoice/InvoiceController/fns/saveEditGood.ts +24 -24
  51. package/src/Invoice/InvoiceController/fns/setEditGood.ts +16 -16
  52. package/src/Invoice/InvoiceController/fns/setGoods.ts +10 -10
  53. package/src/Invoice/InvoiceController/fns/updateInvoiceNo.ts +8 -8
  54. package/src/Invoice/InvoiceController/index.ts +69 -65
  55. package/src/Invoice/_test/buyerNameSearch/index.tsx +41 -41
  56. package/src/Invoice/_test/deduction/index.tsx +935 -935
  57. package/src/Invoice/_test/draft/index.tsx +40 -40
  58. package/src/Invoice/_test/easiest/index.tsx +5 -5
  59. package/src/Invoice/_test/endowCode/index.tsx +1095 -1095
  60. package/src/Invoice/_test/goodsMenuExpand/index.tsx +32 -32
  61. package/src/Invoice/_test/importBuyer/index.tsx +74 -74
  62. package/src/Invoice/_test/importGoods/index.tsx +515 -515
  63. package/src/Invoice/_test/invoiceType/index.tsx +59 -59
  64. package/src/Invoice/_test/isInvoiceNo/index.tsx +12 -12
  65. package/src/Invoice/_test/replaceHead/index.tsx +22 -22
  66. package/src/Invoice/_test/retrieveData/index.tsx +22 -22
  67. package/src/Invoice/_test/seller/index.tsx +28 -28
  68. package/src/Invoice/_test/setDataSource/index.tsx +22 -22
  69. package/src/Invoice/_test/unit/index.tsx +19 -19
  70. package/src/Invoice/index.less +29 -29
  71. package/src/Invoice/index.md +53 -53
  72. package/src/Invoice/index.tsx +165 -165
  73. package/src/Invoice/tools/calculate/index.ts +112 -112
  74. package/src/Invoice/tools/coolingFn/index.ts +17 -17
  75. package/src/Invoice/tools/evaluate/index.ts +7 -7
  76. package/src/Invoice/tools/idGenerator/index.ts +2 -2
  77. package/src/Invoice/tools/itemName/index.ts +55 -55
  78. package/src/Invoice/tools/lazyFn/index.ts +19 -19
  79. package/src/Invoice/tools/mounting/index.ts +13 -13
  80. package/src/Invoice/tools/strringFn/index.ts +40 -40
  81. package/src/Invoice/tools/useToGenerateId/index.ts +8 -8
  82. package/src/Invoice/ui/default/AddComparisonDrawer/index.tsx +149 -149
  83. package/src/Invoice/ui/default/Buyer/index.less +219 -219
  84. package/src/Invoice/ui/default/Buyer/index.tsx +114 -114
  85. package/src/Invoice/ui/default/Buyer/ui/BuyerNameInput/index.tsx +166 -166
  86. package/src/Invoice/ui/default/Buyer/ui/ImportBuyerButton/index.tsx +21 -21
  87. package/src/Invoice/ui/default/EndowCodeDrawer/index.less +8 -8
  88. package/src/Invoice/ui/default/EndowCodeDrawer/index.tsx +431 -431
  89. package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +517 -519
  90. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +620 -620
  91. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +9 -9
  92. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +19 -19
  93. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  94. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  95. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -76
  96. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -41
  97. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -34
  98. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -13
  99. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +98 -98
  100. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  101. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  102. package/src/Invoice/ui/default/GoodsList/hook/useDeduction/index.tsx +24 -24
  103. package/src/Invoice/ui/default/GoodsList/hook/useOnRow/index.tsx +39 -39
  104. package/src/Invoice/ui/default/GoodsList/hook/useRowSelection/index.tsx +111 -111
  105. package/src/Invoice/ui/default/GoodsList/hook/useWindowClick/index.tsx +23 -23
  106. package/src/Invoice/ui/default/GoodsList/index.less +177 -177
  107. package/src/Invoice/ui/default/GoodsList/index.tsx +184 -177
  108. package/src/Invoice/ui/default/GoodsList/ui/AddRowButton/index.tsx +65 -65
  109. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.less +21 -21
  110. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +244 -244
  111. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  112. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +69 -69
  113. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +58 -58
  114. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDetails/index.tsx +37 -0
  115. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/index.tsx +37 -37
  116. package/src/Invoice/ui/default/GoodsList/ui/DescribeSwitch/index.tsx +36 -36
  117. package/src/Invoice/ui/default/GoodsList/ui/Search/index.less +10 -10
  118. package/src/Invoice/ui/default/GoodsList/ui/Search/index.tsx +50 -50
  119. package/src/Invoice/ui/default/GoodsList/ui/Statistics/index.less +18 -18
  120. package/src/Invoice/ui/default/GoodsList/ui/Statistics/index.tsx +109 -109
  121. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.tsx +27 -27
  122. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.less +38 -38
  123. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.tsx +108 -108
  124. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual.o/index.less +44 -44
  125. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual.o/index.tsx +96 -96
  126. package/src/Invoice/ui/default/GoodsList/ui/TaxIncludedSwitch/index.tsx +30 -30
  127. package/src/Invoice/ui/default/ImportBuyerDrawer/index.tsx +75 -75
  128. package/src/Invoice/ui/default/ImportGoodsDrawer/index.tsx +170 -170
  129. package/src/Invoice/ui/default/InvoiceHeader/index.less +68 -68
  130. package/src/Invoice/ui/default/InvoiceHeader/index.tsx +246 -246
  131. package/src/Invoice/ui/default/Seller/index.less +113 -113
  132. package/src/Invoice/ui/default/Seller/index.tsx +98 -98
  133. package/src/Invoice/ui/default/Sign/index.less +14 -14
  134. package/src/Invoice/ui/default/Sign/index.tsx +71 -71
  135. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.ts +519 -519
  136. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/index.tsx +635 -635
  137. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/svg/plus.svg +11 -11
  138. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +9 -9
  139. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +24 -24
  140. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  141. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  142. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -76
  143. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -41
  144. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -34
  145. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -13
  146. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +98 -98
  147. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  148. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -20
  149. package/src/Invoice/ui/digtal/GoodsList/hook/useOnRow/index.tsx +39 -39
  150. package/src/Invoice/ui/digtal/GoodsList/hook/useRowSelection/index.tsx +121 -121
  151. package/src/Invoice/ui/digtal/GoodsList/hook/useWindowClick/index.tsx +23 -23
  152. package/src/Invoice/ui/digtal/GoodsList/index.less +56 -56
  153. package/src/Invoice/ui/digtal/GoodsList/index.tsx +180 -180
  154. package/src/Invoice/ui/digtal/GoodsList/ui/AddRowButton/index.tsx +65 -65
  155. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +341 -341
  156. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/svg/add.svg +11 -11
  157. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  158. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +50 -50
  159. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEmptyRefill/index.tsx +35 -35
  160. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +82 -82
  161. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useReselectInvoiceType/index.tsx +57 -57
  162. package/src/Invoice/ui/digtal/GoodsList/ui/DescribeSwitch/index.tsx +36 -36
  163. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.less +11 -11
  164. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.tsx +50 -50
  165. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.less +53 -53
  166. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.tsx +99 -99
  167. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/svg/fork.svg +11 -11
  168. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.tsx +27 -27
  169. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.less +38 -38
  170. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.tsx +108 -108
  171. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual.o/index.less +44 -44
  172. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual.o/index.tsx +96 -96
  173. package/src/Invoice/ui/digtal/GoodsList/ui/TaxIncludedSwitch/index.tsx +30 -30
  174. package/src/Invoice/ui/digtal/InvoiceHeader/index.less +57 -57
  175. package/src/Invoice/ui/digtal/InvoiceHeader/index.tsx +77 -77
  176. package/src/Invoice/ui/digtal/Sign/index.less +48 -48
  177. package/src/Invoice/ui/digtal/Sign/index.tsx +89 -89
  178. package/src/Invoice/ui/digtal/Stakeholder/index.less +56 -56
  179. package/src/Invoice/ui/digtal/Stakeholder/index.tsx +282 -282
  180. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowDown.svg +2 -2
  181. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowUp.svg +2 -2
  182. package/src/Invoice/ui/digtal/Stakeholder/svg/plus.svg +11 -11
  183. package/src/InvoiceTypeModal/_test/easiest/index.tsx +31 -31
  184. package/src/InvoiceTypeModal/index.less +7 -7
  185. package/src/InvoiceTypeModal/index.md +5 -5
  186. package/src/InvoiceTypeModal/index.tsx +153 -153
  187. package/src/index.ts +9 -9
  188. package/tsconfig.json +31 -31
  189. package/typings.d.ts +3 -3
  190. package/yarn.e.lock +14331 -14331
  191. package/yarn.o.lock +0 -14800
@@ -0,0 +1,125 @@
1
+
2
+ import { message } from 'kts-xui';
3
+ import { chain, bignumber } from 'mathjs';
4
+ import idGenerator from '../../tools/idGenerator';
5
+ import { IGood, InvoiceControllerState, LineAttributeType } from '..';
6
+
7
+ export default async function mergeDetails(state: InvoiceControllerState) {
8
+ if (state.goodsListState.goodsList.length <= 1 || state.goodsListState.editGood) return;
9
+ try {
10
+ // 创建合并后的商品对象
11
+ let sum: IGood = { $index: idGenerator(), lineAttribute: LineAttributeType.正常 }
12
+
13
+ // 存在税率不一样的明细,不能合并
14
+ await checkTaxTate(state.goodsListState.goodsList);
15
+
16
+ // 填充行明细信息
17
+ sum = await fillingInformationGood(state.goodsListState.goodsList, sum);
18
+
19
+ // 合并数量
20
+ sum.quantity = await mergeQuantity(state.goodsListState.goodsList);
21
+
22
+ // 合并金额(不含税)
23
+ sum.lineAmountExcludeTax = await mergeLineAmountExcludeTax(state.goodsListState.goodsList);
24
+
25
+ // 合并金额(含税)
26
+ sum.lineAmountIncludeTax = await mergeLineAmountIncludeTax(state.goodsListState.goodsList);
27
+
28
+ // 计算单价(不含税)
29
+ sum.priceExcludeTax = await calculatePriceExcludeTax(sum);
30
+
31
+ // 计算单价(含税)
32
+ sum.priceIncludeTax = await calculatePriceIncludeTax(sum);
33
+
34
+ // 计算税额
35
+ sum.taxAmount = chain(bignumber(sum.lineAmountIncludeTax)).subtract(bignumber(sum.lineAmountExcludeTax)).done().toNumber()
36
+
37
+ state.goodsListState.goodsList = [sum];
38
+ state.goodsListState.goodsMap = new Map([[sum.$index, sum]]);
39
+ } catch (error: any) {
40
+ showError(error)
41
+ }
42
+ }
43
+
44
+ /** 计算单价(含税) */
45
+ async function calculatePriceIncludeTax(sum: IGood) {
46
+ if (!sum.quantity) return undefined;
47
+ return chain(bignumber(sum.lineAmountIncludeTax)).divide(bignumber(sum.quantity)).done().toNumber();
48
+ }
49
+
50
+ /** 计算单价(不含税) */
51
+ async function calculatePriceExcludeTax(sum: IGood) {
52
+ if (!sum.quantity) return undefined;
53
+ return chain(bignumber(sum.lineAmountExcludeTax)).divide(bignumber(sum.quantity)).done().toNumber();
54
+ }
55
+
56
+ /** 合并金额(含税) */
57
+ async function mergeLineAmountIncludeTax(goodsList: IGood[]) {
58
+ let sum = chain(bignumber(0));
59
+ goodsList.forEach(e => {
60
+ sum = sum.add(bignumber(e.lineAmountIncludeTax || 0))
61
+ })
62
+ return sum.done().toNumber();
63
+ }
64
+
65
+ /** 合并金额(不含税) */
66
+ async function mergeLineAmountExcludeTax(goodsList: IGood[]) {
67
+ let sum = chain(bignumber(0));
68
+ goodsList.forEach(e => {
69
+ sum = sum.add(bignumber(e.lineAmountExcludeTax || 0))
70
+ })
71
+ return sum.done().toNumber();
72
+ }
73
+
74
+ /** 合并数量 */
75
+ async function mergeQuantity(goodsList: IGood[]) {
76
+ let sum = chain(bignumber(0));
77
+ goodsList.forEach(e => {
78
+ sum = sum.add(bignumber(e.quantity || 0))
79
+ })
80
+ return sum.done().toNumber() || undefined;
81
+ }
82
+
83
+ /** 填充行明细信息 */
84
+ async function fillingInformationGood(goodsList: IGood[], sum: IGood) {
85
+ sum = { ...sum };
86
+
87
+ const goods = goodsList[findMaxIndex(goodsList.map(e => e.lineAmountIncludeTax || 0))]
88
+
89
+ return { ...goods };
90
+ }
91
+
92
+ /** 存在税率不一样的明细,不能合并 */
93
+ async function checkTaxTate(goodsList: IGood[]) {
94
+ const tax = goodsList[0].taxRate;
95
+ for (let i = 1; i < goodsList.length; i++) {
96
+ if (tax !== goodsList[i].taxRate) {
97
+ throw new Error('存在税率不一样的明细,不能合并');
98
+ }
99
+ }
100
+ }
101
+
102
+ /** 显示错误信息 */
103
+ function showError(error: Error) {
104
+ console.log(error);
105
+ message.error({ content: error.message, key: error.message });
106
+ }
107
+
108
+ /** 查询最大数据的索引 */
109
+ function findMaxIndex(arr: number[]): number {
110
+ if (arr.length === 0) {
111
+ throw new Error("数组为空");
112
+ }
113
+
114
+ let maxIndex = 0;
115
+ let maxValue = arr[0];
116
+
117
+ for (let i = arr.length - 1; i >= 0; i--) {
118
+ if (arr[i] > maxValue) {
119
+ maxValue = arr[i];
120
+ maxIndex = i;
121
+ }
122
+ }
123
+
124
+ return maxIndex;
125
+ }
@@ -1,24 +1,24 @@
1
- import { InvoiceControllerState } from '../';
2
-
3
- /**
4
- * 保存正在编辑的货物
5
- */
6
- export default async (state: InvoiceControllerState) => {
7
-
8
- const editGood = state.goodsListState.editGood;
9
- const form = state.goodsListState.form;
10
-
11
- if (!editGood || !form || state.goodsListState.importGoods.isVisibleDrawer || state.calculatingField) return;
12
- if ((await validateFields(form)).err) return;
13
-
14
- state.goodsListState.goodsList = state.goodsListState.goodsList.map((e) =>
15
- e.$index === editGood.$index ? { ...e, ...editGood } : e,
16
- );
17
- state.goodsListState.editGood = undefined;
18
- };
19
-
20
- const validateFields = (form: any) => new Promise((resolve: (v: { err: any; values: any }) => void) => {
21
- form.validateFields(async (err: any, values: any) => {
22
- resolve({ err, values });
23
- });
24
- });
1
+ import { InvoiceControllerState } from '../';
2
+
3
+ /**
4
+ * 保存正在编辑的货物
5
+ */
6
+ export default async (state: InvoiceControllerState) => {
7
+
8
+ const editGood = state.goodsListState.editGood;
9
+ const form = state.goodsListState.form;
10
+
11
+ if (!editGood || !form || state.goodsListState.importGoods.isVisibleDrawer || state.calculatingField) return;
12
+ if ((await validateFields(form)).err) return;
13
+
14
+ state.goodsListState.goodsList = state.goodsListState.goodsList.map((e) =>
15
+ e.$index === editGood.$index ? { ...e, ...editGood } : e,
16
+ );
17
+ state.goodsListState.editGood = undefined;
18
+ };
19
+
20
+ const validateFields = (form: any) => new Promise((resolve: (v: { err: any; values: any }) => void) => {
21
+ form.validateFields(async (err: any, values: any) => {
22
+ resolve({ err, values });
23
+ });
24
+ });
@@ -1,16 +1,16 @@
1
- import { InvoiceControllerState, IGood } from '../';
2
-
3
- /**
4
- * 设置当前的编辑货物
5
- */
6
- export default async (state: InvoiceControllerState, newEditGood?: any) => {
7
- if (newEditGood) {
8
- const editGood = state.goodsListState.editGood as IGood;
9
- state.goodsListState = {
10
- ...state.goodsListState,
11
- editGood: { ...editGood, ...newEditGood },
12
- };
13
- } else {
14
- state.goodsListState = { ...state.goodsListState, editGood: undefined };
15
- }
16
- };
1
+ import { InvoiceControllerState, IGood } from '../';
2
+
3
+ /**
4
+ * 设置当前的编辑货物
5
+ */
6
+ export default async (state: InvoiceControllerState, newEditGood?: any) => {
7
+ if (newEditGood) {
8
+ const editGood = state.goodsListState.editGood as IGood;
9
+ state.goodsListState = {
10
+ ...state.goodsListState,
11
+ editGood: { ...editGood, ...newEditGood },
12
+ };
13
+ } else {
14
+ state.goodsListState = { ...state.goodsListState, editGood: undefined };
15
+ }
16
+ };
@@ -1,11 +1,11 @@
1
-
2
- import { InvoiceControllerState, IGood } from '../';
3
-
4
- /**
5
- * 设置单个货物属性
6
- */
7
- export default async (state: InvoiceControllerState, options?: IGood) => {
8
- if (!options || !options.$index) return;
9
- const goodsList = state.goodsListState.goodsList.map(e => e.$index === options.$index ? { ...e, ...options } : e);
10
- state.goodsListState = { ...state.goodsListState, goodsList };
1
+
2
+ import { InvoiceControllerState, IGood } from '../';
3
+
4
+ /**
5
+ * 设置单个货物属性
6
+ */
7
+ export default async (state: InvoiceControllerState, options?: IGood) => {
8
+ if (!options || !options.$index) return;
9
+ const goodsList = state.goodsListState.goodsList.map(e => e.$index === options.$index ? { ...e, ...options } : e);
10
+ state.goodsListState = { ...state.goodsListState, goodsList };
11
11
  };
@@ -1,9 +1,9 @@
1
-
2
- import InvoiceControllerState from '../InvoiceControllerState';
3
-
4
- /**
5
- * 更新 发票单据编号
6
- */
7
- export default async (state: InvoiceControllerState) => {
8
- return `INV${(Math.random() * 10000000000000).toFixed(0)}`;
1
+
2
+ import InvoiceControllerState from '../InvoiceControllerState';
3
+
4
+ /**
5
+ * 更新 发票单据编号
6
+ */
7
+ export default async (state: InvoiceControllerState) => {
8
+ return `INV${(Math.random() * 10000000000000).toFixed(0)}`;
9
9
  };
@@ -1,65 +1,69 @@
1
- import InvoiceControllerForm from './InvoiceControllerForm';
2
- import InvoiceControllerState from './InvoiceControllerState';
3
- import { IGetBuyerListOption } from './InvoiceControllerState/BuyerState';
4
- import { IGetGoodsListOption } from './InvoiceControllerState/GoodsListState/ImportGoods';
5
- // import updateInvoiceNo from './fns/updateInvoiceNo';
6
- import setEditGood from './fns/setEditGood';
7
- import setGoods from './fns/setGoods';
8
- import delGood from './fns/delGood';
9
- import addGoodDiscount from './fns/addGoodDiscount';
10
- import addGoodDiscountV2 from './fns/addGoodDiscountV2';
11
- import addGood from './fns/addGood';
12
- import saveEditGood from './fns/saveEditGood';
13
- import getGoodsSearch from './fns/getGoodsSearch';
14
-
15
- export { default as InvoiceControllerState } from './InvoiceControllerState';
16
- export { default as IGood } from './InvoiceControllerState/GoodsListState/IGood';
17
- export { default as LineAttributeType } from './InvoiceControllerState/GoodsListState/LineAttributeType';
18
-
19
- export default class InvoiceController extends InvoiceControllerForm {
20
- constructor(state = new InvoiceControllerState()) {
21
- super(state);
22
- }
23
-
24
- // ----------------- 发票头 模块相关 -----------------
25
-
26
- /** 更新发票单据编号 */
27
- updateInvoiceNo?: (option?: undefined) => Promise<any> //= this.pipeline(updateInvoiceNo);
28
-
29
- // ----------------- 购买方 模块相关 -----------------
30
-
31
- /** 获取 购买方 列表 */
32
- getBuyerList?: (option?: IGetBuyerListOption | undefined) => Promise<any>;
33
-
34
- // ----------------- 货物 模块相关 -----------------
35
-
36
- /** 设置单个货物属性 */
37
- setGoods = this.pipeline(setGoods);
38
-
39
- /** 设置当前的编辑货物 */
40
- setEditGood = this.pipeline(setEditGood);
41
-
42
- /** 保存正在编辑的货物 */
43
- saveEditGood = this.pipeline(saveEditGood);
44
-
45
- /** 删除一个货物 */
46
- delGood = this.pipeline(delGood);
47
-
48
- /** 添加一个货物 */
49
- addGood = this.pipeline(addGood);
50
-
51
- /** 给一组货物添加折扣行 */
52
- addGoodDiscount = this.pipeline(addGoodDiscount);
53
-
54
- /** 给一组货物添加折扣行 */
55
- addGoodDiscountV2 = this.pipeline(addGoodDiscountV2);
56
-
57
- /** 获取 商品 列表 */
58
- getGoodsList?: (option?: IGetGoodsListOption | undefined) => Promise<any>;
59
-
60
- /** 税收分类编码列表 */
61
- getTaxCategoryCodeList?: () => Promise<any>;
62
-
63
- /** 获取筛选后的列表 */
64
- getGoodsSearch = getGoodsSearch
65
- }
1
+ import InvoiceControllerForm from './InvoiceControllerForm';
2
+ import InvoiceControllerState from './InvoiceControllerState';
3
+ import { IGetBuyerListOption } from './InvoiceControllerState/BuyerState';
4
+ import { IGetGoodsListOption } from './InvoiceControllerState/GoodsListState/ImportGoods';
5
+ // import updateInvoiceNo from './fns/updateInvoiceNo';
6
+ import setEditGood from './fns/setEditGood';
7
+ import setGoods from './fns/setGoods';
8
+ import delGood from './fns/delGood';
9
+ import addGoodDiscount from './fns/addGoodDiscount';
10
+ import addGoodDiscountV2 from './fns/addGoodDiscountV2';
11
+ import addGood from './fns/addGood';
12
+ import saveEditGood from './fns/saveEditGood';
13
+ import getGoodsSearch from './fns/getGoodsSearch';
14
+ import mergeDetails from './fns/mergeDetails';
15
+
16
+ export { default as InvoiceControllerState } from './InvoiceControllerState';
17
+ export { default as IGood } from './InvoiceControllerState/GoodsListState/IGood';
18
+ export { default as LineAttributeType } from './InvoiceControllerState/GoodsListState/LineAttributeType';
19
+
20
+ export default class InvoiceController extends InvoiceControllerForm {
21
+ constructor(state = new InvoiceControllerState()) {
22
+ super(state);
23
+ }
24
+
25
+ // ----------------- 发票头 模块相关 -----------------
26
+
27
+ /** 更新发票单据编号 */
28
+ updateInvoiceNo?: (option?: undefined) => Promise<any> //= this.pipeline(updateInvoiceNo);
29
+
30
+ // ----------------- 购买方 模块相关 -----------------
31
+
32
+ /** 获取 购买方 列表 */
33
+ getBuyerList?: (option?: IGetBuyerListOption | undefined) => Promise<any>;
34
+
35
+ // ----------------- 货物 模块相关 -----------------
36
+
37
+ /** 设置单个货物属性 */
38
+ setGoods = this.pipeline(setGoods);
39
+
40
+ /** 设置当前的编辑货物 */
41
+ setEditGood = this.pipeline(setEditGood);
42
+
43
+ /** 保存正在编辑的货物 */
44
+ saveEditGood = this.pipeline(saveEditGood);
45
+
46
+ /** 删除一个货物 */
47
+ delGood = this.pipeline(delGood);
48
+
49
+ /** 添加一个货物 */
50
+ addGood = this.pipeline(addGood);
51
+
52
+ /** 全单合并明细 */
53
+ mergeDetails = this.pipeline<any>(mergeDetails);
54
+
55
+ /** 给一组货物添加折扣行 */
56
+ addGoodDiscount = this.pipeline(addGoodDiscount);
57
+
58
+ /** 给一组货物添加折扣行 */
59
+ addGoodDiscountV2 = this.pipeline(addGoodDiscountV2);
60
+
61
+ /** 获取 商品 列表 */
62
+ getGoodsList?: (option?: IGetGoodsListOption | undefined) => Promise<any>;
63
+
64
+ /** 税收分类编码列表 */
65
+ getTaxCategoryCodeList?: () => Promise<any>;
66
+
67
+ /** 获取筛选后的列表 */
68
+ getGoodsSearch = getGoodsSearch
69
+ }
@@ -1,42 +1,42 @@
1
-
2
- import React from 'react';
3
- import { Invoice } from '../../../..';
4
-
5
- export default () => {
6
-
7
- const controller = React.useMemo(() => new MyController(), [])
8
-
9
- return (
10
- <Invoice controller={controller} />
11
- );
12
- };
13
-
14
- class MyController extends Invoice.InvoiceController {
15
- constructor() {
16
- super()
17
- this.state.buyerState.autoContainer = {
18
- onBuyNameChange: async (e?: string) => {
19
- await this.wait(2000);
20
- return {
21
- recent: [
22
- { buyerName: '中科讯联科技北京网络有限公司中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
23
- { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
24
- { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
25
- { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
26
- ],
27
- list: [
28
- { buyerName: '中科讯联科技北京网络有限公司中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
29
- { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
30
- { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
31
- { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
32
- { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
33
- { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
34
- { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
35
- { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
36
- { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
37
- ],
38
- }
39
- }
40
- }
41
- }
1
+
2
+ import React from 'react';
3
+ import { Invoice } from '../../../..';
4
+
5
+ export default () => {
6
+
7
+ const controller = React.useMemo(() => new MyController(), [])
8
+
9
+ return (
10
+ <Invoice controller={controller} />
11
+ );
12
+ };
13
+
14
+ class MyController extends Invoice.InvoiceController {
15
+ constructor() {
16
+ super()
17
+ this.state.buyerState.autoContainer = {
18
+ onBuyNameChange: async (e?: string) => {
19
+ await this.wait(2000);
20
+ return {
21
+ recent: [
22
+ { buyerName: '中科讯联科技北京网络有限公司中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
23
+ { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
24
+ { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
25
+ { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
26
+ ],
27
+ list: [
28
+ { buyerName: '中科讯联科技北京网络有限公司中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
29
+ { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
30
+ { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
31
+ { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
32
+ { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
33
+ { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
34
+ { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
35
+ { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
36
+ { buyerName: '中科讯联科技北京网络有限公司', buyerNo: '918273829182918291' },
37
+ ],
38
+ }
39
+ }
40
+ }
41
+ }
42
42
  }