@jiangood/open-admin 3.0.14 → 3.1.0
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.
- package/package.json +15 -2
- package/src/framework/biz/OrgTree.tsx +10 -6
- package/src/framework/biz/PermActions.tsx +5 -3
- package/src/framework/biz/RoleTree.tsx +10 -6
- package/src/framework/biz/index.tsx +1 -0
- package/src/framework/components/ContextMenu/index.tsx +17 -1
- package/src/framework/components/DownloadModal/index.tsx +40 -33
- package/src/framework/components/FormModal/index.tsx +10 -8
- package/src/framework/components/NamedIcon/index.tsx +2 -2
- package/src/framework/components/OrgSwitcher/index.tsx +6 -7
- package/src/framework/components/PageLoading/index.tsx +3 -3
- package/src/framework/components/ProTable/index.tsx +28 -25
- package/src/framework/components/ValueType/index.tsx +1 -1
- package/src/framework/config/themeConfig.ts +5 -5
- package/src/framework/fields/BaseRemoteSelect/index.tsx +23 -21
- package/src/framework/fields/FieldBoolean/index.tsx +6 -6
- package/src/framework/fields/FieldDate/index.tsx +10 -10
- package/src/framework/fields/FieldDateRange/index.tsx +20 -20
- package/src/framework/fields/FieldDictSelect/index.tsx +2 -2
- package/src/framework/fields/FieldEditor/index.tsx +1 -1
- package/src/framework/fields/FieldNumberRange/index.tsx +16 -17
- package/src/framework/fields/FieldPercent/index.tsx +2 -2
- package/src/framework/fields/FieldRemoteSelect/index.tsx +4 -4
- package/src/framework/fields/FieldRemoteTree/index.tsx +1 -1
- package/src/framework/fields/FieldRemoteTreeCascader/index.tsx +1 -1
- package/src/framework/fields/FieldRemoteTreeSelect/index.tsx +1 -1
- package/src/framework/fields/FieldSysOrgTree/index.tsx +1 -1
- package/src/framework/fields/FieldSysOrgTreeSelect/index.tsx +1 -1
- package/src/framework/fields/FieldTable/index.tsx +15 -13
- package/src/framework/fields/FieldTableSelect/index.tsx +5 -5
- package/src/framework/fields/FieldUploadFile/index.tsx +3 -3
- package/src/framework/fields/FieldUploadImage/index.tsx +31 -29
- package/src/framework/fields/types.ts +0 -2
- package/src/framework/router/PageFrame.tsx +1 -1
- package/src/framework/router/matcher.ts +2 -2
- package/src/framework/utils/ArrayUtils.ts +2 -2
- package/src/framework/utils/DateUtils.ts +1 -1
- package/src/framework/utils/{system/DictUtils.ts → DictUtils.ts} +1 -1
- package/src/framework/utils/EventBus.ts +7 -7
- package/src/framework/utils/HttpClient.ts +283 -0
- package/src/framework/utils/{system/PageUtils.ts → PageUtils.ts} +4 -4
- package/src/framework/utils/{system/PermUtils.ts → PermUtils.ts} +3 -3
- package/src/framework/utils/StringUtils.ts +10 -8
- package/src/framework/utils/TreeUtils.ts +3 -3
- package/src/framework/utils/UrlUtils.ts +3 -2
- package/src/framework/utils/index.ts +4 -1
- package/src/framework/views/ViewApproveStatus/index.tsx +1 -2
- package/src/framework/views/ViewBoolean/index.tsx +4 -1
- package/src/framework/views/ViewFile/index.tsx +4 -4
- package/src/framework/views/ViewImage/index.tsx +2 -2
- package/src/framework/views/ViewPassword/index.tsx +3 -2
- package/src/framework/views/ViewText/index.tsx +12 -3
- package/src/framework/views/types.ts +2 -4
- package/src/layouts/admin/AdminTabs.jsx +9 -0
- package/src/layouts/admin/AdminTabs.less +2 -2
- package/src/layouts/admin/HeaderRight.jsx +8 -7
- package/src/layouts/admin/TabLayout.jsx +2 -2
- package/src/layouts/admin/index.jsx +15 -11
- package/src/layouts/admin/index.less +16 -1
- package/src/layouts/index.tsx +24 -18
- package/src/pages/404.jsx +1 -1
- package/src/pages/article/$code.jsx +4 -4
- package/src/pages/index.jsx +1 -1
- package/src/pages/public/login.jsx +34 -27
- package/src/pages/public/test.jsx +1 -1
- package/src/pages/standalone/forceUpdatePwd.jsx +9 -7
- package/src/pages/system/article/index.jsx +9 -8
- package/src/pages/system/dict/index.jsx +19 -16
- package/src/pages/system/file/index.jsx +9 -9
- package/src/pages/system/job/index.jsx +17 -17
- package/src/pages/system/log/index.jsx +5 -7
- package/src/pages/system/org/index.jsx +31 -18
- package/src/pages/system/role/index.jsx +13 -12
- package/src/pages/system/role/rolePerm.jsx +25 -21
- package/src/pages/system/user/index.jsx +35 -33
- package/src/pages/system/user/userPerm.jsx +12 -12
- package/src/pages/userCenter/index.jsx +11 -9
- package/src/pages/userCenter/permView.jsx +7 -7
- package/src/framework/utils/system/HttpUtils.ts +0 -97
- package/src/framework/utils/system/index.ts +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {Button, Form, Input, message} from 'antd';
|
|
3
3
|
import {LockOutlined, UserOutlined, WarningOutlined} from '@ant-design/icons';
|
|
4
|
-
import {EventBus,
|
|
4
|
+
import {EventBus, HttpClient, GlobalData, history} from "../../framework";
|
|
5
5
|
|
|
6
6
|
import "./login.less"
|
|
7
7
|
|
|
@@ -13,54 +13,61 @@ function getRedirect(query) {
|
|
|
13
13
|
return redirect;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function postLogin(values, query) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
16
|
+
function postLogin(values, query, success, error) {
|
|
17
|
+
HttpClient.post('/admin/auth/login', values, null, {toastError: false}).then(rs => {
|
|
18
|
+
EventBus.emit('loginSuccess')
|
|
19
|
+
history.push(getRedirect(query))
|
|
20
|
+
success?.(rs)
|
|
21
|
+
}).catch(e => {
|
|
22
|
+
console.error('[Login] 登录失败:', e);
|
|
23
|
+
message.error(HttpClient.errToMsg(e))
|
|
24
|
+
error?.(e)
|
|
26
25
|
})
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
function encodePassword(pwd) {
|
|
30
29
|
const chars = [];
|
|
31
30
|
for (let i = 0; i < pwd.length; i++)
|
|
32
|
-
chars.push(pwd.
|
|
33
|
-
return btoa(String.
|
|
31
|
+
chars.push(pwd.codePointAt(i) + i + 2);
|
|
32
|
+
return btoa(String.fromCodePoint(...chars));
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
export default class extends React.Component {
|
|
35
|
+
export default class LoginPage extends React.Component {
|
|
37
36
|
|
|
38
37
|
state = {
|
|
39
38
|
logging: false,
|
|
40
39
|
siteInfo: {}
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
componentDidMount() {
|
|
44
43
|
const siteInfo = GlobalData.getSiteInfo()
|
|
45
|
-
if (siteInfo
|
|
44
|
+
if (siteInfo?.title) {
|
|
46
45
|
this.setState({siteInfo})
|
|
47
46
|
return
|
|
48
47
|
}
|
|
49
48
|
// localStorage 中无站点信息,从服务端重新加载
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
console.error('[Login] 加载站点信息失败:', e);
|
|
49
|
+
HttpClient.get('/admin/public/site-info', null, {toastError: false}).then(rs => {
|
|
50
|
+
GlobalData.setSiteInfo(rs.data)
|
|
51
|
+
this.setState({siteInfo: rs.data})
|
|
52
|
+
}).catch(() => {
|
|
53
|
+
console.error('[Login] 加载站点信息失败');
|
|
56
54
|
message.error('加载站点信息失败,请刷新页面重试')
|
|
57
|
-
}
|
|
55
|
+
})
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
submit = values => {
|
|
61
59
|
this.setState({logging: true})
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
try {
|
|
61
|
+
values.password = encodePassword(values.password)
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.error('[Login] 密码编码失败:', e);
|
|
64
|
+
this.setState({logging: false})
|
|
65
|
+
message.error('密码含不支持字符,请联系管理员重置')
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
postLogin(values, this.props.location?.query, () => {
|
|
69
|
+
this.setState({logging: false})
|
|
70
|
+
}, () => {
|
|
64
71
|
this.setState({logging: false})
|
|
65
72
|
})
|
|
66
73
|
}
|
|
@@ -76,14 +83,14 @@ export default class extends React.Component {
|
|
|
76
83
|
<section className='login-page' style={pageStyle}>
|
|
77
84
|
<div className="login-content">
|
|
78
85
|
<h1>{siteInfo.title}</h1>
|
|
79
|
-
{this.getForm(
|
|
86
|
+
{this.getForm()}
|
|
80
87
|
{this.renderFormBottom()}
|
|
81
88
|
</div>
|
|
82
89
|
</section>
|
|
83
90
|
);
|
|
84
91
|
}
|
|
85
92
|
|
|
86
|
-
getForm =
|
|
93
|
+
getForm = () => {
|
|
87
94
|
const form = (
|
|
88
95
|
<Form
|
|
89
96
|
name="normal_login"
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {Button, Form, Input, message} from "antd";
|
|
3
|
-
import {
|
|
3
|
+
import {HttpClient, history} from "../../framework";
|
|
4
4
|
|
|
5
|
-
export default class extends React.Component {
|
|
5
|
+
export default class ForceUpdatePwdPage extends React.Component {
|
|
6
6
|
|
|
7
7
|
onFinish = (values) => {
|
|
8
|
-
|
|
8
|
+
HttpClient.post('admin/userCenter/update-pwd', values, null).then(() => {
|
|
9
9
|
message.success('修改密码成功,请重新登录');
|
|
10
10
|
history.push('/public/login');
|
|
11
11
|
})
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
validator = (rule, value) => {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
validator = (rule, value) => HttpClient.get("admin/sysUser/pwd-strength", {password: value}, {toastError: false})
|
|
15
|
+
.catch(e => {
|
|
16
|
+
throw new Error(e.message)
|
|
17
|
+
})
|
|
17
18
|
|
|
18
19
|
render() {
|
|
19
20
|
return (
|
|
@@ -42,10 +43,11 @@ export default class extends React.Component {
|
|
|
42
43
|
extra={'请输入字母、数字、特殊字符'}
|
|
43
44
|
rules={[
|
|
44
45
|
{required: true, message: '请输入新密码'},
|
|
46
|
+
{pattern: /^[\x20-\x7E]{1,64}$/, message: '密码仅支持英文、数字与常见符号,长度不超过64位'},
|
|
45
47
|
{validator: this.validator}
|
|
46
48
|
]}
|
|
47
49
|
>
|
|
48
|
-
<Input.Password/>
|
|
50
|
+
<Input.Password maxLength={64}/>
|
|
49
51
|
</Form.Item>
|
|
50
52
|
<Form.Item style={{marginTop: 40}}>
|
|
51
53
|
<Button type="primary" htmlType="submit" block size='large'>
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
FieldEditor,
|
|
9
9
|
FieldUploadImage,
|
|
10
10
|
FormModal,
|
|
11
|
-
|
|
11
|
+
HttpClient,
|
|
12
12
|
Page,
|
|
13
13
|
PageUtils,
|
|
14
14
|
PermActions,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
ViewImage
|
|
17
17
|
} from "../../../framework";
|
|
18
18
|
|
|
19
|
-
export default class extends React.Component {
|
|
19
|
+
export default class ArticleListPage extends React.Component {
|
|
20
20
|
|
|
21
21
|
state = {
|
|
22
22
|
editing: false,
|
|
@@ -42,12 +42,12 @@ export default class extends React.Component {
|
|
|
42
42
|
onFinish = async values => {
|
|
43
43
|
const isNew = !values.id;
|
|
44
44
|
const url = isNew ? 'admin/article/create' : 'admin/article/update';
|
|
45
|
-
await
|
|
45
|
+
await HttpClient.post(url, values)
|
|
46
46
|
this.tableRef.current.reload()
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
handleDelete = record => {
|
|
50
|
-
|
|
50
|
+
HttpClient.post('admin/article/delete', {id: record.id}, null).then(() => {
|
|
51
51
|
this.tableRef.current.reload()
|
|
52
52
|
})
|
|
53
53
|
}
|
|
@@ -84,7 +84,8 @@ export default class extends React.Component {
|
|
|
84
84
|
title: '启用',
|
|
85
85
|
dataIndex: 'enabled',
|
|
86
86
|
render(v) {
|
|
87
|
-
|
|
87
|
+
if (v == null) return null;
|
|
88
|
+
return v ? '是' : '否';
|
|
88
89
|
},
|
|
89
90
|
},
|
|
90
91
|
{
|
|
@@ -111,14 +112,14 @@ export default class extends React.Component {
|
|
|
111
112
|
>
|
|
112
113
|
<ProTable
|
|
113
114
|
actionRef={this.tableRef}
|
|
114
|
-
toolBarRender={() => (
|
|
115
|
+
toolBarRender={() => ( // NOSONAR: AntD 渲染函数惯例
|
|
115
116
|
<PermActions>
|
|
116
117
|
<Button perm='article:create' type='primary' icon={<PlusOutlined/>} onClick={this.handleAdd}>新增</Button>
|
|
117
118
|
</PermActions>
|
|
118
119
|
)}
|
|
119
|
-
request={(params) =>
|
|
120
|
+
request={(params) => HttpClient.get('admin/article/page', params)}
|
|
120
121
|
columns={this.columns}
|
|
121
|
-
searchFormRender={() => (
|
|
122
|
+
searchFormRender={() => ( // NOSONAR: AntD 渲染函数惯例
|
|
122
123
|
<>
|
|
123
124
|
<Form.Item label='编码' name='code'>
|
|
124
125
|
<Input/>
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
PermActions,
|
|
6
6
|
FieldBoolean,
|
|
7
7
|
FormModal,
|
|
8
|
-
|
|
8
|
+
HttpClient,
|
|
9
9
|
Page,
|
|
10
10
|
ProTable,
|
|
11
11
|
ViewSwitch,
|
|
@@ -23,7 +23,7 @@ const COLOR_OPTIONS = [
|
|
|
23
23
|
{value: 'GRAY', label: '灰色'},
|
|
24
24
|
]
|
|
25
25
|
|
|
26
|
-
export default class extends React.Component {
|
|
26
|
+
export default class DictPage extends React.Component {
|
|
27
27
|
|
|
28
28
|
state = {
|
|
29
29
|
typeTree: [],
|
|
@@ -42,9 +42,10 @@ export default class extends React.Component {
|
|
|
42
42
|
|
|
43
43
|
loadTree = () => {
|
|
44
44
|
this.setState({treeLoading: true})
|
|
45
|
-
|
|
46
|
-
this.setState({typeTree: rs})
|
|
47
|
-
|
|
45
|
+
HttpClient.get('admin/dict/type-tree', null, {toastError: false}).then(rs => {
|
|
46
|
+
this.setState({typeTree: rs.data})
|
|
47
|
+
this.setState({treeLoading: false})
|
|
48
|
+
}).catch(() => {
|
|
48
49
|
this.setState({treeLoading: false})
|
|
49
50
|
})
|
|
50
51
|
}
|
|
@@ -62,7 +63,7 @@ export default class extends React.Component {
|
|
|
62
63
|
handleTypeDelete = () => {
|
|
63
64
|
const {selectedType} = this.state
|
|
64
65
|
if (!selectedType) return
|
|
65
|
-
|
|
66
|
+
HttpClient.post('admin/dict/type-delete', {id: selectedType.id}, null).then(() => {
|
|
66
67
|
this.setState({selectedType: null, selectedTypeCode: null})
|
|
67
68
|
this.loadTree()
|
|
68
69
|
})
|
|
@@ -71,7 +72,7 @@ export default class extends React.Component {
|
|
|
71
72
|
handleTypeFormFinish = async values => {
|
|
72
73
|
const isNew = !values.id
|
|
73
74
|
const url = isNew ? 'admin/dict/type-create' : 'admin/dict/type-update'
|
|
74
|
-
await
|
|
75
|
+
await HttpClient.post(url, values)
|
|
75
76
|
this.loadTree()
|
|
76
77
|
}
|
|
77
78
|
|
|
@@ -98,11 +99,13 @@ export default class extends React.Component {
|
|
|
98
99
|
this.setState({selectedType: null, selectedTypeCode: null})
|
|
99
100
|
return
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
this.setState((prevState) => {
|
|
103
|
+
const node = this.findNode(prevState.typeTree, selectedKeys[0])
|
|
104
|
+
return {
|
|
105
|
+
selectedType: node,
|
|
106
|
+
selectedTypeCode: node?.typeCode || null
|
|
107
|
+
}
|
|
108
|
+
}, () => this.tableRef.current.reload())
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
handleItemAdd = () => {
|
|
@@ -114,7 +117,7 @@ export default class extends React.Component {
|
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
handleItemDelete = row => {
|
|
117
|
-
|
|
120
|
+
HttpClient.post('admin/dict/delete', row, null).then(() => {
|
|
118
121
|
this.tableRef.current.reload()
|
|
119
122
|
})
|
|
120
123
|
}
|
|
@@ -122,7 +125,7 @@ export default class extends React.Component {
|
|
|
122
125
|
onItemFormFinish = async values => {
|
|
123
126
|
const isNew = !values.id
|
|
124
127
|
const url = isNew ? 'admin/dict/create' : 'admin/dict/update'
|
|
125
|
-
await
|
|
128
|
+
await HttpClient.post(url, values)
|
|
126
129
|
this.tableRef.current.reload()
|
|
127
130
|
}
|
|
128
131
|
|
|
@@ -220,7 +223,7 @@ export default class extends React.Component {
|
|
|
220
223
|
actionRef={this.tableRef}
|
|
221
224
|
request={(params) => {
|
|
222
225
|
params.typeCode = selectedTypeCode
|
|
223
|
-
return
|
|
226
|
+
return HttpClient.get('admin/dict/page', params)
|
|
224
227
|
}}
|
|
225
228
|
columns={this.columns}
|
|
226
229
|
/>
|
|
@@ -266,7 +269,7 @@ export default class extends React.Component {
|
|
|
266
269
|
allowClear
|
|
267
270
|
maxLength={20}
|
|
268
271
|
options={COLOR_OPTIONS}
|
|
269
|
-
filterOption={(input, option) =>
|
|
272
|
+
filterOption={(input, option) => // NOSONAR: AntD AutoComplete 过滤回调惯例
|
|
270
273
|
(option.value + option.label).toLowerCase().includes(input.toLowerCase())
|
|
271
274
|
}
|
|
272
275
|
placeholder='如 SUCCESS、#ff0000'
|
|
@@ -2,9 +2,9 @@ import React from 'react'
|
|
|
2
2
|
import {Button, Form, Input, Modal, Space} from 'antd'
|
|
3
3
|
import {CloudUploadOutlined} from "@ant-design/icons";
|
|
4
4
|
|
|
5
|
-
import {PermActions, DictUtils, FieldDateRange, FieldDictSelect, FieldUploadFile,
|
|
5
|
+
import {PermActions, DictUtils, FieldDateRange, FieldDictSelect, FieldUploadFile, HttpClient, Page, ProTable, UrlUtils, ViewImage} from "../../../framework";
|
|
6
6
|
|
|
7
|
-
export default class extends React.Component {
|
|
7
|
+
export default class FilePage extends React.Component {
|
|
8
8
|
|
|
9
9
|
state = {
|
|
10
10
|
formOpen: false,
|
|
@@ -15,13 +15,13 @@ export default class extends React.Component {
|
|
|
15
15
|
formRef = React.createRef()
|
|
16
16
|
|
|
17
17
|
handleDelete = row => {
|
|
18
|
-
|
|
18
|
+
HttpClient.post('admin/sysFile/delete', {value: row.objectName}, null).then(() => {
|
|
19
19
|
this.tableRef.current.reload()
|
|
20
20
|
})
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
handleBatchDelete = ids => {
|
|
24
|
-
|
|
24
|
+
HttpClient.post('admin/sysFile/deleteBatch', ids, null).then(() => {
|
|
25
25
|
this.tableRef.current.reload()
|
|
26
26
|
this.tableRef.current.clearSelection()
|
|
27
27
|
})
|
|
@@ -32,7 +32,7 @@ export default class extends React.Component {
|
|
|
32
32
|
title: '缩略图',
|
|
33
33
|
dataIndex: 'objectName',
|
|
34
34
|
width: 80,
|
|
35
|
-
render: (objectName, record) => {
|
|
35
|
+
render: (objectName, record) => { // NOSONAR: 返回元素或占位文本,类型不同属预期
|
|
36
36
|
if (record.type !== 'image') {
|
|
37
37
|
return '-'
|
|
38
38
|
}
|
|
@@ -151,12 +151,12 @@ export default class extends React.Component {
|
|
|
151
151
|
<ProTable
|
|
152
152
|
actionRef={this.tableRef}
|
|
153
153
|
rowSelection={{}}
|
|
154
|
-
toolBarRender={(params, selection) => (
|
|
154
|
+
toolBarRender={(params, selection) => ( // NOSONAR: AntD 渲染函数惯例
|
|
155
155
|
<Space>
|
|
156
156
|
<Button type='primary' icon={<CloudUploadOutlined/>} onClick={() => this.setState({formOpen: true})}>上传文件</Button>
|
|
157
157
|
<PermActions
|
|
158
158
|
actions={[{
|
|
159
|
-
label:
|
|
159
|
+
label: '批量删除' + (selection.selectedRowKeys.length ? `(${selection.selectedRowKeys.length})` : ''),
|
|
160
160
|
perm: 'sys-file:delete',
|
|
161
161
|
danger: true,
|
|
162
162
|
disabled: !selection.selectedRowKeys.length,
|
|
@@ -167,11 +167,11 @@ export default class extends React.Component {
|
|
|
167
167
|
</Space>
|
|
168
168
|
)}
|
|
169
169
|
request={(params) => {
|
|
170
|
-
return
|
|
170
|
+
return HttpClient.get('admin/sysFile/page', params);
|
|
171
171
|
}}
|
|
172
172
|
|
|
173
173
|
columns={this.columns}
|
|
174
|
-
searchFormRender={() => (
|
|
174
|
+
searchFormRender={() => ( // NOSONAR: AntD 渲染函数惯例
|
|
175
175
|
<>
|
|
176
176
|
<Form.Item label='文件名' name='originName'>
|
|
177
177
|
<Input/>
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
Tag
|
|
14
14
|
} from 'antd'
|
|
15
15
|
import {PlusOutlined} from "@ant-design/icons";
|
|
16
|
-
import {FormModal,
|
|
16
|
+
import {FormModal, HttpClient, Page, PermActions, ProTable, UrlUtils, ValueType} from "../../../framework";
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
const cronOptions = [
|
|
@@ -40,7 +40,7 @@ const cronOptions = [
|
|
|
40
40
|
]
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
export default class extends React.Component {
|
|
43
|
+
export default class JobPage extends React.Component {
|
|
44
44
|
|
|
45
45
|
state = {
|
|
46
46
|
selectedRowKeys: [],
|
|
@@ -58,8 +58,8 @@ export default class extends React.Component {
|
|
|
58
58
|
modalRef = React.createRef()
|
|
59
59
|
|
|
60
60
|
componentDidMount() {
|
|
61
|
-
|
|
62
|
-
this.setState({jobClassOptions: rs})
|
|
61
|
+
HttpClient.get('admin/job/job-class-options', null, {toastError: false}).then(rs => {
|
|
62
|
+
this.setState({jobClassOptions: rs.data})
|
|
63
63
|
}).catch(e => {
|
|
64
64
|
console.error('[Job] 加载任务类选项失败:', e);
|
|
65
65
|
})
|
|
@@ -76,8 +76,8 @@ export default class extends React.Component {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
loadJobParamFields(className, jobData) {
|
|
79
|
-
|
|
80
|
-
this.setState({paramList: rs})
|
|
79
|
+
HttpClient.post("admin/job/get-job-param-fields", jobData || {}, {className}, {toastError: false}).then(rs => {
|
|
80
|
+
this.setState({paramList: rs.data})
|
|
81
81
|
}).catch(e => {
|
|
82
82
|
console.error('[Job] 加载任务参数字段失败:', e);
|
|
83
83
|
})
|
|
@@ -86,13 +86,13 @@ export default class extends React.Component {
|
|
|
86
86
|
onFinish = async values => {
|
|
87
87
|
const isNew = !values.id;
|
|
88
88
|
const url = isNew ? 'admin/job/create' : 'admin/job/update';
|
|
89
|
-
await
|
|
89
|
+
await HttpClient.post(url, values)
|
|
90
90
|
this.tableRef.current.reload()
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
handleDelete = row => {
|
|
94
94
|
const hide = message.loading("删除任务中...")
|
|
95
|
-
|
|
95
|
+
HttpClient.post('admin/job/delete', {id: row.id}, null, {toastError: false}).then(() => {
|
|
96
96
|
hide();
|
|
97
97
|
this.tableRef.current.reload();
|
|
98
98
|
}).catch(e => {
|
|
@@ -102,7 +102,7 @@ export default class extends React.Component {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
handleTriggerJob = row => {
|
|
105
|
-
|
|
105
|
+
HttpClient.post('admin/job/trigger-job', {id: row.id}, null, {toastError: false}).then(() => {
|
|
106
106
|
this.tableRef.current.reload();
|
|
107
107
|
}).catch(e => {
|
|
108
108
|
console.error('[Job] 触发任务失败:', e);
|
|
@@ -167,8 +167,8 @@ export default class extends React.Component {
|
|
|
167
167
|
|
|
168
168
|
showStatus = () => {
|
|
169
169
|
this.setState({statusOpen: true})
|
|
170
|
-
|
|
171
|
-
this.setState({status: rs})
|
|
170
|
+
HttpClient.get('admin/job/status', null, {toastError: false}).then(rs => {
|
|
171
|
+
this.setState({status: rs.data})
|
|
172
172
|
}).catch(e => {
|
|
173
173
|
console.error('[Job] 加载状态失败:', e);
|
|
174
174
|
})
|
|
@@ -183,15 +183,15 @@ export default class extends React.Component {
|
|
|
183
183
|
return <Page>
|
|
184
184
|
<ProTable
|
|
185
185
|
actionRef={this.tableRef}
|
|
186
|
-
toolBarRender={() => (
|
|
186
|
+
toolBarRender={() => ( // NOSONAR: AntD 渲染函数惯例
|
|
187
187
|
<PermActions>
|
|
188
188
|
<Button type='primary' perm='job:create' icon={<PlusOutlined/>} onClick={() => this.handleAdd()}>新增</Button>
|
|
189
189
|
<Button perm='job:read' onClick={this.showStatus}>查看状态</Button>
|
|
190
190
|
</PermActions>
|
|
191
191
|
)}
|
|
192
|
-
request={(params) =>
|
|
192
|
+
request={(params) => HttpClient.get('admin/job/page', params)}
|
|
193
193
|
columns={this.columns}
|
|
194
|
-
searchFormRender={() => (
|
|
194
|
+
searchFormRender={() => ( // NOSONAR: AntD 渲染函数惯例
|
|
195
195
|
<>
|
|
196
196
|
<Form.Item label='名称' name='name'>
|
|
197
197
|
<Input/>
|
|
@@ -295,9 +295,9 @@ export default class extends React.Component {
|
|
|
295
295
|
return <a href={url} target='_blank'>日志</a>;
|
|
296
296
|
},
|
|
297
297
|
}
|
|
298
|
-
]} request={params => {
|
|
298
|
+
]} request={(params) => {
|
|
299
299
|
params.jobId = this.state.selectedRecord.id
|
|
300
|
-
return
|
|
300
|
+
return HttpClient.get('admin/job/execute-record', params);
|
|
301
301
|
}}></ProTable>
|
|
302
302
|
|
|
303
303
|
</Modal>
|
|
@@ -310,7 +310,7 @@ export default class extends React.Component {
|
|
|
310
310
|
const option = this.state.jobClassOptions.find(o => o.value === changed.jobClass)
|
|
311
311
|
if (option) {
|
|
312
312
|
const {label} = option;
|
|
313
|
-
const match = label.match(/[((](.*?)[))]/);
|
|
313
|
+
const match = label.match(/[((](.*?)[))]/); // NOSONAR: 匹配中英文括号内内容,已最简
|
|
314
314
|
if (match) { // 取括号内中文描述设置为name
|
|
315
315
|
this.modalRef.current.formInstance.setFieldValue("name", match[1])
|
|
316
316
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {Form, Input, Tag} from "antd";
|
|
3
|
-
import {ViewText, FieldDateRange,
|
|
3
|
+
import {ViewText, FieldDateRange, HttpClient, Page, ProTable} from "../../../framework";
|
|
4
4
|
|
|
5
|
-
export default class extends React.Component {
|
|
5
|
+
export default class LogPage extends React.Component {
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
columns = [
|
|
@@ -39,9 +39,7 @@ export default class extends React.Component {
|
|
|
39
39
|
title: '结果',
|
|
40
40
|
dataIndex: 'success',
|
|
41
41
|
render(v) {
|
|
42
|
-
return
|
|
43
|
-
<Tag color={v ? 'green' : 'red'}>{v ? '成功' : '失败'}</Tag>
|
|
44
|
-
</>
|
|
42
|
+
return <Tag color={v ? 'green' : 'red'}>{v ? '成功' : '失败'}</Tag>
|
|
45
43
|
}
|
|
46
44
|
},
|
|
47
45
|
{
|
|
@@ -57,9 +55,9 @@ export default class extends React.Component {
|
|
|
57
55
|
render() {
|
|
58
56
|
return <Page title="操作日志" description="查看系统操作日志">
|
|
59
57
|
<ProTable
|
|
60
|
-
request={(params) =>
|
|
58
|
+
request={(params) => HttpClient.get('admin/sysLog/page', params)}
|
|
61
59
|
columns={this.columns}
|
|
62
|
-
searchFormRender={() => (
|
|
60
|
+
searchFormRender={() => ( // NOSONAR: AntD 渲染函数惯例
|
|
63
61
|
<>
|
|
64
62
|
<Form.Item label='操作' name='operation'>
|
|
65
63
|
<Input/>
|