reminderTimePopup.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <popup
  3. v-model:show="showValue"
  4. class="reminder-time-popup"
  5. closeable
  6. >
  7. <div class="popup-content">
  8. <!-- 标题 -->
  9. <div class="popup-header">
  10. <span class="required">*</span>
  11. <span class="popup-title">请选择下次提醒时间</span>
  12. </div>
  13. <!-- 时间选择输入框 -->
  14. <div class="time-input-wrapper">
  15. <el-date-picker
  16. v-model="selectedTime"
  17. type="date"
  18. size="large"
  19. placeholder="请选择日期"
  20. format="YYYY-MM-DD"
  21. value-format="YYYY-MM-DD"
  22. style="width: 100%"
  23. :editable="false"
  24. :clearable="false"
  25. />
  26. </div>
  27. <!-- 确认按钮 -->
  28. <div class="btn-confirm" @click="handleConfirm">确认</div>
  29. </div>
  30. </popup>
  31. </template>
  32. <script setup>
  33. import { Popup } from "vant";
  34. import { computed, ref } from "vue";
  35. import { ElMessage } from "element-plus";
  36. const props = defineProps({
  37. // 控制弹窗显示/隐藏
  38. show: {
  39. type: Boolean,
  40. default: false,
  41. },
  42. });
  43. const emit = defineEmits(["update:show", "confirm"]);
  44. // 处理v-model双向绑定
  45. const showValue = computed({
  46. get: () => props.show,
  47. set: (value) => emit("update:show", value),
  48. });
  49. // 选中的时间
  50. const selectedTime = ref("");
  51. // 确认按钮点击
  52. const handleConfirm = () => {
  53. if (!selectedTime.value) {
  54. ElMessage.warning("请选择日期");
  55. return;
  56. }
  57. emit("confirm", selectedTime.value);
  58. emit("update:show", false);
  59. // 重置日期
  60. selectedTime.value = "";
  61. };
  62. </script>
  63. <style scoped lang="scss">
  64. .reminder-time-popup {
  65. width: 90%;
  66. padding: 24px 18px 20px;
  67. border-radius: 8px;
  68. background: linear-gradient(360deg, #FFFFFF 74.2%, #D1EBFF 100%);
  69. ::v-deep {
  70. .van-popup__close-icon {
  71. color: #333333;
  72. }
  73. }
  74. .popup-content {
  75. display: flex;
  76. flex-direction: column;
  77. }
  78. .popup-header {
  79. display: flex;
  80. align-items: center;
  81. margin-bottom: 16px;
  82. .required {
  83. color: #ff4d4f;
  84. margin-right: 4px;
  85. font-size: 16px;
  86. }
  87. .popup-title {
  88. font-size: 16px;
  89. }
  90. }
  91. .time-input-wrapper {
  92. margin-bottom: 24px;
  93. }
  94. .btn-confirm {
  95. padding: 10px;
  96. background: #2199f8;
  97. color: #ffffff;
  98. border-radius: 25px;
  99. font-size: 16px;
  100. text-align: center;
  101. }
  102. }
  103. </style>