This commit is contained in:
2025-05-13 10:45:51 +08:00
parent ce0587d2b6
commit ddfd747704
12 changed files with 208 additions and 18 deletions

View File

@@ -1,8 +1,10 @@
<script setup>
import timeIcon from "../static/icons/time.png";
import {ref} from "vue";
const modalValue = defineModel();
const {placeholder, fields} = defineProps({
const DateTimeRef = ref();
const {placeholder, fields, type} = defineProps({
placeholder: {
type: String,
default: "请选择时间",
@@ -10,23 +12,33 @@ const {placeholder, fields} = defineProps({
fields: {
type: String,
default: 'day'
},
type: {
type: Number,
default: 2
}
});
const success = ({detail: {value}}) => {
modalValue.value = value;
const open = () => {
DateTimeRef.value.show();
}
const success = ({result}) => {
modalValue.value = result;
}
</script>
<template>
<picker mode="date" :class="[!$slots.default ? 'x-date-input' : '']" @change="success" :fields="fields">
<view v-if="!$slots.default" class="!flex items-center justify-center gap-[20rpx]">
<view :class="[!$slots.default ? 'x-date-input' : '']">
<view v-if="!$slots.default" class="!flex items-center justify-center gap-[20rpx]" @click="open">
<image class="!size-[24rpx]" :src="timeIcon"></image>
<text v-if="!modalValue" class="text-[#666]">{{ placeholder }}</text>
<text class="test-24r" v-else>{{ modalValue }}</text>
</view>
<slot v-else></slot>
</picker>
</view>
<tui-datetime ref="DateTimeRef" :type="type" @confirm="success"></tui-datetime>
</template>
<style lang="scss" scoped>