kts-component-invoice-operate 3.2.78 → 3.2.79

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 (23) hide show
  1. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/EndowCode/index.d.ts +8 -0
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.d.ts +2 -0
  3. package/dist/Invoice/InvoiceController/InvoiceControllerState/Stakeholder/index.d.ts +2 -0
  4. package/dist/Invoice/InvoiceController/InvoiceControllerState/index.d.ts +5 -0
  5. package/dist/TaxClassificationCodeModal/_test/easiest/index.d.ts +3 -0
  6. package/dist/TaxClassificationCodeModal/index.d.ts +16 -0
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.esm.js +365 -44
  9. package/dist/index.js +361 -39
  10. package/package.json +1 -1
  11. package/src/Invoice/Invoice-digtal/_test/readOnly/index.tsx +4 -3
  12. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/EndowCode/index.tsx +15 -5
  13. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +3 -0
  14. package/src/Invoice/InvoiceController/InvoiceControllerState/Stakeholder/index.ts +3 -0
  15. package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +9 -4
  16. package/src/Invoice/ui/default/EndowCodeDrawer/index.tsx +112 -2
  17. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +1 -1
  18. package/src/Invoice/ui/digtal/Sign/index.tsx +11 -1
  19. package/src/TaxClassificationCodeModal/_test/easiest/index.tsx +176 -0
  20. package/src/TaxClassificationCodeModal/index.less +0 -0
  21. package/src/TaxClassificationCodeModal/index.md +6 -0
  22. package/src/TaxClassificationCodeModal/index.tsx +63 -0
  23. package/src/index.ts +3 -0
@@ -2,19 +2,20 @@ import GoodsListState from './GoodsListState';
2
2
  import BuyerState from './BuyerState';
3
3
  import Stakeholder from './Stakeholder';
4
4
  import { IInvoiceTypeModalProps } from '../../../InvoiceTypeModal';
5
+ import { TaxClassificationProps } from '../../../TaxClassificationCodeModal';
5
6
  import AutoComplete from './AutoComplete';
6
7
 
7
8
  export default class InvoiceControllerState {
8
9
 
9
- /**
10
- * 组件模式
10
+ /**
11
+ * 组件模式
11
12
  * prefab 预制
12
13
  * readOnly 只读
13
14
  * */
14
15
  model: 'default' | 'prefab' | 'readOnly' = 'default';
15
16
 
16
- /**
17
- * 企业类型
17
+ /**
18
+ * 企业类型
18
19
  * 01 一般纳税人
19
20
  * 05 转登记纳税人
20
21
  * 04 代开企业
@@ -57,4 +58,8 @@ export default class InvoiceControllerState {
57
58
 
58
59
  /** 自动补全 */
59
60
  autoComplete = new AutoComplete();
61
+ /**
62
+ * 商品税收分类编码窗口
63
+ * */
64
+ taxClassificationProps?: TaxClassificationProps;
60
65
  }
@@ -16,6 +16,7 @@ import {
16
16
  FormEffectHooks,
17
17
  } from '@formily/antd';
18
18
  import './index.less';
19
+ import TaxClassificationCodeModal from "../../../../TaxClassificationCodeModal";
19
20
 
20
21
  const { TreeNode } = Tree;
21
22
  const { confirm } = Modal;
@@ -86,9 +87,11 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
86
87
 
87
88
  const actions = React.useMemo(() => createAsyncFormActions(), []);
88
89
 
90
+ const taxClassificationProps = controller.useMemo(s => s.taxClassificationProps, []);
91
+
89
92
  /** 免税类型 是否需要 */
90
93
  const isTaxFreeTypeNeeded = controller.useMemo(s => s.goodsListState.endowCode.isTaxFreeTypeNeeded, []);
91
-
94
+
92
95
  /** 税率 是否禁用 */
93
96
  const readOnlyTaxRate = controller.useMemo(s => {
94
97
  if (s.goodsListState.endowCode.getReadOnlyTaxRate) {
@@ -288,6 +291,106 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
288
291
  )
289
292
  }, [controller, actions])
290
293
 
294
+ /** 税收分类编码 选择组件3 */
295
+ const ShowSearch3 = React.useCallback(props => {
296
+ const [open, setOpen] = React.useState(false);
297
+
298
+ const [list, setList] = React.useState<any>([]);
299
+
300
+ const onSearch = React.useCallback(async (value: any = null) => {
301
+ const arr = await controller.state.goodsListState.endowCode.onSearchTaxClassificationCode(value?.target?.value);
302
+ const list: any[] = arr.map((item: any)=> {
303
+ const data = {
304
+ ...item,
305
+ title: `${item.productName} ${item.taxCategoryCode}`,
306
+ key: item.taxCategoryCode,
307
+ }
308
+ if(value?.target?.value) {
309
+ data.isLeaf = true;
310
+ } else {
311
+ data.selectable = false
312
+ }
313
+ return data
314
+ });
315
+ setList(list);
316
+ }, []);
317
+
318
+ const onClick = React.useCallback(async () => {
319
+ await onSearch();
320
+ setOpen(true);
321
+ }, []);
322
+
323
+ const onSelect = React.useCallback((key: any, info: any) => {
324
+ actions.setFieldState('taxClassificationCode', async s => {
325
+ s.value = info.node.taxCategoryCode
326
+ });
327
+
328
+ actions.setFieldState('productName', async (s) => {
329
+ s.value = info.node.productName
330
+ });
331
+
332
+ actions.setFieldState('shorthand', async (s) => {
333
+ s.value = info.node.shorthand
334
+ });
335
+ actions.setFieldState('taxRate', async s => {
336
+ s.value = info.node.taxRate
337
+ });
338
+ setOpen(false);
339
+ }, [controller, actions]);
340
+
341
+ const updateTreeData = (list: any, key: React.Key, children: any): any => {
342
+ const demo = list.map((node: any) => {
343
+ if (node.key === key) {
344
+ return {
345
+ ...node,
346
+ children,
347
+ };
348
+ }
349
+ if (node.children) {
350
+ return {
351
+ ...node,
352
+ children: updateTreeData(node.children, key, children),
353
+ };
354
+ }
355
+ return node;
356
+ });
357
+ setList(demo);
358
+ }
359
+
360
+ const onLoad = React.useCallback(async (value: any) => {
361
+ if (value.children) {
362
+ return [];
363
+ }
364
+ const arr = await controller.state.goodsListState.endowCode.onLoadTaxClassificationCode(value.taxCategoryCode);
365
+ const data: any[] = arr.map((item: any)=> {
366
+ return {
367
+ ...item,
368
+ title: `${item.productName} ${item.taxCategoryCode}`,
369
+ key: item.taxCategoryCode
370
+ }
371
+ });
372
+
373
+ setList((origin: any)=> {
374
+ updateTreeData(origin, value.key, data)
375
+ });
376
+ return [];
377
+ }, []);
378
+
379
+ return (
380
+ <>
381
+ <InputAntd readOnly onClick={onClick} value={props.value} />
382
+ <TaxClassificationCodeModal
383
+ list={list}
384
+ open={open}
385
+ onSelect={onSelect}
386
+ onCancel={()=> {setOpen(false)}}
387
+ onSearch={onSearch}
388
+ onLoad={onLoad}
389
+ />
390
+ </>
391
+ )
392
+ }, [controller])
393
+
291
394
  // 是否享受优惠政策
292
395
  const [favouredPolicyMark, setFavouredPolicyMark] = React.useState<number>(0);
293
396
 
@@ -351,7 +454,7 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
351
454
  }, [controller]);
352
455
 
353
456
  return (
354
- <SchemaForm actions={actions} previewPlaceholder=" " components={{ ...components, showSearch: !!controller.state.goodsListState.endowCode.getTaxCategoryCodeTree ? ShowSearch2 : ShowSearch }} effects={effects}>
457
+ <SchemaForm actions={actions} previewPlaceholder=" " components={{ ...components, showSearch: !!controller.state.goodsListState.endowCode.onSearchTaxClassificationCode() ? ShowSearch3 : ShowSearch }} effects={effects}>
355
458
  <FormButtonGroup>
356
459
  <Field
357
460
  name="taxClassificationCode"
@@ -361,6 +464,13 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
361
464
  default={defaultValue?.taxClassificationCode}
362
465
  x-rules={[{ message: '请选择税收分类编码', required: true }]}
363
466
  />
467
+ <Field
468
+ name="productName"
469
+ type="string"
470
+ readOnly
471
+ default={defaultValue?.productName}
472
+ title="税收分类名称"
473
+ />
364
474
  <Field
365
475
  name="shorthand"
366
476
  type="string"
@@ -477,7 +477,7 @@ export default (form: WrappedFormUtils) => {
477
477
  dataIndex: 'taxRate',
478
478
  key: 'taxRate',
479
479
  align: 'right',
480
- width: 70,
480
+ width: 75,
481
481
  render: (value: string, record: IGood) => {
482
482
  if (editGood?.$index === record.$index) {
483
483
  return (
@@ -27,12 +27,18 @@ export default decorator<IBuyerProps, IBuyerProps & FormComponentProps>(Form.cre
27
27
 
28
28
  const model = controller.useMemo(s => s.model, []);
29
29
 
30
+ /** 禁用字段 */
30
31
  const disableds = controller.useMemo(s => s.stakeholder.disableds || [], []);
31
32
 
33
+ /** 启用字段 */
34
+ const enables = controller.useMemo(s => s.stakeholder.enables || [], []);
35
+
32
36
  const readOnly = React.useMemo(() => model === 'readOnly', [model]);
33
37
 
34
38
  const isReadOnly = React.useCallback(field => disableds.indexOf(field) >= 0, [disableds])
35
39
 
40
+ const isEnables = React.useCallback(field => enables.indexOf(field) >= 0, [enables])
41
+
36
42
  // 注册 form
37
43
  controller.useForm('sign', form);
38
44
 
@@ -47,7 +53,11 @@ export default decorator<IBuyerProps, IBuyerProps & FormComponentProps>(Form.cre
47
53
  <div>
48
54
  {getFieldDecorator('remarks', {
49
55
  initialValue: props.defaultRemark
50
- })(<MyDiv />)}
56
+ })(
57
+ isEnables('remarks')
58
+ ? <Input.TextArea placeholder='请输入' style={{ height: '100%' }} />
59
+ : <MyDiv />
60
+ )}
51
61
  </div>
52
62
  </div>
53
63
  <Form layout='inline' className='digtal-readOnly-form' >
@@ -0,0 +1,176 @@
1
+ import React from 'react';
2
+ import { TaxClassificationModal } from '../../..';
3
+ import { Button } from 'kts-xui';
4
+ import TaxClassificationCodeModal from "@/TaxClassificationCodeModal";
5
+
6
+ export default () => {
7
+
8
+ const [open, setOpen] = React.useState(false);
9
+
10
+ const [list, setList] = React.useState<any>([]);
11
+
12
+ const onSearch = React.useCallback(async (value: any = null) => {
13
+ const arr = [
14
+ {
15
+ "id": "3a4eae5278cd428f975d4da278fd18eb",
16
+ "taxCategoryCode": "3000000000000000000",
17
+ "productName": "销售服务",
18
+ "shorthand": "销售服务",
19
+ "specification": null,
20
+ "createTime": "Tue Jun 20 14:56:46 CST 2023",
21
+ "status": 1,
22
+ "versionCode": "48.0",
23
+ "version": "32.0",
24
+ "startTime": "20190401",
25
+ "endTime": null,
26
+ "cargo": null,
27
+ "desc": null,
28
+ "taxRate": "13",
29
+ "keyword": "",
30
+ "summarizedItem": "Y",
31
+ "countCode": null,
32
+ "customsItem": null,
33
+ "updateTime": "Tue Jun 20 14:56:46 CST 2023"
34
+ },
35
+ {
36
+ "id": "3a4eae5278cd428f975d4da278fd18eb",
37
+ "taxCategoryCode": "410000000000000000",
38
+ "productName": "手机服务",
39
+ "shorthand": "手机服务",
40
+ "specification": null,
41
+ "createTime": "Tue Jun 20 14:56:46 CST 2023",
42
+ "status": 1,
43
+ "versionCode": "48.0",
44
+ "version": "32.0",
45
+ "startTime": "20190401",
46
+ "endTime": null,
47
+ "cargo": null,
48
+ "desc": null,
49
+ "taxRate": "13",
50
+ "keyword": "",
51
+ "summarizedItem": "Y",
52
+ "countCode": null,
53
+ "customsItem": null,
54
+ "updateTime": "Tue Jun 20 14:56:46 CST 2023"
55
+ }
56
+ ];
57
+ const list: any[] = arr.map((item: any)=> {
58
+ const data = {
59
+ ...item,
60
+ title: `${item.productName} ${item.taxCategoryCode}`,
61
+ key: item.taxCategoryCode,
62
+ }
63
+ if(value?.target?.value) {
64
+ data.isLeaf = true;
65
+ } else {
66
+ data.selectable = false
67
+ }
68
+ return data
69
+ });
70
+ setList(list);
71
+ }, []);
72
+
73
+ const onClick = React.useCallback(async () => {
74
+ await onSearch();
75
+ setOpen(true);
76
+ }, []);
77
+
78
+ const onSelect = React.useCallback((key: any, info: any) => {
79
+ setOpen(false);
80
+ }, []);
81
+
82
+ const updateTreeData = (list: any, key: React.Key, children: any): any => {
83
+ const demo = list.map((node: any) => {
84
+ if (node.key === key) {
85
+ return {
86
+ ...node,
87
+ children,
88
+ };
89
+ }
90
+ if (node.children) {
91
+ return {
92
+ ...node,
93
+ children: updateTreeData(node.children, key, children),
94
+ };
95
+ }
96
+ return node;
97
+ });
98
+ setList(demo);
99
+ }
100
+
101
+ const onLoad = React.useCallback(async (value: any) => {
102
+ if (value.children) {
103
+ return [];
104
+ }
105
+ const arr = [
106
+ {
107
+ "id": "3a4eae5278cd428f975d4da278fd18eb",
108
+ "taxCategoryCode": "00000100000000000000",
109
+ "productName": "子任务1",
110
+ "shorthand": "销售服务",
111
+ "specification": null,
112
+ "createTime": "Tue Jun 20 14:56:46 CST 2023",
113
+ "status": 1,
114
+ "versionCode": "48.0",
115
+ "version": "32.0",
116
+ "startTime": "20190401",
117
+ "endTime": null,
118
+ "cargo": null,
119
+ "desc": null,
120
+ "taxRate": "13",
121
+ "keyword": "",
122
+ "summarizedItem": "Y",
123
+ "countCode": null,
124
+ "customsItem": null,
125
+ "updateTime": "Tue Jun 20 14:56:46 CST 2023"
126
+ },
127
+ {
128
+ "id": "3a4eae5278cd428f975d4da278fd18eb",
129
+ "taxCategoryCode": "000002000000000000",
130
+ "productName": "子任务2",
131
+ "shorthand": "手机服务",
132
+ "specification": null,
133
+ "createTime": "Tue Jun 20 14:56:46 CST 2023",
134
+ "status": 1,
135
+ "versionCode": "48.0",
136
+ "version": "32.0",
137
+ "startTime": "20190401",
138
+ "endTime": null,
139
+ "cargo": null,
140
+ "desc": null,
141
+ "taxRate": "13",
142
+ "keyword": "",
143
+ "summarizedItem": "Y",
144
+ "countCode": null,
145
+ "customsItem": null,
146
+ "updateTime": "Tue Jun 20 14:56:46 CST 2023"
147
+ }
148
+ ];
149
+ const data: any[] = arr.map((item: any)=> {
150
+ return {
151
+ ...item,
152
+ title: `${item.productName} ${item.taxCategoryCode}`,
153
+ key: item.taxCategoryCode
154
+ }
155
+ });
156
+
157
+ setList((origin: any)=> {
158
+ updateTreeData(origin, value.key, data)
159
+ });
160
+ return [];
161
+ }, []);
162
+
163
+ return (
164
+ <>
165
+ <Button onClick={onClick} >打开</Button>
166
+ <TaxClassificationCodeModal
167
+ list={list}
168
+ open={open}
169
+ onSelect={onSelect}
170
+ onCancel={()=> {setOpen(false)}}
171
+ onSearch={onSearch}
172
+ onLoad={onLoad}
173
+ />
174
+ </>
175
+ )
176
+ };
File without changes
@@ -0,0 +1,6 @@
1
+ # TaxClassificationCodeModal
2
+
3
+ ## 简单用法
4
+ <code src="./_test/easiest/index.tsx" ></code>
5
+
6
+ <API name="API" exports='["default"]' src="./index.tsx" ></API>
@@ -0,0 +1,63 @@
1
+
2
+ import React from "react";
3
+ import { Drawer, Input, Tree, Form } from "kts-xui";
4
+ import { Icon } from "kts-components-antd-x3";
5
+ import {IFormValues} from "@/InvoiceTypeModal";
6
+
7
+ export interface TaxClassificationProps {
8
+
9
+ /** 是否开启 */
10
+ open?: boolean;
11
+
12
+ /** 数据 */
13
+ list?: any[];
14
+
15
+ /** 点击了取消 */
16
+ onCancel?: () => void;
17
+
18
+ /** 点击了选择 */
19
+ onSelect?: (key: any, info: any) => void;
20
+
21
+ /** 点击了加载 */
22
+ onLoad: (value: any) => Promise<any[]>;
23
+
24
+ /** 点击了搜索 */
25
+ onSearch?: (value?: any) => void;
26
+ }
27
+
28
+ export default function TaxClassificationModal(props: TaxClassificationProps) {
29
+ const [form] = Form.useForm<IFormValues>();
30
+
31
+ React.useEffect(() => {
32
+ if (!props.open) {
33
+ form.resetFields();
34
+ }
35
+ }, [form, props.open])
36
+
37
+ return (
38
+ <Drawer
39
+ title="商品和服务税收分类编码"
40
+ placement="right"
41
+ open={props.open}
42
+ width={503}
43
+ onClose={props.onCancel}
44
+ >
45
+ <Form
46
+ form={form}
47
+ >
48
+ <Form.Item name='search'>
49
+ <Input
50
+ placeholder="请输入税收分类编码、税收分类名称进行检索"
51
+ onChange={props.onSearch}
52
+ />
53
+ </Form.Item>
54
+ <Tree
55
+ onSelect={props.onSelect}
56
+ loadData={props.onLoad}
57
+ treeData={props.list}
58
+ switcherIcon={<Icon type="down" />}
59
+ />
60
+ </Form>
61
+ </Drawer>
62
+ )
63
+ }
package/src/index.ts CHANGED
@@ -7,3 +7,6 @@ export type { default as IGood } from './Invoice/InvoiceController/InvoiceContro
7
7
 
8
8
  export { default as InvoiceTypeModal } from './InvoiceTypeModal';
9
9
  export type { IInvoiceTypeModalProps } from './InvoiceTypeModal';
10
+
11
+ export { default as TaxClassificationModal } from './TaxClassificationCodeModal';
12
+ export type { TaxClassificationProps } from './TaxClassificationCodeModal';