kts-component-invoice-operate 1.2.20 → 2.0.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 (88) 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} +15 -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 +7 -0
  7. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +7 -0
  8. package/dist/Invoice/InvoiceController/fns/addGood.d.ts +1 -1
  9. package/dist/Invoice/InvoiceController/fns/addGoodDiscount.d.ts +1 -1
  10. package/dist/Invoice/InvoiceController/fns/delGood.d.ts +1 -1
  11. package/dist/Invoice/InvoiceController/fns/saveEditGood.d.ts +1 -1
  12. package/dist/Invoice/InvoiceController/fns/setEditGood.d.ts +1 -1
  13. package/dist/Invoice/InvoiceController/fns/setGoods.d.ts +1 -1
  14. package/dist/Invoice/InvoiceController/fns/updateInvoiceNo.d.ts +1 -1
  15. package/dist/Invoice/_test/buyerNameSearch/index.d.ts +1 -0
  16. package/dist/Invoice/_test/deduction/index.d.ts +1 -0
  17. package/dist/Invoice/_test/draft/index.d.ts +1 -0
  18. package/dist/Invoice/_test/easiest/index.d.ts +1 -0
  19. package/dist/Invoice/_test/endowCode/index.d.ts +1 -0
  20. package/dist/Invoice/_test/goodsMenuExpand/index.d.ts +1 -0
  21. package/dist/Invoice/_test/importBuyer/index.d.ts +1 -0
  22. package/dist/Invoice/_test/importGoods/index.d.ts +1 -0
  23. package/dist/Invoice/_test/invoiceType/index.d.ts +1 -0
  24. package/dist/Invoice/_test/isInvoiceNo/index.d.ts +1 -0
  25. package/dist/Invoice/_test/replaceHead/index.d.ts +1 -0
  26. package/dist/Invoice/_test/retrieveData/index.d.ts +1 -0
  27. package/dist/Invoice/_test/seller/index.d.ts +1 -0
  28. package/dist/Invoice/_test/setDataSource/index.d.ts +1 -0
  29. package/dist/Invoice/_test/unit/index.d.ts +1 -0
  30. package/dist/Invoice/index.d.ts +1 -1
  31. package/dist/Invoice/tools/coolingFn/index.d.ts +1 -1
  32. package/dist/Invoice/tools/itemName/index.d.ts +14 -0
  33. package/dist/Invoice/tools/lazyFn/index.d.ts +1 -1
  34. package/dist/Invoice/ui/AddComparisonDrawer/index.d.ts +3 -0
  35. package/dist/Invoice/ui/Buyer/ui/BuyerNameInput/index.d.ts +1 -0
  36. package/dist/Invoice/ui/Buyer/ui/ImportBuyerButton/index.d.ts +1 -0
  37. package/dist/Invoice/ui/EndowCodeDrawer/index.d.ts +1 -0
  38. package/dist/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.d.ts +2 -0
  39. package/dist/Invoice/ui/GoodsList/hook/useColumns/ui/RowEditButton/index.d.ts +1 -0
  40. package/dist/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddComparison/index.d.ts +5 -0
  41. package/dist/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.d.ts +1 -0
  42. package/dist/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.d.ts +1 -0
  43. package/dist/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.d.ts +1 -0
  44. package/dist/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/index.d.ts +1 -0
  45. package/dist/Invoice/ui/GoodsList/hook/useColumns/ui/RowSaveButton/index.d.ts +1 -0
  46. package/dist/Invoice/ui/GoodsList/hook/useRowSelection/index.d.ts +1 -0
  47. package/dist/Invoice/ui/GoodsList/ui/AddRowButton/index.d.ts +1 -0
  48. package/dist/Invoice/ui/GoodsList/ui/CommodityComparisonButton/index.d.ts +3 -0
  49. package/dist/Invoice/ui/GoodsList/ui/DelRowButton/index.d.ts +1 -0
  50. package/dist/Invoice/ui/GoodsList/ui/DescribeSwitch/index.d.ts +3 -0
  51. package/dist/Invoice/ui/GoodsList/ui/EndowCodeButton/index.d.ts +1 -0
  52. package/dist/Invoice/ui/GoodsList/ui/Statistics/index.d.ts +1 -0
  53. package/dist/Invoice/ui/GoodsList/ui/TableRow/index.d.ts +1 -0
  54. package/dist/Invoice/ui/GoodsList/ui/TableVirtual/index.d.ts +1 -0
  55. package/dist/Invoice/ui/GoodsList/ui/TaxIncludedSwitch/index.d.ts +1 -0
  56. package/dist/Invoice/ui/ImportBuyerDrawer/index.d.ts +1 -0
  57. package/dist/Invoice/ui/ImportGoodsDrawer/index.d.ts +1 -0
  58. package/dist/index.d.ts +1 -0
  59. package/dist/index.esm.js +1740 -626
  60. package/dist/index.js +1739 -625
  61. package/docs/index.md +2 -2
  62. package/docs-dist/umi.js +1 -1
  63. package/package.json +4 -1
  64. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{EndowCode.tsx → EndowCode/index.tsx} +3 -3
  65. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{IGood.ts → IGood/index.ts} +20 -5
  66. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{ImportGoods.ts → ImportGoods/index.ts} +0 -0
  67. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{LineAttributeType.ts → LineAttributeType/index.ts} +0 -0
  68. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.ts +10 -0
  69. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +12 -2
  70. package/src/Invoice/InvoiceController/fns/addGoodDiscount.ts +4 -3
  71. package/src/Invoice/_test/importGoods/index.tsx +21 -3
  72. package/src/Invoice/index.tsx +5 -1
  73. package/src/Invoice/tools/itemName/index.ts +48 -0
  74. package/src/Invoice/ui/AddComparisonDrawer/index.tsx +179 -0
  75. package/src/Invoice/ui/EndowCodeDrawer/index.tsx +23 -28
  76. package/src/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.ts +21 -24
  77. package/src/Invoice/ui/GoodsList/hook/useColumns/index.tsx +71 -29
  78. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddComparison/index.tsx +39 -0
  79. package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +5 -2
  80. package/src/Invoice/ui/GoodsList/index.less +34 -37
  81. package/src/Invoice/ui/GoodsList/index.tsx +8 -0
  82. package/src/Invoice/ui/GoodsList/ui/AddDiscountRowButton/index.tsx +6 -16
  83. package/src/Invoice/ui/GoodsList/ui/CommodityComparisonButton/index.tsx +74 -0
  84. package/src/Invoice/ui/GoodsList/ui/DescribeSwitch/index.tsx +37 -0
  85. package/src/Invoice/ui/GoodsList/ui/TaxIncludedSwitch/index.tsx +2 -2
  86. package/src/Invoice/ui/ImportGoodsDrawer/index.tsx +70 -18
  87. package/src/index.ts +1 -0
  88. package/yarn.o.lock +14800 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "1.2.20",
3
+ "version": "2.0.0",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -48,5 +48,8 @@
48
48
  "lint-staged": "^10.0.7",
49
49
  "prettier": "^2.2.1",
50
50
  "yorkie": "^2.0.0"
51
+ },
52
+ "resolutions": {
53
+ "@types/react": "17.0.2"
51
54
  }
52
55
  }
@@ -1,6 +1,6 @@
1
- import GoodsListState from '../GoodsListState';
2
- import IGood from './IGood';
3
- import LineAttributeType from './LineAttributeType';
1
+ import GoodsListState from '../../GoodsListState';
2
+ import IGood from '../IGood';
3
+ import LineAttributeType from '../LineAttributeType';
4
4
 
5
5
  export default class EndowCode {
6
6
 
@@ -1,4 +1,4 @@
1
- import LineAttributeType from './LineAttributeType';
1
+ import LineAttributeType from '../LineAttributeType';
2
2
 
3
3
  export default interface IGood {
4
4
  /** 数据索引 */
@@ -10,14 +10,29 @@ export default interface IGood {
10
10
  /** 发票ID */
11
11
  id?: string;
12
12
 
13
- /** 货物名称 */
13
+ /** 商品编码(我方) */
14
+ itemCode?: string;
15
+
16
+ /** 货物名称(我方) */
14
17
  itemName?: string;
15
18
 
16
- /** 货物规格型号 */
19
+ /** 单位(我方) */
20
+ unit?: string;
21
+
22
+ /** 货物规格型号(我方) */
17
23
  itemModelName?: string;
18
24
 
19
- /** 单位 */
20
- unit?: string;
25
+ /** 商品编码(对方) */
26
+ itemCodeOther?: string;
27
+
28
+ /** 货物名称(对方) */
29
+ itemNameOther?: string;
30
+
31
+ /** 单位(对方) */
32
+ unitOther?: string;
33
+
34
+ /** 货物规格型号(对方) */
35
+ itemModelNameOther?: string;
21
36
 
22
37
  /** 数量 */
23
38
  quantity?: number;
@@ -0,0 +1,10 @@
1
+ import IGood from "../IGood";
2
+
3
+ export default class ProductComparison {
4
+
5
+ /** 执行商品对照 */
6
+ onComply?: (e: IGood[]) => Promise<IGood[]>
7
+
8
+ /** 更新对照表 */
9
+ onUpdateComparisonTable?: (e: IGood, values:any) => Promise<void>
10
+ }
@@ -1,6 +1,7 @@
1
1
  import IGood from './IGood';
2
2
  import ImportGoods from './ImportGoods';
3
3
  import EndowCode from './EndowCode';
4
+ import ProductComparison from './ProductComparison';
4
5
  import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
5
6
  import InvoiceController from '../..';
6
7
 
@@ -11,7 +12,7 @@ export default class GoodsListState {
11
12
 
12
13
  /** 产品最大数 */
13
14
  goodMax?: number;
14
-
15
+
15
16
  /** 是否可以切换(含税/不含税)状态 */
16
17
  isSwitchTax?: boolean;
17
18
 
@@ -21,6 +22,9 @@ export default class GoodsListState {
21
22
  /** 是否含税 */
22
23
  isTaxIncluded = true;
23
24
 
25
+ /** 是否显示我方 */
26
+ isMyShow = false;
27
+
24
28
  /** 正在编辑的货物 */
25
29
  editGood?: IGood;
26
30
 
@@ -34,7 +38,7 @@ export default class GoodsListState {
34
38
  defaultRate = 3;
35
39
 
36
40
  /** 税率列表 */
37
- taxRateList: number[] = [0, 3, 5, 6, 9, 12];
41
+ taxRateList: number[] = [0, 3, 5, 6, 9, 13];
38
42
 
39
43
  /** 货物列表 */
40
44
  goodsList: IGood[] = [];
@@ -57,6 +61,12 @@ export default class GoodsListState {
57
61
  /** 导入商品的相关数据 */
58
62
  importGoods = new ImportGoods();
59
63
 
64
+ /** 商品对照 相关 */
65
+ productComparison = new ProductComparison();
66
+
60
67
  /** 是否显购买示导入抽屉 */
61
68
  isVisibleDrawer = false;
69
+
70
+ /** 正在 添加商品对照 的货物 */
71
+ addComparisonIndex?: number;
62
72
  }
@@ -12,6 +12,7 @@ import { chain, bignumber } from 'mathjs';
12
12
  import { InvoiceControllerState } from '../';
13
13
  import LineAttributeType from '../InvoiceControllerState/GoodsListState/LineAttributeType';
14
14
  import idGenerator from '../../tools/idGenerator';
15
+ import { format2 } from '../../../Invoice/tools/calculate';
15
16
 
16
17
  export interface IOptions {
17
18
  /** 需要添加的 索引列表 */
@@ -29,7 +30,7 @@ export interface IOptions {
29
30
  */
30
31
  export default async (state: InvoiceControllerState, options?: IOptions) => {
31
32
  if (!options) return;
32
-
33
+
33
34
  const { indexList = [] } = options;
34
35
  const discount = chain(bignumber(options.discount || 0)).dotDivide(bignumber(100)).done();
35
36
  const goodsMap = state.goodsListState.goodsMap;
@@ -89,9 +90,9 @@ export default async (state: InvoiceControllerState, options?: IOptions) => {
89
90
  amountSum = amountSum.add(bignumber(lineAmountExcludeTax));
90
91
 
91
92
  /** 金额(含税) lineAmountExcludeTax * (1+${good.taxRate}/100)*/
92
- lineAmountIncludeTax = chain(bignumber(lineAmountExcludeTax))
93
+ lineAmountIncludeTax = format2(chain(bignumber(lineAmountExcludeTax))
93
94
  .multiply(chain(bignumber(1)).add(taxRate).done())
94
- .done().toNumber();
95
+ .done().toNumber()) as number
95
96
  }
96
97
 
97
98
  /** 税额 */
@@ -1,8 +1,11 @@
1
- import { Button } from 'kts-components-antd-x3/lib/radio';
1
+
2
2
  import React from 'react';
3
- import { Invoice } from '../../../';
3
+ import { Button } from 'kts-components-antd-x3/lib/radio';
4
+ import { Invoice, IGood } from '../../../';
4
5
  import { IGetBuyerListOption } from '../../../Invoice/InvoiceController/InvoiceControllerState/BuyerState';
5
6
 
7
+ const InvoiceController = Invoice.InvoiceController
8
+
6
9
  export default () => {
7
10
 
8
11
  // 初始化控制器
@@ -17,7 +20,7 @@ export default () => {
17
20
  };
18
21
 
19
22
  // 重写 购买方 的数据源,实现 ‘获取 购买方 列表’ 方法
20
- class MyInvoiceController extends Invoice.InvoiceController {
23
+ class MyInvoiceController extends InvoiceController {
21
24
  constructor() {
22
25
  super();
23
26
 
@@ -31,6 +34,21 @@ class MyInvoiceController extends Invoice.InvoiceController {
31
34
  },
32
35
  ];
33
36
 
37
+ // 设置比对方法
38
+ this.state.goodsListState.productComparison = {
39
+ onComply: async (e: IGood[]) => {
40
+ return e.map(e => {
41
+ return {
42
+ ...e,
43
+ itemNameOther: e.itemName + '(他方)',
44
+ unitOther: e.unit + '(他方)',
45
+ itemModelNameOther: e.itemModelName + '(他方)',
46
+ itemCodeOther: e.itemCode + '(他方)',
47
+ }
48
+ })
49
+ }
50
+ }
51
+
34
52
  this.state.en = '08'
35
53
  this.state.invoiceType = '10'
36
54
  }
@@ -9,6 +9,7 @@ import Buyer from './ui/Buyer';
9
9
  import ImportBuyerDrawer from './ui/ImportBuyerDrawer';
10
10
  import ImportGoodsDrawer from './ui/ImportGoodsDrawer';
11
11
  import EndowCodeDrawer from './ui/EndowCodeDrawer';
12
+ import AddComparisonDrawer from './ui/AddComparisonDrawer';
12
13
  import idGenerator from './tools/idGenerator';
13
14
 
14
15
  /** 发票组件的上下文 */
@@ -39,7 +40,7 @@ export interface IInvoiceProps {
39
40
  footExpand?: React.ReactNode;
40
41
  }
41
42
 
42
- export default class extends React.PureComponent<IInvoiceProps> {
43
+ export default class Invoice extends React.PureComponent<IInvoiceProps> {
43
44
  /** 控制器 */
44
45
  static readonly InvoiceController = InvoiceController;
45
46
 
@@ -100,6 +101,9 @@ const Main = (props: IInvoiceProps) => {
100
101
 
101
102
  {/* 给货品赋码的抽屉 */}
102
103
  <EndowCodeDrawer />
104
+
105
+ {/* 添加商品对照的抽屉 */}
106
+ <AddComparisonDrawer />
103
107
  </InvoiceContext.Provider>
104
108
  );
105
109
  };
@@ -0,0 +1,48 @@
1
+
2
+ export interface ISN {
3
+
4
+ /** 简称 */
5
+ shorthand?: string;
6
+
7
+ /** 全称 */
8
+ full: string
9
+ }
10
+
11
+ /** 拆分全称加简称 */
12
+ export const getSN = (value?: string): ISN | undefined => {
13
+ debugger;
14
+ if (!value) return undefined;
15
+ const arr = value.match(/\*[^*]+\*/);
16
+ if (arr && arr[0]) {
17
+ return { shorthand: arr[0].split('*')[1], full: value.replace(arr[0], '') };
18
+ } else {
19
+ return { shorthand: undefined, full: value };
20
+ }
21
+ };
22
+
23
+ /** 组合全称加简称 */
24
+ export const getItemName = (value: ISN) => {
25
+ if (value.shorthand) {
26
+ return `*${value.shorthand}*${value.full}`;
27
+ } else {
28
+ return value.full;
29
+ }
30
+ }
31
+
32
+ /** 设置全称 */
33
+ export const setFull = (name?:string, full?:string) => {
34
+ const sn = getSN(name);
35
+ if(!sn) return full;
36
+ sn.full = full || '';
37
+ return getItemName(sn);
38
+ }
39
+
40
+ /** 设置简称 */
41
+ export const setShorthand = (name?:string, shorthand?:string) => {
42
+ if(!name) return undefined
43
+
44
+ const sn = getSN(name);
45
+ if(!sn) return undefined;
46
+ sn.shorthand = shorthand || '';
47
+ return getItemName(sn);
48
+ }
@@ -0,0 +1,179 @@
1
+
2
+ import { Row, Col, Input, Drawer, Form, Checkbox, Button } from "kts-components-antd-x3";
3
+ import { FormComponentProps } from "kts-components-antd-x3/lib/form";
4
+ import { decorator } from "grey-react-box";
5
+ import { Invoice } from "../../../";
6
+ import { getSN } from "../../tools/itemName";
7
+ import React from "react";
8
+ import { WrappedFormUtils } from "kts-components-antd-x3/lib/form/Form";
9
+
10
+ const AddComparisonDrawer = decorator(
11
+ Form.create()
12
+ )(
13
+ (props: FormComponentProps) => {
14
+
15
+ const { form } = props;
16
+
17
+ const { getFieldDecorator } = form;
18
+
19
+ /** 控制器 */
20
+ const controller = Invoice.useInvoiceController();
21
+
22
+ /** 正在 添加商品对照 的货物索引 */
23
+ const addComparisonIndex = controller.useMemo(s => s.goodsListState.addComparisonIndex, []);
24
+
25
+ /** 货物字典 */
26
+ const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, []);
27
+
28
+ /** 正在 对照 的货物 */
29
+ const good = React.useMemo(() => addComparisonIndex ? goodsMap.get(addComparisonIndex) : undefined, [addComparisonIndex])
30
+
31
+ /** 关闭对照 */
32
+ const onClose = React.useCallback(controller.pipeline<any>(async s => {
33
+ s.goodsListState.addComparisonIndex = undefined
34
+ }), [controller])
35
+
36
+ /** 提交数据 */
37
+ const onSubmit = React.useCallback(() => {
38
+ controller.run(async s => {
39
+ if (!good) return
40
+
41
+ const { err, values } = await validateFields(form);
42
+ if (err) return;
43
+
44
+ const shorthand = s.goodsListState.isMyShow ? getSN(good.itemName)?.shorthand : getSN(good.itemNameOther)?.shorthand;
45
+ good.itemCode = values.itemCode;
46
+ good.itemCodeOther = values.itemCodeOther;
47
+ good.itemName = shorthand ? `*${shorthand}*${values.itemName}` : values.itemName;
48
+ good.itemNameOther = shorthand ? `*${shorthand}*${values.itemNameOther}` : values.itemNameOther;
49
+ good.itemModelName = values.itemModelName;
50
+ good.itemModelNameOther = values.itemModelNameOther;
51
+ good.unit = values.unit;
52
+ good.unitOther = values.unitOther;
53
+ s.goodsListState.addComparisonIndex = undefined;
54
+ s.goodsListState.goodsList = [...s.goodsListState.goodsList]
55
+
56
+ if (s.goodsListState?.productComparison?.onUpdateComparisonTable && values.isUpdate) {
57
+ debugger
58
+ await s.goodsListState.productComparison.onUpdateComparisonTable(good, values);
59
+ }
60
+ })
61
+ }, [form, good])
62
+
63
+ React.useEffect(() => {
64
+ form.resetFields();
65
+ if (good) {
66
+ form.setFieldsValue({
67
+ ...good,
68
+ itemName: getSN(good.itemName)?.full,
69
+ itemNameOther: getSN(good.itemNameOther)?.full,
70
+ })
71
+ }
72
+ }, [good])
73
+
74
+ return (
75
+ <Drawer
76
+ width={500}
77
+ onClose={onClose}
78
+ placement="right"
79
+ title="添加商品对照"
80
+ visible={!!addComparisonIndex}
81
+ drawerStyle={{ display: 'flex', flexDirection: 'column' }}
82
+ bodyStyle={{ flex: 1, display: 'flex', flexDirection: 'column' }}
83
+ >
84
+ <Form layout="vertical" style={{ flex: 1 }} >
85
+ <Row gutter={[8, 8]} >
86
+ <Col span={12}>
87
+ {getFieldDecorator('itemCode', {})(
88
+ <Form.Item label="我方商品编码" >
89
+ <Input />
90
+ </Form.Item>
91
+ )}
92
+
93
+ </Col>
94
+ <Col span={12} >
95
+ {getFieldDecorator('itemCodeOther', {})(
96
+ <Form.Item label="对方商品编码" >
97
+ <Input />
98
+ </Form.Item>
99
+ )}
100
+ </Col>
101
+ <Col span={12} >
102
+ {getFieldDecorator('itemName', {
103
+ rules: [{ required: true, message: "请输入我方商品名称" }]
104
+ })(
105
+ <Form.Item label="我方商品名称" >
106
+ <Input />
107
+ </Form.Item>
108
+ )}
109
+
110
+ </Col>
111
+ <Col span={12} >
112
+ {getFieldDecorator('itemNameOther', {
113
+ rules: [{ required: true, message: "请输入对方商品名称" }]
114
+ })(
115
+ <Form.Item label="对方商品名称">
116
+ <Input />
117
+ </Form.Item>
118
+ )}
119
+ </Col>
120
+ <Col span={12} >
121
+ <Form.Item label="我方规格型号">
122
+ <Input />
123
+ </Form.Item>
124
+ </Col>
125
+ <Col span={12} >
126
+ {getFieldDecorator('itemModelNameOther', {
127
+ rules: [{ required: true, message: "请输入对方规格型号" }]
128
+ })(
129
+ <Form.Item label="对方规格型号">
130
+ <Input />
131
+ </Form.Item>
132
+ )}
133
+ </Col>
134
+ <Col span={12} >
135
+ {getFieldDecorator('unit', {
136
+ rules: [{ required: true, message: "请输入对方规格型号" }]
137
+ })(
138
+ <Form.Item label="我方计量单位" >
139
+ <Input />
140
+ </Form.Item>
141
+ )}
142
+ </Col>
143
+ <Col span={12} >
144
+ {getFieldDecorator('unitOther', {
145
+ rules: [{ required: true, message: "请输入对方计量单位" }]
146
+ })(
147
+ <Form.Item label="对方计量单位" >
148
+ <Input />
149
+ </Form.Item>
150
+ )}
151
+ </Col>
152
+ <Col span={24} >
153
+ {getFieldDecorator('isUpdate', {
154
+ })(
155
+ <Form.Item >
156
+ <Checkbox>更新到商品对照表中</Checkbox>
157
+ </Form.Item>
158
+ )}
159
+ </Col>
160
+ </Row>
161
+ </Form>
162
+ <div style={{ display: 'flex', justifyContent: 'flex-end', gap: 10 }} >
163
+ <Button type="primary" onClick={onSubmit} >提交</Button>
164
+ <Button onClick={onClose} >取消</Button>
165
+ </div>
166
+ </Drawer>
167
+ )
168
+ }
169
+ )
170
+
171
+ export default AddComparisonDrawer;
172
+
173
+ function validateFields(form: WrappedFormUtils<any>) {
174
+ return new Promise<{ err: any, values: any }>(resolve => {
175
+ form.validateFields((err, values) => {
176
+ resolve({ err, values })
177
+ })
178
+ })
179
+ }
@@ -8,6 +8,7 @@ import { LineAttributeType } from '../../InvoiceController';
8
8
  import IGood from '../../InvoiceController/InvoiceControllerState/GoodsListState/IGood';
9
9
  import { countTaxAmount } from '../../tools/calculate';
10
10
  import { bytesLnegth, cutStr } from '../../tools/strringFn';
11
+ import { setShorthand } from '../../tools/itemName';
11
12
  import {
12
13
  SchemaForm,
13
14
  FormButtonGroup,
@@ -242,7 +243,7 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
242
243
  setList([])
243
244
  }
244
245
  }, [visible])
245
-
246
+
246
247
  return (
247
248
  <>
248
249
  <InputAntd readOnly value={props.value} addonAfter={<Button size="small" type="link" onClick={() => { setVisible(true) }} >点击选择</Button>} />
@@ -289,9 +290,12 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
289
290
  endowCodeGood.forEach(good => {
290
291
  if (!good) return;
291
292
 
293
+ good.itemName = setShorthand(good.itemName, values.shorthand);
294
+ good.itemNameOther = setShorthand(good.itemNameOther, values.shorthand);
295
+
292
296
  // const name = getItemName(good.itemName, values.shorthand);
297
+ // good.itemName = getItemName(good.itemName, values.shorthand); // `*${values.shorthand}*${name}`;
293
298
 
294
- good.itemName = getItemName(good.itemName, values.shorthand); // `*${values.shorthand}*${name}`;
295
299
  good.taxClassificationCode = values.taxClassificationCode;
296
300
  good.taxRate = values.taxRate;
297
301
  good.taxFreeType = values.taxFreeType;
@@ -301,19 +305,25 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
301
305
  const taxRate = chain(bignumber(values.taxRate)).dotDivide(bignumber(100)).add(bignumber(1)).done();
302
306
 
303
307
  // 是否含税
304
- if (s.goodsListState.isTaxIncluded) {
305
- const lineAmountExcludeTax = chain(bignumber(good.lineAmountIncludeTax)).dotDivide(taxRate).done();
306
- const priceExcludeTax = good.priceIncludeTax ? chain(bignumber(good.priceIncludeTax)).dotDivide(taxRate).done() : undefined
308
+ const lineAmountExcludeTax = chain(bignumber(good.lineAmountIncludeTax)).dotDivide(taxRate).done();
309
+ const priceExcludeTax = good.priceIncludeTax ? chain(bignumber(good.priceIncludeTax)).dotDivide(taxRate).done() : undefined
307
310
 
308
- good.lineAmountExcludeTax = lineAmountExcludeTax.toNumber().toFixed(2);
309
- good.priceExcludeTax = (priceExcludeTax ? format15(priceExcludeTax.toNumber()) : undefined) || undefined;
310
- } else {
311
- const lineAmountIncludeTax = chain(bignumber(good.lineAmountExcludeTax)).multiply(taxRate).done();
312
- const priceIncludeTax = good.priceExcludeTax ? chain(bignumber(good.priceExcludeTax)).multiply(taxRate).done() : undefined
311
+ good.lineAmountExcludeTax = lineAmountExcludeTax.toNumber().toFixed(2);
312
+ good.priceExcludeTax = (priceExcludeTax ? format15(priceExcludeTax.toNumber()) : undefined) || undefined;
313
313
 
314
- good.lineAmountIncludeTax = lineAmountIncludeTax.toNumber().toFixed(2);
315
- good.priceIncludeTax = (priceIncludeTax ? format15(priceIncludeTax.toNumber()) : undefined) || undefined;
316
- }
314
+ // if (s.goodsListState.isTaxIncluded) {
315
+ // const lineAmountExcludeTax = chain(bignumber(good.lineAmountIncludeTax)).dotDivide(taxRate).done();
316
+ // const priceExcludeTax = good.priceIncludeTax ? chain(bignumber(good.priceIncludeTax)).dotDivide(taxRate).done() : undefined
317
+
318
+ // good.lineAmountExcludeTax = lineAmountExcludeTax.toNumber().toFixed(2);
319
+ // good.priceExcludeTax = (priceExcludeTax ? format15(priceExcludeTax.toNumber()) : undefined) || undefined;
320
+ // } else {
321
+ // const lineAmountIncludeTax = chain(bignumber(good.lineAmountExcludeTax)).multiply(taxRate).done();
322
+ // const priceIncludeTax = good.priceExcludeTax ? chain(bignumber(good.priceExcludeTax)).multiply(taxRate).done() : undefined
323
+
324
+ // good.lineAmountIncludeTax = lineAmountIncludeTax.toNumber().toFixed(2);
325
+ // good.priceIncludeTax = (priceIncludeTax ? format15(priceIncludeTax.toNumber()) : undefined) || undefined;
326
+ // }
317
327
 
318
328
  good.taxAmount = countTaxAmount(good.lineAmountIncludeTax || 0, s.goodsListState.deduction, values.taxRate);
319
329
  });
@@ -456,18 +466,3 @@ const getShorthand = (value?: string) => {
456
466
  return undefined;
457
467
  }
458
468
  };
459
-
460
- /** 简称填入名称 */
461
- const getItemName = (value?: string, shorthand?: string) => {
462
- if (!value) value = '';
463
- if (!shorthand) {
464
- return value.replace(/\*[^*]+\*/, ``);
465
- }
466
-
467
- const arr = value.match(/\*[^*]+\*/);
468
- if (arr) {
469
- return value.replace(/\*[^*]+\*/, `*${shorthand}*`);
470
- } else {
471
- return `*${shorthand}*${value}`;
472
- }
473
- }
@@ -7,6 +7,7 @@
7
7
  import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
8
8
  import InvoiceController, { IGood, LineAttributeType } from '../../../../../InvoiceController';
9
9
  import evaluate from '../../../../../tools/evaluate';
10
+ import { getSN, setShorthand } from '../../../../../tools/itemName';
10
11
  import { message } from 'kts-components-antd-x3'
11
12
  import { format2, format15, countTaxAmount, countAmountExcludeTax, countPrice } from '../../../../../tools/calculate';
12
13
  import moment from 'moment';
@@ -291,6 +292,12 @@ export function dutyFree(controller: InvoiceController, taxRate: number, form: W
291
292
  const invoiceType = controller.state.invoiceType;
292
293
 
293
294
  // 4月1日至12月31日
295
+ console.log('===> 小规模纳税人免税逻辑');
296
+ console.log('===> invoiceType', invoiceType);
297
+ console.log('===> en', controller.state.en);
298
+ console.log('===> taxRate', taxRate);
299
+ console.log('===> state', controller.state);
300
+
294
301
  if (moment().valueOf() > moment('2022-12-31 23:59').valueOf()) return taxRate;
295
302
  if (controller.state.en !== '08') return taxRate;
296
303
  if (invoiceType !== '10' && invoiceType !== '04') return taxRate;
@@ -304,30 +311,6 @@ export function dutyFree(controller: InvoiceController, taxRate: number, form: W
304
311
  form.setFieldsValue({ taxRate: 0 });
305
312
  return 0;
306
313
  }
307
-
308
- // 选择的 1或者3
309
- // if (taxRate === 1 || taxRate === 3) {
310
- // 是否处理过
311
- // if (cache[record.$index]) {
312
- // return taxRate;
313
- // } else {
314
- // cache[record.$index] = { favouredPolicyName: record.favouredPolicyName, favouredPolicyMark: record.favouredPolicyMark,taxFreeType:record.taxFreeType }
315
- // record.favouredPolicyName = '免税';
316
- // record.taxRate = 0;
317
- // record.favouredPolicyMark = 1;
318
- // record.taxFreeType = 1 as any;
319
- // form.setFieldsValue({ taxRate: 0 });
320
- // return 0;
321
- // }
322
- // } else {
323
- // if (cache[record.$index] && cache[record.$index] !== true) {
324
- // record.favouredPolicyName = cache[record.$index].favouredPolicyName;
325
- // record.favouredPolicyMark = cache[record.$index].favouredPolicyMark;
326
- // record.taxFreeType = cache[record.$index].taxFreeType;
327
- // cache[record.$index] = true;
328
- // }
329
- // return taxRate;
330
- // }
331
314
  }
332
315
 
333
316
  /** 含税 => 更新(不含税) */
@@ -464,3 +447,17 @@ export const endowCode = async (controller: InvoiceController, goods: IGood) =>
464
447
  })();
465
448
  }
466
449
 
450
+ /** 修改了 货物名称 */
451
+ export const onChangeItemName = async (controller: InvoiceController, form: WrappedFormUtils<any>, record: IGood) => {
452
+ controller.run(async s => {
453
+ const value = form.getFieldsValue().itemName;
454
+ const shorthand = getSN(value)?.shorthand ?? '';
455
+ if (s.goodsListState.isMyShow) {
456
+ await controller.setEditGood({ itemName: value });
457
+ record.itemNameOther && await controller.setEditGood({ itemNameOther: setShorthand(record.itemNameOther, shorthand) });
458
+ } else {
459
+ await controller.setEditGood({ itemNameOther: value });
460
+ record.itemName && await controller.setEditGood({ itemName: setShorthand(record.itemName, shorthand) });
461
+ }
462
+ })
463
+ }