Commit e2b958b4 authored by 潘永坪's avatar 潘永坪

日历禁用修改

parent 79627ed6
......@@ -3,10 +3,9 @@
:show="showPop"
@confirm="onConfirm"
@close="showPop=false"
:maxDate="maxDate"
:minDate='minDate'
:defaultDate="defaultDate"
:formatter='formatter'
:customList='customList'
ref="calendar2"
rowHeight='112'
round='20'
......@@ -21,10 +20,14 @@ export default {
dateList:{
handler(newValue, oldValue){
if(newValue&&newValue.length>0){
this.maxDate=newValue[newValue.length-1].startTime.substr(0,10)
//默认和最小日期都为第一天
this.minDate=newValue[0].startTime.substr(0,10)
this.customList=newValue.map(item=>{
return item.startTime.substr(0,10)
})
this.defaultDate=newValue[0].startTime.substr(0,10)
//由于传入了customList,最大日期和最小日期可以取消
// this.maxDate=newValue[newValue.length-1].startTime.substr(0,10)
// //默认和最小日期都为第一天
// this.minDate=newValue[0].startTime.substr(0,10)
}
},
deep:true,
......@@ -37,6 +40,7 @@ export default {
defaultDate:'', //默认日期
maxDate:'',//最大日期
minDate:'',//最小日期
customList:[],//转化之后的日期列表
}
},
mounted() {
......@@ -67,9 +71,6 @@ export default {
// day.dot = true
// }
// })
// if (!day.bottomInfo) {
// day.type = 'disabled'
// }
return day
}
......
......@@ -294,7 +294,9 @@ export default {
) ||
dayjs(date).isAfter(
dayjs(maxDate).format('YYYY-MM-DD')
),
)||
//自己修改的--用于禁用最大和最小日期之间的日期
this.customList.indexOf(date) === -1,
// 返回一个日期对象,供外部的formatter获取当前日期的年月日等信息,进行加工处理
date: new Date(date),
bottomInfo,
......@@ -331,7 +333,7 @@ export default {
})
// #endif
// #ifdef MP-WEIXIN
this.scrollTop = this.months[_index].top || 0;
this.scrollTop = this.months[_index].top || 0
// #endif
}
},
......@@ -356,16 +358,16 @@ export default {
// 获取默认日期的下标
if (!this.defaultDate) {
// 如果没有设置默认日期,则将当天日期设置为默认选中的日期
const selected = dayjs().format("YYYY-MM")
const selected = dayjs().format('YYYY-MM')
this.scrollIntoDefaultMonth(selected)
return
}
let selected = dayjs().format("YYYY-MM");
let selected = dayjs().format('YYYY-MM')
// 单选模式,可以是字符串或数组,Date对象等
if (!uni.$u.test.array(this.defaultDate)) {
selected = dayjs(this.defaultDate).format("YYYY-MM")
selected = dayjs(this.defaultDate).format('YYYY-MM')
} else {
selected = dayjs(this.defaultDate[0]).format("YYYY-MM");
selected = dayjs(this.defaultDate[0]).format('YYYY-MM')
}
this.scrollIntoDefaultMonth(selected)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment