techDemandDesc.jsx 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280
  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.contactsOption = [];
  720. this.state.data = {};
  721. this.state.tags = [];
  722. this.state.pictureUrl = [];
  723. this.state.textFileList = [];
  724. this.state.videoFileList = [];
  725. this.state.textFileUrl = undefined;
  726. this.props.form.resetFields();
  727. };
  728. },
  729. render() {
  730. const theData = this.state.data || {};
  731. const { getFieldDecorator } = this.props.form;
  732. const FormItem = Form.Item
  733. const formItemLayout = {
  734. labelCol: { span: 6 },
  735. wrapperCol: { span: 12 },
  736. };
  737. return (
  738. <Form horizontal onSubmit={this.handleSubmit} id="demand-form">
  739. <Spin spinning={this.state.loading}>
  740. <div className="clearfix">
  741. <FormItem className="half-item"
  742. {...formItemLayout}
  743. label="编号" >
  744. <span>{theData.serialNumber}</span>
  745. </FormItem>
  746. <FormItem className="half-item"
  747. {...formItemLayout}
  748. label="需求名称" >
  749. {getFieldDecorator('name', {
  750. rules: [{ required: true, message: '此项为必填项!' }],
  751. initialValue: theData.name
  752. })(
  753. <Input />
  754. )}
  755. </FormItem>
  756. <FormItem className="half-item" style={{ display: theData.username ? 'block' : 'none' }}
  757. {...formItemLayout}
  758. label="雇主名称" >
  759. <span>{theData.username}</span>
  760. </FormItem>
  761. <FormItem className="half-item" style={{ display: theData.username ? 'none' : 'block' }}
  762. {...formItemLayout}
  763. label="雇主名称" >
  764. {getFieldDecorator('employerId', {
  765. initialValue: theData.employerId
  766. })(
  767. <Select
  768. placeholder="请选择"
  769. notFoundContent="未找到"
  770. style={{ width: 260 }}
  771. showSearch
  772. filterOption={companySearch}
  773. onSelect={(e, n) => {
  774. theData.uid = e;
  775. if (this.props.detailApiUrl.indexOf('org') >= 0) {
  776. this.getContactsList(e);
  777. };
  778. }}>
  779. {this.props.detailApiUrl.indexOf('org') >= 0 ? this.props.companyOption : this.props.userOption}
  780. </Select>
  781. )}
  782. </FormItem>
  783. {this.props.detailApiUrl.indexOf('org') >= 0 ? <FormItem className="half-item"
  784. {...formItemLayout}
  785. label="联系人" >
  786. {getFieldDecorator('contacts', {
  787. initialValue: theData.contacts
  788. })(
  789. <Select style={{ width: 260 }}
  790. placeholder="请选择联系人"
  791. notFoundContent="未获取到联系人列表"
  792. showSearch
  793. filterOption={companySearch}>
  794. {this.state.contactsOption}
  795. </Select>
  796. )}
  797. </FormItem> : <div></div>}
  798. {theData.techBrokerId ? <FormItem className="half-item"
  799. {...formItemLayout}
  800. label="负责人" >
  801. <span>{this.props.techBrodersObj[theData.techBrokerId]}</span>
  802. </FormItem> : <div></div>}
  803. </div>
  804. {theData.releaseStatus ? <div className="clearfix">
  805. <FormItem className="half-item"
  806. {...formItemLayout}
  807. label="是否发布" >
  808. {(() => {
  809. switch (theData.releaseStatus) {
  810. case "0":
  811. return <span>未发布</span>;
  812. case "1":
  813. return <span>已发布</span>;
  814. }
  815. })()}
  816. </FormItem>
  817. <FormItem className="half-item"
  818. {...formItemLayout}
  819. label="发布时间" >
  820. <span>{theData.releaseDateFormattedDate}</span>
  821. </FormItem>
  822. </div> : <div></div>}
  823. <div className="clearfix">
  824. {theData.releaseStatus == "1" ? <FormItem className="half-item"
  825. {...formItemLayout}
  826. label="需求状态" >
  827. {getFieldDecorator('status', {
  828. initialValue: theData.status
  829. })(
  830. <Radio.Group>
  831. <Radio value="0">未解决</Radio>
  832. <Radio value="1">已解决</Radio>
  833. </Radio.Group>
  834. )}
  835. </FormItem> : <div></div>}
  836. <FormItem className="half-item"
  837. {...formItemLayout}
  838. label="审核状态" >
  839. <span>{getTechAuditStatus(theData.auditStatus)}</span>
  840. </FormItem>
  841. </div>
  842. <FormItem
  843. labelCol={{ span: 3 }}
  844. wrapperCol={{ span: 20 }}
  845. label="关键词" >
  846. <KeyWordTagGroup
  847. keyWordArr={this.state.tags}
  848. tagsArr={this.getTagsArr}
  849. visible={this.props.visible} />
  850. </FormItem>
  851. <FormItem
  852. labelCol={{ span: 3 }}
  853. wrapperCol={{ span: 18 }}
  854. label="行业类别" >
  855. {getFieldDecorator('industryCategory', {
  856. rules: [{ type: 'array', required: true, message: '此项为必填项!' }],
  857. initialValue: [theData.industryCategoryA, theData.industryCategoryB]
  858. })(
  859. <Cascader style={{ width: 300 }} options={IndustryObject} placeholder="请选择一个行业" />
  860. )}
  861. </FormItem>
  862. <div className="clearfix">
  863. <FormItem className="half-item"
  864. {...formItemLayout}
  865. label="需求类型" >
  866. {getFieldDecorator('demandType', {
  867. rules: [{ required: true, message: '此项为必填项!' }],
  868. initialValue: theData.demandType
  869. })(
  870. <Select style={{ width: 160 }} placeholder="请选择需求类型">
  871. {this.props.demandTypeOption}
  872. </Select>
  873. )}
  874. </FormItem>
  875. </div>
  876. <FormItem
  877. labelCol={{ span: 3 }}
  878. wrapperCol={{ span: 18 }}
  879. label="问题说明" >
  880. {getFieldDecorator('problemDes', {
  881. rules: [{ required: true, message: '此项为必填项!' }],
  882. initialValue: theData.problemDes
  883. })(
  884. <Input type="textarea" rows={4} />
  885. )}
  886. </FormItem>
  887. <FormItem
  888. labelCol={{ span: 3 }}
  889. wrapperCol={{ span: 18 }}
  890. label="技术指标要求" >
  891. {getFieldDecorator('technicalRequirements', {
  892. initialValue: theData.technicalRequirements
  893. })(
  894. <Input type="textarea" rows={2} />
  895. )}
  896. </FormItem>
  897. <FormItem
  898. labelCol={{ span: 3 }}
  899. wrapperCol={{ span: 18 }}
  900. label="需求文件(图片)" >
  901. <PicturesWall
  902. uid={theData.employerId}
  903. fileList={this.getPictureUrl}
  904. pictureUrl={this.state.pictureUrl}
  905. visible={this.props.visible} />
  906. </FormItem>
  907. <FormItem
  908. labelCol={{ span: 3 }}
  909. wrapperCol={{ span: 6 }}
  910. label="需求文件(文本)" >
  911. <Upload
  912. name="ratepay"
  913. action={globalConfig.context + "/api/admin/demand/uploadTextFile"}
  914. data={{ 'sign': 'demand_text_file', 'uid': theData.employerId }}
  915. beforeUpload={beforeUploadFile}
  916. fileList={this.state.textFileList}
  917. onChange={(info) => {
  918. if (info.file.status !== 'uploading') {
  919. console.log(info.file, info.fileList);
  920. }
  921. if (info.file.status === 'done') {
  922. if (!info.file.response.error.length) {
  923. message.success(`${info.file.name} 文件上传成功!`);
  924. } else {
  925. message.warning(info.file.response.error[0].message);
  926. return;
  927. };
  928. this.state.textFileUrl = info.file.response.data;
  929. } else if (info.file.status === 'error') {
  930. message.error(`${info.file.name} 文件上传失败。`);
  931. };
  932. this.setState({ textFileList: info.fileList.slice(-1) });
  933. }} >
  934. <Button><Icon type="upload" /> 上传需求文本文件 </Button>
  935. </Upload>
  936. <p style={{ marginTop: '10px' }}>{theData.textFileUrl ?
  937. <span className="download-file">
  938. <a onClick={() => { window.open(globalConfig.context + '/api/admin/demand/download?id=' + this.props.data.id) }}>需求文件(文本文件)</a>
  939. </span>
  940. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  941. </FormItem>
  942. <FormItem
  943. labelCol={{ span: 3 }}
  944. wrapperCol={{ span: 18 }}
  945. label="需求文件(视频地址)" >
  946. {getFieldDecorator('videoUrl', {
  947. initialValue: theData.videoUrl
  948. })(
  949. <Input />
  950. )}
  951. </FormItem>
  952. <div className="clearfix">
  953. <FormItem className="half-item"
  954. {...formItemLayout}
  955. label="固定周期" >
  956. {getFieldDecorator('fixedCycle', {
  957. initialValue: theData.fixedCycle
  958. })(
  959. <Input />
  960. )}
  961. </FormItem>
  962. <FormItem className="half-item"
  963. {...formItemLayout}
  964. label="固定人数" >
  965. {getFieldDecorator('peopleNumber', {
  966. initialValue: theData.peopleNumber
  967. })(
  968. <InputNumber />
  969. )}
  970. <span style={{ marginLeft: '20px' }}>人</span>
  971. </FormItem>
  972. </div>
  973. <FormItem
  974. labelCol={{ span: 3 }}
  975. wrapperCol={{ span: 18 }}
  976. label="固定方案" >
  977. {getFieldDecorator('fixedScheme', {
  978. initialValue: theData.fixedScheme
  979. })(
  980. <Input type="textarea" rows={2} />
  981. )}
  982. </FormItem>
  983. <div className="clearfix">
  984. <FormItem className="half-item"
  985. {...formItemLayout}
  986. label="预算费用" >
  987. {getFieldDecorator('budgetCost', {
  988. initialValue: theData.budgetCost
  989. })(
  990. <InputNumber min={0} max={9999} step={0.01} />
  991. )}
  992. <span style={{ marginLeft: '20px' }}>万元</span>
  993. </FormItem>
  994. <FormItem className="half-item"
  995. {...formItemLayout}
  996. label="费用托管" >
  997. {getFieldDecorator('costEscrow', {
  998. initialValue: theData.costEscrow
  999. })(
  1000. <Radio.Group>
  1001. <Radio value={0}>否</Radio>
  1002. <Radio value={1}>是</Radio>
  1003. </Radio.Group>
  1004. )}
  1005. </FormItem>
  1006. <FormItem className="half-item"
  1007. {...formItemLayout}
  1008. label="有效期限" >
  1009. {getFieldDecorator('validityPeriod', {
  1010. initialValue: theData.validityPeriod ? moment(theData.validityPeriod) : null
  1011. })(
  1012. <DatePicker />
  1013. )}
  1014. </FormItem>
  1015. </div>
  1016. <div className="clearfix" style={{ display: 'none' }}>
  1017. <FormItem className="half-item"
  1018. {...formItemLayout}
  1019. label="雇主地址" >
  1020. <span>{theData.employerAddress}</span>
  1021. </FormItem>
  1022. <FormItem className="half-item"
  1023. {...formItemLayout}
  1024. label="雇主联系人名称" >
  1025. <span>{theData.employerContacts}</span>
  1026. </FormItem>
  1027. <FormItem className="half-item"
  1028. {...formItemLayout}
  1029. label="雇主联系人电话" >
  1030. <span>{theData.employerContactsMobile}</span>
  1031. </FormItem>
  1032. <FormItem className="half-item"
  1033. {...formItemLayout}
  1034. label="雇主联系人邮箱" >
  1035. <span>{theData.employerContactsMailbox}</span>
  1036. </FormItem>
  1037. </div>
  1038. <FormItem wrapperCol={{ span: 12, offset: 3 }}>
  1039. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  1040. <Button className="set-submit" type="ghost" onClick={(e) => { this.state.auditStatus = 1; }} htmlType="submit">发布</Button>
  1041. <Button className="set-submit" type="ghost" onClick={this.props.closeDesc}>取消</Button>
  1042. </FormItem>
  1043. </Spin>
  1044. </Form >
  1045. )
  1046. }
  1047. }));
  1048. const DemandDetail = React.createClass({
  1049. getInitialState() {
  1050. return {
  1051. visible: false,
  1052. techBrodersObj: {},
  1053. tabsKey: "1",
  1054. columns: [
  1055. {
  1056. title: '编号',
  1057. dataIndex: 'serialNumber',
  1058. key: 'serialNumber',
  1059. }, {
  1060. title: '数据类型',
  1061. dataIndex: 'dataCategory',
  1062. key: 'dataCategory',
  1063. render: text => {
  1064. switch (text) {
  1065. case "0":
  1066. return <span>个人需求</span>;
  1067. case "1":
  1068. return <span>团体需求</span>;
  1069. }
  1070. }
  1071. }, {
  1072. title: '名称',
  1073. dataIndex: 'name',
  1074. key: 'name',
  1075. }, {
  1076. title: '关键字',
  1077. dataIndex: 'keyword',
  1078. key: 'keyword',
  1079. }, {
  1080. title: '类型',
  1081. dataIndex: 'category',
  1082. key: 'category',
  1083. render: text => { return getAchievementCategory(text); }
  1084. }, {
  1085. title: '所有人名称',
  1086. dataIndex: 'theName',
  1087. key: 'theName',
  1088. }, {
  1089. title: '所有人类型',
  1090. dataIndex: 'ownerType',
  1091. key: 'ownerType',
  1092. render: text => {
  1093. switch (text) {
  1094. case "0":
  1095. return <span>个人</span>;
  1096. case "1":
  1097. return <span>组织</span>
  1098. }
  1099. }
  1100. }, {
  1101. title: '发布时间',
  1102. dataIndex: 'releaseDateFormattedDate',
  1103. key: 'releaseDateFormattedDate',
  1104. }
  1105. ],
  1106. dataSource: [],
  1107. };
  1108. },
  1109. getTechBrodersList() {
  1110. this.setState({
  1111. loading: true
  1112. });
  1113. $.ajax({
  1114. method: "get",
  1115. dataType: "json",
  1116. crossDomain: false,
  1117. url: globalConfig.context + "/api/admin/audit/techBroders",
  1118. success: function (data) {
  1119. if (!data.data) {
  1120. if (data.error && data.error.length) {
  1121. message.warning(data.error[0].message);
  1122. }
  1123. return;
  1124. };
  1125. let _me = this, theArr = [];
  1126. for (var item in data.data) {
  1127. theArr.push(
  1128. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  1129. )
  1130. };
  1131. this.setState({
  1132. techBrodersOption: theArr,
  1133. techBrodersObj: data.data
  1134. });
  1135. }.bind(this),
  1136. }).always(function () {
  1137. this.setState({
  1138. loading: false
  1139. });
  1140. }.bind(this));
  1141. },
  1142. getTableList() {
  1143. this.setState({
  1144. loading: true
  1145. });
  1146. $.ajax({
  1147. method: "get",
  1148. dataType: "json",
  1149. crossDomain: false,
  1150. url: globalConfig.context + "/api/admin/demand/achievementDemand",
  1151. data: { id: this.state.data.id },
  1152. success: function (data) {
  1153. let theArr = [];
  1154. if (!data.data) {
  1155. if (data.error && data.error.length) {
  1156. message.warning(data.error[0].message);
  1157. };
  1158. } else if (data.data.length) {
  1159. for (let i = 0; i < data.data.length; i++) {
  1160. let thisdata = data.data[i];
  1161. theArr.push({
  1162. key: i,
  1163. id: thisdata.id,
  1164. serialNumber: thisdata.serialNumber,
  1165. dataCategory: thisdata.dataCategory,
  1166. name: thisdata.name,
  1167. keyword: thisdata.keyword,
  1168. category: thisdata.category,
  1169. ownerType: thisdata.ownerType,
  1170. theName: thisdata.username || thisdata.unitName,
  1171. releaseDate: thisdata.releaseDate,
  1172. releaseDateFormattedDate: thisdata.releaseDateFormattedDate
  1173. });
  1174. };
  1175. };
  1176. this.setState({
  1177. dataSource: theArr,
  1178. });
  1179. }.bind(this),
  1180. }).always(function () {
  1181. this.setState({
  1182. loading: false
  1183. });
  1184. }.bind(this));
  1185. },
  1186. tableRowClick(record, index) {
  1187. if (record.ownerType == "0") {
  1188. window.open(globalConfig.context + '/admin/achievement.html?rid=' + record.id + '#orgTechAchievement');
  1189. } else if (record.ownerType == "1") {
  1190. window.open(globalConfig.context + '/admin/achievement.html?rid=' + record.id + '#userTechAchievement')
  1191. };
  1192. },
  1193. handleCancel(e) {
  1194. this.setState({
  1195. visible: false,
  1196. });
  1197. this.props.closeDesc(false);
  1198. },
  1199. handleOk(e) {
  1200. this.setState({
  1201. visible: false,
  1202. });
  1203. this.props.closeDesc(false, true);
  1204. },
  1205. componentWillMount() {
  1206. this.getTechBrodersList();
  1207. },
  1208. componentWillReceiveProps(nextProps) {
  1209. if (!this.state.visible && nextProps.showDesc) {
  1210. this.state.tabsKey = "1";
  1211. };
  1212. this.state.visible = nextProps.showDesc;
  1213. },
  1214. render() {
  1215. if (this.props.data) {
  1216. return (
  1217. <div className="patent-desc">
  1218. <Modal maskClosable={false} visible={this.state.visible}
  1219. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  1220. width='1000px'
  1221. footer=''
  1222. className="admin-desc-content">
  1223. <Spin spinning={this.state.loading}>
  1224. <Tabs activeKey={this.state.tabsKey}
  1225. onChange={(e) => {
  1226. this.setState({ tabsKey: e });
  1227. if (e == "2") {
  1228. this.getTableList();
  1229. };
  1230. }} >
  1231. <Tabs.TabPane tab="需求详情" key="1">
  1232. {(() => {
  1233. if (this.props.data.auditStatus && this.props.data.auditStatus != "0" && this.props.data.auditStatus != "4") {
  1234. return <DemandDetailShow
  1235. data={this.props.data}
  1236. detailApiUrl={this.props.detailApiUrl}
  1237. techBrodersOption={this.state.techBrodersOption}
  1238. techBrodersObj={this.state.techBrodersObj}
  1239. demandTypeOption={this.props.demandTypeOption}
  1240. closeDesc={this.handleCancel}
  1241. visible={this.state.visible}
  1242. handleOk={this.handleOk} />
  1243. } else {
  1244. return <DemandDetailForm
  1245. data={this.props.data}
  1246. detailApiUrl={this.props.detailApiUrl}
  1247. companyOption={this.props.companyOption}
  1248. userOption={this.props.userOption}
  1249. techBrodersObj={this.state.techBrodersObj}
  1250. demandTypeOption={this.props.demandTypeOption}
  1251. closeDesc={this.handleCancel}
  1252. visible={this.state.visible}
  1253. handleOk={this.handleOk} />
  1254. }
  1255. })()}
  1256. </Tabs.TabPane>
  1257. <Tabs.TabPane tab="匹配列表" key="2" disabled={!this.props.data.id}>
  1258. <Table columns={this.state.columns}
  1259. dataSource={this.state.dataSource}
  1260. pagination={false}
  1261. onRowClick={this.tableRowClick} />
  1262. </Tabs.TabPane>
  1263. </Tabs>
  1264. </Spin>
  1265. </Modal>
  1266. </div>
  1267. );
  1268. } else {
  1269. return <div></div>
  1270. }
  1271. },
  1272. });
  1273. export default DemandDetail;