EditShopConfig.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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.colors = [
  49. '#00000000',
  50. '#000000',
  51. '#eeece0',
  52. '#1c487f',
  53. '#4d80bf',
  54. '#c24f4a',
  55. '#8baa4a',
  56. '#7b5ba1',
  57. '#46acc8',
  58. '#f9963b',
  59. '#ffffff'
  60. ];
  61. //editor.customConfig.uploadImgServer = process.env.SERVER_PATH + 'editupload'
  62. //editor.customConfig.uploadFileName = 'file'
  63. editor.customConfig.onchange = function(html) {
  64. that.value = html;
  65. };
  66. editor.create();
  67. var key = this.$route.query.key;
  68. this.key = key;
  69. this.$http.getSysConfig({ key: key }, this).then(res => {
  70. if (res.code === 0) {
  71. editor.txt.html(res.obj);
  72. }
  73. });
  74. }
  75. };
  76. </script>
  77. <style scoped>
  78. .bar {
  79. background-color: #f1f1f1;
  80. border: 1px solid #ccc;
  81. }
  82. .editor {
  83. border: 1px solid #ccc;
  84. border-top: none;
  85. height: 700px;
  86. }
  87. .config_button {
  88. margin-bottom: 20px;
  89. }
  90. .operation {
  91. display: flex;
  92. height: 50px;
  93. border-bottom: 1px solid #e6e6e6;
  94. margin-bottom: 10px;
  95. }
  96. .operation .btn {
  97. display: flex;
  98. height: 28px;
  99. }
  100. .operation .btn,
  101. .operation .el-input,
  102. .operation .el-select {
  103. width: 150px;
  104. margin-right: 8px;
  105. }
  106. </style>