setting.jsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 "../authentication/techDemand.less";
  6. import {
  7. Form,
  8. Button,
  9. message,
  10. } from "antd";
  11. import {
  12. beforeUploadFile,
  13. } from "@/tools.js";
  14. import Editors from "@/richTextEditors";
  15. //主体
  16. const Setting = Form.create()(
  17. React.createClass({
  18. getInitialState() {
  19. return {
  20. content: "",
  21. };
  22. },
  23. // 初始化数据
  24. loadData() {
  25. //发送请求
  26. $.ajax({
  27. method: "get",
  28. dataType: "json",
  29. crossDomain: false,
  30. url: globalConfig.context + "/api/admin/getSysConfig",
  31. data: {
  32. id: 100
  33. },
  34. success: function (data) {
  35. if (data.error.length == 0) {
  36. this.setState({
  37. content: data.data.content
  38. });
  39. } else {
  40. message.warning(data.error[0].message)
  41. }
  42. }.bind(this),
  43. }).always(
  44. function () {
  45. this.setState({
  46. loading: false,
  47. });
  48. }.bind(this)
  49. );
  50. },
  51. // 编辑声明
  52. edit() {
  53. this.setState({
  54. loading: true,
  55. });
  56. $.ajax({
  57. method: "post",
  58. dataType: "json",
  59. crossDomain: false,
  60. url: globalConfig.context + "/api/admin/updateSysConfig",
  61. data: {
  62. id: 100,
  63. content: this.state.content,
  64. },
  65. success: function (data) {
  66. this.setState({
  67. loading: false,
  68. });
  69. if (data.error && data.error.length) {
  70. message.warning(data.error[0].message);
  71. }else{
  72. message.success("修改成功!")
  73. }
  74. }.bind(this),
  75. }).always(
  76. function () {
  77. this.setState({
  78. loading: false,
  79. });
  80. }.bind(this)
  81. );
  82. },
  83. componentWillMount() {
  84. this.loadData();
  85. },
  86. render() {
  87. return (
  88. <div className="user-content">
  89. <div className="content-title">
  90. <span>本站声明设置</span>
  91. <div style={{ width: 800, marginTop: 20 }}>
  92. <Editors
  93. textContent={this.state.content}
  94. uploadUrl={"/api/admin/news/uploadFile"}
  95. globalConfig={globalConfig.uploadPath}
  96. placeholder=""
  97. handleRichText={(value) => {
  98. this.setState({ content: value });
  99. }}
  100. />
  101. <Button
  102. type="primary"
  103. onClick={this.edit}
  104. style={{ margin: "50px 0 20px 360px" }}
  105. >
  106. 保存更改
  107. </Button>
  108. <div style={{ color: "red" }}>提示:本站声明,显示在新闻底部,一旦修改,将整站全部修改!!!</div>
  109. </div>
  110. </div>
  111. </div>
  112. );
  113. },
  114. })
  115. );
  116. export default Setting;