kts-component-invoice-operate 2.0.0 → 2.0.3

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 (48) hide show
  1. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.d.ts +10 -12
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.d.ts +0 -2
  3. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
  4. package/dist/Invoice/InvoiceController/fns/getGoodsSearch.d.ts +2 -0
  5. package/dist/Invoice/InvoiceController/index.d.ts +3 -0
  6. package/dist/Invoice/ui/AddComparisonDrawer/index.d.ts +2 -3
  7. package/dist/Invoice/ui/GoodsList/ui/{AddDiscountRowButton → BulkMenu/hooks/useAddDiscountRowButton}/index.d.ts +5 -2
  8. package/dist/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.d.ts +5 -0
  9. package/dist/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.d.ts +5 -0
  10. package/dist/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.d.ts +5 -0
  11. package/dist/Invoice/ui/GoodsList/ui/BulkMenu/index.d.ts +2 -0
  12. package/dist/Invoice/ui/GoodsList/ui/Search/index.d.ts +3 -0
  13. package/dist/index.esm.js +820 -595
  14. package/dist/index.js +819 -594
  15. package/docs-dist/404.html +1 -1
  16. package/docs-dist/index.html +1 -1
  17. package/docs-dist/static/magnifier.2b26be6e.svg +1 -0
  18. package/docs-dist/umi.css +21 -20
  19. package/docs-dist/umi.js +1 -1
  20. package/package.json +5 -1
  21. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +10 -13
  22. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.ts +1 -1
  23. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +3 -0
  24. package/src/Invoice/InvoiceController/fns/getGoodsSearch.ts +17 -0
  25. package/src/Invoice/InvoiceController/index.ts +4 -0
  26. package/src/Invoice/tools/itemName/index.ts +0 -1
  27. package/src/Invoice/ui/AddComparisonDrawer/index.tsx +98 -142
  28. package/src/Invoice/ui/EndowCodeDrawer/index.tsx +1 -1
  29. package/src/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.ts +5 -4
  30. package/src/Invoice/ui/GoodsList/hook/useColumns/index.tsx +61 -15
  31. package/src/Invoice/ui/GoodsList/hook/useRowSelection/index.tsx +34 -8
  32. package/src/Invoice/ui/GoodsList/index.less +10 -2
  33. package/src/Invoice/ui/GoodsList/index.tsx +17 -21
  34. package/src/Invoice/ui/GoodsList/ui/AddRowButton/index.tsx +5 -2
  35. package/src/Invoice/ui/GoodsList/ui/{AddDiscountRowButton → BulkMenu/hooks/useAddDiscountRowButton}/index.less +0 -0
  36. package/src/Invoice/ui/GoodsList/ui/{AddDiscountRowButton → BulkMenu/hooks/useAddDiscountRowButton}/index.tsx +20 -17
  37. package/src/Invoice/ui/GoodsList/ui/{CommodityComparisonButton → BulkMenu/hooks/useCommodityComparisonButton}/index.tsx +23 -22
  38. package/src/Invoice/ui/GoodsList/ui/{DelRowButton → BulkMenu/hooks/useDelRowButton}/index.tsx +15 -7
  39. package/src/Invoice/ui/GoodsList/ui/{EndowCodeButton → BulkMenu/hooks/useEndowCodeButton}/index.tsx +13 -9
  40. package/src/Invoice/ui/GoodsList/ui/BulkMenu/index.tsx +43 -0
  41. package/src/Invoice/ui/GoodsList/ui/Search/icon/magnifier.svg +1 -0
  42. package/src/Invoice/ui/GoodsList/ui/Search/index.less +10 -0
  43. package/src/Invoice/ui/GoodsList/ui/Search/index.tsx +47 -0
  44. package/src/Invoice/ui/ImportGoodsDrawer/index.tsx +10 -10
  45. package/yarn.e.lock +14331 -0
  46. package/dist/Invoice/ui/GoodsList/ui/CommodityComparisonButton/index.d.ts +0 -3
  47. package/dist/Invoice/ui/GoodsList/ui/DelRowButton/index.d.ts +0 -3
  48. 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": "2.0.0",
3
+ "version": "2.0.3",
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,6 +47,7 @@
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",
@@ -10,29 +10,26 @@ export default interface IGood {
10
10
  /** 发票ID */
11
11
  id?: string;
12
12
 
13
- /** 商品编码(我方) */
13
+ /** 商品编码(对方-购买方) */
14
14
  itemCode?: string;
15
15
 
16
- /** 货物名称(我方) */
16
+ /** 货物名称(对方-购买方) */
17
17
  itemName?: string;
18
18
 
19
- /** 单位(我方) */
19
+ /** 单位(对方-购买方) */
20
20
  unit?: string;
21
21
 
22
- /** 货物规格型号(我方) */
22
+ /** 货物规格型号(对方-购买方) */
23
23
  itemModelName?: string;
24
24
 
25
- /** 商品编码(对方) */
26
- itemCodeOther?: string;
25
+ /** 商品编码(我方-销售) */
26
+ itemCodeSelf?: string;
27
27
 
28
- /** 货物名称(对方) */
29
- itemNameOther?: string;
28
+ /** 货物名称(我方-销售) */
29
+ itemNameSelf?: string;
30
30
 
31
- /** 单位(对方) */
32
- unitOther?: string;
33
-
34
- /** 货物规格型号(对方) */
35
- itemModelNameOther?: string;
31
+ /** 货物规格型号(我方-销售) */
32
+ itemModelNameSelf?: string;
36
33
 
37
34
  /** 数量 */
38
35
  quantity?: number;
@@ -6,5 +6,5 @@ export default class ProductComparison {
6
6
  onComply?: (e: IGood[]) => Promise<IGood[]>
7
7
 
8
8
  /** 更新对照表 */
9
- onUpdateComparisonTable?: (e: IGood, values:any) => Promise<void>
9
+ // onUpdateComparisonTable?: (e: IGood, values:any) => Promise<void>
10
10
  }
@@ -40,6 +40,9 @@ export default class GoodsListState {
40
40
  /** 税率列表 */
41
41
  taxRateList: number[] = [0, 3, 5, 6, 9, 13];
42
42
 
43
+ /** 搜索条件 */
44
+ searchValue = '';
45
+
43
46
  /** 货物列表 */
44
47
  goodsList: IGood[] = [];
45
48
 
@@ -0,0 +1,17 @@
1
+
2
+ import IGood from "../InvoiceControllerState/GoodsListState/IGood";
3
+
4
+ export default function getGoodsSearch(goodsList: IGood[], search: string) {
5
+ if (!search) return goodsList;
6
+ return goodsList.filter(e => {
7
+ if ((e.itemName?.indexOf(search) ?? -1) >= 0) {
8
+ return true;
9
+ } else if ((e.itemModelName?.indexOf(search) ?? -1) >= 0) {
10
+ return true
11
+ } else if (`${e.lineAmountIncludeTax}`.indexOf(search) >= 0) {
12
+ return true
13
+ } else {
14
+ return false;
15
+ }
16
+ })
17
+ }
@@ -9,6 +9,7 @@ import delGood from './fns/delGood';
9
9
  import addGoodDiscount from './fns/addGoodDiscount';
10
10
  import addGood from './fns/addGood';
11
11
  import saveEditGood from './fns/saveEditGood';
12
+ import getGoodsSearch from './fns/getGoodsSearch';
12
13
 
13
14
  export { default as InvoiceControllerState } from './InvoiceControllerState';
14
15
  export { default as IGood } from './InvoiceControllerState/GoodsListState/IGood';
@@ -54,4 +55,7 @@ export default class InvoiceController extends InvoiceControllerForm {
54
55
 
55
56
  /** 税收分类编码列表 */
56
57
  getTaxCategoryCodeList?: () => Promise<any>;
58
+
59
+ /** 获取筛选后的列表 */
60
+ getGoodsSearch = getGoodsSearch
57
61
  }
@@ -10,7 +10,6 @@ export interface ISN {
10
10
 
11
11
  /** 拆分全称加简称 */
12
12
  export const getSN = (value?: string): ISN | undefined => {
13
- debugger;
14
13
  if (!value) return undefined;
15
14
  const arr = value.match(/\*[^*]+\*/);
16
15
  if (arr && arr[0]) {
@@ -1,179 +1,135 @@
1
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";
2
+ import React from "react";
3
+ import { Row, Col, Input, Button } from "kts-components-antd-x3";
4
+ import { Form, Drawer } from "kts-xui";
5
5
  import { Invoice } from "../../../";
6
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
7
 
15
- const { form } = props;
8
+ export default function AddComparisonDrawer() {
16
9
 
17
- const { getFieldDecorator } = form;
10
+ const [form] = Form.useForm();
18
11
 
19
- /** 控制器 */
20
- const controller = Invoice.useInvoiceController();
12
+ /** 控制器 */
13
+ const controller = Invoice.useInvoiceController();
21
14
 
22
- /** 正在 添加商品对照 的货物索引 */
23
- const addComparisonIndex = controller.useMemo(s => s.goodsListState.addComparisonIndex, []);
15
+ /** 正在 添加商品对照 的货物索引 */
16
+ const addComparisonIndex = controller.useMemo(s => s.goodsListState.addComparisonIndex, []);
24
17
 
25
- /** 货物字典 */
26
- const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, []);
18
+ /** 货物字典 */
19
+ const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, []);
27
20
 
28
- /** 正在 对照 的货物 */
29
- const good = React.useMemo(() => addComparisonIndex ? goodsMap.get(addComparisonIndex) : undefined, [addComparisonIndex])
21
+ /** 正在 对照 的货物 */
22
+ const good = React.useMemo(() => addComparisonIndex ? goodsMap.get(addComparisonIndex) : undefined, [addComparisonIndex]);
30
23
 
31
- /** 关闭对照 */
32
- const onClose = React.useCallback(controller.pipeline<any>(async s => {
33
- s.goodsListState.addComparisonIndex = undefined
34
- }), [controller])
24
+ /** 关闭对照 */
25
+ const onClose = React.useCallback(controller.pipeline<any>(async s => { s.goodsListState.addComparisonIndex = undefined }), [controller]);
35
26
 
36
- /** 提交数据 */
37
- const onSubmit = React.useCallback(() => {
38
- controller.run(async s => {
39
- if (!good) return
27
+ /** 提交数据 */
28
+ const onSubmit = React.useCallback(() => {
29
+ controller.run(async s => {
30
+ if (!good) return
40
31
 
41
- const { err, values } = await validateFields(form);
42
- if (err) return;
32
+ try {
33
+ const values = await form.validateFields()
34
+ const shorthand = s.goodsListState.isMyShow ? getSN(good.itemNameSelf)?.shorthand : getSN(good.itemName)?.shorthand;
43
35
 
44
- const shorthand = s.goodsListState.isMyShow ? getSN(good.itemName)?.shorthand : getSN(good.itemNameOther)?.shorthand;
45
36
  good.itemCode = values.itemCode;
46
- good.itemCodeOther = values.itemCodeOther;
37
+ good.itemCodeSelf = values.itemCodeSelf;
47
38
  good.itemName = shorthand ? `*${shorthand}*${values.itemName}` : values.itemName;
48
- good.itemNameOther = shorthand ? `*${shorthand}*${values.itemNameOther}` : values.itemNameOther;
39
+ good.itemNameSelf = shorthand ? `*${shorthand}*${values.itemNameSelf}` : values.itemNameSelf;
49
40
  good.itemModelName = values.itemModelName;
50
- good.itemModelNameOther = values.itemModelNameOther;
51
- good.unit = values.unit;
52
- good.unitOther = values.unitOther;
41
+ good.itemModelNameSelf = values.itemModelNameSelf;
42
+
53
43
  s.goodsListState.addComparisonIndex = undefined;
54
- s.goodsListState.goodsList = [...s.goodsListState.goodsList]
44
+ s.goodsListState.goodsList = [...s.goodsListState.goodsList];
45
+ } catch (error) {
55
46
 
56
- if (s.goodsListState?.productComparison?.onUpdateComparisonTable && values.isUpdate) {
57
- debugger
58
- await s.goodsListState.productComparison.onUpdateComparisonTable(good, values);
59
- }
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,
60
58
  })
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
- })
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>
71
74
  }
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 }} >
75
+ >
76
+ {
77
+ !!good &&
78
+ <Form layout="vertical" style={{ flex: 1 }} form={form} >
85
79
  <Row gutter={[8, 8]} >
86
80
  <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
-
81
+ <Form.Item
82
+ name="itemCodeSelf"
83
+ label="我方商品编码"
84
+ >
85
+ <Input />
86
+ </Form.Item>
110
87
  </Col>
111
88
  <Col span={12} >
112
- {getFieldDecorator('itemNameOther', {
113
- rules: [{ required: true, message: "请输入对方商品名称" }]
114
- })(
115
- <Form.Item label="对方商品名称">
116
- <Input />
117
- </Form.Item>
118
- )}
89
+ <Form.Item
90
+ name="itemCode"
91
+ label="对方商品编码"
92
+ >
93
+ <Input />
94
+ </Form.Item>
119
95
  </Col>
120
96
  <Col span={12} >
121
- <Form.Item label="我方规格型号">
97
+ <Form.Item
98
+ name="itemNameSelf"
99
+ label="我方商品名称"
100
+ >
122
101
  <Input />
123
102
  </Form.Item>
124
103
  </Col>
125
104
  <Col span={12} >
126
- {getFieldDecorator('itemModelNameOther', {
127
- rules: [{ required: true, message: "请输入对方规格型号" }]
128
- })(
129
- <Form.Item label="对方规格型号">
130
- <Input />
131
- </Form.Item>
132
- )}
105
+ <Form.Item
106
+ name="itemName"
107
+ label="对方商品名称"
108
+ >
109
+ <Input />
110
+ </Form.Item>
133
111
  </Col>
134
112
  <Col span={12} >
135
- {getFieldDecorator('unit', {
136
- rules: [{ required: true, message: "请输入对方规格型号" }]
137
- })(
138
- <Form.Item label="我方计量单位" >
139
- <Input />
140
- </Form.Item>
141
- )}
113
+ <Form.Item name='itemModelNameSelf' label="我方规格型号">
114
+ <Input />
115
+ </Form.Item>
142
116
  </Col>
143
117
  <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
- )}
118
+ <Form.Item name="itemModelName" label="对方规格型号">
119
+ <Input />
120
+ </Form.Item>
159
121
  </Col>
160
122
  </Row>
161
123
  </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
- }
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
+ // }
@@ -291,7 +291,7 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
291
291
  if (!good) return;
292
292
 
293
293
  good.itemName = setShorthand(good.itemName, values.shorthand);
294
- good.itemNameOther = setShorthand(good.itemNameOther, values.shorthand);
294
+ good.itemNameSelf = setShorthand(good.itemNameSelf, values.shorthand);
295
295
 
296
296
  // const name = getItemName(good.itemName, values.shorthand);
297
297
  // good.itemName = getItemName(good.itemName, values.shorthand); // `*${values.shorthand}*${name}`;
@@ -452,12 +452,13 @@ export const onChangeItemName = async (controller: InvoiceController, form: Wrap
452
452
  controller.run(async s => {
453
453
  const value = form.getFieldsValue().itemName;
454
454
  const shorthand = getSN(value)?.shorthand ?? '';
455
+
455
456
  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 });
457
+ await controller.setEditGood({ itemNameSelf: value });
460
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) });
461
462
  }
462
463
  })
463
464
  }
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import { Form, AutoComplete, Select, Typography, Button, Input, Spin } from 'kts-components-antd-x3';
3
3
  import { InputProps } from 'kts-components-antd-x3/lib/input';
4
4
  import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
5
- import Invoice from '../../../../';
6
5
  import { IGood } from '../../../../InvoiceController';
6
+ import Invoice from '../../../../';
7
7
  import RowMenu from './ui/RowMenu';
8
8
  import {
9
9
  onChangeQuantity,
@@ -12,7 +12,7 @@ import {
12
12
  onChangeLineAmountIncludeTax,
13
13
  onChangeLineAmountExcludeTax,
14
14
  onChangeTaxRate,
15
- onSaveEditGood,
15
+ // onSaveEditGood,
16
16
  endowCode,
17
17
  onChangeItemName,
18
18
  } from './autoFillFn';
@@ -33,6 +33,9 @@ export default (form: WrappedFormUtils) => {
33
33
  /** 正在编辑的货物 */
34
34
  const editGood = controller.useMemo((e) => e.goodsListState.editGood, []);
35
35
 
36
+ /** 搜索条件 */
37
+ const searchValue = controller.useMemo((e) => e.goodsListState.searchValue, []);
38
+
36
39
  /** 税率列表 */
37
40
  const taxRateList = controller.useMemo((e) => e.goodsListState.taxRateList, []);
38
41
 
@@ -61,12 +64,12 @@ export default (form: WrappedFormUtils) => {
61
64
  <Form.Item>
62
65
  <div style={{ display: 'flex' }} >
63
66
  {getFieldDecorator('itemName', {
64
- initialValue: isMyShow ? record.itemName : record.itemNameOther,
67
+ initialValue: isMyShow ? record.itemNameSelf : record.itemName,
65
68
  rules: [{
66
69
  validator: async (_, __, callback) => {
67
70
  await controller.wait();
68
71
  const value = controller.state.goodsListState.editGood;
69
- if (!value?.itemName && !value?.itemNameOther) {
72
+ if (!value?.itemName && !value?.itemNameSelf) {
70
73
  callback('货物名称不能为空');
71
74
  } else {
72
75
  return;
@@ -105,7 +108,16 @@ export default (form: WrappedFormUtils) => {
105
108
  </Form.Item>
106
109
  );
107
110
  } else {
108
- return <MyItemNameDiv valueT={record.itemName} valueF={record.itemNameOther} isMyShow={isMyShow} />
111
+ return (
112
+ <MyItemNameDiv
113
+ valueT={formatSearch(record.itemNameSelf, searchValue)}
114
+ valueF={formatSearch(record.itemName, searchValue)}
115
+ isMyShow={isMyShow}
116
+ />
117
+ )
118
+ // return (
119
+ // <span style={{ padding: '0 10px' }}>{formatSearch(value, searchValue)}</span>
120
+ // );
109
121
  }
110
122
  },
111
123
  },
@@ -118,12 +130,12 @@ export default (form: WrappedFormUtils) => {
118
130
  return (
119
131
  <Form.Item>
120
132
  {getFieldDecorator('itemModelName', {
121
- initialValue: isMyShow ? editGood.itemModelName : editGood.itemModelNameOther,
133
+ initialValue: isMyShow ? editGood.itemModelNameSelf : editGood.itemModelName,
122
134
  })(
123
135
  <MyInput
124
136
  onChange={async () => {
125
137
  await controller.wait()
126
- const key = isMyShow ? 'itemModelName' : 'itemModelNameOther';
138
+ const key = isMyShow ? 'itemModelNameSelf' : 'itemModelName';
127
139
  const value = {} as any;
128
140
  value[key] = form.getFieldsValue().itemModelName;
129
141
  controller.setEditGood(value);
@@ -133,7 +145,13 @@ export default (form: WrappedFormUtils) => {
133
145
  </Form.Item>
134
146
  );
135
147
  } else {
136
- return <MyItemNameDiv valueT={record.itemModelName} valueF={record.itemModelNameOther} isMyShow={isMyShow} />
148
+ return (
149
+ <MyItemNameDiv
150
+ valueT={formatSearch(record.itemModelNameSelf, searchValue)}
151
+ valueF={formatSearch(record.itemModelName, searchValue)}
152
+ isMyShow={isMyShow}
153
+ />
154
+ )
137
155
  }
138
156
  },
139
157
  },
@@ -163,7 +181,7 @@ export default (form: WrappedFormUtils) => {
163
181
  </Form.Item>
164
182
  );
165
183
  } else {
166
- return <MyItemNameDiv valueT={record.unit} valueF={record.unitOther} isMyShow={isMyShow} />;
184
+ return record.unit;
167
185
  }
168
186
  },
169
187
  },
@@ -340,7 +358,7 @@ export default (form: WrappedFormUtils) => {
340
358
  </Form.Item>
341
359
  );
342
360
  } else {
343
- return <span style={{ padding: '0 10px' }}>{parseFloat(value).toFixed(2)}</span>;
361
+ return <span style={{ padding: '0 10px' }}>{formatSearch(parseFloat(value).toFixed(2), searchValue)}</span>;
344
362
  }
345
363
  },
346
364
  },
@@ -415,6 +433,7 @@ export default (form: WrappedFormUtils) => {
415
433
  showArrow={false}
416
434
  style={{ width: '100%' }}
417
435
  onChange={() => {
436
+ setChangeField('taxRate');
418
437
  onChangeTaxRate(controller, form, record);
419
438
  }}
420
439
  >
@@ -444,7 +463,7 @@ export default (form: WrappedFormUtils) => {
444
463
  if (editGood?.$index === record.$index) {
445
464
  return getFieldDecorator('taxAmount', {
446
465
  initialValue: editGood.taxAmount,
447
- })(<MyDiv />);
466
+ })(<MyDiv loading={isCipher(changeField, 'taxAmount')} />);
448
467
  } else {
449
468
  return <span style={{ padding: '0 10px' }}>{parseFloat(value).toFixed(2)}</span>;
450
469
  }
@@ -472,7 +491,7 @@ export default (form: WrappedFormUtils) => {
472
491
  ellipsis: true,
473
492
  };
474
493
  }) as any[];
475
- }, [isTaxIncluded, editGood, controller, changeField, deduction, isMyShow]);
494
+ }, [isTaxIncluded, editGood, controller, changeField, deduction, isMyShow, searchValue]);
476
495
 
477
496
  React.useEffect(() => {
478
497
  if (!changeField) return;
@@ -507,13 +526,22 @@ class MyInput extends React.Component<InputProps & { loading?: boolean }> {
507
526
  }
508
527
  }
509
528
 
510
- class MyDiv extends React.Component<{ value?: any }> {
529
+ class MyDiv extends React.Component<{ value?: any, loading?: boolean }> {
530
+
511
531
  render() {
512
- return <span style={{ padding: '0 10px' }}>{this.props.value}</span>;
532
+ if (this.props.loading) {
533
+ return (
534
+ <Spin size="small">
535
+ <span style={{ padding: '0 10px' }}>{this.props.value}</span>
536
+ </Spin>
537
+ )
538
+ } else {
539
+ return <span style={{ padding: '0 10px' }}>{this.props.value}</span>
540
+ }
513
541
  }
514
542
  }
515
543
 
516
- class MyItemNameDiv extends React.Component<{ valueT?: string, valueF?: string, isMyShow: boolean }> {
544
+ class MyItemNameDiv extends React.Component<{ valueT?: React.ReactNode, valueF?: React.ReactNode, isMyShow: boolean }> {
517
545
  render(): React.ReactNode {
518
546
 
519
547
  const { isMyShow, valueT, valueF } = this.props;
@@ -540,4 +568,22 @@ class MyItemNameDiv extends React.Component<{ valueT?: string, valueF?: string,
540
568
  }
541
569
  }
542
570
  }
571
+ }
572
+
573
+ /** 格式搜索结果 */
574
+ function formatSearch(value?: string, search?: string) {
575
+ if (!value || !search) return value;
576
+
577
+ const __html = ucoding(value).split(new RegExp(ucoding(search), 'g')).map(e => dcoding(e)).join(`<span class="kts-invoice-operate-goods-list-table-search-protrude" >${search}</span>`);
578
+ return <span dangerouslySetInnerHTML={{ __html }} />
579
+ }
580
+
581
+ /** 编码 */
582
+ function ucoding(v: string): string {
583
+ return v.split('').map(e => `U${e.charCodeAt(0)}E`).join('');
584
+ }
585
+
586
+ /** 解码 */
587
+ function dcoding(v: string): string {
588
+ return v.split('U').map(e => e ? String.fromCharCode(parseInt(e.replace('E', ''))) : '').join('');
543
589
  }