import React from 'react'; import $ from 'jquery/src/ajax'; import { Modal, message, Spin, Upload, Button, Form } from 'antd'; import { getprovince, splitUrl } from '@/tools.js'; import './business.less'; import 'react-quill/dist/quill.bubble.css'; const DemandDetail = 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/jtBusiness/project/detail', 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 categoryList = this.props.categoryList,name=''; categoryList.map(item=>{ if((item.children).length){ (item.children).map(atem=>{ if(atem.value==thisData.categoryId){ name=item.label+'/'+atem.label; return; } }) } }) let tagFirst =thisData.tags,tagTxt=[]; tagFirst.map(item=>{ tagTxt.push(item.name); }) //富文本处理 document.querySelector('.txt').innerHTML=''; let eleDiv = document.createElement('div'); eleDiv.innerHTML=thisData.introduce; document.querySelector('.txt').append(eleDiv); this.setState({ id: thisData.id, data: thisData, name:name, tags:tagTxt.join(' - '), createTime: thisData.createTime ? new Date(thisData.createTime).toLocaleString() : '', auditStatus: thisData.auditStatus, orgCodeUrl: thisData.minImgUrl ? splitUrl(thisData.minImgUrl, ',', globalConfig.avatarHost + '/upload') : [], companyLogoUrl: thisData.maxImgUrl ? splitUrl(thisData.maxImgUrl, ',', globalConfig.avatarHost + '/upload') : [] }); }.bind(this) }).always( function() { this.setState({ loading: false }); }.bind(this) ); }, cancelFun() { this.props.closeDesc(); }, //刷新发布 updateFun(inex) { this.setState({ loading: true }); $.ajax({ method: 'get', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/user/jtBusiness/project/refreshPublish', data: { id: this.state.id, auditStatus: this.state.auditStatus } }).done( function(data) { if (!data.error.length) { message.success('刷新成功!'); this.setState({ loading: false }); } else { message.warning(data.error[0].message); } this.props.handOk(); }.bind(this) ); }, //撤销发布 revokeFun() { this.setState({ loading: true }); $.ajax({ method: 'get', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/user/jtBusiness/project/offShelf', data: { id: this.state.id, auditStatus:this.state.auditStatus } }).done( function(data) { if (!data.error.length) { message.success('撤销成功!'); this.setState({ loading: false }); } else { message.warning(data.error[0].message); } this.props.handOk(); }.bind(this) ); }, 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.pictureUrl = []; } this.props.form.resetFields(); } }, render() { const theData = this.state.data || {}; const FormItem = Form.Item; return (
{ this.handleSubmit(e, 0); }} id="demand-form" >
{theData.name} {this.state.name}
{theData.province!='0'?getprovince(theData.province):'全国'} {/* {theData.isHot=='1' ? '是' :theData.isHot=='0'?'否':''} */} {this.state.createTime}
{theData.price?theData.price+' 万元':''} {theData.activityPrice?theData.activityPrice+' 万元':''} {theData.offset?theData.offset+' 万元':''} {theData.memberPrice?theData.memberPrice+' 万元':''} {theData.activityFlag=='1' ? '有效' :theData.activityFlag=='0'?'无效':''} {theData.keyword}
{this.state.tags}
{theData.summary}
{theData.advertisement}
{/*
{theData.value}
{theData.applyConditions}
*/}
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true }); }} /> { this.setState({ previewVisible: false }); }} > { this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true }); }} /> { this.setState({ previewVisible: false }); }} >
{this.props.data.auditStatus == '2' && ( )}
); } }) ); export default DemandDetail;