import React from 'react'; import $ from 'jquery/src/ajax'; import { Modal, message, Spin, Upload, Button, Form, } from 'antd'; import {getProvince} from '@/NewDicProvinceList'; import 'react-quill/dist/quill.bubble.css'; import './policy.less' import {getReleaseStateList,getPolicyPosition,splitUrl} from '@/tools'; const NewDetail = 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/admin/policy/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 = {}; }; document.querySelector('.txt').innerHTML=''; let ProvinceS = thisData.province, ProvinceCity = getProvince(ProvinceS); let eleDiv = document.createElement('div'); eleDiv.innerHTML=thisData.content; document.querySelector('.txt').append(eleDiv); this.setState({ id:thisData.id, page:thisData.publishPages, data: thisData, eleDiv:eleDiv, ProvinceCity:ProvinceCity, edit:{content:thisData.content}, auditStatus:thisData.auditStatus, pictureUrl: thisData.titleImg ? splitUrl(thisData.titleImg, ',', 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: "POST", dataType: "json", crossDomain: false, url: globalConfig.context +'/api/admin/policy/updateStatus', data: { id: this.state.id, auditStatus:this.state.auditStatus, refresh:1 } }).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: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/policy/updateStatus', data: { id: this.state.id, auditStatus:4, } }).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 const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 12 }, }; return (