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.7 kB

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