achievementDetails.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. import React from 'react';
  2. import $ from 'jquery/src/ajax';
  3. import {
  4. Modal,
  5. message,
  6. Spin,
  7. Upload,
  8. Button,
  9. Form,
  10. } from 'antd';
  11. import { getIndustryCategory } from '@/industryList.js';
  12. import { splitUrl ,getMaturity,getAchievementType,getTransaction,getAchievementPosition,getAchievementCategory,getReleaseStateList,getInnovation} from '@/tools.js';
  13. import SpinContainer from "../../SpinContainer";
  14. const DemandDetail = Form.create()(React.createClass({
  15. getInitialState() {
  16. return {
  17. visible: false,
  18. loading: false,
  19. auditStatus: 0,
  20. textFileList: [],
  21. pictureUrlMin:[],
  22. videoFileList: [],
  23. pictureUrl: [],
  24. };
  25. },
  26. loadData(id) {
  27. this.setState({
  28. loading: true
  29. });
  30. $.ajax({
  31. method: "get",
  32. dataType: "json",
  33. crossDomain: false,
  34. url: globalConfig.context + '/api/user/achievement/achievementDetail' ,
  35. data: {
  36. id: id
  37. },
  38. success: function (data) {
  39. let thisData = data.data;
  40. if (!thisData) {
  41. if (data.error && data.error.length) {
  42. message.warning(data.error[0].message);
  43. };
  44. thisData = {};
  45. };
  46. let publishPagesArr = [];
  47. thisData.publishPages.map(item=>{
  48. publishPagesArr.push(item.publishPage)
  49. })
  50. this.setState({
  51. id:thisData.id,
  52. publishPagesArr:publishPagesArr,
  53. data: thisData,
  54. auditStatus:thisData.auditStatus,
  55. pictureUrl: thisData.technicalPictureUrl ? splitUrl(thisData.technicalPictureUrl, ',', globalConfig.avatarHost + '/upload') : [],
  56. pictureUrlMin: thisData.pictureUrlMin ? splitUrl(thisData.pictureUrlMin, ',', globalConfig.avatarHost + '/upload') : []
  57. });
  58. }.bind(this),
  59. }).always(function () {
  60. this.setState({
  61. loading: false
  62. });
  63. }.bind(this));
  64. },
  65. getTagsArr(e) {
  66. this.setState({ tags: e });
  67. },
  68. getPictureUrl(e) {
  69. this.setState({ pictureUrl: e });
  70. },
  71. cancelFun(){
  72. this.props.closeDesc();
  73. },
  74. //刷新发布
  75. updateFun(inex){
  76. this.setState({
  77. loading:true
  78. })
  79. $.ajax({
  80. method: "POST",
  81. dataType: "json",
  82. crossDomain: false,
  83. url: globalConfig.context +'/api/user/achievement/refreshPublish',
  84. data: {
  85. id: this.state.id,
  86. auditStatus:this.state.auditStatus
  87. }
  88. }).done(function (data) {
  89. if (!data.error.length) {
  90. message.success('刷新成功!');
  91. this.setState({
  92. loading: false,
  93. });
  94. } else {
  95. message.warning(data.error[0].message);
  96. };
  97. this.props.handOk();
  98. }.bind(this));
  99. },
  100. //撤销发布
  101. revokeFun(){
  102. this.setState({
  103. loading:true
  104. })
  105. $.ajax({
  106. method: "POST",
  107. dataType: "json",
  108. crossDomain: false,
  109. url: globalConfig.context + '/api/user/achievement/offShelf',
  110. data: {
  111. id: this.state.id,
  112. }
  113. }).done(function (data) {
  114. if (!data.error.length) {
  115. message.success('撤销成功!');
  116. this.setState({
  117. loading: false,
  118. });
  119. } else {
  120. message.warning(data.error[0].message);
  121. };
  122. this.props.handOk();
  123. }.bind(this));
  124. },
  125. componentWillMount() {
  126. if (this.props.data.id) {
  127. this.loadData(this.props.data.id);
  128. } else {
  129. this.state.data = {};
  130. };
  131. },
  132. componentWillReceiveProps(nextProps) {
  133. if (!this.props.visible && nextProps.visible) {
  134. this.state.textFileList = [];
  135. this.state.videoFileList = [];
  136. if (nextProps.data.id) {
  137. this.loadData(nextProps.data.id);
  138. } else {
  139. this.state.data = {};
  140. this.state.pictureUrl = [];
  141. this.state.pictureUrlMin = [];
  142. };
  143. this.props.form.resetFields();
  144. };
  145. },
  146. render() {
  147. const theData = this.state.data || {};
  148. const { getFieldDecorator } = this.props.form;
  149. const FormItem = Form.Item
  150. const formItemLayout = {
  151. labelCol: { span: 6 },
  152. wrapperCol: { span: 12 },
  153. };
  154. return (
  155. <div className='login'>
  156. <Form layout="horizontal" id="demand-form">
  157. <SpinContainer spinning={this.state.loading}>
  158. <div className="clearfix">
  159. <FormItem className="half-item" {...formItemLayout} label="标题">
  160. <span>{theData.name}</span>
  161. </FormItem>
  162. </div>
  163. <div className="clearfix">
  164. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="发个成果吧">
  165. <span>{theData.introduction}</span>
  166. </FormItem>
  167. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="知识产权情况">
  168. <span>{theData.patentCase}</span>
  169. </FormItem>
  170. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="技术参数">
  171. <span>{theData.parameter}</span>
  172. </FormItem>
  173. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="团队情况">
  174. <span>{theData.teamDes}</span>
  175. </FormItem>
  176. </div>
  177. <div className="clearfix">
  178. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="关键字">
  179. <span>{theData.keywords&&theData.keywords.length?(theData.keywords).join(','):''}</span>
  180. </FormItem>
  181. </div>
  182. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="行业领域">
  183. <span>{getIndustryCategory(theData.fieldA,theData.fieldB)}</span>
  184. </FormItem>
  185. <div className="clearfix">
  186. <FormItem className="half-item" {...formItemLayout} label="成果类型">
  187. <span>{getAchievementType(theData.dataCategory)}</span>
  188. </FormItem>
  189. <FormItem className="half-item" {...formItemLayout} label="知识产权类型">
  190. <span>{getAchievementCategory(theData.category)}</span>
  191. </FormItem>
  192. <FormItem className="half-item" {...formItemLayout} label="创新度">
  193. <span>{getInnovation(theData.innovation)}</span>
  194. </FormItem>
  195. <FormItem className="half-item" {...formItemLayout} label="成熟度">
  196. <span>{getMaturity(theData.maturity)}</span>
  197. </FormItem>
  198. <FormItem className="half-item" {...formItemLayout} label="交易形式">
  199. <span>{getTransaction(theData.transferMode)}</span>
  200. </FormItem>
  201. </div>
  202. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="成果(大图)">
  203. <div className="clearfix">
  204. <Upload className="demandDetailShow-upload"
  205. listType="picture-card"
  206. fileList={this.state.pictureUrl}
  207. onPreview={(file) => {
  208. this.setState({
  209. previewImage: file.url || file.thumbUrl,
  210. previewVisible: true,
  211. });
  212. }} >
  213. </Upload>
  214. <Modal maskClosable={false} footer={null}
  215. visible={this.state.previewVisible}
  216. onCancel={() => { this.setState({ previewVisible: false }) }}>
  217. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  218. </Modal>
  219. </div>
  220. </FormItem>
  221. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="成果(小图)">
  222. <div className="clearfix">
  223. <Upload className="demandDetailShow-upload"
  224. listType="picture-card"
  225. fileList={this.state.pictureUrlMin}
  226. onPreview={(file) => {
  227. this.setState({
  228. previewImage: file.url || file.thumbUrl,
  229. previewVisible: true,
  230. });
  231. }} >
  232. </Upload>
  233. <Modal maskClosable={false} footer={null}
  234. visible={this.state.previewVisible}
  235. onCancel={() => { this.setState({ previewVisible: false }) }}>
  236. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  237. </Modal>
  238. </div>
  239. </FormItem>
  240. <div className="clearfix">
  241. <FormItem className="half-item" {...formItemLayout} label="精品成果">
  242. <span>{theData.boutique?'精品':'非精品'}</span>
  243. </FormItem>
  244. <FormItem className="half-item" {...formItemLayout} label="热点成果">
  245. <span>{theData.isHot?'热点':'非热点'}</span>
  246. </FormItem>
  247. </div>
  248. <div>
  249. <FormItem className="half-item" {...formItemLayout} label="发布状态">
  250. <span>{getReleaseStateList(theData.auditStatus)}</span>
  251. </FormItem>
  252. </div>
  253. <div>
  254. <FormItem className="half-item" labelCol={{ span: 6 }}
  255. wrapperCol={{ span: 18 }} label="发布位置">
  256. <span>{getAchievementPosition(theData.publishPages)}</span>
  257. </FormItem>
  258. </div>
  259. <div className="clearfix">
  260. <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="审核信息">
  261. <span>{theData.auditInfo}</span>
  262. </FormItem>
  263. </div>
  264. <div className="clearfix">
  265. {this.props.data.auditStatus=='2'&&<FormItem wrapperCol={{ span: 12, offset: 3 }}>
  266. <Button className="set-submit" type="primary" onClick={(e)=>{this.updateFun()}} >
  267. 刷新发布
  268. </Button>
  269. <Button type="danger" style={{marginRight:20}} onClick={(e)=>{this.revokeFun()}}>
  270. 撤销发布
  271. </Button>
  272. <Button className="set-submit" type="ghost" onClick={this.cancelFun}>
  273. 取消
  274. </Button>
  275. </FormItem>}
  276. </div>
  277. </SpinContainer>
  278. </Form>
  279. </div>
  280. )
  281. }
  282. }));
  283. export default DemandDetail;