Sword/src/pages/System/Dept/Dept.js

107 lines
2.5 KiB
JavaScript

import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Button, Col, Form, Input, Row } from 'antd';
import Panel from '../../../components/Panel';
import Grid from '../../../components/Sword/Grid';
import { DEPT_LIST } from '../../../actions/dept';
import { tenantMode } from '../../../defaultSettings';
const FormItem = Form.Item;
@connect(({ dept, loading }) => ({
dept,
loading: loading.models.dept,
}))
@Form.create()
class Dept extends PureComponent {
// ============ 查询 ===============
handleSearch = params => {
const { dispatch } = this.props;
dispatch(DEPT_LIST(params));
};
// ============ 查询表单 ===============
renderSearchForm = onReset => {
const { form } = this.props;
const { getFieldDecorator } = form;
return (
<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
<Col md={6} sm={24}>
<FormItem label="部门名称">
{getFieldDecorator('deptName')(<Input placeholder="请输入部门名称" />)}
</FormItem>
</Col>
<Col md={6} sm={24}>
<FormItem label="租户编号">
{getFieldDecorator('tenantCode')(<Input placeholder="请输入角色名称" />)}
</FormItem>
</Col>
<Col md={6} sm={24}>
<FormItem label="部门全称">
{getFieldDecorator('fullName')(<Input placeholder="请输入部门全称" />)}
</FormItem>
</Col>
<Col>
<div style={{ float: 'right' }}>
<Button type="primary" htmlType="submit">
查询
</Button>
<Button style={{ marginLeft: 8 }} onClick={onReset}>
重置
</Button>
</div>
</Col>
</Row>
);
};
render() {
const code = 'dept';
const {
form,
loading,
dept: { data },
} = this.props;
const columns = [
{
title: '租户编号',
dataIndex: 'tenantCode',
},
{
title: '部门名称',
dataIndex: 'deptName',
},
{
title: '部门全称',
dataIndex: 'fullName',
},
{
title: '排序',
dataIndex: 'sort',
},
];
if (!tenantMode) {
columns.splice(0, 1);
}
return (
<Panel>
<Grid
code={code}
form={form}
onSearch={this.handleSearch}
renderSearchForm={this.renderSearchForm}
loading={loading}
data={data}
columns={columns}
/>
</Panel>
);
}
}
export default Dept;