/**
|
* 徐祥健<xuxj@hugeinfo.com.cn>
|
* 2018年9月17日 10:35
|
*
|
*/
|
|
|
|
import React from 'react';
|
|
import HeadView from '../view/HeadView';
|
import TableBtnView from '../view/TableBtnView';
|
import { Input, Button, DatePicker, Divider, message, Breadcrumb, Select, Badge } from 'antd';
|
import moment from 'moment';
|
import Fetch from '../fetch';
|
import TableView from '../view/TableView';
|
const Option = Select.Option;
|
//1生态环境与资源保护领域 2食品药品安全领域 3文物保护领域 4英雄烈士保护领域 5国有财产保护领域 6国有土地出让领域
|
function picType(type) {
|
switch (type) {
|
case "1":
|
return "生态环境与资源保护领域";
|
case "2":
|
return "食品药品安全领域";
|
case "3":
|
return "文物保护领域";
|
case "4":
|
return "英雄烈士保护领域";
|
case "5":
|
return "国有财产保护领域";
|
case "6":
|
return "国有土地出让领域";
|
}
|
}
|
export default class BusList extends React.Component {
|
constructor(props) {
|
super(props);
|
this.state = {
|
data: [],
|
formdata: {},
|
resetKey: Date.now(),
|
loading: false
|
};
|
}
|
|
componentDidMount() {
|
|
document.title = '公益随手拍';
|
this.getData();
|
}
|
|
getData = () => {
|
const { formdata } = this.state;
|
Fetch.getSnapshot(formdata)
|
.then(res => {
|
for (var i = 0; i < res.length; i++) {
|
res[i]['index'] = i + 1;
|
}
|
this.setState({
|
data: res
|
});
|
});
|
}
|
onInputChange = ({ target: { value, name } }) => {
|
this.setState(({ formdata }) => ({
|
formdata: {
|
...formdata,
|
[name]: value
|
}
|
}))
|
}
|
|
Seaech = () => {
|
const { formdata } = this.state;
|
Fetch.getSnapshot(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);
|
}
|
onClick = (id, flag) => {
|
this.props.history.push('/snapshotDetail/' + id + '/' + flag)
|
}
|
deleteItems = (id) => {
|
confirm({
|
title: '确认要删除这条数据吗?',
|
onOk: () => {
|
Fetch.deleteCompany(id)
|
.then(data => {
|
if (data.statuscode == 1) {
|
message.success("删除成功!")
|
this.setState({
|
resetKey: Date.now(),
|
formdata: {}
|
}, this.getData);
|
} else {
|
message.error('删除失败,请联系管理员', 2)
|
}
|
})
|
}
|
});
|
}
|
render() {
|
const columns = [{
|
title: '序号',
|
dataIndex: 'index',
|
key: 'index'
|
}, {
|
title: '姓名',
|
dataIndex: 'userName',
|
key: 'userName'
|
}, {
|
title: '联系方式',
|
dataIndex: 'mobile',
|
key: 'mobile',
|
}, {
|
title: '详情说明',
|
dataIndex: 'content',
|
key: 'content',
|
}, {
|
title: '拍摄地址',
|
dataIndex: 'address',
|
key: 'address',
|
}, {
|
title: '上报类型',
|
dataIndex: 'picType',
|
key: 'picType',
|
render: text => <span>{picType(text)}</span>
|
}, {
|
title: '状态',
|
dataIndex: 'status',
|
key: 'status',
|
render: text => (
|
text == 1 ?
|
<Badge count={'待回复'} /> : <Badge count={'已回复'} style={{ backgroundColor: '#52c41a' }} />
|
)
|
}, {
|
title: '创建时间',
|
dataIndex: 'createTime',
|
key: 'createTime',
|
render: text => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>
|
}, {
|
title: '操作',
|
key: 'action',
|
render: (text, record) => (
|
<span>
|
{
|
text.status == 1 ? <span>
|
<label className='theme-color' onClick={() => this.onClick(record.id, 'do')} style={{ cursor: 'pointer' }}>处理</label>
|
<Divider type="vertical" />
|
</span> : null
|
}
|
<label className='theme-color' onClick={() => this.onClick(record.id, 'see')} style={{ cursor: 'pointer' }}>查看</label>
|
</span>
|
),
|
}];
|
const { data, loading, resetKey } = this.state;
|
return (
|
<div className="app-page">
|
<HeadView history={this.props.history} />
|
<Breadcrumb style={{ padding: '20px' }}>
|
<Breadcrumb.Item><a href="">后台中心</a></Breadcrumb.Item>
|
<Breadcrumb.Item>公益随手拍</Breadcrumb.Item>
|
</Breadcrumb>
|
<TableBtnView name={''} key={resetKey}>
|
<Input placeholder="根据姓名模糊查询" style={{ width: "200px" }} name='userName' onChange={this.onInputChange} />
|
<Input placeholder="根据联系方式模糊查询" style={{ width: "200px" }} name='mobile' onChange={this.onInputChange} />
|
<Input placeholder="根据拍摄地址模糊查询" style={{ width: "200px" }} name='address' 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>
|
<Select
|
style={{ width: 200 }}
|
placeholder="根据上报类型查询"
|
onChange={(value) => this.onInputChange({ target: { name: 'picType', value } })}
|
>
|
<Option value="1">生态环境与资源保护领域</Option>
|
<Option value="2">食品药品安全领域</Option>
|
<Option value="3">文物保护领域</Option>
|
<Option value="4">英雄烈士保护领域</Option>
|
<Option value="5">国有财产保护领域</Option>
|
<Option value="6">国有土地出让领域</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>
|
);
|
}
|
|
}
|