techDemandDesc.jsx 57 KB

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