kts-component-invoice-operate 1.2.25 → 2.0.2

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 (55) hide show
  1. package/d.dio +2 -69
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{EndowCode.d.ts → EndowCode/index.d.ts} +2 -2
  3. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{IGood.d.ts → IGood/index.d.ts} +13 -5
  4. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{ImportGoods.d.ts → ImportGoods/index.d.ts} +0 -0
  5. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{LineAttributeType.d.ts → LineAttributeType/index.d.ts} +0 -0
  6. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.d.ts +5 -0
  7. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +7 -0
  8. package/dist/Invoice/index.d.ts +1 -1
  9. package/dist/Invoice/tools/itemName/index.d.ts +14 -0
  10. package/dist/Invoice/ui/AddComparisonDrawer/index.d.ts +2 -0
  11. package/dist/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.d.ts +2 -0
  12. package/dist/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddComparison/index.d.ts +5 -0
  13. package/dist/Invoice/ui/GoodsList/ui/{AddDiscountRowButton → BulkMenu/hooks/useAddDiscountRowButton}/index.d.ts +5 -2
  14. package/dist/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.d.ts +5 -0
  15. package/dist/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.d.ts +5 -0
  16. package/dist/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.d.ts +5 -0
  17. package/dist/Invoice/ui/GoodsList/ui/BulkMenu/index.d.ts +2 -0
  18. package/dist/Invoice/ui/GoodsList/ui/{DelRowButton → DescribeSwitch}/index.d.ts +0 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.esm.js +1084 -314
  21. package/dist/index.js +1083 -313
  22. package/docs/index.md +1 -1
  23. package/docs-dist/umi.css +8 -7
  24. package/docs-dist/umi.js +1 -1
  25. package/package.json +8 -1
  26. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{EndowCode.tsx → EndowCode/index.tsx} +3 -3
  27. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{IGood.ts → IGood/index.ts} +17 -5
  28. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{ImportGoods.ts → ImportGoods/index.ts} +0 -0
  29. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{LineAttributeType.ts → LineAttributeType/index.ts} +0 -0
  30. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.ts +10 -0
  31. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +10 -0
  32. package/src/Invoice/_test/importGoods/index.tsx +21 -3
  33. package/src/Invoice/index.tsx +5 -1
  34. package/src/Invoice/tools/itemName/index.ts +48 -0
  35. package/src/Invoice/ui/AddComparisonDrawer/index.tsx +135 -0
  36. package/src/Invoice/ui/EndowCodeDrawer/index.tsx +6 -17
  37. package/src/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.ts +16 -0
  38. package/src/Invoice/ui/GoodsList/hook/useColumns/index.tsx +101 -36
  39. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddComparison/index.tsx +39 -0
  40. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +5 -2
  41. package/src/Invoice/ui/GoodsList/index.less +1 -4
  42. package/src/Invoice/ui/GoodsList/index.tsx +11 -17
  43. package/src/Invoice/ui/GoodsList/ui/{AddDiscountRowButton → BulkMenu/hooks/useAddDiscountRowButton}/index.less +0 -0
  44. package/src/Invoice/ui/GoodsList/ui/{AddDiscountRowButton → BulkMenu/hooks/useAddDiscountRowButton}/index.tsx +20 -17
  45. package/src/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +75 -0
  46. package/src/Invoice/ui/GoodsList/ui/{DelRowButton → BulkMenu/hooks/useDelRowButton}/index.tsx +15 -7
  47. package/src/Invoice/ui/GoodsList/ui/{EndowCodeButton → BulkMenu/hooks/useEndowCodeButton}/index.tsx +13 -9
  48. package/src/Invoice/ui/GoodsList/ui/BulkMenu/index.tsx +43 -0
  49. package/src/Invoice/ui/GoodsList/ui/DescribeSwitch/index.tsx +37 -0
  50. package/src/Invoice/ui/GoodsList/ui/TaxIncludedSwitch/index.tsx +2 -2
  51. package/src/Invoice/ui/ImportGoodsDrawer/index.tsx +70 -18
  52. package/src/index.ts +1 -0
  53. package/yarn.e.lock +14331 -0
  54. package/yarn.o.lock +14800 -0
  55. package/dist/Invoice/ui/GoodsList/ui/EndowCodeButton/index.d.ts +0 -3
@@ -0,0 +1,37 @@
1
+
2
+ import React from 'react';
3
+ import { Switch, Icon, Tooltip } from 'kts-components-antd-x3';
4
+ import Invoice from '../../../../';
5
+
6
+ export default () => {
7
+
8
+ const controller = Invoice.useInvoiceController();
9
+
10
+ const productComparison = controller.useMemo(s => s.goodsListState.productComparison, [])
11
+
12
+ const isMyShow = controller.useMemo(s => s.goodsListState.isMyShow, []);
13
+
14
+ const onChange = React.useCallback(e => {
15
+ controller.run(async s => s.goodsListState.isMyShow = !s.goodsListState.isMyShow)
16
+ }, [])
17
+
18
+ if (!productComparison.onComply) return <></>;
19
+
20
+ return (
21
+ <span>
22
+ <label style={{ marginRight: 2 }} >
23
+ <Tooltip title="蓝色代表我方商品描述,黑色代表对方的商品描述。">
24
+ <Icon style={{ marginRight: 3 }} type="info-circle" />
25
+ </Tooltip>
26
+ 使用哪方商品描述:
27
+ </label>
28
+ <Switch
29
+ checked={isMyShow}
30
+ checkedChildren="我方"
31
+ unCheckedChildren="对方"
32
+ defaultChecked
33
+ onChange={onChange}
34
+ />
35
+ </span>
36
+ )
37
+ }
@@ -14,12 +14,12 @@ export default () => {
14
14
  const isSwitchTax = controller.useMemo(e => e.goodsListState.isSwitchTax, []);
15
15
 
16
16
  const onChange = React.useCallback(e => {
17
- controller.pipeline(async s => { s.goodsListState = { ...s.goodsListState, isTaxIncluded: e } })()
17
+ controller.pipeline(async s => { s.goodsListState = { ...s.goodsListState, isTaxIncluded: e } })();
18
18
  }, [])
19
19
 
20
20
  return (
21
21
  <span>
22
- <label>含税:</label>
22
+ <label style={{ marginRight: 2 }}>含税:</label>
23
23
  <Switch
24
24
  disabled={isSwitchTax === false}
25
25
  checked={isTaxIncluded}
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
- import { Drawer, message, Table } from 'kts-components-antd-x3';
2
+ import { Drawer, Table } from 'kts-components-antd-x3';
3
3
  import Invoice from '../../';
4
4
  import { updateUnitPriceExcludingTax, updateUnitPriceTax, dutyFree, format15 } from '../GoodsList/hook/useColumns/autoFillFn';
5
5
  import { countAmountIncludeTax } from '../../tools/calculate'
6
+ import { getSN } from '../../tools/itemName'
6
7
  import { IGood } from '../../InvoiceController';
7
8
  import evaluate from '../../tools/evaluate';
8
9
 
@@ -68,8 +69,10 @@ const DrawerBody = () => {
68
69
  async s => {
69
70
  Object.keys(record).filter(e => !record[e] && record[e] !== 0).forEach(e => { delete record[e] });
70
71
 
72
+ // 导入时校验函数
71
73
  if (await s.goodsListState.importGoods.verifyFn(record) === false) return;
72
74
 
75
+ // 没用 被编辑的货物 和 form 就退出
73
76
  if (!s.goodsListState.editGood || !s.goodsListState.form) return;
74
77
 
75
78
  if (s.goodsListState.editGood.lineAmountExcludeTax || s.goodsListState.editGood.lineAmountIncludeTax) {
@@ -79,25 +82,42 @@ const DrawerBody = () => {
79
82
  record.lineAmountIncludeTax = s.goodsListState.editGood.lineAmountIncludeTax;
80
83
  }
81
84
 
82
- s.goodsListState.editGood = { ...s.goodsListState.editGood, ...record };
83
- if (!s.goodsListState.editGood) return;
85
+ // 中间数据
86
+ const between = { ...record };
87
+ between.itemName = getItemName(record, s.goodsListState.editGood);
88
+ between.itemNameOther = getItemNameOther(record, s.goodsListState.editGood);
84
89
 
85
- if(s.goodsListState.editGood.taxRate)
86
- s.goodsListState.editGood.taxRate = dutyFree(controller, s.goodsListState.editGood.taxRate, s.goodsListState.form, s.goodsListState.editGood)
90
+ // 设置编辑货物
91
+ const editGood: IGood = s.goodsListState.editGood = { ...s.goodsListState.editGood, ...between };
87
92
 
88
- if (`${s.goodsListState.editGood.priceIncludeTax}` === '0') {
89
- s.goodsListState.editGood.priceIncludeTax = undefined;
90
- s.goodsListState.editGood.priceExcludeTax = undefined;
93
+ if (editGood.taxRate) {
94
+ editGood.taxRate = dutyFree(controller, editGood.taxRate, s.goodsListState.form, editGood)
95
+ }
96
+
97
+ if (`${editGood.priceIncludeTax}` === '0') {
98
+ editGood.priceIncludeTax = undefined;
99
+ editGood.priceExcludeTax = undefined;
91
100
  } else {
92
- s.goodsListState.editGood.priceExcludeTax = getPriceExcludeTax(s.goodsListState.editGood, record) as number;
101
+ editGood.priceExcludeTax = getPriceExcludeTax(editGood, record) as number;
93
102
  }
94
103
 
95
- if (s.goodsListState.editGood.quantity && s.goodsListState.editGood.priceIncludeTax)
96
- s.goodsListState.editGood.lineAmountIncludeTax = countAmountIncludeTax(s.goodsListState.editGood.quantity, s.goodsListState.editGood.priceIncludeTax);
104
+ if (editGood.quantity && editGood.priceIncludeTax) {
105
+ editGood.lineAmountIncludeTax = countAmountIncludeTax(editGood.quantity, editGood.priceIncludeTax);
106
+ }
97
107
 
98
- s.goodsListState.editGood.itemName = getItemName(record);
108
+ // 导入FORM里
109
+ if (s.goodsListState.isMyShow) {
110
+ s.goodsListState.form.setFieldsValue({
111
+ ...editGood,
112
+ itemName: editGood.itemNameSelf,
113
+ itemModelName: editGood.itemModelNameSelf,
114
+ });
115
+ } else {
116
+ s.goodsListState.form.setFieldsValue({
117
+ ...editGood,
118
+ });
119
+ }
99
120
 
100
- s.goodsListState.form.setFieldsValue(s.goodsListState.editGood as any);
101
121
  s.goodsListState.importGoods.isVisibleDrawer = false;
102
122
 
103
123
  s.goodsListState.isTaxIncluded
@@ -113,11 +133,11 @@ const DrawerBody = () => {
113
133
  };
114
134
 
115
135
  /** 货物名称 */
116
- const getItemName = (record: any) => {
117
- return record.shorthand
118
- ? `*${record.shorthand}*${record.itemName}`
119
- : record.itemName;
120
- };
136
+ // const getItemName = (record: any) => {
137
+ // return record.shorthand
138
+ // ? `*${record.shorthand}*${record.itemName}`
139
+ // : record.itemName;
140
+ // };
121
141
 
122
142
  /** 货物单价,不含税 */
123
143
  const getPriceExcludeTax = (s: IGood, record: any) => {
@@ -126,3 +146,35 @@ const getPriceExcludeTax = (s: IGood, record: any) => {
126
146
  // 单价(含税)/(1+税率) = 单价(不含税)
127
147
  return format15(evaluate(`${record.priceIncludeTax} / (1+${s.taxRate}/100)`));
128
148
  };
149
+
150
+ // 获取我方名称
151
+ const getItemName = (record: any, editGood: IGood) => {
152
+
153
+ let shorthand;
154
+
155
+ shorthand = record.shorthand;
156
+ if (shorthand) {
157
+ return `*${shorthand}*${record.itemName}`;
158
+ }
159
+
160
+ shorthand = getSN(editGood.itemName)?.shorthand;
161
+ if (shorthand) {
162
+ return `*${shorthand}*${record.itemNameSelf}`;
163
+ }
164
+
165
+ return record.itemName;
166
+ }
167
+
168
+ // 获取他方名称
169
+ const getItemNameOther = (record: any, editGood: IGood) => {
170
+ if (!editGood.itemName) return editGood.itemName;
171
+
172
+ let shorthand;
173
+
174
+ shorthand = record.shorthand;
175
+ if (shorthand) {
176
+ return `*${shorthand}*${record.itemNameSelf}`;
177
+ }
178
+
179
+ return record.itemName;
180
+ }
package/src/index.ts CHANGED
@@ -3,3 +3,4 @@ import 'kts-components-antd-x3/dist/kts-components-antd-x3.css';
3
3
 
4
4
  export { default as Invoice } from './Invoice';
5
5
  export { default as InvoiceController } from './Invoice/InvoiceController';
6
+ export type { default as IGood } from './Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood';