CodeDialog.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <cus-dialog
  3. :visible="templateVisible"
  4. @on-close="templateVisible = false"
  5. ref="codeDialog"
  6. :width="width"
  7. form
  8. :title="title"
  9. @on-submit="handleSubmit"
  10. class="code-dialog-container"
  11. >
  12. <code-editor :height="codeHeight" :mode="this.mode" v-model="templ"></code-editor>
  13. <div class="code-dialog-help" v-if="help">
  14. <el-button type="text" @click="handleHelp">帮助<i class="el-icon-question el-icon--right"></i></el-button>
  15. </div>
  16. </cus-dialog>
  17. </template>
  18. <script>
  19. import CusDialog from './CusDialog'
  20. import CodeEditor from './CodeEditor'
  21. export default {
  22. components: {
  23. CusDialog,
  24. CodeEditor
  25. },
  26. props: {
  27. mode: {
  28. type: String,
  29. default: 'xml'
  30. },
  31. title: {
  32. type: String,
  33. default: ''
  34. },
  35. help: {
  36. type: String,
  37. default: ''
  38. },
  39. width: {
  40. type: String,
  41. default: '900px'
  42. },
  43. codeHeight: {
  44. type: String,
  45. default: '460px'
  46. }
  47. },
  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>