talentsList.jsx 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  1. import React from "react";
  2. import $ from "jquery/src/ajax";
  3. import "react-quill/dist/quill.bubble.css";
  4. import moment from "moment";
  5. import {
  6. Form,
  7. Icon,
  8. Button,
  9. Input,
  10. Select,
  11. Table,
  12. message,
  13. DatePicker,
  14. Modal,
  15. Upload,
  16. Popconfirm,
  17. Cascader,
  18. InputNumber,
  19. Radio,
  20. TimePicker,
  21. Tabs,
  22. Tag
  23. } from "antd";
  24. import { areaSelect, getProvince } from "@/NewDicProvinceList"; //省市区
  25. import {
  26. getGameState,
  27. splitUrl,
  28. getprovince,
  29. getStatuslist,
  30. getLvl,
  31. placeList,
  32. province,
  33. provinceStatus,
  34. beforeUploadFile,
  35. getPicPath
  36. } from "@/tools.js";
  37. const { Option } = Select;
  38. import Editors from "@/richTextEditors"; //富文本编辑器
  39. import ad01 from "./image/ad01.jpg";
  40. import ad02 from "./image/ad02.jpg";
  41. import ad03 from "./image/ad03.jpg";
  42. import ad04 from "./image/ad04.jpg";
  43. import SpinContainer from "../../SpinContainer";
  44. const PicturesWall = React.createClass({
  45. getInitialState() {
  46. return {
  47. previewVisible: false,
  48. previewImage: "",
  49. fileList: []
  50. };
  51. },
  52. getDefaultProps() {
  53. return {
  54. changeClick: this.modifyChange
  55. };
  56. },
  57. handleCancel() {
  58. this.setState({ previewVisible: false });
  59. },
  60. handlePreview(file) {
  61. this.setState({
  62. previewImage: file.url || file.thumbUrl,
  63. previewVisible: true
  64. });
  65. },
  66. handleChange(info) {
  67. let fileList = info.fileList;
  68. this.setState({ fileList });
  69. this.props.fileList(fileList);
  70. },
  71. componentWillReceiveProps(nextProps) {
  72. this.state.fileList = nextProps.pictureUrl;
  73. },
  74. render() {
  75. const { previewVisible, previewImage, fileList } = this.state;
  76. const uploadButton = (
  77. <div>
  78. <Icon type="plus" />
  79. <div className="ant-upload-text">点击上传</div>
  80. </div>
  81. );
  82. return (
  83. <div style={{ display: "inline-block" }}>
  84. <Upload
  85. beforeUpload={beforeUploadFile}
  86. // action={globalConfig.context + "/api/admin/purchase/uploadPicture"}
  87. // url: '//172.16.0.253:8080' + '/api/admin/banners/addBanners',
  88. action={globalConfig.context + "/api/admin/recruitment/uploadFile"}
  89. data={{ sign: "purchase_picture" }}
  90. listType="picture-card"
  91. fileList={fileList}
  92. onPreview={this.handlePreview}
  93. onChange={this.handleChange}
  94. >
  95. {fileList && fileList.length >= 1 ? null : uploadButton}
  96. </Upload>
  97. <Modal
  98. maskClosable={false}
  99. visible={previewVisible}
  100. footer={null}
  101. onCancel={this.handleCancel}
  102. >
  103. <img alt="" style={{ width: "100%" }} src={previewImage} />
  104. </Modal>
  105. </div>
  106. );
  107. }
  108. });
  109. //主体
  110. const TalentsList = Form.create()(
  111. React.createClass({
  112. loadData(pageNo) {
  113. this.state.data = [];
  114. this.setState({
  115. loading: true,
  116. page: pageNo
  117. });
  118. $.ajax({
  119. method: "get",
  120. dataType: "json",
  121. url: globalConfig.context + "/api/admin/recruitment/listRecruitment",
  122. data: {
  123. pageNo: pageNo || this.state.pagination.current || 1,
  124. pageSize: this.state.pagination.pageSize,
  125. name: this.state.nameSearch
  126. },
  127. success: function (data) {
  128. let theArr = [];
  129. if (!data.data || !data.data.list) {
  130. if (data.error && data.error.length) {
  131. message.warning(data.error[0].message);
  132. }
  133. } else {
  134. for (let i = 0; i < data.data.list.length; i++) {
  135. let thisdata = data.data.list[i];
  136. theArr.push({
  137. key: i + 1,
  138. id: thisdata.id,
  139. name: thisdata.name,
  140. releaseStatus: thisdata.releaseStatus,
  141. sort: thisdata.sort,
  142. province: thisdata.province,
  143. region: thisdata.region,
  144. content: thisdata.content,
  145. releaseTimeConvert: thisdata.releaseTimeConvert
  146. });
  147. }
  148. this.state.pagination.current = data.data.pageNo;
  149. this.state.pagination.total = data.data.totalCount;
  150. }
  151. this.setState({
  152. dataSource: theArr,
  153. pagination: this.state.pagination
  154. });
  155. }.bind(this)
  156. }).always(
  157. function () {
  158. this.setState({
  159. loading: false
  160. });
  161. }.bind(this)
  162. );
  163. },
  164. getInitialState() {
  165. return {
  166. loading: false,
  167. flag: true,
  168. imgeditvisible: false,
  169. activeKey: "1",
  170. purchaseImg: [],
  171. maximg: "",
  172. timesArr: [],
  173. pagination: {
  174. defaultCurrent: 1,
  175. defaultPageSize: 10,
  176. showQuickJumper: true,
  177. pageSize: 10,
  178. onChange: function (page) {
  179. this.loadData(page);
  180. this.setState({
  181. selectedRowKeys: []
  182. });
  183. }.bind(this),
  184. showTotal: function (total) {
  185. return "共" + total + "条数据";
  186. }
  187. },
  188. //数据类型
  189. columns: [
  190. {
  191. title: "序号",
  192. dataIndex: "key",
  193. key: "key"
  194. },
  195. {
  196. title: "职位名称",
  197. dataIndex: "name",
  198. key: "name"
  199. },
  200. {
  201. title: "招聘省份",
  202. dataIndex: "province",
  203. key: "province",
  204. render: e => {
  205. let str = "";
  206. let p = e.split(',');
  207. provinceStatus.forEach(item => {
  208. for (var i = 0; i < p.length; i++) {
  209. if (item.value == p[i]) {
  210. str += item.key + ",";
  211. }
  212. }
  213. });
  214. var reg = /,$/gi;
  215. return str.replace(reg, "");
  216. }
  217. },
  218. {
  219. title: "排序",
  220. dataIndex: "sort",
  221. key: "sort"
  222. },
  223. {
  224. title: "是否发布",
  225. dataIndex: "releaseStatus",
  226. key: "releaseStatus",
  227. render: s => {
  228. return s ? (
  229. <Tag color="#87d068">已发布</Tag>
  230. ) : (
  231. <Tag color="#f50">未发布</Tag>
  232. );
  233. }
  234. },
  235. {
  236. title: "操作",
  237. dataIndex: "c",
  238. render: (text, record, index) => {
  239. return (
  240. <div>
  241. {
  242. <Button
  243. type="primary"
  244. onClick={event => {
  245. this.stopPropagation(event);
  246. this.edit(record);
  247. }}
  248. >
  249. 编辑
  250. </Button>
  251. }
  252. {
  253. <Popconfirm
  254. okText="确定"
  255. cancelText="取消"
  256. title="您确定删除?删除后,招聘信息将不再显示"
  257. onConfirm={() => {
  258. this.delete(record.id);
  259. }}
  260. >
  261. <Button
  262. type="danger"
  263. style={{ marginLeft: "10px" }}
  264. onClick={event => {
  265. this.stopPropagation(event);
  266. }}
  267. >
  268. 删除
  269. </Button>
  270. </Popconfirm>
  271. }
  272. <Button
  273. type="primary"
  274. style={{ marginLeft: "10px" }}
  275. onClick={event => {
  276. this.stopPropagation(event);
  277. if (record.releaseStatus) {
  278. this.remove(record, 0);
  279. } else {
  280. this.remove(record, 1);
  281. }
  282. }}
  283. >
  284. {record.releaseStatus ? "撤销发布" : "发布"}
  285. </Button>
  286. </div>
  287. );
  288. }
  289. },
  290. {
  291. title: "发布时间",
  292. dataIndex: "releaseTimeConvert",
  293. key: "releaseTimeConvert"
  294. }
  295. ],
  296. //数据列表
  297. dataSource: []
  298. };
  299. },
  300. componentWillMount() {
  301. this.loadData();
  302. },
  303. detailes(record) {
  304. this.setState({
  305. loading: true
  306. });
  307. $.ajax({
  308. method: "get",
  309. dataType: "json",
  310. crossDomain: false,
  311. url: globalConfig.context + "/api/admin/banners/selectBanners",
  312. data: {
  313. id: record.id
  314. },
  315. success: function (data) {
  316. let thisdata = data.data;
  317. this.setState({
  318. id: thisdata.id,
  319. title: thisdata.title,
  320. bannerUrl: thisdata.bannerUrl
  321. ? splitUrl(thisdata.bannerUrl, ",", globalConfig.avatarUploadHost)
  322. : [],
  323. sortNumber: thisdata.sort,
  324. display: thisdata.display,
  325. position: thisdata.position
  326. });
  327. }.bind(this)
  328. }).always(
  329. function () {
  330. this.setState({
  331. loading: false
  332. });
  333. }.bind(this)
  334. );
  335. },
  336. //点击大图
  337. maximg(url) {
  338. this.setState({
  339. imgeditvisible: true,
  340. maximg: url
  341. });
  342. },
  343. //删除按钮
  344. delete(id) {
  345. $.ajax({
  346. method: "post",
  347. dataType: "json",
  348. crossDomain: false,
  349. url: globalConfig.context + "/api/admin/recruitment/deleteRecruitment",
  350. data: {
  351. id
  352. },
  353. success: function (data) {
  354. this.loadData(1);
  355. }.bind(this)
  356. }).always(
  357. function () {
  358. this.setState({
  359. loading: false
  360. });
  361. }.bind(this)
  362. );
  363. },
  364. //阻止默认冒泡
  365. stopPropagation(e) {
  366. e.stopPropagation();
  367. e.nativeEvent.stopImmediatePropagation();
  368. },
  369. imghandleCancel() {
  370. this.setState({
  371. imgeditvisible: false
  372. });
  373. },
  374. //项目列表整行点击
  375. tableRowClick(record, index) {
  376. this.setState({
  377. editvisible: true
  378. });
  379. this.edit(record);
  380. },
  381. edithandleCancel(e) {
  382. this.setState(
  383. {
  384. editvisible: false
  385. },
  386. () => {
  387. this.addReset();
  388. }
  389. );
  390. this.loadData();
  391. },
  392. search() {
  393. this.loadData();
  394. },
  395. add() {
  396. this.setState({
  397. editvisible: true,
  398. flag: false
  399. });
  400. this.addReset();
  401. },
  402. cancelAdd() {
  403. this.setState(
  404. {
  405. editvisible: false
  406. },
  407. () => {
  408. this.setState({
  409. flag: true
  410. });
  411. this.addReset();
  412. }
  413. );
  414. this.loadData();
  415. },
  416. //撤下
  417. remove(record, flag) {
  418. $.ajax({
  419. method: "post",
  420. dataType: "json",
  421. crossDomain: false,
  422. url: globalConfig.context + "/api/admin/recruitment/updateRecruitment",
  423. data: {
  424. id: record.id,
  425. releaseStatus: flag
  426. },
  427. success: function (data) {
  428. if (data.error && data.error.length) {
  429. message.warning(data.error[0].message);
  430. } else {
  431. this.loadData();
  432. }
  433. }.bind(this)
  434. }).always(
  435. function () {
  436. this.setState({
  437. loading: false
  438. });
  439. }.bind(this)
  440. );
  441. },
  442. //编辑按钮操作
  443. edit(record) {
  444. this.setState({
  445. flag: true,
  446. editvisible: true
  447. });
  448. this.setState({
  449. loading: true
  450. });
  451. $.ajax({
  452. method: "get",
  453. dataType: "json",
  454. crossDomain: false,
  455. url: globalConfig.context + "/api/admin/recruitment/selectRecruitment",
  456. data: {
  457. id: record.id
  458. },
  459. success: function (data) {
  460. let thisdata = data.data;
  461. let str = "";
  462. placeList.forEach(item => {
  463. if (item.value == thisdata.region) {
  464. str = item.place;
  465. }
  466. });
  467. this.setState({
  468. id: thisdata.id,
  469. name: thisdata.name,
  470. releaseStatus: thisdata.releaseStatus,
  471. province: !!thisdata.province ? thisdata.province.split(',') : [],
  472. region: thisdata.region,
  473. regionStr: str,
  474. editorcontext: thisdata.content,
  475. sort: thisdata.sort,
  476. time: thisdata.releaseTimeConvert,
  477. createTimeConvert: thisdata.createTimeConvert
  478. });
  479. }.bind(this)
  480. }).always(
  481. function () {
  482. this.setState({
  483. loading: false
  484. });
  485. }.bind(this)
  486. );
  487. },
  488. addNew(flag) {
  489. this.setState({
  490. loading: true
  491. });
  492. if (this.state.flag) {
  493. $.ajax({
  494. method: "post",
  495. dataType: "json",
  496. crossDomain: false,
  497. url:
  498. globalConfig.context + "/api/admin/recruitment/updateRecruitment",
  499. data: {
  500. id: this.state.id,
  501. name: this.state.name,
  502. province: this.state.province.toString(), // 省份多选
  503. sort: this.state.sort,
  504. content: this.state.editorcontext,
  505. region: this.state.region,
  506. releaseStatus: flag,
  507. releaseTimes: this.state.time
  508. },
  509. success: function (data) {
  510. this.setState({
  511. loading: false
  512. });
  513. let theArr = [];
  514. if (data.error && data.error.length) {
  515. message.warning(data.error[0].message);
  516. } else {
  517. this.cancelAdd();
  518. }
  519. }.bind(this)
  520. }).always(
  521. function () {
  522. this.setState({
  523. loading: false
  524. });
  525. }.bind(this)
  526. );
  527. } else {
  528. $.ajax({
  529. method: "post",
  530. dataType: "json",
  531. crossDomain: false,
  532. url: globalConfig.context + "/api/admin/recruitment/addRecruitment",
  533. data: {
  534. name: this.state.name,
  535. province: this.state.province.toString(),
  536. sort: this.state.sort,
  537. content: this.state.editorcontext,
  538. region: this.state.region,
  539. releaseStatus: flag,
  540. releaseTimes: this.state.time
  541. },
  542. success: function (data) {
  543. this.setState({
  544. loading: false
  545. });
  546. let theArr = [];
  547. if (data.error && data.error.length) {
  548. message.warning(data.error[0].message);
  549. } else {
  550. this.cancelAdd();
  551. }
  552. }.bind(this)
  553. }).always(
  554. function () {
  555. this.setState({
  556. loading: false
  557. });
  558. }.bind(this)
  559. );
  560. }
  561. },
  562. //新增框的清零
  563. addReset() {
  564. this.setState({
  565. name: undefined,
  566. sort: undefined,
  567. display: 1,
  568. province: [],
  569. editorcontext: "",
  570. region: undefined,
  571. time: undefined
  572. });
  573. },
  574. //搜索部分的清零
  575. reset() {
  576. this.state.nameSearch = undefined;
  577. this.loadData(1);
  578. },
  579. imgOk() {
  580. this.setState({
  581. imgeditvisible: false
  582. });
  583. },
  584. getOrgCodeUrl(e) {
  585. this.setState({ bannerUrl: e });
  586. },
  587. render() {
  588. const FormItem = Form.Item;
  589. const rowSelection = {
  590. selectedRowKeys: this.state.selectedRowKeys,
  591. onChange: (selectedRowKeys, selectedRows) => {
  592. this.setState({
  593. selectedRows: selectedRows.slice(-1),
  594. selectedRowKeys: selectedRowKeys.slice(-1)
  595. });
  596. }
  597. };
  598. const { TextArea } = Input; //文本域
  599. const { TabPane } = Tabs; //标签页
  600. const { MonthPicker, RangePicker, WeekPicker } = DatePicker; //日期输入框
  601. const dateFormat = "YYYY/MM/DD"; //日期格式
  602. const theData = this.state.data || {};
  603. return (
  604. <div className="user-content">
  605. <div className="content-title">
  606. <span>招聘列表</span>
  607. <div className="user-search">
  608. <Input
  609. placeholder="请输入职位名称"
  610. value={this.state.nameSearch}
  611. onChange={e => {
  612. this.setState({ nameSearch: e.target.value });
  613. }}
  614. style={{
  615. width: "150px",
  616. marginRight: "10px",
  617. marginBottom: "10px"
  618. }}
  619. />
  620. <Button
  621. type="primary"
  622. onClick={this.search}
  623. style={{ marginRight: "10px" }}
  624. >
  625. 搜索
  626. </Button>
  627. <Button onClick={this.reset} style={{ marginRight: "10px" }}>
  628. 重置
  629. </Button>
  630. <Button
  631. type="primary"
  632. onClick={this.add}
  633. style={{ marginLeft: "100px" }}
  634. >
  635. 新增职位
  636. </Button>
  637. </div>
  638. <div className="patent-table">
  639. <SpinContainer spinning={this.state.loading}>
  640. <Table
  641. columns={this.state.columns}
  642. dataSource={this.state.dataSource}
  643. onRowClick={this.tableRowClick}
  644. pagination={this.state.pagination}
  645. bordered
  646. size="small"
  647. />
  648. </SpinContainer>
  649. </div>
  650. </div>
  651. <div className="patent-desc">
  652. {
  653. this.state.editvisible &&
  654. <Modal
  655. className="customeDetails"
  656. title={this.state.flag ? "职位详情" : "新增职位"}
  657. visible={this.state.editvisible}
  658. onOk={this.edithandleCancel}
  659. width={"1000px"}
  660. onCancel={
  661. this.state.flag ? this.edithandleCancel : this.cancelAdd
  662. }
  663. footer=""
  664. >
  665. <Form
  666. layout="horizontal"
  667. onSubmit={this.edithandleSubmit}
  668. id="demand-form"
  669. >
  670. <SpinContainer spinning={this.state.loading}>
  671. <div className="clearfix">
  672. <FormItem
  673. className="half-item"
  674. labelCol={{ span: 8 }}
  675. wrapperCol={{ span: 12 }}
  676. label="职位名称"
  677. >
  678. <Input
  679. placeholder="请输入职位名称"
  680. value={this.state.name}
  681. onChange={e => {
  682. this.setState({ name: e.target.value });
  683. }}
  684. style={{ width: "240px" }}
  685. />
  686. </FormItem>
  687. <div className="clearfix">
  688. <FormItem
  689. className="half-item"
  690. labelCol={{ span: 8 }}
  691. wrapperCol={{ span: 12 }}
  692. label="发布时间"
  693. >
  694. <DatePicker
  695. placeholder="请输入发布时间"
  696. format="YYYY-MM-DD HH:mm:ss"
  697. showTime
  698. value={
  699. this.state.time ? moment(this.state.time) : null
  700. }
  701. onChange={(e, f) => {
  702. this.setState({ time: f });
  703. }}
  704. style={{ width: "240px" }}
  705. />
  706. </FormItem>
  707. </div>
  708. <div className="clearfix">
  709. <FormItem
  710. className="half-item"
  711. labelCol={{ span: 8 }}
  712. wrapperCol={{ span: 12 }}
  713. label="招聘省份"
  714. >
  715. <Select
  716. mode="multiple"
  717. style={{ width: 240 }}
  718. placeholder="请选择省份"
  719. value={this.state.province}
  720. onChange={e => {
  721. this.setState({
  722. province: e
  723. });
  724. let str = "";
  725. provinceStatus.forEach(item => {
  726. if (item.value == e) {
  727. str = item.key;
  728. }
  729. });
  730. placeList.forEach(item => {
  731. item.children.forEach(key => {
  732. if (key == str) {
  733. this.setState({
  734. regionStr: item.place,
  735. region: item.value
  736. });
  737. }
  738. });
  739. });
  740. }}
  741. >
  742. {provinceStatus.map(item => {
  743. return (
  744. <Option value={item.value}>{item.key}</Option>
  745. );
  746. })}
  747. </Select>
  748. </FormItem>
  749. </div>
  750. <FormItem
  751. className="half-item"
  752. labelCol={{ span: 8 }}
  753. wrapperCol={{ span: 12 }}
  754. label="排序"
  755. >
  756. <Input
  757. placeholder="请输入数字"
  758. value={this.state.sort}
  759. onChange={e => {
  760. this.setState({
  761. sort: e.target.value
  762. });
  763. }}
  764. style={{ width: "140px" }}
  765. />
  766. </FormItem>
  767. </div>
  768. <div className="clearfix">
  769. <FormItem
  770. labelCol={{ span: 4 }}
  771. wrapperCol={{ span: 18 }}
  772. label="招聘内容"
  773. >
  774. <Editors
  775. textContent={this.state.editorcontext}
  776. uploadUrl={"/api/admin/recruitment/uploadFile"}
  777. globalConfig={globalConfig.uploadPath}
  778. placeholder="业务项目客户基本条件"
  779. handleRichText={value => {
  780. // this.setState({ editorcontext: value });
  781. this.setState({
  782. editorcontext: value
  783. });
  784. }}
  785. />
  786. </FormItem>
  787. </div>
  788. <div className="clearfix">
  789. <Button
  790. type="primary"
  791. size="large"
  792. onClick={e => {
  793. this.addNew(0);
  794. }}
  795. style={{
  796. float: "right",
  797. marginRight: "80px",
  798. marginTop: "20px"
  799. }}
  800. >
  801. 保存
  802. </Button>
  803. <Button
  804. type="primary"
  805. size="large"
  806. onClick={e => {
  807. this.addNew(1);
  808. }}
  809. style={{
  810. float: "right",
  811. marginRight: "20px",
  812. marginTop: "20px"
  813. }}
  814. >
  815. 保存并发布
  816. </Button>
  817. </div>
  818. </SpinContainer>
  819. </Form>
  820. </Modal>
  821. }
  822. </div>
  823. <Modal
  824. visible={this.state.imgeditvisible}
  825. onCancel={this.imghandleCancel}
  826. onOk={this.imgOk}
  827. >
  828. <img style={{ width: "100%" }} src={this.state.maximg} />
  829. </Modal>
  830. </div>
  831. );
  832. }
  833. })
  834. );
  835. export default TalentsList;