kts-component-invoice-operate 3.1.19 → 3.2.0

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 (315) 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/Invoice-digtal/_test/disabled/index.d.ts +4 -0
  9. package/dist/Invoice/Invoice-digtal/_test/easiest/index.d.ts +4 -0
  10. package/dist/Invoice/Invoice-digtal/_test/header/index.d.ts +4 -0
  11. package/dist/Invoice/Invoice-digtal/_test/readOnly/index.d.ts +4 -0
  12. package/dist/Invoice/Invoice-digtal/_test/stakeholder/index.d.ts +4 -0
  13. package/dist/Invoice/Invoice-digtal/_test/typeSelection/index.d.ts +4 -0
  14. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +4 -0
  15. package/dist/Invoice/InvoiceController/InvoiceControllerState/Stakeholder/index.d.ts +10 -0
  16. package/dist/Invoice/InvoiceController/InvoiceControllerState/index.d.ts +6 -0
  17. package/dist/Invoice/InvoiceController/fns/addGoodDiscount.d.ts +1 -1
  18. package/dist/Invoice/InvoiceController/fns/addGoodDiscountV2.d.ts +12 -0
  19. package/dist/Invoice/InvoiceController/fns/delGood.d.ts +1 -1
  20. package/dist/Invoice/InvoiceController/index.d.ts +2 -0
  21. package/dist/Invoice/index.d.ts +25 -12
  22. package/dist/Invoice/tools/mounting/index.d.ts +3 -0
  23. package/dist/Invoice/{ui/GoodsList/hook → tools}/useToGenerateId/index.d.ts +1 -1
  24. package/dist/Invoice/ui/{Buyer → default/Buyer}/index.d.ts +1 -1
  25. package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/autoFillFn/index.d.ts +2 -2
  26. package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.d.ts +0 -1
  27. package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.d.ts +1 -1
  28. package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowMenu/hook/useDelItem/index.d.ts +1 -1
  29. package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.d.ts +1 -1
  30. package/dist/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.d.ts +7 -0
  31. package/dist/Invoice/ui/default/GoodsList/hook/useDeduction/index.d.ts +8 -0
  32. package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useOnRow/index.d.ts +1 -1
  33. package/dist/Invoice/ui/default/GoodsList/hook/useWindowClick/index.d.ts +8 -0
  34. package/dist/Invoice/ui/{Seller → default/Seller}/index.d.ts +1 -1
  35. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.d.ts +35 -0
  36. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/index.d.ts +3 -0
  37. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.d.ts +7 -0
  38. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowEditButton/index.d.ts +6 -0
  39. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.d.ts +4 -0
  40. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.d.ts +7 -0
  41. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.d.ts +7 -0
  42. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.d.ts +7 -0
  43. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.d.ts +7 -0
  44. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowSaveButton/index.d.ts +6 -0
  45. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/TitleText/index.d.ts +8 -0
  46. package/dist/Invoice/ui/digtal/GoodsList/hook/useOnRow/index.d.ts +8 -0
  47. package/dist/Invoice/ui/digtal/GoodsList/hook/useRowSelection/index.d.ts +8 -0
  48. package/dist/Invoice/ui/digtal/GoodsList/hook/useWindowClick/index.d.ts +8 -0
  49. package/dist/Invoice/ui/digtal/GoodsList/index.d.ts +17 -0
  50. package/dist/Invoice/ui/digtal/GoodsList/ui/AddRowButton/index.d.ts +3 -0
  51. package/dist/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.d.ts +5 -0
  52. package/dist/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.d.ts +5 -0
  53. package/dist/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.d.ts +6 -0
  54. package/dist/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEmptyRefill/index.d.ts +6 -0
  55. package/dist/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.d.ts +6 -0
  56. package/dist/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useReselectInvoiceType/index.d.ts +5 -0
  57. package/dist/Invoice/ui/digtal/GoodsList/ui/DescribeSwitch/index.d.ts +3 -0
  58. package/dist/Invoice/ui/digtal/GoodsList/ui/Search/index.d.ts +3 -0
  59. package/dist/Invoice/ui/digtal/GoodsList/ui/Statistics/index.d.ts +4 -0
  60. package/dist/Invoice/ui/digtal/GoodsList/ui/TableRow/index.d.ts +2 -0
  61. package/dist/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.d.ts +4 -0
  62. package/dist/Invoice/ui/digtal/GoodsList/ui/TableVirtual.o/index.d.ts +4 -0
  63. package/dist/Invoice/ui/digtal/GoodsList/ui/TaxIncludedSwitch/index.d.ts +3 -0
  64. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/autoFillFn/index.d.ts +35 -0
  65. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/index.d.ts +3 -0
  66. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/ItemNameInput/index.d.ts +7 -0
  67. package/dist/Invoice/ui/{GoodsList/hook/useColumns/ui/RowMenu → digtal/GoodsList.o/hook/useColumns/ui/RowEditButton}/index.d.ts +0 -1
  68. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.d.ts +4 -0
  69. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.d.ts +7 -0
  70. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useDelItem/index.d.ts +7 -0
  71. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.d.ts +7 -0
  72. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/index.d.ts +7 -0
  73. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowSaveButton/index.d.ts +6 -0
  74. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/TitleText/index.d.ts +8 -0
  75. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useOnRow/index.d.ts +8 -0
  76. package/dist/Invoice/ui/digtal/GoodsList.o/hook/useRowSelection/index.d.ts +8 -0
  77. package/dist/Invoice/ui/digtal/GoodsList.o/index.d.ts +20 -0
  78. package/dist/Invoice/ui/digtal/GoodsList.o/ui/AddRowButton/index.d.ts +3 -0
  79. package/dist/Invoice/ui/digtal/GoodsList.o/ui/TableRow/index.d.ts +2 -0
  80. package/dist/Invoice/ui/digtal/GoodsList.o/ui/TableVirtual/index.d.ts +4 -0
  81. package/dist/Invoice/ui/digtal/InvoiceHeader/index.d.ts +14 -0
  82. package/dist/Invoice/ui/digtal/Sign/index.d.ts +10 -0
  83. package/dist/Invoice/ui/digtal/Stakeholder/index.d.ts +7 -0
  84. package/dist/InvoiceTypeModal/_test/easiest/index.d.ts +3 -0
  85. package/dist/InvoiceTypeModal/index.d.ts +34 -0
  86. package/dist/index.d.ts +2 -0
  87. package/dist/index.esm.js +10107 -2821
  88. package/dist/index.js +10101 -2814
  89. package/docs/index.md +5 -5
  90. package/docs-dist/404.html +33 -33
  91. package/docs-dist/index.html +33 -33
  92. package/docs-dist/umi.css +19 -19
  93. package/index.html +12 -12
  94. package/package.json +60 -60
  95. package/src/Invoice/Invoice-digtal/_test/disabled/index.tsx +38 -0
  96. package/src/Invoice/Invoice-digtal/_test/easiest/index.tsx +5 -0
  97. package/src/Invoice/Invoice-digtal/_test/header/index.tsx +17 -0
  98. package/src/Invoice/Invoice-digtal/_test/readOnly/index.tsx +42 -0
  99. package/src/Invoice/Invoice-digtal/_test/stakeholder/index.tsx +12 -0
  100. package/src/Invoice/Invoice-digtal/_test/typeSelection/index.tsx +29 -0
  101. package/src/Invoice/Invoice-digtal/index.md +19 -0
  102. package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +94 -94
  103. package/src/Invoice/InvoiceController/InvoiceControllerState/BuyerState/index.tsx +88 -88
  104. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/EndowCode/index.tsx +93 -93
  105. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IColumnsReplenish/index.ts +10 -10
  106. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +75 -75
  107. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ImportGoods/index.ts +80 -80
  108. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.ts +5 -5
  109. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.ts +9 -9
  110. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +94 -88
  111. package/src/Invoice/InvoiceController/InvoiceControllerState/Stakeholder/index.ts +11 -0
  112. package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +56 -48
  113. package/src/Invoice/InvoiceController/fns/addGood.ts +11 -11
  114. package/src/Invoice/InvoiceController/fns/addGoodDiscount.ts +125 -125
  115. package/src/Invoice/InvoiceController/fns/addGoodDiscountV2.ts +84 -0
  116. package/src/Invoice/InvoiceController/fns/delGood.ts +41 -43
  117. package/src/Invoice/InvoiceController/fns/getGoodsSearch.ts +23 -23
  118. package/src/Invoice/InvoiceController/fns/saveEditGood.ts +24 -23
  119. package/src/Invoice/InvoiceController/fns/setEditGood.ts +16 -16
  120. package/src/Invoice/InvoiceController/fns/setGoods.ts +10 -10
  121. package/src/Invoice/InvoiceController/fns/updateInvoiceNo.ts +8 -8
  122. package/src/Invoice/InvoiceController/index.ts +65 -61
  123. package/src/Invoice/_test/buyerNameSearch/index.tsx +41 -41
  124. package/src/Invoice/_test/deduction/index.tsx +935 -935
  125. package/src/Invoice/_test/draft/index.tsx +40 -40
  126. package/src/Invoice/_test/easiest/index.tsx +5 -5
  127. package/src/Invoice/_test/endowCode/index.tsx +1095 -1095
  128. package/src/Invoice/_test/goodsMenuExpand/index.tsx +32 -32
  129. package/src/Invoice/_test/importBuyer/index.tsx +74 -74
  130. package/src/Invoice/_test/importGoods/index.tsx +515 -515
  131. package/src/Invoice/_test/invoiceType/index.tsx +59 -59
  132. package/src/Invoice/_test/isInvoiceNo/index.tsx +12 -12
  133. package/src/Invoice/_test/replaceHead/index.tsx +22 -22
  134. package/src/Invoice/_test/retrieveData/index.tsx +22 -22
  135. package/src/Invoice/_test/seller/index.tsx +28 -28
  136. package/src/Invoice/_test/setDataSource/index.tsx +22 -22
  137. package/src/Invoice/_test/unit/index.tsx +19 -19
  138. package/src/Invoice/index.less +30 -12
  139. package/src/Invoice/index.md +53 -53
  140. package/src/Invoice/index.tsx +164 -109
  141. package/src/Invoice/tools/calculate/index.ts +112 -112
  142. package/src/Invoice/tools/coolingFn/index.ts +17 -17
  143. package/src/Invoice/tools/evaluate/index.ts +7 -7
  144. package/src/Invoice/tools/idGenerator/index.ts +2 -2
  145. package/src/Invoice/tools/itemName/index.ts +55 -55
  146. package/src/Invoice/tools/lazyFn/index.ts +19 -19
  147. package/src/Invoice/tools/mounting/index.ts +14 -0
  148. package/src/Invoice/tools/strringFn/index.ts +40 -40
  149. package/src/Invoice/{ui/GoodsList/hook → tools}/useToGenerateId/index.ts +8 -8
  150. package/src/Invoice/ui/{AddComparisonDrawer → default/AddComparisonDrawer}/index.tsx +149 -149
  151. package/src/Invoice/ui/{Buyer → default/Buyer}/index.less +219 -219
  152. package/src/Invoice/ui/{Buyer → default/Buyer}/index.tsx +114 -114
  153. package/src/Invoice/ui/{Buyer → default/Buyer}/ui/BuyerNameInput/index.tsx +166 -166
  154. package/src/Invoice/ui/{Buyer → default/Buyer}/ui/ImportBuyerButton/index.tsx +21 -21
  155. package/src/Invoice/ui/{EndowCodeDrawer → default/EndowCodeDrawer}/index.less +8 -8
  156. package/src/Invoice/ui/{EndowCodeDrawer → default/EndowCodeDrawer}/index.tsx +431 -431
  157. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/autoFillFn/index.ts +519 -519
  158. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/index.tsx +620 -620
  159. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/ItemNameInput/index.less +9 -9
  160. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/ItemNameInput/index.tsx +19 -19
  161. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowEditButton/index.tsx +30 -30
  162. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -43
  163. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -76
  164. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -35
  165. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -34
  166. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowMenu/index.less +13 -13
  167. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowMenu/index.tsx +98 -98
  168. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowSaveButton/index.tsx +14 -14
  169. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/TitleText/index.tsx +20 -20
  170. package/src/Invoice/ui/default/GoodsList/hook/useDeduction/index.tsx +24 -0
  171. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useOnRow/index.tsx +39 -39
  172. package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useRowSelection/index.tsx +111 -111
  173. package/src/Invoice/ui/default/GoodsList/hook/useWindowClick/index.tsx +23 -0
  174. package/src/Invoice/ui/{GoodsList → default/GoodsList}/index.less +177 -177
  175. package/src/Invoice/ui/{GoodsList → default/GoodsList}/index.tsx +177 -177
  176. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/AddRowButton/index.tsx +65 -61
  177. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/BulkMenu/hooks/useAddDiscountRowButton/index.less +21 -21
  178. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +244 -244
  179. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -75
  180. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/BulkMenu/hooks/useDelRowButton/index.tsx +69 -66
  181. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +58 -58
  182. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/BulkMenu/index.tsx +37 -37
  183. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/DescribeSwitch/index.tsx +36 -36
  184. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/Search/index.less +10 -10
  185. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/Search/index.tsx +50 -50
  186. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/Statistics/index.less +18 -18
  187. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/Statistics/index.tsx +109 -109
  188. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/TableRow/index.tsx +27 -27
  189. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/TableVirtual/index.less +38 -38
  190. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/TableVirtual/index.tsx +108 -108
  191. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/TableVirtual.o/index.less +44 -44
  192. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/TableVirtual.o/index.tsx +96 -96
  193. package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/TaxIncludedSwitch/index.tsx +30 -30
  194. package/src/Invoice/ui/{ImportBuyerDrawer → default/ImportBuyerDrawer}/index.tsx +75 -75
  195. package/src/Invoice/ui/{ImportGoodsDrawer → default/ImportGoodsDrawer}/index.tsx +170 -170
  196. package/src/Invoice/ui/{InvoiceHeader → default/InvoiceHeader}/index.less +68 -68
  197. package/src/Invoice/ui/{InvoiceHeader → default/InvoiceHeader}/index.tsx +246 -246
  198. package/src/Invoice/ui/{Seller → default/Seller}/index.less +113 -113
  199. package/src/Invoice/ui/{Seller → default/Seller}/index.tsx +98 -98
  200. package/src/Invoice/ui/{Sign → default/Sign}/index.less +14 -14
  201. package/src/Invoice/ui/{Sign → default/Sign}/index.tsx +71 -71
  202. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/autoFillFn/index.ts +520 -0
  203. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/index.tsx +623 -0
  204. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.less +10 -0
  205. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +19 -0
  206. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowEditButton/index.tsx +30 -0
  207. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -0
  208. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -0
  209. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -0
  210. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -0
  211. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.less +13 -0
  212. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +98 -0
  213. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowMenu/spot.svg +1 -0
  214. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/RowSaveButton/index.tsx +14 -0
  215. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/TitleText/index.tsx +20 -0
  216. package/src/Invoice/ui/digtal/GoodsList/hook/useOnRow/index.tsx +39 -0
  217. package/src/Invoice/ui/digtal/GoodsList/hook/useRowSelection/index.tsx +112 -0
  218. package/src/Invoice/ui/digtal/GoodsList/hook/useWindowClick/index.tsx +23 -0
  219. package/src/Invoice/ui/digtal/GoodsList/index.less +57 -0
  220. package/src/Invoice/ui/digtal/GoodsList/index.tsx +181 -0
  221. package/src/Invoice/ui/digtal/GoodsList/ui/AddRowButton/index.tsx +66 -0
  222. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +321 -0
  223. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/svg/add.svg +12 -0
  224. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -0
  225. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +50 -0
  226. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEmptyRefill/index.tsx +35 -0
  227. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +82 -0
  228. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useReselectInvoiceType/index.tsx +56 -0
  229. package/src/Invoice/ui/digtal/GoodsList/ui/DescribeSwitch/index.tsx +37 -0
  230. package/src/Invoice/ui/digtal/GoodsList/ui/Search/icon/magnifier.svg +1 -0
  231. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.less +12 -0
  232. package/src/Invoice/ui/digtal/GoodsList/ui/Search/index.tsx +50 -0
  233. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.less +54 -0
  234. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/index.tsx +99 -0
  235. package/src/Invoice/ui/digtal/GoodsList/ui/Statistics/svg/fork.svg +12 -0
  236. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.tsx +28 -0
  237. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.less +39 -0
  238. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual/index.tsx +109 -0
  239. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual.o/index.less +44 -0
  240. package/src/Invoice/ui/digtal/GoodsList/ui/TableVirtual.o/index.tsx +96 -0
  241. package/src/Invoice/ui/digtal/GoodsList/ui/TaxIncludedSwitch/index.tsx +31 -0
  242. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/autoFillFn/index.ts +520 -0
  243. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/index.tsx +624 -0
  244. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/ItemNameInput/index.less +10 -0
  245. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/ItemNameInput/index.tsx +19 -0
  246. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowEditButton/index.tsx +30 -0
  247. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +43 -0
  248. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +76 -0
  249. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +41 -0
  250. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +34 -0
  251. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/index.less +13 -0
  252. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/index.tsx +98 -0
  253. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/spot.svg +1 -0
  254. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowSaveButton/index.tsx +14 -0
  255. package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/TitleText/index.tsx +20 -0
  256. package/src/Invoice/ui/{GoodsList → digtal/GoodsList.o}/hook/useDeduction/index.tsx +24 -24
  257. package/src/Invoice/ui/digtal/GoodsList.o/hook/useOnRow/index.tsx +39 -0
  258. package/src/Invoice/ui/digtal/GoodsList.o/hook/useRowSelection/index.tsx +112 -0
  259. package/src/Invoice/ui/{GoodsList → digtal/GoodsList.o}/hook/useWindowClick/index.tsx +23 -23
  260. package/src/Invoice/ui/digtal/GoodsList.o/index.less +7 -0
  261. package/src/Invoice/ui/digtal/GoodsList.o/index.tsx +132 -0
  262. package/src/Invoice/ui/digtal/GoodsList.o/ui/AddRowButton/index.tsx +66 -0
  263. package/src/Invoice/ui/digtal/GoodsList.o/ui/TableRow/index.tsx +28 -0
  264. package/src/Invoice/ui/digtal/GoodsList.o/ui/TableVirtual/index.less +43 -0
  265. package/src/Invoice/ui/digtal/GoodsList.o/ui/TableVirtual/index.tsx +109 -0
  266. package/src/Invoice/ui/digtal/InvoiceHeader/index.less +58 -0
  267. package/src/Invoice/ui/digtal/InvoiceHeader/index.tsx +77 -0
  268. package/src/Invoice/ui/digtal/Sign/index.less +49 -0
  269. package/src/Invoice/ui/digtal/Sign/index.tsx +90 -0
  270. package/src/Invoice/ui/digtal/Stakeholder/index.less +57 -0
  271. package/src/Invoice/ui/digtal/Stakeholder/index.tsx +237 -0
  272. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowDown.svg +3 -0
  273. package/src/Invoice/ui/digtal/Stakeholder/svg/arrowUp.svg +3 -0
  274. package/src/InvoiceTypeModal/_test/easiest/index.tsx +32 -0
  275. package/src/InvoiceTypeModal/index.less +8 -0
  276. package/src/InvoiceTypeModal/index.md +6 -0
  277. package/src/InvoiceTypeModal/index.tsx +123 -0
  278. package/src/index.ts +9 -6
  279. package/tsconfig.json +31 -31
  280. package/typings.d.ts +3 -3
  281. package/yarn.e.lock +14331 -14331
  282. package/yarn.o.lock +14800 -14800
  283. /package/dist/Invoice/ui/{AddComparisonDrawer → default/AddComparisonDrawer}/index.d.ts +0 -0
  284. /package/dist/Invoice/ui/{Buyer → default/Buyer}/ui/BuyerNameInput/index.d.ts +0 -0
  285. /package/dist/Invoice/ui/{Buyer → default/Buyer}/ui/ImportBuyerButton/index.d.ts +0 -0
  286. /package/dist/Invoice/ui/{EndowCodeDrawer → default/EndowCodeDrawer}/index.d.ts +0 -0
  287. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/index.d.ts +0 -0
  288. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/ItemNameInput/index.d.ts +0 -0
  289. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowEditButton/index.d.ts +0 -0
  290. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowSaveButton/index.d.ts +0 -0
  291. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/TitleText/index.d.ts +0 -0
  292. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/hook/useRowSelection/index.d.ts +0 -0
  293. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/index.d.ts +0 -0
  294. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/AddRowButton/index.d.ts +0 -0
  295. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/BulkMenu/hooks/useAddDiscountRowButton/index.d.ts +0 -0
  296. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/BulkMenu/hooks/useCommodityComparisonButton/index.d.ts +0 -0
  297. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/BulkMenu/hooks/useDelRowButton/index.d.ts +0 -0
  298. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/BulkMenu/hooks/useEndowCodeButton/index.d.ts +0 -0
  299. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/BulkMenu/index.d.ts +0 -0
  300. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/DescribeSwitch/index.d.ts +0 -0
  301. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/Search/index.d.ts +0 -0
  302. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/Statistics/index.d.ts +0 -0
  303. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/TableRow/index.d.ts +0 -0
  304. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/TableVirtual/index.d.ts +0 -0
  305. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/TableVirtual.o/index.d.ts +0 -0
  306. /package/dist/Invoice/ui/{GoodsList → default/GoodsList}/ui/TaxIncludedSwitch/index.d.ts +0 -0
  307. /package/dist/Invoice/ui/{ImportBuyerDrawer → default/ImportBuyerDrawer}/index.d.ts +0 -0
  308. /package/dist/Invoice/ui/{ImportGoodsDrawer → default/ImportGoodsDrawer}/index.d.ts +0 -0
  309. /package/dist/Invoice/ui/{InvoiceHeader → default/InvoiceHeader}/index.d.ts +0 -0
  310. /package/dist/Invoice/ui/{Sign → default/Sign}/index.d.ts +0 -0
  311. /package/dist/Invoice/ui/{GoodsList → digtal/GoodsList.o}/hook/useDeduction/index.d.ts +0 -0
  312. /package/dist/Invoice/ui/{GoodsList → digtal/GoodsList.o}/hook/useWindowClick/index.d.ts +0 -0
  313. /package/src/Invoice/ui/{GoodsList → default/GoodsList}/hook/useColumns/ui/RowMenu/spot.svg +0 -0
  314. /package/src/Invoice/ui/{GoodsList → default/GoodsList}/ui/Search/icon/magnifier.svg +0 -0
  315. /package/src/Invoice/ui/{InvoiceHeader → default/InvoiceHeader}/auto.svg +0 -0
@@ -0,0 +1,181 @@
1
+
2
+ import React from 'react';
3
+ import { Button } from 'kts-xui';
4
+ import classnames from 'classnames';
5
+ import { decorator } from 'grey-react-box';
6
+ import { Form } from 'kts-components-antd-x3';
7
+ import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
8
+ import { FormComponentProps } from 'kts-components-antd-x3/lib/form';
9
+ import Invoice from '../../..';
10
+
11
+ import TableVirtual from './ui/TableVirtual';
12
+ import Statistics from './ui/Statistics';
13
+ import AddRowButton from './ui/AddRowButton';
14
+ import TaxIncludedSwitch from './ui/TaxIncludedSwitch';
15
+ import Search from './ui/Search';
16
+ import TableRow from './ui/TableRow';
17
+
18
+ import useColumns from './hook/useColumns';
19
+ import useOnRow from './hook/useOnRow';
20
+ import useWindowClick from './hook/useWindowClick';
21
+ import useRowSelection from './hook/useRowSelection';
22
+
23
+ import useDelRowButton from './ui/BulkMenu/hooks/useDelRowButton';
24
+ import useAddDiscountRowButton from './ui/BulkMenu/hooks/useAddDiscountRowButton';
25
+ import useEndowCodeButton from './ui/BulkMenu/hooks/useEndowCodeButton';
26
+ import useEmptyRefill from './ui/BulkMenu/hooks/useEmptyRefill';
27
+ import useReselectInvoiceType from './ui/BulkMenu/hooks/useReselectInvoiceType';
28
+
29
+ import './index.less';
30
+
31
+ export interface IGoodsListProps {
32
+ /** 扩展部分 */
33
+ menuExpansion?: React.ReactNode;
34
+
35
+ /** 产品最大数 */
36
+ goodMax?: number;
37
+
38
+ /** 扣除额 */
39
+ deduction?: number;
40
+
41
+ /** 是否能添加折扣行 */
42
+ isAddDiscount?: boolean;
43
+
44
+ /** 是否可以切换(含税/不含税)状态 */
45
+ isSwitchTax?: boolean;
46
+ }
47
+
48
+ export default class GoodsList extends React.Component<IGoodsListProps>{
49
+ render() {
50
+ return <Main {...this.props} />
51
+ }
52
+ }
53
+
54
+ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Form.create())((props) => {
55
+
56
+ /** 控制器 */
57
+ const controller = Invoice.useInvoiceController();
58
+
59
+ const goodsList = controller.useMemo(s => s.goodsListState.goodsList, []);
60
+
61
+ /** 货物列表 */
62
+ const dataSource = controller.useMemo(s => s.goodsListState.goodsList, [])
63
+
64
+ /** 搜索条件 */
65
+ const searchValue = controller.useMemo(s => s.goodsListState.searchValue, [])
66
+
67
+ /** 计算搜索商品 */
68
+ const isTaxIncluded = controller.useMemo(s => s.goodsListState.isTaxIncluded, [])
69
+
70
+ /** 计算搜索商品 */
71
+ const dataSourceSearch = React.useMemo(() => controller.getGoodsSearch(dataSource, searchValue, isTaxIncluded), [dataSource, searchValue, controller, isTaxIncluded])
72
+
73
+ /** 表格行事件 */
74
+ const onRow = useOnRow();
75
+
76
+ /** 批量删除 */
77
+ const delRowButton = useDelRowButton();
78
+
79
+ /** 添加折扣行 */
80
+ const addDiscountRowButton = useAddDiscountRowButton();
81
+
82
+ /** 赋码 */
83
+ const endowCodeButton = useEndowCodeButton();
84
+
85
+ /** 重选发票类型 */
86
+ const reselectInvoiceType = useReselectInvoiceType()
87
+
88
+ /** 清空重填 */
89
+ const emptyRefill = useEmptyRefill();
90
+
91
+ useWindowClick(controller); // 点击组件外部 保存正在编辑的货物
92
+
93
+ /** 清空自动赋码缓存 */
94
+ React.useEffect(() => {
95
+ controller.run(async s => { s.goodsListState.endowCode.cache = {} });
96
+ }, [controller])
97
+
98
+ /** 注册 from 对象 */
99
+ React.useEffect(() => {
100
+ controller.pipeline<WrappedFormUtils>(async (s, form) => { s.goodsListState = { ...s.goodsListState, form } })(props.form);
101
+ }, [controller, props.form]);
102
+
103
+ // 跟新 货物
104
+ React.useEffect(() => {
105
+ controller.run(async (s) => {
106
+ s.goodsListState.goodsMap = new Map();
107
+ goodsList.forEach((e) => { s.goodsListState.goodsMap.set(e.$index, e); });
108
+ });
109
+ }, [controller, goodsList]);
110
+
111
+ /** props 产品最大数 更新 */
112
+ React.useEffect(() => {
113
+ controller.pipeline(async s => { s.goodsListState.goodMax = props.goodMax })()
114
+ }, [controller, props.goodMax])
115
+
116
+ /** props 是否能添加折扣行 更新 */
117
+ React.useEffect(() => {
118
+ controller.pipeline(async s => { s.goodsListState.isAddDiscount = props.isAddDiscount })()
119
+ }, [controller, props.goodMax])
120
+
121
+ /** props 是否可以切换(含税/不含税)状态 更新 */
122
+ React.useEffect(() => {
123
+ controller.pipeline(async s => { s.goodsListState.isSwitchTax = props.isSwitchTax })()
124
+ }, [controller, props.isSwitchTax])
125
+
126
+ return (
127
+ <div className="kts-invoice-operate-goods-list-digtal" onClick={(e) => { e.stopPropagation() }} >
128
+ <div className="kts-invoice-operate-goods-list-able">
129
+ {/* 添加行 */}
130
+ <AddRowButton />
131
+
132
+ {/* 批量删除 */}
133
+ {delRowButton.button}
134
+
135
+ {/* 加载折扣 */}
136
+ {addDiscountRowButton.button}
137
+
138
+ {/* 赋码 */}
139
+ {endowCodeButton.button}
140
+
141
+ {/* 是否含税开关 */}
142
+ <TaxIncludedSwitch />
143
+
144
+ {/* 搜索 */}
145
+ <Search />
146
+
147
+ <div style={{ flex: 1 }} />
148
+
149
+ {/* 扩展部分 */}
150
+ {props.menuExpansion}
151
+
152
+ {/* 重选发票类型 */}
153
+ {reselectInvoiceType.button}
154
+
155
+ {/* 清空重填 */}
156
+ {emptyRefill.button}
157
+ </div>
158
+ <div className={classnames('kts-invoice-operate-goods-list-table-digtal')}>
159
+ <TableVirtual
160
+ size="small"
161
+ rowKey="$index"
162
+ pagination={false}
163
+ scroll={{ y: 280 }}
164
+ components={{ body: { row: TableRow } }}
165
+ dataSource={dataSourceSearch}
166
+ columns={useColumns(props.form)}
167
+ rowSelection={useRowSelection()}
168
+ onRow={record => ({
169
+ onClick: () => {
170
+ onRow.onClick(record);
171
+ },
172
+ })}
173
+ />
174
+ </div>
175
+ <div>
176
+ {/* 汇总 */}
177
+ <Statistics />
178
+ </div>
179
+ </div>
180
+ );
181
+ });
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import Invoice from '../../../../..';
3
+ import { Button, message } from 'kts-xui';
4
+ import InvoiceController, { LineAttributeType } from '../../../../../InvoiceController';
5
+
6
+ export default () => {
7
+ const controller = Invoice.useInvoiceController();
8
+
9
+ const model = controller.useMemo(s => s.model, []);
10
+
11
+ const rootElement = controller.useMemo(s => s.rootElement, []);
12
+
13
+ /** 产品数据量 */
14
+ const goodsNum = controller.useMemo(s => s.goodsListState.goodsList.length, []);
15
+
16
+ /** 搜索条件 */
17
+ const searchValue = controller.useMemo(s => s.goodsListState.searchValue, []);
18
+
19
+ /** 搜索条件 */
20
+ const isAddRow = controller.useMemo(s => s.goodsListState.isAddRow, []);
21
+
22
+ /** 产品最大数 */
23
+ const goodMax = controller.useMemo(s => s.goodsListState.goodMax, []);
24
+
25
+ /** 按钮是否禁用 */
26
+ const disabled = React.useMemo(() => typeof goodMax === 'number' ? goodsNum >= goodMax : !!searchValue, [goodMax, goodsNum, searchValue])
27
+
28
+ const onClick = React.useCallback(async () => {
29
+ await addGood(controller);
30
+ await rollBottom(controller, rootElement);
31
+ }, [controller, rootElement]);
32
+
33
+ if (isAddRow === false) return <></>;
34
+ if (model === 'prefab') return <></>;
35
+ if (model === 'readOnly') return <></>;
36
+
37
+ return (
38
+ <Button size='small' type='primary' onClick={onClick} disabled={disabled}>
39
+ 增行
40
+ </Button>
41
+ );
42
+ };
43
+
44
+ /** 添加一个空货物 */
45
+ async function addGood(controller: InvoiceController) {
46
+ await controller.saveEditGood();
47
+ await controller.wait();
48
+ await controller.run(async (s) => {
49
+ if (s.goodsListState.editGood) {
50
+ message.error({
51
+ content: '你正在编辑一个货物',
52
+ key: '你正在编辑一个货物',
53
+ });
54
+ return;
55
+ }
56
+ s.goodsListState.editGood = await controller.addGood({ taxRate: s.goodsListState.defaultRate, lineAttribute: LineAttributeType.正常 });
57
+ });
58
+ }
59
+
60
+ /** 货物列表,滚动到底部 */
61
+ async function rollBottom(controller: InvoiceController, rootElement: HTMLDivElement | null | undefined) {
62
+ await controller.wait();
63
+ const cont = rootElement?.querySelector('.ktsAntX-table-body');
64
+ if (!cont) return;
65
+ cont.scrollTop = cont.scrollHeight;
66
+ }
@@ -0,0 +1,321 @@
1
+
2
+ import React from "react";
3
+ import { chain, bignumber } from 'mathjs';
4
+ import Icon from '@ant-design/icons';
5
+ import { Button, Drawer, Form, InputNumber, Radio, message, Space } from "kts-xui";
6
+ import { ReactComponent as AddSvg } from './svg/add.svg';
7
+ import Invoice from "../../../../../../..";
8
+ import { LineAttributeType } from "../../../../../../../InvoiceController";
9
+
10
+ export default () => {
11
+
12
+ /** 控制器 */
13
+ const controller = Invoice.useInvoiceController();
14
+
15
+ /** 组件模式 prefab 预制 readOnly 只读 */
16
+ const model = controller.useMemo(s => s.model, []);
17
+
18
+ /** 准备添加折扣的货物索引列表 */
19
+ const discountGoodIndex = controller.useMemo(s => s.goodsListState.discountGoodIndex || [], []);
20
+
21
+ /** 列表选中的货物索引列表 */
22
+ const selectedGoodIndex = controller.useMemo(s => s.goodsListState.selectedGoodIndex, []);
23
+
24
+ /** 货物字典 */
25
+ const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, []);
26
+
27
+ /** 是否能添加折扣行 */
28
+ const isAddDiscount = controller.useMemo(s => s.goodsListState.isAddDiscount, []);
29
+
30
+ // 抽屉开启状态
31
+ const open = React.useMemo(() => discountGoodIndex.length > 0, [discountGoodIndex]);
32
+
33
+ /** 打开抽屉 */
34
+ const onOpen = React.useCallback(async () => {
35
+ await controller.saveEditGood();
36
+ await controller.wait();
37
+ await controller.run(async s => {
38
+
39
+ let isOk = s.goodsListState.editGood && s.goodsListState.selectedGoodIndex.indexOf(s.goodsListState.editGood.$index) >= 0;
40
+ if (isOk) {
41
+ message.error({ content: '不能给编辑状态的行增加折扣!', key: '不能给编辑状态的行增加折扣!' });
42
+ return;
43
+ }
44
+
45
+ if (!isContinuityNum(s.goodsListState.selectedGoodIndex.map(e => s.goodsListState.goodsMap.get(e)?.serialNo || -2).sort((a, b) => a - b))) {
46
+ message.error({ content: '项目不连续,不允许添加折扣', key: '项目不连续,不允许添加折扣' });
47
+ return;
48
+ }
49
+
50
+ isOk = s.goodsListState.selectedGoodIndex.some($index => s.goodsListState.goodsMap.get($index)?.lineAttribute !== LineAttributeType.正常)
51
+ if (isOk) {
52
+ message.error({ content: '不允许重复添加折扣', key: '不允许重复添加折扣' });
53
+ return;
54
+ }
55
+
56
+ isOk = s.goodsListState.selectedGoodIndex.some($index => {
57
+ const good = s.goodsListState.goodsMap.get($index);
58
+ return !good || (good.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !good.taxFreeType)
59
+ })
60
+ if (isOk) {
61
+ message.error({ content: '零税率需要设置免税类型,请在赋码中设置!', key: '零税率需要设置免税类型,请在赋码中设置!' });
62
+ return;
63
+ }
64
+
65
+ isOk = s.goodsListState.selectedGoodIndex.some($index => {
66
+ const good = s.goodsListState.goodsMap.get($index);
67
+ return `${good?.lineAmountIncludeTax}` === '0'
68
+ })
69
+ if (isOk) {
70
+ message.error({ content: '金额为0不能添加折扣行', key: '金额为0不能添加折扣行' });
71
+ return;
72
+ }
73
+
74
+ s.goodsListState.discountGoodIndex = s.goodsListState.selectedGoodIndex.slice();
75
+ });
76
+ }, [controller]);
77
+
78
+ /** 关闭抽屉 */
79
+ const onClose = React.useCallback(() => {
80
+ controller.run(async s => {
81
+ s.goodsListState.discountGoodIndex = []
82
+ })
83
+ }, [controller]);
84
+
85
+ /** 是否禁用 */
86
+ const disabled = React.useMemo(() => selectedGoodIndex.length === 0, [selectedGoodIndex, goodsMap]);
87
+
88
+ /** 是否启用 */
89
+ const isEnable = React.useMemo(() => {
90
+ if (model === 'readOnly') return false;
91
+ return !(isAddDiscount === false)
92
+ }, [isAddDiscount, model]);
93
+
94
+ const button = React.useMemo(() => {
95
+ if (isEnable) {
96
+ return (
97
+ <>
98
+ <Button
99
+ size='small'
100
+ onClick={onOpen}
101
+ disabled={disabled}
102
+ icon={<Icon component={AddSvg} />}
103
+ >
104
+ 添加折扣
105
+ </Button>
106
+ <AddDiscountRowDrawer open={open} onClose={onClose} />
107
+ </>
108
+ )
109
+ } else {
110
+ return (
111
+ <></>
112
+ )
113
+ }
114
+ }, [open, onOpen, onClose, isEnable, disabled])
115
+
116
+ return {
117
+ button,
118
+ }
119
+ }
120
+
121
+ /** 添加折扣行的抽屉 */
122
+ function AddDiscountRowDrawer(props: {
123
+
124
+ /** 是否打开 */
125
+ open: boolean;
126
+
127
+ /** 点击关闭 */
128
+ onClose: () => void;
129
+
130
+ }) {
131
+
132
+ const { open, onClose } = props;
133
+
134
+ const [form] = Form.useForm();
135
+
136
+ const [formValues, setFormValues] = React.useState<{ discolineType: string }>()
137
+
138
+ /** 控制器 */
139
+ const controller = Invoice.useInvoiceController();
140
+
141
+ /** 货物字典 */
142
+ const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, []);
143
+
144
+ /** 准备添加折扣的货物索引列表 */
145
+ const discountGoodIndex = controller.useMemo(s => s.goodsListState.discountGoodIndex || [], []);
146
+
147
+ /** 准备添加折扣的货物列表 */
148
+ const discountGood = React.useMemo(() => discountGoodIndex.map(e => goodsMap.get(e)), [discountGoodIndex, goodsMap])
149
+
150
+ /** 总金额 */
151
+ const totalAmount = React.useMemo(() => {
152
+ let sum = 0;
153
+ discountGood.forEach(e => {
154
+ sum += e?.lineAmountIncludeTax ?? 0;
155
+ })
156
+ return sum;
157
+ }, [discountGood])
158
+
159
+ /** 表单变化 */
160
+ const onChangeForm = React.useCallback(async () => {
161
+ setFormValues(form.getFieldsValue())
162
+ }, [form])
163
+
164
+ /** 点击了确认 */
165
+ const onDefine = React.useCallback(async () => {
166
+ // 表单数据
167
+ const values = await form.validateFields();
168
+
169
+ // 折扣总金额
170
+ const totalDiscoline = values.discolineType === '1'
171
+ ? chain(bignumber(values.discolineValue))
172
+ : chain(bignumber(totalAmount)).multiply(bignumber(values.discolineValue)).multiply(bignumber(0.01));
173
+
174
+
175
+ let discolinesSum = chain(bignumber(0));
176
+
177
+ // 每行的折扣金额
178
+ const discolines: number[] = discountGood.map((e, i) => {
179
+ // 折扣金额占比
180
+ const share = chain(bignumber(e?.lineAmountIncludeTax ?? 0))
181
+ .divide(bignumber(totalAmount));
182
+
183
+ // 折扣金额
184
+ const value = totalDiscoline
185
+ .multiply(share.done())
186
+
187
+ .multiply(bignumber(100))
188
+ .floor()
189
+ .divide(bignumber(100))
190
+
191
+ .done();
192
+
193
+ discolinesSum = discolinesSum.add(value);
194
+ return value.toNumber();
195
+ });
196
+
197
+ // 剩余折扣金额
198
+ let surplus = totalDiscoline.subtract(discolinesSum.done());
199
+
200
+ // 补充剩余折扣金
201
+ for (let i = 0; i < discolines.length; i++) {
202
+ if (surplus.smaller(0.01).done()) break;
203
+ discolines[i] = chain(bignumber(discolines[i])).add(bignumber(0.01)).done().toNumber();
204
+ surplus = surplus.subtract(bignumber(0.01));
205
+ }
206
+
207
+ // 给一组货物添加折扣行
208
+ await controller.addGoodDiscountV2(discolines.map((e, i) => {
209
+ return {
210
+ $index: discountGood[i]?.$index as string,
211
+ discolineAmountunt: e as number,
212
+ }
213
+ }))
214
+
215
+ await controller.run(async s => { s.goodsListState.selectedGoodIndex = [] })
216
+
217
+ // 关闭抽屉
218
+ onClose();
219
+ }, [discountGood, form, totalAmount, onClose, controller])
220
+
221
+ // 打开抽屉时 重置form
222
+ React.useEffect(() => {
223
+ if (open) {
224
+ form.resetFields();
225
+ setFormValues(form.getFieldsValue())
226
+ }
227
+ }, [open])
228
+
229
+ // 切换 折扣方式 清空折扣值
230
+ React.useEffect(() => {
231
+ form.setFieldsValue({ ...formValues, discolineValue: undefined })
232
+ }, [formValues?.discolineType])
233
+
234
+ return (
235
+ <Drawer
236
+ title="添加折扣"
237
+ placement="right"
238
+ width={350}
239
+ onClose={onClose}
240
+ open={open}
241
+ footer={
242
+ <Space size="middle" style={{ display: 'flex', justifyContent: 'end' }}>
243
+ <Button onClick={onDefine} type='primary' >确定</Button>
244
+ <Button onClick={onClose} >取消</Button>
245
+ </Space>
246
+ }
247
+ >
248
+ <Form
249
+ form={form}
250
+ layout='vertical'
251
+ onChange={onChangeForm}
252
+ >
253
+ <Form.Item label='商品金额(含税)' >
254
+ {totalAmount.toFixed(2)}(共 {discountGood.length} 行)
255
+ </Form.Item>
256
+
257
+ <Form.Item
258
+ label='折扣方式'
259
+ name='discolineType'
260
+ initialValue='1'
261
+ >
262
+ <Radio.Group options={[
263
+ { label: '按金额折扣', value: '1' },
264
+ { label: '按比例折扣', value: '2' },
265
+ ]} />
266
+ </Form.Item>
267
+ {
268
+ formValues?.discolineType === '1' ?
269
+ (
270
+ <Form.Item
271
+ label='折扣金额(元)(含税)'
272
+ name='discolineValue'
273
+ rules={[
274
+ { required: true, message: '必填' },
275
+ {
276
+ validator: async (_, value) => {
277
+ if (!value) return;
278
+ if (value > totalAmount) throw new Error('不可以大于商品金额');
279
+ }
280
+ }
281
+ ]}
282
+ >
283
+ <InputNumber style={{ width: '100%' }} />
284
+ </Form.Item>
285
+ ) : (
286
+ <Form.Item
287
+ label='折扣比例(%)(含税)'
288
+ name='discolineValue'
289
+ rules={[
290
+ { required: true, message: '必填' },
291
+ {
292
+ validator: async (_, value) => {
293
+ if (!value) return;
294
+ if (value > 100) throw new Error('不可以大于100');
295
+ }
296
+ }
297
+ ]}
298
+ >
299
+ <InputNumber style={{ width: '100%' }} />
300
+ </Form.Item>
301
+ )
302
+ }
303
+ </Form>
304
+ </Drawer>
305
+ )
306
+ }
307
+
308
+ /** 判断数组是否连续 */
309
+ function isContinuityNum(array: number[]) {
310
+ var i = array[0];
311
+ var isContinuation = true;
312
+ for (var e in array) {
313
+ if (array[e] != i) {
314
+ isContinuation = false;
315
+ break;
316
+ }
317
+ i++;
318
+ }
319
+ return isContinuation;
320
+ }
321
+
@@ -0,0 +1,12 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none">
2
+ <g clip-path="url(#clip0_715_372)">
3
+ <path d="M7.5 14.5312C3.61687 14.5312 0.46875 11.3831 0.46875 7.5C0.46875 3.61687 3.61687 0.46875 7.5 0.46875C11.3831 0.46875 14.5312 3.61687 14.5312 7.5C14.5312 11.3831 11.3831 14.5312 7.5 14.5312ZM7.5 13.5938C10.8656 13.5938 13.5938 10.8656 13.5938 7.5C13.5938 4.13438 10.8656 1.40625 7.5 1.40625C4.13438 1.40625 1.40625 4.13438 1.40625 7.5C1.40625 10.8656 4.13438 13.5938 7.5 13.5938Z" />
4
+ <path d="M3.75 7.96875C3.62568 7.96875 3.50645 7.91936 3.41854 7.83146C3.33064 7.74355 3.28125 7.62432 3.28125 7.5C3.28125 7.37568 3.33064 7.25645 3.41854 7.16854C3.50645 7.08064 3.62568 7.03125 3.75 7.03125H11.25C11.3743 7.03125 11.4935 7.08064 11.5815 7.16854C11.6694 7.25645 11.7188 7.37568 11.7188 7.5C11.7188 7.62432 11.6694 7.74355 11.5815 7.83146C11.4935 7.91936 11.3743 7.96875 11.25 7.96875H3.75Z" />
5
+ <path d="M7.03125 3.75C7.03125 3.62568 7.08064 3.50645 7.16854 3.41854C7.25645 3.33064 7.37568 3.28125 7.5 3.28125C7.62432 3.28125 7.74355 3.33064 7.83146 3.41854C7.91936 3.50645 7.96875 3.62568 7.96875 3.75V11.25C7.96875 11.3743 7.91936 11.4935 7.83146 11.5815C7.74355 11.6694 7.62432 11.7188 7.5 11.7188C7.37568 11.7188 7.25645 11.6694 7.16854 11.5815C7.08064 11.4935 7.03125 11.3743 7.03125 11.25V3.75Z" />
6
+ </g>
7
+ <defs>
8
+ <clipPath id="clip0_715_372">
9
+ <rect width="15" height="15" />
10
+ </clipPath>
11
+ </defs>
12
+ </svg>
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import { Menu, message } from 'kts-components-antd-x3';
3
+ import coolingFn from '../../../../../../../tools/coolingFn'
4
+ import { getSN, setShorthand } from '../../../../../../../tools/itemName'
5
+ import { Invoice, IGood } from '../../../../../../../..';
6
+
7
+ export default () => {
8
+
9
+ const controller = Invoice.useInvoiceController();
10
+
11
+ const { onComply } = controller.useMemo(s => s.goodsListState.productComparison, [])
12
+
13
+ /** 是否禁用 */
14
+ const disabled = controller.useMemo(s => s.goodsListState.selectedGoodIndex.length <= 0, []);
15
+
16
+ /** 点击了 */
17
+ const onClick = React.useCallback(async () => {
18
+ await controller.saveEditGood();
19
+ await controller.wait();
20
+ await controller.run(async s => {
21
+
22
+ // 不能给正在编辑的货物对照
23
+ if (s.goodsListState.editGood && s.goodsListState.selectedGoodIndex.indexOf(s.goodsListState.editGood.$index) >= 0) {
24
+ coolingFn('不能给正在编辑的货物执行商品对照', 3000, () => { message.error('不能给正在编辑的货物执行商品对照') });
25
+ return;
26
+ }
27
+
28
+ if (!s.goodsListState?.productComparison?.onComply) return;
29
+
30
+ const goods = s.goodsListState.selectedGoodIndex.map(e => {
31
+ const t = s.goodsListState.goodsMap.get(e);
32
+ if (!t) return undefined;
33
+
34
+ return {
35
+ ...t,
36
+ itemName: getSN(t.itemName)?.full,
37
+ itemNameSelf: getSN(t.itemNameSelf)?.full,
38
+ } as IGood
39
+ }).filter(e => !!e) as IGood[]
40
+
41
+
42
+ // 比对后的商品
43
+ const newGoods = await s.goodsListState.productComparison.onComply(goods);
44
+
45
+ newGoods.forEach(e => {
46
+ const vt = s.goodsListState.goodsMap.get(e.$index);
47
+ if (!vt) return undefined;
48
+
49
+ vt.itemName = e.itemName ? setShorthand(e.itemName, getSN(vt.itemName)?.shorthand) : vt.itemName;
50
+ vt.itemNameSelf = e.itemNameSelf ? setShorthand(e.itemNameSelf, getSN(vt.itemNameSelf)?.shorthand) : vt.itemNameSelf;
51
+
52
+ vt.itemModelName = e.itemModelName ? e.itemModelName : vt.itemModelName;
53
+ vt.itemModelNameSelf = e.itemModelNameSelf ? e.itemModelNameSelf : vt.itemModelNameSelf;
54
+
55
+ vt.itemCode = e.itemCode ? e.itemCode : vt.itemCode;
56
+ vt.itemCodeSelf = e.itemCodeSelf ? e.itemCodeSelf : vt.itemCodeSelf;
57
+ })
58
+ })
59
+ }, [])
60
+
61
+
62
+ const menuItem = React.useMemo(() => {
63
+
64
+ // 没用 执行商品对照 的方法 不显示按钮
65
+ if (!onComply) return <></>;
66
+
67
+ return (
68
+ <Menu.Item key="3" disabled={disabled} onClick={onClick} >
69
+ 商品映射
70
+ </Menu.Item>
71
+ );
72
+ }, [disabled, onClick, onComply])
73
+
74
+ return { menuItem }
75
+ };