techDemandDesc.jsx 53 KB

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