CanalInstanceUpdate.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div>
  3. <el-form ref="form" :model="form">
  4. <div style="padding-left: 10px;padding-top: 20px;">
  5. <el-form-item>
  6. {{ form.name }}&nbsp;&nbsp;&nbsp;&nbsp;
  7. <el-button type="primary" @click="onSubmit">修改</el-button>
  8. <el-button type="warning" @click="onCancel">重置</el-button>
  9. <el-button type="info" @click="onBack">返回</el-button>
  10. </el-form-item>
  11. </div>
  12. <editor v-model="form.content" lang="properties" theme="chrome" width="100%" :height="800" @init="editorInit" />
  13. </el-form>
  14. </div>
  15. </template>
  16. <script>
  17. import { canalInstanceDetail, updateCanalInstance } from '@/api/canalInstance'
  18. export default {
  19. components: {
  20. editor: require('vue2-ace-editor')
  21. },
  22. data() {
  23. return {
  24. form: {
  25. id: null,
  26. name: '',
  27. content: ''
  28. }
  29. }
  30. },
  31. created() {
  32. this.loadCanalConfig()
  33. },
  34. methods: {
  35. editorInit() {
  36. require('brace/ext/language_tools')
  37. require('brace/mode/html')
  38. require('brace/mode/yaml')
  39. require('brace/mode/properties')
  40. require('brace/mode/javascript')
  41. require('brace/mode/less')
  42. require('brace/theme/chrome')
  43. require('brace/snippets/javascript')
  44. },
  45. loadCanalConfig() {
  46. canalInstanceDetail(this.$route.query.id).then(response => {
  47. const data = response.data
  48. this.form.id = data.id
  49. this.form.name = data.name + '/instance.propertios'
  50. this.form.content = data.content
  51. })
  52. },
  53. onSubmit() {
  54. this.$confirm(
  55. '修改Instance配置可能会导致重启,是否继续?',
  56. '确定修改',
  57. {
  58. confirmButtonText: '确定',
  59. cancelButtonText: '取消',
  60. type: 'warning'
  61. }
  62. ).then(() => {
  63. updateCanalInstance(this.form).then(response => {
  64. if (response.data === 'success') {
  65. this.$message({
  66. message: '修改成功',
  67. type: 'success'
  68. })
  69. this.loadCanalConfig()
  70. } else {
  71. this.$message({
  72. message: '修改失败',
  73. type: 'error'
  74. })
  75. }
  76. })
  77. })
  78. },
  79. onCancel() {
  80. this.loadCanalConfig()
  81. },
  82. onBack() {
  83. history.go(-1)
  84. }
  85. }
  86. }
  87. </script>
  88. <style scoped>
  89. .line{
  90. text-align: center;
  91. }
  92. </style>