kts-component-invoice-operate 3.2.78 → 3.2.80

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 +379 -44
  9. package/dist/index.js +375 -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 +123 -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 +178 -0
  20. package/src/TaxClassificationCodeModal/index.less +0 -0
  21. package/src/TaxClassificationCodeModal/index.md +6 -0
  22. package/src/TaxClassificationCodeModal/index.tsx +67 -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,117 @@ 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
+ if(value){
302
+ const arr = await controller.state.goodsListState.endowCode.onSearchTaxClassificationCode(value?.target?.value);
303
+ const list: any[] = arr.map((item: any)=> {
304
+ return {
305
+ ...item,
306
+ title: `${item.productName} ${item.taxCategoryCode}`,
307
+ key: item.taxCategoryCode,
308
+ isLeaf: true
309
+ }
310
+ });
311
+ setList(list);
312
+ } else {
313
+ await onLoad();
314
+ }
315
+ }, []);
316
+
317
+ const onLoad = React.useCallback(async (value?: any) => {
318
+ const arr = await controller.state.goodsListState.endowCode.onLoadTaxClassificationCode(value?.taxCategoryCode);
319
+ const data: any[] = arr.map((item: any)=> {
320
+ return {
321
+ ...item,
322
+ title: `${item.productName} ${item.taxCategoryCode}`,
323
+ key: item.taxCategoryCode
324
+ }
325
+ });
326
+
327
+ const treeData = optimizeTreeData(data);
328
+
329
+ if(value?.key) {
330
+ setList((origin: any)=> {
331
+ updateTreeData(origin, value.key, treeData)
332
+ });
333
+ } else {
334
+ setList(treeData);
335
+ }
336
+ return [];
337
+ }, []);
338
+
339
+ const onClick = React.useCallback(async () => {
340
+ await onLoad();
341
+ setOpen(true);
342
+ }, []);
343
+
344
+ const onSelect = React.useCallback((key: any, info: any) => {
345
+ actions.setFieldState('taxClassificationCode', async s => {
346
+ s.value = info.node.taxCategoryCode
347
+ });
348
+
349
+ actions.setFieldState('productName', async (s) => {
350
+ s.value = info.node.productName
351
+ });
352
+
353
+ actions.setFieldState('shorthand', async (s) => {
354
+ s.value = info.node.shorthand
355
+ });
356
+ actions.setFieldState('taxRate', async s => {
357
+ s.value = info.node.taxRate
358
+ });
359
+ setOpen(false);
360
+ }, [controller, actions]);
361
+
362
+ const optimizeTreeData = (data: any): any => {
363
+ return data.map((item: any)=> {
364
+ return {
365
+ ...item,
366
+ selectable: item?.hzx === 'N',
367
+ isLeaf: item?.hzx === 'N'
368
+ }
369
+ });
370
+ }
371
+
372
+ const updateTreeData = (list: any, key: React.Key, children: any): any => {
373
+ return list.map((node: any) => {
374
+ if (node.key === key) {
375
+ return {
376
+ ...node,
377
+ children
378
+ };
379
+ }
380
+ if (node.children) {
381
+ return {
382
+ ...node,
383
+ children: updateTreeData(node.children, key, children)
384
+ };
385
+ }
386
+ return node;
387
+ });
388
+ }
389
+
390
+ return (
391
+ <>
392
+ <InputAntd readOnly onClick={onClick} value={props.value} />
393
+ <TaxClassificationCodeModal
394
+ list={list}
395
+ open={open}
396
+ onSelect={onSelect}
397
+ onCancel={()=> {setOpen(false)}}
398
+ onSearch={onSearch}
399
+ onLoad={onLoad}
400
+ />
401
+ </>
402
+ )
403
+ }, [controller])
404
+
291
405
  // 是否享受优惠政策
292
406
  const [favouredPolicyMark, setFavouredPolicyMark] = React.useState<number>(0);
293
407
 
@@ -351,7 +465,7 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
351
465
  }, [controller]);
352
466
 
353
467
  return (
354
- <SchemaForm actions={actions} previewPlaceholder=" " components={{ ...components, showSearch: !!controller.state.goodsListState.endowCode.getTaxCategoryCodeTree ? ShowSearch2 : ShowSearch }} effects={effects}>
468
+ <SchemaForm actions={actions} previewPlaceholder=" " components={{ ...components, showSearch: !!controller.state.goodsListState.endowCode.onLoadTaxClassificationCode() ? ShowSearch3 : ShowSearch }} effects={effects}>
355
469
  <FormButtonGroup>
356
470
  <Field
357
471
  name="taxClassificationCode"
@@ -361,6 +475,13 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
361
475
  default={defaultValue?.taxClassificationCode}
362
476
  x-rules={[{ message: '请选择税收分类编码', required: true }]}
363
477
  />
478
+ <Field
479
+ name="productName"
480
+ type="string"
481
+ readOnly
482
+ default={defaultValue?.productName}
483
+ title="税收分类名称"
484
+ />
364
485
  <Field
365
486
  name="shorthand"
366
487
  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,178 @@
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 updateTreeData = (list: any, key: React.Key, children: any): any => {
13
+ const demo = list.map((node: any) => {
14
+ if (node.key === key) {
15
+ return {
16
+ ...node,
17
+ children,
18
+ };
19
+ }
20
+ if (node.children) {
21
+ return {
22
+ ...node,
23
+ children: updateTreeData(node.children, key, children),
24
+ };
25
+ }
26
+ return node;
27
+ });
28
+ setList(demo);
29
+ }
30
+
31
+ const onSearch = React.useCallback(async (value: any = null) => {
32
+ const arr = [
33
+ {
34
+ "id": "3a4eae5278cd428f975d4da278fd18eb",
35
+ "taxCategoryCode": "3000000000000000000",
36
+ "productName": "销售服务",
37
+ "shorthand": "销售服务",
38
+ "specification": null,
39
+ "createTime": "Tue Jun 20 14:56:46 CST 2023",
40
+ "status": 1,
41
+ "versionCode": "48.0",
42
+ "version": "32.0",
43
+ "startTime": "20190401",
44
+ "endTime": null,
45
+ "cargo": null,
46
+ "desc": null,
47
+ "taxRate": "13",
48
+ "keyword": "",
49
+ "summarizedItem": "Y",
50
+ "countCode": null,
51
+ "customsItem": null,
52
+ "updateTime": "Tue Jun 20 14:56:46 CST 2023"
53
+ },
54
+ {
55
+ "id": "3a4eae5278cd428f975d4da278fd18eb",
56
+ "taxCategoryCode": "410000000000000000",
57
+ "productName": "手机服务",
58
+ "shorthand": "手机服务",
59
+ "specification": null,
60
+ "createTime": "Tue Jun 20 14:56:46 CST 2023",
61
+ "status": 1,
62
+ "versionCode": "48.0",
63
+ "version": "32.0",
64
+ "startTime": "20190401",
65
+ "endTime": null,
66
+ "cargo": null,
67
+ "desc": null,
68
+ "taxRate": "13",
69
+ "keyword": "",
70
+ "summarizedItem": "Y",
71
+ "countCode": null,
72
+ "customsItem": null,
73
+ "updateTime": "Tue Jun 20 14:56:46 CST 2023"
74
+ }
75
+ ];
76
+ const list: any[] = arr.map((item: any)=> {
77
+ const data = {
78
+ ...item,
79
+ title: `${item.productName} ${item.taxCategoryCode}`,
80
+ key: item.taxCategoryCode,
81
+ }
82
+ if(value?.target?.value) {
83
+ data.isLeaf = true;
84
+ } else {
85
+ data.selectable = false
86
+ }
87
+ return data
88
+ });
89
+ setList(list);
90
+ }, []);
91
+
92
+ const onLoad = React.useCallback(async (value?: any) => {
93
+ const arr = [
94
+ {
95
+ "id": "3a4eae5278cd428f975d4da278fd18eb",
96
+ "taxCategoryCode": "00000100000000000000",
97
+ "productName": "子任务1",
98
+ "shorthand": "销售服务",
99
+ "specification": null,
100
+ "createTime": "Tue Jun 20 14:56:46 CST 2023",
101
+ "status": 1,
102
+ "versionCode": "48.0",
103
+ "version": "32.0",
104
+ "startTime": "20190401",
105
+ "endTime": null,
106
+ "cargo": null,
107
+ "desc": null,
108
+ "taxRate": "13",
109
+ "keyword": "",
110
+ "summarizedItem": "Y",
111
+ "countCode": null,
112
+ "customsItem": null,
113
+ "updateTime": "Tue Jun 20 14:56:46 CST 2023"
114
+ },
115
+ {
116
+ "id": "3a4eae5278cd428f975d4da278fd18eb",
117
+ "taxCategoryCode": "000002000000000000",
118
+ "productName": "子任务2",
119
+ "shorthand": "手机服务",
120
+ "specification": null,
121
+ "createTime": "Tue Jun 20 14:56:46 CST 2023",
122
+ "status": 1,
123
+ "versionCode": "48.0",
124
+ "version": "32.0",
125
+ "startTime": "20190401",
126
+ "endTime": null,
127
+ "cargo": null,
128
+ "desc": null,
129
+ "taxRate": "13",
130
+ "keyword": "",
131
+ "summarizedItem": "Y",
132
+ "countCode": null,
133
+ "customsItem": null,
134
+ "updateTime": "Tue Jun 20 14:56:46 CST 2023"
135
+ }
136
+ ];
137
+ const data: any[] = arr.map((item: any)=> {
138
+ return {
139
+ ...item,
140
+ title: `${item.productName} ${item.taxCategoryCode}`,
141
+ key: item.taxCategoryCode,
142
+ selectable: false
143
+ }
144
+ });
145
+
146
+ if(value?.key) {
147
+ setList((origin: any)=> {
148
+ updateTreeData(origin, value.key, data)
149
+ });
150
+ } else {
151
+ setList(data);
152
+ }
153
+ return [];
154
+ }, []);
155
+
156
+ const onClick = React.useCallback(async () => {
157
+ await onLoad();
158
+ setOpen(true);
159
+ }, []);
160
+
161
+ const onSelect = React.useCallback((key: any, info: any) => {
162
+ setOpen(false);
163
+ }, []);
164
+
165
+ return (
166
+ <>
167
+ <Button onClick={onClick} >打开</Button>
168
+ <TaxClassificationCodeModal
169
+ list={list}
170
+ open={open}
171
+ onSelect={onSelect}
172
+ onCancel={()=> {setOpen(false)}}
173
+ onSearch={onSearch}
174
+ onLoad={onLoad}
175
+ />
176
+ </>
177
+ )
178
+ };
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,67 @@
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
+ setTimeout(()=> {
34
+ form.resetFields();
35
+ }, 500)
36
+ }
37
+ }, [form, props.open])
38
+
39
+ return (
40
+ <Drawer
41
+ title="商品和服务税收分类编码"
42
+ placement="right"
43
+ open={props.open}
44
+ width={503}
45
+ onClose={props.onCancel}
46
+ >
47
+ <Form
48
+ form={form}
49
+ >
50
+ <Form.Item name='search'>
51
+ <Input
52
+ placeholder="请输入税收分类编码、税收分类名称进行检索"
53
+ onChange={props.onSearch}
54
+ />
55
+ </Form.Item>
56
+ <Form.Item name='tree'>
57
+ <Tree
58
+ onSelect={props.onSelect}
59
+ loadData={props.onLoad}
60
+ treeData={props.list}
61
+ switcherIcon={<Icon type="down" />}
62
+ />
63
+ </Form.Item>
64
+ </Form>
65
+ </Drawer>
66
+ )
67
+ }
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';