import React from 'react';
|
|
import HeadView from '../view/HeadView';
|
import TableBtnView from '../view/TableBtnView';
|
import CommonSearchForm from '../view/CommonSearchForm';
|
import { Input, Button, DatePicker, Divider, message, Popconfirm, Select, Badge, Modal } 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 "心理疏导";
|
case 5:
|
return "法律援助";
|
}
|
}
|
|
const taskNodeIds = {
|
1: '跟踪帮教',
|
2: '合适成年人',
|
3: '社会调查',
|
4: '心理疏导',
|
5: '法律援助',
|
}
|
|
const activityTypeList = [
|
1,
|
2,
|
3,
|
4,
|
5
|
]
|
const activityStatusIds = {
|
0: '未开始',
|
1: '进行中',
|
2: '已结束',
|
99: '暂停',
|
}
|
|
const activityStatusList = [
|
0,
|
1,
|
2
|
]
|
|
export default class CareList extends React.Component {
|
constructor(props) {
|
super(props);
|
this.state = {
|
data: [],
|
formData: {
|
__key: Date.now(),
|
page: 1,
|
size: 10,
|
},
|
resetKey: Date.now(),
|
loading: false,
|
zIndex: '-1'
|
};
|
}
|
|
componentDidMount() {
|
document.title = '社会观护管理';
|
window.addEventListener('message', function (e) {
|
console.log('反馈',e)
|
}, false);
|
console.log('this', this);
|
this.iframeAddEventListener();
|
}
|
|
setFormData = data => {
|
console.log('form', data);
|
this.setState({
|
formData: data,
|
});
|
}
|
|
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)
|
}
|
}
|
)
|
}
|
|
showModal = (id) => {
|
this.setState({
|
visible: true,
|
zIndex: 1000
|
});
|
this.sendMsg()
|
// Fetch.socialCompanyDetail(id)
|
// .then(res => {
|
// this.setState({ savedate: res })
|
// })
|
}
|
|
renderColumns = () => {
|
return [{
|
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={'进行中'} style={{ backgroundColor: '#F1C40F' }} /> : text == 2 ? <Badge count={'已结束'} style={{ backgroundColor: '#2ECC71' }} /> : <Badge count={'暂停'} style={{ backgroundColor: '#2ECC71' }} />
|
)
|
}, {
|
title: '创建时间',
|
dataIndex: 'createTime',
|
key: 'createTime',
|
render: text => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>
|
}, {
|
title: '开始时间',
|
dataIndex: 'startTime',
|
key: 'startTime',
|
render: text => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>
|
}, {
|
title: '结束时间',
|
dataIndex: 'endTime',
|
key: 'endTime',
|
render: text => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>
|
}, {
|
title: '操作',
|
key: 'action',
|
render: (text, record) => (
|
<span>
|
{
|
record.status == 0 ?
|
<React.Fragment>
|
<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>
|
<Divider type="vertical" />
|
</Popconfirm>
|
<a onClick={() => this.reboot(record.id, 99)}>暂停</a>
|
</React.Fragment> :
|
record.status == 1 ?
|
<React.Fragment>
|
<a onClick={() => this.showModal(record.id)}>查看</a>
|
<Divider type="vertical" />
|
<a onClick={() => this.showModal(record.id)}>结束任务</a>
|
<Divider type="vertical" />
|
<a onClick={() => this.reboot(record.id, 99)}>暂停</a>
|
</React.Fragment> :
|
<React.Fragment>
|
<a onClick={() => this.showModal(record.id)}>查看</a>
|
<Divider type="vertical" />
|
<a onClick={() => this.reboot(record.id, 0)}>重启</a>
|
</React.Fragment>
|
}
|
</span>
|
),
|
}]
|
}
|
|
iframeAddEventListener = () => {
|
let _this = this;
|
this.iframeWin = this.refs.iframe && this.refs.iframe.contentWindow;
|
this.refs.iframe && this.refs.iframe.addEventListener("load", function () {
|
//代码能执行到这里说明已经载入成功完毕了
|
//这里是回调函数
|
_this.iframeWin.postMessage({
|
fgData: false
|
}, '*');
|
}, false);
|
}
|
|
sendMsg = () => {
|
this.iframeWin = this.refs.iframe && this.refs.iframe.contentWindow;
|
this.iframeWin.postMessage({
|
fgData: false
|
}, '*');
|
}
|
|
render() {
|
const { data, resetKey, visible, loading, savedate, closeKey, formData, zIndex } = 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>
|
<div style={{ background: '#fff', margin: 20 }}>
|
<CommonSearchForm
|
{...this.props}
|
formData={formData}
|
setFormData={this.setFormData}
|
searchonClick={this.searchonClick}
|
pathName={this.props.location.pathname}
|
data={[
|
{
|
type: 'input', name: '公司名称', label: '公司名称', key: 'companyName'
|
},
|
{
|
type: 'input', name: '法人姓名', label: '法人姓名', key: 'companyLegal'
|
},
|
{
|
type: 'input', name: '联系电话', label: '联系电话', key: 'companyTel'
|
},
|
]} />
|
<TableView columns={this.renderColumns()} data={data} pageSize='10' size='default' loading={loading} />
|
</div>
|
<Modal
|
zIndex={zIndex}
|
key={closeKey}
|
confirmLoading={loading}
|
visible={true}
|
title="指纹录入"
|
onCancel={() => { this.setState({ visible: false, zIndex: '-1', }) }}
|
bodyStyle={{ lineHeight: 4 }}
|
footer={null}
|
width={'80%'}
|
bodyStyle={{ height: '600px' }}
|
>
|
<iframe
|
style={{ width: '100%', height: '100%' }}
|
onLoad={() => { }}
|
ref="iframe"
|
src='./fingerprint/指纹登记.html'
|
width="100%"
|
scrolling="no"
|
frameBorder="0"
|
/>
|
</Modal>
|
|
{/* </div> */}
|
</div>
|
)
|
}
|
}
|