techDemandDesc.jsx 56 KB

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