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 { splitUrl, companySearch, getDemandType, getAchievementCategory } from '@/tools.js'; const FormItem =Form.Item 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 DemandDetailForm = Form.create()(React.createClass({ getInitialState() { return { visible: false, loading: false, auditStatus: 0, textFileList: [], videoFileList: [], pictureUrl: [], }; }, loadData(id) { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/user/demand/orgDemandDetail' , 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 = {}; }; let ProvinceCityArr = []; let ProvinceS = thisData.locationProvince; //getprovince let citys = thisData.locationCity; let Areas = thisData.locationArea; ProvinceCityArr.push(ProvinceS, citys, Areas); this.setState({ ProvinceCity:ProvinceCityArr, data: thisData, 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) => { console.log(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", 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, 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, 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)); } }); }, cancelFun(){ this.props.closeDesc(); }, componentWillMount() { if (this.props.data.id) { this.loadData(this.props.data.id); } else { this.state.data = {}; }; }, 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.demandType=undefined; //需求类型 this.state.urgent=undefined;//加急需求 this.state.offer=undefined;//是否悬赏 this.state.hotDemand=undefined; this.state.solve=undefined; this.state.pictureUrl = []; }; 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 }, }; let demandType =(getFieldsValue(['demandType']).demandType); 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 ] })()}
{getFieldDecorator('demandType', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue:theData.demandType })( )} {demandType=='5'||theData.demandType=='5'? {getFieldDecorator('name', { rules: [ { required: false } ], initialValue: theData.namea })()} 元/月 :''} {demandType=='3'||theData.demandType=='3'?
{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 DemandDetailForm;