achievementDesc.jsx 22 KB

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