techDemandDesc.jsx 63 KB

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