techDemandDesc.jsx 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438
  1. import React from 'react';
  2. import { AutoComplete, Switch, Tabs, Table, Icon, Tooltip, Modal, Popover, message, Spin, Upload, Input, InputNumber, Select, DatePicker, Button, Radio, Form, Cascader, Tag } from 'antd';
  3. import moment from 'moment';
  4. import './techDemand.less';
  5. import ajax from 'jquery/src/ajax/xhr.js';
  6. import $ from 'jquery/src/ajax';
  7. import { IndustryObject, getIndustryCategory } from '../../DicIndustryList.js';
  8. import { beforeUploadFile, getTechAuditStatus, splitUrl, companySearch, getTechField, getDemandType, getAchievementCategory } from '../../tools.js';
  9. import throttle from '../../throttle.js';
  10. const KeyWordTagGroup = React.createClass({
  11. getInitialState() {
  12. return {
  13. tags: [],
  14. inputVisible: false,
  15. inputValue: ''
  16. };
  17. },
  18. handleClose(removedTag) {
  19. const tags = this.state.tags.filter(tag => tag !== removedTag);
  20. this.props.tagsArr(tags);
  21. this.setState({ tags });
  22. },
  23. showInput() {
  24. this.setState({ inputVisible: true }, () => this.input.focus());
  25. },
  26. handleInputChange(e) {
  27. this.setState({ inputValue: e.target.value });
  28. },
  29. handleInputConfirm() {
  30. const state = this.state;
  31. const inputValue = state.inputValue;
  32. let tags = state.tags;
  33. if (inputValue && tags.indexOf(inputValue) === -1 && inputValue.replace(/(^\s*)|(\s*$)/g, "").length != 0) {
  34. tags = [...tags, inputValue.replace(/(^\s*)|(\s*$)/g, "")];
  35. }
  36. this.props.tagsArr(tags);
  37. this.setState({
  38. tags,
  39. inputVisible: false,
  40. inputValue: '',
  41. });
  42. },
  43. componentWillMount() {
  44. this.state.tags = this.props.keyWordArr;
  45. },
  46. componentWillReceiveProps(nextProps) {
  47. if (this.props.keyWordArr != nextProps.keyWordArr) {
  48. this.state.tags = nextProps.keyWordArr;
  49. };
  50. },
  51. render() {
  52. const { tags, inputVisible, inputValue } = this.state;
  53. return (
  54. <div className="keyWord-tips">
  55. {tags.map((tag, index) => {
  56. const isLongTag = tag.length > 10;
  57. const tagElem = (
  58. <Tag key={tag} closable={index !== -1} afterClose={() => this.handleClose(tag)}>
  59. {isLongTag ? `${tag.slice(0, 10)}...` : tag}
  60. </Tag>
  61. );
  62. return isLongTag ? <Tooltip title={tag}>{tagElem}</Tooltip> : tagElem;
  63. })}
  64. {inputVisible && (
  65. <Input
  66. ref={input => this.input = input}
  67. type="text"
  68. style={{ width: 78 }}
  69. value={inputValue}
  70. onChange={this.handleInputChange}
  71. onBlur={this.handleInputConfirm}
  72. onPressEnter={this.handleInputConfirm}
  73. />
  74. )}
  75. {!inputVisible && <Button className="addtips" type="dashed" disabled={tags.length > 9 ? true : false} onClick={this.showInput}>+ 新关键词</Button>}
  76. </div>
  77. );
  78. }
  79. });
  80. const PicturesWall = React.createClass({
  81. getInitialState() {
  82. return {
  83. previewVisible: false,
  84. previewImage: '',
  85. fileList: [],
  86. }
  87. },
  88. handleCancel() {
  89. this.setState({ previewVisible: false })
  90. },
  91. handlePreview(file) {
  92. this.setState({
  93. previewImage: file.url || file.thumbUrl,
  94. previewVisible: true,
  95. });
  96. },
  97. handleChange(info) {
  98. let fileList = info.fileList;
  99. this.setState({ fileList });
  100. this.props.fileList(fileList);
  101. },
  102. componentWillReceiveProps(nextProps) {
  103. this.state.fileList = nextProps.pictureUrl;
  104. },
  105. render() {
  106. const { previewVisible, previewImage, fileList } = this.state;
  107. const uploadButton = (
  108. <div>
  109. <Icon type="plus" />
  110. <div className="ant-upload-text">点击上传</div>
  111. </div>
  112. );
  113. return (
  114. <div className="clearfix">
  115. <Upload
  116. action={globalConfig.context + "/api/admin/demand/uploadPicture"}
  117. data={{ 'sign': 'demand_picture', 'uid': this.props.uid }}
  118. listType="picture-card"
  119. fileList={fileList}
  120. onPreview={this.handlePreview}
  121. onChange={this.handleChange} >
  122. {fileList.length >= 5 ? null : uploadButton}
  123. </Upload>
  124. <Modal maskClosable={false} visible={previewVisible} footer={null} onCancel={this.handleCancel}>
  125. <img alt="example" style={{ width: '100%' }} src={previewImage} />
  126. </Modal>
  127. </div>
  128. );
  129. }
  130. });
  131. const DemandDetailShow = Form.create()(React.createClass({
  132. getInitialState() {
  133. return {
  134. visible: false,
  135. loading: false,
  136. contactsObj: {},
  137. salesmanObj: {},
  138. data: {},
  139. tags: [],
  140. pictureUrl: []
  141. };
  142. },
  143. loadData(id, detailApiUrl) {
  144. this.setState({
  145. loading: true
  146. });
  147. $.ajax({
  148. method: "get",
  149. dataType: "json",
  150. crossDomain: false,
  151. url: globalConfig.context + detailApiUrl,
  152. data: {
  153. id: id
  154. },
  155. success: function (data) {
  156. let thisData = data.data;
  157. if (!thisData) {
  158. if (data.error && data.error.length) {
  159. message.warning(data.error[0].message);
  160. };
  161. thisData = {};
  162. };
  163. this.setState({
  164. data: thisData,
  165. switchValue: Boolean(!thisData.employerId),
  166. tags: thisData.keyword ? (thisData.keyword.replace(/(,|、)/g, ",")).split(',') : [],
  167. pictureUrl: thisData.pictureUrl ? splitUrl(thisData.pictureUrl, ',', globalConfig.avatarHost + '/upload') : []
  168. });
  169. }.bind(this),
  170. }).always(function () {
  171. this.setState({
  172. loading: false
  173. });
  174. }.bind(this));
  175. },
  176. getContactsList(theUid) {
  177. $.ajax({
  178. method: "get",
  179. dataType: "json",
  180. crossDomain: false,
  181. url: globalConfig.context + "/api/admin/getContacts",
  182. data: {
  183. uid: theUid
  184. },
  185. success: function (data) {
  186. let theOption = [];
  187. if (!data.data) {
  188. if (data.error && data.error.length) {
  189. message.warning(data.error[0].message);
  190. };
  191. } else {
  192. this.setState({
  193. contactsObj: data.data
  194. });
  195. };
  196. }.bind(this),
  197. });
  198. },
  199. offShelf() {
  200. this.setState({
  201. loading: true
  202. });
  203. $.ajax({
  204. method: "post",
  205. dataType: "json",
  206. crossDomain: false,
  207. url: globalConfig.context + "/api/admin/demand/offShelf",
  208. data: { "id": this.props.data.id }
  209. }).done(function (data) {
  210. if (!data.error.length) {
  211. message.success('撤销成功!');
  212. this.props.handleOk();
  213. } else {
  214. message.warning(data.error[0].message);
  215. };
  216. this.setState({
  217. loading: false,
  218. releaseSubmitVisible: false
  219. });
  220. }.bind(this));
  221. },
  222. formSubmit() {
  223. this.props.form.validateFields((err, values) => {
  224. if (values.auditStatus == 3 && !values.techBroderId) {
  225. message.warning('必须选择一个技术经纪人!');
  226. return
  227. };
  228. if (!err) {
  229. this.setState({
  230. loading: true
  231. });
  232. $.ajax({
  233. method: "POST",
  234. dataType: "json",
  235. crossDomain: false,
  236. url: globalConfig.context + '/api/admin/audit/demand',
  237. data: {
  238. id: this.props.data.id,
  239. techBroderId: values.techBroderId,
  240. auditStatus: values.auditStatus
  241. }
  242. }).done(function (data) {
  243. this.state.auditStatus = 0;
  244. if (!data.error.length) {
  245. message.success('保存成功!');
  246. this.setState({ formSubmitVisible: false });
  247. this.props.handleOk();
  248. } else {
  249. message.warning(data.error[0].message);
  250. this.setState({
  251. loading: false,
  252. });
  253. }
  254. }.bind(this));
  255. }
  256. });
  257. },
  258. handleSubmit(e) {
  259. e.preventDefault();
  260. this.props.form.validateFields((err, values) => {
  261. if (values.auditStatus == 4) {
  262. this.setState({
  263. formSubmitVisible: true
  264. });
  265. } else {
  266. this.formSubmit();
  267. };
  268. });
  269. },
  270. buildMatchList() {
  271. this.setState({
  272. buttonLoading: true
  273. });
  274. $.ajax({
  275. method: "POST",
  276. dataType: "json",
  277. crossDomain: false,
  278. url: globalConfig.context + '/api/admin/demand/matchAchievement',
  279. data: {
  280. id: this.props.data.id,
  281. }
  282. }).done(function (data) {
  283. this.setState({
  284. buttonLoading: false
  285. });
  286. if (!data.error.length) {
  287. message.success('匹配完成!匹配到' + data.data + '条记录');
  288. } else {
  289. message.warning(data.error[0].message);
  290. };
  291. }.bind(this));
  292. },
  293. componentWillMount() {
  294. this.loadData(this.props.data.id, this.props.detailApiUrl);
  295. if (this.props.data.employerId) {
  296. this.getContactsList(this.props.data.employerId);
  297. };
  298. },
  299. componentWillReceiveProps(nextProps) {
  300. if (!this.props.visible && nextProps.visible) {
  301. this.loadData(nextProps.data.id, nextProps.detailApiUrl);
  302. if (nextProps.data.employerId) {
  303. this.getContactsList(nextProps.data.employerId);
  304. };
  305. this.props.form.resetFields();
  306. };
  307. },
  308. render() {
  309. const theData = this.state.data || {};
  310. const { getFieldDecorator } = this.props.form;
  311. const FormItem = Form.Item
  312. const formItemLayout = {
  313. labelCol: { span: 6 },
  314. wrapperCol: { span: 12 },
  315. };
  316. return (
  317. <Form horizontal onSubmit={this.handleSubmit} id="demand-form">
  318. <Spin spinning={this.state.loading}>
  319. <div className="clearfix">
  320. <FormItem className="half-item"
  321. {...formItemLayout}
  322. label="编号" >
  323. <span>{theData.serialNumber}</span>
  324. </FormItem>
  325. <FormItem className="half-item"
  326. {...formItemLayout}
  327. label="需求名称" >
  328. <span>{theData.name}</span>
  329. </FormItem>
  330. </div>
  331. {this.state.switchValue ? <div>
  332. <FormItem className="half-item"
  333. {...formItemLayout}
  334. label="雇主名称" >
  335. <span>{theData.employerName}</span>
  336. </FormItem>
  337. <FormItem className="half-item"
  338. {...formItemLayout}
  339. label="联系电话" >
  340. <span>{theData.employerContactsMobile}</span>
  341. </FormItem>
  342. <FormItem className="half-item"
  343. {...formItemLayout}
  344. label="电子邮箱" >
  345. <span>{theData.employerContactsMailbox}</span>
  346. </FormItem>
  347. <FormItem className="half-item"
  348. {...formItemLayout}
  349. label="通讯地址" >
  350. <span>{theData.employerAddress}</span>
  351. </FormItem>
  352. </div> : <div className="clearfix">
  353. <FormItem className="half-item"
  354. {...formItemLayout}
  355. label="雇主名称" >
  356. <span>{theData.username}</span>
  357. </FormItem>
  358. <FormItem className="half-item"
  359. {...formItemLayout}
  360. label="联系人" >
  361. <span>{this.state.contactsObj[theData.contacts]}</span>
  362. </FormItem>
  363. </div>}
  364. <div className="clearfix">
  365. <FormItem className="half-item"
  366. {...formItemLayout}
  367. label="负责人" >
  368. <span>{this.props.techBrodersObj[theData.techBrokerId]}</span>
  369. </FormItem>
  370. </div>
  371. <div className="clearfix">
  372. <FormItem className="half-item"
  373. {...formItemLayout}
  374. label="是否发布" >
  375. {(() => {
  376. switch (theData.releaseStatus) {
  377. case "0":
  378. return <span>未发布</span>;
  379. case "1":
  380. return <div>
  381. <span>已发布</span>
  382. <Button style={{ marginLeft: '10px' }} onClick={() => { this.setState({ releaseSubmitVisible: true }); }}>撤消发布</Button>
  383. <Modal maskClosable={false} title="确认"
  384. visible={this.state.releaseSubmitVisible}
  385. width='300px'
  386. footer={null}
  387. onCancel={() => { this.setState({ releaseSubmitVisible: false }) }} >
  388. <span>确认要撤销发布吗?</span>
  389. <Button className="modal-submit" type="primary" onClick={this.offShelf} >确认</Button>
  390. <Button className="modal-submit" type="ghost" onClick={() => { this.setState({ releaseSubmitVisible: false }) }}>取消</Button>
  391. </Modal>
  392. </div>;
  393. }
  394. })()}
  395. </FormItem>
  396. <FormItem className="half-item"
  397. {...formItemLayout}
  398. label="发布时间" >
  399. <span>{theData.releaseDateFormattedDate}</span>
  400. </FormItem>
  401. </div>
  402. <div className="clearfix">
  403. <FormItem className="half-item"
  404. {...formItemLayout}
  405. label="需求状态" >
  406. {(() => {
  407. switch (theData.status) {
  408. case "0":
  409. return <span>未解决</span>;
  410. case "1":
  411. return <span>已解决</span>;
  412. }
  413. })()}
  414. </FormItem>
  415. <FormItem className="half-item"
  416. {...formItemLayout}
  417. label="审核状态" >
  418. {(() => {
  419. switch (theData.auditStatus) {
  420. case "0":
  421. return <span>未提交审核(草稿)</span>;
  422. case "1":
  423. return <span>提交审核</span>;
  424. case "2":
  425. return <span>审核中</span>;
  426. case "3":
  427. return <span>审核通过</span>;
  428. case "4":
  429. return <span>审核未通过</span>;
  430. }
  431. })()}
  432. </FormItem>
  433. </div>
  434. <div className="clearfix">
  435. <FormItem className="half-item"
  436. {...formItemLayout}
  437. label="信息来源" >
  438. {(() => {
  439. switch (theData.infoSources) {
  440. case "0":
  441. return <span>平台采集</span>;
  442. case "1":
  443. return <span>客户发布</span>;
  444. case "2":
  445. return <span>批量导入</span>;
  446. case "3":
  447. return <span>三方对接</span>;
  448. }
  449. })()}
  450. </FormItem>
  451. </div>
  452. <FormItem
  453. labelCol={{ span: 3 }}
  454. wrapperCol={{ span: 20 }}
  455. label="关键词" >
  456. {this.state.tags.map((tag) => {
  457. return <Tooltip key={tag} title={tag}>
  458. <Tag key={tag}>{tag}</Tag>
  459. </Tooltip>;
  460. })}
  461. </FormItem>
  462. <FormItem
  463. labelCol={{ span: 3 }}
  464. wrapperCol={{ span: 18 }}
  465. label="行业类别" >
  466. <span>{getIndustryCategory(theData.industryCategoryA, theData.industryCategoryB)}</span>
  467. </FormItem>
  468. <div className="clearfix">
  469. <FormItem className="half-item"
  470. {...formItemLayout}
  471. label="需求类型" >
  472. <span>{getDemandType(theData.demandType)}</span>
  473. </FormItem>
  474. </div>
  475. <FormItem
  476. labelCol={{ span: 3 }}
  477. wrapperCol={{ span: 18 }}
  478. label="问题说明" >
  479. <span>{theData.problemDes}</span>
  480. </FormItem>
  481. <FormItem
  482. labelCol={{ span: 3 }}
  483. wrapperCol={{ span: 18 }}
  484. label="技术指标要求" >
  485. <span>{theData.technicalRequirements}</span>
  486. </FormItem>
  487. <FormItem
  488. labelCol={{ span: 3 }}
  489. wrapperCol={{ span: 18 }}
  490. label="需求文件(图片)" >
  491. <div className="clearfix">
  492. <Upload className="demandDetailShow-upload"
  493. listType="picture-card"
  494. fileList={this.state.pictureUrl}
  495. onPreview={(file) => {
  496. this.setState({
  497. previewImage: file.url || file.thumbUrl,
  498. previewVisible: true,
  499. });
  500. }} >
  501. </Upload>
  502. <Modal maskClosable={false} footer={null}
  503. visible={this.state.previewVisible}
  504. onCancel={() => { this.setState({ previewVisible: false }) }}>
  505. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  506. </Modal>
  507. </div>
  508. </FormItem>
  509. <FormItem
  510. labelCol={{ span: 3 }}
  511. wrapperCol={{ span: 6 }}
  512. label="需求文件(文本)" >
  513. <div>{theData.textFileUrl ?
  514. <span className="download-file">
  515. <a onClick={() => { window.open(globalConfig.context + '/api/admin/demand/download?id=' + this.props.data.id) }}>需求文件(文本文件)</a>
  516. </span>
  517. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</div>
  518. </FormItem>
  519. <FormItem
  520. labelCol={{ span: 3 }}
  521. wrapperCol={{ span: 18 }}
  522. label="需求文件(视频地址)" >
  523. <span>{theData.videoUrl}</span>
  524. </FormItem>
  525. <div className="clearfix">
  526. <FormItem className="half-item"
  527. {...formItemLayout}
  528. label="固定周期" >
  529. <span>{theData.fixedCycle}</span>
  530. </FormItem>
  531. <FormItem className="half-item"
  532. {...formItemLayout}
  533. label="固定人数" >
  534. <span>{theData.peopleNumber} 人</span>
  535. </FormItem>
  536. </div>
  537. <FormItem
  538. labelCol={{ span: 3 }}
  539. wrapperCol={{ span: 18 }}
  540. label="固定方案" >
  541. <span>{theData.fixedScheme}</span>
  542. </FormItem>
  543. <div className="clearfix">
  544. <FormItem className="half-item"
  545. {...formItemLayout}
  546. label="预算费用" >
  547. <span>{theData.budgetCost} 万元</span>
  548. </FormItem>
  549. <FormItem className="half-item"
  550. {...formItemLayout}
  551. label="费用托管" >
  552. {(() => {
  553. switch (theData.costEscrow) {
  554. case 0:
  555. return <span>否</span>;
  556. case 1:
  557. return <span>是</span>;
  558. }
  559. })()}
  560. </FormItem>
  561. <FormItem className="half-item"
  562. {...formItemLayout}
  563. label="有效期限" >
  564. <span>{theData.validityPeriodFormattedDate}</span>
  565. </FormItem>
  566. </div>
  567. {window.showAuditStatus && theData.auditStatus == 2 ? <div className="clearfix">
  568. <FormItem className="half-item"
  569. {...formItemLayout}
  570. label="审核状态" >
  571. {getFieldDecorator('auditStatus')(
  572. <Radio.Group>
  573. <Radio value={3}>审核通过</Radio>
  574. <Radio value={4}>审核未通过</Radio>
  575. </Radio.Group>
  576. )}
  577. </FormItem>
  578. <FormItem className="half-item"
  579. {...formItemLayout}
  580. label="技术经纪人" >
  581. {getFieldDecorator('techBroderId', {
  582. initialValue: theData.techBrokerId
  583. })(
  584. <Select style={{ width: 260 }}
  585. placeholder="请选择技术经纪人"
  586. notFoundContent="未获取到经纪人列表"
  587. showSearch
  588. filterOption={companySearch}>
  589. {this.props.techBrodersOption}
  590. </Select>
  591. )}
  592. </FormItem>
  593. </div> : <div></div>}
  594. <FormItem wrapperCol={{ span: 12, offset: 3 }}>
  595. {theData.auditStatus == 2 ? <Button className="set-submit" type="primary" htmlType="submit">保存</Button> : <span></span>}
  596. <Button className="set-submit" type="ghost" onClick={this.props.closeDesc}>取消</Button>
  597. {window.showAuditStatus ? <Button className="set-submit" loading={this.state.buttonLoading} type="primary" onClick={this.buildMatchList}>生成匹配列表</Button> : <span></span>}
  598. </FormItem>
  599. <Modal maskClosable={false} title="确认"
  600. visible={this.state.formSubmitVisible}
  601. width='360px'
  602. footer={null}
  603. onCancel={() => { this.setState({ formSubmitVisible: false }) }} >
  604. <span>确认该需求审核未通过?</span>
  605. <Button className="modal-submit" type="primary" onClick={this.formSubmit}>确认</Button>
  606. <Button className="modal-submit" type="ghost" onClick={() => { this.setState({ formSubmitVisible: false }) }}>取消</Button>
  607. </Modal>
  608. </Spin>
  609. </Form >
  610. )
  611. }
  612. }));
  613. const DemandDetailForm = Form.create()(React.createClass({
  614. getInitialState() {
  615. return {
  616. visible: false,
  617. loading: false,
  618. auditStatus: 0,
  619. switchValue: false,
  620. textFileList: [],
  621. videoFileList: [],
  622. contactsOption: [],
  623. data: {},
  624. tags: [],
  625. pictureUrl: [],
  626. dataSource: []
  627. };
  628. },
  629. getContactsList(theUid) {
  630. $.ajax({
  631. method: "get",
  632. dataType: "json",
  633. crossDomain: false,
  634. url: globalConfig.context + "/api/admin/getContacts",
  635. data: {
  636. uid: theUid
  637. },
  638. success: function (data) {
  639. let theOption = [];
  640. if (!data.data) {
  641. if (data.error && data.error.length) {
  642. message.warning(data.error[0].message);
  643. return;
  644. };
  645. };
  646. for (let item in data.data) {
  647. let theData = data.data[item];
  648. theOption.push(
  649. <Select.Option value={item} key={theData}>{theData}</Select.Option>
  650. );
  651. };
  652. this.setState({
  653. contactsOption: theOption
  654. });
  655. }.bind(this),
  656. });
  657. },
  658. loadData(id, detailApiUrl) {
  659. this.setState({
  660. loading: true
  661. });
  662. $.ajax({
  663. method: "get",
  664. dataType: "json",
  665. crossDomain: false,
  666. url: globalConfig.context + detailApiUrl,
  667. data: {
  668. id: id
  669. },
  670. success: function (data) {
  671. let thisData = data.data;
  672. if (!thisData) {
  673. if (data.error && data.error.length) {
  674. message.warning(data.error[0].message);
  675. };
  676. thisData = {};
  677. };
  678. if (thisData.employerId) {
  679. this.getContactsList(thisData.employerId)
  680. };
  681. this.setState({
  682. data: thisData,
  683. switchValue: Boolean(!thisData.employerId),
  684. tags: thisData.keyword ? (thisData.keyword.replace(/(,|、)/g, ",")).split(',') : [],
  685. pictureUrl: thisData.pictureUrl ? splitUrl(thisData.pictureUrl, ',', globalConfig.avatarHost + '/upload') : []
  686. });
  687. }.bind(this),
  688. }).always(function () {
  689. this.setState({
  690. loading: false
  691. });
  692. }.bind(this));
  693. },
  694. getTagsArr(e) {
  695. this.setState({ tags: e });
  696. },
  697. getPictureUrl(e) {
  698. this.setState({ pictureUrl: e });
  699. },
  700. handleSubmit(e) {
  701. e.preventDefault();
  702. this.props.form.validateFields((err, values) => {
  703. //keyword长度判断
  704. if ((this.state.tags ? this.state.tags.length : this.props.tags.length) < 3) {
  705. message.warning('关键词数量不能小于3个!');
  706. return;
  707. };
  708. //url转化
  709. let thePictureUrl = [];
  710. if (this.state.pictureUrl.length) {
  711. let picArr = [];
  712. this.state.pictureUrl.map(function (item) {
  713. picArr.push(item.response.data);
  714. });
  715. thePictureUrl = picArr.join(",");
  716. };
  717. if (!err) {
  718. this.setState({
  719. loading: true
  720. });
  721. $.ajax({
  722. method: "POST",
  723. dataType: "json",
  724. crossDomain: false,
  725. url: this.props.data.id ? globalConfig.context + '/api/admin/demand/update' : globalConfig.context + '/api/admin/demand/apply',
  726. data: {
  727. id: this.props.data.id,
  728. dataCategory: this.props.detailApiUrl.indexOf('org') >= 0 ? 1 : 0,
  729. serialNumber: this.props.data.serialNumber,
  730. name: values.name,
  731. keyword: this.state.tags ? this.state.tags.join(",") : this.props.tags.join(","),
  732. keywords: this.state.tags ? this.state.tags : this.props.tags,
  733. infoSources: 0,
  734. industryCategoryA: values.industryCategory ? values.industryCategory[0] : undefined,
  735. industryCategoryB: values.industryCategory ? values.industryCategory[1] : undefined,
  736. demandType: values.demandType,
  737. problemDes: values.problemDes,
  738. technicalRequirements: values.technicalRequirements,
  739. pictureUrl: thePictureUrl,
  740. textFileUrl: this.state.textFileUrl,
  741. videoUrl: values.videoUrl,
  742. fixedBudget: values.fixedBudget,
  743. fixedCycle: values.fixedCycle,
  744. peopleNumber: values.peopleNumber,
  745. fixedScheme: values.fixedScheme,
  746. costEscrow: values.costEscrow,
  747. budgetCost: values.budgetCost,
  748. //
  749. switchSign: this.state.switchValue ? 1 : 0,
  750. //
  751. employerId: !this.state.switchValue ? (this.state.dataSourceObj ? this.state.dataSourceObj[values.employerId] : this.props.data.employerId) : null,
  752. contacts: !this.state.switchValue ? values.contacts : null,
  753. //自定义
  754. employerName: this.state.switchValue ? values.employerName : null,
  755. employerAddress: this.state.switchValue ? values.employerAddress : null,
  756. employerContactsMobile: this.state.switchValue ? values.employerContactsMobile : null,
  757. employerContactsMailbox: this.state.switchValue ? values.employerContactsMailbox : null,
  758. //
  759. releaseStatus: values.releaseStatus,
  760. principalId: values.principalId,
  761. validityPeriodFormattedDate: values.validityPeriod ? values.validityPeriod.format('YYYY-MM-DD') : undefined,
  762. //
  763. status: this.state.status,
  764. auditStatus: this.state.auditStatus
  765. }
  766. }).done(function (data) {
  767. this.state.auditStatus = 0;
  768. if (!data.error.length) {
  769. message.success('保存成功!');
  770. this.props.handleOk();
  771. } else {
  772. message.warning(data.error[0].message);
  773. };
  774. this.setState({
  775. loading: false
  776. });
  777. }.bind(this));
  778. }
  779. });
  780. },
  781. handleSearch(e) {
  782. if (this.props.detailApiUrl.indexOf('org') != -1) {
  783. $.ajax({
  784. method: "get",
  785. dataType: "json",
  786. crossDomain: false,
  787. url: globalConfig.context + "/api/admin/achievement/orgOwner",
  788. data: { name: e },
  789. success: function (data) {
  790. let theArr = [];
  791. let theObj = {};
  792. if (!data.data) {
  793. if (data.error && data.error.length) {
  794. message.warning(data.error[0].message);
  795. };
  796. } else if (!$.isEmptyObject(data.data)) {
  797. data.data.map(function (item) {
  798. theArr.push(item.unitName);
  799. theObj[item.unitName] = item.uid;
  800. });
  801. };
  802. this.setState({
  803. dataSource: theArr,
  804. dataSourceObj: theObj
  805. });
  806. }.bind(this),
  807. });
  808. } else {
  809. $.ajax({
  810. method: "get",
  811. dataType: "json",
  812. crossDomain: false,
  813. url: globalConfig.context + "/api/admin/achievement/userOwner",
  814. data: { name: e },
  815. success: function (data) {
  816. let theArr = [];
  817. let theObj = {};
  818. if (!data.data) {
  819. if (data.error && data.error.length) {
  820. message.warning(data.error[0].message);
  821. };
  822. } else if (!$.isEmptyObject(data.data)) {
  823. for (let item in data.data) {
  824. theArr.push(data.data[item]);
  825. theObj[data.data[item]] = item;
  826. };
  827. };
  828. this.setState({
  829. dataSource: theArr,
  830. dataSourceObj: theObj
  831. });
  832. }.bind(this),
  833. });
  834. };
  835. },
  836. componentWillMount() {
  837. this.state.therottleSearch = throttle(this.handleSearch, 1000, { leading: false }).bind(this);
  838. if (this.props.data && this.props.data.id) {
  839. this.loadData(this.props.data.id, this.props.detailApiUrl);
  840. };
  841. },
  842. componentWillReceiveProps(nextProps) {
  843. if (!this.props.visible && nextProps.visible) {
  844. if (nextProps.data && nextProps.data.id) {
  845. this.loadData(nextProps.data.id, nextProps.detailApiUrl);
  846. };
  847. this.state.contactsOption = [];
  848. this.state.data = {};
  849. this.state.tags = [];
  850. this.state.switchValue = false;
  851. this.state.pictureUrl = [];
  852. this.state.textFileList = [];
  853. this.state.videoFileList = [];
  854. this.state.textFileUrl = undefined;
  855. this.props.form.resetFields();
  856. };
  857. },
  858. render() {
  859. const theData = this.state.data || {};
  860. const { getFieldDecorator } = this.props.form;
  861. const FormItem = Form.Item
  862. const formItemLayout = {
  863. labelCol: { span: 6 },
  864. wrapperCol: { span: 12 },
  865. };
  866. return (
  867. <Form horizontal onSubmit={this.handleSubmit} id="demand-form">
  868. <Spin spinning={this.state.loading}>
  869. <div className="clearfix">
  870. <FormItem className="half-item"
  871. {...formItemLayout}
  872. label="编号" >
  873. <span>{theData.serialNumber}</span>
  874. </FormItem>
  875. <FormItem className="half-item"
  876. {...formItemLayout}
  877. label="需求名称" >
  878. {getFieldDecorator('name', {
  879. rules: [{ required: true, message: '此项为必填项!' }],
  880. initialValue: theData.name
  881. })(
  882. <Input />
  883. )}
  884. </FormItem>
  885. </div>
  886. <FormItem style={{ marginBottom: '10px' }} labelCol={{ span: 3 }}
  887. label="自定义雇主" >
  888. <Switch checked={this.state.switchValue} onChange={(e) => { this.setState({ switchValue: e }); }} />
  889. </FormItem>
  890. {this.state.switchValue ? <div className="clearfix" >
  891. <FormItem className="half-item"
  892. {...formItemLayout}
  893. label="雇主名称" >
  894. {getFieldDecorator('employerName', {
  895. initialValue: theData.employerName
  896. })(
  897. <Input />
  898. )}
  899. </FormItem>
  900. <FormItem className="half-item"
  901. {...formItemLayout}
  902. label="联系电话" >
  903. {getFieldDecorator('employerContactsMobile', {
  904. initialValue: theData.employerContactsMobile
  905. })(
  906. <Input />
  907. )}
  908. </FormItem>
  909. <FormItem className="half-item"
  910. {...formItemLayout}
  911. label="电子邮箱" >
  912. {getFieldDecorator('employerContactsMailbox', {
  913. initialValue: theData.employerContactsMailbox
  914. })(
  915. <Input />
  916. )}
  917. </FormItem>
  918. <FormItem className="half-item"
  919. {...formItemLayout}
  920. label="通讯地址" >
  921. {getFieldDecorator('employerAddress', {
  922. initialValue: theData.employerAddress
  923. })(
  924. <Input />
  925. )}
  926. </FormItem>
  927. </div> : <div className="clearfix">
  928. <FormItem className="half-item"
  929. {...formItemLayout}
  930. label="雇主名称" >
  931. {getFieldDecorator('employerId', {
  932. initialValue: theData.username || ''
  933. })(
  934. <AutoComplete
  935. dataSource={this.state.dataSource}
  936. style={{ width: 200 }}
  937. onSearch={this.state.therottleSearch}
  938. placeholder="雇主名称"
  939. onSelect={(e) => {
  940. this.getContactsList(this.state.dataSourceObj[e]);
  941. }} />
  942. )}
  943. </FormItem>
  944. {this.props.detailApiUrl.indexOf('org') >= 0 ? <FormItem className="half-item"
  945. {...formItemLayout}
  946. label="联系人" >
  947. {getFieldDecorator('contacts', {
  948. initialValue: theData.contacts
  949. })(
  950. <Select style={{ width: 260 }}
  951. placeholder="请选择联系人"
  952. notFoundContent="未获取到联系人列表"
  953. showSearch
  954. filterOption={companySearch}>
  955. {this.state.contactsOption}
  956. </Select>
  957. )}
  958. </FormItem> : <div></div>}
  959. </div>}
  960. <div className="clearfix">
  961. {theData.techBrokerId ? <FormItem className="half-item"
  962. {...formItemLayout}
  963. label="负责人" >
  964. <span>{this.props.techBrodersObj[theData.techBrokerId]}</span>
  965. </FormItem> : <div></div>}
  966. </div>
  967. {theData.releaseStatus ? <div className="clearfix">
  968. <FormItem className="half-item"
  969. {...formItemLayout}
  970. label="是否发布" >
  971. {(() => {
  972. switch (theData.releaseStatus) {
  973. case "0":
  974. return <span>未发布</span>;
  975. case "1":
  976. return <span>已发布</span>;
  977. }
  978. })()}
  979. </FormItem>
  980. <FormItem className="half-item"
  981. {...formItemLayout}
  982. label="发布时间" >
  983. <span>{theData.releaseDateFormattedDate}</span>
  984. </FormItem>
  985. </div> : <div></div>}
  986. <div className="clearfix">
  987. {theData.releaseStatus == "1" ? <FormItem className="half-item"
  988. {...formItemLayout}
  989. label="需求状态" >
  990. {getFieldDecorator('status', {
  991. initialValue: theData.status
  992. })(
  993. <Radio.Group>
  994. <Radio value="0">未解决</Radio>
  995. <Radio value="1">已解决</Radio>
  996. </Radio.Group>
  997. )}
  998. </FormItem> : <div></div>}
  999. <FormItem className="half-item"
  1000. {...formItemLayout}
  1001. label="审核状态" >
  1002. <span>{getTechAuditStatus(theData.auditStatus)}</span>
  1003. </FormItem>
  1004. </div>
  1005. <FormItem
  1006. labelCol={{ span: 3 }}
  1007. wrapperCol={{ span: 20 }}
  1008. label="关键词" >
  1009. <KeyWordTagGroup
  1010. keyWordArr={this.state.tags}
  1011. tagsArr={this.getTagsArr}
  1012. visible={this.props.visible} />
  1013. </FormItem>
  1014. <FormItem
  1015. labelCol={{ span: 3 }}
  1016. wrapperCol={{ span: 18 }}
  1017. label="行业类别" >
  1018. {getFieldDecorator('industryCategory', {
  1019. rules: [{ type: 'array', required: true, message: '此项为必填项!' }],
  1020. initialValue: [theData.industryCategoryA, theData.industryCategoryB]
  1021. })(
  1022. <Cascader style={{ width: 300 }} options={IndustryObject} placeholder="请选择一个行业" />
  1023. )}
  1024. </FormItem>
  1025. <div className="clearfix">
  1026. <FormItem className="half-item"
  1027. {...formItemLayout}
  1028. label="需求类型" >
  1029. {getFieldDecorator('demandType', {
  1030. rules: [{ required: true, message: '此项为必填项!' }],
  1031. initialValue: theData.demandType
  1032. })(
  1033. <Select style={{ width: 160 }} placeholder="请选择需求类型">
  1034. {this.props.demandTypeOption}
  1035. </Select>
  1036. )}
  1037. </FormItem>
  1038. </div>
  1039. <FormItem
  1040. labelCol={{ span: 3 }}
  1041. wrapperCol={{ span: 18 }}
  1042. label="问题说明" >
  1043. {getFieldDecorator('problemDes', {
  1044. rules: [{ required: true, message: '此项为必填项!' }],
  1045. initialValue: theData.problemDes
  1046. })(
  1047. <Input type="textarea" rows={4} />
  1048. )}
  1049. </FormItem>
  1050. <FormItem
  1051. labelCol={{ span: 3 }}
  1052. wrapperCol={{ span: 18 }}
  1053. label="技术指标要求" >
  1054. {getFieldDecorator('technicalRequirements', {
  1055. initialValue: theData.technicalRequirements
  1056. })(
  1057. <Input type="textarea" rows={2} />
  1058. )}
  1059. </FormItem>
  1060. <FormItem
  1061. labelCol={{ span: 3 }}
  1062. wrapperCol={{ span: 18 }}
  1063. label="需求文件(图片)" >
  1064. <PicturesWall
  1065. uid={theData.employerId}
  1066. fileList={this.getPictureUrl}
  1067. pictureUrl={this.state.pictureUrl}
  1068. visible={this.props.visible} />
  1069. </FormItem>
  1070. <FormItem
  1071. labelCol={{ span: 3 }}
  1072. wrapperCol={{ span: 6 }}
  1073. label="需求文件(文本)" >
  1074. <Upload
  1075. name="ratepay"
  1076. action={globalConfig.context + "/api/admin/demand/uploadTextFile"}
  1077. data={{ 'sign': 'demand_text_file', 'uid': theData.employerId }}
  1078. beforeUpload={beforeUploadFile}
  1079. fileList={this.state.textFileList}
  1080. onChange={(info) => {
  1081. if (info.file.status !== 'uploading') {
  1082. console.log(info.file, info.fileList);
  1083. }
  1084. if (info.file.status === 'done') {
  1085. if (!info.file.response.error.length) {
  1086. message.success(`${info.file.name} 文件上传成功!`);
  1087. } else {
  1088. message.warning(info.file.response.error[0].message);
  1089. return;
  1090. };
  1091. this.state.textFileUrl = info.file.response.data;
  1092. } else if (info.file.status === 'error') {
  1093. message.error(`${info.file.name} 文件上传失败。`);
  1094. };
  1095. this.setState({ textFileList: info.fileList.slice(-1) });
  1096. }} >
  1097. <Button><Icon type="upload" /> 上传需求文本文件 </Button>
  1098. </Upload>
  1099. <p style={{ marginTop: '10px' }}>{theData.textFileUrl ?
  1100. <span className="download-file">
  1101. <a onClick={() => { window.open(globalConfig.context + '/api/admin/demand/download?id=' + this.props.data.id) }}>需求文件(文本文件)</a>
  1102. </span>
  1103. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  1104. </FormItem>
  1105. <FormItem
  1106. labelCol={{ span: 3 }}
  1107. wrapperCol={{ span: 18 }}
  1108. label="需求文件(视频地址)" >
  1109. {getFieldDecorator('videoUrl', {
  1110. initialValue: theData.videoUrl
  1111. })(
  1112. <Input />
  1113. )}
  1114. </FormItem>
  1115. <div className="clearfix">
  1116. <FormItem className="half-item"
  1117. {...formItemLayout}
  1118. label="固定周期" >
  1119. {getFieldDecorator('fixedCycle', {
  1120. initialValue: theData.fixedCycle
  1121. })(
  1122. <Input />
  1123. )}
  1124. </FormItem>
  1125. <FormItem className="half-item"
  1126. {...formItemLayout}
  1127. label="固定人数" >
  1128. {getFieldDecorator('peopleNumber', {
  1129. initialValue: theData.peopleNumber || 0
  1130. })(
  1131. <InputNumber />
  1132. )}
  1133. <span style={{ marginLeft: '20px' }}>人</span>
  1134. </FormItem>
  1135. </div>
  1136. <FormItem
  1137. labelCol={{ span: 3 }}
  1138. wrapperCol={{ span: 18 }}
  1139. label="固定方案" >
  1140. {getFieldDecorator('fixedScheme', {
  1141. initialValue: theData.fixedScheme
  1142. })(
  1143. <Input type="textarea" rows={2} />
  1144. )}
  1145. </FormItem>
  1146. <div className="clearfix">
  1147. <FormItem className="half-item"
  1148. {...formItemLayout}
  1149. label="预算费用" >
  1150. {getFieldDecorator('budgetCost', {
  1151. initialValue: theData.budgetCost || 0
  1152. })(
  1153. <InputNumber min={0} max={999999} step={0.01} />
  1154. )}
  1155. <span style={{ marginLeft: '20px' }}>万元</span>
  1156. </FormItem>
  1157. <FormItem className="half-item"
  1158. {...formItemLayout}
  1159. label="费用托管" >
  1160. {getFieldDecorator('costEscrow', {
  1161. initialValue: theData.costEscrow
  1162. })(
  1163. <Radio.Group>
  1164. <Radio value={0}>否</Radio>
  1165. <Radio value={1}>是</Radio>
  1166. </Radio.Group>
  1167. )}
  1168. </FormItem>
  1169. <FormItem className="half-item"
  1170. {...formItemLayout}
  1171. label="有效期限" >
  1172. {getFieldDecorator('validityPeriod', {
  1173. initialValue: theData.validityPeriod ? moment(theData.validityPeriod) : null
  1174. })(
  1175. <DatePicker />
  1176. )}
  1177. </FormItem>
  1178. </div>
  1179. <div className="clearfix" style={{ display: 'none' }}>
  1180. <FormItem className="half-item"
  1181. {...formItemLayout}
  1182. label="雇主地址" >
  1183. <span>{theData.employerAddress}</span>
  1184. </FormItem>
  1185. <FormItem className="half-item"
  1186. {...formItemLayout}
  1187. label="雇主联系人名称" >
  1188. <span>{theData.employerContacts}</span>
  1189. </FormItem>
  1190. <FormItem className="half-item"
  1191. {...formItemLayout}
  1192. label="雇主联系人电话" >
  1193. <span>{theData.employerContactsMobile}</span>
  1194. </FormItem>
  1195. <FormItem className="half-item"
  1196. {...formItemLayout}
  1197. label="雇主联系人邮箱" >
  1198. <span>{theData.employerContactsMailbox}</span>
  1199. </FormItem>
  1200. </div>
  1201. <FormItem wrapperCol={{ span: 12, offset: 3 }}>
  1202. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  1203. <Button className="set-submit" type="ghost" onClick={(e) => { this.state.auditStatus = 1; }} htmlType="submit">发布</Button>
  1204. <Button className="set-submit" type="ghost" onClick={this.props.closeDesc}>取消</Button>
  1205. </FormItem>
  1206. </Spin>
  1207. </Form >
  1208. )
  1209. }
  1210. }));
  1211. const DemandDetail = React.createClass({
  1212. getInitialState() {
  1213. return {
  1214. visible: false,
  1215. techBrodersObj: {},
  1216. tabsKey: "1",
  1217. columns: [
  1218. {
  1219. title: '编号',
  1220. dataIndex: 'serialNumber',
  1221. key: 'serialNumber',
  1222. }, {
  1223. title: '数据类型',
  1224. dataIndex: 'dataCategory',
  1225. key: 'dataCategory',
  1226. render: text => {
  1227. switch (text) {
  1228. case "0":
  1229. return <span>个人需求</span>;
  1230. case "1":
  1231. return <span>团体需求</span>;
  1232. }
  1233. }
  1234. }, {
  1235. title: '名称',
  1236. dataIndex: 'name',
  1237. key: 'name',
  1238. }, {
  1239. title: '关键字',
  1240. dataIndex: 'keyword',
  1241. key: 'keyword',
  1242. }, {
  1243. title: '类型',
  1244. dataIndex: 'category',
  1245. key: 'category',
  1246. render: text => { return getAchievementCategory(text); }
  1247. }, {
  1248. title: '所有人名称',
  1249. dataIndex: 'theName',
  1250. key: 'theName',
  1251. }, {
  1252. title: '所有人类型',
  1253. dataIndex: 'ownerType',
  1254. key: 'ownerType',
  1255. render: text => {
  1256. switch (text) {
  1257. case "0":
  1258. return <span>个人</span>;
  1259. case "1":
  1260. return <span>组织</span>
  1261. }
  1262. }
  1263. }, {
  1264. title: '发布时间',
  1265. dataIndex: 'releaseDateFormattedDate',
  1266. key: 'releaseDateFormattedDate',
  1267. }
  1268. ],
  1269. dataSource: [],
  1270. };
  1271. },
  1272. getTechBrodersList() {
  1273. this.setState({
  1274. loading: true
  1275. });
  1276. $.ajax({
  1277. method: "get",
  1278. dataType: "json",
  1279. crossDomain: false,
  1280. url: globalConfig.context + "/api/admin/audit/techBroders",
  1281. success: function (data) {
  1282. if (!data.data) {
  1283. if (data.error && data.error.length) {
  1284. message.warning(data.error[0].message);
  1285. }
  1286. return;
  1287. };
  1288. let _me = this, theArr = [];
  1289. for (var item in data.data) {
  1290. theArr.push(
  1291. <Select.Option key={item}>{data.data[item]}</Select.Option>
  1292. )
  1293. };
  1294. this.setState({
  1295. techBrodersOption: theArr,
  1296. techBrodersObj: data.data
  1297. });
  1298. }.bind(this),
  1299. }).always(function () {
  1300. this.setState({
  1301. loading: false
  1302. });
  1303. }.bind(this));
  1304. },
  1305. getTableList() {
  1306. this.setState({
  1307. loading: true
  1308. });
  1309. $.ajax({
  1310. method: "get",
  1311. dataType: "json",
  1312. crossDomain: false,
  1313. url: globalConfig.context + "/api/admin/demand/achievementDemand",
  1314. data: { id: this.props.data.id },
  1315. success: function (data) {
  1316. let theArr = [];
  1317. if (!data.data) {
  1318. if (data.error && data.error.length) {
  1319. message.warning(data.error[0].message);
  1320. };
  1321. } else if (data.data.length) {
  1322. for (let i = 0; i < data.data.length; i++) {
  1323. let thisdata = data.data[i];
  1324. theArr.push({
  1325. key: i,
  1326. id: thisdata.id,
  1327. serialNumber: thisdata.serialNumber,
  1328. dataCategory: thisdata.dataCategory,
  1329. name: thisdata.name,
  1330. keyword: thisdata.keyword,
  1331. category: thisdata.category,
  1332. ownerType: thisdata.ownerType,
  1333. theName: thisdata.username || thisdata.unitName,
  1334. releaseDate: thisdata.releaseDate,
  1335. releaseDateFormattedDate: thisdata.releaseDateFormattedDate
  1336. });
  1337. };
  1338. };
  1339. this.setState({
  1340. dataSource: theArr,
  1341. });
  1342. }.bind(this),
  1343. }).always(function () {
  1344. this.setState({
  1345. loading: false
  1346. });
  1347. }.bind(this));
  1348. },
  1349. tableRowClick(record, index) {
  1350. window.open(globalConfig.context + '/portal/detail/achievementDetail.html?id=' + record.id + '&type=' + record.ownerType);
  1351. },
  1352. handleCancel(e) {
  1353. this.setState({
  1354. visible: false,
  1355. });
  1356. this.props.closeDesc(false);
  1357. },
  1358. handleOk(e) {
  1359. this.setState({
  1360. visible: false,
  1361. });
  1362. this.props.closeDesc(false, true);
  1363. },
  1364. componentWillMount() {
  1365. this.getTechBrodersList();
  1366. },
  1367. componentWillReceiveProps(nextProps) {
  1368. if (!this.state.visible && nextProps.showDesc) {
  1369. this.state.tabsKey = "1";
  1370. };
  1371. this.state.visible = nextProps.showDesc;
  1372. },
  1373. render() {
  1374. if (this.props.data) {
  1375. return (
  1376. <div className="patent-desc">
  1377. <Modal maskClosable={false} visible={this.state.visible}
  1378. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  1379. width='1000px'
  1380. footer=''
  1381. className="admin-desc-content">
  1382. <Spin spinning={this.state.loading}>
  1383. <Tabs activeKey={this.state.tabsKey}
  1384. onChange={(e) => {
  1385. this.setState({ tabsKey: e });
  1386. if (e == "2") {
  1387. this.getTableList();
  1388. };
  1389. }} >
  1390. <Tabs.TabPane tab="需求详情" key="1">
  1391. {(() => {
  1392. if (this.props.data.id && this.props.data.auditStatus != "0" && this.props.data.auditStatus != "4") {
  1393. return <DemandDetailShow
  1394. data={this.props.data}
  1395. detailApiUrl={this.props.detailApiUrl}
  1396. techBrodersOption={this.state.techBrodersOption}
  1397. techBrodersObj={this.state.techBrodersObj}
  1398. demandTypeOption={this.props.demandTypeOption}
  1399. closeDesc={this.handleCancel}
  1400. visible={this.state.visible}
  1401. handleOk={this.handleOk} />
  1402. } else {
  1403. return <DemandDetailForm
  1404. data={this.props.data}
  1405. detailApiUrl={this.props.detailApiUrl}
  1406. companyOption={this.props.companyOption}
  1407. userOption={this.props.userOption}
  1408. techBrodersObj={this.state.techBrodersObj}
  1409. demandTypeOption={this.props.demandTypeOption}
  1410. closeDesc={this.handleCancel}
  1411. visible={this.state.visible}
  1412. handleOk={this.handleOk} />
  1413. }
  1414. })()}
  1415. </Tabs.TabPane>
  1416. <Tabs.TabPane tab="匹配列表" key="2" disabled={!this.props.data.id}>
  1417. <Table columns={this.state.columns}
  1418. dataSource={this.state.dataSource}
  1419. pagination={false}
  1420. onRowClick={this.tableRowClick} />
  1421. </Tabs.TabPane>
  1422. </Tabs>
  1423. </Spin>
  1424. </Modal>
  1425. </div>
  1426. );
  1427. } else {
  1428. return <div></div>
  1429. }
  1430. },
  1431. });
  1432. export default DemandDetail;