kts-component-invoice-operate 3.2.26 → 3.2.28

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 (21) hide show
  1. package/dist/Invoice/InvoiceController/InvoiceControllerState/AutoComplete/index.d.ts +2 -0
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.d.ts +7 -0
  3. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +3 -0
  4. package/dist/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.d.ts +2 -0
  5. package/dist/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.d.ts +7 -0
  6. package/dist/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.d.ts +7 -0
  7. package/dist/index.esm.js +255 -69
  8. package/dist/index.js +255 -69
  9. package/package.json +1 -1
  10. package/src/Invoice/InvoiceController/InvoiceControllerState/AutoComplete/index.ts +3 -0
  11. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.ts +10 -0
  12. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +4 -0
  13. package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +16 -1
  14. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +37 -30
  15. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.less +3 -0
  16. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.tsx +49 -0
  17. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/svg/I001.svg +1 -0
  18. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.less +18 -0
  19. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.tsx +45 -0
  20. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDetails/index.tsx +4 -4
  21. package/src/Invoice/ui/digtal/Stakeholder/index.tsx +4 -11
@@ -515,4 +515,19 @@ export const onChangeItemName = async (controller: InvoiceController, form: Wrap
515
515
  record.itemNameSelf && await controller.setEditGood({ itemNameSelf: record.itemNameSelf });
516
516
  }
517
517
  })
518
- }
518
+ }
519
+
520
+ /** 修改了 商品编码 */
521
+ export const onChangeItemCode = async (controller: InvoiceController, form: WrappedFormUtils<any>, record: IGood) => {
522
+ controller.run(async s => {
523
+ const value = form.getFieldsValue().itemCode;
524
+
525
+ if (s.goodsListState.isMyShow) {
526
+ await controller.setEditGood({ itemCodeSelf: value });
527
+ record.itemCode && await controller.setEditGood({ itemCode: record.itemCode });
528
+ } else {
529
+ await controller.setEditGood({ itemCode: value });
530
+ record.itemCodeSelf && await controller.setEditGood({ itemCodeSelf: record.itemCodeSelf });
531
+ }
532
+ })
533
+ }
@@ -7,6 +7,7 @@ import Invoice from '../../../../..';
7
7
  import RowMenu from './ui/RowMenu';
8
8
  import TitleText from './ui/TitleText';
9
9
  import ItemNameInput from './ui/ItemNameInput';
10
+ import ItemCodeInput from './ui/ItemCodeInput';
10
11
  import {
11
12
  onChangeQuantity,
12
13
  onChangePriceIncludeTax,
@@ -15,8 +16,10 @@ import {
15
16
  onChangeLineAmountExcludeTax,
16
17
  onChangeTaxRate,
17
18
  onChangeItemName,
19
+ onChangeItemCode,
18
20
  } from './autoFillFn';
19
21
  import { getItemNameWithShorthand } from '../../../../../tools/itemName';
22
+ import Drag from './ui/Drag';
20
23
 
21
24
  export default (form: WrappedFormUtils) => {
22
25
  const { getFieldDecorator, getFieldValue } = form;
@@ -77,6 +80,13 @@ export default (form: WrappedFormUtils) => {
77
80
  /** 表头 */
78
81
  const columns = React.useMemo(() => {
79
82
  return [
83
+ // {
84
+ // title: ' ',
85
+ // key: 'drag',
86
+ // width: 40,
87
+ // align: 'center',
88
+ // render: (_: any, record: IGood) => <Drag record={record} />
89
+ // },
80
90
  {
81
91
  title: '序号',
82
92
  key: 'serialNo',
@@ -84,6 +94,31 @@ export default (form: WrappedFormUtils) => {
84
94
  width: 50,
85
95
  render: (e: number) => <span style={{ padding: '0 10px' }}>{e}</span>,
86
96
  },
97
+ {
98
+ title: '商品编码',
99
+ key: 'itemCode',
100
+ width: 119,
101
+ render: (_: string, record: IGood) => {
102
+ if (editGood?.$index === record.$index) {
103
+ return (
104
+ <Form.Item>
105
+ {getFieldDecorator('itemCode', {
106
+ initialValue: editGood.itemCode,
107
+ })(
108
+ <ItemCodeInput
109
+ shorthand={editGood.shorthand}
110
+ onChange={() => {
111
+ onChangeItemCode(controller, form, record);
112
+ }}
113
+ />
114
+ )}
115
+ </Form.Item>
116
+ )
117
+ } else {
118
+ return record.itemCode
119
+ }
120
+ }
121
+ },
87
122
  {
88
123
  title: <TitleText required >项目名称</TitleText>,
89
124
  key: 'itemName',
@@ -141,26 +176,6 @@ export default (form: WrappedFormUtils) => {
141
176
  }
142
177
  },
143
178
  },
144
- {
145
- title: '商品编码',
146
- key: 'itemCode',
147
- width: 119,
148
- render: (_: string, record: IGood) => {
149
- if (editGood?.$index === record.$index) {
150
- return (
151
- <Form.Item>
152
- {getFieldDecorator('itemCode', {
153
- initialValue: editGood.itemCode,
154
- })(
155
- <MyInput />,
156
- )}
157
- </Form.Item>
158
- )
159
- } else {
160
- return record.itemCode
161
- }
162
- }
163
- },
164
179
  {
165
180
  title: <TitleText rules={columnsReplenish['itemModelName']?.rules} >规格型号</TitleText>,
166
181
  key: 'itemModelName',
@@ -521,7 +536,7 @@ export default (form: WrappedFormUtils) => {
521
536
  },
522
537
  ]
523
538
  // 筛选隐藏
524
- .filter(e => {
539
+ .filter(e => {
525
540
  return e.key ? columnshide.indexOf(e.key) < 0 : false;
526
541
  })
527
542
  // 含税不含税
@@ -547,13 +562,6 @@ export default (form: WrappedFormUtils) => {
547
562
  };
548
563
  }) as any[];
549
564
  }, [isTaxIncluded, editGood, controller, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, columnshide]);
550
-
551
- // React.useEffect(() => {
552
- // clearTimeout(t)
553
- // const t = setTimeout(() => { setChangeField('') }, 1000);
554
- // return () => { clearTimeout(t) }
555
- // }, [changeField]);
556
-
557
565
  return columns;
558
566
  };
559
567
 
@@ -578,7 +586,6 @@ class MyInput extends React.Component<InputProps & { loading?: boolean }> {
578
586
  }
579
587
 
580
588
  class MyDiv extends React.Component<{ value?: any, loading?: boolean }> {
581
-
582
589
  render() {
583
590
  if (this.props.loading) {
584
591
  return (
@@ -645,4 +652,4 @@ function ucoding(v: string): string {
645
652
  /** 解码 */
646
653
  function dcoding(v: string): string {
647
654
  return v.split('U').map(e => e ? String.fromCharCode(parseInt(e.replace('E', ''))) : '').join('');
648
- }
655
+ }
@@ -0,0 +1,3 @@
1
+ .kts-invoice-operate-goods-list-itemName-drag {
2
+ cursor: all-scroll;
3
+ }
@@ -0,0 +1,49 @@
1
+
2
+ import React from "react";
3
+ import Icon from '@ant-design/icons';
4
+ import { ReactComponent as I001Svg } from './svg/I001.svg';
5
+ import { Button } from "kts-components-antd-x3";
6
+ import { IGood, Invoice } from '../../../../../../../..';
7
+ import './index.less';
8
+
9
+
10
+ export interface IDragProps {
11
+ record: IGood
12
+ }
13
+
14
+ export default function Drag(props: IDragProps) {
15
+
16
+ const { record } = props;
17
+
18
+ const controller = Invoice.useInvoiceController();
19
+
20
+ const editGood = controller.useMemo(s => s.goodsListState.editGood, []);
21
+
22
+ const current = controller.useMemo(s => s.goodsListState.drag.current, []);
23
+
24
+ const disabled = React.useMemo(() => !!editGood, [editGood]);
25
+
26
+ const onMouseDown = React.useCallback(() => {
27
+ if (!controller || !record) return;
28
+ controller.run(async s => s.goodsListState.drag.current = record.$index);
29
+ window.addEventListener('mouseup', onMouseup);
30
+
31
+ function onMouseup() {
32
+ controller.run(async s => s.goodsListState.drag.current = undefined);
33
+ window.removeEventListener('mouseup', onMouseup);
34
+ }
35
+ }, [controller, record])
36
+
37
+ return (
38
+ <Button
39
+ type='link'
40
+ style={{ padding: 0 }}
41
+ disabled={disabled}
42
+ onMouseDown={onMouseDown}
43
+ onClick={e => { e.stopPropagation() }}
44
+ className={"kts-invoice-operate-goods-list-itemName-drag"}
45
+ >
46
+ <Icon component={I001Svg} />
47
+ </Button>
48
+ )
49
+ }
@@ -0,0 +1 @@
1
+ <svg t="1694426134787" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4024" width="200" height="200"><path d="M304.87387614-5.81530905h123.75785957v123.75785958H304.87387614V-5.81530905z m281.27727647 0h123.75785836v123.75785958h-123.75785836V-5.81530905zM304.87387614 286.75034075h123.75785957v123.75785835H304.87387614V286.75034075z m281.27727647 0h123.75785836v123.75785835h-123.75785836V286.75034075zM304.87387614 579.21242666h123.75785957v123.75785957H304.87387614v-123.75785957z m281.27727647 0h123.75785836v123.75785957h-123.75785836v-123.75785957zM304.87387614 871.82985838h123.75785957v123.75785837H304.87387614v-123.75785837z m281.27727647 0h123.75785836v123.75785837h-123.75785836v-123.75785837z" p-id="4025"></path></svg>
@@ -0,0 +1,18 @@
1
+ .kts-invoice-operate-goods-list-itemCode-input {
2
+ display : flex;
3
+ flex : 1;
4
+ padding-left: 10px;
5
+ height : 31px;
6
+
7
+ .ktsAntX-select {
8
+ width: 100%;
9
+
10
+ .ktsAntX-select-selector{
11
+ height: 100%;
12
+ }
13
+ }
14
+ }
15
+
16
+ .has-error .kts-invoice-operate-goods-list-itemCode-input {
17
+ border: 1px solid #f5222d;
18
+ }
@@ -0,0 +1,45 @@
1
+
2
+ import { Input } from 'kts-components-antd-x3';
3
+ import React, { ChangeEvent } from 'react';
4
+ import { AutoComplete } from 'kts-xui';
5
+ import { IGood, Invoice } from '../../../../../../../..';
6
+ import './index.less';
7
+
8
+ export default function ItemCodeInput(props: { onChange?: (e: ChangeEvent<HTMLInputElement>) => void, value?: string, shorthand?: string }) {
9
+
10
+ const controller = Invoice.useInvoiceController();
11
+
12
+ const autoComplete = controller.useMemo(s => s.autoComplete, [])
13
+
14
+ const [options, setOptions] = React.useState<IGood[]>([])
15
+
16
+ const onChange = React.useCallback((e: ChangeEvent<HTMLInputElement>) => {
17
+ const event = { ...e };
18
+ props.onChange && props.onChange(event);
19
+ }, [])
20
+
21
+ const onSearch = React.useCallback(async (searchText: string) => {
22
+ try {
23
+ if (autoComplete.onItemCodeSearch) {
24
+ setOptions(await autoComplete.onItemCodeSearch(searchText))
25
+ }
26
+ } catch (error) {
27
+ setOptions([])
28
+ throw error;
29
+ }
30
+ }, [autoComplete.onItemCodeSearch])
31
+
32
+ const onChangeAutoComplete = React.useCallback(itemName => {
33
+ const record = options.filter(e => e.itemCode === itemName)[0] as any;
34
+ if (!record) return;
35
+ }, [options, controller])
36
+
37
+ return (
38
+ <div className='kts-invoice-operate-goods-list-itemCode-input'>
39
+ {props.shorthand && <span style={{ alignSelf: 'center', fontSize: 12 }} >*{props.shorthand}*</span>}
40
+ <AutoComplete onSearch={onSearch} options={options.map(e => ({ value: e.itemCode }))} onChange={onChangeAutoComplete} >
41
+ <Input style={{ height: '100%', border: 'none' }} value={props.value} onChange={onChange} />
42
+ </AutoComplete>
43
+ </div>
44
+ )
45
+ }
@@ -8,7 +8,7 @@ export default function useMergeDetails() {
8
8
 
9
9
  const controller = Invoice.useInvoiceController();
10
10
 
11
- const goodsList = controller.useMemo(s => s.goodsListState.goodsList, []);
11
+ const selectedGoodIndex = controller.useMemo(s => s.goodsListState.selectedGoodIndex, []);
12
12
 
13
13
  const isMergeDetails = controller.useMemo(s => s.goodsListState.isMergeDetails, []);
14
14
 
@@ -23,15 +23,15 @@ export default function useMergeDetails() {
23
23
  return (
24
24
  <Button
25
25
  onClick={onClick}
26
- disabled={goodsList.length <= 1}
26
+ disabled={selectedGoodIndex.length <= 1}
27
27
  >
28
28
  合并明细
29
29
  </Button>
30
30
  )
31
- }, [goodsList.length])
31
+ }, [selectedGoodIndex.length])
32
32
 
33
33
  return {
34
34
  /** 按钮 */
35
35
  button,
36
36
  }
37
- }
37
+ }
@@ -14,12 +14,7 @@ import Invoice from "../../../../Invoice";
14
14
  import './index.less';
15
15
 
16
16
  const RULES = {
17
- companyNameBySpecial: (label: string) => [
18
- { required: true, message: `${label}必填` },
19
- { max: 300, message: `${label}内容超长` },
20
- { pattern: /^([A-Za-z()\u4e00-\u9fa5])*$/g, message: `${label}仅能中文、英文、括号` }
21
- ],
22
- companyNameByNormal: (label: string) => [
17
+ companyName: (label: string) => [
23
18
  { required: true, message: `${label}必填` },
24
19
  { max: 200, message: `${label}内容超长` }
25
20
  ],
@@ -120,9 +115,7 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
120
115
  <Col span={24} >
121
116
  <Form.Item label='名称' colon={false}>
122
117
  {getFieldDecorator('buyerName', {
123
- rules: getRules('buyerName', isVatNormal ?
124
- RULES.companyNameByNormal('购买方名称') :
125
- RULES.companyNameBySpecial('购买方名称')),
118
+ rules: getRules('buyerName', RULES.companyName('购买方名称')),
126
119
  })(
127
120
  <BuyerNameInput
128
121
  myform={form}
@@ -224,7 +217,7 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
224
217
  <Col span={24} >
225
218
  <Form.Item label='名称' colon={false}>
226
219
  {getFieldDecorator('supplierName', {
227
- rules: getRules('supplierName', RULES.companyNameBySpecial('销售方名称')),
220
+ rules: getRules('supplierName', RULES.companyName('销售方名称')),
228
221
  getValueFromEvent: formatCompanyName
229
222
  })(<MyInput readOnly={isReadOnly('supplierName')} placeholder="请输入" autoComplete="off" />)}
230
223
  </Form.Item>
@@ -353,4 +346,4 @@ class Discontinue {
353
346
  clearTimeout(Discontinue.timer);
354
347
  Discontinue.timer = setTimeout(resolve, interval);
355
348
  })
356
- }
349
+ }