Propup.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div class="propup">
  3. <el-dialog
  4. :visible.sync="showDialog"
  5. :show-close="false"
  6. :width="width"
  7. :modal="modal"
  8. :close-on-click-modal="false"
  9. :top="distanceTop"
  10. :destroy-on-close="true"
  11. >
  12. <div slot="title" class="header flex-center">
  13. <span>{{title}}</span>
  14. <div @click="closePropup()">+</div>
  15. </div>
  16. <div class="popup-container" v-if="showBody">
  17. <slot name="body"></slot>
  18. <div class="btns flex-center" v-if="showBtns">
  19. <div class="confim flex-center" @click="confim()" v-if="confimText">{{confimText}}</div>
  20. <div class="cancle flex-center" @click="cancle()" v-if="!hideCancleButton" :style="cancleStyle">{{cancleText}}</div>
  21. </div>
  22. </div>
  23. <div v-else>
  24. <slot name="body"></slot>
  25. <div class="btns flex-center" v-if="showBtns">
  26. <div class="confim flex-center" @click="confim()" v-if="confimText">{{confimText}}</div>
  27. <div class="cancle flex-center" @click="cancle()" v-if="!hideCancleButton" :style="cancleStyle">{{cancleText}}</div>
  28. </div>
  29. </div>
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. props: {
  36. showDialog: {
  37. type: Boolean,
  38. default: true
  39. },
  40. title: {
  41. type: String,
  42. default: "添加信息"
  43. },
  44. width: {
  45. type: String,
  46. default: "50%"
  47. },
  48. confimText: {
  49. type: String,
  50. default: "保存"
  51. },
  52. cancleText: {
  53. type: String,
  54. default: "取消"
  55. },
  56. cancleStyle: {
  57. type: Object,
  58. default: () => {
  59. return {
  60. background: "#EEEEEE"
  61. };
  62. }
  63. },
  64. showBtns: {
  65. type: Boolean,
  66. default: true
  67. },
  68. hideCancleButton: {
  69. type: Boolean,
  70. default: false
  71. },
  72. distanceTop: {
  73. type: String,
  74. default: "15vh"
  75. },
  76. showBody: {
  77. type: Boolean,
  78. default: true
  79. },
  80. modal: {
  81. type: Boolean,
  82. default: true
  83. },
  84. destroyOnClose: {
  85. type: Boolean,
  86. default: false
  87. }
  88. },
  89. methods: {
  90. // 关闭弹窗
  91. closePropup() {
  92. this.$emit("update:showDialog", false);
  93. this.$emit("cancle", 1);
  94. },
  95. // 取消按钮点击
  96. cancle() {
  97. this.$emit("cancle", 2);
  98. },
  99. // 确定按钮点击
  100. confim() {
  101. this.$emit("confim");
  102. }
  103. }
  104. };
  105. </script>
  106. <style lang="scss" scoped>
  107. @import "../style/common.scss";
  108. .propup {
  109. .header {
  110. // width: 642px;
  111. height: 34px;
  112. background: #5386f6;
  113. position: relative;
  114. div {
  115. transform: rotate(45deg);
  116. color: #fff;
  117. position: absolute;
  118. top: -8px;
  119. right: 25px;
  120. font-size: 44px;
  121. cursor: pointer;
  122. }
  123. span {
  124. font-size: 16px;
  125. font-family: PingFang SC;
  126. font-weight: 400;
  127. color: #ffffff;
  128. }
  129. }
  130. .popup-container {
  131. // max-height: 400px;
  132. height: 80vh;
  133. overflow-y: auto;
  134. }
  135. .btns {
  136. margin-top: 20px;
  137. div {
  138. width: 108px;
  139. height: 40px;
  140. // background: #5386F6;
  141. border-radius: 3px;
  142. font-size: 18px;
  143. cursor: pointer;
  144. }
  145. .confim {
  146. background: #5386f6;
  147. color: #fff;
  148. margin-right: 30px;
  149. }
  150. .cancle {
  151. background: #eeeeee;
  152. color: #333333;
  153. }
  154. }
  155. }
  156. .propup ::v-deep .el-dialog {
  157. margin: 0 auto;
  158. }
  159. .propup ::v-deep.el-dialog__header {
  160. padding: 0;
  161. }
  162. .propup ::v-deep .el-dialog__body {
  163. padding: 18px 18px;
  164. }
  165. </style>