import React from 'react'; import { Icon, Modal, message, Spin, Input, Select, DatePicker, Button, Table, Form, Upload } from 'antd'; import './contract.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, getPatentType, getPatentState, gethighTechState, getTechnologyState } from '../../../tools.js'; const ContractDetailForm = Form.create()(React.createClass({ getInitialState() { return { visible: false, loading: false, stateOption: [], stateTable: [], contactsOption: [], 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', } ], patentColumns: [ { title: '专利名称', dataIndex: 'patentName', key: 'patentName' }, { title: '专利编号', dataIndex: 'patentNumber', key: 'patentNumber' }, { title: '专利状态', dataIndex: 'patentState', key: 'patentName', render: text => { return getPatentState(text) }, }, { title: '专利类型', dataIndex: 'patentType', key: 'patentType', render: text => { return getPatentType(text) }, }, { title: '当前操作人', dataIndex: 'techPrincipal', key: 'techPrincipal' } ], copyrightColumns: [ { title: '软著名称', dataIndex: 'copyrightName', key: 'copyrightName' }, { title: '软著编号', dataIndex: 'copyrightNumber', key: 'copyrightNumber' }, { title: '软著状态', dataIndex: 'copyrightState', key: 'copyrightName', render: (text) => { return getCopyrightState(text) } }, { title: '加急天数', dataIndex: 'copyrightType', key: 'copyrightType', render: (text) => { switch (text) { case 0: return '不加急(45个工作日)'; case 3: return '3个工作日'; case 5: return '5个工作日'; case 10: return '6-10个工作日'; case 15: return '11-15个工作日'; case 20: return '16-20个工作日'; case 25: return '21-25个工作日'; case 30: return '26-30个工作日'; case 35: return '31-35个工作日'; } } }, { title: '当前操作人', dataIndex: 'techPrincipal', key: 'techPrincipal' } ], highTechColumns: [ { title: '申请年份', dataIndex: 'highTechYear', key: 'highTechYear' }, { title: '申请状态', dataIndex: 'highTechState', key: 'highTechName', render: (text) => { return gethighTechState(text) } }, { title: '证书编号', dataIndex: 'highTechType', key: 'highTechType', }, { title: '当前操作人', dataIndex: 'techPrincipal', key: 'techPrincipal' } ], techProjectColumns: [ { title: '项目名称', dataIndex: 'techProjectName', key: 'techProjectName' }, { title: '项目类型', dataIndex: 'techProjectCatagory', key: 'techProjectCatagory' }, { title: '项目状态', dataIndex: 'techProjectState', key: 'techProjectState', render: text => { return getTechnologyState(text) } }, { title: '技术领域', dataIndex: 'techProjectField', key: 'techProjectField' }, { title: '当前操作人', dataIndex: 'techPrincipal', key: 'techPrincipal' } ] }; }, componentWillMount() { this.loadData(); this.getContactsList(); }, getContactsList(uid) { $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/getContacts", data: { uid: uid || this.props.data.uid }, success: function (data) { if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); return; }; }; this.setState({ contactsList: data.data }); }.bind(this), }); }, loadData(id) { this.setState({ loading: true }); $.when($.ajax({ method: "get", dataType: "json", crossDomain: false, cache: false, url: globalConfig.context + "/api/admin/contract/logs", data: { id: id || this.props.data.id } }), $.ajax({ method: "get", dataType: "json", crossDomain: false, cache: false, url: globalConfig.context + "/api/admin/contract/detail", data: { id: id || this.props.data.id } })).done((data1, data2) => { 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 }); }); }; //获取详细数据 if (!data2[0].data) { if (data2[0].error && data2[0].error.length) { message.warning(data2[0].error[0].message); }; } else { let detailData = data2[0].data; this.setState({ data: detailData }); }; }).always(function () { this.setState({ loading: false }); }.bind(this)); }, loadColumnsData() { this.setState({ loading: true }); $.when($.ajax({ method: "get", dataType: "json", crossDomain: false, cache: false, url: globalConfig.context + "/api/admin/contract/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/contract/detail", data: { id: id || this.props.data.id } })).done(() => { }).always(function () { this.setState({ loading: false }); }.bind(this)); }, foundHighTech() { }, foundPatent() { }, foundCopyright() { }, foundTechProject() { }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { this.loadData(nextProps.data.id); this.getContactsList(nextProps.data.uid); }; }, 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.data || {}; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 18 }, }; const _me = this; return (
{getFieldDecorator('unitName')( {theData.unitName} )} {getFieldDecorator('orgCode')( {theData.orgCode} )} {getFieldDecorator('address')( {theData.address} )} {(() => { if (this.state.contactsList && theData.contacts) { debugger } })()}

状态流转记录:

{getFieldDecorator('status')( )} {getFieldDecorator('recordTime')( )} {getFieldDecorator('principal')( )} {getFieldDecorator('comment')( )}
{getFieldDecorator('cognizanceYear', { initialValue: theData.cognizanceYear })( {theData.cognizanceYear} 年 )} {theData.cognizanceStatus == 1 ? : }
{getFieldDecorator('patentNum', { initialValue: theData.patentNum })( {theData.patentNum} 条 )} {theData.patentStatus == 1 ? : }
{getFieldDecorator('copyrightNum', { initialValue: theData.copyrightNum })( {theData.copyrightNum} 条 )} {theData.copyrightStatus == 1 ? : }
{getFieldDecorator('techProjectNum', { initialValue: theData.techProjectNum })( {theData.techProjectNum} 条 )} {theData.techProjectStatus == 1 ? : }
); } })); const ContractDetail = 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 ContractDetail;