index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-10-19 14:56:17
  4. * @LastEditTime: 2022-04-28 11:22:47
  5. * @LastEditors: your name
  6. * @Description: 弹出框
  7. * @FilePath: \Foshan4A\src\layout\components\Dialog\index.vue
  8. -->
  9. <template>
  10. <div class="dialog">
  11. <el-dialog
  12. :visible.sync="flag"
  13. ref="dialogTk"
  14. :top="top"
  15. :custom-class="customClass"
  16. :lock-scroll="false"
  17. :modal="modal"
  18. :before-close="close"
  19. :width="width"
  20. :show-close="showFlag"
  21. >
  22. <div
  23. :style="{
  24. height: child
  25. ? this.$store.state.settings.dialogHeight - 96 + 'px'
  26. : '',
  27. }"
  28. class="dialog-content"
  29. >
  30. <slot />
  31. </div>
  32. </el-dialog>
  33. </div>
  34. </template>
  35. <script>
  36. export default {
  37. name: "Dialog",
  38. props: {
  39. // 弹框开关
  40. flag: {
  41. type: Boolean,
  42. default: false,
  43. },
  44. showFlag: {
  45. type: Boolean,
  46. default: false,
  47. },
  48. // 弹框宽度
  49. width: {
  50. type: String,
  51. default: "400px",
  52. },
  53. // 弹框类名
  54. customClass: {
  55. type: String,
  56. default: "",
  57. },
  58. // 弹框高度
  59. top: {
  60. type: String,
  61. default: "0vh",
  62. },
  63. // 弹框遮罩层
  64. modal: {
  65. type: Boolean,
  66. default: true,
  67. },
  68. // 二级弹框标记
  69. child: {
  70. type: Boolean,
  71. default: false,
  72. },
  73. },
  74. // 监听弹框开关
  75. watch: {
  76. flag: {
  77. handler(val) {
  78. if (val) {
  79. this.$nextTick(() => {
  80. // 获取弹框高度
  81. const height = this.$refs["dialogTk"].$refs.dialog.clientHeight;
  82. if (height) {
  83. // 当前弹框无二级弹框时 存入高度
  84. if (!this.child) {
  85. this.$store.state.settings.dialogHeight = height;
  86. }
  87. }
  88. });
  89. }
  90. },
  91. deep: true,
  92. },
  93. },
  94. methods: {
  95. // 弹框关闭
  96. close() {
  97. this.$emit("closeDialog", false);
  98. },
  99. },
  100. };
  101. </script>
  102. <style lang="scss" scoped>
  103. .dialog {
  104. ::v-deep .el-dialog {
  105. border-radius: 2px;
  106. background: #ffffff;
  107. box-shadow: 0px 6px 10px 0px rgba(0, 0, 0, 0.3);
  108. position: absolute;
  109. left: 50%;
  110. top: 50%;
  111. transform: translate(-50%, -50%);
  112. .el-dialog__header {
  113. display: none;
  114. }
  115. .el-dialog__body {
  116. padding: 0;
  117. .title {
  118. padding: 10px 0px 10px 20px;
  119. font-size: 16px;
  120. font-family: Microsoft YaHei;
  121. font-weight: bold;
  122. height: 36px;
  123. background: #2d67e3;
  124. color: #ffffff;
  125. margin-bottom: 24px;
  126. width: 100%;
  127. }
  128. .del-title,
  129. .Deltitle {
  130. padding: 10px 0px 10px 20px;
  131. font-size: 16px;
  132. font-family: Microsoft YaHei;
  133. font-weight: bold;
  134. height: 36px;
  135. background: #eb2f3b;
  136. color: #ffffff;
  137. display: flex;
  138. align-items: center;
  139. margin-bottom: 36px;
  140. width: 100%;
  141. }
  142. .Delfoot {
  143. background-color: #fff;
  144. }
  145. .del-content {
  146. .error {
  147. color: #eb2f3b;
  148. }
  149. }
  150. .dialog-content .el-form {
  151. padding-right: 24px;
  152. }
  153. .el-form-item__label {
  154. font-size: 14px;
  155. font-family: Microsoft YaHei;
  156. font-weight: 400;
  157. color: #303133;
  158. }
  159. }
  160. .el-button + .el-button {
  161. margin-left: 0px;
  162. }
  163. }
  164. }
  165. </style>