dialog -drawer.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div class="ad-aw-box">
  3. <el-drawer
  4. v-if="type == 'drawer'"
  5. :visible.sync="visible"
  6. :wrapperClosable="modal"
  7. :close-on-press-escape="escape"
  8. :show-close="close"
  9. :before-close="beforeClose"
  10. :size="wd"
  11. >
  12. <template v-slot:title>
  13. <h1>
  14. {{ title }}
  15. </h1>
  16. </template>
  17. <slot name="content"></slot>
  18. </el-drawer>
  19. <el-dialog
  20. v-if="type == 'dialog'"
  21. :title="title"
  22. :close-on-click-modal="modal"
  23. :close-on-press-escape="escape"
  24. :show-close="close"
  25. :visible.sync="visible"
  26. :before-close="beforeClose"
  27. :width="wd"
  28. >
  29. <slot name="content"></slot>
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. props: {
  36. // 标题
  37. title: String,
  38. type: { type: String, default: 'dialog' },
  39. // 是否可以点击遮罩关闭
  40. modal: { type: Boolean, default: true },
  41. // 是否可以ESC关闭
  42. escape: { type: Boolean, default: true },
  43. // 是否显示退出按钮
  44. close: { type: Boolean, default: true },
  45. visible: { type: Boolean, default: true, required: true },
  46. width: { type: String }
  47. },
  48. computed: {
  49. wd () {
  50. if (this.width) return this.width
  51. const width = this.type === 'dialog' ? '40%' : '25%'
  52. return width
  53. }
  54. },
  55. data () {
  56. return {}
  57. },
  58. methods: {
  59. beforeClose (done) {
  60. this.$emit('close')
  61. }
  62. },
  63. mounted () {}
  64. }
  65. </script>
  66. <style lang="less" scoped></style>