前端:修复管理员无分页的问题

This commit is contained in:
YunaiV 2019-03-19 03:39:17 +08:00
parent e2619ce5d4
commit 76818dab18
8 changed files with 55 additions and 18 deletions

View File

@ -0,0 +1,10 @@
// 校验必须是英文或者数字
export function checkTypeWithEnglishAndNumbers (rule, value, callback, text) {
let char = /^[a-zA-Z0-9]+$/
if (char.test(value)) {
callback()
} else {
callback(text)
}
}

View File

@ -49,10 +49,10 @@ function getDictionaryTree(req, res) {
}
export default {
'GET /admin-api/admins/admin/menu_resource_tree': getAdminMenu,
'GET /admin-api/admins/admin/menu_resource_tree': getAdminMenuAll,
'GET /admin-api/admins/admin/url_resource_list': getAdminUrls,
'GET /admin-api/admins/resource/tree': getResourceTree,
'GET /admin-api/admins/role/page': getQueryRole,
'GET /admin-api/admins/admin/page': getQueryRole,
// 'GET /admin-api/admins/admin/page': getQueryRole,
'GET /admin-api/admins/data_dict/tree': getDictionaryTree,
};

View File

@ -5,6 +5,7 @@ export default class DictionaryText extends PureComponent {
componentDidMount() {}
render() {
debugger;
const { dicKey, dicValue } = this.props;
return (
<DictionaryContext.Consumer>

View File

@ -82,6 +82,7 @@ export default {
payload: {
list: admins,
count,
pageNo: payload.pageNo + 1
},
});
},

View File

@ -3,10 +3,12 @@
import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import { Card, Form, Input, Button, Modal, message, Table, Divider, Tree, Spin } from 'antd';
import { checkTypeWithEnglishAndNumbers } from '../../../helpers/validator'
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import styles from './AdminList.less';
import moment from "moment";
import Pagination from "antd/es/pagination";
const FormItem = Form.Item;
const { TreeNode } = Tree;
@ -44,18 +46,24 @@ const CreateForm = Form.create()(props => {
>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="用户名">
{form.getFieldDecorator('username', {
rules: [{ required: true, message: '请输入用户名!', min: 2 }],
rules: [{ required: true, message: '请输入用户名!'},
{max: 16, min:6, message: '长度为6-16位'},
{ validator: (rule, value, callback) => checkTypeWithEnglishAndNumbers(rule, value, callback, '数字以及字母')}
],
initialValue: initValues.username,
})(<Input placeholder="请输入" />)}
</FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="昵称">
{form.getFieldDecorator('nickname', {
rules: [{ required: true, message: '请输入昵称!', min: 2 }],
rules: [{ required: true, message: '请输入昵称!'},
{max: 10, message: '姓名最大长度为10'}],
initialValue: initValues.nickname,
})(<Input placeholder="请输入" />)}
</FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="密码">
{form.getFieldDecorator('password', {
rules: [{ required: modalType === 'add', message: '请填写密码'}, // 添加时,必须输入密码
{max: 16, min: 6, message: '长度为6-18位'}],
initialValue: initValues.password,
})(<Input placeholder="请输入" type="password" />)}
</FormItem>
@ -304,9 +312,21 @@ class ResourceList extends PureComponent {
});
};
onPageChange = (page = {}) => {
const { dispatch } = this.props;
// debugger;
dispatch({
type: 'adminList/query',
payload: {
pageNo: page - 1,
pageSize: 10,
}
});
}
render() {
const { list, data } = this.props;
const { roleList, roleCheckedKeys, roleAssignLoading } = data;
const { count, pageNo, pageSize, roleList, roleCheckedKeys, roleAssignLoading } = data;
const {
modalVisible,
modalType,
@ -335,7 +355,7 @@ class ResourceList extends PureComponent {
title: '状态',
dataIndex: 'status',
render(val) {
return <span>{status[val]}</span>;
return <span>{status[val]}</span>; // TODO 芋艿此处要改
},
},
{
@ -386,6 +406,12 @@ class ResourceList extends PureComponent {
columns={columns}
dataSource={list}
rowKey="id"
pagination={{
current: pageNo,
pageSize: pageSize,
total: count,
onChange: this.onPageChange
}}
/>
</Card>
<CreateForm {...parentMethods} modalVisible={modalVisible} />

View File

@ -42,6 +42,8 @@ public class AdminController {
// =========== 当前管理员相关的资源 API ===========
// TODO 功能当前管理员
@SuppressWarnings("Duplicates")
@GetMapping("/menu_resource_tree")
@ApiOperation(value = "获得当前登陆的管理员拥有的菜单权限", notes = "以树结构返回")
@ -120,7 +122,7 @@ public class AdminController {
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
@RequestParam("username") String username,
@RequestParam("nickname") String nickname,
@RequestParam("password") String password) {
@RequestParam(value = "password", required = false) String password) {
AdminUpdateDTO adminUpdateDTO = new AdminUpdateDTO().setId(id).setUsername(username).setNickname(nickname).setPassword(password);
return adminService.updateAdmin(AdminSecurityContextHolder.getContext().getAdminId(), adminUpdateDTO);
}

View File

@ -3,17 +3,17 @@ package cn.iocoder.mall.admin.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.OAuth2Service;
import cn.iocoder.mall.admin.api.bo.OAuth2AccessTokenBO;
import cn.iocoder.mall.admin.application.convert.AdminConvert;
import cn.iocoder.mall.admin.application.convert.PassportConvert;
import cn.iocoder.mall.admin.application.vo.AdminInfoVO;
import cn.iocoder.mall.admin.application.vo.PassportLoginVO;
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
import com.alibaba.dubbo.config.annotation.Reference;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("admins/passport")
@ -35,10 +35,8 @@ public class PassportController {
return PassportConvert.INSTANCE.convert(result);
}
// TODO 艿艿后续继续完善
@GetMapping("/info")
public CommonResult<AdminInfoVO> info() {
return CommonResult.success(AdminConvert.INSTANCE.convert(AdminSecurityContextHolder.getContext()));
}
// TODO 功能 logout
// TODO 功能 refresh_token
}

View File

@ -77,7 +77,6 @@ public class OAuth2ServiceImpl implements OAuth2Service {
}
// 获得管理员拥有的角色
List<AdminRoleDO> adminRoleDOs = adminService.getAdminRoles(accessTokenDO.getAdminId());
// TODO 芋艿有个 bug 要排除掉已经失效的角色
return CommonResult.success(OAuth2Convert.INSTANCE.convertToAuthentication(accessTokenDO, adminRoleDOs));
}