index.vue 3.3 KB

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