Propup.vue 3.7 KB

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