|
import React from 'react';
|
|
import { Row, Col, Input, DatePicker, Button, Modal, Upload, Icon, message, Breadcrumb, TimePicker, Badge, Select, Popconfirm, Spin } from 'antd';
|
const { TextArea } = Input;
|
import HeadView from '../view/HeadView';
|
import BusDetailView from '../view/BusDetailView';
|
import TableView from '../view/TableView';
|
import ImageBoxView from '../view/ImageBoxView'
|
// 引入编辑器以及编辑器样式
|
import Fetch from '../fetch';
|
import moment from 'moment';
|
const format = 'HH:mm';
|
const { Option } = Select;
|
const yearFormat = 'YYYY-MM-DD';
|
const divStyle = {
|
margin: '20px'
|
}
|
const domain = Fetch.domain;
|
|
function typeStatus(type) {
|
switch (type) {
|
case 1:
|
return "待审核";
|
case 2:
|
return "未签到";
|
case 3:
|
return "已签到";
|
case 4:
|
return "不通过";
|
case 99:
|
return "取消";
|
}
|
}
|
export default class CareListEdit extends React.Component {
|
constructor(props) {
|
super(props);
|
this.state = {
|
dateSource: [],
|
savedate: {},
|
formdata: {},
|
fileList: [],
|
previewVisible: false,
|
previewImage: '',
|
visible: false,
|
hitList: [],
|
num: 0,
|
taskType: 1,
|
disabled: true,
|
status: '',
|
loading: false,
|
socialTaskObject: '',
|
};
|
}
|
|
componentDidMount() {
|
document.title = '社会关护管理详情';
|
this.getDetail();
|
}
|
|
getDetail = () => {
|
const { id } = this.props.match.params;
|
this.setState({ loading: true })
|
Fetch.socialfind(id)
|
.then(res => {
|
console.log(res)
|
let { startTime, endTime } = res;
|
if (startTime == null) {
|
startTime = Date.now();
|
}
|
if (endTime == null) {
|
endTime = Date.now();
|
}
|
this.setState({
|
savedate: {
|
...res,
|
startDate: moment(startTime).format(yearFormat),
|
startHour: moment(startTime).format(format),
|
endDate: moment(endTime).format(yearFormat),
|
endHour: moment(endTime).format(format),
|
taskType: res.taskType || 1
|
},
|
taskType: res.taskType || 1,
|
// status: res.activityStatus || '',
|
socialTaskObject: res.socialTaskObject ? { id: res.socialTaskObject.objectId, objectName: res.socialTaskObject.objectName, taskReport:res.socialTaskObject.taskReport } : {},
|
disabled: res.status ? true : false,
|
fileList: res.attachments || [],
|
loading: false,
|
});
|
})
|
}
|
|
saveInputChange = ({ target: { value, name } }) => {
|
this.setState(({ savedate }) => ({
|
savedate: {
|
...savedate,
|
[name]: value
|
}
|
}))
|
}
|
|
selectChange = ({ target: { value, name } }) => {
|
console.log(value, name)
|
this.setState(({ socialTaskObject }) => ({
|
socialTaskObject: {
|
...socialTaskObject,
|
[name]: value
|
}
|
}))
|
}
|
|
submit = () => {
|
const { savedate, socialTaskObject } = this.state;
|
savedate.startTime = moment(savedate.startDate + " " + moment(savedate.startHour).format(format), 'YYYY-MM-DD HH:mm')
|
savedate.endTime = moment(savedate.endDate + " " + moment(savedate.endHour).format(format), 'YYYY-MM-DD HH:mm')
|
console.log(savedate);
|
console.log(socialTaskObject);
|
let data2 = {}
|
if (!savedate.taskTitle) {
|
message.warning("任务标题不能为空");
|
return;
|
}
|
if (!savedate.taskAddress) {
|
message.warning("任务地点不能为空");
|
return;
|
}
|
if (!savedate.taskRequire) {
|
message.warning("任务要求不能为空");
|
return;
|
}
|
if (!savedate.taskProcess) {
|
message.warning("任务流程不能为空");
|
return;
|
}
|
if (!socialTaskObject.id) {
|
message.warning("请选择任务对象");
|
return;
|
} else {
|
const data = savedate.companies.filter(item => (item.id == socialTaskObject.id))
|
const data1 = { objectId: data[0].id, objectName: data[0].companyName }
|
console.log(data)
|
console.log(data1)
|
data2 = { ...savedate, socialTaskObject: data1 }
|
}
|
|
console.log(data2)
|
|
Fetch.socialSave(data2)
|
.then(res => {
|
if (res.code === 0) {
|
message.success("提交成功!");
|
this.props.history.push("/careList")
|
} else {
|
message.error('保存失败,请联系管理员', 2)
|
}
|
});
|
}
|
|
cancle = () => {
|
this.props.history.push("/careList");
|
}
|
handlePreview = (file) => {
|
this.setState({
|
previewImage: file.url || file.thumbUrl,
|
previewVisible: true,
|
});
|
}
|
|
showModal = () => {
|
this.setState({
|
visible: true,
|
});
|
}
|
|
handleCancelModel = (e) => {
|
this.setState({
|
visible: false,
|
});
|
}
|
|
handleOk = e => {
|
const { savedate } = this.state;
|
console.log(savedate);
|
|
this.setState({
|
visible: false,
|
});
|
Fetch.socialUpdate(savedate.id)
|
.then(res => {
|
if (res.code === 0) {
|
message.success("结束任务成功!");
|
this.props.history.push("/careList")
|
} else {
|
message.error('保存失败,请联系管理员', 2)
|
}
|
});
|
};
|
|
getNum = (e) => {
|
console.log(e.target.value)
|
this.setState({
|
num: e.target.value
|
})
|
}
|
getPerson = () => {
|
const { num } = this.state;
|
const { id } = this.state.savedate;
|
if (!num) {
|
message.error("请输入摇号数量")
|
return;
|
}
|
if (isNaN(num)) {
|
message.error("请输入数字")
|
return;
|
}
|
Fetch.getActPerson(id, num)
|
.then(res => {
|
this.setState({
|
hitList: res.data
|
})
|
});
|
}
|
|
|
publishResult = () => {
|
const { hitList, savedate } = this.state;
|
Fetch.publishResult(hitList, savedate.id)
|
.then(res => {
|
if (res.code === 0) {
|
message.success("发布成功!");
|
this.setState({
|
visible: false,
|
}, this.getDetail);
|
} else {
|
message.error('发布失败,请联系管理员', 2)
|
}
|
});
|
}
|
|
confirm = (e) => {
|
console.log(e);
|
const data = { id: e, status: 2 };
|
this.setState({ loading: true })
|
Fetch.auditPerson(data).then(res => {
|
if (res.code == 0) {
|
console.log(res)
|
this.setState({ loading: false })
|
message.success('审核通过');
|
this.getDetail();
|
} else {
|
this.setState({ loading: false })
|
message.error('请求失败,请联系管理员', 2)
|
}
|
}
|
)
|
}
|
|
cancel = (e) => {
|
console.log(e);
|
const data = { id: e, status: 4 };
|
this.setState({ loading: true })
|
Fetch.auditPerson(data).then(res => {
|
if (res.code == 0) {
|
console.log(res)
|
this.setState({ loading: false })
|
message.error('审核不通过');
|
this.getDetail();
|
} else {
|
this.setState({ loading: false })
|
message.error('请求失败,请联系管理员', 2)
|
}
|
}
|
)
|
}
|
|
handleCancel = () => this.setState({ previewVisible: false })
|
render() {
|
const { savedate, previewVisible, socialTaskObject, fileList, dateSource, hitList, taskType, disabled, loading } = this.state;
|
console.log('list', socialTaskObject)
|
const props = {
|
action: domain + 'api/v1/attachment/materials?entityId=' + savedate.id,
|
onChange: ({ file, fileList }) => {
|
this.setState({ fileList });
|
},
|
fileList: fileList,
|
onRemove: (file) => {
|
Fetch.deleteAttachment(file.uid)
|
.then(res => {
|
message.success("移除成功!");
|
});
|
this.setState(({ fileList }) => {
|
const index = fileList.indexOf(file);
|
const newFileList = fileList.slice();
|
newFileList.splice(index, 1);
|
return {
|
fileList: newFileList,
|
};
|
});
|
}
|
};
|
const columns = [{
|
title: '姓名',
|
dataIndex: 'proposerName',
|
key: 'proposerName'
|
}, {
|
title: '联系电话',
|
dataIndex: 'proposerPhone',
|
key: 'proposerPhone',
|
}, {
|
title: '是否中奖',
|
dataIndex: 'isHit',
|
key: 'isHit',
|
render: text => ((
|
savedate.activityStatus < 3 ?
|
<span>未开奖</span> :
|
(
|
text == 0 ? <span>未中奖</span> : <Badge count={'中奖'} style={{ backgroundColor: '#52c41a' }} />
|
)
|
)
|
)
|
}];
|
|
const act2columns = [{
|
title: '报名方',
|
dataIndex: 'proposerName',
|
key: 'proposerName'
|
}, {
|
title: '报名方性质',
|
dataIndex: 'signerType',
|
key: 'signerType',
|
render: text => (<span>{text == 1 ? '个人' : '企业'}</span>)
|
}, {
|
title: '报名人数',
|
dataIndex: 'signNum',
|
key: 'signNum',
|
}, {
|
title: '审核状态',
|
dataIndex: 'signStatus',
|
key: 'signStatus',
|
render: text => (<span>{typeStatus(text)}</span>)
|
}, {
|
title: '操作',
|
dataIndex: 'isHit',
|
key: 'isHit',
|
render: (text, record) => (
|
record.signStatus == 1 ?
|
<Popconfirm
|
title="确认通过审核吗?"
|
id={record.id}
|
onConfirm={e => this.confirm(record.id)}
|
onCancel={this.cancel}
|
okText="通过"
|
cancelText="不通过"
|
>
|
<a href="#">审核</a>
|
</Popconfirm> : <span disabled>审核</span>
|
)
|
}];
|
|
return (
|
<div className="app-page">
|
<Spin spinning={loading}>
|
<HeadView history={this.props.history} />
|
<Breadcrumb style={{ padding: '20px' }}>
|
<Breadcrumb.Item><a href="index.html#/entry/applyFor">社会关护管理</a></Breadcrumb.Item>
|
<Breadcrumb.Item>社会关护管理活动</Breadcrumb.Item>
|
</Breadcrumb>
|
<BusDetailView type='社会关护管理活动' >
|
<div style={divStyle}>
|
<Row type="flex" align='middle' justify="space-around">
|
<Col span={6} pull={0} style={{ textAlign: 'center' }}><span>任务类型</span></Col>
|
<Col span={6} push={0} >
|
<Select disabled={disabled} value={taskType || 1} style={{ width: "300px" }} onChange={(value) => this.saveInputChange({ target: { name: 'taskType', value } })}>
|
<Option value={1}>跟踪帮教</Option>
|
<Option value={2}>合适成年人</Option>
|
<Option value={3}>社会调查</Option>
|
<Option value={4}>心理疏导</Option>
|
</Select>
|
</Col>
|
<Col span={12} pull={0}></Col>
|
</Row>
|
</div>
|
<div style={divStyle}>
|
<Row type="flex" align='middle' justify="space-around">
|
<Col span={6} pull={0} style={{ textAlign: 'center' }}><span>任务标题</span></Col>
|
<Col span={6} push={0} ><Input disabled={disabled} placeholder="请输入任务标题" style={{ width: '300px' }} name='taskTitle' onChange={this.saveInputChange} value={savedate.taskTitle || ""} /></Col>
|
<Col span={6} pull={0} style={{ textAlign: 'center' }}><span>任务地点</span></Col>
|
<Col span={6} push={0} ><Input disabled={disabled} placeholder="请输入任务地点" style={{ width: '300px' }} name='taskAddress' onChange={this.saveInputChange} value={savedate.taskAddress || ""} /></Col>
|
</Row>
|
</div>
|
|
<div style={divStyle}>
|
<Row type="flex" align='middle' justify="space-around">
|
<Col span={6} pull={0} style={{ textAlign: 'center' }}><span>开始时间</span></Col>
|
<Col span={6} push={0} >
|
<DatePicker disabled={disabled} style={{ width: '165px' }} onChange={(_, value) => this.saveInputChange({ target: { name: 'startDate', value } })} value={moment(savedate.startDate || new Date(), yearFormat)} format={yearFormat} />
|
<TimePicker disabled={disabled} minuteStep={30} onChange={(value) => this.saveInputChange({ target: { name: 'startHour', value } })} value={moment(savedate.startHour || new Date(), format)} format={format} /></Col>
|
<Col span={6} pull={0} style={{ textAlign: 'center' }}><span>结束时间</span></Col>
|
<Col span={6} push={0} >
|
<DatePicker disabled={disabled} style={{ width: '165px' }} onChange={(_, value) => this.saveInputChange({ target: { name: 'endDate', value } })} value={moment(savedate.endDate || new Date(), yearFormat)} format={yearFormat} />
|
<TimePicker disabled={disabled} minuteStep={30} onChange={(value) => this.saveInputChange({ target: { name: 'endHour', value } })} value={moment(savedate.endHour || new Date(), format)} format={format} /></Col>
|
|
</Row>
|
</div>
|
|
<div style={divStyle}>
|
<Row type="flex" align='middle' justify="space-around">
|
<Col span={6} pull={0} style={{ textAlign: 'center' }}><span>任务要求</span></Col>
|
<Col span={18} push={0} ><TextArea disabled={disabled} rows={4} placeholder="请输入任务要求" style={{ width: '92%' }} value={savedate.taskRequire || ""} onChange={this.saveInputChange} name='taskRequire' /></Col>
|
</Row>
|
</div>
|
|
<div style={divStyle}>
|
<Row type="flex" align='middle' justify="space-around">
|
<Col span={6} pull={0} style={{ textAlign: 'center' }}><span>任务流程</span></Col>
|
<Col span={18} push={0} ><TextArea disabled={disabled} rows={4} placeholder="请输入任务流程" style={{ width: '92%' }} value={savedate.taskProcess || ""} onChange={this.saveInputChange} name='taskProcess' /></Col>
|
</Row>
|
</div>
|
|
<div style={divStyle}>
|
<Row type="flex" align='middle' justify="space-around">
|
<Col span={6} pull={0} style={{ textAlign: 'center' }}><span>任务对象</span></Col>
|
<Col span={6} push={0} >
|
<Select disabled={disabled} value={socialTaskObject ? socialTaskObject.id : ''} style={{ width: "300px" }} onChange={(value) => this.selectChange({ target: { name: 'id', value } })}>
|
{
|
savedate.companies ? savedate.companies.map(item =>
|
<Option value={item.id}>{item.companyName}</Option>
|
) : ''
|
}
|
</Select>
|
</Col>
|
<Col span={12} pull={0}></Col>
|
</Row>
|
</div>
|
|
{
|
savedate.status !== 0 ?
|
<div style={divStyle}>
|
<Row type="flex" align='middle' justify="space-around">
|
<Col span={6} pull={0} style={{ textAlign: 'center' }}><span>任务汇报</span></Col>
|
<Col span={6} push={0} >
|
<TextArea disabled={disabled} rows={4} style={{ width: '92%' }} value={socialTaskObject.taskReport || ""} onChange={this.saveInputChange} name='taskReport' />
|
</Col>
|
<Col span={12} pull={0}></Col>
|
</Row>
|
</div> : ''
|
}
|
|
{
|
savedate.status !== 0 ?
|
<div style={divStyle}>
|
<div style={divStyle}>
|
<Row type="flex" align='top' justify="space-around">
|
<Col span={6} pull={0} style={{ textAlign: 'center' }}><span>汇报附件</span></Col>
|
<Col span={18} push={0} >
|
<Upload disabled={disabled} listType="picture-card" onPreview={this.handlePreview} {...props}>
|
|
</Upload>
|
</Col>
|
</Row>
|
</div>
|
</div> :''
|
}
|
|
{
|
|
savedate.status == 2 || savedate.status == 99 ?
|
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
<Button style={{ marginLeft: '15px', width: '150px' }} onClick={this.cancle}>返回</Button>
|
</div>
|
:
|
savedate.status == 1 ?
|
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
<Button style={{ marginRight: '15px', width: '150px' }} type="primary" onClick={this.showModal}>结束任务</Button>
|
<Button style={{ marginLeft: '15px', width: '150px' }} onClick={this.cancle}>返回</Button>
|
</div> :
|
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
<Button style={{ marginRight: '15px', width: '150px' }} type="primary" onClick={this.submit}>提交</Button>
|
<Button style={{ marginLeft: '15px', width: '150px' }} onClick={this.cancle}>返回</Button>
|
</div>
|
}
|
|
</BusDetailView>
|
|
<Modal
|
title="结束任务"
|
visible={this.state.visible}
|
onOk={this.handleOk}
|
onCancel={this.handleCancelModel}
|
width='300px'
|
>
|
<p>确认结束任务吗?</p>
|
</Modal>
|
</Spin>
|
</div>
|
);
|
}
|
|
}
|