index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. @include useTheme() {
  92. display: flex;
  93. justify-content: center;
  94. align-items: center;
  95. width: 100%;
  96. height: 100vh;
  97. position: fixed;
  98. top: 0;
  99. left: 0;
  100. z-index: 10001;
  101. background: rgba(0, 0, 0, 0.39);
  102. .simple-dialog__container {
  103. position: relative;
  104. width: 400px;
  105. background: #fff;
  106. .simple-dialog__colse {
  107. width: 36px;
  108. height: 36px;
  109. font-size: 26px;
  110. position: absolute;
  111. top: 8px;
  112. right: 12px;
  113. text-align: center;
  114. line-height: 36px;
  115. color: #c2c2c2;
  116. cursor: pointer;
  117. }
  118. .simple-dialog__title {
  119. padding: 12px 24px;
  120. border-bottom: 1px solid #c2c2c2;
  121. .simple-dialog__title__text {
  122. font-size: 18px;
  123. color: #282828;
  124. }
  125. }
  126. .simple-dialog__content {
  127. padding: 24px 24px;
  128. .simple-dialog__content__text {
  129. font-size: 16px;
  130. color: #282828;
  131. }
  132. }
  133. .simple-dialog__footer {
  134. padding: 0 24px 24px;
  135. .simple-dialog__btn {
  136. width: 100%;
  137. height: 40px;
  138. text-align: center;
  139. line-height: 40px;
  140. font-size: 16px;
  141. border-radius: 4px;
  142. cursor: pointer;
  143. }
  144. .simple-dialog__confirm {
  145. color: #fff;
  146. background: fetch('color');
  147. }
  148. .simple-dialog__cancel {
  149. color: #666666;
  150. box-sizing: border-box;
  151. border: 1px solid #c2c2c2;
  152. margin-top: 16px;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. @media screen and (max-width: 768px) {
  160. .simple-dialog {
  161. @include useTheme() {
  162. display: flex;
  163. justify-content: center;
  164. align-items: center;
  165. width: 100%;
  166. height: 100vh;
  167. position: fixed;
  168. top: 0;
  169. left: 0;
  170. z-index: 10001;
  171. background: rgba(0, 0, 0, 0.39);
  172. .simple-dialog__container {
  173. position: relative;
  174. width: 76vw;
  175. min-height: 20vw;
  176. background: #fff;
  177. .simple-dialog__colse {
  178. width: 6.4vw;
  179. height: 6.4vw;
  180. font-size: 5vw;
  181. position: absolute;
  182. top: 3vw;
  183. right: 3vw;
  184. text-align: center;
  185. line-height: 6.4vw;
  186. color: #c2c2c2;
  187. }
  188. .simple-dialog__title {
  189. padding: 3vw 4.8vw;
  190. border-bottom: 1px solid #c2c2c2;
  191. .simple-dialog__title__text {
  192. font-size: 4.2vw;
  193. color: #282828;
  194. }
  195. }
  196. .simple-dialog__content {
  197. padding: 3vw 4.8vw;
  198. .simple-dialog__content__text {
  199. font-size: 3.6vw;
  200. color: #282828;
  201. }
  202. }
  203. .simple-dialog__footer {
  204. padding: 0 24px 24px;
  205. .simple-dialog__btn {
  206. width: 100%;
  207. height: 8.8vw;
  208. text-align: center;
  209. line-height: 8.8vw;
  210. font-size: 3.6vw;
  211. border-radius: 0.4vw;
  212. }
  213. .simple-dialog__confirm {
  214. color: #fff;
  215. background: fetch('color');
  216. }
  217. .simple-dialog__cancel {
  218. color: #666666;
  219. box-sizing: border-box;
  220. border: 1px solid #c2c2c2;
  221. margin-top: 2.8vw;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. }
  228. </style>