import React from 'react'; import { Icon, Tabs, Table, Tooltip, Modal, message, Spin, Upload, Input, InputNumber, Select, DatePicker, Button, Radio, Form, Cascader, Tag } from 'antd'; import moment from 'moment'; import './techAchievement.less'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; import { IndustryObject, getIndustryCategory } from '../../DicIndustryList.js'; import { beforeUploadFile, splitUrl, getAchievementCategory, getDemandType } from '../../tools.js'; import ImgList from "../../common/imgList"; const KeyWordTagGroup = React.createClass({ getInitialState() { return { tags: [], inputVisible: false, inputValue: '' }; }, handleClose(removedTag) { const tags = this.state.tags.filter(tag => tag !== removedTag); this.props.tagsArr(tags); this.setState({ tags }); }, showInput() { this.setState({ inputVisible: true }, () => this.input.focus()); }, handleInputChange(e) { this.setState({ inputValue: e.target.value }); }, handleInputConfirm() { const state = this.state; const inputValue = state.inputValue; let tags = state.tags; if (inputValue && tags.indexOf(inputValue) === -1 && inputValue.replace(/(^\s*)|(\s*$)/g, "").length != 0) { tags = [...tags, inputValue.replace(/(^\s*)|(\s*$)/g, "")]; } this.props.tagsArr(tags); this.setState({ tags, inputVisible: false, inputValue: '', }); }, componentWillMount() { this.state.tags = this.props.keyWordArr; }, componentWillReceiveProps(nextProps) { if (this.props.keyWordArr != nextProps.keyWordArr) { this.state.tags = nextProps.keyWordArr; }; }, render() { const { tags, inputVisible, inputValue } = this.state; return (
{tags.map((tag, index) => { const isLongTag = tag.length > 10; const tagElem = ( this.handleClose(tag)}> {isLongTag ? `${tag.slice(0, 10)}...` : tag} ); return isLongTag ? {tagElem} : tagElem; })} {inputVisible && ( this.input = input} type="text" style={{ width: 78 }} value={inputValue} onChange={this.handleInputChange} onBlur={this.handleInputConfirm} onPressEnter={this.handleInputConfirm} /> )} {!inputVisible && }
); } }); 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 (
{ this.handleChange(infor) }} fileList={fileList} />
); } }); const AchievementDetailShow = Form.create()(React.createClass({ getInitialState() { return { visible: false, loading: false, textFileList: [], techPlanFileList: [], businessPlanFileList: [], maturityPictureUrl: [], technicalPictureUrl: [], tags: [] }; }, loadData(id) { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + (window.userData.type == "1" ? "/api/user/achievement/orgDetail" : "/api/user/achievement/userDetail"), 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(",") : [], technicalPictureUrl: thisData.technicalPictureUrl ? splitUrl(thisData.technicalPictureUrl, ',', globalConfig.avatarHost + '/upload') : [], maturityPictureUrl: thisData.maturityPictureUrl ? splitUrl(thisData.maturityPictureUrl, ',', globalConfig.avatarHost + '/upload') : [] }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, offShelf() { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/achievement/offShelf", data: { "id": this.props.data.id } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('撤销成功!'); this.setState({ visible: false, releaseSubmitVisible: 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) { if (!this.props.visible && nextProps.visible) { this.state.textFileList = []; this.state.techPlanFileList = []; this.state.businessPlanFileList = []; if (nextProps.data.id) { this.loadData(nextProps.data.id); } else { this.state.data = {}; this.state.tags = []; this.state.maturityPictureUrl = []; this.state.technicalPictureUrl = []; }; this.props.form.resetFields(); }; }, render() { const theData = this.state.data || {}; const { getFieldDecorator } = this.props.form; const FormItem = Form.Item const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 14 }, }; return (
{theData.serialNumber} {theData.name} {userData.type ? {this.props.contactsObj[theData.contacts]} :
} {(() => { switch (theData.dataCategory) { case "0": return 成果; case "1": return 技术; case "2": return 项目; } })()} {getAchievementCategory(theData.category)}
{(() => { switch (theData.releaseStatus) { case "0": return 未发布; case "1": return
已发布 { this.setState({ releaseSubmitVisible: false }) }} > 确认要撤销发布吗?
; } })()}
{theData.releaseDateFormattedDate} {(() => { switch (theData.auditStatus) { case "0": return 未提交审核(草稿); case "1": return 提交审核; case "2": return 审核中; case "3": return 审核通过; case "4": return 审核未通过; } })()}
{this.state.tags.map((tag) => { return {tag} ; })} {theData.summary} {theData.introduction}
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }} > { this.setState({ previewVisible: false }) }}>
{getIndustryCategory(theData.fieldA, theData.fieldB)}
{(() => { switch (theData.maturity) { case "0": return 正在研发; case "1": return 已有样品; case "2": return 通过小试; case "3": return 通过中试; case "4": return 可以量产; } })()} {(() => { switch (theData.innovation) { case "0": return 行业先进; case "1": return 行业领先; case "2": return 国内先进; case "3": return 国内领先; case "4": return 国际先进; case "5": return 国际领先; } })()}
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }} >

{theData.maturityTextFileUrl ? { window.open(globalConfig.context + '/api/user/achievement/download?id=' + this.props.data.id + '&sign=achievement_maturity_text_file') }}>{theData.maturityTextFileDownloadFileName} : 未上传!}

{theData.maturityVideoUrl}
{theData.iOwnerName || theData.ownerName} {theData.iOwnerIdNumber || theData.ownerIdNumber} {theData.iOwnerMobile || theData.ownerMobile} {theData.iOwnerEmail || theData.ownerEmail} {theData.iOwnerPostalAddress || theData.ownerPostalAddress}
{(() => { switch (theData.ownerType) { case "0": return 个人; case "1": return 组织; } })()}
{theData.ownerType == "9" ?
{theData.orgName} {theData.orgAddress} {theData.orgEmail} {theData.orgContacts} {theData.orgContactsMobile}
:
}
{(() => { switch (theData.cooperationMode) { case "0": return 技术转让; case "1": return 授权生产; } })()} {(() => { switch (theData.transferMode) { case "0": return 完全转让; case "1": return 许可转让; case "2": return 技术入股; } })()}
{theData.bargainingMode == 1 ? {theData.transferPrice} 万元 : 面议 }
{theData.technicalScene} {theData.breakthrough} {theData.patentCase} {theData.awards} {theData.teamDes} {theData.parameter}

{theData.techPlanUrl ? { window.open(globalConfig.context + '/api/user/achievement/download?id=' + this.props.data.id + '&sign=achievement_tech_plan') }}>{theData.techPlanDownloadFileName} : 未上传!}

{theData.businessPlanUrl ? { window.open(globalConfig.context + '/api/user/achievement/download?id=' + this.props.data.id + '&sign=achievement_business_plan') }}>{theData.businessPlanDownloadFileName} : 未上传!}

) } })); const AchievementDetailForm = Form.create()(React.createClass({ getInitialState() { return { visible: false, loading: false, auditStatus: 0, textFileList: [], techPlanFileList: [], businessPlanFileList: [], maturityPictureUrl: [], technicalPictureUrl: [], tags: [] }; }, loadData(id) { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + (window.userData.type == "1" ? "/api/user/achievement/orgDetail" : "/api/user/achievement/userDetail"), 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, orgDisplay: thisData.ownerType, transferPriceDis: thisData.bargainingMode == 1 ? true : false, tags: thisData.keyword ? thisData.keyword.split(",") : [], technicalPictureUrl: thisData.technicalPictureUrl ? splitUrl(thisData.technicalPictureUrl, ',', globalConfig.avatarHost + '/upload') : [], maturityPictureUrl: thisData.maturityPictureUrl ? splitUrl(thisData.maturityPictureUrl, ',', globalConfig.avatarHost + '/upload') : [] }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getTagsArr(e) { this.setState({ tags: e }); }, getMaturityPictureUrl(e) { this.setState({ maturityPictureUrl: e }); }, getTechnicalPictureUrl(e) { this.setState({ technicalPictureUrl: e }); }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { //keyword长度判断 if (this.state.tags.length < 3) { message.warning('关键词数量不能小于3个!'); return; }; //url转化 let theTechnicalPictureUrl = []; if (this.state.technicalPictureUrl.length) { let picArr = []; this.state.technicalPictureUrl.map(function (item) { if ( item.response && item.response.data && item.response.data.length ){ picArr.push(item.response.data); } }); theTechnicalPictureUrl = picArr.join(","); }; let theMaturityPictureUrl = []; if (this.state.maturityPictureUrl.length) { let picArr = []; this.state.maturityPictureUrl.map(function (item) { if ( item.response && item.response.data && item.response.data.length ){ picArr.push(item.response.data); } }); theMaturityPictureUrl = picArr.join(","); }; if (!err) { this.setState({ loading: true }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: this.props.data.id ? globalConfig.context + '/api/user/achievement/update' : globalConfig.context + '/api/user/achievement/apply', data: { id: this.props.data.id, dataCategory: values.dataCategory, serialNumber: this.props.data.serialNumber, name: values.name, contacts: values.contacts, keyword: this.state.tags ? this.state.tags.join(",") : [], keywords: this.state.tags, category: values.category, summary: values.summary, introduction: values.introduction, technicalPictureUrl: theTechnicalPictureUrl, fieldA: values.field ? values.field[0] : undefined, fieldB: values.field ? values.field[1] : undefined, maturity: values.maturity, maturityPictureUrl: theMaturityPictureUrl, maturityTextFileUrl: this.state.maturityTextFileUrl, maturityVideoUrl: values.maturityVideoUrl, innovation: values.innovation, cooperationMode: values.cooperationMode, transferMode: values.transferMode, bargainingMode: values.bargainingMode, transferPrice: values.transferPrice, technicalScene: values.technicalScene, breakthrough: values.breakthrough, patentCase: values.patentCase, awards: values.awards, teamDes: values.teamDes, parameter: values.parameter, releaseStatus: values.releaseStatus, techPlanUrl: this.state.techPlanUrl, businessPlanUrl: this.state.businessPlanUrl, auditStatus: this.state.auditStatus, ownerType: window.userData.type // 所有人类型 } }).done(function (data) { this.state.auditStatus = 0; this.setState({ loading: false }); if (!data.error.length) { message.success('保存成功!'); 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) { if (!this.props.visible && nextProps.visible) { this.state.textFileList = []; this.state.techPlanFileList = []; this.state.businessPlanFileList = []; if (nextProps.data.id) { this.loadData(nextProps.data.id); } else { this.state.data = {}; this.state.tags = []; this.state.maturityPictureUrl = []; this.state.technicalPictureUrl = []; }; this.props.form.resetFields(); }; }, render() { const theData = this.state.data || {}; const { getFieldDecorator } = this.props.form; const FormItem = Form.Item const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 14 }, }; return (
{theData.serialNumber} {getFieldDecorator('name', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: theData.name })( )} {userData.type ? {getFieldDecorator('contacts', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: theData.contacts })( )} :
} {getFieldDecorator('dataCategory', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: theData.dataCategory })( )} {getFieldDecorator('category', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: theData.category })( )}
{(() => { switch (theData.releaseStatus) { case "0": return 未发布; case "1": return 已发布; } })()} {theData.releaseDateFormattedDate} {(() => { switch (theData.auditStatus) { case "0": return 未提交审核(草稿); case "1": return 提交审核; case "2": return 审核中; case "3": return 审核通过; case "4": return 审核未通过; } })()}
{getFieldDecorator('summary', { initialValue: theData.summary })( )} {getFieldDecorator('introduction', { initialValue: theData.introduction })( )}

图片建议:专利证书或专利申请书图片、技术图纸、样品图片、技术相关网络图片;成熟度处于非研发阶段的项目,必须上传样品图片,如未上传,成熟度将视为处在研发阶段。

{getFieldDecorator('field', { rules: [{ type: 'array', required: true, message: '此项为必填项!' }], initialValue: [theData.fieldA, theData.fieldB] })( )}
{getFieldDecorator('maturity', { rules: [{ type: 'string', required: true, message: '此项为必填项!' }], initialValue: theData.maturity })( )} {getFieldDecorator('innovation', { initialValue: theData.innovation })( )}
{ if (info.file.status !== 'uploading') { // console.log(info.file, info.fileList); } if (info.file.status === 'done') { if (!info.file.response.error.length) { message.success(`${info.file.name} 文件上传成功!`); } else { message.warning(info.file.response.error[0].message); return; }; this.state.maturityTextFileUrl = info.file.response.data; } else if (info.file.status === 'error') { message.error(`${info.file.name} 文件上传失败。`); }; this.setState({ textFileList: info.fileList.slice(-1) }); }} >

{theData.maturityTextFileUrl ? { window.open(globalConfig.context + '/api/user/achievement/download?id=' + this.props.data.id + '&sign=achievement_maturity_text_file') }}>{theData.maturityTextFileDownloadFileName} : 未上传!}

{getFieldDecorator('maturityVideoUrl', { initialValue: theData.maturityVideoUrl })( )}
{getFieldDecorator('cooperationMode', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: theData.cooperationMode })( 技术转让 授权生产 )} {getFieldDecorator('transferMode', { initialValue: theData.transferMode })( )}
{getFieldDecorator('bargainingMode', { initialValue: theData.bargainingMode })( { this.setState({ transferPriceDis: (e.target.value == 1 ? true : false) }) })}> 面议 定价 )} {this.state.transferPriceDis ? {getFieldDecorator('transferPrice', { initialValue: theData.transferPrice })( )} 万元 :
}
{getFieldDecorator('technicalScene', { initialValue: theData.technicalScene })( )} {getFieldDecorator('breakthrough', { initialValue: theData.breakthrough })( )} {getFieldDecorator('patentCase', { initialValue: theData.patentCase })( )} {getFieldDecorator('awards', { initialValue: theData.awards })( )} {getFieldDecorator('teamDes', { initialValue: theData.teamDes })( )} {getFieldDecorator('parameter', { initialValue: theData.parameter })( )} { if (info.file.status !== 'uploading') { // console.log(info.file, info.fileList); } if (info.file.status === 'done') { if (!info.file.response.error.length) { message.success(`${info.file.name} 文件上传成功!`); } else { message.warning(info.file.response.error[0].message); return; }; this.state.techPlanUrl = info.file.response.data; } else if (info.file.status === 'error') { message.error(`${info.file.name} 文件上传失败。`); }; this.setState({ techPlanFileList: info.fileList.slice(-1) }); }} >

{theData.techPlanUrl ? { window.open(globalConfig.context + '/api/user/achievement/download?id=' + this.props.data.id + '&sign=achievement_tech_plan') }}>{theData.techPlanDownloadFileName} : 未上传!}

{ if (info.file.status !== 'uploading') { // console.log(info.file, info.fileList); } if (info.file.status === 'done') { if (!info.file.response.error.length) { message.success(`${info.file.name} 文件上传成功!`); } else { message.warning(info.file.response.error[0].message); return; }; this.state.businessPlanUrl = info.file.response.data; } else if (info.file.status === 'error') { message.error(`${info.file.name} 文件上传失败。`); }; this.setState({ businessPlanFileList: info.fileList.slice(-1) }); }} >

{theData.businessPlanUrl ? { window.open(globalConfig.context + '/api/user/achievement/download?id=' + this.props.data.id + '&sign=achievement_business_plan') }}>{theData.businessPlanDownloadFileName} : 未上传!}

) } })); const AchievementDetail = React.createClass({ getInitialState() { return { visible: false, tabsKey: 1, contactsObj: {}, columns: [ { title: '编号', dataIndex: 'serialNumber', key: 'serialNumber', }, { title: '名称', dataIndex: 'name', key: 'name', }, { title: '关键字', dataIndex: 'keyword', key: 'keyword', }, { title: '类型', dataIndex: 'demandType', key: 'demandType', render: text => { return getDemandType(text); } }, { title: '所有人名称', dataIndex: 'theName', key: 'theName', }, { title: '发布时间', dataIndex: 'releaseDateFormattedDate', key: 'releaseDateFormattedDate', }, { title: '有效期限', dataIndex: 'validityPeriodFormattedDate', key: 'validityPeriodFormattedDate', }, ], dataSource: [], }; }, getTableList() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/achievement/achievementDemand", data: { id: this.props.data.id }, success: function (data) { let theArr = []; if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else if (data.data.length) { for (let i = 0; i < data.data.length; i++) { let thisdata = data.data[i]; theArr.push({ key: i, id: thisdata.id, serialNumber: thisdata.serialNumber, dataCategory: thisdata.dataCategory, name: thisdata.name, keyword: thisdata.keyword, demandType: thisdata.demandType, theName: thisdata.username || thisdata.unitName, releaseDateFormattedDate: thisdata.releaseDateFormattedDate, validityPeriodFormattedDate: thisdata.validityPeriodFormattedDate }); }; }; this.setState({ dataSource: theArr, }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, tableRowClick(record, index) { window.open(globalConfig.context + '/portal/detail/demandDetail.html?id=' + record.id + '&type=' + record.dataCategory); }, showModal() { this.setState({ visible: true, }); }, handleCancel(e) { this.setState({ visible: false, }); this.props.closeDesc(false); }, handleOk(e) { this.setState({ visible: false, }); this.props.closeDesc(false, true); }, componentWillMount() { this.getContactsOption(); }, getContactsOption() { let theOption = [], theObj = {}; $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/user/getContacts', success: function (data) { if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { for (let item in data.data) { let theData = data.data[item]; theOption.push( {theData} ); }; theObj = data.data; }; this.setState({ contactsOption: theOption, contactsObj: theObj }); }.bind(this) }); }, componentWillReceiveProps(nextProps) { if (nextProps.showDesc) { this.state.tabsKey = "1"; this.state.tabBool = true; }; this.state.visible = nextProps.showDesc; }, render() { if (this.props.data) { return (
{ this.setState({ tabsKey: e }); if (e == "2" && this.state.tabBool) { this.getTableList(); this.state.tabBool = false; }; }} > {(() => { if (this.props.data.id && this.props.data.auditStatus != "0" && this.props.data.auditStatus != "4") { return } else { return } })()} ); } else { return
} }, }); export default AchievementDetail;