demandDesc.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. import React from 'react';
  2. import { Icon, Modal, message, Spin, Button, Row, Col, Upload, Tooltip, Tag, Input, Table } 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, getDemandType, beforeUploadFile, getOrderStatus } from '@/tools.js';
  8. const DemandDetail = React.createClass({
  9. getInitialState() {
  10. return {
  11. visible: false,
  12. loading: false,
  13. buttonLoading: false,
  14. dataSource: [],
  15. orderVisible: false,
  16. fileList: false,
  17. tags: [],
  18. pictureUrl: [],
  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. };
  36. },
  37. handleCancel(e) {
  38. this.props.closeDesc(false);
  39. },
  40. loadData(id) {
  41. this.setState({
  42. loading: true
  43. });
  44. $.ajax({
  45. method: "get",
  46. dataType: "json",
  47. crossDomain: false,
  48. url: globalConfig.context + '/api/user/portal/demandDetail',
  49. data: {
  50. id: id
  51. },
  52. success: function (data) {
  53. let thisData = data.data;
  54. if (!thisData) {
  55. if (data.error && data.error.length) {
  56. message.warning(data.error[0].message);
  57. };
  58. thisData = {};
  59. };
  60. this.setState({
  61. data: thisData,
  62. tags: thisData.keyword ? thisData.keyword.split(",") : [],
  63. pictureUrl: thisData.pictureUrl ? splitUrl(thisData.pictureUrl, ',', globalConfig.avatarHost + '/upload') : []
  64. });
  65. }.bind(this),
  66. }).always(function () {
  67. this.setState({
  68. loading: false
  69. });
  70. }.bind(this));
  71. },
  72. loadLogsData(id) {
  73. this.setState({
  74. loading: true
  75. });
  76. $.ajax({
  77. method: "get",
  78. dataType: "json",
  79. crossDomain: false,
  80. url: globalConfig.context + '/api/user/portal/order/demandOrderLog',
  81. data: {
  82. demandOrderId: id
  83. },
  84. success: function (data) {
  85. let thisData = data.data, theArr = [], _me = this;
  86. if (!thisData) {
  87. if (data.error && data.error.length) {
  88. message.warning(data.error[0].message);
  89. };
  90. } else {
  91. thisData.map(function (item, i) {
  92. theArr.push({
  93. key: i,
  94. recordTime: item.recordTime,
  95. recordTimeFormattedDate: item.recordTimeFormattedDate,
  96. status: item.status,
  97. comment: item.comment
  98. });
  99. _me.state.logsOrderStatus = item.status;
  100. });
  101. };
  102. this.setState({
  103. dataSource: theArr
  104. });
  105. }.bind(this),
  106. }).always(function () {
  107. this.setState({
  108. loading: false
  109. });
  110. }.bind(this));
  111. },
  112. interestClick() {
  113. this.setState({
  114. loading: true
  115. });
  116. $.ajax({
  117. method: "post",
  118. dataType: "json",
  119. crossDomain: false,
  120. url: globalConfig.context + '/api/user/portal/demandInterest',
  121. data: {
  122. id: this.props.data.id
  123. },
  124. success: function (data) {
  125. if (data.error && data.error.length) {
  126. message.warning(data.error[0].message);
  127. } else {
  128. this.loadData(this.props.data.id);
  129. };
  130. }.bind(this),
  131. }).always(function () {
  132. this.setState({
  133. loading: false
  134. });
  135. }.bind(this));;
  136. },
  137. cancelInterestClick() {
  138. this.setState({
  139. loading: true
  140. });
  141. $.ajax({
  142. method: "post",
  143. dataType: "json",
  144. crossDomain: false,
  145. url: globalConfig.context + '/api/user/portal/demandCancelInterest',
  146. data: {
  147. id: this.state.data.demandInterestId
  148. },
  149. success: function (data) {
  150. if (data.error && data.error.length) {
  151. message.warning(data.error[0].message);
  152. } else {
  153. this.loadData(this.props.data.id);
  154. };
  155. }.bind(this),
  156. }).always(function () {
  157. this.setState({
  158. loading: false
  159. });
  160. }.bind(this));;
  161. },
  162. handleSubmit() {
  163. this.setState({
  164. buttonLoading: true
  165. });
  166. $.ajax({
  167. method: "post",
  168. dataType: "json",
  169. crossDomain: false,
  170. url: globalConfig.context + '/api/user/portal/order/orderDemand',
  171. data: {
  172. demandId: this.state.data.id,
  173. enclosureUrl: this.state.enclosureUrl,
  174. comment: this.state.comment
  175. },
  176. success: function (data) {
  177. if (data.error && data.error.length) {
  178. message.warning(data.error[0].message);
  179. } else { message.success("提交成功!") };
  180. }.bind(this),
  181. }).always(function () {
  182. this.loadData(this.state.data.id);
  183. this.setState({
  184. orderVisible: false,
  185. buttonLoading: false
  186. });
  187. }.bind(this));
  188. },
  189. cancelSubmit() {
  190. this.setState({
  191. buttonLoading: true
  192. });
  193. $.ajax({
  194. method: "post",
  195. dataType: "json",
  196. crossDomain: false,
  197. url: globalConfig.context + '/api/user/portal/order/demandShutdown',
  198. data: {
  199. id: this.state.data.demandOrderId
  200. },
  201. success: function (data) {
  202. if (data.error && data.error.length) {
  203. message.warning(data.error[0].message);
  204. } else { message.success("撤销成功!") };
  205. }.bind(this),
  206. }).always(function () {
  207. this.loadData(this.state.data.id);
  208. this.setState({
  209. buttonLoading: false
  210. });
  211. }.bind(this));
  212. },
  213. componentWillReceiveProps(nextProps) {
  214. if (!this.props.showDesc && nextProps.showDesc) {
  215. if (nextProps.data.id) {
  216. this.loadData(nextProps.data.id);
  217. if (nextProps.data.orderId) {
  218. this.loadLogsData(nextProps.data.orderId)
  219. }
  220. } else {
  221. this.state.data = {};
  222. this.state.tags = [];
  223. this.state.pictureUrl = [];
  224. };
  225. };
  226. },
  227. render() {
  228. const theData = this.state.data || {};
  229. if (this.props.data) {
  230. return (
  231. <Modal maskClosable={false}
  232. visible={this.props.showDesc}
  233. onCancel={this.handleCancel}
  234. title={<div className="interest clearfix">
  235. <span>需求详情</span>
  236. {theData.demandInterestId ? <a onClick={this.cancelInterestClick}><Icon type="heart" /> 不感兴趣</a>
  237. : <a onClick={this.interestClick}><Icon type="heart-o" /> 感兴趣</a>}
  238. </div>}
  239. width='1000px'
  240. footer=''
  241. className="portal-desc-content">
  242. <Spin spinning={this.state.loading} className="portal-desc">
  243. <Row>
  244. <Col span={4}>编号</Col>
  245. <Col span={8}>{theData.serialNumber}</Col>
  246. <Col span={4}>名称</Col>
  247. <Col span={8}>{theData.name}</Col>
  248. </Row>
  249. <Row>
  250. <Col span={4}>数据类别</Col>
  251. <Col span={8}>
  252. {(() => {
  253. switch (theData.dataCategory) {
  254. case "0":
  255. return <span>个人需求</span>;
  256. case "1":
  257. return <span>单位需求</span>;
  258. }
  259. })()}
  260. </Col>
  261. <Col span={4}>需求类型</Col>
  262. <Col span={8}>{getDemandType(theData.demandType)}</Col>
  263. </Row>
  264. <Row>
  265. <Col span={4}>应用领域</Col>
  266. <Col span={8}>{getIndustryCategory(theData.industryCategoryA, theData.industryCategoryB)}</Col>
  267. <Col span={4}>有效期限</Col>
  268. <Col span={8}>{theData.releaseDateFormattedDate}</Col>
  269. </Row>
  270. <Row>
  271. <Col span={4}>关键词</Col>
  272. <Col span={20}>
  273. {this.state.tags.map((tag) => {
  274. return <Tooltip key={tag} title={tag}>
  275. <Tag key={tag}>{tag}</Tag>
  276. </Tooltip>;
  277. })}
  278. </Col>
  279. </Row>
  280. <Row>
  281. <Col span={4}>问题说明</Col>
  282. <Col span={20}>{theData.problemDes}</Col>
  283. </Row>
  284. <Row>
  285. <Col span={4}>技术指标要求</Col>
  286. <Col span={20}>{theData.technicalRequirements}</Col>
  287. </Row>
  288. <Row>
  289. <Col span={4}>需求相关文件(图片)</Col>
  290. <Col span={20}>
  291. <div className="clearfix">
  292. <Upload
  293. listType="picture-card"
  294. fileList={this.state.pictureUrl}
  295. onPreview={(file) => {
  296. this.setState({
  297. previewImage: file.url || file.thumbUrl,
  298. previewVisible: true,
  299. });
  300. }} >
  301. </Upload>
  302. <Modal maskClosable={false} footer={null}
  303. visible={this.state.previewVisible}
  304. onCancel={() => { this.setState({ previewVisible: false }) }}>
  305. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  306. </Modal>
  307. </div>
  308. </Col>
  309. </Row>
  310. <Row>
  311. <Col span={4}>需求相关文件(文本)</Col>
  312. <Col span={20}>
  313. {theData.textFileUrl ?
  314. <span className="download-file">
  315. <a onClick={() => { window.open(globalConfig.context + '/api/user/demand/download?id=' + theData.id + '&sign=demand_maturity_text_file') }}>需求文件(文本文件)</a>
  316. </span>
  317. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}
  318. </Col>
  319. </Row>
  320. <Row>
  321. <Col span={4}>需求文件(视频地址)</Col>
  322. <Col span={20}>{theData.videoUrl}</Col>
  323. </Row>
  324. <Row>
  325. <Col span={4}>雇佣方名称</Col>
  326. <Col span={8}>{theData.employerName}</Col>
  327. <Col span={4}>固定周期</Col>
  328. <Col span={8}>{theData.fixedCycle}</Col>
  329. </Row>
  330. <Row>
  331. <Col span={4}>固定人数</Col>
  332. <Col span={8}>{theData.peopleNumber}</Col>
  333. <Col span={4}>预算价格</Col>
  334. <Col span={8}>{theData.budgetCost}</Col>
  335. </Row>
  336. <Row>
  337. <Col span={4}>固定方案</Col>
  338. <Col span={20}>{theData.fixedScheme}</Col>
  339. </Row>
  340. {this.props.data.orderId ? <div>
  341. <p>状态流转记录: </p>
  342. <Table style={{ margin: '10px 0', background: "#eee" }}
  343. pagination={false}
  344. dataSource={this.state.dataSource}
  345. columns={this.state.columns} />
  346. </div> : <div></div>}
  347. {this.state.logsOrderStatus == 6 ? <div>
  348. <Button type="ghost" onClick={() => { this.handleCancel() }}>取消</Button>
  349. </div> : <div>
  350. {theData.demandOrderId ? <Button type="ghost" loading={this.state.buttonLoading}
  351. disabled={Boolean(theData.orderStatus != "0")}
  352. onClick={this.cancelSubmit}>我要撤销</Button>
  353. : <Button type="primary" onClick={() => {
  354. if (window.userData.number) {
  355. this.setState({ orderVisible: true });
  356. } else {
  357. message.warning("请先登录!");
  358. }
  359. }}>我要接单</Button>}
  360. </div>}
  361. <Modal maskClosable={false}
  362. title="我要接单"
  363. width={600}
  364. style={{ 'top': '160px' }}
  365. visible={this.state.orderVisible}
  366. footer={null}
  367. onCancel={() => { this.setState({ orderVisible: false }); }}>
  368. <Row>
  369. <Col span={2}>附件 : </Col>
  370. <Col span={8}>
  371. <Upload action={globalConfig.context + "/api/user/portal/order/demandUpload"}
  372. data={{ 'sign': 'demand_order_file' }}
  373. beforeUpload={beforeUploadFile}
  374. fileList={this.state.fileList}
  375. onChange={(info) => {
  376. if (info.file.status !== 'uploading') {
  377. console.log(info.file, info.fileList);
  378. }
  379. if (info.file.status === 'done') {
  380. if (!info.file.response.error.length) {
  381. message.success(`${info.file.name} 文件上传成功!`);
  382. } else {
  383. message.warning(info.file.response.error[0].message);
  384. return;
  385. };
  386. this.state.enclosureUrl = info.file.response.data;
  387. } else if (info.file.status === 'error') {
  388. message.error(`${info.file.name} 文件上传失败。`);
  389. };
  390. this.setState({ fileList: info.fileList.slice(-1) });
  391. }} >
  392. <Button><Icon type="upload" /> 上传相关资质附件 </Button>
  393. </Upload>
  394. </Col>
  395. </Row>
  396. <Row style={{ marginTop: '20px' }} >
  397. <Col span={2}>备注 : </Col>
  398. <Col span={22}>
  399. <Input type="textarea" rows={4} onChange={(e) => { this.state.comment = e.target.value }} />
  400. </Col>
  401. </Row>
  402. <Button loading={this.state.buttonLoading} style={{ marginTop: '20px' }} type="primary" onClick={this.handleSubmit}>提交</Button>
  403. </Modal>
  404. </Spin>
  405. </Modal>
  406. );
  407. } else {
  408. return <div></div>
  409. }
  410. },
  411. });
  412. export default DemandDetail;