@jiangood/open-admin 2.5.9 → 3.0.1

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 (142) hide show
  1. package/package.json +20 -8
  2. package/src/framework/GlobalData.ts +85 -0
  3. package/src/framework/biz/OrgTree.tsx +2 -7
  4. package/src/framework/biz/Perm.tsx +11 -0
  5. package/src/framework/biz/PermActions.tsx +18 -15
  6. package/src/framework/biz/index.tsx +34 -19
  7. package/src/framework/components/ContextMenu/index.tsx +105 -78
  8. package/src/framework/components/DownloadModal/index.tsx +15 -17
  9. package/src/framework/components/ErrorBoundary/index.tsx +2 -2
  10. package/src/framework/components/FormModal/index.tsx +76 -0
  11. package/src/framework/components/Gap/index.tsx +1 -1
  12. package/src/framework/components/NamedIcon/index.tsx +55 -9
  13. package/src/framework/components/Page/index.less +0 -1
  14. package/src/framework/components/Page/index.tsx +34 -27
  15. package/src/framework/components/PageLoading/index.less +15 -0
  16. package/src/framework/components/PageLoading/index.tsx +32 -16
  17. package/src/framework/components/ProTable/index.tsx +86 -15
  18. package/src/framework/components/index.ts +1 -0
  19. package/src/framework/config/index.ts +1 -0
  20. package/src/framework/config/themeConfig.ts +39 -0
  21. package/src/framework/fields/FieldBoolean/index.tsx +11 -2
  22. package/src/framework/fields/FieldDate/index.tsx +22 -7
  23. package/src/framework/fields/FieldDateRange/index.tsx +24 -6
  24. package/src/framework/fields/FieldDictSelect/index.tsx +1 -0
  25. package/src/framework/fields/FieldEditor/index.tsx +7 -1
  26. package/src/framework/fields/FieldNumberRange/index.tsx +14 -5
  27. package/src/framework/fields/FieldPercent/index.tsx +16 -5
  28. package/src/framework/fields/FieldRemoteSelect/index.tsx +4 -2
  29. package/src/framework/fields/FieldRemoteTreeSelect/index.tsx +2 -1
  30. package/src/framework/fields/FieldSysOrgTree/index.tsx +6 -1
  31. package/src/framework/fields/FieldSysOrgTreeSelect/index.tsx +6 -1
  32. package/src/framework/fields/FieldTable/index.tsx +35 -6
  33. package/src/framework/fields/FieldTableSelect/index.tsx +18 -2
  34. package/src/framework/fields/FieldUploadFile/index.tsx +69 -28
  35. package/src/framework/fields/index.ts +0 -1
  36. package/src/framework/index.ts +2 -0
  37. package/src/framework/router/Link.tsx +26 -0
  38. package/src/framework/router/PageFrame.tsx +31 -0
  39. package/src/framework/router/history.ts +50 -0
  40. package/src/framework/router/index.ts +4 -0
  41. package/src/framework/router/matcher.ts +58 -0
  42. package/src/framework/utils/{ArrayUtils.js → ArrayUtils.ts} +5 -5
  43. package/src/framework/utils/{DateUtils.js → DateUtils.ts} +19 -19
  44. package/src/framework/utils/{DeviceUtils.js → DeviceUtils.ts} +8 -1
  45. package/src/framework/utils/{EventBus.js → EventBus.ts} +13 -6
  46. package/src/framework/utils/MessageApi.ts +5 -0
  47. package/src/framework/utils/ModalApi.ts +5 -0
  48. package/src/framework/utils/ObjectUtils.ts +15 -0
  49. package/src/framework/utils/{StorageUtils.js → StorageUtils.ts} +7 -7
  50. package/src/framework/utils/{StringUtils.js → StringUtils.ts} +15 -15
  51. package/src/framework/utils/{TreeUtils.js → TreeUtils.ts} +19 -12
  52. package/src/framework/utils/{UrlUtils.js → UrlUtils.ts} +10 -10
  53. package/src/framework/utils/index.ts +2 -1
  54. package/src/framework/utils/system/{DictUtils.js → DictUtils.ts} +16 -4
  55. package/src/framework/utils/system/{HttpUtils.js → HttpUtils.ts} +25 -21
  56. package/src/framework/utils/system/PageUtils.ts +49 -0
  57. package/src/framework/utils/system/{PermUtils.js → PermUtils.ts} +5 -6
  58. package/src/framework/utils/system/index.ts +0 -2
  59. package/src/framework/views/ViewBoolean/index.tsx +6 -3
  60. package/src/framework/views/ViewFileButton/index.tsx +13 -8
  61. package/src/framework/views/ViewImage/index.tsx +19 -14
  62. package/src/framework/views/ViewRange/index.tsx +10 -7
  63. package/src/framework/views/ViewText/index.tsx +9 -11
  64. package/src/layouts/admin/AdminTabs.jsx +79 -0
  65. package/src/layouts/admin/AdminTabs.less +63 -0
  66. package/src/layouts/admin/HeaderRight.jsx +27 -13
  67. package/src/layouts/admin/TabLayout.jsx +124 -0
  68. package/src/layouts/admin/index.jsx +5 -6
  69. package/src/layouts/admin/index.less +1 -82
  70. package/src/layouts/index.tsx +148 -0
  71. package/src/main.jsx +8 -0
  72. package/src/pages/account/changePassword.jsx +14 -10
  73. package/src/pages/article/$code.jsx +2 -2
  74. package/src/pages/index.jsx +6 -4
  75. package/src/pages/{login.jsx → public/login.jsx} +7 -10
  76. package/src/pages/public/test.jsx +30 -0
  77. package/src/pages/{forceUpdatePwd.jsx → standalone/forceUpdatePwd.jsx} +3 -24
  78. package/src/pages/system/article/index.jsx +51 -56
  79. package/src/pages/system/dict/index.jsx +60 -91
  80. package/src/pages/system/file/index.jsx +23 -17
  81. package/src/pages/system/job/index.jsx +63 -72
  82. package/src/pages/system/log/index.jsx +11 -8
  83. package/src/pages/system/org/index.jsx +60 -80
  84. package/src/pages/system/role/index.jsx +50 -86
  85. package/src/pages/system/role/rolePerm.jsx +2 -2
  86. package/src/pages/system/user/index.jsx +120 -73
  87. package/src/pages/system/user/userPerm.jsx +2 -2
  88. package/vite-plugin/index.js +107 -0
  89. package/config/common-plugin.js +0 -145
  90. package/config/config.js +0 -5
  91. package/config/utils.js +0 -73
  92. package/src/.umi-production/appData.json +0 -2257
  93. package/src/.umi-production/core/EmptyRoute.tsx +0 -9
  94. package/src/.umi-production/core/defineApp.ts +0 -16
  95. package/src/.umi-production/core/helmet.ts +0 -10
  96. package/src/.umi-production/core/helmetContext.ts +0 -4
  97. package/src/.umi-production/core/history.ts +0 -72
  98. package/src/.umi-production/core/historyIntelli.ts +0 -132
  99. package/src/.umi-production/core/plugin.ts +0 -40
  100. package/src/.umi-production/core/pluginConfig.ts +0 -330
  101. package/src/.umi-production/core/pluginConfigJoi.d.ts +0 -7
  102. package/src/.umi-production/core/polyfill.ts +0 -220
  103. package/src/.umi-production/core/route.tsx +0 -47
  104. package/src/.umi-production/core/routeProps.js +0 -5
  105. package/src/.umi-production/core/routeProps.ts +0 -6
  106. package/src/.umi-production/core/terminal.ts +0 -37
  107. package/src/.umi-production/exports.ts +0 -17
  108. package/src/.umi-production/testBrowser.tsx +0 -90
  109. package/src/.umi-production/tsconfig.json +0 -43
  110. package/src/.umi-production/typings.d.ts +0 -136
  111. package/src/.umi-production/umi.ts +0 -83
  112. package/src/framework/GlobalData.d.ts +0 -10
  113. package/src/framework/GlobalData.js +0 -42
  114. package/src/framework/biz/HasPerm.tsx +0 -14
  115. package/src/framework/fields/FieldRemoteSelectMultiple/index.tsx +0 -29
  116. package/src/framework/utils/ArrayUtils.d.ts +0 -6
  117. package/src/framework/utils/DateUtils.d.ts +0 -20
  118. package/src/framework/utils/DeviceUtils.d.ts +0 -3
  119. package/src/framework/utils/EventBus.d.ts +0 -6
  120. package/src/framework/utils/MessageUtils.d.ts +0 -10
  121. package/src/framework/utils/MessageUtils.js +0 -43
  122. package/src/framework/utils/ObjectUtils.d.ts +0 -14
  123. package/src/framework/utils/ObjectUtils.js +0 -12
  124. package/src/framework/utils/StorageUtils.d.ts +0 -4
  125. package/src/framework/utils/StringUtils.d.ts +0 -17
  126. package/src/framework/utils/TreeUtils.d.ts +0 -13
  127. package/src/framework/utils/UrlUtils.d.ts +0 -6
  128. package/src/framework/utils/system/DictUtils.d.ts +0 -20
  129. package/src/framework/utils/system/FormRegistry.d.ts +0 -8
  130. package/src/framework/utils/system/FormRegistry.js +0 -31
  131. package/src/framework/utils/system/HttpUtils.d.ts +0 -14
  132. package/src/framework/utils/system/PageUtils.d.ts +0 -14
  133. package/src/framework/utils/system/PageUtils.js +0 -59
  134. package/src/framework/utils/system/PermUtils.d.ts +0 -5
  135. package/src/framework/utils/system/ThemeUtils.d.ts +0 -6
  136. package/src/framework/utils/system/ThemeUtils.js +0 -52
  137. package/src/layouts/PageRender.tsx +0 -29
  138. package/src/layouts/admin/TabPageRender.jsx +0 -210
  139. package/src/layouts/index.jsx +0 -120
  140. package/src/loading.jsx +0 -19
  141. package/src/pages/about.jsx +0 -16
  142. /package/src/pages/{login.less → public/login.less} +0 -0
@@ -108,88 +108,7 @@
108
108
  display: flex;
109
109
  flex-direction: column;
110
110
  overflow: hidden;
111
-
112
- .oa-tabs {
113
- flex: 1;
114
- display: flex;
115
- flex-direction: column;
116
- overflow: hidden;
117
-
118
- .oa-tab-bar {
119
- display: flex;
120
- flex-wrap: nowrap;
121
- overflow-x: auto;
122
- overflow-y: hidden;
123
- flex-shrink: 0;
124
- margin-bottom: 0;
125
- border-bottom: 1px solid #e8e8e8;
126
- background: #fff;
127
-
128
- &::-webkit-scrollbar {
129
- height: 0;
130
- }
131
- }
132
-
133
- .oa-tab {
134
- display: inline-flex;
135
- align-items: center;
136
- gap: 4px;
137
- padding: 0 12px;
138
- height: 32px;
139
- line-height: 32px;
140
- font-size: 13px;
141
- cursor: pointer;
142
- border-right: 1px solid #e8e8e8;
143
- white-space: nowrap;
144
- color: rgba(0, 0, 0, 0.65);
145
- background: #fafafa;
146
- transition: color 0.2s, background 0.2s;
147
- position: relative;
148
- flex-shrink: 0;
149
-
150
- &:hover {
151
- color: var(--primary-color, #1961AC);
152
- }
153
-
154
- &.active {
155
- color: var(--primary-color, #1961AC);
156
- background: #fff;
157
- font-weight: 500;
158
- }
159
-
160
- .oa-tab-label {
161
- max-width: 120px;
162
- overflow: hidden;
163
- text-overflow: ellipsis;
164
- }
165
-
166
- .oa-tab-close {
167
- display: inline-flex;
168
- align-items: center;
169
- justify-content: center;
170
- width: 16px;
171
- height: 16px;
172
- font-size: 12px;
173
- line-height: 1;
174
- border-radius: 50%;
175
- color: rgba(0, 0, 0, 0.45);
176
-
177
- &:hover {
178
- background: rgba(0, 0, 0, 0.08);
179
- color: rgba(0, 0, 0, 0.88);
180
- }
181
- }
182
- }
183
-
184
- .oa-tabs-content {
185
- flex: 1;
186
- overflow: hidden;
187
-
188
- .oa-tab-pane {
189
- height: 100%;
190
- }
191
- }
192
- }
111
+ flex: 1;
193
112
  }
194
113
  }
195
114
 
@@ -0,0 +1,148 @@
1
+ import React from "react";
2
+ import {ConfigProvider, Modal} from "antd";
3
+ import zhCN from 'antd/locale/zh_CN';
4
+ import dayjs from 'dayjs';
5
+ import 'dayjs/locale/zh-cn';
6
+ import {history, PageFrame} from "../framework";
7
+
8
+ import AdminLayout from "./admin"
9
+ import {HttpUtils, PageLoading, PageUtils, GlobalData, getThemeConfig, EventBus} from "../framework";
10
+ import {ErrorBoundary} from "../framework";
11
+
12
+ import '../style/global.less'
13
+ import './index.less'
14
+
15
+ dayjs.locale('zh-cn');
16
+
17
+ const configProps = {
18
+ input: {autoComplete: 'off'},
19
+ form: {validateMessages: {required: '必填项'}, colon: false},
20
+ button: {autoInsertSpace: false},
21
+ locale: zhCN,
22
+ theme: getThemeConfig(),
23
+ };
24
+
25
+ export class Layouts extends React.Component {
26
+ state = {
27
+ location: history.location,
28
+ siteInfoLoaded: false,
29
+ loginChecked: false,
30
+ loginExpiredVisible: false,
31
+ };
32
+
33
+ unlisten: (() => void) | null = null;
34
+ unsubscribeLoginExpired: (() => void) | null = null;
35
+
36
+ onLocationChange = ({location}: { location: typeof history.location }) => {
37
+ this.setState({location});
38
+ };
39
+
40
+ getPageType(pathname): 'public' | 'standalone' | 'protected' {
41
+ if (pathname === '/' || pathname === '/index') return 'protected';
42
+ if (pathname.startsWith('/public/')) return 'public';
43
+ if (pathname.startsWith('/standalone/')) return 'standalone';
44
+ return 'protected';
45
+ }
46
+
47
+ loadData() {
48
+ const {siteInfoLoaded, loginChecked} = this.state;
49
+ const pageType = this.getPageType(this.state.location.pathname);
50
+
51
+ if (!siteInfoLoaded) {
52
+ this.loadSiteInfo();
53
+ }
54
+
55
+ if ((pageType === 'protected' || pageType === 'standalone') && !loginChecked) {
56
+ this.loadLoginInfo();
57
+ }
58
+ }
59
+
60
+ loadSiteInfo() {
61
+ HttpUtils.get("/admin/public/site-info").then(data => {
62
+ GlobalData.setSiteInfo(data);
63
+ this.setState({siteInfoLoaded: true});
64
+ }).catch(() => {
65
+ console.error('[Layout] 加载站点信息失败');
66
+ });
67
+ }
68
+
69
+ loadLoginInfo() {
70
+ HttpUtils.get('/admin/public/login-info').then(data => {
71
+ GlobalData.setDictInfo(data.dictInfo);
72
+ GlobalData.setLoginInfo(data.loginInfo);
73
+ GlobalData.setSiteArticles(data.siteArticles);
74
+
75
+ if (data.needUpdatePwd) {
76
+ history.push('/standalone/forceUpdatePwd');
77
+ return;
78
+ }
79
+
80
+ this.setState({loginChecked: true});
81
+ }).catch(() => {
82
+ console.error('[Layout] 初始化应用失败');
83
+ PageUtils.redirectToLogin();
84
+ });
85
+ }
86
+
87
+ componentDidMount() {
88
+ this.unlisten = history.listen(this.onLocationChange);
89
+ this.unsubscribeLoginExpired = EventBus.on('loginExpired', () => {
90
+ if (!this.state.loginExpiredVisible) {
91
+ this.setState({loginExpiredVisible: true});
92
+ }
93
+ });
94
+ this.loadData();
95
+ }
96
+
97
+ componentDidUpdate(prevProps: {}, prevState: typeof this.state) {
98
+ if (this.state.location !== prevState.location) {
99
+ this.loadData();
100
+ }
101
+ }
102
+
103
+ componentWillUnmount() {
104
+ if (this.unlisten) {
105
+ this.unlisten();
106
+ }
107
+ if (this.unsubscribeLoginExpired) {
108
+ this.unsubscribeLoginExpired();
109
+ }
110
+ }
111
+
112
+ render() {
113
+ const {location, siteInfoLoaded, loginChecked} = this.state;
114
+ const {pathname, search} = location;
115
+ const ready = siteInfoLoaded && loginChecked;
116
+ const pageType = this.getPageType(pathname);
117
+ const showPageFrame = pageType === 'public' || (pageType === 'standalone' && ready);
118
+
119
+ return (
120
+ <ErrorBoundary minimal>
121
+ <ConfigProvider {...configProps}>
122
+ {showPageFrame ? <PageFrame url={pathname + search}/> : ready ? <AdminLayout/> : (
123
+ <PageLoading messages={[
124
+ !siteInfoLoaded && '加载站点信息...',
125
+ !loginChecked && '检查登录中...',
126
+ ].filter(Boolean)}/>
127
+ )}
128
+ {this.renderLoginExpiredModal()}
129
+ </ConfigProvider>
130
+ </ErrorBoundary>
131
+ );
132
+ }
133
+
134
+ renderLoginExpiredModal() {
135
+ return (
136
+ <Modal open={this.state.loginExpiredVisible} title="确认操作" okText="确定"
137
+ onCancel={() => this.setState({loginExpiredVisible: false})}
138
+ onOk={() => {
139
+ this.setState({loginExpiredVisible: false});
140
+ PageUtils.redirectToLogin();
141
+ }}>
142
+ 登录已过期,请重新登录
143
+ </Modal>
144
+ );
145
+ }
146
+ }
147
+
148
+ export default Layouts;
package/src/main.jsx ADDED
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import {createRoot} from 'react-dom/client';
3
+ import routes from 'virtual:open-admin/routes';
4
+ import {registerRoutes} from './framework';
5
+ import App from './layouts';
6
+
7
+ registerRoutes(routes);
8
+ createRoot(document.getElementById('root')).render(<App/>);
@@ -1,26 +1,22 @@
1
1
  import React from "react";
2
2
  import {Button, Form, Input, Modal} from "antd";
3
- import {history} from 'umi'
4
- import {HttpUtils} from "../../framework";
3
+ import {HttpUtils, history} from "../../framework";
5
4
 
6
5
  export default class extends React.Component {
7
6
 
7
+ state = {
8
+ successModalOpen: false,
9
+ };
8
10
 
9
11
  onFinish = (values) => {
10
12
  HttpUtils.post('admin/userCenter/update-pwd', values).then(() => {
11
- Modal.success({
12
- title: '提示',
13
- content: '修改密码成功',
14
- onOk: () => {
15
- history.push('/login')
16
- }
17
- })
13
+ this.setState({successModalOpen: true});
18
14
  })
19
15
  }
20
16
 
21
17
  validator = (rule, value) => {
22
18
  return new Promise((resolve, reject) => {
23
- HttpUtils.get("admin/sysUser/pwd-strength", {password: value}).then(response => {
19
+ HttpUtils.get("admin/sysUser/pwd-strength", {password: value}, {showError: false}).then(response => {
24
20
  const rs = response.data
25
21
  if (!rs.success) {
26
22
  reject(rs.message)
@@ -33,6 +29,14 @@ export default class extends React.Component {
33
29
 
34
30
  render() {
35
31
  return <div>
32
+ <Modal open={this.state.successModalOpen} title="提示" okText="确定"
33
+ onCancel={() => this.setState({successModalOpen: false})}
34
+ onOk={() => {
35
+ this.setState({successModalOpen: false});
36
+ history.push('/public/login');
37
+ }}>
38
+ 修改密码成功
39
+ </Modal>
36
40
 
37
41
  <Form onFinish={this.onFinish} style={{maxWidth: 400}}>
38
42
 
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import {HttpUtils, Page, PageUtils} from "../../framework";
2
+ import {HttpUtils, Page} from "../../framework";
3
3
 
4
4
  export default class extends React.Component {
5
5
 
@@ -9,7 +9,7 @@ export default class extends React.Component {
9
9
  }
10
10
 
11
11
  componentDidMount() {
12
- const code = PageUtils.currentPathnameLastPart()
12
+ const code = this.props.params?.code
13
13
  if (code) {
14
14
  HttpUtils.get('admin/article/getByCode', {code}).then(rs => {
15
15
  this.setState({article: rs, loading: false})
@@ -2,8 +2,10 @@ import React from "react";
2
2
  import {Card} from "antd";
3
3
  import {Page} from "../framework";
4
4
 
5
- export default function () {
6
- return <Page title="首页" description="欢迎使用本系统">
7
- <Card>欢迎使用本系统</Card>
8
- </Page>
5
+ export default class extends React.Component {
6
+ render() {
7
+ return <Page title="首页" description="欢迎使用本系统">
8
+ <Card>欢迎使用本系统</Card>
9
+ </Page>
10
+ }
9
11
  }
@@ -1,26 +1,23 @@
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 {history} from 'umi';
5
- import {EventBus, HttpUtils, PageUtils, GlobalData} from "../framework";
4
+ import {EventBus, HttpUtils, GlobalData, history} from "../../framework";
6
5
 
7
6
  import "./login.less"
8
7
 
9
- function getRedirect() {
10
- let redirect = PageUtils.currentParams()['redirect'];
11
- if (redirect) {
12
- redirect = decodeURIComponent(redirect)
13
- } else {
8
+ function getRedirect(query) {
9
+ let redirect = query?.redirect;
10
+ if (!redirect) {
14
11
  redirect = '/'
15
12
  }
16
13
  return redirect;
17
14
  }
18
15
 
19
- function postLogin(values) {
16
+ function postLogin(values, query) {
20
17
  return new Promise((resolve, reject) => {
21
18
  HttpUtils.post('/admin/auth/login', values).then(rs => {
22
19
  EventBus.emit('loginSuccess')
23
- history.push(getRedirect())
20
+ history.push(getRedirect(query))
24
21
  resolve(rs)
25
22
  }).catch(e => {
26
23
  console.error('[Login] 登录失败:', e);
@@ -63,7 +60,7 @@ export default class extends React.Component {
63
60
  submit = values => {
64
61
  this.setState({logging: true})
65
62
  values.password = encodePassword(values.password)
66
- postLogin(values).finally(() => {
63
+ postLogin(values, this.props.location?.query).finally(() => {
67
64
  this.setState({logging: false})
68
65
  })
69
66
  }
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ import {Page} from "../../framework";
3
+ import {Button, message, Modal, Space} from "antd";
4
+
5
+ export default class extends React.Component {
6
+
7
+ state = {
8
+ modalOpen:false
9
+ }
10
+
11
+ render() {
12
+ return <Page title="测试组件">
13
+
14
+ <Space>
15
+ <Button type={"primary"} onClick={()=>{message.info('你好,李白!')}} >message.info</Button>
16
+
17
+ <Button danger onClick={()=>{Modal.info({content:'你好,李白!'})}} >modal.info</Button>
18
+
19
+ <Button onClick={()=>{this.setState({modalOpen:true})}} >modal.组件</Button>
20
+
21
+ </Space>
22
+
23
+ <Modal title='modal组件' open={this.state.modalOpen} onCancel={()=>this.setState({modalOpen:false})}>
24
+ 内容内容
25
+ </Modal>
26
+
27
+
28
+ </Page>
29
+ }
30
+ }
@@ -1,42 +1,21 @@
1
1
  import React from "react";
2
2
  import {Button, Form, Input, message} from "antd";
3
- import {history} from 'umi'
4
- import {HttpUtils, PageUtils, GlobalData} from "../framework";
3
+ import {HttpUtils, history} from "../../framework";
5
4
 
6
5
  export default class extends React.Component {
7
6
 
8
- state = {
9
- checking: true
10
- }
11
-
12
- async componentDidMount() {
13
- try {
14
- const rs = await HttpUtils.get('/admin/public/user-info', null, {showError: false});
15
- if (!rs.login) {
16
- PageUtils.redirectToLogin();
17
- return;
18
- }
19
- GlobalData.setLoginInfo(rs.loginInfo);
20
- this.setState({checking: false});
21
- } catch (e) {
22
- PageUtils.redirectToLogin();
23
- }
24
- }
25
-
26
7
  onFinish = (values) => {
27
8
  HttpUtils.post('admin/userCenter/update-pwd', values).then(() => {
28
9
  message.success('修改密码成功,请重新登录');
29
- history.push('/login');
10
+ history.push('/public/login');
30
11
  })
31
12
  }
32
13
 
33
14
  validator = (rule, value) => {
34
- return HttpUtils.get("admin/sysUser/pwd-strength", {password: value})
15
+ return HttpUtils.get("admin/sysUser/pwd-strength", {password: value}, {showError: false})
35
16
  }
36
17
 
37
18
  render() {
38
- if (this.state.checking) return null;
39
-
40
19
  return (
41
20
  <div style={{
42
21
  display: 'flex',
@@ -1,11 +1,12 @@
1
1
  import {PlusOutlined} from '@ant-design/icons'
2
- import {Button, Form, Input, InputNumber, Modal, Popconfirm} from 'antd'
2
+ import {Button, Form, Input, InputNumber, Popconfirm} from 'antd'
3
3
  import React from 'react'
4
4
  import {
5
5
  DictUtils,
6
6
  FieldBoolean,
7
7
  FieldDictSelect,
8
8
  FieldEditor,
9
+ FormModal,
9
10
  HttpUtils,
10
11
  Page,
11
12
  PermActions,
@@ -17,28 +18,27 @@ const {TextArea} = Input;
17
18
  export default class extends React.Component {
18
19
 
19
20
  state = {
20
- formValues: {},
21
- formOpen: false,
21
+ editing: false,
22
22
  }
23
23
 
24
- formRef = React.createRef()
24
+ modalRef = React.createRef()
25
25
  tableRef = React.createRef()
26
26
 
27
27
  handleAdd = () => {
28
- this.setState({formOpen: true, formValues: {}})
28
+ this.setState({editing: false})
29
+ this.modalRef.current.open({})
29
30
  }
30
31
 
31
32
  handleEdit = record => {
32
- this.setState({formOpen: true, formValues: record})
33
+ this.setState({editing: true})
34
+ this.modalRef.current.open(record)
33
35
  }
34
36
 
35
- onFinish = values => {
37
+ onFinish = async values => {
36
38
  const isNew = !values.id;
37
39
  const url = isNew ? 'admin/article/create' : 'admin/article/update';
38
- HttpUtils.post(url, values).then(rs => {
39
- this.setState({formOpen: false})
40
- this.tableRef.current.reload()
41
- })
40
+ await HttpUtils.post(url, values)
41
+ this.tableRef.current.reload()
42
42
  }
43
43
 
44
44
  handleDelete = record => {
@@ -94,59 +94,54 @@ export default class extends React.Component {
94
94
  return <Page
95
95
  title="文章管理"
96
96
  description="管理系统文章,如关于、帮助等页面"
97
- actions={<Button perm='article:create' type='primary' icon={<PlusOutlined/>} onClick={this.handleAdd}>新增</Button>}
98
97
  >
99
98
  <ProTable
100
99
  actionRef={this.tableRef}
100
+ toolBarRender={() => (
101
+ <PermActions>
102
+ <Button perm='article:create' type='primary' icon={<PlusOutlined/>} onClick={this.handleAdd}>新增</Button>
103
+ </PermActions>
104
+ )}
101
105
  request={(params) => HttpUtils.get('admin/article/page', params)}
102
106
  columns={this.columns}
103
- >
104
- <Form.Item label='编码' name='code'>
105
- <Input/>
107
+ searchFormRender={() => (
108
+ <>
109
+ <Form.Item label='编码' name='code'>
110
+ <Input/>
111
+ </Form.Item>
112
+ <Form.Item label='标题' name='title'>
113
+ <Input/>
114
+ </Form.Item>
115
+ </>
116
+ )}
117
+ />
118
+
119
+ <FormModal ref={this.modalRef} title='文章' width={800} onFinish={this.onFinish}>
120
+
121
+ <Form.Item label='编码' name='code' rules={[{required: true}]}>
122
+ <Input disabled={this.state.editing}/>
106
123
  </Form.Item>
107
- <Form.Item label='标题' name='title'>
124
+
125
+ <Form.Item label='标题' name='title' rules={[{required: true}]}>
108
126
  <Input/>
109
127
  </Form.Item>
110
- </ProTable>
111
-
112
- <Modal title='文章'
113
- open={this.state.formOpen}
114
- onOk={() => this.formRef.current.submit()}
115
- onCancel={() => this.setState({formOpen: false})}
116
- destroyOnHidden
117
- width={800}
118
- >
119
- <Form ref={this.formRef} labelCol={{flex: '100px'}}
120
- initialValues={this.state.formValues}
121
- onFinish={this.onFinish}
122
- >
123
- <Form.Item name='id' noStyle></Form.Item>
124
-
125
- <Form.Item label='编码' name='code' rules={[{required: true}]}>
126
- <Input disabled={!!this.state.formValues.id}/>
127
- </Form.Item>
128
-
129
- <Form.Item label='标题' name='title' rules={[{required: true}]}>
130
- <Input/>
131
- </Form.Item>
132
-
133
- <Form.Item label='内容' name='content'>
134
- <FieldEditor />
135
- </Form.Item>
136
-
137
- <Form.Item label='显示位置' name='position' rules={[{required: true}]}>
138
- <FieldDictSelect typeCode='articlePosition'/>
139
- </Form.Item>
140
-
141
- <Form.Item label='排序' name='seq'>
142
- <InputNumber/>
143
- </Form.Item>
144
-
145
- <Form.Item label='启用' name='enabled'>
146
- <FieldBoolean/>
147
- </Form.Item>
148
- </Form>
149
- </Modal>
128
+
129
+ <Form.Item label='内容' name='content'>
130
+ <FieldEditor />
131
+ </Form.Item>
132
+
133
+ <Form.Item label='显示位置' name='position' rules={[{required: true}]}>
134
+ <FieldDictSelect typeCode='articlePosition'/>
135
+ </Form.Item>
136
+
137
+ <Form.Item label='排序' name='seq'>
138
+ <InputNumber/>
139
+ </Form.Item>
140
+
141
+ <Form.Item label='启用' name='enabled'>
142
+ <FieldBoolean/>
143
+ </Form.Item>
144
+ </FormModal>
150
145
  </Page>
151
146
  }
152
147
  }