achievementDesc.jsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. import React from 'react';
  2. import { Icon, Modal, message, Spin, Button, Row, Col, Upload, Tooltip, Tag, Table, Input } from 'antd';
  3. import '../portal.less';
  4. import ajax from 'jquery/src/ajax/xhr.js';
  5. import $ from 'jquery/src/ajax';
  6. import { getIndustryCategory } from '@/DicIndustryList.js';
  7. import { splitUrl, getAchievementCategory, getMaturity, getInnovation, getOrderStatus, beforeUploadFile } from '@/tools.js';
  8. const AchievementDetail = React.createClass({
  9. getInitialState() {
  10. return {
  11. visible: false,
  12. loading: false,
  13. buttonLoading: false,
  14. dataSource: [],
  15. orderVisible: false,
  16. tags: [],
  17. technicalPictureUrl: [],
  18. maturityPictureUrl: [],
  19. columns: [
  20. {
  21. title: '状态',
  22. dataIndex: 'status',
  23. key: 'status',
  24. render: (text) => { return getOrderStatus(text) }
  25. }, {
  26. title: '处理时间',
  27. dataIndex: 'recordTimeFormattedDate',
  28. key: 'recordTimeFormattedDate',
  29. }, {
  30. title: '备注',
  31. dataIndex: 'comment',
  32. key: 'comment',
  33. }
  34. ],
  35. logsOrderStatus: 0
  36. };
  37. },
  38. handleCancel(e) {
  39. this.props.closeDesc(false);
  40. },
  41. loadData(id) {
  42. this.setState({
  43. loading: true
  44. });
  45. $.ajax({
  46. method: "get",
  47. dataType: "json",
  48. crossDomain: false,
  49. url: globalConfig.context + '/api/user/portal/achievementDetail',
  50. data: {
  51. id: id
  52. },
  53. success: function (data) {
  54. let thisData = data.data;
  55. if (!thisData) {
  56. if (data.error && data.error.length) {
  57. message.warning(data.error[0].message);
  58. };
  59. thisData = {};
  60. };
  61. this.setState({
  62. data: thisData,
  63. tags: thisData.keyword ? thisData.keyword.split(",") : [],
  64. technicalPictureUrl: thisData.technicalPictureUrl ? splitUrl(thisData.technicalPictureUrl, ',', globalConfig.avatarHost + '/upload') : [],
  65. maturityPictureUrl: thisData.maturityPictureUrl ? splitUrl(thisData.maturityPictureUrl, ',', globalConfig.avatarHost + '/upload') : []
  66. });
  67. }.bind(this),
  68. }).always(function () {
  69. this.setState({
  70. loading: false
  71. });
  72. }.bind(this));
  73. },
  74. loadLogsData(id) {
  75. this.setState({
  76. loading: true
  77. });
  78. $.ajax({
  79. method: "get",
  80. dataType: "json",
  81. crossDomain: false,
  82. url: globalConfig.context + '/api/user/portal/order/achievementOrderLog',
  83. data: {
  84. achievementOrderId: id
  85. },
  86. success: function (data) {
  87. let thisData = data.data, theArr = [], _me = this;
  88. if (!thisData) {
  89. if (data.error && data.error.length) {
  90. message.warning(data.error[0].message);
  91. };
  92. } else {
  93. thisData.map(function (item, i) {
  94. theArr.push({
  95. key: i,
  96. recordTime: item.recordTime,
  97. recordTimeFormattedDate: item.recordTimeFormattedDate,
  98. status: item.status,
  99. comment: item.comment
  100. });
  101. _me.state.logsOrderStatus = item.status;
  102. });
  103. };
  104. this.setState({
  105. dataSource: theArr
  106. });
  107. }.bind(this),
  108. }).always(function () {
  109. this.setState({
  110. loading: false
  111. });
  112. }.bind(this));
  113. },
  114. interestClick() {
  115. this.setState({
  116. loading: true
  117. });
  118. $.ajax({
  119. method: "post",
  120. dataType: "json",
  121. crossDomain: false,
  122. url: globalConfig.context + '/api/user/portal/achievementInterest',
  123. data: {
  124. id: this.props.data.id
  125. },
  126. success: function (data) {
  127. if (data.error && data.error.length) {
  128. message.warning(data.error[0].message);
  129. } else {
  130. this.loadData(this.props.data.id);
  131. };
  132. }.bind(this),
  133. }).always(function () {
  134. this.setState({
  135. loading: false
  136. });
  137. }.bind(this));;
  138. },
  139. cancelInterestClick() {
  140. this.setState({
  141. loading: true
  142. });
  143. $.ajax({
  144. method: "post",
  145. dataType: "json",
  146. crossDomain: false,
  147. url: globalConfig.context + '/api/user/portal/achievementCancelInterest',
  148. data: {
  149. id: this.state.data.achievementInterestId
  150. },
  151. success: function (data) {
  152. if (data.error && data.error.length) {
  153. message.warning(data.error[0].message);
  154. } else {
  155. this.loadData(this.props.data.id);
  156. };
  157. }.bind(this),
  158. }).always(function () {
  159. this.setState({
  160. loading: false
  161. });
  162. }.bind(this));;
  163. },
  164. handleSubmit() {
  165. this.setState({
  166. buttonLoading: true
  167. });
  168. $.ajax({
  169. method: "post",
  170. dataType: "json",
  171. crossDomain: false,
  172. url: globalConfig.context + '/api/user/portal/order/orderAchievement',
  173. data: {
  174. achievementId: this.state.data.id,
  175. comment: this.state.comment
  176. },
  177. success: function (data) {
  178. if (data.error && data.error.length) {
  179. message.warning(data.error[0].message);
  180. } else { message.success("提交成功!") };
  181. }.bind(this),
  182. }).always(function () {
  183. this.loadData(this.state.data.id);
  184. this.setState({
  185. orderVisible: false,
  186. buttonLoading: false
  187. });
  188. }.bind(this));
  189. },
  190. cancelSubmit() {
  191. this.setState({
  192. buttonLoading: true
  193. });
  194. $.ajax({
  195. method: "post",
  196. dataType: "json",
  197. crossDomain: false,
  198. url: globalConfig.context + '/api/user/portal/order/achievementShutdown',
  199. data: {
  200. id: this.state.data.achievementOrderId
  201. },
  202. success: function (data) {
  203. if (data.error && data.error.length) {
  204. message.warning(data.error[0].message);
  205. } else { message.success("撤销成功!") };
  206. }.bind(this),
  207. }).always(function () {
  208. this.loadData(this.state.data.id);
  209. this.setState({
  210. buttonLoading: false
  211. });
  212. }.bind(this));
  213. },
  214. componentWillReceiveProps(nextProps) {
  215. if (!this.props.showDesc && nextProps.showDesc) {
  216. if (nextProps.data.id) {
  217. this.loadData(nextProps.data.id);
  218. if (nextProps.data.orderId) {
  219. this.loadLogsData(nextProps.data.orderId)
  220. }
  221. } else {
  222. this.state.data = {};
  223. this.state.tags = [];
  224. this.state.maturityPictureUrl = [];
  225. this.state.technicalPictureUrl = [];
  226. };
  227. };
  228. },
  229. render() {
  230. const theData = this.state.data || {};
  231. if (this.props.data) {
  232. return (
  233. <Modal maskClosable={false}
  234. visible={this.props.showDesc}
  235. onCancel={this.handleCancel}
  236. title={<div className="interest clearfix">
  237. <span>成果详情</span>
  238. {theData.achievementInterestId ? <a onClick={this.cancelInterestClick}><Icon type="heart" /> 不感兴趣</a>
  239. : <a onClick={this.interestClick}><Icon type="heart-o" /> 感兴趣</a>}
  240. </div>}
  241. width='1000px'
  242. footer=''
  243. className="portal-desc-content">
  244. <Spin spinning={this.state.loading} className="portal-desc">
  245. <Row>
  246. <Col span={4}>编号</Col>
  247. <Col span={8}>{theData.serialNumber}</Col>
  248. <Col span={4}>名称</Col>
  249. <Col span={8}>{theData.name}</Col>
  250. </Row>
  251. <Row>
  252. <Col span={4}>数据类别</Col>
  253. <Col span={8}>
  254. {(() => {
  255. switch (theData.dataCategory) {
  256. case "0":
  257. return <span>成果</span>;
  258. case "1":
  259. return <span>技术</span>;
  260. case "2":
  261. return <span>项目</span>;
  262. }
  263. })()}
  264. </Col>
  265. <Col span={4}>类型</Col>
  266. <Col span={8}>{getAchievementCategory(theData.category)}</Col>
  267. </Row>
  268. <Row>
  269. <Col span={4}>应用领域</Col>
  270. <Col span={8}>{getIndustryCategory(theData.fieldA, theData.fieldB)}</Col>
  271. <Col span={4}>发布时间</Col>
  272. <Col span={8}>{theData.releaseDateFormattedDate}</Col>
  273. </Row>
  274. <Row>
  275. <Col span={4}>关键词</Col>
  276. <Col span={20}>
  277. {this.state.tags.map((tag) => {
  278. return <Tooltip key={tag} title={tag}>
  279. <Tag key={tag}>{tag}</Tag>
  280. </Tooltip>;
  281. })}
  282. </Col>
  283. </Row>
  284. <Row>
  285. <Col span={4}>摘要</Col>
  286. <Col span={20}>{theData.summary}</Col>
  287. </Row>
  288. <Row>
  289. <Col span={4}>成果简介</Col>
  290. <Col span={20}>{theData.introduction}</Col>
  291. </Row>
  292. <Row>
  293. <Col span={4}>技术图片</Col>
  294. <Col span={20}>
  295. <div className="clearfix">
  296. <Upload
  297. listType="picture-card"
  298. fileList={this.state.technicalPictureUrl}
  299. onPreview={(file) => {
  300. this.setState({
  301. previewImage: file.url || file.thumbUrl,
  302. previewVisible: true,
  303. });
  304. }} >
  305. </Upload>
  306. <Modal maskClosable={false} footer={null}
  307. visible={this.state.previewVisible}
  308. onCancel={() => { this.setState({ previewVisible: false }) }}>
  309. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  310. </Modal>
  311. </div>
  312. </Col>
  313. </Row>
  314. <Row>
  315. <Col span={4}>成熟度</Col>
  316. <Col span={8}>{getMaturity(theData.maturity)}</Col>
  317. <Col span={4}>创新度</Col>
  318. <Col span={8}>{getInnovation(theData.innovation)}</Col>
  319. </Row>
  320. <Row>
  321. <Col span={4}>成熟度证明材料(图片)</Col>
  322. <Col span={20}>
  323. <Upload className="demandDetailShow-upload"
  324. listType="picture-card"
  325. fileList={this.state.maturityPictureUrl}
  326. onPreview={(file) => {
  327. this.setState({
  328. previewImage: file.url || file.thumbUrl,
  329. previewVisible: true,
  330. });
  331. }} >
  332. </Upload>
  333. </Col>
  334. </Row>
  335. <Row>
  336. <Col span={4}>成熟度证明材料(文本)</Col>
  337. <Col span={20}>
  338. {theData.maturityTextFileUrl ?
  339. <span className="download-file">
  340. <a onClick={() => { window.open(globalConfig.context + '/api/user/achievement/download?id=' + theData.id + '&sign=achievement_maturity_text_file') }}>成熟度证明材料(文本文件)</a>
  341. </span>
  342. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}
  343. </Col>
  344. </Row>
  345. <Row>
  346. <Col span={4}>成熟度证明材料(视频地址)</Col>
  347. <Col span={20}>{theData.maturityVideoUrl}</Col>
  348. </Row>
  349. <Row>
  350. <Col span={4}>成果所有人名称</Col>
  351. <Col span={8}>{theData.ownerName}</Col>
  352. <Col span={4}>合作方式</Col>
  353. <Col span={8}>
  354. {(() => {
  355. switch (theData.cooperationMode) {
  356. case "0":
  357. return <span>技术转让</span>;
  358. case "1":
  359. return <span>授权生产</span>;
  360. }
  361. })()}
  362. </Col>
  363. </Row>
  364. <Row>
  365. <Col span={4}>转让方式</Col>
  366. <Col span={8}>
  367. {(() => {
  368. switch (theData.transferMode) {
  369. case "0":
  370. return <span>完全转让</span>;
  371. case "1":
  372. return <span>许可转让</span>;
  373. case "2":
  374. return <span>技术入股</span>;
  375. }
  376. })()}
  377. </Col>
  378. <Col span={4}>转让价格</Col>
  379. <Col span={8}>
  380. {(() => {
  381. switch (theData.bargainingMode) {
  382. case "0":
  383. return <span>面议</span>;
  384. case "1":
  385. return <span>{theData.transferPrice} 万元</span>;
  386. }
  387. })()}
  388. </Col>
  389. </Row>
  390. <Row>
  391. <Col span={4}>技术场景</Col>
  392. <Col span={20}>{theData.technicalScene}</Col>
  393. </Row>
  394. <Row>
  395. <Col span={4}>技术突破</Col>
  396. <Col span={20}>{theData.breakthrough}</Col>
  397. </Row>
  398. <Row>
  399. <Col span={4}>专利情况</Col>
  400. <Col span={20}>{theData.patentCase}</Col>
  401. </Row>
  402. <Row>
  403. <Col span={4}>获奖情况</Col>
  404. <Col span={20}>{theData.awards}</Col>
  405. </Row>
  406. <Row>
  407. <Col span={4}>技术团队情况</Col>
  408. <Col span={20}>{theData.teamDes}</Col>
  409. </Row>
  410. <Row>
  411. <Col span={4}>技术参数</Col>
  412. <Col span={20}>{theData.parameter}</Col>
  413. </Row>
  414. <Row>
  415. <Col span={4}>技术方案</Col>
  416. <Col span={20}>
  417. {theData.techPlanUrl ?
  418. <span className="download-file">
  419. <a onClick={() => { window.open(globalConfig.context + '/api/user/achievement/download?id=' + theData.id + '&sign=achievement_tech_plan') }}>技术方案</a>
  420. </span>
  421. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}
  422. </Col>
  423. </Row>
  424. <Row>
  425. <Col span={4}>商业计划书</Col>
  426. <Col span={20}>
  427. {theData.businessPlanUrl ?
  428. <span className="download-file">
  429. <a onClick={() => { window.open(globalConfig.context + '/api/user/achievement/download?id=' + theData.id + '&sign=achievement_business_plan') }}>商业计划书</a>
  430. </span>
  431. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}
  432. </Col>
  433. </Row>
  434. {this.props.data.orderId ? <div>
  435. <p>状态流转记录: </p>
  436. <Table style={{ margin: '10px 0', background: "#eee" }}
  437. pagination={false}
  438. dataSource={this.state.dataSource}
  439. columns={this.state.columns} />
  440. </div> : <div></div>}
  441. {this.state.logsOrderStatus == 6 ? <div>
  442. <Button type="ghost" onClick={() => { this.handleCancel() }}>取消</Button>
  443. </div> : <div>
  444. {theData.achievementOrderId ? <Button type="ghost" loading={this.state.buttonLoading}
  445. disabled={Boolean(theData.orderStatus != "0")}
  446. onClick={this.cancelSubmit}>我要撤销</Button>
  447. : <Button type="primary" onClick={() => {
  448. if (window.userData.number) {
  449. this.setState({ orderVisible: true });
  450. } else {
  451. message.warning("请先登录!");
  452. }
  453. }}>我要购买</Button>}
  454. </div>}
  455. <Modal maskClosable={false}
  456. title="我要购买"
  457. width={600}
  458. style={{ 'top': '160px' }}
  459. visible={this.state.orderVisible}
  460. footer={null}
  461. onCancel={() => { this.setState({ orderVisible: false }); }}>
  462. <Row>
  463. <Col span={2}>备注 : </Col>
  464. <Col span={22}>
  465. <Input type="textarea" rows={4} onChange={(e) => { this.state.comment = e.target.value }} />
  466. </Col>
  467. </Row>
  468. <Button loading={this.state.buttonLoading} style={{ marginTop: '20px' }} type="primary" onClick={this.handleSubmit}>提交</Button>
  469. </Modal>
  470. </Spin>
  471. </Modal>
  472. );
  473. } else {
  474. return <div></div>
  475. }
  476. },
  477. });
  478. export default AchievementDetail;