spring-cloud/admin-web/src/pages/Admin/DeptmentList.js

87 lines
2.3 KiB
Java

import React, { PureComponent, Fragment } from 'react';
import { Button, Card, Table, Form, Divider } from 'antd';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import { connect } from 'dva';
import styles from './DeptmentList.less';
import PaginationHelper from '../../../helpers/PaginationHelper';
import moment from 'moment';
@connect(({ deptmentList, loading }) => ({
deptmentList,
deptmentData: deptmentList.deptmentData,
loading: loading.models.deptmentList,
}))
@Form.create()
export default class DepetmentList extends PureComponent {
componentDidMount() {
const { dispatch } = this.props;
dispatch({
type: 'deptmentList/getDeptmentList',
payload: {
...PaginationHelper.defaultPayload,
},
});
}
render() {
const { deptmentData, deptmentList } = this.props;
const columns = [
{
title: '',
dataIndex: 'name',
},
{
title: '',
dataIndex: 'sort',
},
{
title: '',
dataIndex: 'createTime',
sorter: true,
render: val => <span>{moment(val).format('YYYY-MM-DD')}</span>,
},
{
title: '',
render: (text, record) => (
<Fragment>
<a onClick={() => this.handleModalVisible(true, 'update', record)}></a>
<Divider type="vertical" />
<a className={styles.tableDelete} onClick={() => this.handleDelete(record)}>
</a>
</Fragment>
),
},
];
// const {
// deptmentList: {deptmentData},
// loading,
// } = this.props;
return (
<PageHeaderWrapper>
<Card bordered={false}>
<div className={styles.tableList}>
<div className={styles.tableListOperator}>
<Button
icon="plus"
type="primary"
onClick={() => this.handleModalVisible(true, 'add', {})}
>
</Button>
</div>
</div>
<Table
defaultExpandAllRows={true}
columns={columns}
dataSource={deptmentData.list ? deptmentData.list : []}
rowKey="id"
/>
</Card>
</PageHeaderWrapper>
);
}
}