birthdayDialog.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <uni-popup ref="birthdayPopup" :animation="false" :is-mask-click="false"
  3. mask-background-color="rgba(0, 0, 0, 0.4)">
  4. <view class="phone-common-dialog birthday-dialog">
  5. <view class="common-body-box">
  6. <uni-calendar
  7. ref="calendar"
  8. :insert="true"
  9. @change="dataConfirm"
  10. />
  11. <view class="common-btn-box">
  12. <view class="not-confirm-btn" @click="handleClose">{{notBtn}}</view>
  13. <view class="confirm-btn" @click="confirmBtn">{{okBtn}}</view>
  14. </view>
  15. </view>
  16. </view>
  17. </uni-popup>
  18. </template>
  19. <script setup>
  20. import {ref,reactive} from "vue"
  21. import {toast} from "@/utils/common";
  22. const props = defineProps({
  23. notBtn: {
  24. type: String,
  25. require: true,
  26. default: '取消'
  27. },
  28. okBtn: {
  29. type: String,
  30. require: true,
  31. default: '确认'
  32. },
  33. });
  34. const time= ref('');
  35. const birthdayPopup = ref(null); // 索引
  36. const $emit = defineEmits(['confirm-btn'])
  37. function passClear(){
  38. time.value = '';
  39. }
  40. function dataConfirm(data){
  41. time.value = data.fulldate;
  42. }
  43. // 打开弹窗
  44. function handleShow() {
  45. birthdayPopup.value.open();
  46. }
  47. // 取消
  48. function handleClose() {
  49. passClear();
  50. birthdayPopup.value.close();
  51. }
  52. // 确认
  53. function confirmBtn(){
  54. if(time.value){
  55. $emit('confirm-btn',time.value);
  56. passClear();
  57. birthdayPopup.value.close();
  58. }else{
  59. toast('请选择日期')
  60. }
  61. }
  62. defineExpose({
  63. handleShow,
  64. handleClose
  65. })
  66. </script>
  67. <style>
  68. </style>