techDemandDesc.jsx 54 KB

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