BaseDialog.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <el-dialog
  3. :visible.sync="visible"
  4. :width="width"
  5. :show-close="false"
  6. :close-on-click-modal="false"
  7. :append-to-body="appendToBody"
  8. @closed="close"
  9. >
  10. <div slot="title" class="hearders">
  11. <div class="leftTitle">{{ title }}</div>
  12. <div class="rightBoxs">
  13. <img
  14. src="@/assets/images/Close@2x.png"
  15. alt=""
  16. @click="visible = false"
  17. />
  18. </div>
  19. </div>
  20. <slot></slot>
  21. <div slot="footer" class="dialog-footer" v-if="isShowFooter">
  22. <slot name="slotBtn"></slot>
  23. <el-button :loading="disabledBtn" @click="visible = false">{{
  24. cancelName
  25. }}</el-button>
  26. <el-button
  27. v-if="confirmStatus"
  28. :loading="disabledBtn"
  29. type="primary"
  30. @click="confirmBtn"
  31. >{{ confirmName }}</el-button
  32. >
  33. </div>
  34. </el-dialog>
  35. </template>
  36. <script>
  37. export default {
  38. name: "BaseDialog",
  39. props: {
  40. title: {
  41. type: String,
  42. default: "",
  43. },
  44. isShow: {
  45. type: Boolean,
  46. default: false,
  47. },
  48. width: {
  49. type: String,
  50. default: "600px",
  51. },
  52. cancelName: {
  53. type: String,
  54. default: "取 消",
  55. },
  56. confirmName: {
  57. type: String,
  58. default: "确 定",
  59. },
  60. isShowFooter: {
  61. type: Boolean,
  62. default: true,
  63. },
  64. appendToBody: {
  65. type: Boolean,
  66. default: false,
  67. },
  68. disabledBtn: {
  69. type: Boolean,
  70. default: false,
  71. },
  72. confirmStatus: {
  73. type: Boolean,
  74. default: true,
  75. },
  76. },
  77. data() {
  78. return {};
  79. },
  80. methods: {
  81. confirmBtn() {
  82. this.$emit("submit");
  83. },
  84. close() {
  85. this.$emit("close");
  86. },
  87. },
  88. computed: {
  89. visible: {
  90. get() {
  91. return this.isShow;
  92. },
  93. set(val) {
  94. this.$emit("update:isShow", false);
  95. },
  96. },
  97. },
  98. watch: {
  99. visible(val) {
  100. // 在此做显示与隐藏的交互
  101. if (val === false) {
  102. // 重置操作
  103. } else {
  104. // 展示时操作
  105. }
  106. },
  107. },
  108. };
  109. </script>
  110. <style scoped lang="scss">
  111. /deep/.el-dialog {
  112. border-radius: 8px;
  113. .el-dialog__header {
  114. padding: 0;
  115. .hearders {
  116. height: 40px;
  117. display: flex;
  118. align-items: center;
  119. justify-content: space-between;
  120. padding: 0px 18px 0px 20px;
  121. border-bottom: 1px solid #e2e2e2;
  122. .leftTitle {
  123. font-size: 14px;
  124. font-weight: bold;
  125. color: #2f4378;
  126. }
  127. .rightBoxs {
  128. display: flex;
  129. align-items: center;
  130. img {
  131. width: 14px;
  132. height: 14px;
  133. margin-left: 13px;
  134. cursor: pointer;
  135. }
  136. }
  137. }
  138. }
  139. .el-dialog__footer {
  140. padding: 0;
  141. .dialog-footer {
  142. padding: 0px 40px;
  143. height: 70px;
  144. border-top: 1px solid #e2e2e2;
  145. display: flex;
  146. align-items: center;
  147. justify-content: flex-end;
  148. }
  149. }
  150. }
  151. /deep/.el-button {
  152. border-radius: 8px;
  153. }
  154. </style>