import React from 'react'; import $ from 'jquery/src/ajax'; import { Icon, Modal, message, Spin, Upload, Input, Button, Radio, Form, Checkbox, Cascader, Row, Col } from 'antd'; import { splitUrl} from '@/tools.js'; import {areaSelect } from '@/NewDicProvinceList'; import Editors from '@/richTextEditors'; const PicturesWall = React.createClass({ getInitialState() { return { previewVisible: false, previewImage: '', fileList: [], tags: [] }; }, handleCancel() { this.setState({ previewVisible: false }); }, handlePreview(file) { this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true }); }, handleChange(info) { let fileList = info.fileList; this.setState({ fileList }); this.props.fileList(fileList); }, componentWillReceiveProps(nextProps) { this.state.fileList = nextProps.pictureUrl; }, render() { const { previewVisible, previewImage, fileList } = this.state; const uploadButton = (
点击上传
); return (
{fileList.length >= 3 ? null : uploadButton} example
); } }); const NewDetailForm = Form.create()(React.createClass({ getInitialState() { return { visible: false, loading: false, auditStatus: 0, textFileList: [], videoFileList: [], pictureUrl: [], tags:[] }; }, loadData(id) { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/user/achievement/achievementDetail' , data: { id: id }, success: function (data) { let thisData = data.data; if (!thisData) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thisData = {}; }; this.setState({ id:thisData.id, data: thisData, publishPages:thisData.publishPages.length?thisData.publishPages:['app_achievement_list','web_achievement_list'], auditStatus:thisData.auditStatus, pictureUrl: thisData.technicalPictureUrl ? splitUrl(thisData.technicalPictureUrl, ',', globalConfig.avatarHost + '/upload') : [] }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getPictureUrl(e) { this.setState({ pictureUrl: e }); }, handleSubmit(e,index) { e.preventDefault(); console.log(this.state.edit) this.props.form.validateFields((err, values) => { //url转化 let thePictureUrl = []; if (this.state.pictureUrl.length) { let picArr = []; this.state.pictureUrl.map(function (item) { if ( item.response && item.response.data && item.response.data.length ){ picArr.push(item.response.data); } }); thePictureUrl = picArr.join(","); }; if (!err) { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", async:true, url: this.props.data.id ? globalConfig.context + '/api/user/achievement/update' : globalConfig.context + '/api/user/achievement/apply', data: { id: this.props.data.id, name: values.name, fieldA: values.industryCategory ? values.industryCategory[0] : undefined, fieldB: values.industryCategory ? values.industryCategory[1] : undefined, dataCategory: values.dataCategory, category: values.category, technicalPictureUrl: thePictureUrl, introduction:values.introduction, maturity:values.maturity, innovation:values.innovation, transferMode:values.transferMode, auditStatus:index, patentCase: values.patentCase, teamDes: values.teamDes, parameter: values.parameter, boutique: values.boutique, isHot:values.isHot, publishPages:values.publishPages, } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('操作成功!'); this.setState({ visible: false }); this.props.handOk(); } else { message.warning(data.error[0].message); } }.bind(this)); } }); }, submission(e,index){ this.handleSubmit(e,index); $.ajax({ method: "POST", dataType: "json", crossDomain: false, async:true, url: globalConfig.context + "/api/user/achievement/commit", data: { id: this.state.id, } }).done(function (data) { if (!data.error.length) { this.setState({ loading: false, }); } else { message.warning(data.error[0].message); }; }.bind(this)); }, cancelFun(){ this.props.closeDesc(); }, componentWillMount() { if (this.props.data.id) { this.loadData(this.props.data.id); } else { this.state.data = {}; this.state.tags = []; this.setState({ publishPages:['app_achievement_list','web_achievement_list'] }) }; }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { this.state.textFileList = []; this.state.videoFileList = []; if (nextProps.data.id) { this.loadData(nextProps.data.id); } else { this.state.data = {}; this.state.pictureUrl = []; this.state.theData={}; this.setState({ publishPages:['app_achievement_list','web_achievement_list'] }) }; this.props.form.resetFields(); }; }, render() { const theData = this.state.data || {}; const { getFieldDecorator,getFieldsValue } = this.props.form; const FormItem = Form.Item const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 12 }, }; this.state.edit ={}; return (
{this.handleSubmit(e,0)}} id="demand-form">
{getFieldDecorator('name', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.name })()}
{getFieldDecorator('hot', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.hot })( )} {getFieldDecorator('name', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.name })()} {getFieldDecorator('url', { initialValue: theData.url })()} {getFieldDecorator('ProvinceCity', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.ProvinceCity })( )}
{getFieldDecorator('introduction', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.introduction })()}
* 新闻正文}> { this.state.edit.content = value; }} visible={this.state.visible} />
{theData.auditInfo&&
{theData.auditInfo}
} {theData.createTime&&
{theData.createTime}
}
{getFieldDecorator('publishPages', { rules: [ { required: false } ], initialValue: this.state.publishPages })( 网站新闻首页 网站科技服务主页 app政策主页 APP科技服务首页 )}
{this.props.data&&!this.props.data.id&&}
) } })); export default NewDetailForm;