achievementDetails.jsx 11 KB

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