EditShopConfig.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div>
  3. <div class="config_button">
  4. <el-button type="primary" @click="save" size="mini">保存</el-button>
  5. <el-button @click="goBack" size="mini">取消</el-button>
  6. </div>
  7. <div id="bar" class="bar"></div>
  8. <div id="editor" class="editor"></div>
  9. </div>
  10. </template>
  11. <script>
  12. var E = require("wangeditor");
  13. export default {
  14. data() {
  15. return {
  16. key: "",
  17. value: ""
  18. };
  19. },
  20. methods: {
  21. save: function() {
  22. var that = this;
  23. var param = {
  24. key: this.key,
  25. value: this.value
  26. };
  27. this.$http.saveSysConfig(param, this).then(res => {
  28. if (res.code === 0) {
  29. this.$message({
  30. message: "操作成功",
  31. type: "success",
  32. duration: 1000,
  33. onClose: function() {
  34. that.$router.back();
  35. }
  36. });
  37. }
  38. });
  39. },
  40. goBack: function() {
  41. this.$router.back();
  42. }
  43. },
  44. mounted: function() {
  45. var that = this;
  46. var editor = new E("#bar", "#editor");
  47. editor.customConfig.uploadImgShowBase64 = true;
  48. //editor.customConfig.uploadImgServer = process.env.SERVER_PATH + 'editupload'
  49. //editor.customConfig.uploadFileName = 'file'
  50. editor.customConfig.onchange = function(html) {
  51. that.value = html;
  52. };
  53. editor.create();
  54. var key = this.$route.query.key;
  55. this.key = key;
  56. this.$http.getSysConfig({ key: key }, this).then(res => {
  57. if (res.code === 0) {
  58. editor.txt.html(res.obj);
  59. }
  60. });
  61. }
  62. };
  63. </script>
  64. <style scoped>
  65. .bar {
  66. background-color: #f1f1f1;
  67. border: 1px solid #ccc;
  68. }
  69. .editor {
  70. border: 1px solid #ccc;
  71. border-top: none;
  72. height: 700px;
  73. }
  74. .config_button {
  75. margin-bottom: 20px;
  76. }
  77. .operation {
  78. display: flex;
  79. height: 50px;
  80. border-bottom: 1px solid #e6e6e6;
  81. margin-bottom: 10px;
  82. }
  83. .operation .btn {
  84. display: flex;
  85. height: 28px;
  86. }
  87. .operation .btn,
  88. .operation .el-input,
  89. .operation .el-select {
  90. width: 150px;
  91. margin-right: 8px;
  92. }
  93. </style>