techDemandDesc.jsx 57 KB

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