my-dialog.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <!-- 自定义对话框 -->
  2. <template>
  3. <u-modal
  4. :z-index="zIndex"
  5. v-model="modal"
  6. :show-title="false"
  7. :show-cancel-button="false"
  8. :show-confirm-button="false"
  9. :mask-close-able="maskCloseAble"
  10. >
  11. <view class="container">
  12. <!-- 标题 -->
  13. <view v-if="showTitle" class="title" :style="titleStyle">{{ title }}</view>
  14. <!-- 中间显示内容 -->
  15. <view class="content flex-column-center">
  16. <slot name="content"></slot>
  17. </view>
  18. <!-- 底部按钮 -->
  19. <view class="btn-wrap flex-between" style="width: 470rpx;margin: 30rpx auto;" v-if="showCancelButton || showConfirmButton">
  20. <view v-if="showCancelButton" class="btn" style="margin-right: 44rpx;">
  21. <u-button class="cancelBtn" type="primary" :style="{...cancelStyle,...btnStyle}" @click="cancel">{{ cancelText }}</u-button>
  22. </view>
  23. <view v-if="showConfirmButton" class="btn">
  24. <u-button class="cfmBtn" type="primary" :style="{...cfmStyle,...btnStyle}" @click="cfm">{{ cfmText }}</u-button>
  25. </view>
  26. </view>
  27. </view>
  28. </u-modal>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. modal: false
  35. }
  36. },
  37. methods:{
  38. cfm() {
  39. this.$emit('cfmClick')
  40. },
  41. cancel() {
  42. this.$emit('cancelClick')
  43. }
  44. },
  45. watch: {
  46. value: {
  47. handler (n) {
  48. this.modal = n
  49. },
  50. immediate: true
  51. },
  52. modal (n) {
  53. this.$emit('input', n)
  54. if(!n) {
  55. this.$emit('cancelClick')
  56. }
  57. }
  58. },
  59. props: {
  60. value: {
  61. type: Boolean,
  62. default: false,
  63. require: true
  64. },
  65. zIndex: '',
  66. title: {
  67. type: String,
  68. default: '标题'
  69. },
  70. maskCloseAble: {
  71. type: Boolean,
  72. default: true
  73. },
  74. showDialog: {
  75. type: Boolean,
  76. default: false
  77. },
  78. showTitle: {
  79. type: Boolean,
  80. default: true
  81. },
  82. showCancelButton: {
  83. type: Boolean,
  84. default: true
  85. },
  86. titleStyle: {
  87. type: Object,
  88. default: () => {
  89. return {}
  90. }
  91. },
  92. cancelStyle: {
  93. type: Object,
  94. default: () => {
  95. return {}
  96. }
  97. },
  98. cfmStyle: {
  99. type: Object,
  100. default: () => {
  101. return {}
  102. }
  103. },
  104. btnStyle: {
  105. type: Object,
  106. default: () => {
  107. return {
  108. height: '57rpx',
  109. width: '200rpx'
  110. }
  111. }
  112. },
  113. showConfirmButton: {
  114. type: Boolean,
  115. default: true
  116. },
  117. cancelText:{
  118. type: String,
  119. default: '取消'
  120. },
  121. cfmText:{
  122. type: String,
  123. default: '确认'
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. @import '../../static/css/mycss.scss';
  130. /deep/ .u-mode-center-box{
  131. overflow: visible !important;
  132. min-height: 0;
  133. }
  134. /deep/ .u-drawer__scroll-view > .uni-scroll-view > .uni-scroll-view {
  135. overflow: visible !important;
  136. }
  137. /deep/ .u-model{
  138. border-radius: 8px;
  139. overflow: visible;
  140. }
  141. .container {
  142. height: 100%;
  143. .title {
  144. padding: 40rpx 0;
  145. text-align: center;
  146. font-size: 36rpx;
  147. font-weight: bold;
  148. }
  149. .content{
  150. }
  151. .btn-wrap {
  152. .btn{
  153. flex: 1;
  154. .cancelBtn {
  155. width: 100%;
  156. background-color: gray;
  157. }
  158. .cfmBtn {
  159. width: 100%;
  160. }
  161. }
  162. }
  163. }
  164. </style>