Skip to content

Commit 9b8528a

Browse files
committed
Update menu ui
1 parent f8012b1 commit 9b8528a

20 files changed

Lines changed: 678 additions & 392 deletions

File tree

config/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default {
2828
},
2929
proxy: {
3030
'/api/': {
31-
target: 'http://47.105.189.180:8080/',
31+
target: 'http://127.0.0.1:18088/',
3232
changeOrigin: true,
3333
},
3434
},

src/components/UpdatePasswordDialog/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ class UpdatePasswordDialog extends PureComponent {
101101
],
102102
})(<Input type="password" placeholder="请输入新密码" />)}
103103
</Form.Item>
104-
<Form.Item {...formItemLayout} label="确认旧密码">
104+
<Form.Item {...formItemLayout} label="确认新密码">
105105
{getFieldDecorator('confirm_new_password', {
106106
rules: [
107107
{
108108
required: true,
109-
message: '请输入确认旧密码',
109+
message: '请输入确认新密码',
110110
},
111111
],
112-
})(<Input type="password" placeholder="请输入确认旧密码" />)}
112+
})(<Input type="password" placeholder="请输入确认新密码" />)}
113113
</Form.Item>
114114
</Form>
115115
</Modal>

src/layouts/AdminLayout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ class AdminLayout extends React.PureComponent {
168168
}
169169

170170
return menusData.map(item => {
171-
if (!item.name || item.hidden !== 0) {
171+
if (!item.name || item.show_status !== 1) {
172172
return null;
173173
}
174174

175-
if (item.children && item.children.some(child => child.name && child.hidden === 0)) {
175+
if (item.children && item.children.some(child => child.name && child.show_status === 1)) {
176176
return (
177177
<SubMenu
178178
title={

src/models/demo.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,26 @@ export default {
111111

112112
const params = { ...payload };
113113
const formType = yield select(state => state.demo.formType);
114-
let response;
114+
let success = false;
115115
if (formType === 'E') {
116116
params.record_id = yield select(state => state.demo.formID);
117-
response = yield call(demoService.update, params);
117+
const response = yield call(demoService.update, params);
118+
if (response.status === 'OK') {
119+
success = true;
120+
}
118121
} else {
119-
response = yield call(demoService.create, params);
122+
const response = yield call(demoService.create, params);
123+
if (response.record_id && response.record_id !== '') {
124+
success = true;
125+
}
120126
}
121127

122128
yield put({
123129
type: 'changeSubmitting',
124130
payload: false,
125131
});
126132

127-
if (response.record_id && response.record_id !== '') {
133+
if (success) {
128134
message.success('保存成功');
129135
yield put({
130136
type: 'changeFormVisible',

src/models/global.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55

66
state: {
77
title: '权限管理脚手架',
8-
copyRight: '2019 LyricTian',
8+
copyRight: '2020 LyricTian',
99
defaultURL: '/dashboard',
1010
collapsed: false,
1111
openKeys: [],

src/models/login.js

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { routerRedux } from 'dva/router';
1+
import { history } from 'umi';
22
import { stringify, parse } from 'qs';
33
import store from '@/utils/store';
44
import * as loginService from '@/services/login';
55

6-
let isLogout = false;
7-
86
export default {
97
namespace: 'login',
108

@@ -72,31 +70,22 @@ export default {
7270
payload: false,
7371
});
7472

75-
isLogout = false;
7673
const params = parse(window.location.href.split('?')[1]);
7774
const { redirect } = params;
7875
if (redirect) {
7976
window.location.href = redirect;
8077
return;
8178
}
82-
yield put(routerRedux.replace('/'));
79+
history.replace('/');
8380
},
84-
*logout(_, { put, call }) {
85-
if (isLogout) {
86-
return;
87-
}
88-
isLogout = true;
89-
81+
*logout(_, { call }) {
9082
const response = yield call(loginService.logout);
9183
if (response.status === 'OK') {
92-
yield put(
93-
routerRedux.push({
94-
pathname: '/user/login',
95-
search: stringify({
96-
redirect: window.location.href,
97-
}),
98-
})
99-
);
84+
history.push('/user/login', {
85+
search: stringify({
86+
redirect: window.location.href,
87+
}),
88+
});
10089
}
10190
store.clearAccessToken();
10291
},

src/models/menu.js

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default {
100100
const search = yield select(state => state.menu.search);
101101
yield put({
102102
type: 'saveFormData',
103-
payload: { parent_id: search.parent_id ? search.parent_id : '' },
103+
payload: { parent_id: search.parentID ? search.parentID : '' },
104104
});
105105
}
106106
},
@@ -120,15 +120,17 @@ export default {
120120
const params = { ...payload };
121121
const formType = yield select(state => state.menu.formType);
122122
let success = false;
123-
let response;
124123
if (formType === 'E') {
125124
params.record_id = yield select(state => state.menu.formID);
126-
response = yield call(menuService.update, params);
125+
const response = yield call(menuService.update, params);
126+
if (response.status === 'OK') {
127+
success = true;
128+
}
127129
} else {
128-
response = yield call(menuService.create, params);
129-
}
130-
if (response.record_id && response.record_id !== '') {
131-
success = true;
130+
const response = yield call(menuService.create, params);
131+
if (response.record_id && response.record_id !== '') {
132+
success = true;
133+
}
132134
}
133135

134136
yield put({
@@ -166,6 +168,37 @@ export default {
166168
payload: response.list || [],
167169
});
168170
},
171+
*changeStatus({ payload }, { call, put, select }) {
172+
let response;
173+
if (payload.status === 1) {
174+
response = yield call(menuService.enable, payload);
175+
} else {
176+
response = yield call(menuService.disable, payload);
177+
}
178+
179+
if (response.status === 'OK') {
180+
let msg = '启用成功';
181+
if (payload.status === 2) {
182+
msg = '停用成功';
183+
}
184+
message.success(msg);
185+
const data = yield select(state => state.menu.data);
186+
const newData = { list: [], pagination: data.pagination };
187+
188+
for (let i = 0; i < data.list.length; i += 1) {
189+
const item = data.list[i];
190+
if (item.record_id === payload.record_id) {
191+
item.status = payload.status;
192+
}
193+
newData.list.push(item);
194+
}
195+
196+
yield put({
197+
type: 'saveData',
198+
payload: newData,
199+
});
200+
}
201+
},
169202
},
170203
reducers: {
171204
saveData(state, { payload }) {

src/models/role.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,26 @@ export default {
113113
const params = { ...payload };
114114
const formType = yield select(state => state.role.formType);
115115

116-
let response;
116+
let success = false;
117117
if (formType === 'E') {
118118
params.record_id = yield select(state => state.role.formID);
119-
response = yield call(roleService.update, params);
119+
const response = yield call(roleService.update, params);
120+
if (response.status === 'OK') {
121+
success = true;
122+
}
120123
} else {
121-
response = yield call(roleService.create, params);
124+
const response = yield call(roleService.create, params);
125+
if (response.record_id && response.record_id !== '') {
126+
success = true;
127+
}
122128
}
123129

124130
yield put({
125131
type: 'changeSubmitting',
126132
payload: false,
127133
});
128134

129-
if (response.record_id && response.record_id !== '') {
135+
if (success) {
130136
message.success('保存成功');
131137
yield put({
132138
type: 'changeFormVisible',

src/models/user.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,26 @@ export default {
108108

109109
const params = { ...payload };
110110
const formType = yield select(state => state.user.formType);
111-
let response;
111+
let success = false;
112112
if (formType === 'E') {
113113
params.record_id = yield select(state => state.user.formID);
114-
response = yield call(userService.update, params);
114+
const response = yield call(userService.update, params);
115+
if (response.status === 'OK') {
116+
success = true;
117+
}
115118
} else {
116-
response = yield call(userService.create, params);
119+
const response = yield call(userService.create, params);
120+
if (response.record_id && response.record_id !== '') {
121+
success = true;
122+
}
117123
}
118124

119125
yield put({
120126
type: 'changeSubmitting',
121127
payload: false,
122128
});
123129

124-
if (response.record_id && response.record_id !== '') {
130+
if (success) {
125131
message.success('保存成功');
126132
yield put({
127133
type: 'changeFormVisible',

src/pages/Demo/DemoList.js

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
22
import { connect } from 'dva';
33
import { Form } from '@ant-design/compatible';
44
import '@ant-design/compatible/assets/index.css';
5-
import { Row, Col, Card, Input, Button, Table, Modal, Badge, Select } from 'antd';
5+
import { Row, Col, Card, Input, Button, Table, Modal, Badge } from 'antd';
66
import PageHeaderLayout from '@/layouts/PageHeaderLayout';
77
import PButton from '@/components/PermButton';
88
import { formatDate } from '@/utils/utils';
@@ -169,39 +169,24 @@ class DemoList extends PureComponent {
169169
form: { getFieldDecorator },
170170
} = this.props;
171171
return (
172-
<Form onSubmit={this.onSearchFormSubmit} layout="inline">
172+
<Form onSubmit={this.onSearchFormSubmit}>
173173
<Row gutter={16}>
174-
<Col md={8} sm={24}>
175-
<Form.Item label="编号">
176-
{getFieldDecorator('code')(<Input placeholder="请输入" />)}
174+
<Col span={8}>
175+
<Form.Item>
176+
{getFieldDecorator('queryValue')(<Input placeholder="请输入需要查询的内容" />)}
177177
</Form.Item>
178178
</Col>
179-
<Col md={8} sm={24}>
180-
<Form.Item label="名称">
181-
{getFieldDecorator('name')(<Input placeholder="请输入" />)}
182-
</Form.Item>
183-
</Col>
184-
<Col md={8} sm={24}>
185-
<Form.Item label="状态">
186-
{getFieldDecorator('status')(
187-
<Select placeholder="请选择" style={{ width: '100%' }}>
188-
<Select.Option value="1">正常</Select.Option>
189-
<Select.Option value="2">停用</Select.Option>
190-
</Select>
191-
)}
192-
</Form.Item>
179+
<Col span={8}>
180+
<div style={{ overflow: 'hidden', paddingTop: 4 }}>
181+
<Button type="primary" htmlType="submit">
182+
查询
183+
</Button>
184+
<Button style={{ marginLeft: 8 }} onClick={this.onResetFormClick}>
185+
重置
186+
</Button>
187+
</div>
193188
</Col>
194189
</Row>
195-
<div style={{ overflow: 'hidden' }}>
196-
<span style={{ float: 'right', marginBottom: 24 }}>
197-
<Button type="primary" htmlType="submit">
198-
查询
199-
</Button>
200-
<Button style={{ marginLeft: 8 }} onClick={this.onResetFormClick}>
201-
重置
202-
</Button>
203-
</span>
204-
</div>
205190
</Form>
206191
);
207192
}
@@ -261,22 +246,20 @@ class DemoList extends PureComponent {
261246
<div className={styles.tableList}>
262247
<div className={styles.tableListForm}>{this.renderSearchForm()}</div>
263248
<div className={styles.tableListOperator}>
264-
<PButton code="add" icon="plus" type="primary" onClick={() => this.onAddClick()}>
249+
<PButton code="add" type="primary" onClick={() => this.onAddClick()}>
265250
新建
266251
</PButton>
267252
{selectedRows.length === 1 && [
268253
<PButton
269254
key="edit"
270255
code="edit"
271-
icon="edit"
272256
onClick={() => this.onItemEditClick(selectedRows[0])}
273257
>
274258
编辑
275259
</PButton>,
276260
<PButton
277261
key="del"
278262
code="del"
279-
icon="delete"
280263
type="danger"
281264
onClick={() => this.onItemDelClick(selectedRows[0])}
282265
>
@@ -286,7 +269,6 @@ class DemoList extends PureComponent {
286269
<PButton
287270
key="enable"
288271
code="enable"
289-
icon="check"
290272
onClick={() => this.onItemEnableClick(selectedRows[0])}
291273
>
292274
启用
@@ -296,7 +278,6 @@ class DemoList extends PureComponent {
296278
<PButton
297279
key="disable"
298280
code="disable"
299-
icon="stop"
300281
type="danger"
301282
onClick={() => this.onItemDisableClick(selectedRows[0])}
302283
>

0 commit comments

Comments
 (0)