90 lines
1.7 KiB
Vue
90 lines
1.7 KiB
Vue
<template>
|
|
<view @click="handleSelectDate" class="pos-rlt">
|
|
<u-input :placeholder="placeholder" :fontSize="fontSize" :modelValue="inputValue"
|
|
:custom-style="`border-radius: 10rpx;padding: 8rpx 12rpx;${customStyle};`"
|
|
readonly="true"
|
|
>
|
|
<template v-slot:suffix>
|
|
<u-icon name="calendar" :size="fontSize*1.5"></u-icon>
|
|
</template>
|
|
</u-input>
|
|
<view class="pos-abt-all"></view>
|
|
</view>
|
|
<!-- 日历 -->
|
|
<u-calendar title="请选择日期范围" color="#B12D29" mode="range" rowHeight="90" closeOnClickOverlay :show="showCladar" :defaultDate="value" @confirm="handleClaOk" @close="handleSwitchCladar"
|
|
></u-calendar>
|
|
</template>
|
|
|
|
<script>
|
|
import { } from "@/common/untool"
|
|
export default {
|
|
computed: {
|
|
inputValue() {
|
|
const val = this.value
|
|
return val && (val.length > 1 ? val.join("~") : val[0])
|
|
}
|
|
},
|
|
props: {
|
|
value: {
|
|
default () {
|
|
return ''
|
|
}
|
|
},
|
|
placeholder:{
|
|
default () {
|
|
return '请选择日期'
|
|
}
|
|
},
|
|
fontSize: {
|
|
default () {
|
|
return 26
|
|
}
|
|
},
|
|
customStyle:{
|
|
default () {
|
|
return ''
|
|
}
|
|
},
|
|
placeholderStyle:{
|
|
default () {
|
|
return ''
|
|
}
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
showCladar: false
|
|
}
|
|
},
|
|
created() {
|
|
|
|
},
|
|
onHide() {
|
|
|
|
},
|
|
destroyed() {},
|
|
|
|
methods: {
|
|
handleSelectDate() {
|
|
this.handleSwitchCladar()
|
|
},
|
|
handleChange(val){
|
|
this.$emit('change', val)
|
|
this.$emit('update:value', val)
|
|
},
|
|
handleClaOk(res){
|
|
const ary = Object.values(res)
|
|
const val = [ary[0], ary[ary.length-1]]
|
|
this.handleChange(val)
|
|
this.handleSwitchCladar()
|
|
},
|
|
handleSwitchCladar() {
|
|
this.showCladar = !this.showCladar
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
|
|
</style> |