import React from 'react'; import { Icon, Modal, message, Spin, Input, Select, DatePicker, Button, Row, Col, Table, Form, Upload } from 'antd'; import './comprehensive.less'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; import moment from 'moment'; import { copyrightStateList } from '../../../dataDic.js'; import { companySearch, getCopyrightState, getTime, copyrightDownloadFile, beforeUploadFile, getInUrgentTime, getVacations, getPreview } from '../../../tools.js'; const CopyrightDescForm = Form.create()(React.createClass({ getInitialState() { return { visible: false, loading: false, stateOption: [], stateTable: [], contactsOption: [], vacations: [], stateColumns: [{ title: '申请状态', dataIndex: 'status', key: 'status', render: (text) => { return getCopyrightState(text) } }, { title: '处理时间', dataIndex: 'recordTimeFormattedDate', key: 'recordTimeFormattedDate', }, { title: '负责人', dataIndex: 'principal', key: 'principal', }, { title: '操作人', dataIndex: 'operator', key: 'operator', }, { title: '备注', dataIndex: 'comment', key: 'comment', }] }; }, componentWillMount() { this.loadData(); getVacations((data) => { this.setState({ vacations: data }); }); }, loadData(uid, id) { this.setState({ loading: true }); $.when($.ajax({ method: "get", dataType: "json", crossDomain: false, cache: false, url: globalConfig.context + "/api/admin/copyright/logs", data: { id: id || this.props.data.id } }), $.ajax({ method: "get", dataType: "json", crossDomain: false, cache: false, url: globalConfig.context + "/api/admin/getContacts", data: { uid: uid || this.props.data.uid } }), $.ajax({ method: "get", dataType: "json", crossDomain: false, cache: false, url: globalConfig.context + "/api/admin/copyright/detail", data: { id: id || this.props.data.id } })).done((data1, data2, data3) => { let _me = this; //状态流转table this.state.stateTable = []; if (data1[0].error && data1[0].error.length) { message.warning(data1[0].error[0].message); } else { data1[0].data.map(function (item, i) { _me.state.stateTable.push({ key: i, recordTimeFormattedDate: item.recordTimeFormattedDate, status: item.status, principal: item.principal, operator: item.operator, comment: item.comment }); }); }; //获取联系人 this.state.contactsOption = []; if (data2[0].error && data2[0].error.length) { message.warning(data2[0].error[0].message); } else { for (let item in data2[0].data) { let theData = data2[0].data[item]; _me.state.contactsOption.push( {theData} ); }; }; //获取详细数据 if (!data3[0].data && data3[0].error && data3[0].error.length) { message.warning(data3[0].error[0].message); } else if (data3[0].data) { let detailData = data3[0].data; this.setState({ id: detailData.id, province: detailData.province, postalAddress: detailData.postalAddress, unitName: detailData.unitName, orgCode: detailData.orgCode, serialNumber: detailData.serialNumber, createTime: detailData.createTime, acceptTime: detailData.acceptTime, principal: detailData.principal, contact: detailData.contact, copyrightName: detailData.copyrightName, copyrightNumber: detailData.copyrightNumber, status: detailData.status, comment: detailData.comment, workIssue: detailData.workIssue, outsource: detailData.outsource, inUrgent: detailData.inUrgent, authorizedDate: detailData.authorizedDate, fisrtContact: detailData.fisrtContact, secondContact: detailData.secondContact, thirdContact: detailData.thirdContact, city: detailData.city, area: detailData.area, postcode: detailData.postcode, certificateUrl: detailData.certificateUrl, applicationUrl: detailData.applicationUrl, certificateUrlDownloadFileName: detailData.certificateUrlDownloadFileName, applicationUrlDownloadFileName: detailData.applicationUrlDownloadFileName, authorizedDateFormattedDate: detailData.authorizedDateFormattedDate, createTimeFormattedDate: detailData.createTimeFormattedDate, acceptTimeFormattedDate: detailData.acceptTimeFormattedDate, expectTime: [detailData.acceptTime, detailData.inUrgent] }); }; }).always(function () { this.setState({ loading: false }); }.bind(this)); }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { this.loadData(nextProps.data.uid, nextProps.data.id); this.state.fileList_copyright_apply = []; this.state.fileList_copyright_auth = []; this.props.form.resetFields(); }; }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (values.status || values.principal || values.recordTime || values.comment) { if (!values.status || !values.principal || !values.recordTime) { message.warning("请填写完整的状态流转信息!"); return; }; }; if (!err) { this.props.spinState(true); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/copyright/modify", data: { "id": this.props.data.id, "contact": values.contact, // 联系人, 1,2,3 //"copyrightInfo": values.copyrightInfo, // 软著简介,size 0-255 "copyrightName": values.copyrightName, // 软著名称, size 0-60 "copyrightNumber": values.copyrightNumber, "outsource": values.outsource, // 外包公司, size 0-60 //"workIssue": values.workIssue, // 派单信息, size 0-128 "inUrgent": values.inUrgent, // 加急天数, "status": values.status, // 状态 "comment": values.comment, // 备注 size 0-128 "recordTime": values.recordTime ? values.recordTime.format("YYYY-MM-DD HH:mm:ss") : undefined, // 状态修改时间 yyyy-MM-dd HH:mm:ss "principal": values.principal // 负责人id } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); this.props.clickOk(); this.props.form.resetFields(); this.props.spinState(false); } else { message.warning(data.error[0].message); this.props.spinState(false); } }.bind(this)); } }); }, render() { const FormItem = Form.Item; const { getFieldDecorator } = this.props.form; const theData = this.state; const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 16 }, }; const _me = this; return (
{theData.unitName} {theData.orgCode}
{theData.postalAddress} {getFieldDecorator('contact', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: theData.contact })( )}

状态流转记录:

{getFieldDecorator('status')( )} {getFieldDecorator('recordTime')( )} {getFieldDecorator('principal')( )} {getFieldDecorator('comment')( )}
编号{theData.serialNumber}外包公司{getFieldDecorator('outsource', { initialValue: theData.outsource })( )} 软著名称{getFieldDecorator('copyrightName', { initialValue: theData.copyrightName })( )} 软著编号{getFieldDecorator('copyrightNumber', { initialValue: theData.copyrightNumber })( )} 加急天数{getFieldDecorator('inUrgent', { initialValue: theData.inUrgent ? String(theData.inUrgent) : '0' })( )} {theData.authorizedDateFormattedDate ? 下证时间{theData.authorizedDateFormattedDate} : 下证时间(预计){(() => { if (theData.expectTime && theData.expectTime[0]) { if (theData.expectTime[1]) { return getTime(getInUrgentTime(moment(theData.expectTime[0]), theData.expectTime[1], this.state.vacations)) } else { return getTime(getInUrgentTime(moment(theData.expectTime[0]), 45, this.state.vacations)) }; }; })()} }
{ if (info.file.status !== 'uploading') { // console.log(info.file, info.fileList); } if (info.file.status === 'done') { if (!info.file.response.error.length) { message.success(`${info.file.name} 文件上传成功!`); } else { message.warning(info.file.response.error[0].message); return; }; this.state.copyrightApplyUrl = info.file.response.data; } else if (info.file.status === 'error') { message.error(`${info.file.name} 文件上传失败。`); }; this.setState({ fileList_copyright_apply: info.fileList.slice(-1) }); }} >

{theData.applicationUrl ? 软著申请书 { var newTab = window.open('about:blank'); getPreview(theData.id, 'copyright', 'copyright_apply', function (data) { newTab.location.href = data; }); }}> : 未上传!}

{ if (info.file.status !== 'uploading') { // console.log(info.file, info.fileList); } if (info.file.status === 'done') { if (!info.file.response.error.length) { message.success(`${info.file.name} 文件上传成功!`); } else { message.warning(info.file.response.error[0].message); return; }; this.state.copyrightAuthUrl = info.file.response.data; } else if (info.file.status === 'error') { message.error(`${info.file.name} 文件上传失败。`); }; this.setState({ fileList_copyright_auth: info.fileList.slice(-1) }); }} >

{ theData.certificateUrl ? 软著证书 { var newTab = window.open('about:blank'); getPreview(theData.id, 'copyright', 'copyright_auth', function (data) { newTab.location.href = data; }); }}> : 未上传!}

); } })); const CopyrightDesc = React.createClass({ getInitialState() { return { visible: false, loading: false }; }, componentWillReceiveProps(nextProps) { this.state.visible = nextProps.showDesc }, showModal() { this.setState({ visible: true, }); }, handleOk() { this.setState({ visible: false, }); this.props.closeDesc(false, true); }, handleCancel(e) { this.setState({ visible: false, }); this.props.closeDesc(false); }, spinChange(e) { this.setState({ loading: e }); }, render() { return (
); } }); export default CopyrightDesc;