guide.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <!-- -->
  2. <template>
  3. <div>
  4. <main-top :crumb="crumbData">
  5. <div slot="con"></div>
  6. </main-top>
  7. <div class="table-interface">
  8. <div class="top-body" style="padding: 50px 20px">
  9. <el-form
  10. :model="form"
  11. :rules="rules"
  12. ref="form"
  13. label-width="100px"
  14. class="demo-ruleForm"
  15. >
  16. <el-row>
  17. <el-col :span="24">
  18. <el-form-item label="内容" prop="content">
  19. <vue-editor class="quill-editor" v-model="form.content" />
  20. </el-form-item>
  21. </el-col>
  22. </el-row>
  23. <el-form-item>
  24. <el-button type="primary" @click="submitForm('form')"
  25. >保存</el-button
  26. >
  27. </el-form-item>
  28. </el-form>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. const crumbData = [
  35. {
  36. name: "参观指南",
  37. id: 3,
  38. },
  39. ];
  40. import MainTop from "@/components/main-top";
  41. import * as common from "@/util/commonfn.js";
  42. import { VueEditor} from "vue2-editor";
  43. export default {
  44. components: {
  45. MainTop,
  46. VueEditor
  47. },
  48. data() {
  49. return {
  50. crumbData,
  51. form: {},
  52. rules: {
  53. content: [{ required: true, message: "请输入内容", trigger: "blur" }],
  54. },
  55. token: window.localStorage.getItem("token"),
  56. };
  57. },
  58. computed: {},
  59. watch: {},
  60. mounted() {},
  61. created() {
  62. this.getDetail()
  63. },
  64. methods: {
  65. async getDetail() {
  66. let result = await this.$http({
  67. method: "get",
  68. url: "/manage/guide/detail/4",
  69. });
  70. if(result['code'] === 0){
  71. this["form"] = result['data'];
  72. } else {
  73. this["form"] = {}
  74. }
  75. },
  76. submitForm(formName) {
  77. this.$refs[formName].validate((valid) => {
  78. if (valid) {
  79. this.save();
  80. } else {
  81. console.log("error submit!!");
  82. return false;
  83. }
  84. });
  85. },
  86. async save() {
  87. let data = this["form"];
  88. let result = await this.$http({
  89. method: "post",
  90. data,
  91. url: "/manage/guide/save"
  92. });
  93. if(result['code'] === 0) {
  94. common.tip('success','保存成功');
  95. this.getDetail()
  96. } else {
  97. common.tip('error','保存失败,请联系管理员');
  98. }
  99. }
  100. }
  101. };
  102. </script>
  103. <style scoped>
  104. .table-interface {
  105. height: calc(100% - 3rem);
  106. overflow: auto;
  107. }
  108. .top-body {
  109. border-top: 0.0625rem solid #e6e6e6;
  110. line-height: 1.5;
  111. padding: 0 1.25rem 1.25rem;
  112. align-items: center;
  113. box-sizing: border-box;
  114. background: #fff;
  115. margin: 1rem 0;
  116. }
  117. .info-top {
  118. padding: 20px 0;
  119. display: flex;
  120. justify-content: space-between;
  121. border-bottom: 1px #a5a5a5 solid;
  122. }
  123. </style>
  124. <style>
  125. .ck-content { height:500px; }
  126. </style>