import React from 'react'; import { Icon, Modal, Button, Form, message, Input, Spin, Select, DatePicker, Upload } from 'antd'; import './patent.less'; import { intellectualGetList, catagoryList } from '../../dataDic.js'; import { beforeUploadFile, newDownloadFile } from '../../tools.js'; import ajax from 'jquery/src/ajax/xhr.js' import $ from 'jquery/src/ajax'; import moment from 'moment'; const IntellectualDescFrom = Form.create()(React.createClass({ getInitialState() { return { loading: false, intellectualGetOption: [], catagoryOption: [] }; }, componentWillMount() { let _me = this; intellectualGetList.map(function (item) { _me.state.intellectualGetOption.push( {item.key} ) }); catagoryList.map(function (item) { _me.state.catagoryOption.push( {item.key} ) }); }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { this.props.spinState(true); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/cognizance/intellectual", data: { id: this.props.data.id, intellectualPropertyNumber: values.intellectualPropertyNumber, intellectualPropertyName: values.intellectualPropertyName, catagory: values.catagory, obtainWay: values.obtainWay, sortNumber: values.sortNumber, authorizationNumber: values.authorizationNumber, authorizationDateFormattedDate: values.authorizationDate._i || this.state.authorizationDateFormattedDate, propertyRightUrl: this.state.propertyRightUrl } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); } else { message.warning(data.error[0].message); } }.bind(this)).always(function () { this.props.spinState(false); this.props.clickOk(); this.props.form.resetFields(); }.bind(this)); } }); }, checkIdcardnum(rule, value, callback) { if (!/(^\d{15}$)|(^\d{17}(\d|X)$)/.test(value)) { callback('请输入正确的身份证号!'); } else { callback(); } }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { this.props.form.resetFields(); }; }, render() { const FormItem = Form.Item; const { getFieldDecorator } = this.props.form; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 12 }, }; const _me = this; const theData = this.props.data; return (
{getFieldDecorator('intellectualPropertyNumber', { rules: [{ required: true, message: '请输入,知识产权编号不能为空!' }], initialValue: this.props.data.intellectualPropertyNumber })( )} {getFieldDecorator('intellectualPropertyName', { rules: [{ required: true, message: '请输入,知识产权名称不能为空!' }], initialValue: this.props.data.intellectualPropertyName })( )} {getFieldDecorator('sortNumber', { rules: [{ required: true, message: '请输入,排序号不能为空!' }], initialValue: this.props.data.sortNumber })( )} {getFieldDecorator('catagory', { rules: [{ required: true, message: '请选择,知识产权类型不能为空!' }], initialValue: this.props.data.catagory })( )} {getFieldDecorator('obtainWay', { rules: [{ required: true, message: '请选择,获得方式不能为空!' }], initialValue: this.props.data.obtainWay })( )} {getFieldDecorator('authorizationNumber', { rules: [{ required: true, message: '请输入,授权号不能为空!' }], initialValue: this.props.data.authorizationNumber })( )} {getFieldDecorator('authorizationDate', { rules: [{ type: 'object', required: true, message: '请选择,授权日期不能为空!' }], initialValue: !this.props.data.authorizationDateFormattedDate ? null : moment(this.props.data.authorizationDateFormattedDate, 'YYYY/MM/DD') })( { this.state.authorizationDateFormattedDate = dataString }} /> )}
{ 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.propertyRightUrl = info.file.response.data; } else if (info.file.status === 'error') { message.error(`${info.file.name} 文件上传失败。`); } }} >

{theData.propertyRightUrl ? {theData.propertyRightDownloadFileName} : 未上传!}

); }, })); const intellectualDesc = 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 intellectualDesc;