proservlist.jsx 22 KB

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