@jiangood/open-admin 1.0.0-beta.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 (186) hide show
  1. package/config/common-plugin.js +94 -0
  2. package/config/config.js +58 -0
  3. package/config/utils.js +73 -0
  4. package/package.json +42 -0
  5. package/src/.umi-production/appData.json +2365 -0
  6. package/src/.umi-production/core/EmptyRoute.tsx +9 -0
  7. package/src/.umi-production/core/defineApp.ts +16 -0
  8. package/src/.umi-production/core/helmet.ts +10 -0
  9. package/src/.umi-production/core/helmetContext.ts +4 -0
  10. package/src/.umi-production/core/history.ts +72 -0
  11. package/src/.umi-production/core/historyIntelli.ts +132 -0
  12. package/src/.umi-production/core/plugin.ts +40 -0
  13. package/src/.umi-production/core/pluginConfig.ts +324 -0
  14. package/src/.umi-production/core/pluginConfigJoi.d.ts +7 -0
  15. package/src/.umi-production/core/polyfill.ts +220 -0
  16. package/src/.umi-production/core/route.tsx +54 -0
  17. package/src/.umi-production/core/routeProps.js +5 -0
  18. package/src/.umi-production/core/routeProps.ts +6 -0
  19. package/src/.umi-production/core/terminal.ts +37 -0
  20. package/src/.umi-production/exports.ts +17 -0
  21. package/src/.umi-production/testBrowser.tsx +90 -0
  22. package/src/.umi-production/tsconfig.json +44 -0
  23. package/src/.umi-production/typings.d.ts +136 -0
  24. package/src/.umi-production/umi.ts +83 -0
  25. package/src/framework/components/DownloadFileButton/index.d.ts +11 -0
  26. package/src/framework/components/DownloadFileButton/index.jsx +33 -0
  27. package/src/framework/components/Gap/index.d.ts +23 -0
  28. package/src/framework/components/Gap/index.jsx +46 -0
  29. package/src/framework/components/LinkButton/index.d.ts +14 -0
  30. package/src/framework/components/LinkButton/index.jsx +10 -0
  31. package/src/framework/components/NamedIcon/index.d.ts +5 -0
  32. package/src/framework/components/NamedIcon/index.jsx +11 -0
  33. package/src/framework/components/OrgTree/index.d.ts +4 -0
  34. package/src/framework/components/OrgTree/index.jsx +58 -0
  35. package/src/framework/components/Page/index.d.ts +17 -0
  36. package/src/framework/components/Page/index.jsx +30 -0
  37. package/src/framework/components/Page/index.less +10 -0
  38. package/src/framework/components/PageLoading/index.d.ts +1 -0
  39. package/src/framework/components/PageLoading/index.jsx +25 -0
  40. package/src/framework/components/ProModal/index.tsx +66 -0
  41. package/src/framework/components/ProTable/components/ToolBar/index.jsx +123 -0
  42. package/src/framework/components/ProTable/components/ToolBar/index.less +53 -0
  43. package/src/framework/components/ProTable/index.d.ts +42 -0
  44. package/src/framework/components/ProTable/index.jsx +260 -0
  45. package/src/framework/components/ProTable/index.less +14 -0
  46. package/src/framework/components/ProTable/utils/index.js +43 -0
  47. package/src/framework/components/RoleTree/index.d.ts +4 -0
  48. package/src/framework/components/RoleTree/index.jsx +50 -0
  49. package/src/framework/components/ValueType/index.jsx +34 -0
  50. package/src/framework/components/ValueType/registry.jsx +26 -0
  51. package/src/framework/components/ViewRange/index.d.ts +14 -0
  52. package/src/framework/components/ViewRange/index.jsx +20 -0
  53. package/src/framework/components/index.ts +13 -0
  54. package/src/framework/components/system/ButtonList.d.ts +8 -0
  55. package/src/framework/components/system/ButtonList.jsx +42 -0
  56. package/src/framework/components/system/HasPerm.tsx +14 -0
  57. package/src/framework/components/system/index.tsx +29 -0
  58. package/src/framework/fields/FieldBoolean/index.d.ts +9 -0
  59. package/src/framework/fields/FieldBoolean/index.jsx +73 -0
  60. package/src/framework/fields/FieldDate/index.d.ts +23 -0
  61. package/src/framework/fields/FieldDate/index.jsx +116 -0
  62. package/src/framework/fields/FieldDateRange/index.d.ts +22 -0
  63. package/src/framework/fields/FieldDateRange/index.jsx +103 -0
  64. package/src/framework/fields/FieldDictSelect/index.d.ts +12 -0
  65. package/src/framework/fields/FieldDictSelect/index.jsx +16 -0
  66. package/src/framework/fields/FieldEditor/index.d.ts +14 -0
  67. package/src/framework/fields/FieldEditor/index.jsx +59 -0
  68. package/src/framework/fields/FieldNumberRange/index.d.ts +10 -0
  69. package/src/framework/fields/FieldNumberRange/index.jsx +55 -0
  70. package/src/framework/fields/FieldPercent/index.d.ts +8 -0
  71. package/src/framework/fields/FieldPercent/index.jsx +30 -0
  72. package/src/framework/fields/FieldRemoteSelect/index.d.ts +44 -0
  73. package/src/framework/fields/FieldRemoteSelect/index.jsx +125 -0
  74. package/src/framework/fields/FieldRemoteSelectMultiple/index.d.ts +20 -0
  75. package/src/framework/fields/FieldRemoteSelectMultiple/index.jsx +85 -0
  76. package/src/framework/fields/FieldRemoteSelectMultipleInline/index.d.ts +21 -0
  77. package/src/framework/fields/FieldRemoteSelectMultipleInline/index.jsx +88 -0
  78. package/src/framework/fields/FieldRemoteTree/index.d.ts +20 -0
  79. package/src/framework/fields/FieldRemoteTree/index.jsx +50 -0
  80. package/src/framework/fields/FieldRemoteTreeCascader/index.d.ts +18 -0
  81. package/src/framework/fields/FieldRemoteTreeCascader/index.jsx +59 -0
  82. package/src/framework/fields/FieldRemoteTreeSelect/index.d.ts +19 -0
  83. package/src/framework/fields/FieldRemoteTreeSelect/index.jsx +57 -0
  84. package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.d.ts +20 -0
  85. package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.jsx +62 -0
  86. package/src/framework/fields/FieldSysOrgTree/index.d.ts +9 -0
  87. package/src/framework/fields/FieldSysOrgTree/index.jsx +20 -0
  88. package/src/framework/fields/FieldSysOrgTreeSelect/index.d.ts +9 -0
  89. package/src/framework/fields/FieldSysOrgTreeSelect/index.jsx +22 -0
  90. package/src/framework/fields/FieldTable/index.d.ts +14 -0
  91. package/src/framework/fields/FieldTable/index.jsx +108 -0
  92. package/src/framework/fields/FieldTable/styles.less +29 -0
  93. package/src/framework/fields/FieldTableSelect/index.d.ts +19 -0
  94. package/src/framework/fields/FieldTableSelect/index.jsx +60 -0
  95. package/src/framework/fields/FieldUploadFile/index.d.ts +31 -0
  96. package/src/framework/fields/FieldUploadFile/index.jsx +139 -0
  97. package/src/framework/fields/index.ts +22 -0
  98. package/src/framework/fields/types.ts +16 -0
  99. package/src/framework/index.ts +5 -0
  100. package/src/framework/pages/LoginPage.d.ts +16 -0
  101. package/src/framework/pages/LoginPage.jsx +135 -0
  102. package/src/framework/pages/LoginPage.less +53 -0
  103. package/src/framework/pages/LoginPageUtils.ts +36 -0
  104. package/src/framework/pages/index.ts +2 -0
  105. package/src/framework/utils/ArrUtils.ts +229 -0
  106. package/src/framework/utils/ColorsUtils.ts +378 -0
  107. package/src/framework/utils/DateUtils.ts +187 -0
  108. package/src/framework/utils/DeviceUtils.ts +46 -0
  109. package/src/framework/utils/DomUtils.ts +50 -0
  110. package/src/framework/utils/EventBusUtils.ts +144 -0
  111. package/src/framework/utils/Logger.ts +40 -0
  112. package/src/framework/utils/MessageUtils.tsx +170 -0
  113. package/src/framework/utils/ObjectUtils.ts +118 -0
  114. package/src/framework/utils/StorageUtils.ts +50 -0
  115. package/src/framework/utils/StringUtils.ts +436 -0
  116. package/src/framework/utils/TreeUtils.ts +251 -0
  117. package/src/framework/utils/UrlUtils.ts +152 -0
  118. package/src/framework/utils/UuidUtils.ts +88 -0
  119. package/src/framework/utils/ValidateUtils.ts +28 -0
  120. package/src/framework/utils/index.ts +15 -0
  121. package/src/framework/utils/system/DictUtils.ts +97 -0
  122. package/src/framework/utils/system/FormRegistryUtils.ts +77 -0
  123. package/src/framework/utils/system/HttpUtils.ts +247 -0
  124. package/src/framework/utils/system/PageUtils.ts +163 -0
  125. package/src/framework/utils/system/PermUtils.ts +79 -0
  126. package/src/framework/utils/system/SysUtils.ts +97 -0
  127. package/src/framework/utils/system/ThemeUtils.ts +27 -0
  128. package/src/framework/utils/system/index.ts +7 -0
  129. package/src/framework/views/ViewApproveStatus/index.d.ts +3 -0
  130. package/src/framework/views/ViewApproveStatus/index.jsx +21 -0
  131. package/src/framework/views/ViewBoolean/index.d.ts +3 -0
  132. package/src/framework/views/ViewBoolean/index.jsx +4 -0
  133. package/src/framework/views/ViewBooleanEnableDisable/index.d.ts +5 -0
  134. package/src/framework/views/ViewBooleanEnableDisable/index.jsx +15 -0
  135. package/src/framework/views/ViewFile/index.d.ts +10 -0
  136. package/src/framework/views/ViewFile/index.jsx +49 -0
  137. package/src/framework/views/ViewFileButton/index.d.ts +10 -0
  138. package/src/framework/views/ViewFileButton/index.jsx +22 -0
  139. package/src/framework/views/ViewImage/index.d.ts +6 -0
  140. package/src/framework/views/ViewImage/index.jsx +60 -0
  141. package/src/framework/views/ViewPassword/index.d.ts +5 -0
  142. package/src/framework/views/ViewPassword/index.jsx +24 -0
  143. package/src/framework/views/ViewProcessInstanceProgress/index.d.ts +12 -0
  144. package/src/framework/views/ViewProcessInstanceProgress/index.jsx +97 -0
  145. package/src/framework/views/ViewProcessInstanceProgressButton/index.d.ts +6 -0
  146. package/src/framework/views/ViewProcessInstanceProgressButton/index.jsx +24 -0
  147. package/src/framework/views/ViewText/index.d.ts +16 -0
  148. package/src/framework/views/ViewText/index.jsx +42 -0
  149. package/src/framework/views/index.ts +12 -0
  150. package/src/framework/views/types.ts +26 -0
  151. package/src/index.ts +2 -0
  152. package/src/layouts/PageRender.d.ts +22 -0
  153. package/src/layouts/PageRender.jsx +90 -0
  154. package/src/layouts/admin/HeaderRight.jsx +104 -0
  155. package/src/layouts/admin/TabPageRender.jsx +158 -0
  156. package/src/layouts/admin/index.jsx +159 -0
  157. package/src/layouts/admin/index.less +65 -0
  158. package/src/layouts/index.jsx +187 -0
  159. package/src/layouts/index.less +24 -0
  160. package/src/loading.jsx +18 -0
  161. package/src/pages/404.jsx +13 -0
  162. package/src/pages/about.jsx +12 -0
  163. package/src/pages/index.jsx +10 -0
  164. package/src/pages/login.jsx +16 -0
  165. package/src/pages/system/api/ApiDoc.jsx +148 -0
  166. package/src/pages/system/api/index.jsx +267 -0
  167. package/src/pages/system/api/perm.jsx +69 -0
  168. package/src/pages/system/dict/Dict.jsx +67 -0
  169. package/src/pages/system/dict/DictItem.jsx +175 -0
  170. package/src/pages/system/dict/index.jsx +25 -0
  171. package/src/pages/system/file/index.jsx +147 -0
  172. package/src/pages/system/job/index.jsx +324 -0
  173. package/src/pages/system/log/index.jsx +77 -0
  174. package/src/pages/system/org/index.jsx +260 -0
  175. package/src/pages/system/role/index.jsx +302 -0
  176. package/src/pages/system/role/perm.jsx +107 -0
  177. package/src/pages/system/sysManual/index.jsx +126 -0
  178. package/src/pages/system/user/UserPerm.jsx +94 -0
  179. package/src/pages/system/user/index.jsx +253 -0
  180. package/src/pages/test/views.jsx +95 -0
  181. package/src/pages/ureport/index.jsx +16 -0
  182. package/src/pages/userCenter/ChangePassword.jsx +64 -0
  183. package/src/pages/userCenter/index.jsx +90 -0
  184. package/src/pages/userCenter/manual.jsx +57 -0
  185. package/src/pages/userCenter/message.jsx +103 -0
  186. package/src/style/global.less +51 -0
@@ -0,0 +1,175 @@
1
+ import {PlusOutlined} from '@ant-design/icons'
2
+ import {Button, Col, Form, Input, InputNumber, Modal, Popconfirm, Row, Tag} from 'antd'
3
+ import React from 'react'
4
+
5
+ import {ButtonList, FieldBoolean, HttpUtils, ProTable} from '../../../framework'
6
+
7
+
8
+ export default class extends React.Component {
9
+
10
+ state = {
11
+ formValues: {},
12
+ formOpen: false
13
+ }
14
+
15
+ formRef = React.createRef()
16
+ tableRef = React.createRef()
17
+
18
+ componentDidUpdate(prevProps, prevState, snapshot) {
19
+ if (prevProps.sysDictId !== this.props.sysDictId) {
20
+ this.tableRef.current.reload()
21
+ }
22
+ }
23
+
24
+ handleAdd = () => {
25
+ this.setState({formOpen: true, formValues: {}})
26
+ }
27
+
28
+ handleEdit = record => {
29
+ this.setState({formOpen: true, formValues: record})
30
+ }
31
+
32
+ onFinish = values => {
33
+ values.sysDict = {id: this.props.sysDictId}
34
+ HttpUtils.post('admin/sysDictItem/save', values).then(rs => {
35
+ this.setState({formOpen: false})
36
+ this.tableRef.current.reload()
37
+ })
38
+ }
39
+
40
+ handleDelete = row => {
41
+ HttpUtils.get('admin/sysDictItem/delete', row).then(rs => {
42
+ this.tableRef.current.reload()
43
+ })
44
+ }
45
+
46
+ columns = [
47
+ {
48
+ title: '文本',
49
+ dataIndex: 'text',
50
+ },
51
+ {
52
+ title: '编码',
53
+ dataIndex: 'code',
54
+ },
55
+
56
+ {
57
+ title: '启用',
58
+ dataIndex: 'enabled',
59
+ render(v) {
60
+ return v ? '是' : '否'
61
+ }
62
+
63
+ },
64
+ {
65
+ title: '显示颜色',
66
+ dataIndex: 'color',
67
+ render(v) {
68
+ return <Tag color={v}>COLOR</Tag>
69
+ }
70
+ },
71
+ {
72
+ title: '系统内置',
73
+ dataIndex: 'builtin',
74
+ render(v) {
75
+ return v ? '是' : '否'
76
+ }
77
+
78
+ },
79
+ {
80
+ title: '序号',
81
+ dataIndex: 'seq',
82
+ },
83
+ {
84
+ title: '操作',
85
+ dataIndex: 'option',
86
+ render: (_, record) => {
87
+
88
+ return (
89
+ <ButtonList>
90
+ <Button size='small' perm='sysDict:save'
91
+ onClick={() => this.handleEdit(record)}> 编辑 </Button>
92
+ <Popconfirm perm='sysDict:delete' title='是否确定删除字典项'
93
+ onConfirm={() => this.handleDelete(record)}>
94
+ <Button size='small'>删除</Button>
95
+ </Popconfirm>
96
+ </ButtonList>
97
+ );
98
+ },
99
+ },
100
+ ]
101
+
102
+ render() {
103
+ return <>
104
+ <ProTable
105
+ headerTitle='字典项列表'
106
+ actionRef={this.tableRef}
107
+ toolBarRender={() => {
108
+ return <ButtonList>
109
+ <Button perm='sysDictItem:save' type='primary' onClick={this.handleAdd}>
110
+ <PlusOutlined/> 新增
111
+ </Button>
112
+ </ButtonList>
113
+ }}
114
+ request={(params) => {
115
+ params.sysDictId = this.props.sysDictId
116
+ return HttpUtils.get('admin/sysDictItem/page', params);
117
+ }}
118
+ columns={this.columns}
119
+ rowKey='id'
120
+ search={false}
121
+ />
122
+
123
+ <Modal
124
+ title='编辑数据字典项'
125
+ open={this.state.formOpen}
126
+ onOk={() => this.formRef.current.submit()}
127
+ onCancel={() => this.setState({formOpen: false})}
128
+ destroyOnHidden
129
+ >
130
+
131
+ <Form ref={this.formRef} labelCol={{flex: '100px'}}
132
+ initialValues={this.state.formValues}
133
+ onFinish={this.onFinish}>
134
+ <Form.Item name='id' noStyle></Form.Item>
135
+
136
+ <Row>
137
+ <Col span={12}>
138
+ <Form.Item label='编码' name='code' rules={[{required: true}]}>
139
+ <Input/>
140
+ </Form.Item>
141
+ </Col>
142
+ <Col span={12}>
143
+ <Form.Item label='文本' name='text' rules={[{required: true}]}>
144
+ <Input/>
145
+ </Form.Item>
146
+ </Col>
147
+ </Row>
148
+
149
+ <Row>
150
+ <Col span={12}>
151
+ <Form.Item label='颜色' name='color' rules={[{required: true}]}>
152
+ <Input/>
153
+ </Form.Item>
154
+ </Col>
155
+ <Col span={12}>
156
+ <Form.Item label='序号' name='seq' rules={[{required: true}]}>
157
+ <InputNumber/>
158
+ </Form.Item>
159
+ </Col>
160
+ </Row>
161
+
162
+ <Form.Item label='启用' name='enabled' rules={[{required: true}]}>
163
+ <FieldBoolean/>
164
+ </Form.Item>
165
+
166
+ </Form>
167
+ </Modal>
168
+ </>
169
+
170
+
171
+ }
172
+ }
173
+
174
+
175
+
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import Dict from "./Dict";
3
+ import DictItem from "./DictItem";
4
+ import {Splitter} from "antd";
5
+
6
+ export default class extends React.Component {
7
+
8
+ state = {
9
+ selectedKey: null
10
+ }
11
+
12
+
13
+ render() {
14
+ return <Splitter>
15
+ <Splitter.Panel defaultSize={600} style={{paddingRight: 16}}>
16
+ <Dict onChange={selectedKey => this.setState({selectedKey})}/>
17
+ </Splitter.Panel>
18
+ <Splitter.Panel style={{paddingLeft: 16}}>
19
+ <DictItem sysDictId={this.state.selectedKey}/>
20
+ </Splitter.Panel>
21
+ </Splitter>
22
+
23
+
24
+ }
25
+ }
@@ -0,0 +1,147 @@
1
+ import {Button, Form, Input, Modal, Popconfirm} from 'antd'
2
+ import React from 'react'
3
+ import {ButtonList, FieldDateRange, FieldDictSelect, FieldUploadFile, HttpUtils, ProTable} from "../../../framework";
4
+ import {CloudUploadOutlined} from "@ant-design/icons";
5
+
6
+ export default class extends React.Component {
7
+
8
+ state = {
9
+ formOpen: false,
10
+ formValues: {}
11
+ }
12
+
13
+ tableRef = React.createRef()
14
+ formRef = React.createRef()
15
+
16
+ handleDelete = row => {
17
+ HttpUtils.get('admin/sysFile/delete', row).then(rs => {
18
+ this.tableRef.current.reload()
19
+ })
20
+ }
21
+
22
+ columns = [
23
+ {
24
+ title: '原始名称',
25
+ tooltip: '上传时候的文件名',
26
+ dataIndex: 'originName',
27
+ width: 200,
28
+ },
29
+ {
30
+ title: '存储名称',
31
+ dataIndex: 'objectName',
32
+ tooltip: '文件唯一标识id'
33
+ },
34
+
35
+ {
36
+ title: '文件大小',
37
+ dataIndex: 'sizeInfo',
38
+ },
39
+
40
+ {
41
+ title: 'mime',
42
+ dataIndex: 'mimeType',
43
+ },
44
+ {
45
+ title: '扩展名',
46
+ dataIndex: 'suffix',
47
+ },
48
+
49
+ {
50
+ title: '上传时间',
51
+ dataIndex: 'createTime',
52
+ },
53
+ {
54
+ title: '上传者',
55
+ dataIndex: 'createUserLabel',
56
+ },
57
+ {
58
+ title: '预览',
59
+ dataIndex: 'id',
60
+ render(id, record) {
61
+ const nodes = [<a href={'/admin/sysFile/preview/' + record.id} target='_blank'>预览</a>]
62
+
63
+
64
+ if (record.imageUrls?.length > 0) {
65
+ for (let item of record.imageUrls) {
66
+ let url = item.url;
67
+ let label = item.label;
68
+ nodes.push(<a href={(url)} target='_blank' style={{marginLeft: 8}}>{label}</a>)
69
+ }
70
+ }
71
+
72
+ return nodes;
73
+
74
+ }
75
+ },
76
+ {
77
+ title: '操作',
78
+ dataIndex: 'option',
79
+ render: (_, record) => (
80
+ <ButtonList>
81
+ <Popconfirm perm='sysFile:delete' title='是否确定删除文件信息'
82
+ onConfirm={() => this.handleDelete(record)}>
83
+ <a>删除</a>
84
+ </Popconfirm>
85
+ </ButtonList>
86
+ ),
87
+ },
88
+ ]
89
+
90
+ render() {
91
+ return <>
92
+ <ProTable
93
+ actionRef={this.tableRef}
94
+ toolBarRender={() => {
95
+ return <Button type='primary' icon={<CloudUploadOutlined/>}
96
+ onClick={() => this.setState({formOpen: true})}>
97
+ 上传文件
98
+ </Button>
99
+ }}
100
+ request={(params) => {
101
+ return HttpUtils.get('admin/sysFile/page', params);
102
+ }}
103
+
104
+ columns={this.columns}
105
+
106
+ >
107
+ <Form.Item label='文件名' name='originName'>
108
+ <Input/>
109
+ </Form.Item>
110
+ <Form.Item label='对象名称' name='objectName'>
111
+ <Input/>
112
+ </Form.Item>
113
+ <Form.Item label='类型' name='type'>
114
+ <FieldDictSelect typeCode='materialType'/>
115
+ </Form.Item>
116
+
117
+ <Form.Item label='上传时间' name='dateRange'>
118
+ <FieldDateRange/>
119
+ </Form.Item>
120
+ </ProTable>
121
+
122
+ <Modal open={this.state.formOpen} title='上传文件'
123
+ width={800}
124
+ onCancel={() => {
125
+ this.setState({formOpen: false})
126
+ this.tableRef.current.reload()
127
+ }}
128
+ footer={null}
129
+ destroyOnHidden
130
+ >
131
+ <Form ref={this.formRef}
132
+ initialValues={this.state.formValues}
133
+ >
134
+ <Form.Item name='文件'>
135
+ <FieldUploadFile accept="*/*"/>
136
+ </Form.Item>
137
+
138
+
139
+ </Form>
140
+ </Modal>
141
+
142
+ </>
143
+ }
144
+ }
145
+
146
+
147
+
@@ -0,0 +1,324 @@
1
+ import {
2
+ Alert,
3
+ AutoComplete,
4
+ Button,
5
+ Divider,
6
+ Form,
7
+ Input,
8
+ message,
9
+ Modal,
10
+ Popconfirm,
11
+ Select,
12
+ Space,
13
+ Switch,
14
+ Tag
15
+ } from 'antd'
16
+ import React from 'react'
17
+ import {PlusOutlined} from "@ant-design/icons";
18
+ import {ButtonList, HttpUtils, Page, ProTable, StringUtils, ValueType} from "../../../framework";
19
+
20
+
21
+ const cronOptions = [
22
+ {
23
+ label: '*/5 * * * * ? 每隔5秒',
24
+ value: '*/5 * * * * ?'
25
+ },
26
+ {
27
+ label: '0 */5 * * * ? 每隔5分钟',
28
+ value: '0 */5 * * * ?'
29
+ },
30
+ {
31
+ label: '0 0 22 * * ? 每天22点',
32
+ value: '0 0 22 * * ?'
33
+ },
34
+ {
35
+ label: '0 0 1 * * ? 每天1点',
36
+ value: '0 0 1 * * ?'
37
+ },
38
+ {
39
+ label: '0 0 1 1 * ? 每月1号凌晨1点',
40
+ value: '0 0 1 1 * ?'
41
+ }
42
+ ]
43
+
44
+
45
+ export default class extends React.Component {
46
+
47
+ state = {
48
+ formValues: {},
49
+ formOpen: false,
50
+
51
+ selectedRowKeys: [],
52
+
53
+ jobClassOptions: [],
54
+
55
+ paramList: [],
56
+
57
+ statusOpen: false,
58
+ status: null,
59
+
60
+ executeRecordOpen: false,
61
+ }
62
+ tableRef = React.createRef()
63
+ formRef = React.createRef()
64
+
65
+ componentDidMount() {
66
+ HttpUtils.get('admin/job/jobClassOptions').then(rs => {
67
+ this.setState({jobClassOptions: rs})
68
+ })
69
+ }
70
+
71
+ handleAdd = () => {
72
+ this.setState({formOpen: true, formValues: {}, paramList: []})
73
+ }
74
+
75
+ handleEdit = (record) => {
76
+ this.loadJobParamFields(record.jobClass, record.jobData)
77
+ this.setState({formOpen: true, formValues: record,})
78
+ }
79
+
80
+ loadJobParamFields(className, jobData) {
81
+ HttpUtils.post("admin/job/getJobParamFields", jobData || {}, {className}).then(rs => {
82
+ this.setState({paramList: rs})
83
+ })
84
+ }
85
+
86
+ onFinish = (values) => {
87
+ HttpUtils.post('admin/job/save', values).then(rs => {
88
+ this.setState({formOpen: false})
89
+ this.tableRef.current.reload();
90
+ })
91
+ }
92
+
93
+ handleDelete = row => {
94
+ const hide = message.loading("删除作业中...")
95
+ HttpUtils.get('admin/job/delete', {id: row.id}).then(rs => {
96
+ this.tableRef.current.reload();
97
+ }).catch(hide)
98
+ }
99
+
100
+ handleTriggerJob = row => {
101
+ HttpUtils.get('admin/job/triggerJob', {id: row.id}).then(rs => {
102
+ this.tableRef.current.reload();
103
+ })
104
+ }
105
+
106
+ columns = [
107
+ {
108
+ title: '名称',
109
+ dataIndex: 'name',
110
+
111
+ },
112
+ {
113
+ title: '执行类',
114
+ dataIndex: 'jobClass',
115
+
116
+ },
117
+
118
+ {
119
+ title: 'cron',
120
+ dataIndex: 'cron',
121
+ },
122
+
123
+
124
+ {
125
+ title: '参数',
126
+ dataIndex: 'jobData',
127
+ render(list) {
128
+ if (list)
129
+ return JSON.stringify(list)
130
+ }
131
+ },
132
+
133
+
134
+ {
135
+ title: '启用状态',
136
+ dataIndex: 'enabled',
137
+ render: (v, record) => {
138
+ return record.enabled ? <Tag color='green'>启用</Tag> : <Tag color='red'>停用</Tag>
139
+ },
140
+ },
141
+
142
+ {
143
+ title: '操作',
144
+ dataIndex: 'option',
145
+ fixed: 'right',
146
+ render: (_, record) => {
147
+
148
+ return (
149
+ <Space>
150
+ <Button size='small' onClick={() => this.showExecuteRecord(record)}>执行记录</Button>
151
+ <Button size='small' onClick={() => this.handleTriggerJob(record)}>执行一次</Button>
152
+ <Button size='small' onClick={() => this.handleEdit(record)}> 编辑 </Button>
153
+ <Popconfirm title='是否确定删除?' onConfirm={() => this.handleDelete(record)}>
154
+ <Button size='small'>删除</Button>
155
+ </Popconfirm>
156
+ </Space>
157
+ );
158
+ },
159
+ },
160
+
161
+ ]
162
+
163
+ showStatus = () => {
164
+ this.setState({statusOpen: true})
165
+ HttpUtils.get('admin/job/status').then(rs => {
166
+ this.setState({status: rs})
167
+ })
168
+ };
169
+
170
+ showExecuteRecord(record) {
171
+ this.setState({executeRecordOpen: true, formValues: record})
172
+ }
173
+
174
+
175
+ render() {
176
+ return <Page padding>
177
+ <ProTable
178
+ actionRef={this.tableRef}
179
+ toolBarRender={() => {
180
+ return <ButtonList>
181
+ <Button type='primary' onClick={() => this.handleAdd()} icon={<PlusOutlined/>}>
182
+ 新增
183
+ </Button>
184
+ <Button onClick={this.showStatus}>
185
+ 查看状态
186
+ </Button>
187
+ </ButtonList>
188
+ }}
189
+ request={(params) => HttpUtils.get('admin/job/page', params)}
190
+ columns={this.columns}
191
+ showToolbarSearch
192
+ />
193
+
194
+
195
+ <Modal title='作业调度'
196
+ open={this.state.formOpen}
197
+ destroyOnHidden
198
+ width={800}
199
+ onOk={() => this.formRef.current.submit()}
200
+ onCancel={() => this.setState({formOpen: false})}
201
+ >
202
+
203
+ <Form ref={this.formRef} labelCol={{flex: '100px'}}
204
+ initialValues={this.state.formValues}
205
+ onValuesChange={this.onValuesChange}
206
+ onFinish={this.onFinish}>
207
+ <Form.Item name='id' noStyle>
208
+ </Form.Item>
209
+ <Form.Item label='执行类' name='jobClass' rules={[{required: true}]}
210
+ tooltip='org.quartz.Job接口,参考io.tmgg.job.builtin.DemoJob'>
211
+ <Select options={this.state.jobClassOptions}/>
212
+ </Form.Item>
213
+ <Form.Item label='名称' name='name' rules={[{required: true}]}>
214
+ <Input/>
215
+ </Form.Item>
216
+
217
+ <Form.Item label='cron表达式' name='cron' help='格式:秒分时日月周,留空表示手动执行'
218
+ rules={[{required: true}]}>
219
+ <AutoComplete placeholder='如 0 */5 * * * ?' options={cronOptions}/>
220
+ </Form.Item>
221
+
222
+ <Form.Item label='启用' name='enabled' valuePropName='checked' rules={[{required: true}]}>
223
+ <Switch/>
224
+ </Form.Item>
225
+
226
+
227
+ {this.state.paramList?.map(p => (
228
+ <div key={p.name}>
229
+ <Divider>作业参数</Divider>
230
+ <Form.Item label={p.label}
231
+ name={['jobData', p.name]}
232
+ key={p.name}
233
+ rules={[{required: p.required}]}>
234
+ {ValueType.renderField(p.componentType, p.componentProps)}
235
+ </Form.Item>
236
+ </div>
237
+ ))}
238
+ </Form>
239
+ </Modal>
240
+
241
+ <Modal title='作业调度状态'
242
+ open={this.state.statusOpen}
243
+ onCancel={() => this.setState({statusOpen: false})}
244
+ footer={null}
245
+ width={1024}
246
+ >
247
+ <Alert message={<pre>{this.state.status}</pre>}></Alert>
248
+
249
+ </Modal>
250
+
251
+ <Modal title='作业调度记录'
252
+ open={this.state.executeRecordOpen}
253
+ onCancel={() => this.setState({executeRecordOpen: false})}
254
+ footer={null}
255
+ width={1024}
256
+ destroyOnHidden
257
+ >
258
+ <ProTable columns={[{
259
+ title: '开始时间',
260
+ dataIndex: 'beginTime',
261
+ },
262
+ {
263
+ title: '结束时间',
264
+ dataIndex: 'endTime',
265
+ },
266
+ {
267
+ title: '耗时',
268
+ dataIndex: 'jobRunTimeLabel',
269
+
270
+ },
271
+ {
272
+ title: '是否成功',
273
+ dataIndex: 'success',
274
+ width: 200,
275
+ render: v => {
276
+ if (v != null) {
277
+ return v ? '成功' : '异常'
278
+ }
279
+ }
280
+ },
281
+ {
282
+ title: '返回结果',
283
+ dataIndex: 'result',
284
+ width: 300
285
+ },
286
+
287
+ {
288
+ title: '操作',
289
+ dataIndex: 'option',
290
+ render: (_, record) => {
291
+ let url = '/admin/sys/log/' + record.id;
292
+ return <a href={url} target='_blank'>日志</a>;
293
+ },
294
+ }
295
+ ]} request={params => {
296
+ params.jobId = this.state.formValues.id
297
+ return HttpUtils.get('admin/job/executeRecord', params);
298
+ }}></ProTable>
299
+
300
+ </Modal>
301
+ </Page>
302
+ }
303
+
304
+ onValuesChange = (changed, values) => {
305
+ if (changed.jobClass) {
306
+ this.loadJobParamFields(values.jobClass)
307
+ const option = this.state.jobClassOptions.find(o => o.value === changed.jobClass)
308
+ if (option) {
309
+ let {label} = option;
310
+ if (StringUtils.contains(label, " ")) { // 取中文名部门设置为name
311
+ this.formRef.current.setFieldValue("name", label.split(" ")[1])
312
+ }
313
+ }
314
+ }
315
+
316
+ if (changed.jobData) {
317
+ this.loadJobParamFields(values.jobClass, values.jobData)
318
+ }
319
+
320
+ };
321
+ }
322
+
323
+
324
+