techDemandDesc.jsx 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434
  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.techBroderId
  583. })(
  584. <Select style={{ width: 260 }}>
  585. {this.props.techBrodersOption}
  586. </Select>
  587. )}
  588. </FormItem>
  589. </div> : <div></div>}
  590. <FormItem wrapperCol={{ span: 12, offset: 3 }}>
  591. {theData.auditStatus == 2 ? <Button className="set-submit" type="primary" htmlType="submit">保存</Button> : <span></span>}
  592. <Button className="set-submit" type="ghost" onClick={this.props.closeDesc}>取消</Button>
  593. {window.showAuditStatus ? <Button className="set-submit" loading={this.state.buttonLoading} type="primary" onClick={this.buildMatchList}>生成匹配列表</Button> : <span></span>}
  594. </FormItem>
  595. <Modal maskClosable={false} title="确认"
  596. visible={this.state.formSubmitVisible}
  597. width='360px'
  598. footer={null}
  599. onCancel={() => { this.setState({ formSubmitVisible: false }) }} >
  600. <span>确认该需求审核未通过?</span>
  601. <Button className="modal-submit" type="primary" onClick={this.formSubmit}>确认</Button>
  602. <Button className="modal-submit" type="ghost" onClick={() => { this.setState({ formSubmitVisible: false }) }}>取消</Button>
  603. </Modal>
  604. </Spin>
  605. </Form >
  606. )
  607. }
  608. }));
  609. const DemandDetailForm = Form.create()(React.createClass({
  610. getInitialState() {
  611. return {
  612. visible: false,
  613. loading: false,
  614. auditStatus: 0,
  615. switchValue: false,
  616. textFileList: [],
  617. videoFileList: [],
  618. contactsOption: [],
  619. data: {},
  620. tags: [],
  621. pictureUrl: [],
  622. dataSource: []
  623. };
  624. },
  625. getContactsList(theUid) {
  626. $.ajax({
  627. method: "get",
  628. dataType: "json",
  629. crossDomain: false,
  630. url: globalConfig.context + "/api/admin/getContacts",
  631. data: {
  632. uid: theUid
  633. },
  634. success: function (data) {
  635. let theOption = [];
  636. if (!data.data) {
  637. if (data.error && data.error.length) {
  638. message.warning(data.error[0].message);
  639. return;
  640. };
  641. };
  642. for (let item in data.data) {
  643. let theData = data.data[item];
  644. theOption.push(
  645. <Select.Option value={item} key={theData}>{theData}</Select.Option>
  646. );
  647. };
  648. this.setState({
  649. contactsOption: theOption
  650. });
  651. }.bind(this),
  652. });
  653. },
  654. loadData(id, detailApiUrl) {
  655. this.setState({
  656. loading: true
  657. });
  658. $.ajax({
  659. method: "get",
  660. dataType: "json",
  661. crossDomain: false,
  662. url: globalConfig.context + detailApiUrl,
  663. data: {
  664. id: id
  665. },
  666. success: function (data) {
  667. let thisData = data.data;
  668. if (!thisData) {
  669. if (data.error && data.error.length) {
  670. message.warning(data.error[0].message);
  671. };
  672. thisData = {};
  673. };
  674. if (thisData.employerId) {
  675. this.getContactsList(thisData.employerId)
  676. };
  677. this.setState({
  678. data: thisData,
  679. switchValue: Boolean(!thisData.employerId),
  680. tags: thisData.keyword ? (thisData.keyword.replace(/(,|、)/g, ",")).split(',') : [],
  681. pictureUrl: thisData.pictureUrl ? splitUrl(thisData.pictureUrl, ',', globalConfig.avatarHost + '/upload') : []
  682. });
  683. }.bind(this),
  684. }).always(function () {
  685. this.setState({
  686. loading: false
  687. });
  688. }.bind(this));
  689. },
  690. getTagsArr(e) {
  691. this.setState({ tags: e });
  692. },
  693. getPictureUrl(e) {
  694. this.setState({ pictureUrl: e });
  695. },
  696. handleSubmit(e) {
  697. e.preventDefault();
  698. this.props.form.validateFields((err, values) => {
  699. //keyword长度判断
  700. if ((this.state.tags ? this.state.tags.length : this.props.tags.length) < 3) {
  701. message.warning('关键词数量不能小于3个!');
  702. return;
  703. };
  704. //url转化
  705. let thePictureUrl = [];
  706. if (this.state.pictureUrl.length) {
  707. let picArr = [];
  708. this.state.pictureUrl.map(function (item) {
  709. picArr.push(item.response.data);
  710. });
  711. thePictureUrl = picArr.join(",");
  712. };
  713. if (!err) {
  714. this.setState({
  715. loading: true
  716. });
  717. $.ajax({
  718. method: "POST",
  719. dataType: "json",
  720. crossDomain: false,
  721. url: this.props.data.id ? globalConfig.context + '/api/admin/demand/update' : globalConfig.context + '/api/admin/demand/apply',
  722. data: {
  723. id: this.props.data.id,
  724. dataCategory: this.props.detailApiUrl.indexOf('org') >= 0 ? 1 : 0,
  725. serialNumber: this.props.data.serialNumber,
  726. name: values.name,
  727. keyword: this.state.tags ? this.state.tags.join(",") : this.props.tags.join(","),
  728. keywords: this.state.tags ? this.state.tags : this.props.tags,
  729. infoSources: 0,
  730. industryCategoryA: values.industryCategory ? values.industryCategory[0] : undefined,
  731. industryCategoryB: values.industryCategory ? values.industryCategory[1] : undefined,
  732. demandType: values.demandType,
  733. problemDes: values.problemDes,
  734. technicalRequirements: values.technicalRequirements,
  735. pictureUrl: thePictureUrl,
  736. textFileUrl: this.state.textFileUrl,
  737. videoUrl: values.videoUrl,
  738. fixedBudget: values.fixedBudget,
  739. fixedCycle: values.fixedCycle,
  740. peopleNumber: values.peopleNumber,
  741. fixedScheme: values.fixedScheme,
  742. costEscrow: values.costEscrow,
  743. budgetCost: values.budgetCost,
  744. //
  745. switchSign: this.state.switchValue ? 1 : 0,
  746. //
  747. employerId: !this.state.switchValue ? (this.state.dataSourceObj ? this.state.dataSourceObj[values.employerId] : this.props.data.employerId) : null,
  748. contacts: !this.state.switchValue ? values.contacts : null,
  749. //自定义
  750. employerName: this.state.switchValue ? values.employerName : null,
  751. employerAddress: this.state.switchValue ? values.employerAddress : null,
  752. employerContactsMobile: this.state.switchValue ? values.employerContactsMobile : null,
  753. employerContactsMailbox: this.state.switchValue ? values.employerContactsMailbox : null,
  754. //
  755. releaseStatus: values.releaseStatus,
  756. principalId: values.principalId,
  757. validityPeriodFormattedDate: values.validityPeriod ? values.validityPeriod.format('YYYY-MM-DD') : undefined,
  758. //
  759. status: this.state.status,
  760. auditStatus: this.state.auditStatus
  761. }
  762. }).done(function (data) {
  763. this.state.auditStatus = 0;
  764. if (!data.error.length) {
  765. message.success('保存成功!');
  766. this.props.handleOk();
  767. } else {
  768. message.warning(data.error[0].message);
  769. };
  770. this.setState({
  771. loading: false
  772. });
  773. }.bind(this));
  774. }
  775. });
  776. },
  777. handleSearch(e) {
  778. if (this.props.detailApiUrl.indexOf('org') != -1) {
  779. $.ajax({
  780. method: "get",
  781. dataType: "json",
  782. crossDomain: false,
  783. url: globalConfig.context + "/api/admin/achievement/orgOwner",
  784. data: { name: e },
  785. success: function (data) {
  786. let theArr = [];
  787. let theObj = {};
  788. if (!data.data) {
  789. if (data.error && data.error.length) {
  790. message.warning(data.error[0].message);
  791. };
  792. } else if (!$.isEmptyObject(data.data)) {
  793. data.data.map(function (item) {
  794. theArr.push(item.unitName);
  795. theObj[item.unitName] = item.uid;
  796. });
  797. };
  798. this.setState({
  799. dataSource: theArr,
  800. dataSourceObj: theObj
  801. });
  802. }.bind(this),
  803. });
  804. } else {
  805. $.ajax({
  806. method: "get",
  807. dataType: "json",
  808. crossDomain: false,
  809. url: globalConfig.context + "/api/admin/achievement/userOwner",
  810. data: { name: e },
  811. success: function (data) {
  812. let theArr = [];
  813. let theObj = {};
  814. if (!data.data) {
  815. if (data.error && data.error.length) {
  816. message.warning(data.error[0].message);
  817. };
  818. } else if (!$.isEmptyObject(data.data)) {
  819. for (let item in data.data) {
  820. theArr.push(data.data[item]);
  821. theObj[data.data[item]] = item;
  822. };
  823. };
  824. this.setState({
  825. dataSource: theArr,
  826. dataSourceObj: theObj
  827. });
  828. }.bind(this),
  829. });
  830. };
  831. },
  832. componentWillMount() {
  833. this.state.therottleSearch = throttle(this.handleSearch, 1000, { leading: false }).bind(this);
  834. if (this.props.data && this.props.data.id) {
  835. this.loadData(this.props.data.id, this.props.detailApiUrl);
  836. };
  837. },
  838. componentWillReceiveProps(nextProps) {
  839. if (!this.props.visible && nextProps.visible) {
  840. if (nextProps.data && nextProps.data.id) {
  841. this.loadData(nextProps.data.id, nextProps.detailApiUrl);
  842. };
  843. this.state.contactsOption = [];
  844. this.state.data = {};
  845. this.state.tags = [];
  846. this.state.switchValue = false;
  847. this.state.pictureUrl = [];
  848. this.state.textFileList = [];
  849. this.state.videoFileList = [];
  850. this.state.textFileUrl = undefined;
  851. this.props.form.resetFields();
  852. };
  853. },
  854. render() {
  855. const theData = this.state.data || {};
  856. const { getFieldDecorator } = this.props.form;
  857. const FormItem = Form.Item
  858. const formItemLayout = {
  859. labelCol: { span: 6 },
  860. wrapperCol: { span: 12 },
  861. };
  862. return (
  863. <Form horizontal onSubmit={this.handleSubmit} id="demand-form">
  864. <Spin spinning={this.state.loading}>
  865. <div className="clearfix">
  866. <FormItem className="half-item"
  867. {...formItemLayout}
  868. label="编号" >
  869. <span>{theData.serialNumber}</span>
  870. </FormItem>
  871. <FormItem className="half-item"
  872. {...formItemLayout}
  873. label="需求名称" >
  874. {getFieldDecorator('name', {
  875. rules: [{ required: true, message: '此项为必填项!' }],
  876. initialValue: theData.name
  877. })(
  878. <Input />
  879. )}
  880. </FormItem>
  881. </div>
  882. <FormItem style={{ marginBottom: '10px' }} labelCol={{ span: 3 }}
  883. label="自定义雇主" >
  884. <Switch checked={this.state.switchValue} onChange={(e) => { this.setState({ switchValue: e }); }} />
  885. </FormItem>
  886. {this.state.switchValue ? <div className="clearfix" >
  887. <FormItem className="half-item"
  888. {...formItemLayout}
  889. label="雇主名称" >
  890. {getFieldDecorator('employerName', {
  891. initialValue: theData.employerName
  892. })(
  893. <Input />
  894. )}
  895. </FormItem>
  896. <FormItem className="half-item"
  897. {...formItemLayout}
  898. label="联系电话" >
  899. {getFieldDecorator('employerContactsMobile', {
  900. initialValue: theData.employerContactsMobile
  901. })(
  902. <Input />
  903. )}
  904. </FormItem>
  905. <FormItem className="half-item"
  906. {...formItemLayout}
  907. label="电子邮箱" >
  908. {getFieldDecorator('employerContactsMailbox', {
  909. initialValue: theData.employerContactsMailbox
  910. })(
  911. <Input />
  912. )}
  913. </FormItem>
  914. <FormItem className="half-item"
  915. {...formItemLayout}
  916. label="通讯地址" >
  917. {getFieldDecorator('employerAddress', {
  918. initialValue: theData.employerAddress
  919. })(
  920. <Input />
  921. )}
  922. </FormItem>
  923. </div> : <div className="clearfix">
  924. <FormItem className="half-item"
  925. {...formItemLayout}
  926. label="雇主名称" >
  927. {getFieldDecorator('employerId', {
  928. initialValue: theData.username || ''
  929. })(
  930. <AutoComplete
  931. dataSource={this.state.dataSource}
  932. style={{ width: 200 }}
  933. onSearch={this.state.therottleSearch}
  934. placeholder="雇主名称"
  935. onSelect={(e) => {
  936. this.getContactsList(this.state.dataSourceObj[e]);
  937. }} />
  938. )}
  939. </FormItem>
  940. {this.props.detailApiUrl.indexOf('org') >= 0 ? <FormItem className="half-item"
  941. {...formItemLayout}
  942. label="联系人" >
  943. {getFieldDecorator('contacts', {
  944. initialValue: theData.contacts
  945. })(
  946. <Select style={{ width: 260 }}
  947. placeholder="请选择联系人"
  948. notFoundContent="未获取到联系人列表"
  949. showSearch
  950. filterOption={companySearch}>
  951. {this.state.contactsOption}
  952. </Select>
  953. )}
  954. </FormItem> : <div></div>}
  955. </div>}
  956. <div className="clearfix">
  957. {theData.techBrokerId ? <FormItem className="half-item"
  958. {...formItemLayout}
  959. label="负责人" >
  960. <span>{this.props.techBrodersObj[theData.techBrokerId]}</span>
  961. </FormItem> : <div></div>}
  962. </div>
  963. {theData.releaseStatus ? <div className="clearfix">
  964. <FormItem className="half-item"
  965. {...formItemLayout}
  966. label="是否发布" >
  967. {(() => {
  968. switch (theData.releaseStatus) {
  969. case "0":
  970. return <span>未发布</span>;
  971. case "1":
  972. return <span>已发布</span>;
  973. }
  974. })()}
  975. </FormItem>
  976. <FormItem className="half-item"
  977. {...formItemLayout}
  978. label="发布时间" >
  979. <span>{theData.releaseDateFormattedDate}</span>
  980. </FormItem>
  981. </div> : <div></div>}
  982. <div className="clearfix">
  983. {theData.releaseStatus == "1" ? <FormItem className="half-item"
  984. {...formItemLayout}
  985. label="需求状态" >
  986. {getFieldDecorator('status', {
  987. initialValue: theData.status
  988. })(
  989. <Radio.Group>
  990. <Radio value="0">未解决</Radio>
  991. <Radio value="1">已解决</Radio>
  992. </Radio.Group>
  993. )}
  994. </FormItem> : <div></div>}
  995. <FormItem className="half-item"
  996. {...formItemLayout}
  997. label="审核状态" >
  998. <span>{getTechAuditStatus(theData.auditStatus)}</span>
  999. </FormItem>
  1000. </div>
  1001. <FormItem
  1002. labelCol={{ span: 3 }}
  1003. wrapperCol={{ span: 20 }}
  1004. label="关键词" >
  1005. <KeyWordTagGroup
  1006. keyWordArr={this.state.tags}
  1007. tagsArr={this.getTagsArr}
  1008. visible={this.props.visible} />
  1009. </FormItem>
  1010. <FormItem
  1011. labelCol={{ span: 3 }}
  1012. wrapperCol={{ span: 18 }}
  1013. label="行业类别" >
  1014. {getFieldDecorator('industryCategory', {
  1015. rules: [{ type: 'array', required: true, message: '此项为必填项!' }],
  1016. initialValue: [theData.industryCategoryA, theData.industryCategoryB]
  1017. })(
  1018. <Cascader style={{ width: 300 }} options={IndustryObject} placeholder="请选择一个行业" />
  1019. )}
  1020. </FormItem>
  1021. <div className="clearfix">
  1022. <FormItem className="half-item"
  1023. {...formItemLayout}
  1024. label="需求类型" >
  1025. {getFieldDecorator('demandType', {
  1026. rules: [{ required: true, message: '此项为必填项!' }],
  1027. initialValue: theData.demandType
  1028. })(
  1029. <Select style={{ width: 160 }} placeholder="请选择需求类型">
  1030. {this.props.demandTypeOption}
  1031. </Select>
  1032. )}
  1033. </FormItem>
  1034. </div>
  1035. <FormItem
  1036. labelCol={{ span: 3 }}
  1037. wrapperCol={{ span: 18 }}
  1038. label="问题说明" >
  1039. {getFieldDecorator('problemDes', {
  1040. rules: [{ required: true, message: '此项为必填项!' }],
  1041. initialValue: theData.problemDes
  1042. })(
  1043. <Input type="textarea" rows={4} />
  1044. )}
  1045. </FormItem>
  1046. <FormItem
  1047. labelCol={{ span: 3 }}
  1048. wrapperCol={{ span: 18 }}
  1049. label="技术指标要求" >
  1050. {getFieldDecorator('technicalRequirements', {
  1051. initialValue: theData.technicalRequirements
  1052. })(
  1053. <Input type="textarea" rows={2} />
  1054. )}
  1055. </FormItem>
  1056. <FormItem
  1057. labelCol={{ span: 3 }}
  1058. wrapperCol={{ span: 18 }}
  1059. label="需求文件(图片)" >
  1060. <PicturesWall
  1061. uid={theData.employerId}
  1062. fileList={this.getPictureUrl}
  1063. pictureUrl={this.state.pictureUrl}
  1064. visible={this.props.visible} />
  1065. </FormItem>
  1066. <FormItem
  1067. labelCol={{ span: 3 }}
  1068. wrapperCol={{ span: 6 }}
  1069. label="需求文件(文本)" >
  1070. <Upload
  1071. name="ratepay"
  1072. action={globalConfig.context + "/api/admin/demand/uploadTextFile"}
  1073. data={{ 'sign': 'demand_text_file', 'uid': theData.employerId }}
  1074. beforeUpload={beforeUploadFile}
  1075. fileList={this.state.textFileList}
  1076. onChange={(info) => {
  1077. if (info.file.status !== 'uploading') {
  1078. console.log(info.file, info.fileList);
  1079. }
  1080. if (info.file.status === 'done') {
  1081. if (!info.file.response.error.length) {
  1082. message.success(`${info.file.name} 文件上传成功!`);
  1083. } else {
  1084. message.warning(info.file.response.error[0].message);
  1085. return;
  1086. };
  1087. this.state.textFileUrl = info.file.response.data;
  1088. } else if (info.file.status === 'error') {
  1089. message.error(`${info.file.name} 文件上传失败。`);
  1090. };
  1091. this.setState({ textFileList: info.fileList.slice(-1) });
  1092. }} >
  1093. <Button><Icon type="upload" /> 上传需求文本文件 </Button>
  1094. </Upload>
  1095. <p style={{ marginTop: '10px' }}>{theData.textFileUrl ?
  1096. <span className="download-file">
  1097. <a onClick={() => { window.open(globalConfig.context + '/api/admin/demand/download?id=' + this.props.data.id) }}>需求文件(文本文件)</a>
  1098. </span>
  1099. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  1100. </FormItem>
  1101. <FormItem
  1102. labelCol={{ span: 3 }}
  1103. wrapperCol={{ span: 18 }}
  1104. label="需求文件(视频地址)" >
  1105. {getFieldDecorator('videoUrl', {
  1106. initialValue: theData.videoUrl
  1107. })(
  1108. <Input />
  1109. )}
  1110. </FormItem>
  1111. <div className="clearfix">
  1112. <FormItem className="half-item"
  1113. {...formItemLayout}
  1114. label="固定周期" >
  1115. {getFieldDecorator('fixedCycle', {
  1116. initialValue: theData.fixedCycle
  1117. })(
  1118. <Input />
  1119. )}
  1120. </FormItem>
  1121. <FormItem className="half-item"
  1122. {...formItemLayout}
  1123. label="固定人数" >
  1124. {getFieldDecorator('peopleNumber', {
  1125. initialValue: theData.peopleNumber || 0
  1126. })(
  1127. <InputNumber />
  1128. )}
  1129. <span style={{ marginLeft: '20px' }}>人</span>
  1130. </FormItem>
  1131. </div>
  1132. <FormItem
  1133. labelCol={{ span: 3 }}
  1134. wrapperCol={{ span: 18 }}
  1135. label="固定方案" >
  1136. {getFieldDecorator('fixedScheme', {
  1137. initialValue: theData.fixedScheme
  1138. })(
  1139. <Input type="textarea" rows={2} />
  1140. )}
  1141. </FormItem>
  1142. <div className="clearfix">
  1143. <FormItem className="half-item"
  1144. {...formItemLayout}
  1145. label="预算费用" >
  1146. {getFieldDecorator('budgetCost', {
  1147. initialValue: theData.budgetCost || 0
  1148. })(
  1149. <InputNumber min={0} max={999999} step={0.01} />
  1150. )}
  1151. <span style={{ marginLeft: '20px' }}>万元</span>
  1152. </FormItem>
  1153. <FormItem className="half-item"
  1154. {...formItemLayout}
  1155. label="费用托管" >
  1156. {getFieldDecorator('costEscrow', {
  1157. initialValue: theData.costEscrow
  1158. })(
  1159. <Radio.Group>
  1160. <Radio value={0}>否</Radio>
  1161. <Radio value={1}>是</Radio>
  1162. </Radio.Group>
  1163. )}
  1164. </FormItem>
  1165. <FormItem className="half-item"
  1166. {...formItemLayout}
  1167. label="有效期限" >
  1168. {getFieldDecorator('validityPeriod', {
  1169. initialValue: theData.validityPeriod ? moment(theData.validityPeriod) : null
  1170. })(
  1171. <DatePicker />
  1172. )}
  1173. </FormItem>
  1174. </div>
  1175. <div className="clearfix" style={{ display: 'none' }}>
  1176. <FormItem className="half-item"
  1177. {...formItemLayout}
  1178. label="雇主地址" >
  1179. <span>{theData.employerAddress}</span>
  1180. </FormItem>
  1181. <FormItem className="half-item"
  1182. {...formItemLayout}
  1183. label="雇主联系人名称" >
  1184. <span>{theData.employerContacts}</span>
  1185. </FormItem>
  1186. <FormItem className="half-item"
  1187. {...formItemLayout}
  1188. label="雇主联系人电话" >
  1189. <span>{theData.employerContactsMobile}</span>
  1190. </FormItem>
  1191. <FormItem className="half-item"
  1192. {...formItemLayout}
  1193. label="雇主联系人邮箱" >
  1194. <span>{theData.employerContactsMailbox}</span>
  1195. </FormItem>
  1196. </div>
  1197. <FormItem wrapperCol={{ span: 12, offset: 3 }}>
  1198. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  1199. <Button className="set-submit" type="ghost" onClick={(e) => { this.state.auditStatus = 1; }} htmlType="submit">发布</Button>
  1200. <Button className="set-submit" type="ghost" onClick={this.props.closeDesc}>取消</Button>
  1201. </FormItem>
  1202. </Spin>
  1203. </Form >
  1204. )
  1205. }
  1206. }));
  1207. const DemandDetail = React.createClass({
  1208. getInitialState() {
  1209. return {
  1210. visible: false,
  1211. techBrodersObj: {},
  1212. tabsKey: "1",
  1213. columns: [
  1214. {
  1215. title: '编号',
  1216. dataIndex: 'serialNumber',
  1217. key: 'serialNumber',
  1218. }, {
  1219. title: '数据类型',
  1220. dataIndex: 'dataCategory',
  1221. key: 'dataCategory',
  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: 'name',
  1233. key: 'name',
  1234. }, {
  1235. title: '关键字',
  1236. dataIndex: 'keyword',
  1237. key: 'keyword',
  1238. }, {
  1239. title: '类型',
  1240. dataIndex: 'category',
  1241. key: 'category',
  1242. render: text => { return getAchievementCategory(text); }
  1243. }, {
  1244. title: '所有人名称',
  1245. dataIndex: 'theName',
  1246. key: 'theName',
  1247. }, {
  1248. title: '所有人类型',
  1249. dataIndex: 'ownerType',
  1250. key: 'ownerType',
  1251. render: text => {
  1252. switch (text) {
  1253. case "0":
  1254. return <span>个人</span>;
  1255. case "1":
  1256. return <span>组织</span>
  1257. }
  1258. }
  1259. }, {
  1260. title: '发布时间',
  1261. dataIndex: 'releaseDateFormattedDate',
  1262. key: 'releaseDateFormattedDate',
  1263. }
  1264. ],
  1265. dataSource: [],
  1266. };
  1267. },
  1268. getTechBrodersList() {
  1269. this.setState({
  1270. loading: true
  1271. });
  1272. $.ajax({
  1273. method: "get",
  1274. dataType: "json",
  1275. crossDomain: false,
  1276. url: globalConfig.context + "/api/admin/audit/techBroders",
  1277. success: function (data) {
  1278. if (!data.data) {
  1279. if (data.error && data.error.length) {
  1280. message.warning(data.error[0].message);
  1281. }
  1282. return;
  1283. };
  1284. let _me = this, theArr = [];
  1285. for (var item in data.data) {
  1286. theArr.push(
  1287. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  1288. )
  1289. };
  1290. this.setState({
  1291. techBrodersOption: theArr,
  1292. techBrodersObj: data.data
  1293. });
  1294. }.bind(this),
  1295. }).always(function () {
  1296. this.setState({
  1297. loading: false
  1298. });
  1299. }.bind(this));
  1300. },
  1301. getTableList() {
  1302. this.setState({
  1303. loading: true
  1304. });
  1305. $.ajax({
  1306. method: "get",
  1307. dataType: "json",
  1308. crossDomain: false,
  1309. url: globalConfig.context + "/api/admin/demand/achievementDemand",
  1310. data: { id: this.props.data.id },
  1311. success: function (data) {
  1312. let theArr = [];
  1313. if (!data.data) {
  1314. if (data.error && data.error.length) {
  1315. message.warning(data.error[0].message);
  1316. };
  1317. } else if (data.data.length) {
  1318. for (let i = 0; i < data.data.length; i++) {
  1319. let thisdata = data.data[i];
  1320. theArr.push({
  1321. key: i,
  1322. id: thisdata.id,
  1323. serialNumber: thisdata.serialNumber,
  1324. dataCategory: thisdata.dataCategory,
  1325. name: thisdata.name,
  1326. keyword: thisdata.keyword,
  1327. category: thisdata.category,
  1328. ownerType: thisdata.ownerType,
  1329. theName: thisdata.username || thisdata.unitName,
  1330. releaseDate: thisdata.releaseDate,
  1331. releaseDateFormattedDate: thisdata.releaseDateFormattedDate
  1332. });
  1333. };
  1334. };
  1335. this.setState({
  1336. dataSource: theArr,
  1337. });
  1338. }.bind(this),
  1339. }).always(function () {
  1340. this.setState({
  1341. loading: false
  1342. });
  1343. }.bind(this));
  1344. },
  1345. tableRowClick(record, index) {
  1346. window.open(globalConfig.context + '/portal/detail/achievementDetail.html?id=' + record.id + '&type=' + record.ownerType);
  1347. },
  1348. handleCancel(e) {
  1349. this.setState({
  1350. visible: false,
  1351. });
  1352. this.props.closeDesc(false);
  1353. },
  1354. handleOk(e) {
  1355. this.setState({
  1356. visible: false,
  1357. });
  1358. this.props.closeDesc(false, true);
  1359. },
  1360. componentWillMount() {
  1361. this.getTechBrodersList();
  1362. },
  1363. componentWillReceiveProps(nextProps) {
  1364. if (!this.state.visible && nextProps.showDesc) {
  1365. this.state.tabsKey = "1";
  1366. };
  1367. this.state.visible = nextProps.showDesc;
  1368. },
  1369. render() {
  1370. if (this.props.data) {
  1371. return (
  1372. <div className="patent-desc">
  1373. <Modal maskClosable={false} visible={this.state.visible}
  1374. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  1375. width='1000px'
  1376. footer=''
  1377. className="admin-desc-content">
  1378. <Spin spinning={this.state.loading}>
  1379. <Tabs activeKey={this.state.tabsKey}
  1380. onChange={(e) => {
  1381. this.setState({ tabsKey: e });
  1382. if (e == "2") {
  1383. this.getTableList();
  1384. };
  1385. }} >
  1386. <Tabs.TabPane tab="需求详情" key="1">
  1387. {(() => {
  1388. if (this.props.data.id && this.props.data.auditStatus != "0" && this.props.data.auditStatus != "4") {
  1389. return <DemandDetailShow
  1390. data={this.props.data}
  1391. detailApiUrl={this.props.detailApiUrl}
  1392. techBrodersOption={this.state.techBrodersOption}
  1393. techBrodersObj={this.state.techBrodersObj}
  1394. demandTypeOption={this.props.demandTypeOption}
  1395. closeDesc={this.handleCancel}
  1396. visible={this.state.visible}
  1397. handleOk={this.handleOk} />
  1398. } else {
  1399. return <DemandDetailForm
  1400. data={this.props.data}
  1401. detailApiUrl={this.props.detailApiUrl}
  1402. companyOption={this.props.companyOption}
  1403. userOption={this.props.userOption}
  1404. techBrodersObj={this.state.techBrodersObj}
  1405. demandTypeOption={this.props.demandTypeOption}
  1406. closeDesc={this.handleCancel}
  1407. visible={this.state.visible}
  1408. handleOk={this.handleOk} />
  1409. }
  1410. })()}
  1411. </Tabs.TabPane>
  1412. <Tabs.TabPane tab="匹配列表" key="2" disabled={!this.props.data.id}>
  1413. <Table columns={this.state.columns}
  1414. dataSource={this.state.dataSource}
  1415. pagination={false}
  1416. onRowClick={this.tableRowClick} />
  1417. </Tabs.TabPane>
  1418. </Tabs>
  1419. </Spin>
  1420. </Modal>
  1421. </div>
  1422. );
  1423. } else {
  1424. return <div></div>
  1425. }
  1426. },
  1427. });
  1428. export default DemandDetail;