uu
This commit is contained in:
parent
7bb4e42b54
commit
7ed62600dc
90
components/tpx-date-input/tpx-date-input.vue
Normal file
90
components/tpx-date-input/tpx-date-input.vue
Normal file
@ -0,0 +1,90 @@
|
||||
<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>
|
||||
@ -31,6 +31,9 @@
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
|
||||
@ -3,11 +3,15 @@
|
||||
:custom-style="`border-radius: 10rpx;padding: 8rpx 12rpx;${customStyle};`"
|
||||
@change="handleChange"
|
||||
>
|
||||
<template v-slot:prefix>
|
||||
<template v-if="iconPos == 'left'" v-slot:prefix>
|
||||
<u-icon @click="handleScan" name="scan" :size="fontSize*1.5"></u-icon>
|
||||
</template>
|
||||
|
||||
<template v-if="iconPos == 'right'" v-slot:suffix>
|
||||
<u-icon @click="handleScan" name="scan" :size="fontSize*1.5"></u-icon>
|
||||
</template>
|
||||
</u-input>
|
||||
<tpx-physics-scan onChange="handleChange"></tpx-physics-scan>
|
||||
<tpx-physics-scan @onChange="handleChange"></tpx-physics-scan>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -15,6 +19,7 @@
|
||||
export default {
|
||||
|
||||
props: {
|
||||
|
||||
value: {
|
||||
default () {
|
||||
return ''
|
||||
@ -30,6 +35,11 @@
|
||||
return 26
|
||||
}
|
||||
},
|
||||
iconPos: {
|
||||
default () {
|
||||
return "left"
|
||||
}
|
||||
},
|
||||
customStyle:{
|
||||
default () {
|
||||
return ''
|
||||
|
||||
Loading…
Reference in New Issue
Block a user