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
@@ -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,8 +12,9 @@ import {
12
12
  onChangeLineAmountIncludeTax,
13
13
  onChangeLineAmountExcludeTax,
14
14
  onChangeTaxRate,
15
- onSaveEditGood,
15
+ // onSaveEditGood,
16
16
  endowCode,
17
+ onChangeItemName,
17
18
  } from './autoFillFn';
18
19
 
19
20
  const { Text } = Typography;
@@ -26,6 +27,9 @@ export default (form: WrappedFormUtils) => {
26
27
  /** 是否含税 */
27
28
  const isTaxIncluded = controller.useMemo(e => e.goodsListState.isTaxIncluded, []);
28
29
 
30
+ /** 是否显示我方 */
31
+ const isMyShow = controller.useMemo(e => e.goodsListState.isMyShow, []);
32
+
29
33
  /** 正在编辑的货物 */
30
34
  const editGood = controller.useMemo((e) => e.goodsListState.editGood, []);
31
35
 
@@ -53,21 +57,30 @@ export default (form: WrappedFormUtils) => {
53
57
  <Text type="danger">*</Text>货物名称
54
58
  </>
55
59
  ),
56
- dataIndex: 'itemName',
57
60
  key: 'itemName',
58
- render: (value: string, record: IGood) => {
61
+ render: (_: string, record: IGood) => {
59
62
  if (editGood?.$index === record.$index) {
60
63
  return (
61
64
  <Form.Item>
62
65
  <div style={{ display: 'flex' }} >
63
66
  {getFieldDecorator('itemName', {
64
- initialValue: editGood.itemName,
65
- rules: [{ required: true, message: '货物名称不能为空' }],
67
+ initialValue: isMyShow ? record.itemNameSelf : record.itemName,
68
+ rules: [{
69
+ validator: async (_, __, callback) => {
70
+ await controller.wait();
71
+ const value = controller.state.goodsListState.editGood;
72
+ if (!value?.itemName && !value?.itemNameSelf) {
73
+ callback('货物名称不能为空');
74
+ } else {
75
+ return;
76
+ }
77
+ }
78
+ }]
66
79
  })(
67
80
  <MyInput
68
81
  style={{ flex: 1 }}
69
82
  onChange={() => {
70
- onSaveEditGood(controller, form, record, 'itemName');
83
+ onChangeItemName(controller, form, record);
71
84
  }}
72
85
  />,
73
86
  )}
@@ -83,11 +96,9 @@ export default (form: WrappedFormUtils) => {
83
96
  )}
84
97
  {controller.getGoodsList && (
85
98
  <Button
86
- onClick={() => {
87
- controller.pipeline(async (s) => {
88
- s.goodsListState.importGoods.isVisibleDrawer = true;
89
- })();
90
- }}
99
+ onClick={controller.pipeline(async (s) => {
100
+ s.goodsListState.importGoods.isVisibleDrawer = true;
101
+ })}
91
102
  type="link"
92
103
  icon="plus-circle"
93
104
  />
@@ -98,42 +109,57 @@ export default (form: WrappedFormUtils) => {
98
109
  );
99
110
  } else {
100
111
  return (
101
- <span style={{ padding: '0 10px' }}>{formatSearch(value, searchValue)}</span>
102
- );
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
+ // );
103
121
  }
104
122
  },
105
123
  },
106
124
  {
107
125
  title: '货物规格型号',
108
- dataIndex: 'itemModelName',
109
126
  key: 'itemModelName',
110
127
  width: 119,
111
- render: (value: string, record: IGood) => {
128
+ render: (_: string, record: IGood) => {
112
129
  if (editGood?.$index === record.$index) {
113
130
  return (
114
131
  <Form.Item>
115
132
  {getFieldDecorator('itemModelName', {
116
- initialValue: editGood.itemModelName,
133
+ initialValue: isMyShow ? editGood.itemModelNameSelf : editGood.itemModelName,
117
134
  })(
118
135
  <MyInput
119
- onChange={() => {
120
- onSaveEditGood(controller, form, record, 'itemModelName');
136
+ onChange={async () => {
137
+ await controller.wait()
138
+ const key = isMyShow ? 'itemModelNameSelf' : 'itemModelName';
139
+ const value = {} as any;
140
+ value[key] = form.getFieldsValue().itemModelName;
141
+ controller.setEditGood(value);
121
142
  }}
122
143
  />,
123
144
  )}
124
145
  </Form.Item>
125
146
  );
126
147
  } else {
127
- return <span style={{ padding: '0 10px' }}>{formatSearch(value, searchValue)}</span>;
148
+ return (
149
+ <MyItemNameDiv
150
+ valueT={formatSearch(record.itemModelNameSelf, searchValue)}
151
+ valueF={formatSearch(record.itemModelName, searchValue)}
152
+ isMyShow={isMyShow}
153
+ />
154
+ )
128
155
  }
129
156
  },
130
157
  },
131
158
  {
132
159
  title: '单位',
133
- dataIndex: 'unit',
134
160
  key: 'unit',
135
161
  width: 70,
136
- render: (value: string, record: IGood) => {
162
+ render: (_: string, record: IGood) => {
137
163
  if (editGood?.$index === record.$index) {
138
164
  return (
139
165
  <Form.Item>
@@ -143,15 +169,19 @@ export default (form: WrappedFormUtils) => {
143
169
  <AutoComplete
144
170
  style={{ width: '100%' }}
145
171
  dataSource={unitList}
146
- onChange={() => {
147
- onSaveEditGood(controller, form, record, 'unit');
172
+ onChange={async () => {
173
+ await controller.wait()
174
+ const key = isMyShow ? 'unit' : 'unitOther';
175
+ const value = {} as any;
176
+ value[key] = form.getFieldsValue().unit;
177
+ controller.setEditGood(value);
148
178
  }}
149
179
  />,
150
180
  )}
151
181
  </Form.Item>
152
182
  );
153
183
  } else {
154
- return <span style={{ padding: '0 10px' }}>{value}</span>;
184
+ return record.unit;
155
185
  }
156
186
  },
157
187
  },
@@ -403,6 +433,7 @@ export default (form: WrappedFormUtils) => {
403
433
  showArrow={false}
404
434
  style={{ width: '100%' }}
405
435
  onChange={() => {
436
+ setChangeField('taxRate');
406
437
  onChangeTaxRate(controller, form, record);
407
438
  }}
408
439
  >
@@ -432,7 +463,7 @@ export default (form: WrappedFormUtils) => {
432
463
  if (editGood?.$index === record.$index) {
433
464
  return getFieldDecorator('taxAmount', {
434
465
  initialValue: editGood.taxAmount,
435
- })(<MyDiv />);
466
+ })(<MyDiv loading={isCipher(changeField, 'taxAmount')} />);
436
467
  } else {
437
468
  return <span style={{ padding: '0 10px' }}>{parseFloat(value).toFixed(2)}</span>;
438
469
  }
@@ -449,13 +480,9 @@ export default (form: WrappedFormUtils) => {
449
480
  ]
450
481
  .filter((e) => {
451
482
  if (isTaxIncluded) {
452
- return !(
453
- e.key === 'priceExcludeTax' || e.key === 'lineAmountExcludeTax'
454
- );
483
+ return !(e.key === 'priceExcludeTax' || e.key === 'lineAmountExcludeTax');
455
484
  } else {
456
- return !(
457
- e.key === 'priceIncludeTax' || e.key === 'lineAmountIncludeTax'
458
- );
485
+ return !(e.key === 'priceIncludeTax' || e.key === 'lineAmountIncludeTax');
459
486
  }
460
487
  })
461
488
  .map((e) => {
@@ -464,7 +491,7 @@ export default (form: WrappedFormUtils) => {
464
491
  ellipsis: true,
465
492
  };
466
493
  }) as any[];
467
- }, [isTaxIncluded, editGood, controller, changeField, deduction, searchValue]);
494
+ }, [isTaxIncluded, editGood, controller, changeField, deduction, isMyShow, searchValue]);
468
495
 
469
496
  React.useEffect(() => {
470
497
  if (!changeField) return;
@@ -499,14 +526,52 @@ class MyInput extends React.Component<InputProps & { loading?: boolean }> {
499
526
  }
500
527
  }
501
528
 
502
- class MyDiv extends React.Component<{ value?: any }> {
529
+ class MyDiv extends React.Component<{ value?: any, loading?: boolean }> {
530
+
503
531
  render() {
504
- 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
+ }
541
+ }
542
+ }
543
+
544
+ class MyItemNameDiv extends React.Component<{ valueT?: React.ReactNode, valueF?: React.ReactNode, isMyShow: boolean }> {
545
+ render(): React.ReactNode {
546
+
547
+ const { isMyShow, valueT, valueF } = this.props;
548
+
549
+ if (isMyShow) {
550
+ if (valueT) {
551
+ return (
552
+ <span style={{ padding: '0 10px', color: '#0074ff' }}>{valueT}</span>
553
+ )
554
+ } else {
555
+ return (
556
+ <span style={{ padding: '0 10px' }}>{valueF}</span>
557
+ )
558
+ }
559
+ } else {
560
+ if (valueF) {
561
+ return (
562
+ <span style={{ padding: '0 10px' }}>{valueF}</span>
563
+ )
564
+ } else {
565
+ return (
566
+ <span style={{ padding: '0 10px', color: '#0074ff' }}>{valueT}</span>
567
+ )
568
+ }
569
+ }
505
570
  }
506
571
  }
507
572
 
508
573
  /** 格式搜索结果 */
509
- function formatSearch(value: string, search: string) {
574
+ function formatSearch(value?: string, search?: string) {
510
575
  if (!value || !search) return value;
511
576
 
512
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>`);
@@ -0,0 +1,39 @@
1
+ /** 添加商品对照 */
2
+
3
+ import React from 'react';
4
+ import { Menu, message, Typography } from 'kts-components-antd-x3';
5
+ import { IGood } from '../../../../../../../../InvoiceController';
6
+ import Invoice from '../../../../../../../../';
7
+
8
+ const { Text } = Typography;
9
+
10
+ export default (goods: IGood) => {
11
+
12
+ const controller = Invoice.useInvoiceController();
13
+
14
+ const productComparison = controller.useMemo(s => s.goodsListState.productComparison, []);
15
+
16
+ const onClick = React.useCallback(async () => {
17
+ await controller.saveEditGood();
18
+ await controller.wait();
19
+ await controller.run(async s => {
20
+ if (s.goodsListState.form) {
21
+ const err: any = s.goodsListState.form.getFieldsError();
22
+ for (let key in err) {
23
+ if (!err[key]) continue;
24
+ message.error(err[key][0]);
25
+ return;
26
+ }
27
+ }
28
+ s.goodsListState.addComparisonIndex = goods.$index;
29
+ })
30
+ }, [controller, goods.$index]);
31
+
32
+ return React.useMemo(() => {
33
+ if (productComparison.onComply) {
34
+ return <Menu.Item key="delItem" onClick={onClick}><Text strong>添加商品对照</Text></Menu.Item>
35
+ } else {
36
+ return <></>
37
+ }
38
+ }, [onClick, productComparison])
39
+ };
@@ -5,6 +5,7 @@ import { ReactComponent as SpotSvg } from './spot.svg';
5
5
  import useDelItem from './hook/useDelItem';
6
6
  import useAddDiscount from './hook/useAddDiscount';
7
7
  import useEndowCode from './hook/useEndowCode';
8
+ import useAddComparison from './hook/useAddComparison';
8
9
  import './index.less';
9
10
  import Invoice from '../../../../../../';
10
11
 
@@ -22,13 +23,15 @@ export default (props: { goods: IGood }) => {
22
23
  const delItem = useDelItem(props.goods);
23
24
  const addDiscount = useAddDiscount(props.goods);
24
25
  const endowCode = useEndowCode(props.goods);
26
+ const addComparison = useAddComparison(props.goods);
25
27
 
26
28
  const itemList = React.useMemo(() => {
27
29
  const arr: any[] = [];
28
30
 
29
31
  model !=='prefab' && isAddDiscount !== false && addDiscount && arr.push(addDiscount); // 添加折扣行
30
- endowCode && arr.push(endowCode); // 赋码
31
- model !=='prefab' && delItem && arr.push(delItem); // 删除
32
+ arr.push(addComparison); // 添加商品对照
33
+ endowCode && arr.push(endowCode); // 赋码
34
+ model !=='prefab' && delItem && arr.push(delItem); // 删除
32
35
 
33
36
  if (!goodsMenuExpand || goodsMenuExpand.length === 0) return arr;
34
37
 
@@ -39,10 +39,7 @@
39
39
  .kts-invoice-operate-goods-list-able-extend {
40
40
  flex : none;
41
41
  display: flex;
42
-
43
- label {
44
- margin-right: 5px;
45
- }
42
+ gap : 5px;
46
43
  }
47
44
  }
48
45
 
@@ -10,11 +10,10 @@ import TableVirtual from './ui/TableVirtual';
10
10
  import Statistics from './ui/Statistics';
11
11
  import AddRowButton from './ui/AddRowButton';
12
12
  import TaxIncludedSwitch from './ui/TaxIncludedSwitch';
13
+ import DescribeSwitch from './ui/DescribeSwitch';
13
14
  import Search from './ui/Search';
14
15
  import TableRow from './ui/TableRow';
15
- import AddDiscountRowButton from './ui/AddDiscountRowButton';
16
- import EndowCodeButton from './ui/EndowCodeButton';
17
- import DelRowButton from './ui/DelRowButton';
16
+ import BulkMenu from './ui/BulkMenu';
18
17
 
19
18
  import useColumns from './hook/useColumns';
20
19
  import useOnRow from './hook/useOnRow';
@@ -76,17 +75,15 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
76
75
 
77
76
  /** 注册 from 对象 */
78
77
  React.useEffect(() => {
79
- controller.pipeline<WrappedFormUtils>(async (s, form) => {
80
- s.goodsListState = { ...s.goodsListState, form };
81
- })(props.form);
78
+ controller.pipeline<WrappedFormUtils>(async (s, form) => { s.goodsListState = { ...s.goodsListState, form } })(props.form);
82
79
  }, [controller, props.form]);
83
80
 
84
81
  // 跟新 货物
85
82
  React.useEffect(() => {
86
- controller.pipeline(async (s) => {
83
+ controller.run(async (s) => {
87
84
  s.goodsListState.goodsMap = new Map();
88
85
  goodsList.forEach((e) => { s.goodsListState.goodsMap.set(e.$index, e); });
89
- })();
86
+ });
90
87
  }, [controller, goodsList]);
91
88
 
92
89
  /** props 产品最大数 更新 */
@@ -111,14 +108,8 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
111
108
  {/* 添加行 */}
112
109
  <AddRowButton />
113
110
 
114
- {/* 删除行 */}
115
- <DelRowButton />
116
-
117
- {/* 添加折扣行 */}
118
- <AddDiscountRowButton />
119
-
120
- {/* 批量赋码 */}
121
- <EndowCodeButton />
111
+ {/* 批量菜单 */}
112
+ <BulkMenu />
122
113
 
123
114
  {/* 搜索 */}
124
115
  <Search />
@@ -128,6 +119,9 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
128
119
  {/* 扩展部分 */}
129
120
  {props.menuExpansion}
130
121
 
122
+ {/* 使用哪方商品描述 */}
123
+ <DescribeSwitch />
124
+
131
125
  {/* 是否含税开关 */}
132
126
  <TaxIncludedSwitch />
133
127
  </div>
@@ -143,7 +137,7 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
143
137
  dataSource={dataSourceSearch}
144
138
  columns={useColumns(props.form)}
145
139
  rowSelection={useRowSelection()}
146
- onRow={(record) => ({
140
+ onRow={record => ({
147
141
  onClick: () => {
148
142
  onRow.onClick(record);
149
143
  },
@@ -7,20 +7,20 @@
7
7
  */
8
8
 
9
9
  import React from 'react';
10
- import { Button, Drawer, Form, message, Input, Typography } from 'kts-components-antd-x3';
10
+ import { Button, Drawer, Form, message, Input, Typography, Menu } from 'kts-components-antd-x3';
11
11
  import { FormComponentProps } from 'kts-components-antd-x3/lib/form';
12
12
  import { all, create } from 'mathjs';
13
13
  import { decorator } from 'grey-react-box';
14
- import Invoice from '../../../../';
15
- import lazyFn from '../../../../tools/lazyFn';
16
- import LineAttributeType from '../../../../InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType';
17
- import evaluate from '../../../../../Invoice/tools/evaluate';
14
+ import Invoice from '../../../../../../';
15
+ import lazyFn from '../../../../../../tools/lazyFn';
16
+ import LineAttributeType from '../../../../../../InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType';
17
+ import evaluate from '../../../../../../../Invoice/tools/evaluate';
18
18
  import './index.less';
19
19
 
20
20
  const { Text } = Typography;
21
21
  const { chain } = create(all, { number: 'BigNumber', precision: 20 }) as any;
22
22
 
23
- export default decorator<{}, FormComponentProps>(Form.create())((props) => {
23
+ export default () => {
24
24
  /** 控制器 */
25
25
  const controller = Invoice.useInvoiceController();
26
26
 
@@ -86,15 +86,16 @@ export default decorator<{}, FormComponentProps>(Form.create())((props) => {
86
86
  })();
87
87
  }, [controller]);
88
88
 
89
- if (model === 'prefab') return <></>;
89
+ const menuItem = React.useMemo(() => {
90
+ return model === 'prefab' ? <></> : isAddDiscount !== false ? (
91
+ <Menu.Item key="0" onClick={onClick} disabled={disabled}>
92
+ 添加折扣行
93
+ </Menu.Item>
94
+ ) : undefined
95
+ }, [isAddDiscount, disabled, onClick])
90
96
 
91
- return (
92
- <>
93
- {
94
- isAddDiscount !== false &&
95
- <Button icon="plus-circle" disabled={disabled} onClick={onClick}>
96
- 添加折扣行
97
- </Button>}
97
+ const drawer = React.useMemo(() => {
98
+ return (
98
99
  <Drawer
99
100
  className="kts-invoice-operate-goods-list-add-discount-row"
100
101
  width={540}
@@ -106,9 +107,11 @@ export default decorator<{}, FormComponentProps>(Form.create())((props) => {
106
107
  >
107
108
  <DrawerBody />
108
109
  </Drawer>
109
- </>
110
- );
111
- });
110
+ )
111
+ }, [visible, onClose])
112
+
113
+ return { menuItem, drawer }
114
+ };
112
115
 
113
116
  const DrawerBody = decorator<{}, FormComponentProps>(Form.create())((props) => {
114
117
  const { form } = props;
@@ -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.filter(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
+ };
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
- import Invoice from '../../../../';
3
- import LineAttributeType from '../../../../InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType';
4
- import { Button } from 'kts-components-antd-x3';
2
+ import Invoice from '../../../../../../';
3
+ import LineAttributeType from '../../../../../../InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType';
4
+ import { Menu } from 'kts-components-antd-x3';
5
5
 
6
6
  export default () => {
7
+
7
8
  const controller = Invoice.useInvoiceController();
8
9
 
9
10
  const model = controller.useMemo(s => s.model, []);
@@ -41,9 +42,16 @@ export default () => {
41
42
  })();
42
43
  }, [controller]);
43
44
 
44
- if (model === 'prefab') return <></>;
45
+ const menuItem = React.useMemo(() => {
46
+
47
+ if (model === 'prefab') return <></>;
48
+
49
+ return (
50
+ <Menu.Item key="1" onClick={onClick} disabled={disabled}>
51
+ 删除行
52
+ </Menu.Item>
53
+ )
54
+ }, [model, onClick, disabled])
45
55
 
46
- return (
47
- <Button icon="delete" onClick={onClick} disabled={disabled}>删除行</Button>
48
- );
56
+ return { menuItem };
49
57
  };
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
- import Invoice from '../../../../';
3
- import { Button, message } from 'kts-components-antd-x3';
4
- import coolingFn from '../../../../tools/coolingFn'
5
- // import { LineAttributeType } from '../../../../InvoiceController';
2
+ import Invoice from '../../../../../../';
3
+ import { message ,Menu} from 'kts-components-antd-x3';
4
+ import coolingFn from '../../../../../../tools/coolingFn';
6
5
 
7
6
  export default () => {
8
7
  const controller = Invoice.useInvoiceController();
@@ -34,9 +33,14 @@ export default () => {
34
33
  })();
35
34
  }, [controller]);
36
35
 
37
- return (
38
- <Button icon="file-add" disabled={disabled} onClick={onClick}>
39
- 批量赋码
40
- </Button>
41
- );
36
+ const menuItem = React.useMemo(() => {
37
+
38
+ return (
39
+ <Menu.Item key="2" onClick={onClick} disabled={disabled}>
40
+ 批量赋码
41
+ </Menu.Item>
42
+ )
43
+ }, [onClick, disabled])
44
+
45
+ return { menuItem };
42
46
  };
@@ -0,0 +1,43 @@
1
+
2
+ import React from "react";
3
+ import { Button, Dropdown, Menu } from "kts-components-antd-x3";
4
+
5
+ import useDelRowButton from "./hooks/useDelRowButton";
6
+ import useAddDiscountRowButton from "./hooks/useAddDiscountRowButton";
7
+ import useEndowCodeButton from "./hooks/useEndowCodeButton";
8
+ import useCommodityComparisonButton from "./hooks/useCommodityComparisonButton";
9
+
10
+ export default function BulkMenu() {
11
+
12
+ /** 删除行 */
13
+ const delRowButton = useDelRowButton();
14
+
15
+ /** 添加折扣行 */
16
+ const addDiscountRowButton = useAddDiscountRowButton();
17
+
18
+ /** 批量赋码 */
19
+ const endowCodeButton = useEndowCodeButton();
20
+
21
+ /** 执行商品对照 */
22
+ const commodityComparisonButton = useCommodityComparisonButton();
23
+
24
+ const menu = (
25
+ <Menu>
26
+ {delRowButton.menuItem}
27
+ {addDiscountRowButton.menuItem}
28
+ {endowCodeButton.menuItem}
29
+ {commodityComparisonButton.menuItem}
30
+ </Menu>
31
+ );
32
+
33
+ return (
34
+ <>
35
+ <Dropdown overlay={menu}>
36
+ <Button>
37
+ 批量操作行
38
+ </Button>
39
+ </Dropdown>
40
+ {addDiscountRowButton.drawer}
41
+ </>
42
+ )
43
+ }