import React from 'react';
|
|
import HeadView from '../view/HeadView';
|
import TableBtnView from '../view/TableBtnView';
|
import { Input, Button, DatePicker, Divider, message, Popconfirm, Select, Badge } from 'antd';
|
import moment from 'moment';
|
import Fetch from '../fetch';
|
import TableView from '../view/TableView';
|
const Option = Select.Option;
|
function typeOfName(type) {
|
switch (type) {
|
case 1:
|
return "跟踪帮教";
|
case 2:
|
return "合适成年人";
|
case 3:
|
return "社会调查";
|
case 4:
|
return "心理疏导";
|
}
|
}
|
export default class CareList extends React.Component {
|
constructor(props) {
|
super(props);
|
this.state = {
|
data: [],
|
formdata: {
|
page: 1,
|
size: 10,
|
},
|
resetKey: Date.now(),
|
loading: false
|
};
|
}
|
|
componentDidMount() {
|
|
document.title = '社会关护管理';
|
this.getData();
|
}
|
|
getData = () => {
|
const { formdata } = this.state;
|
Fetch.socialQuery({ ...formdata })
|
.then(res => {
|
console.log(res)
|
for (var i = 0; i < res.rows.length; i++) {
|
res.rows[i]['index'] = i + 1;
|
}
|
this.setState({
|
data: res.rows
|
});
|
});
|
}
|
onInputChange = ({ target: { value, name } }) => {
|
this.setState(({ formdata }) => ({
|
formdata: {
|
...formdata,
|
[name]: value
|
}
|
}))
|
}
|
showModal = (id) => {
|
this.props.history.push("/careListEdit/" + id);
|
}
|
|
Seaech = () => {
|
const { formdata } = this.state;
|
Fetch.getSweeping(formdata)
|
.then(res => {
|
for (var i = 0; i < res.length; i++) {
|
res[i]['index'] = i + 1;
|
}
|
this.setState({
|
data: res
|
});
|
});
|
}
|
Reset = () => {
|
this.setState({
|
resetKey: Date.now(),
|
formdata: {}
|
}, this.getData);
|
}
|
|
confirm = (e) => {
|
console.log(e);
|
this.setState({ loading: true })
|
Fetch.socialDelete(e).then(res => {
|
if (res.code == 0) {
|
console.log(res)
|
this.setState({ loading: false })
|
message.success('删除成功');
|
this.getData();
|
} else {
|
this.setState({ loading: false })
|
message.error('删除失败,请联系管理员', 2)
|
}
|
}
|
)
|
}
|
render() {
|
const columns = [{
|
title: '任务标题',
|
dataIndex: 'taskTitle',
|
key: 'taskTitle'
|
}, {
|
title: '任务类型',
|
dataIndex: 'taskType',
|
key: 'taskType',
|
render: text => <span>{typeOfName(text)}</span>
|
}, {
|
title: '状态',
|
dataIndex: 'status',
|
key: 'status',
|
render: text => (
|
text == 0 ?
|
<Badge style={{ backgroundColor: '#6C757C' }} count={'未开始'} /> :text == 1 ? <Badge count={'F1C40F'} style={{ backgroundColor: '#6C757C' }} /> : <Badge count={'已结束'} style={{ backgroundColor: '#2ECC71' }} />
|
)
|
}, {
|
title: '创建时间',
|
dataIndex: 'createTime',
|
key: 'createTime',
|
render: text => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>
|
}, {
|
title: '操作',
|
key: 'action',
|
render: (text, record) => (
|
<span>
|
<a onClick={() => this.showModal(record.id)}>编辑</a>
|
<Divider type="vertical" />
|
<Popconfirm
|
title="确认删除任务吗?"
|
id={record.id}
|
onConfirm={e => this.confirm(record.id)}
|
okText="确定"
|
cancelText="取消"
|
>
|
<a href="#">删除</a>
|
</Popconfirm>
|
{
|
record.status==1?
|
<React.Fragment>
|
<Divider type="vertical" />
|
<a onClick={() => this.showModal(record.id)}>结束任务</a>
|
</React.Fragment>:''
|
}
|
</span>
|
),
|
}];
|
const { data, loading, resetKey } = this.state;
|
return (
|
<div className="app-page">
|
<HeadView history={this.props.history} />
|
<div style={{ marginLeft: '90%', marginBottom: '20px', marginTop: '20px' }}>
|
<Button type="primary" size='large' onClick={() => this.showModal('new')}>新建任务</Button>
|
</div>
|
{/* <Breadcrumb style={{ padding: '20px' }}>
|
<Breadcrumb.Item><a href="">后台中心</a></Breadcrumb.Item>
|
<Breadcrumb.Item>社会关护</Breadcrumb.Item>
|
</Breadcrumb> */}
|
<TableBtnView name={''} key={resetKey}>
|
<Select
|
style={{ width: 200 }}
|
placeholder="根据举报性质查询"
|
onChange={(value) => this.onInputChange({ target: { name: 'nature', value } })}
|
>
|
<Option value="1">涉黑涉恶违法犯罪行为</Option>
|
<Option value="2">涉黑涉恶违法犯罪保护伞</Option>
|
<Option value="3">其他</Option>
|
</Select>
|
<Input placeholder="根据内容模糊查询" style={{ width: "200px" }} name='content' onChange={this.onInputChange} />
|
<Select
|
style={{ width: 200 }}
|
placeholder="根据状态查询"
|
onChange={(value) => this.onInputChange({ target: { name: 'status', value } })}
|
>
|
<Option value="2">已回复</Option>
|
<Option value="1">待回复</Option>
|
</Select>
|
|
<DatePicker onChange={(_, value) => this.onInputChange({ target: { name: 'createTime', value } })} placeholder="根据创建时间查询" />
|
<Button type="primary" onClick={this.Seaech}>查询</Button>
|
<Button onClick={this.Reset}>重置</Button>
|
</TableBtnView>
|
<TableView columns={columns} data={data} pageSize='10' size='default' loading={loading} />
|
</div>
|
);
|
}
|
|
}
|