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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "1.2.25",
3
+ "version": "2.0.2",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -30,10 +30,13 @@
30
30
  "classnames": "^2.3.1",
31
31
  "grey-react-box": "^0.2.20",
32
32
  "kts-components-antd-x3": "^3.26.20-5",
33
+ "kts-components-antd-x4": "^4.0.3",
34
+ "kts-xui": "^1.0.30",
33
35
  "mathjs": "^9.4.2",
34
36
  "next": "^11.0.1",
35
37
  "nzh": "^1.0.4",
36
38
  "react": "^16.12.0",
39
+ "react-dom": "^16.12.0",
37
40
  "styled-components": "^5.3.0",
38
41
  "uuid": "^8.3.2"
39
42
  },
@@ -44,9 +47,13 @@
44
47
  "dumi": "^1.0.14",
45
48
  "father-build": "^1.17.2",
46
49
  "gh-pages": "^3.0.0",
50
+ "invariant": "^2.2.4",
47
51
  "kts-components": "^1.2.18",
48
52
  "lint-staged": "^10.0.7",
49
53
  "prettier": "^2.2.1",
50
54
  "yorkie": "^2.0.0"
55
+ },
56
+ "resolutions": {
57
+ "@types/react": "17.0.2"
51
58
  }
52
59
  }
@@ -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,26 @@ 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
+ itemCodeSelf?: string;
27
+
28
+ /** 货物名称(我方-购买) */
29
+ itemNameSelf?: string;
30
+
31
+ /** 货物规格型号(我方-购买) */
32
+ itemModelNameSelf?: string;
21
33
 
22
34
  /** 数量 */
23
35
  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
 
@@ -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
 
@@ -60,6 +64,12 @@ export default class GoodsListState {
60
64
  /** 导入商品的相关数据 */
61
65
  importGoods = new ImportGoods();
62
66
 
67
+ /** 商品对照 相关 */
68
+ productComparison = new ProductComparison();
69
+
63
70
  /** 是否显购买示导入抽屉 */
64
71
  isVisibleDrawer = false;
72
+
73
+ /** 正在 添加商品对照 的货物 */
74
+ addComparisonIndex?: number;
65
75
  }
@@ -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,135 @@
1
+
2
+ import React from "react";
3
+ import { Row, Col, Input, Button } from "kts-components-antd-x3";
4
+ import { Form, Drawer } from "kts-xui";
5
+ import { Invoice } from "../../../";
6
+ import { getSN } from "../../tools/itemName";
7
+
8
+ export default function AddComparisonDrawer() {
9
+
10
+ const [form] = Form.useForm();
11
+
12
+ /** 控制器 */
13
+ const controller = Invoice.useInvoiceController();
14
+
15
+ /** 正在 添加商品对照 的货物索引 */
16
+ const addComparisonIndex = controller.useMemo(s => s.goodsListState.addComparisonIndex, []);
17
+
18
+ /** 货物字典 */
19
+ const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, []);
20
+
21
+ /** 正在 对照 的货物 */
22
+ const good = React.useMemo(() => addComparisonIndex ? goodsMap.get(addComparisonIndex) : undefined, [addComparisonIndex]);
23
+
24
+ /** 关闭对照 */
25
+ const onClose = React.useCallback(controller.pipeline<any>(async s => { s.goodsListState.addComparisonIndex = undefined }), [controller]);
26
+
27
+ /** 提交数据 */
28
+ const onSubmit = React.useCallback(() => {
29
+ controller.run(async s => {
30
+ if (!good) return
31
+
32
+ try {
33
+ const values = await form.validateFields()
34
+ const shorthand = s.goodsListState.isMyShow ? getSN(good.itemNameSelf)?.shorthand : getSN(good.itemName)?.shorthand;
35
+
36
+ good.itemCode = values.itemCode;
37
+ good.itemCodeSelf = values.itemCodeSelf;
38
+ good.itemName = shorthand ? `*${shorthand}*${values.itemName}` : values.itemName;
39
+ good.itemNameSelf = shorthand ? `*${shorthand}*${values.itemNameSelf}` : values.itemNameSelf;
40
+ good.itemModelName = values.itemModelName;
41
+ good.itemModelNameSelf = values.itemModelNameSelf;
42
+
43
+ s.goodsListState.addComparisonIndex = undefined;
44
+ s.goodsListState.goodsList = [...s.goodsListState.goodsList];
45
+ } catch (error) {
46
+
47
+ }
48
+ })
49
+ }, [form, good])
50
+
51
+ React.useEffect(() => {
52
+ form.resetFields();
53
+ if (good) {
54
+ form.setFieldsValue({
55
+ ...good,
56
+ itemName: getSN(good.itemName)?.full,
57
+ itemNameSelf: getSN(good.itemNameSelf)?.full,
58
+ })
59
+ }
60
+ }, [good])
61
+
62
+ return (
63
+ <Drawer
64
+ width={500}
65
+ onClose={onClose}
66
+ placement="right"
67
+ title="添加商品对照"
68
+ visible={!!good}
69
+ footer={
70
+ <div style={{ display: 'flex', justifyContent: 'flex-end', gap: 10 }} >
71
+ <Button type="primary" onClick={onSubmit} >提交</Button>
72
+ <Button onClick={onClose} >取消</Button>
73
+ </div>
74
+ }
75
+ >
76
+ {
77
+ !!good &&
78
+ <Form layout="vertical" style={{ flex: 1 }} form={form} >
79
+ <Row gutter={[8, 8]} >
80
+ <Col span={12}>
81
+ <Form.Item
82
+ name="itemCodeSelf"
83
+ label="我方商品编码"
84
+ >
85
+ <Input />
86
+ </Form.Item>
87
+ </Col>
88
+ <Col span={12} >
89
+ <Form.Item
90
+ name="itemCode"
91
+ label="对方商品编码"
92
+ >
93
+ <Input />
94
+ </Form.Item>
95
+ </Col>
96
+ <Col span={12} >
97
+ <Form.Item
98
+ name="itemNameSelf"
99
+ label="我方商品名称"
100
+ >
101
+ <Input />
102
+ </Form.Item>
103
+ </Col>
104
+ <Col span={12} >
105
+ <Form.Item
106
+ name="itemName"
107
+ label="对方商品名称"
108
+ >
109
+ <Input />
110
+ </Form.Item>
111
+ </Col>
112
+ <Col span={12} >
113
+ <Form.Item name='itemModelNameSelf' label="我方规格型号">
114
+ <Input />
115
+ </Form.Item>
116
+ </Col>
117
+ <Col span={12} >
118
+ <Form.Item name="itemModelName" label="对方规格型号">
119
+ <Input />
120
+ </Form.Item>
121
+ </Col>
122
+ </Row>
123
+ </Form>
124
+ }
125
+ </Drawer>
126
+ )
127
+ }
128
+
129
+ // function validateFields(form: WrappedFormUtils<any>) {
130
+ // return new Promise<{ err: any, values: any }>(resolve => {
131
+ // form.validateFields((err, values) => {
132
+ // resolve({ err, values })
133
+ // })
134
+ // })
135
+ // }
@@ -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,
@@ -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.itemNameSelf = setShorthand(good.itemNameSelf, values.shorthand);
295
+
292
296
  // const name = getItemName(good.itemName, values.shorthand);
293
-
294
- good.itemName = getItemName(good.itemName, values.shorthand); // `*${values.shorthand}*${name}`;
297
+ // good.itemName = getItemName(good.itemName, values.shorthand); // `*${values.shorthand}*${name}`;
298
+
295
299
  good.taxClassificationCode = values.taxClassificationCode;
296
300
  good.taxRate = values.taxRate;
297
301
  good.taxFreeType = values.taxFreeType;
@@ -462,18 +466,3 @@ const getShorthand = (value?: string) => {
462
466
  return undefined;
463
467
  }
464
468
  };
465
-
466
- /** 简称填入名称 */
467
- const getItemName = (value?: string, shorthand?: string) => {
468
- if (!value) value = '';
469
- if (!shorthand) {
470
- return value.replace(/\*[^*]+\*/, ``);
471
- }
472
-
473
- const arr = value.match(/\*[^*]+\*/);
474
- if (arr) {
475
- return value.replace(/\*[^*]+\*/, `*${shorthand}*`);
476
- } else {
477
- return `*${shorthand}*${value}`;
478
- }
479
- }
@@ -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';
@@ -446,3 +447,18 @@ export const endowCode = async (controller: InvoiceController, goods: IGood) =>
446
447
  })();
447
448
  }
448
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
+
456
+ if (s.goodsListState.isMyShow) {
457
+ await controller.setEditGood({ itemNameSelf: value });
458
+ record.itemName && await controller.setEditGood({ itemName: setShorthand(record.itemName, shorthand) });
459
+ } else {
460
+ await controller.setEditGood({ itemName: value });
461
+ record.itemNameSelf && await controller.setEditGood({ itemNameSelf: setShorthand(record.itemNameSelf, shorthand) });
462
+ }
463
+ })
464
+ }