kts-components-document-access-point 1.4.2 → 1.4.5

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 (123) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +4 -4
  3. package/.prettierignore +7 -7
  4. package/.prettierrc +11 -11
  5. package/.umirc.ts +11 -11
  6. package/README.md +3 -3
  7. package/dist/index.esm.js +28 -8
  8. package/dist/index.js +28 -8
  9. package/docs/index.md +3 -3
  10. package/index.html +12 -12
  11. package/package.json +56 -56
  12. package/src/DocumentWhiteList/___demo___/base/index.tsx +7 -7
  13. package/src/DocumentWhiteList/___demo___/setService/index.tsx +23 -23
  14. package/src/DocumentWhiteList/control/actions/addblack/index.ts +14 -14
  15. package/src/DocumentWhiteList/control/actions/addwhite/index.ts +14 -14
  16. package/src/DocumentWhiteList/control/actions/blacklist/index.ts +22 -22
  17. package/src/DocumentWhiteList/control/actions/checkclient/index.ts +14 -14
  18. package/src/DocumentWhiteList/control/actions/demo/index.ts +4 -4
  19. package/src/DocumentWhiteList/control/actions/didilist/index.ts +18 -18
  20. package/src/DocumentWhiteList/control/actions/enableblacklist/index.ts +17 -17
  21. package/src/DocumentWhiteList/control/actions/enablelist/index.ts +18 -18
  22. package/src/DocumentWhiteList/control/actions/enablewhitelist/index.ts +17 -17
  23. package/src/DocumentWhiteList/control/actions/getmode/index.ts +14 -14
  24. package/src/DocumentWhiteList/control/actions/setmode/index.ts +14 -14
  25. package/src/DocumentWhiteList/control/actions/synclist/index.ts +19 -19
  26. package/src/DocumentWhiteList/control/actions/whitelist/index.ts +22 -22
  27. package/src/DocumentWhiteList/control/index.tsx +42 -42
  28. package/src/DocumentWhiteList/control/state/index.ts +47 -47
  29. package/src/DocumentWhiteList/index.md +5 -5
  30. package/src/DocumentWhiteList/index.tsx +40 -40
  31. package/src/DocumentWhiteList/interface/index.ts +30 -30
  32. package/src/DocumentWhiteList/ui/clientmodal/index.tsx +190 -190
  33. package/src/DocumentWhiteList/ui/main/black.tsx +132 -132
  34. package/src/DocumentWhiteList/ui/main/index.tsx +49 -49
  35. package/src/DocumentWhiteList/ui/main/switchmode.tsx +52 -52
  36. package/src/DocumentWhiteList/ui/main/white.tsx +120 -120
  37. package/src/DocumentWhiteList/ui/pageheader/BlackHeader.tsx +143 -143
  38. package/src/DocumentWhiteList/ui/pageheader/WhiteHeader.tsx +152 -152
  39. package/src/DocumentWhiteList/ui/pageui/index.tsx +64 -64
  40. package/src/DocumentWhiteList/ui/whitemodal/index.tsx +146 -146
  41. package/src/DocumentWhiteList/util/ConfigEnum.ts +8 -8
  42. package/src/DocumentsCont/___demo___/base/index.tsx +7 -7
  43. package/src/DocumentsCont/___demo___/setService/index.tsx +25 -25
  44. package/src/DocumentsCont/index.md +9 -9
  45. package/src/DocumentsCont/index.tsx +54 -51
  46. package/src/DocumentsDemo/Controller/index.tsx +14 -14
  47. package/src/DocumentsDemo/Controller/whitelist.ts +22 -22
  48. package/src/DocumentsDemo/Text.tsx +22 -22
  49. package/src/DocumentsDemo/___demo___/base/index.tsx +7 -7
  50. package/src/DocumentsDemo/index.md +6 -6
  51. package/src/DocumentsDemo/index.tsx +38 -38
  52. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/IProperties/index.ts +69 -69
  53. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/IRules/index.ts +18 -18
  54. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/ISchema/index.ts +14 -14
  55. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/PropertyTableState/index.ts +12 -12
  56. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/RuleState/index.ts +336 -336
  57. package/src/DocumentsEdit/DocumentsEditController/DocumentsEditControllerState/index.ts +51 -51
  58. package/src/DocumentsEdit/DocumentsEditController/actions/addProperties/index.ts +37 -37
  59. package/src/DocumentsEdit/DocumentsEditController/actions/delProperties/index.ts +48 -48
  60. package/src/DocumentsEdit/DocumentsEditController/actions/editProperties/index.ts +93 -79
  61. package/src/DocumentsEdit/DocumentsEditController/index.tsx +21 -21
  62. package/src/DocumentsEdit/___demo___/conventional/index.tsx +10 -10
  63. package/src/DocumentsEdit/___demo___/monitor/index.tsx +1421 -1421
  64. package/src/DocumentsEdit/___demo___/readOnly/index.tsx +16 -16
  65. package/src/DocumentsEdit/constant/propertyColumns/index.tsx +65 -65
  66. package/src/DocumentsEdit/index.less +45 -45
  67. package/src/DocumentsEdit/index.md +10 -10
  68. package/src/DocumentsEdit/index.tsx +117 -117
  69. package/src/DocumentsEdit/tools/index.ts +88 -88
  70. package/src/DocumentsEdit/ui/AddPropertyButton/index.tsx +238 -238
  71. package/src/DocumentsEdit/ui/Breadcrumb/index.tsx +51 -51
  72. package/src/DocumentsEdit/ui/EditProperty/index.tsx +290 -290
  73. package/src/DocumentsEdit/ui/EditRule/index.tsx +156 -156
  74. package/src/DocumentsEdit/ui/EditRule/ui/AddRuleButton/index.tsx +49 -49
  75. package/src/DocumentsEdit/ui/EditRule/ui/DelRuleButton/index.tsx +31 -31
  76. package/src/DocumentsEdit/ui/EditRule/ui/RuleForm/fn/algorithmFormComponent/index.tsx +142 -142
  77. package/src/DocumentsEdit/ui/EditRule/ui/RuleForm/index.tsx +154 -154
  78. package/src/DocumentsEdit/ui/PropertyTable/hooks/useTableProps/index.less +4 -4
  79. package/src/DocumentsEdit/ui/PropertyTable/hooks/useTableProps/index.tsx +70 -70
  80. package/src/DocumentsEdit/ui/PropertyTable/hooks/useTableProps/ui/AddChildPropertyButton/index.tsx +34 -34
  81. package/src/DocumentsEdit/ui/PropertyTable/hooks/useTableProps/ui/AddRuleButton/index.tsx +64 -64
  82. package/src/DocumentsEdit/ui/PropertyTable/hooks/useTableProps/ui/EditPropertyButton/index.tsx +31 -31
  83. package/src/DocumentsEdit/ui/PropertyTable/index.less +19 -19
  84. package/src/DocumentsEdit/ui/PropertyTable/index.tsx +18 -18
  85. package/src/DocumentsEdit/ui/RefPropertyButton/index.tsx +121 -121
  86. package/src/DocumentsList/DocumentsListController/DocumentsListControllerState/index.ts +55 -55
  87. package/src/DocumentsList/DocumentsListController/actions/demo/index.ts +4 -4
  88. package/src/DocumentsList/DocumentsListController/actions/typelist/index.ts +15 -15
  89. package/src/DocumentsList/DocumentsListController/index.tsx +16 -16
  90. package/src/DocumentsList/___demo___/list/index.tsx +4 -4
  91. package/src/DocumentsList/index.less +22 -22
  92. package/src/DocumentsList/index.md +3 -3
  93. package/src/DocumentsList/index.tsx +46 -46
  94. package/src/DocumentsList/ui/ModalComfirm/index.tsx +94 -92
  95. package/src/DocumentsList/ui/PageHeader/SendHeader.tsx +230 -230
  96. package/src/DocumentsList/ui/PageHeader/index.tsx +325 -325
  97. package/src/DocumentsList/ui/PageUI/index.tsx +65 -65
  98. package/src/DocumentsList/ui/RuleTable/index.tsx +163 -163
  99. package/src/DocumentsList/ui/sendlist/index.tsx +151 -151
  100. package/src/DocumentsList/util/ConfigEnum.ts +11 -11
  101. package/src/DocumentsRule/control/actions/batchsend/index.ts +13 -13
  102. package/src/DocumentsRule/control/actions/configsave/index.ts +14 -14
  103. package/src/DocumentsRule/control/actions/configupdate/index.ts +13 -13
  104. package/src/DocumentsRule/control/actions/getconfigbyid/index.ts +14 -14
  105. package/src/DocumentsRule/control/actions/getrecordbyid/index.ts +14 -14
  106. package/src/DocumentsRule/control/actions/gettemplate/index.ts +15 -15
  107. package/src/DocumentsRule/control/actions/listbysubjectid/index.ts +13 -13
  108. package/src/DocumentsRule/control/actions/typelist/index.ts +13 -13
  109. package/src/DocumentsRule/control/index.tsx +30 -30
  110. package/src/DocumentsRule/control/state/index.ts +42 -42
  111. package/src/DocumentsRule/index.md +1 -1
  112. package/src/DocumentsRule/index.tsx +25 -25
  113. package/src/DocumentsRule/interface/index.ts +28 -28
  114. package/src/DocumentsRule/ui/main/index.tsx +362 -362
  115. package/src/DocumentsService/index.ts +18 -18
  116. package/src/index.ts +9 -9
  117. package/tsconfig.json +29 -29
  118. package/typings.d.ts +3 -3
  119. package/docs-dist/404.html +0 -38
  120. package/docs-dist/index.html +0 -38
  121. package/docs-dist/static/icon.050945f2.svg +0 -1
  122. package/docs-dist/umi.css +0 -11
  123. package/docs-dist/umi.js +0 -1
@@ -1,93 +1,95 @@
1
- import React, { useCallback, useState, useEffect, useMemo } from 'react';
2
- import { Radio, message, Tooltip } from 'kts-components-antd-x4';
3
- import { Modal } from 'kts-xui';
4
- import Main from '../../';
5
- import { useHistory } from 'react-router-dom';
6
- import { DocumentsService } from "../../../";
7
- //发布弹框
8
- export default function modalcomfirm(props: any) {
9
- const selectItems = props.list;
10
- const history = useHistory();
11
- const controller = Main.useController();
12
- const targetId = controller.useMemo(s => s.targetId, [])
13
- const [targetList, setTargetList] = useState<any[]>([]);
14
- useEffect(() => {
15
- (async () => {
16
- const res = await DocumentsService.instance.service?.call({ url: '/participant/listBySubjectId', data: {}, type: 'get' }) as any;
17
- if (res.res) {
18
- setTargetList(res.res);
19
- }
20
- })()
21
- }, []);
22
- const handleCancel = useCallback(() => {
23
- props.handleCancel();
24
- }, [])
25
- const handleOk = useCallback(() => {
26
- (async () => {
27
- const note = targetList.find(item => item.participantId === targetId)
28
- const data = selectItems.map((item: any) => {
29
- return {
30
- ...item,
31
- senderParticipantId: targetId,
32
- privateList: [],
33
- sendPublic: true,
34
- senderParticipantNote: note && note.remarkName
35
- };
36
- });
37
- const res = await DocumentsService.instance.service?.call({ url: '/schema/config/batchSend', data: data, type: 'post' }) as any;
38
- if (res.res) {
39
- gotoSendlist();
40
- message.success('操作成功');
41
- props.handleCancel()
42
- }
43
- })()
44
- }, [targetId,targetList]);
45
- const gotoSendlist = useCallback(() => {
46
- controller.pipeline(async s => {
47
- s.type = 2;
48
- if (selectItems.length === 1) {
49
- s.params = { configNumber: selectItems[0].configNumber }
50
- s.selectedRowKey=[];
51
- }
52
- history.push({ pathname: `/rulelist`, state: { type: 2 } })
53
- })()
54
- }, []);
55
- const targetSelect = useCallback((e) => {
56
-
57
- controller.pipeline(async s => {
58
- s.targetId = e.target.value;
59
- })()
60
- }, []);
61
- const radioStyle = useMemo(() => {
62
- return {
63
- alignItems: 'center',
64
- marginBottom: 10,
65
- lineHeight: 1.2
66
- };
67
- }, [])
68
- return (
69
- <div>
70
- <Modal
71
- title="请选择我司对应DID"
72
- visible={true}
73
- onOk={handleOk}
74
- onCancel={handleCancel}
75
- >
76
- <Radio.Group onChange={targetSelect} value={targetId} >
77
- {
78
- targetList.map((item: any, key) => {
79
- return <Radio style={radioStyle as any} key={key} value={item.participantId} >
80
-
81
- <div style={{ display: 'flex', flexDirection: 'column', alignContent: 'flex-start' }}>
82
- <span>{item.remarkName}</span>
83
- <span style={{ maxWidth: 460, overflow: 'hidden', textOverflow: 'ellipsis', display: 'block' }}>{item.participantId}</span>
84
- </div>
85
- </Radio>
86
- })
87
- }
88
- </Radio.Group>
89
- </Modal>
90
- </div>
91
-
92
- );
1
+ import React, { useCallback, useState, useEffect, useMemo } from 'react';
2
+ import { Radio, message, Tooltip } from 'kts-components-antd-x4';
3
+ import { Modal } from 'kts-xui';
4
+ import Main from '../../';
5
+ import { useHistory } from 'react-router-dom';
6
+ import { DocumentsService } from "../../../";
7
+ //发布弹框
8
+ export default function modalcomfirm(props: any) {
9
+ const selectItems = props.list;
10
+ const history = useHistory();
11
+ const controller = Main.useController();
12
+ const targetId = controller.useMemo(s => s.targetId, [])
13
+ const [targetList, setTargetList] = useState<any[]>([]);
14
+ useEffect(() => {
15
+ (async () => {
16
+ const res = await DocumentsService.instance.service?.call({ url: '/participant/listBySubjectId', data: {}, type: 'get' }) as any;
17
+ if (res.res) {
18
+ setTargetList(res.res);
19
+ }
20
+ })()
21
+ }, []);
22
+ const handleCancel = useCallback(() => {
23
+ props.handleCancel();
24
+ }, [])
25
+ const handleOk = useCallback(() => {
26
+ (async () => {
27
+ const note = targetList.find(item => item.participantId === targetId)
28
+ const data = selectItems.map((item: any) => {
29
+ return {
30
+ ...item,
31
+ senderParticipantId: targetId,
32
+ privateList: [],
33
+ sendPublic: true,
34
+ senderParticipantNote: note && note.remarkName
35
+ };
36
+ });
37
+ const res = await DocumentsService.instance.service?.call({ url: '/schema/config/batchSend', data: data, type: 'post' }) as any;
38
+ if (res.res) {
39
+ gotoSendlist();
40
+ message.success('操作成功');
41
+ props.handleCancel()
42
+ }
43
+ })()
44
+ }, [targetId,targetList]);
45
+ const gotoSendlist = useCallback(() => {
46
+ controller.pipeline(async s => {
47
+ s.type = 2;
48
+ if (selectItems.length === 1) {
49
+ s.params = { configNumber: selectItems[0].configNumber }
50
+ s.selectedRowKey=[];
51
+ }
52
+ history.push({ pathname: `/rulelist`, state: { type: 2 } })
53
+ })()
54
+ }, []);
55
+ const targetSelect = useCallback((e) => {
56
+
57
+ controller.pipeline(async s => {
58
+ s.targetId = e.target.value;
59
+ })()
60
+ }, []);
61
+ const radioStyle = useMemo(() => {
62
+ return {
63
+ alignItems: 'center',
64
+ marginBottom: 10,
65
+ lineHeight: 1.2
66
+ };
67
+ }, [])
68
+ return (
69
+ <div>
70
+ <Modal
71
+ title="请选择我司对应DID"
72
+ visible={true}
73
+ onOk={handleOk}
74
+ onCancel={handleCancel}
75
+ okText="确定"
76
+ cancelText="取消"
77
+ >
78
+ <Radio.Group onChange={targetSelect} value={targetId} >
79
+ {
80
+ targetList.map((item: any, key) => {
81
+ return <Radio style={radioStyle as any} key={key} value={item.participantId} >
82
+
83
+ <div style={{ display: 'flex', flexDirection: 'column', alignContent: 'flex-start' }}>
84
+ <span>{item.remarkName}</span>
85
+ <span style={{ maxWidth: 460, overflow: 'hidden', textOverflow: 'ellipsis', display: 'block' }}>{item.participantId}</span>
86
+ </div>
87
+ </Radio>
88
+ })
89
+ }
90
+ </Radio.Group>
91
+ </Modal>
92
+ </div>
93
+
94
+ );
93
95
  }
@@ -1,230 +1,230 @@
1
- import React, { useRef, useState, useEffect, useMemo, useCallback } from 'react';
2
- import { Radio, Button, Dropdown, PageHeaderFoot } from 'kts-xui';
3
- import { Menu } from 'kts-components-antd-x4';
4
- import { AdvancedSearch, KtsForm } from 'kts-components';
5
- import { LifeCycleTypes } from '@formily/antd';
6
- import Main from '../..';
7
- import ModalComfirm from '../ModalComfirm'
8
- import { DocumentsService } from "../../..";
9
- import _ from 'lodash';
10
- import { useHistory } from 'react-router-dom';
11
- const { SubMenu } = Menu;
12
- export default () => {
13
- const history = useHistory();
14
- const controller = Main.useController();
15
- const type = controller.useMemo(s => s.type, [])
16
- const [billEnum, setBill] = useState([]);
17
- const selectedRowKey = controller.useMemo(s => s.selectedRowKey, [])
18
- const params = controller.useMemo(s => s.params, [])
19
- const visible = controller.useMemo(s => s.visible, []);
20
- const [profileEnum, setProfile] = useState([]);
21
- const [schema, setSchema] = useState({});
22
- const ktsRef = useRef(null);
23
- useEffect(() => {
24
- (async () => {
25
- const res = await DocumentsService.instance.service?.call({ url: '/schema/config/getDefaultTypeList', data: {}, type: 'get' }) as any;
26
- if (res.err) {
27
- return false;
28
- } else {
29
- const list = res.res.map((item: any) => {
30
- return { ...item, label: item.name, value: item.value }
31
- })
32
- setBill(list);
33
- }
34
- })()
35
- }, []);
36
- const onSearchFormSubmit = React.useCallback((value) => {
37
- value = {
38
- ...value,
39
- typeList: value['typeList'] && [value['typeList']]
40
- }
41
- controller.pipeline(async s => {
42
- s.params = value;
43
- })()
44
- }, [controller])
45
-
46
- const switchType = React.useCallback((e) => {
47
- controller.pipeline(async s => {
48
- s.type = e.target.value;
49
- s.params = {}
50
- })()
51
- }, [])
52
- const handleCancel = React.useCallback(() => {
53
- controller.pipeline(async s => {
54
- s.visible = false;
55
- })()
56
- }, []);
57
- const batchSend = React.useCallback(() => {
58
- controller.pipeline(async s => {
59
- s.visible = true;
60
- })()
61
- }, [controller]);
62
- useEffect(() => {
63
- let obj: any = {
64
- type: "object",
65
- properties: {
66
- configName: {
67
- type: "string",
68
- title: "配置名称",
69
- },
70
- attributionList: {
71
- type: "string",
72
- title: "发送对象",
73
- visible: type === 2 ? true : false
74
- },
75
- type: {
76
- type: "string",
77
- title: "单据大类",
78
- enum: billEnum,
79
- },
80
- profile: {
81
- type: "string",
82
- title: "单据子类",
83
- enum: profileEnum,
84
- visible: false
85
- },
86
- attribution: {
87
- type: "radio",
88
- title: "收发角色",
89
- enum: [{
90
- "label": "发送方",
91
- "value": '1'
92
- }, {
93
- "label": "接收方",
94
- "value": '0'
95
- }],
96
- 'x-props': {
97
- mode: "multiple"
98
- }
99
- },
100
- '[beginCreateTime,endCreateTime]': {
101
- key: "[beginCreateTime,endCreateTime",
102
- name: "[beginCreateTime,endCreateTime",
103
- type: "daterange",
104
- title: "创建时间",
105
- },
106
- '[beginSendTime,endSendTime]': {
107
- key: "[beginSendTime,endSendTime",
108
- name: "[beginSendTime,endSendTime",
109
- type: "daterange",
110
- title: "更新时间",
111
- },
112
- }
113
- }
114
- setSchema(obj);
115
- }, [billEnum, type, profileEnum])
116
- const onCreateType = useCallback((category, record?) => {
117
- history.push({ pathname: `/rule`, search: `?type=config&profile=${record && record.value || ''}&billtype=${category}` })
118
- }, [])
119
- const topExpand = useCallback(() => {
120
- return (
121
- <div style={{ display: 'flex' }}>
122
- <div style={{ marginRight: 10 }}>
123
- <Radio.Group value={type} onChange={switchType}>
124
- <Radio.Button value={1}>单据校验规则配置</Radio.Button>
125
- <Radio.Button value={2}>发布记录</Radio.Button>
126
- </Radio.Group>
127
- </div>
128
- <AdvancedSearch
129
- width={480}
130
- height={44}
131
- compact={true}
132
- defaultKey="configName"
133
- placeholder="输入配置名称"
134
- searchFormSubmit={onSearchFormSubmit}
135
- >
136
- <KtsForm
137
- ref={ktsRef}
138
- labelCol={9}
139
- wrapperCol={15}
140
- labelAlign='left'
141
- compact={true}
142
- schema={schema}
143
- defaultValue={_.pick(params, ['configName', 'type', 'profile', 'attributionList', 'attribution', '[beginCreateTime,endCreateTime]', '[beginSendTime,endSendTime]'])}
144
- effects={($: any, actions: any) => {
145
- $(LifeCycleTypes.ON_FIELD_VALUE_CHANGE, 'type',).subscribe((fieldState: any) => {
146
- if (fieldState.value) {
147
- const target: any = billEnum.find((item: any) => item.value === fieldState.value);
148
- if (target && target.profileList) {
149
- actions.setFieldState('profile', (state: any) => {
150
- state.visible = true;
151
- });
152
- const list = target.profileList.map((item: any) => {
153
- return {
154
- label: item.name,
155
- value: item.value
156
- }
157
- })
158
- setProfile(list);
159
- } else {
160
- actions.setFieldState('profile', (state: any) => {
161
- state.visible = false;
162
- });
163
- setProfile([])
164
- }
165
- } else {
166
- actions.setFieldState('profile', (state: any) => {
167
- state.visible = false;
168
- });
169
- setProfile([])
170
- }
171
- });
172
- }}
173
- >
174
- </KtsForm>
175
- </AdvancedSearch>
176
-
177
- </div>
178
- );
179
- }, [type,schema]);
180
- const menu = useMemo(() => {
181
- return (
182
- <Menu>
183
- {billEnum && billEnum.map((item: any, key) => {
184
- if (item.profileList) {
185
- return (
186
- <SubMenu key={key} title={item.label}>
187
- {
188
- item.profileList.map((element: any) => {
189
- return (
190
- <Menu.Item key={element.value} onClick={() => { onCreateType(item.value, element); }}>
191
- <a >
192
- {element.name}
193
- </a>
194
- </Menu.Item>
195
- )
196
- })
197
- }
198
- </SubMenu>
199
- )
200
- } else {
201
- return (
202
- <Menu.Item key={item.value} onClick={() => { onCreateType(item.value); }}>
203
- <a >
204
- {item.label}
205
- </a>
206
- </Menu.Item>
207
- )
208
- }
209
- })}
210
-
211
- </Menu>);
212
- }, [billEnum]);
213
- return (
214
- <div style={{ flex: 'none', position: 'relative', zIndex: 1 }}>
215
- <PageHeaderFoot
216
- expandLeft={topExpand()}
217
- expandRight={[
218
- type === 1 && <Button key="1" onClick={batchSend} style={{ marginRight: 10 }}>批量发布</Button>,
219
- <Dropdown key="2" overlay={menu}>
220
- <Button type="primary" >创建配置</Button>
221
- </Dropdown>
222
- ]}
223
- >
224
- </PageHeaderFoot>
225
- {
226
- visible && <ModalComfirm handleCancel={handleCancel} list={selectedRowKey} />
227
- }
228
- </div>
229
- );
230
- };
1
+ import React, { useRef, useState, useEffect, useMemo, useCallback } from 'react';
2
+ import { Radio, Button, Dropdown, PageHeaderFoot } from 'kts-xui';
3
+ import { Menu } from 'kts-components-antd-x4';
4
+ import { AdvancedSearch, KtsForm } from 'kts-components';
5
+ import { LifeCycleTypes } from '@formily/antd';
6
+ import Main from '../..';
7
+ import ModalComfirm from '../ModalComfirm'
8
+ import { DocumentsService } from "../../..";
9
+ import _ from 'lodash';
10
+ import { useHistory } from 'react-router-dom';
11
+ const { SubMenu } = Menu;
12
+ export default () => {
13
+ const history = useHistory();
14
+ const controller = Main.useController();
15
+ const type = controller.useMemo(s => s.type, [])
16
+ const [billEnum, setBill] = useState([]);
17
+ const selectedRowKey = controller.useMemo(s => s.selectedRowKey, [])
18
+ const params = controller.useMemo(s => s.params, [])
19
+ const visible = controller.useMemo(s => s.visible, []);
20
+ const [profileEnum, setProfile] = useState([]);
21
+ const [schema, setSchema] = useState({});
22
+ const ktsRef = useRef(null);
23
+ useEffect(() => {
24
+ (async () => {
25
+ const res = await DocumentsService.instance.service?.call({ url: '/schema/config/getDefaultTypeList', data: {}, type: 'get' }) as any;
26
+ if (res.err) {
27
+ return false;
28
+ } else {
29
+ const list = res.res.map((item: any) => {
30
+ return { ...item, label: item.name, value: item.value }
31
+ })
32
+ setBill(list);
33
+ }
34
+ })()
35
+ }, []);
36
+ const onSearchFormSubmit = React.useCallback((value) => {
37
+ value = {
38
+ ...value,
39
+ typeList: value['typeList'] && [value['typeList']]
40
+ }
41
+ controller.pipeline(async s => {
42
+ s.params = value;
43
+ })()
44
+ }, [controller])
45
+
46
+ const switchType = React.useCallback((e) => {
47
+ controller.pipeline(async s => {
48
+ s.type = e.target.value;
49
+ s.params = {}
50
+ })()
51
+ }, [])
52
+ const handleCancel = React.useCallback(() => {
53
+ controller.pipeline(async s => {
54
+ s.visible = false;
55
+ })()
56
+ }, []);
57
+ const batchSend = React.useCallback(() => {
58
+ controller.pipeline(async s => {
59
+ s.visible = true;
60
+ })()
61
+ }, [controller]);
62
+ useEffect(() => {
63
+ let obj: any = {
64
+ type: "object",
65
+ properties: {
66
+ configName: {
67
+ type: "string",
68
+ title: "配置名称",
69
+ },
70
+ attributionList: {
71
+ type: "string",
72
+ title: "发送对象",
73
+ visible: type === 2 ? true : false
74
+ },
75
+ type: {
76
+ type: "string",
77
+ title: "单据大类",
78
+ enum: billEnum,
79
+ },
80
+ profile: {
81
+ type: "string",
82
+ title: "单据子类",
83
+ enum: profileEnum,
84
+ visible: false
85
+ },
86
+ attribution: {
87
+ type: "radio",
88
+ title: "收发角色",
89
+ enum: [{
90
+ "label": "发送方",
91
+ "value": '1'
92
+ }, {
93
+ "label": "接收方",
94
+ "value": '0'
95
+ }],
96
+ 'x-props': {
97
+ mode: "multiple"
98
+ }
99
+ },
100
+ '[beginCreateTime,endCreateTime]': {
101
+ key: "[beginCreateTime,endCreateTime",
102
+ name: "[beginCreateTime,endCreateTime",
103
+ type: "daterange",
104
+ title: "创建时间",
105
+ },
106
+ '[beginSendTime,endSendTime]': {
107
+ key: "[beginSendTime,endSendTime",
108
+ name: "[beginSendTime,endSendTime",
109
+ type: "daterange",
110
+ title: "更新时间",
111
+ },
112
+ }
113
+ }
114
+ setSchema(obj);
115
+ }, [billEnum, type, profileEnum])
116
+ const onCreateType = useCallback((category, record?) => {
117
+ history.push({ pathname: `/rule`, search: `?type=config&profile=${record && record.value || ''}&billtype=${category}` })
118
+ }, [])
119
+ const topExpand = useCallback(() => {
120
+ return (
121
+ <div style={{ display: 'flex' }}>
122
+ <div style={{ marginRight: 10 }}>
123
+ <Radio.Group value={type} onChange={switchType}>
124
+ <Radio.Button value={1}>单据校验规则配置</Radio.Button>
125
+ <Radio.Button value={2}>发布记录</Radio.Button>
126
+ </Radio.Group>
127
+ </div>
128
+ <AdvancedSearch
129
+ width={480}
130
+ height={44}
131
+ compact={true}
132
+ defaultKey="configName"
133
+ placeholder="输入配置名称"
134
+ searchFormSubmit={onSearchFormSubmit}
135
+ >
136
+ <KtsForm
137
+ ref={ktsRef}
138
+ labelCol={9}
139
+ wrapperCol={15}
140
+ labelAlign='left'
141
+ compact={true}
142
+ schema={schema}
143
+ defaultValue={_.pick(params, ['configName', 'type', 'profile', 'attributionList', 'attribution', '[beginCreateTime,endCreateTime]', '[beginSendTime,endSendTime]'])}
144
+ effects={($: any, actions: any) => {
145
+ $(LifeCycleTypes.ON_FIELD_VALUE_CHANGE, 'type',).subscribe((fieldState: any) => {
146
+ if (fieldState.value) {
147
+ const target: any = billEnum.find((item: any) => item.value === fieldState.value);
148
+ if (target && target.profileList) {
149
+ actions.setFieldState('profile', (state: any) => {
150
+ state.visible = true;
151
+ });
152
+ const list = target.profileList.map((item: any) => {
153
+ return {
154
+ label: item.name,
155
+ value: item.value
156
+ }
157
+ })
158
+ setProfile(list);
159
+ } else {
160
+ actions.setFieldState('profile', (state: any) => {
161
+ state.visible = false;
162
+ });
163
+ setProfile([])
164
+ }
165
+ } else {
166
+ actions.setFieldState('profile', (state: any) => {
167
+ state.visible = false;
168
+ });
169
+ setProfile([])
170
+ }
171
+ });
172
+ }}
173
+ >
174
+ </KtsForm>
175
+ </AdvancedSearch>
176
+
177
+ </div>
178
+ );
179
+ }, [type,schema]);
180
+ const menu = useMemo(() => {
181
+ return (
182
+ <Menu>
183
+ {billEnum && billEnum.map((item: any, key) => {
184
+ if (item.profileList) {
185
+ return (
186
+ <SubMenu key={key} title={item.label}>
187
+ {
188
+ item.profileList.map((element: any) => {
189
+ return (
190
+ <Menu.Item key={element.value} onClick={() => { onCreateType(item.value, element); }}>
191
+ <a >
192
+ {element.name}
193
+ </a>
194
+ </Menu.Item>
195
+ )
196
+ })
197
+ }
198
+ </SubMenu>
199
+ )
200
+ } else {
201
+ return (
202
+ <Menu.Item key={item.value} onClick={() => { onCreateType(item.value); }}>
203
+ <a >
204
+ {item.label}
205
+ </a>
206
+ </Menu.Item>
207
+ )
208
+ }
209
+ })}
210
+
211
+ </Menu>);
212
+ }, [billEnum]);
213
+ return (
214
+ <div style={{ flex: 'none', position: 'relative', zIndex: 1 }}>
215
+ <PageHeaderFoot
216
+ expandLeft={topExpand()}
217
+ expandRight={[
218
+ type === 1 && <Button key="1" onClick={batchSend} style={{ marginRight: 10 }}>批量发布</Button>,
219
+ <Dropdown key="2" overlay={menu}>
220
+ <Button type="primary" >创建配置</Button>
221
+ </Dropdown>
222
+ ]}
223
+ >
224
+ </PageHeaderFoot>
225
+ {
226
+ visible && <ModalComfirm handleCancel={handleCancel} list={selectedRowKey} />
227
+ }
228
+ </div>
229
+ );
230
+ };