Files
hiddendangerDingtalk/components/form/date-li.vue
T
2025-03-28 09:16:48 +08:00

103 lines
1.9 KiB
Vue

<!-- label 为字段名 -->
<!-- isSelectAuto 默认为true false只选择年月日 -->
<!-- isBorder 是否有边框 默认 true有-->
<template>
<view class="input-box" :class="isBorder ? '' : 'border-none'">
<view class="label"><text>*</text> {{label}}</view>
<view @click="onClickDate" class="date-box">
<view v-if="value" class="time">{{value}}</view>
<view v-else class="time placeholder">请选择{{label}}</view>
<image src="../../static/jiantou.png"></image>
</view>
</view>
</template>
<script>
import { watch } from "vue";
export default {
props: {
value: {
default: ''
},
isSelectAuto: {
default: true
},
isBorder: {
default: true
},
label:{
default: '时间'
}
},
data() {
return {
sea: ''
};
},
methods: {
// 点击选择日期
onClickDate () {
let formtStr = 'yyyy-MM-dd HH:mm'
this.isSelectAuto ? formtStr = 'yyyy-MM-dd HH:mm' : formtStr = 'HH:mm:ss'
let date = new Date()
uni.datePicker({
format: formtStr,
currentDate: this.value ? this.value : (date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()),
success: (res) => {
this.$emit('input', res.date)
},
});
},
onClickInput(e) {
},
}
}
</script>
<style lang='scss' scoped>
.input-box{
width: 100%;
height: 100rpx;
background: #fff;
padding: 0 16rpx;
box-sizing: border-box;
display: flex;
align-items: center;
font-size: 28rpx;
border-bottom: 2rpx dashed #D9D9D9;
.label{
width: 200rpx;
line-height: 40rpx;
display: flex;
text{
display: block;
width: 14rpx;
color: #E14343;
margin-right: 8rpx;
line-height: 40rpx;
}
}
.date-box{
flex: 1;
width: 100%;
height: 100rpx;
display: flex;
justify-content: flex-end;
align-items: center;
image{
width: 32rpx;
height: 32rpx;
margin-left: 4rpx;
}
.placeholder{
color: #999999;
}
}
}
.border-none{
border: none;
}
</style>