index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <div class="simple-dialog" v-if="value">
  3. <div class="simple-dialog__container">
  4. <span
  5. class="el-icon-close simple-dialog__colse"
  6. @click="onCloseClick"
  7. ></span>
  8. <div class="simple-dialog__title">
  9. <span class="simple-dialog__title__text">提示</span>
  10. <slot name="title"></slot>
  11. </div>
  12. <div
  13. class="simple-dialog__content"
  14. :style="{ textAlign: center && 'center' }"
  15. >
  16. <slot></slot>
  17. <span class="simple-dialog__content__text" v-text="description"></span>
  18. </div>
  19. <div class="simple-dialog__footer">
  20. <slot name="footer" v-if="!confirm || !cancel"></slot>
  21. <div
  22. class="simple-dialog__confirm simple-dialog__btn"
  23. v-if="confirm"
  24. @click="onConfirm"
  25. >
  26. 确定
  27. </div>
  28. <div
  29. class="simple-dialog__cancel simple-dialog__btn"
  30. v-if="cancel"
  31. @click="onCancel"
  32. >
  33. 取消
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. export default {
  41. model: {
  42. prop: 'value',
  43. event: 'change',
  44. },
  45. props: {
  46. value: {
  47. type: Boolean,
  48. default: false,
  49. },
  50. confirm: {
  51. type: Boolean,
  52. default: true,
  53. },
  54. cancel: {
  55. type: Boolean,
  56. default: true,
  57. },
  58. description: {
  59. type: String,
  60. default: '',
  61. },
  62. center: {
  63. type: Boolean,
  64. default: false,
  65. },
  66. },
  67. methods: {
  68. onCloseClick() {
  69. this.$emit('change', false)
  70. },
  71. onConfirm() {
  72. this.$emit('confirm')
  73. },
  74. onCancel() {
  75. this.$emit('cancel')
  76. },
  77. },
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. @media screen and (min-width: 768px) {
  82. .simple-dialog {
  83. display: flex;
  84. justify-content: center;
  85. align-items: center;
  86. width: 100%;
  87. height: 100vh;
  88. position: fixed;
  89. top: 0;
  90. left: 0;
  91. background: rgba(0, 0, 0, 0.39);
  92. .simple-dialog__container {
  93. position: relative;
  94. width: 400px;
  95. background: #fff;
  96. .simple-dialog__colse {
  97. width: 36px;
  98. height: 36px;
  99. font-size: 26px;
  100. position: absolute;
  101. top: 8px;
  102. right: 12px;
  103. text-align: center;
  104. line-height: 36px;
  105. color: #c2c2c2;
  106. cursor: pointer;
  107. }
  108. .simple-dialog__title {
  109. padding: 12px 24px;
  110. border-bottom: 1px solid #c2c2c2;
  111. .simple-dialog__title__text {
  112. font-size: 18px;
  113. color: #282828;
  114. }
  115. }
  116. .simple-dialog__content {
  117. padding: 24px 24px;
  118. .simple-dialog__content__text {
  119. font-size: 16px;
  120. color: #282828;
  121. }
  122. }
  123. .simple-dialog__footer {
  124. padding: 0 24px 24px;
  125. .simple-dialog__btn {
  126. width: 100%;
  127. height: 40px;
  128. text-align: center;
  129. line-height: 40px;
  130. font-size: 16px;
  131. border-radius: 4px;
  132. cursor: pointer;
  133. }
  134. .simple-dialog__confirm {
  135. background: #f3920d;
  136. color: #fff;
  137. }
  138. .simple-dialog__cancel {
  139. color: #666666;
  140. box-sizing: border-box;
  141. border: 1px solid #c2c2c2;
  142. margin-top: 16px;
  143. }
  144. }
  145. }
  146. }
  147. }
  148. @media screen and (max-width: 768px) {
  149. .simple-dialog {
  150. display: flex;
  151. justify-content: center;
  152. align-items: center;
  153. width: 100%;
  154. height: 100vh;
  155. position: fixed;
  156. top: 0;
  157. left: 0;
  158. background: rgba(0, 0, 0, 0.39);
  159. .simple-dialog__container {
  160. position: relative;
  161. width: 76vw;
  162. min-height: 20vw;
  163. background: #fff;
  164. .simple-dialog__colse {
  165. width: 6.4vw;
  166. height: 6.4vw;
  167. font-size: 5vw;
  168. position: absolute;
  169. top: 3vw;
  170. right: 3vw;
  171. text-align: center;
  172. line-height: 6.4vw;
  173. color: #c2c2c2;
  174. }
  175. .simple-dialog__title {
  176. padding: 3vw 4.8vw;
  177. border-bottom: 1px solid #c2c2c2;
  178. .simple-dialog__title__text {
  179. font-size: 4.2vw;
  180. color: #282828;
  181. }
  182. }
  183. .simple-dialog__content {
  184. padding: 3vw 4.8vw;
  185. .simple-dialog__content__text {
  186. font-size: 3.6vw;
  187. color: #282828;
  188. }
  189. }
  190. .simple-dialog__footer {
  191. padding: 0 4.8vw 7vw;
  192. .simple-dialog__confirm {
  193. width: 100%;
  194. height: 8.8vw;
  195. text-align: center;
  196. background: #f3920d;
  197. color: #fff;
  198. line-height: 8.8vw;
  199. font-size: 3.6vw;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. </style>