import React from 'react'; import $ from 'jquery/src/ajax'; import { Icon, Tabs, Table, Tooltip, Modal, Popover, message, Spin, Upload, Input, InputNumber, Select, DatePicker, Button, Radio, Form, Cascader, Tag, Checkbox, Row, Col } from 'antd'; import { getTechField } from '@/DicTechFieldList.js'; import {areaSelect } from '@/NewDicProvinceList'; import { IndustryObject, getIndustryCategory } from '@/DicIndustryList.js'; import { beforeUploadFile, splitUrl, companySearch, getDemandType, getAchievementCategory } from '@/tools.js'; const PicturesWall = React.createClass({ getInitialState() { return { previewVisible: false, previewImage: '', fileList: [] }; }, 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 >= 5 ? null : uploadButton} example
); } }); const DemandForm = Form.create()( React.createClass({ getInitialState() { return { visible: false, loading: false, auditStatus: 0, textFileList: [], videoFileList: [], pictureUrl: [], tags: [], ProvinceCity:[] }; }, loadData(id) { this.setState({ loading: true }); $.ajax({ method: 'get', dataType: 'json', crossDomain: false, url: globalConfig.context + (window.userData.type == '1' ? '/api/user/demand/orgDemandDetail' : '/api/user/demand/userDemandDetail'), 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({ data: thisData, tags: thisData.keyword ? thisData.keyword.split(',') : [], pictureUrl: thisData.pictureUrl ? splitUrl(thisData.pictureUrl, ',', globalConfig.avatarHost + '/upload') : [] }); }.bind(this) }).always( function() { this.setState({ loading: false }); }.bind(this) ); }, getTagsArr(e) { this.setState({ tags: e }); }, getPictureUrl(e) { this.setState({ pictureUrl: e }); }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { //keyword长度判断 if (this.state.tags.length < 3) { message.warning('关键词数量不能小于3个!'); return; } //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', crossDomain: false, url: this.props.data.id ? globalConfig.context + '/api/user/demand/update' : globalConfig.context + '/api/user/demand/apply', data: { id: this.props.data.id, dataCategory: Number(window.userData.type), serialNumber: this.props.data.serialNumber, name: values.name, keyword: this.state.tags ? this.state.tags.join(',') : [], keywords: this.state.tags, infoSources: 1, industryCategoryA: values.industryCategory ? values.industryCategory[0] : undefined, industryCategoryB: values.industryCategory ? values.industryCategory[1] : undefined, demandType: values.demandType, problemDes: values.problemDes, technicalRequirements: values.technicalRequirements, pictureUrl: thePictureUrl, textFileUrl: this.state.textFileUrl, videoUrl: values.videoUrl, fixedBudget: values.fixedBudget, fixedCycle: values.fixedCycle, peopleNumber: values.peopleNumber, fixedScheme: values.fixedScheme, costEscrow: values.costEscrow, budgetCost: values.budgetCost, employerId: values.employerId || this.state.data.employerId, releaseStatus: values.releaseStatus, principalId: values.principalId, validityPeriodFormattedDate: values.validityPeriod ? values.validityPeriod.format('YYYY-MM-DD') : undefined, // contacts: values.contacts, status: this.state.status, auditStatus: this.state.auditStatus } }).done( function(data) { this.state.auditStatus = 0; this.setState({ loading: false }); if (!data.error.length) { message.success('保存成功!'); this.setState({ visible: false }); this.props.handleOk(); } else { message.warning(data.error[0].message); } }.bind(this) ); } }); }, componentWillMount() { if (this.props.data.id) { this.loadData(this.props.data.id); } else { this.state.data = {}; } }, componentWillReceiveProps(nextProps) { this.state.textFileList = []; this.state.videoFileList = []; if (nextProps.data.id) { this.loadData(nextProps.data.id); } else { this.state.data = {}; this.state.pictureUrl = []; } this.props.form.resetFields(); }, render() { const theData = this.state.data || {}; const { getFieldDecorator, getFieldsError, getFieldError, isFieldTouched } = this.props.form; const FormItem = Form.Item; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 12 } }; return (
{getFieldDecorator('problemDes', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.problemDes })()} {getFieldDecorator('name', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.name })()}
{getFieldDecorator('industryCategory', { rules: [ { type: 'array', required: true, message: '此项为必填项!' } ], initialValue: [ theData.industryCategoryA, theData.industryCategoryB ] })()}
{this.state.demandType=='0'&& {getFieldDecorator('name', { rules: [ { required: false } ], initialValue: theData.namea })()} } {this.state.demandType=='1'&&
{getFieldDecorator('name', { rules: [ { required: false } ], initialValue: theData.namea })()} {getFieldDecorator('namea', { rules: [ { required: false } ], initialValue: theData.namea })( )}
}

您还可以说明

{this.setState({urgent:e.target.value})}}> 加急需求 非加急需求 {this.state.urgent&& {getFieldDecorator('validitytime', { initialValue: theData.validitytime ? moment(theData.validitytime) : null })()} }
{this.setState({offer:e.target.value})}}> {this.state.offer>=1&& {getFieldDecorator('budgetCost', { initialValue: theData.budgetCost })()} 万元 }
{this.setState({hotDemand:e.target.value})}}> {this.setState({solve:e.target.value})}}>
{ this.setState({ ProvinceCity: e }); }} />
{getFieldDecorator('releaseState', { rules: [ { required: false } ], initialValue: theData.releaseState })( )} {getFieldDecorator('releaseTime', { initialValue: theData.releaseTime ? moment(theData.releaseTime) : null })()}
{getFieldDecorator('releasePosition', { rules: [ { required: false } ], initialValue: theData.releasePosition })( 网站首页 网站需求主页 网站需求搜索页 APP首页 APP需求首页 APP需求搜索页 )}
{this.props.data&&this.props.data.id&&}
); } }) ); export default DemandForm;