kts-component-invoice-operate 2.0.4 → 2.0.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "2.0.4",
3
+ "version": "2.0.7",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -1,14 +1,21 @@
1
1
 
2
2
  import IGood from "../InvoiceControllerState/GoodsListState/IGood";
3
3
 
4
- export default function getGoodsSearch(goodsList: IGood[], search: string) {
4
+ /**
5
+ * 计算搜索商品
6
+ * @param goodsList 被搜索列表
7
+ * @param search 搜索条件
8
+ * @param isTaxIncluded 是否含税
9
+ * @returns
10
+ */
11
+ export default function getGoodsSearch(goodsList: IGood[], search: string, isTaxIncluded: boolean) {
5
12
  if (!search) return goodsList;
6
13
  return goodsList.filter(e => {
7
14
  if ((e.itemName?.indexOf(search) ?? -1) >= 0) {
8
15
  return true;
9
16
  } else if ((e.itemModelName?.indexOf(search) ?? -1) >= 0) {
10
17
  return true
11
- } else if (`${e.lineAmountIncludeTax}`.indexOf(search) >= 0) {
18
+ } else if (`${isTaxIncluded ? e.lineAmountIncludeTax?.toFixed(2) : e.lineAmountExcludeTax?.toFixed(2)}`.indexOf(search) >= 0) {
12
19
  return true
13
20
  } else {
14
21
  return false;
@@ -37,14 +37,32 @@ class MyInvoiceController extends InvoiceController {
37
37
  // 设置比对方法
38
38
  this.state.goodsListState.productComparison = {
39
39
  onComply: async (e: IGood[]) => {
40
- return e.map(e => {
41
- return {
42
- ...e,
43
- itemName: e.itemNameSelf + '(他方)',
44
- itemModelName: e.itemModelNameSelf + '(他方)',
45
- itemCode: e.itemCodeSelf + '(他方)',
40
+ // return e.map(e => {
41
+ // return {
42
+ // ...e,
43
+ // itemName: e.itemNameSelf + '(他方)',
44
+ // itemModelName: e.itemModelNameSelf + '(他方)',
45
+ // itemCode: e.itemCodeSelf + '(他方)',
46
+ // }
47
+ // })
48
+ return [
49
+ {
50
+ "itemCodeSelf": null,
51
+ "itemNameSelf": "china",
52
+ "itemModelNameSelf": "xx",
53
+ "itemCode": null,
54
+ "itemName": "中国",
55
+ "itemModelName": "北京房山 "
56
+ },
57
+ {
58
+ "itemCodeSelf": null,
59
+ "itemNameSelf": "china",
60
+ "itemModelNameSelf": "xx",
61
+ "itemCode": null,
62
+ "itemName": "中国",
63
+ "itemModelName": "北京房山 "
46
64
  }
47
- })
65
+ ] as any
48
66
  }
49
67
  }
50
68
 
@@ -77,7 +77,7 @@ export default function AddComparisonDrawer() {
77
77
  !!good &&
78
78
  <Form layout="vertical" style={{ flex: 1 }} form={form} >
79
79
  <Row gutter={[8, 8]} >
80
- <Col span={12}>
80
+ {/* <Col span={12}>
81
81
  <Form.Item
82
82
  name="itemCodeSelf"
83
83
  label="我方商品编码"
@@ -92,7 +92,7 @@ export default function AddComparisonDrawer() {
92
92
  >
93
93
  <Input />
94
94
  </Form.Item>
95
- </Col>
95
+ </Col> */}
96
96
  <Col span={12} >
97
97
  <Form.Item
98
98
  name="itemNameSelf"
@@ -402,7 +402,7 @@ export default (form: WrappedFormUtils) => {
402
402
  </Form.Item>
403
403
  );
404
404
  } else {
405
- return <span style={{ padding: '0 10px' }}>{parseFloat(value).toFixed(2)}</span>;
405
+ return <span style={{ padding: '0 10px' }}>{formatSearch(parseFloat(value).toFixed(2), searchValue)}</span>;
406
406
  }
407
407
  },
408
408
  },
@@ -22,13 +22,13 @@ export default () => {
22
22
  // const isAll = controller.useMemo(s => s.goodsListState.goodsList.length > 0 && s.goodsListState.selectedGoodIndex.length === s.goodsListState.goodsList.length, [])
23
23
  const isAll = controller.useMemo(s => {
24
24
  if (s.goodsListState.selectedGoodIndex.length <= 0) return false;
25
- const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue).map(e => e.$index);
25
+ const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue, s.goodsListState.isTaxIncluded).map(e => e.$index);
26
26
  const selectedGoodIndex = s.goodsListState.selectedGoodIndex.filter(e => seeGoodsIndex.some(t => e === t));
27
27
  return selectedGoodIndex.length === seeGoodsIndex.length
28
28
  }, [])
29
29
 
30
30
  const indeterminate = controller.useMemo(s => {
31
- const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue).map(e => e.$index);
31
+ const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue, s.goodsListState.isTaxIncluded).map(e => e.$index);
32
32
  const selectedGoodIndex = s.goodsListState.selectedGoodIndex.filter(e => seeGoodsIndex.some(t => e === t));
33
33
  if (selectedGoodIndex.length === 0) return false;
34
34
  return selectedGoodIndex.length < seeGoodsIndex.length
@@ -38,17 +38,13 @@ export default () => {
38
38
  const onClickSelectAll = React.useCallback(async () => {
39
39
  if (isAll) {
40
40
  await controller.pipeline(async s => {
41
- const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue).map(e => e.$index)
41
+ const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue, s.goodsListState.isTaxIncluded).map(e => e.$index)
42
42
 
43
43
  s.goodsListState.selectedGoodIndex = s.goodsListState.selectedGoodIndex.filter(e=>!seeGoodsIndex.some(t => e === t));
44
44
  })()
45
45
  } else {
46
- // controller.pipeline(async s => {
47
- // s.goodsListState.selectedGoodIndex = s.goodsListState.goodsList.map(e => e.$index);
48
- // })()
49
-
50
46
  await controller.pipeline(async s => {
51
- const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue).map(e => e.$index)
47
+ const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue, s.goodsListState.isTaxIncluded).map(e => e.$index)
52
48
 
53
49
  s.goodsListState.selectedGoodIndex = [...s.goodsListState.selectedGoodIndex, ...seeGoodsIndex];
54
50
  s.goodsListState.selectedGoodIndex = Array.from(new Set(s.goodsListState.selectedGoodIndex));
@@ -60,7 +60,9 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
60
60
 
61
61
  const searchValue = controller.useMemo(s => s.goodsListState.searchValue, [])
62
62
 
63
- const dataSourceSearch = React.useMemo(() => controller.getGoodsSearch(dataSource, searchValue), [dataSource, searchValue, controller])
63
+ const isTaxIncluded = controller.useMemo(s => s.goodsListState.isTaxIncluded, [])
64
+
65
+ const dataSourceSearch = React.useMemo(() => controller.getGoodsSearch(dataSource, searchValue, isTaxIncluded), [dataSource, searchValue, controller, isTaxIncluded])
64
66
 
65
67
  /** 表格行事件 */
66
68
  const onRow = useOnRow();
@@ -1,6 +1,6 @@
1
1
  .kts-invoice-operate-goods-list-able-list {
2
2
  .kts-invoice-operate-goods-list-search {
3
- width: 330px;
3
+ width: 350px;
4
4
 
5
5
  input {
6
6
  border-radius: 999px;
@@ -13,6 +13,9 @@ export default function Search() {
13
13
 
14
14
  const readOnly = controller.useMemo(s => !!s.goodsListState.editGood, [])
15
15
 
16
+ /** 是否含税 */
17
+ const isTaxIncluded = controller.useMemo(s => s.goodsListState.isTaxIncluded, [])
18
+
16
19
  const onClick = React.useCallback(async () => {
17
20
  await controller.saveEditGood();
18
21
  await controller.wait();
@@ -27,7 +30,7 @@ export default function Search() {
27
30
 
28
31
  React.useEffect(() => {
29
32
  controller.run(async s => {
30
- s.goodsListState.searchValue = value;
33
+ s.goodsListState.searchValue = value.replace(/^ */, '').replace(/ *$/, '');
31
34
  })
32
35
  }, [value, controller])
33
36
 
@@ -37,7 +40,7 @@ export default function Search() {
37
40
  readOnly={readOnly}
38
41
  value={value}
39
42
  className="kts-invoice-operate-goods-list-search"
40
- placeholder="请您输入货物名称、规格型号、金额(含税)搜索"
43
+ placeholder={`请您输入货物名称、规格型号、金额(${isTaxIncluded ? '含税' : '不含税'})搜索`}
41
44
  prefix={<Icon component={MagnifierSvg} style={{ color: "#b8b8b8" }} />}
42
45
  onChange={e => { setValue(e.target.value); }}
43
46
  onClick={onClick}