/**
|
* 徐祥健<xuxj@hugeinfo.com.cn>
|
* 2018年7月23日 09:23
|
*
|
*/
|
|
|
import React from 'react';
|
import Abs from './Abs';
|
import Fetch from '../fetch';
|
import { Divider, message, Badge, Modal, Popconfirm } from 'antd';
|
const confirm = Modal.confirm;
|
export default class List extends React.Component {
|
constructor(props) {
|
super(props);
|
this.state = {
|
resetKey: Date.now(),
|
contact: [],
|
formdata: { businessType: 21 },
|
loading: false
|
};
|
}
|
|
componentDidMount() {
|
this.initUpdate();
|
}
|
initUpdate() {
|
const { type } = this.props.match.params;
|
const { formdata } = this.state;
|
let msgType = 0;
|
this.setState({ loading: true });
|
if (type === 'deputy') {
|
msgType = 4;
|
formdata.msgType = msgType;
|
this.getData(formdata);
|
} else if (type === 'committee') {
|
msgType = 2;
|
formdata.msgType = msgType;
|
this.getData(formdata);
|
} else if (type === 'peopleSupervise') {
|
msgType = 1;
|
formdata.msgType = msgType;
|
this.getData(formdata);
|
} else if (type === 'authProcurator') {
|
msgType = 3;
|
formdata.msgType = msgType;
|
this.getData(formdata);
|
} else if (type === 'online') {
|
formdata.msgType = 23;
|
this.getMsgList(formdata)
|
} else {
|
formdata.msgType = 24;
|
this.getMsgList(formdata)
|
}
|
}
|
|
|
componentDidUpdate(prev) {
|
if (prev.match.params.type !== this.props.match.params.type) {
|
this.initUpdate();
|
}
|
}
|
getData = (formdata) => {
|
this.setState({ loading: true });
|
Fetch.getComSugges(formdata)
|
.then(res => {
|
for (var i = 0; i < res.length; i++) {
|
res[i]['index'] = i + 1;
|
}
|
if (this.unmounted) return;
|
|
this.setState({
|
contact: res,
|
loading: false
|
});
|
});
|
}
|
getMsgList = (formdata) => {
|
this.setState({ loading: true });
|
Fetch.getMsgList(formdata)
|
.then(res => {
|
if (this.unmounted) return;
|
this.setState({
|
contact: res.contact,
|
loading: false
|
});
|
});
|
}
|
componentWillUnmount() {
|
this.unmounted = true;
|
}
|
onInputChange = ({ target: { value, name } }) => {
|
|
this.setState(({ formdata }) => ({
|
formdata: {
|
...formdata,
|
[name]: value
|
}
|
}))
|
|
|
}
|
Seaech = () => {
|
const { type } = this.props.match.params;
|
const { formdata } = this.state;
|
let msgType = 0;
|
this.setState({ loading: true });
|
if (type === 'deputy') {
|
msgType = 4;
|
formdata.msgType = msgType;
|
this.getData(formdata);
|
} else if (type === 'committee') {
|
msgType = 2;
|
formdata.msgType = msgType;
|
this.getData(formdata);
|
} else if (type === 'peopleSupervise') {
|
msgType = 1;
|
formdata.msgType = msgType;
|
this.getData(formdata);
|
} else if (type === 'authProcurator') {
|
msgType = 3;
|
formdata.msgType = msgType;
|
this.getData(formdata);
|
} else if (type === 'online') {
|
formdata.msgType = 23;
|
this.getMsgList(formdata)
|
} else {
|
formdata.msgType = 24;
|
this.getMsgList(formdata)
|
}
|
}
|
Reset = () => {
|
const { type } = this.props.match.params;
|
this.setState({ loading: true, resetKey: Date.now() });
|
if (type === 'deputy') {
|
this.getData({ businessType: 21, msgType: 4 });
|
} else if (type === 'committee') {
|
this.getData({ businessType: 21, msgType: 2 });
|
} else if (type === 'peopleSupervise') {
|
this.getData({ businessType: 21, msgType: 1 });
|
} else if (type === 'authProcurator') {
|
this.getData({ businessType: 21, msgType: 3 });
|
} else if (type === 'online') {
|
this.getMsgList({ msgType: 23 })
|
} else {
|
this.getMsgList({ msgType: 24 })
|
}
|
}
|
|
deleteItems = (businessId) => {
|
console.log(businessId);
|
confirm({
|
title: '确认要删除这条数据吗?',
|
onOk: () => {
|
Fetch.businessDel(businessId)
|
.then(data => {
|
if (data.code == 1) {
|
message.success("删除成功!")
|
if (this.unmounted) return;
|
this.setState({
|
resetKey: Date.now(),
|
formdata: {}
|
}, this.getData);
|
} else {
|
message.error('删除失败,请联系管理员', 2)
|
}
|
})
|
}
|
});
|
}
|
onDel = (_text, _record) => {
|
const { formdata } = this.state;
|
var that = this;
|
Fetch.businessDel({ businessId: _text.businessId }).then(res => {
|
if (res.code == 0) {
|
that.getData(formdata);
|
}
|
}, err => {
|
message.error(err);
|
});
|
}
|
|
titleOfType(type) {
|
if (type === 'deputy') {
|
return '人大代表联络站';
|
} else if (type === 'committee') {
|
return '政协委员联络站';
|
} else if (type === 'peopleSupervise') {
|
return '人民监督员联络站';
|
} else if (type === 'authProcurator') {
|
return '特约检察员联络站';
|
} else if (type === 'online') {
|
return '在线咨询(个人)';
|
} else if (type === 'onlineCompany') {
|
return '在线咨询(企业)';
|
}
|
return 'Unkown';
|
}
|
|
// 点击跳转
|
onClick = (busId, createId, flag) => {
|
const { type } = this.props.match.params;
|
this.props.history.push('/msgDetail/' + '21' + '/' + busId + '/' + createId + '/' + flag + '/' + type);
|
}
|
|
render() {
|
const { type } = this.props.match.params;
|
const title = this.titleOfType(type);
|
const { resetKey, contact, loading } = this.state;
|
const sed = "消息管理"
|
const columns = [{
|
title: '序号',
|
dataIndex: 'index',
|
key: 'index'
|
}, {
|
title: '消息标题',
|
dataIndex: 'title',
|
key: 'title',
|
}, {
|
title: '消息内容',
|
dataIndex: 'content',
|
key: 'content'
|
}, {
|
title: '发送人',
|
dataIndex: 'userName',
|
key: 'userName',
|
}, {
|
title: '状态',
|
dataIndex: 'status',
|
key: 'status',
|
render: text => text === "待审" ?
|
<Badge count={'待回复'} />
|
:
|
<Badge count={'已回复'} style={{ backgroundColor: '#52c41a' }} />
|
}, {
|
title: '发送时间',
|
dataIndex: 'createTime',
|
key: 'createTime'
|
}, {
|
title: '操作',
|
key: 'action',
|
render: (text, record) => (
|
<span style={{ cursor: 'pointer' }}>
|
{
|
text.status == '待审' ? <span><label onClick={() => { this.onClick(record.businessId, record.createId, 'do') }} className="theme-color"> 处理</label><Divider type="vertical" /></span> : null
|
}
|
<label onClick={() => { this.onClick(record.businessId, record.createId, 'see') }} className="theme-color">详情</label>
|
<Divider type="vertical" />
|
<Popconfirm placement="topRight" title={'你确定要删除该条记录吗'} onConfirm={() => { this.onDel(text, record) }} okText="确定" cancelText="取消" >
|
<label className="theme-color">删除</label>
|
</Popconfirm>
|
</span>
|
),
|
}];
|
|
return (
|
<Abs key={type} title={title} local={title} type={title} resetKey={resetKey} contact={contact} sed={sed} msgType={type}
|
onInputChange={this.onInputChange} Seaech={this.Seaech} Reset={this.Reset} columns={columns} loading={loading} />
|
);
|
}
|
|
}
|