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