CodeDialog.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <cus-dialog
  3. :visible="templateVisible"
  4. @on-close="templateVisible = false"
  5. ref="codeDialog"
  6. :width="width"
  7. :title="title"
  8. @on-submit="handleSubmit"
  9. custom-class="code-dialog-container"
  10. >
  11. <code-editor :height="codeHeight" :mode="this.mode" v-model="templ"></code-editor>
  12. <div class="code-dialog-help" v-if="help">
  13. <el-button link type="danger" @click="handleHelp">帮助<i class="fm-iconfont icon-question-circle"></i></el-button>
  14. </div>
  15. </cus-dialog>
  16. </template>
  17. <script>
  18. import CusDialog from './CusDialog.vue'
  19. import CodeEditor from './CodeEditor/index.vue'
  20. export default {
  21. components: {
  22. CusDialog,
  23. CodeEditor
  24. },
  25. props: {
  26. mode: {
  27. type: String,
  28. default: 'xml'
  29. },
  30. title: {
  31. type: String,
  32. default: ''
  33. },
  34. help: {
  35. type: String,
  36. default: ''
  37. },
  38. width: {
  39. type: String,
  40. default: '900px'
  41. },
  42. codeHeight: {
  43. type: String,
  44. default: '460px'
  45. }
  46. },
  47. emits: ['on-confirm'],
  48. data () {
  49. return {
  50. templateVisible: false,
  51. templ: ''
  52. }
  53. },
  54. methods: {
  55. handleSubmit () {
  56. this.$emit('on-confirm', this.templ)
  57. },
  58. open (val) {
  59. this.templ = val
  60. this.templateVisible = true
  61. },
  62. close () {
  63. this.templateVisible = false
  64. },
  65. end () {
  66. this.$refs['codeDialog'].end()
  67. },
  68. handleHelp () {
  69. window.open(this.help)
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss">
  75. @media screen and (max-width: 1000px) {
  76. .code-dialog-container{
  77. .el-dialog{
  78. width: 100% !important;
  79. }
  80. }
  81. }
  82. </style>