迁移 system 服务,admin 逻辑
This commit is contained in:
@@ -4,17 +4,19 @@ import {
|
||||
addAdmin,
|
||||
adminRoleAssign,
|
||||
deleteAdmin,
|
||||
queryAdmin,
|
||||
queryAdminRoleList,
|
||||
updateAdmin,
|
||||
updateAdminStatus,
|
||||
deptTreeAll,
|
||||
} from '../../services/admin';
|
||||
import {
|
||||
adminPage
|
||||
} from '../../services/system';
|
||||
import { arrayToStringParams } from '../../utils/request.qs';
|
||||
import PaginationHelper from '../../../helpers/PaginationHelper';
|
||||
|
||||
const SEARCH_PARAMS_DEFAULT = {
|
||||
nickname: '',
|
||||
name: '',
|
||||
};
|
||||
|
||||
const buildSelectTree = list => {
|
||||
@@ -76,7 +78,7 @@ export default {
|
||||
});
|
||||
|
||||
// 请求
|
||||
const response = yield call(queryAdmin, payload);
|
||||
const response = yield call(adminPage, payload);
|
||||
// 响应
|
||||
yield put({
|
||||
type: 'setAll',
|
||||
@@ -84,7 +86,7 @@ export default {
|
||||
list: response.data.list,
|
||||
pagination: PaginationHelper.formatPagination(response.data, payload),
|
||||
searchParams: {
|
||||
nickname: payload.nickname || '',
|
||||
name: payload.name || '',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ import PaginationHelper from '../../../helpers/PaginationHelper';
|
||||
|
||||
const FormItem = Form.Item;
|
||||
const { TreeNode } = Tree;
|
||||
const status = ['未知', '正常', '禁用'];
|
||||
const status = ['未知', '在职', '离职'];
|
||||
|
||||
// 列表
|
||||
function List({
|
||||
@@ -52,23 +52,6 @@ function List({
|
||||
});
|
||||
}
|
||||
|
||||
function handleStatus(record) {
|
||||
Modal.confirm({
|
||||
title: record.status === 1 ? '确认禁用' : '取消禁用',
|
||||
content: `${record.username}`,
|
||||
onOk() {
|
||||
dispatch({
|
||||
type: 'adminList/updateStatus',
|
||||
payload: {
|
||||
id: record.id,
|
||||
status: record.status === 1 ? 2 : 1,
|
||||
},
|
||||
});
|
||||
},
|
||||
onCancel() {},
|
||||
});
|
||||
}
|
||||
|
||||
function handleDelete(record) {
|
||||
Modal.confirm({
|
||||
title: `确认删除?`,
|
||||
@@ -92,7 +75,7 @@ function List({
|
||||
},
|
||||
{
|
||||
title: '员工姓名',
|
||||
dataIndex: 'nickname',
|
||||
dataIndex: 'name',
|
||||
},
|
||||
{
|
||||
title: '部门',
|
||||
@@ -115,7 +98,7 @@ function List({
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
title: '在职状态',
|
||||
dataIndex: 'status',
|
||||
render(val) {
|
||||
return <span>{status[val]}</span>; // TODO 芋艿,此处要改
|
||||
@@ -130,16 +113,12 @@ function List({
|
||||
title: '操作',
|
||||
width: 360,
|
||||
render: (text, record) => {
|
||||
const statusText = record.status === 1 ? '禁用' : '开启'; // TODO 芋艿,此处要改
|
||||
return (
|
||||
<Fragment>
|
||||
<a onClick={() => handleModalVisible(true, 'update', record)}>编辑</a>
|
||||
<Divider type="vertical" />
|
||||
<a onClick={() => handleRoleAssign(record)}>角色分配</a>
|
||||
<Divider type="vertical" />
|
||||
<a className={styles.tableDelete} onClick={() => handleStatus(record)}>
|
||||
{statusText}
|
||||
</a>
|
||||
{record.status === 2 ? (
|
||||
<span>
|
||||
<Divider type="vertical" />
|
||||
@@ -223,7 +202,7 @@ const SearchForm = Form.create()(props => {
|
||||
<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
|
||||
<Col md={6} sm={24}>
|
||||
<FormItem label="员工姓名">
|
||||
{getFieldDecorator('nickname')(<Input style={{ width: 250 }} placeholder="请输入" />)}
|
||||
{getFieldDecorator('name')(<Input style={{ width: 200 }} placeholder="请输入" />)}
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col md={6} sm={24}>
|
||||
@@ -233,7 +212,7 @@ const SearchForm = Form.create()(props => {
|
||||
})(
|
||||
<TreeSelect
|
||||
showSearch
|
||||
style={{ width: 250 }}
|
||||
style={{ width: 200 }}
|
||||
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
||||
treeData={deptSelectTree}
|
||||
placeholder="选择部门"
|
||||
@@ -327,26 +306,13 @@ const AddOrUpdateForm = Form.create()(props => {
|
||||
okText="保存"
|
||||
onCancel={() => handleModalVisible()}
|
||||
>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="账号">
|
||||
{form.getFieldDecorator('username', {
|
||||
rules: [
|
||||
{ required: true, message: '请输入账号!' },
|
||||
{ max: 16, min: 6, message: '长度为 6-16 位' },
|
||||
{
|
||||
validator: (rule, value, callback) =>
|
||||
checkTypeWithEnglishAndNumbers(rule, value, callback, '数字以及字母'),
|
||||
},
|
||||
],
|
||||
initialValue: formVals.username,
|
||||
})(<Input placeholder="请输入" />)}
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="员工姓名">
|
||||
{form.getFieldDecorator('nickname', {
|
||||
{form.getFieldDecorator('name', {
|
||||
rules: [
|
||||
{ required: true, message: '请输入员工姓名!' },
|
||||
{ max: 10, message: '姓名最大长度为 10' },
|
||||
],
|
||||
initialValue: formVals.nickname,
|
||||
initialValue: formVals.name,
|
||||
})(<Input placeholder="请输入" />)}
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="归属部门">
|
||||
@@ -364,6 +330,19 @@ const AddOrUpdateForm = Form.create()(props => {
|
||||
/>
|
||||
)}
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="账号">
|
||||
{form.getFieldDecorator('username', {
|
||||
rules: [
|
||||
{ required: true, message: '请输入账号!' },
|
||||
{ max: 16, min: 6, message: '长度为 6-16 位' },
|
||||
{
|
||||
validator: (rule, value, callback) =>
|
||||
checkTypeWithEnglishAndNumbers(rule, value, callback, '数字以及字母'),
|
||||
},
|
||||
],
|
||||
initialValue: formVals.username,
|
||||
})(<Input placeholder="请输入" />)}
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="密码">
|
||||
{form.getFieldDecorator('password', {
|
||||
rules: [
|
||||
|
||||
@@ -10,6 +10,7 @@ import styles from './RoleList.less';
|
||||
|
||||
const FormItem = Form.Item;
|
||||
const { TreeNode } = Tree;
|
||||
const types = ['未知', '系统角色', '自定义角色'];
|
||||
|
||||
// 添加 form 表单
|
||||
const CreateForm = Form.create()(props => {
|
||||
@@ -296,6 +297,13 @@ class RoleList extends PureComponent {
|
||||
title: '编码',
|
||||
dataIndex: 'code',
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
render(val) {
|
||||
return <span>{types[val]}</span>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
@@ -307,13 +315,21 @@ class RoleList extends PureComponent {
|
||||
width: 200,
|
||||
render: (text, record) => (
|
||||
<Fragment>
|
||||
<a onClick={() => this.handleModalVisible(true, 'update', record)}>更新</a>
|
||||
{record.type === 2 ? (
|
||||
<span>
|
||||
<a onClick={() => this.handleModalVisible(true, 'update', record)}>更新</a>
|
||||
</span>
|
||||
) : null}
|
||||
<Divider type="vertical" />
|
||||
<a onClick={() => this.handleAssignModalVisible(true, record)}>分配权限</a>
|
||||
<Divider type="vertical" />
|
||||
<a className={styles.tableDelete} onClick={() => this.handleDelete(record)}>
|
||||
删除
|
||||
</a>
|
||||
{record.type === 2 ? (
|
||||
<span>
|
||||
<a className={styles.tableDelete} onClick={() => this.handleDelete(record)}>
|
||||
删除
|
||||
</a>
|
||||
</span>
|
||||
) : null}
|
||||
</Fragment>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -89,3 +89,11 @@ export async function roleUpdate(params) {
|
||||
body: {},
|
||||
});
|
||||
}
|
||||
|
||||
// ========== Admin 模块 ==========
|
||||
|
||||
export async function adminPage(params) {
|
||||
return request(`/system-api/admins/admin/page?${stringify(params)}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user