邓宏
2 years ago
7 changed files with 195 additions and 29 deletions
@ -0,0 +1,109 @@ |
|||
<style lang="less"> |
|||
.d-dateRange{ |
|||
flex-shrink: 0; |
|||
display:flex; |
|||
align-items: center; |
|||
margin:20rpx 30rpx; |
|||
&>text{ |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: space-between; |
|||
background:#fff; |
|||
font-size:24rpx; |
|||
color:#333; |
|||
height:48rpx; |
|||
position: relative; |
|||
padding:0 30rpx 0 10rpx; |
|||
min-width:220rpx; |
|||
box-sizing: border-box; |
|||
border-radius: 8rpx; |
|||
&:first-child{margin-right:28rpx;} |
|||
&:nth-child(2){margin-left:28rpx;} |
|||
&.noDate{ |
|||
color:#999; |
|||
} |
|||
.plant-youbian,.plant-zengjia{ |
|||
font-size:24rpx; |
|||
height:48rpx; |
|||
width:40rpx; |
|||
text-align: center; |
|||
line-height: 48rpx; |
|||
position:absolute; |
|||
top:0; |
|||
right:0; |
|||
&:before{ |
|||
display: inline-block; |
|||
transform: rotate(90deg); |
|||
} |
|||
} |
|||
.plant-zengjia{ |
|||
z-index: 100; |
|||
&:before{ |
|||
transform: rotate(45deg); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
</style> |
|||
<template> |
|||
<view class="d-dateRange"> |
|||
<text :class="{noDate:!startTime}" @click="type='start';show=true"> |
|||
{{startTime||"请选择开始日期"}} |
|||
<text v-if="startTime" class="plant-zengjia" @click.stop="startTime=''"/> |
|||
<text v-else class="plant-youbian"/> |
|||
</text> |
|||
~ |
|||
<text :class="{noDate:!endTime}" @click="type='end';show=true"> |
|||
{{endTime||"请选择结束日期"}} |
|||
<text class="plant-youbian"/> |
|||
<text v-if="endTime" class="plant-zengjia" @click.stop="endTime=''"/> |
|||
<text v-else class="plant-youbian"/> |
|||
</text> |
|||
|
|||
<u-datetime-picker |
|||
:show="show" |
|||
mode="date" |
|||
style="flex:0;" |
|||
closeOnClickOverlay |
|||
@close="show=false" |
|||
@cancel="show=false" |
|||
:minDate="type=='end'&&startTime?new Date(startTime).getTime():new Date().set('y',-15).getTime()" |
|||
:maxDate="type=='start'&&endTime?new Date(endTime).getTime():new Date().set('y',15).getTime()" |
|||
:value=" type=='start'&&startTime|| type=='end'&&endTime || new Date().format('yyyy-MM-dd')" |
|||
@confirm="confirm"/> |
|||
</view> |
|||
</template> |
|||
<script> |
|||
export default{ |
|||
data(){ |
|||
return{ |
|||
startTime:"", |
|||
endTime:"", |
|||
type:"start", |
|||
show:false, |
|||
} |
|||
}, |
|||
computed:{ |
|||
date(){ |
|||
return[this.startTime,this.endTime] |
|||
} |
|||
}, |
|||
watch:{ |
|||
date(n){ |
|||
if(n[0]&&n[1]||!n[0]&&!n[1]){ |
|||
this.$emit("date",n) |
|||
} |
|||
} |
|||
}, |
|||
methods:{ |
|||
confirm(e){ |
|||
if(this.type=='start'){ |
|||
this.startTime=new Date(e.value).format('yyyy-MM-dd') |
|||
}else{ |
|||
this.endTime=new Date(e.value).format('yyyy-MM-dd') |
|||
} |
|||
this.show=false |
|||
}, |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,81 @@ |
|||
{ |
|||
"id": "d-dateRange", |
|||
"displayName": "d-dateRange", |
|||
"version": "1.0.0", |
|||
"description": "d-dateRange", |
|||
"keywords": [ |
|||
"d-dateRange" |
|||
], |
|||
"repository": "", |
|||
"engines": { |
|||
"HBuilderX": "^3.1.0" |
|||
}, |
|||
"dcloudext": { |
|||
"type": "component-vue", |
|||
"sale": { |
|||
"regular": { |
|||
"price": "0.00" |
|||
}, |
|||
"sourcecode": { |
|||
"price": "0.00" |
|||
} |
|||
}, |
|||
"contact": { |
|||
"qq": "" |
|||
}, |
|||
"declaration": { |
|||
"ads": "", |
|||
"data": "", |
|||
"permissions": "" |
|||
}, |
|||
"npmurl": "" |
|||
}, |
|||
"uni_modules": { |
|||
"dependencies": [], |
|||
"encrypt": [], |
|||
"platforms": { |
|||
"cloud": { |
|||
"tcb": "u", |
|||
"aliyun": "u" |
|||
}, |
|||
"client": { |
|||
"Vue": { |
|||
"vue2": "u", |
|||
"vue3": "u" |
|||
}, |
|||
"App": { |
|||
"app-vue": "u", |
|||
"app-nvue": "u" |
|||
}, |
|||
"H5-mobile": { |
|||
"Safari": "u", |
|||
"Android Browser": "u", |
|||
"微信浏览器(Android)": "u", |
|||
"QQ浏览器(Android)": "u" |
|||
}, |
|||
"H5-pc": { |
|||
"Chrome": "u", |
|||
"IE": "u", |
|||
"Edge": "u", |
|||
"Firefox": "u", |
|||
"Safari": "u" |
|||
}, |
|||
"小程序": { |
|||
"微信": "u", |
|||
"阿里": "u", |
|||
"百度": "u", |
|||
"字节跳动": "u", |
|||
"QQ": "u", |
|||
"钉钉": "u", |
|||
"快手": "u", |
|||
"飞书": "u", |
|||
"京东": "u" |
|||
}, |
|||
"快应用": { |
|||
"华为": "u", |
|||
"联盟": "u" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1 @@ |
|||
# d-dateRange |
Loading…
Reference in new issue