import React from "react"; import { Spin, message, Modal, Button, DatePicker, Input, Icon } from "antd"; import ajax from "jquery/src/ajax/xhr.js"; import $ from "jquery/src/ajax"; import './detail.less'; import moment from "moment"; import ReactToPrint from "react-to-print"; import { getPdf } from "../../../../utils/tools"; const { RangePicker } = DatePicker; const detail = React.createClass({ getInitialState() { return { loading: false, change: false, data: {}, num: 0, }; }, // 获取详情 getInfo() { this.setState({ loading: true, }) $.ajax({ method: 'get', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/admin/RD/details', data: { id: this.props.rowdata.id, }, success: function (data) { this.setState({ data: data.data, }) this.state.num == 0 && this.addBrowse() }.bind(this), }).always( function () { this.setState({ loading: false, }) }.bind(this) ) }, // 浏览+1 addBrowse() { let i = 20 this.timer = setInterval(() => { i--; if (i == 0) { clearInterval(this.timer); $.ajax({ method: 'post', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/admin/RD/addBrowse', data: { id: this.props.rowdata.id, }, success: function (data) { this.setState({ num: 1 }) }.bind(this), }).always( function () { }.bind(this) ) } }, 1000) }, // 下载+1 addDownload() { $.ajax({ method: 'post', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/admin/RD/addDownload', data: { id: this.props.rowdata.id, }, success: function (data) { this.state.data.downloadCount++ this.setState({ data: this.state.data }); // this.getInfo() }.bind(this), }).always( function () { }.bind(this) ) }, // PDF下载 pdfDownload() { message.loading("下载中..."); window.location.href = globalConfig.context + `/api/admin/RD/downloadDetailsPDF?id=${this.props.rowdata.id}`; // getPdf(this.state.data.rdName, "pdf") this.addDownload() }, // Word下载 wordDownload() { message.loading("下载中..."); window.location.href = globalConfig.context + `/api/admin/RD/downloadDetailsWord?id=${this.props.rowdata.id}`; this.addDownload() }, // 修改详情 update() { const { data } = this.state // if (!data.userName) { // message.warning("公司名称不能为空!"); // return // } // if (!data.consultantName) { // message.warning("项目负责人不能为空!"); // return // } // if (!data.technicalField) { // message.warning("技术领域不能为空!"); // return // } // if (!data.technologySource) { // message.warning("技术来源不能为空!"); // return // } // if (!data.totalAmount) { // message.warning("研发费用总预计不能为空!"); // return // } // if (!data.rdObjective) { // message.warning("研发目的/立项目的/实施方式不能为空!"); // return // } // if (!data.coreTechnology) { // message.warning("核心技术/创新点不能为空!"); // return // } // if (!data.achieveResults) { // message.warning("成果不能为空!"); // return // } this.setState({ loading: true, }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/RD/update", data: { id: data.id, ipNo: data.ipNo, rdNo: data.rdNo, rdStartStr: data.rdStartStr, rdEndStr: data.rdEndStr, userName: data.userName, consultantName: data.consultantName, technicalField: data.technicalField, technologySource: data.technologySource, totalAmount: data.totalAmount, rdObjective: data.rdObjective, coreTechnology: data.coreTechnology, achieveResults: data.achieveResults, }, }).done( function (data) { this.setState({ loading: false, }); if (!data.error.length) { this.getInfo(); message.success("保存成功!"); this.setState({ change: false }) } else { message.warning(data.error[0].message); } }.bind(this) ); }, componentWillMount() { this.getInfo(); }, componentWillUnmount() { clearInterval(this.timer) }, render() { const { data, change } = this.state return (
{/* ( )} content={() => this.refs.all} /> */}
已下载次数:{data.downloadCount}
{ this.refs.all = e; }} >

{data.rdName}

项目起止时间: { change ? { this.setState({ data: Object.assign(data, { rdStartStr: dataString[0], rdEndStr: dataString[1], }), }); }} /> : {!data.rdStartStr ? "" : (data.rdStartStr + "~" + data.rdEndStr)} }
公司名称: { change ? { data.userName = e.target.value this.setState({ data }); }} /> : {data.userName} }
项目负责人: { change ? { data.consultantName = e.target.value this.setState({ data }); }} /> : {data.consultantName} }
技术领域: { change ? { data.technicalField = e.target.value this.setState({ data }); }} /> : {data.technicalField} }
技术来源: { change ? { data.technologySource = e.target.value this.setState({ data }); }} /> : {data.technologySource} }
研发费用总预计: { change ? { data.totalAmount = e.target.value this.setState({ data }); }} /> : {data.totalAmount} }   {"万元"}
研发目的/立项目的/实施方式 { change ? { data.rdObjective = e.target.value this.setState({ data }); }} /> :

{data.rdObjective}

}
核心技术/创新点 { change ? { data.coreTechnology = e.target.value this.setState({ data }); }} /> :

{data.coreTechnology}

}
成果 { change ? { data.achieveResults = e.target.value this.setState({ data }); }} /> :

{data.achieveResults}

}
{ change ?
: }
); }, }); export default detail;