You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

BaseDialog.vue 2.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="base-dlg">
  3. <el-dialog
  4. :visible.sync="dialogShow"
  5. :title="title"
  6. :width="width"
  7. :fullscreen="fullscreen"
  8. :top="top"
  9. :modal="modal"
  10. :modal-append-to-body="modalAppendToBody"
  11. :append-to-body="appendToBody"
  12. :lock-scroll="lockScroll"
  13. :custom-class="customClass"
  14. :close-on-click-modal="closeOnClickModal"
  15. :close-on-press-escape="closeOnPressEscape"
  16. :show-close="showClose"
  17. :center="center"
  18. :destroy-on-close="destroyOnClose"
  19. :before-close="beforeClose"
  20. @open="open"
  21. @opened="opened"
  22. @close="close"
  23. @closed="closed"
  24. >
  25. <template v-slot:title>
  26. <slot name="title"></slot>
  27. </template>
  28. <template v-slot:default>
  29. <slot name="default"></slot>
  30. </template>
  31. <template v-slot:footer>
  32. <slot name="footer"></slot>
  33. </template>
  34. </el-dialog>
  35. </div>
  36. </template>
  37. <script>
  38. export default {
  39. name: "BaseDialog",
  40. props: {
  41. visible: { type: Boolean, default: false },
  42. title: { type: String, default: "" },
  43. width: { type: String, default: "" },
  44. fullscreen: { type: Boolean, default: false },
  45. top: { type: String },
  46. modal: { type: Boolean, default: true },
  47. modalAppendToBody: { type: Boolean, default: true },
  48. appendToBody: { type: Boolean, default: false },
  49. lockScroll: { type: Boolean, default: false },
  50. customClass: { type: String, default: "" },
  51. closeOnClickModal: { type: Boolean, default: false },
  52. closeOnPressEscape: { type: Boolean, default: true },
  53. showClose: { type: Boolean, default: true },
  54. beforeClose: { type: Function },
  55. center: { type: Boolean, default: false },
  56. destroyOnClose: { type: Boolean, default: false },
  57. },
  58. data: function () {
  59. return {
  60. dialogShow: false,
  61. };
  62. },
  63. watch: {
  64. visible: function (val) {
  65. this.dialogShow = val;
  66. },
  67. },
  68. methods: {
  69. open: function () {
  70. this.$emit("open");
  71. },
  72. opened: function () {
  73. this.$emit("opened");
  74. },
  75. close: function () {
  76. this.$emit("close");
  77. },
  78. closed: function () {
  79. this.$emit("closed");
  80. this.$emit("update:visible", false);
  81. },
  82. },
  83. };
  84. </script>
  85. <style scoped lang="less">
  86. .base-dlg {
  87. /deep/ .el-dialog__header {
  88. text-align: left;
  89. height: 45px;
  90. background: rgb(240, 240, 240);
  91. border-radius: 5px 5px 0px 0px;
  92. border-bottom: 1px solid rgb(212, 212, 213);
  93. padding: 0 15px;
  94. display: flex;
  95. align-items: center;
  96. font-weight: 500;
  97. font-size: 16px;
  98. color: rgb(16, 16, 16);
  99. .el-dialog__title {
  100. font-weight: 500;
  101. font-size: 16px;
  102. color: rgb(16, 16, 16);
  103. }
  104. .el-dialog__headerbtn {
  105. top: 15px;
  106. right: 15px;
  107. }
  108. }
  109. /deep/ .el-dialog__body {
  110. padding: 15px 15px;
  111. }
  112. }
  113. </style>