index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. {{ confirmText }}
  27. </div>
  28. <div
  29. class="simple-dialog__cancel simple-dialog__btn"
  30. v-if="cancel"
  31. @click="onCancel"
  32. >
  33. {{ cancelText }}
  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. confirmText: {
  47. type: String,
  48. default: '确定',
  49. },
  50. cancelText: {
  51. type: String,
  52. default: '取消',
  53. },
  54. value: {
  55. type: Boolean,
  56. default: false,
  57. },
  58. confirm: {
  59. type: Boolean,
  60. default: true,
  61. },
  62. cancel: {
  63. type: Boolean,
  64. default: true,
  65. },
  66. description: {
  67. type: String,
  68. default: '',
  69. },
  70. center: {
  71. type: Boolean,
  72. default: false,
  73. },
  74. },
  75. methods: {
  76. onCloseClick() {
  77. this.$emit('change', false)
  78. },
  79. onConfirm() {
  80. this.$emit('confirm')
  81. },
  82. onCancel() {
  83. this.$emit('cancel')
  84. },
  85. },
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. @media screen and (min-width: 768px) {
  90. .simple-dialog {
  91. display: flex;
  92. justify-content: center;
  93. align-items: center;
  94. width: 100%;
  95. height: 100vh;
  96. position: fixed;
  97. top: 0;
  98. left: 0;
  99. z-index: 10001;
  100. background: rgba(0, 0, 0, 0.39);
  101. .simple-dialog__container {
  102. position: relative;
  103. width: 400px;
  104. background: #fff;
  105. .simple-dialog__colse {
  106. width: 36px;
  107. height: 36px;
  108. font-size: 26px;
  109. position: absolute;
  110. top: 8px;
  111. right: 12px;
  112. text-align: center;
  113. line-height: 36px;
  114. color: #c2c2c2;
  115. cursor: pointer;
  116. }
  117. .simple-dialog__title {
  118. padding: 12px 24px;
  119. border-bottom: 1px solid #c2c2c2;
  120. .simple-dialog__title__text {
  121. font-size: 18px;
  122. color: #282828;
  123. }
  124. }
  125. .simple-dialog__content {
  126. padding: 24px 24px;
  127. .simple-dialog__content__text {
  128. font-size: 16px;
  129. color: #282828;
  130. }
  131. }
  132. .simple-dialog__footer {
  133. padding: 0 24px 24px;
  134. .simple-dialog__btn {
  135. width: 100%;
  136. height: 40px;
  137. text-align: center;
  138. line-height: 40px;
  139. font-size: 16px;
  140. border-radius: 4px;
  141. cursor: pointer;
  142. }
  143. .simple-dialog__confirm {
  144. background: #f3920d;
  145. color: #fff;
  146. }
  147. .simple-dialog__cancel {
  148. color: #666666;
  149. box-sizing: border-box;
  150. border: 1px solid #c2c2c2;
  151. margin-top: 16px;
  152. }
  153. }
  154. }
  155. }
  156. }
  157. @media screen and (max-width: 768px) {
  158. .simple-dialog {
  159. display: flex;
  160. justify-content: center;
  161. align-items: center;
  162. width: 100%;
  163. height: 100vh;
  164. position: fixed;
  165. top: 0;
  166. left: 0;
  167. z-index: 10001;
  168. background: rgba(0, 0, 0, 0.39);
  169. .simple-dialog__container {
  170. position: relative;
  171. width: 76vw;
  172. min-height: 20vw;
  173. background: #fff;
  174. .simple-dialog__colse {
  175. width: 6.4vw;
  176. height: 6.4vw;
  177. font-size: 5vw;
  178. position: absolute;
  179. top: 3vw;
  180. right: 3vw;
  181. text-align: center;
  182. line-height: 6.4vw;
  183. color: #c2c2c2;
  184. }
  185. .simple-dialog__title {
  186. padding: 3vw 4.8vw;
  187. border-bottom: 1px solid #c2c2c2;
  188. .simple-dialog__title__text {
  189. font-size: 4.2vw;
  190. color: #282828;
  191. }
  192. }
  193. .simple-dialog__content {
  194. padding: 3vw 4.8vw;
  195. .simple-dialog__content__text {
  196. font-size: 3.6vw;
  197. color: #282828;
  198. }
  199. }
  200. .simple-dialog__footer {
  201. padding: 0 24px 24px;
  202. .simple-dialog__btn {
  203. width: 100%;
  204. height: 8.8vw;
  205. text-align: center;
  206. line-height: 8.8vw;
  207. font-size: 3.6vw;
  208. border-radius: 0.4vw;
  209. }
  210. .simple-dialog__confirm {
  211. background: #f3920d;
  212. color: #fff;
  213. }
  214. .simple-dialog__cancel {
  215. color: #666666;
  216. box-sizing: border-box;
  217. border: 1px solid #c2c2c2;
  218. margin-top: 2.8vw;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. </style>