EditShopConfig.vue 1.7 KB

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