2025-03-28 09:37:10 +08:00
|
|
|
<script setup>
|
|
|
|
|
import timeIcon from "../static/icons/time.png";
|
2025-05-13 10:45:51 +08:00
|
|
|
import {ref} from "vue";
|
2025-03-28 09:37:10 +08:00
|
|
|
|
|
|
|
|
const modalValue = defineModel();
|
2025-05-13 10:45:51 +08:00
|
|
|
const DateTimeRef = ref();
|
|
|
|
|
const {placeholder, fields, type} = defineProps({
|
2025-03-28 09:37:10 +08:00
|
|
|
placeholder: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: "请选择时间",
|
2025-04-21 15:19:28 +08:00
|
|
|
},
|
|
|
|
|
fields: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'day'
|
2025-05-13 10:45:51 +08:00
|
|
|
},
|
|
|
|
|
type: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 2
|
2025-03-28 09:37:10 +08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-05-13 10:45:51 +08:00
|
|
|
const open = () => {
|
|
|
|
|
DateTimeRef.value.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const success = ({result}) => {
|
|
|
|
|
modalValue.value = result;
|
2025-03-28 09:37:10 +08:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-05-13 10:45:51 +08:00
|
|
|
<view :class="[!$slots.default ? 'x-date-input' : '']">
|
|
|
|
|
<view v-if="!$slots.default" class="!flex items-center justify-center gap-[20rpx]" @click="open">
|
2025-04-21 15:19:28 +08:00
|
|
|
<image class="!size-[24rpx]" :src="timeIcon"></image>
|
2025-03-28 09:37:10 +08:00
|
|
|
<text v-if="!modalValue" class="text-[#666]">{{ placeholder }}</text>
|
2025-04-21 15:19:28 +08:00
|
|
|
<text class="test-24r" v-else>{{ modalValue }}</text>
|
2025-03-28 09:37:10 +08:00
|
|
|
</view>
|
2025-04-21 15:19:28 +08:00
|
|
|
<slot v-else></slot>
|
2025-05-13 10:45:51 +08:00
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<tui-datetime ref="DateTimeRef" :type="type" @confirm="success"></tui-datetime>
|
2025-03-28 09:37:10 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.x-date-input {
|
|
|
|
|
background-color: #F2F3F5;
|
|
|
|
|
padding: 14rpx 0;
|
|
|
|
|
flex-grow: 1;
|
|
|
|
|
text-align: center;
|
|
|
|
|
border-radius: 4rpx;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
</style>
|