Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
U
uni-pdtravel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
panyongping
uni-pdtravel
Commits
e2b958b4
Commit
e2b958b4
authored
Feb 01, 2024
by
潘永坪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日历禁用修改
parent
79627ed6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
256 additions
and
253 deletions
+256
-253
calendar.vue
pages/scenic/scenicComponents/calendar.vue
+9
-8
u-calendar.vue
uview-ui/components/u-calendar/u-calendar.vue
+247
-245
No files found.
pages/scenic/scenicComponents/calendar.vue
View file @
e2b958b4
...
@@ -3,10 +3,9 @@
...
@@ -3,10 +3,9 @@
:show=
"showPop"
:show=
"showPop"
@
confirm=
"onConfirm"
@
confirm=
"onConfirm"
@
close=
"showPop=false"
@
close=
"showPop=false"
:maxDate=
"maxDate"
:minDate=
'minDate'
:defaultDate=
"defaultDate"
:defaultDate=
"defaultDate"
:formatter=
'formatter'
:formatter=
'formatter'
:customList=
'customList'
ref=
"calendar2"
ref=
"calendar2"
rowHeight=
'112'
rowHeight=
'112'
round=
'20'
round=
'20'
...
@@ -21,10 +20,14 @@ export default {
...
@@ -21,10 +20,14 @@ export default {
dateList
:{
dateList
:{
handler
(
newValue
,
oldValue
){
handler
(
newValue
,
oldValue
){
if
(
newValue
&&
newValue
.
length
>
0
){
if
(
newValue
&&
newValue
.
length
>
0
){
this
.
maxDate
=
newValue
[
newValue
.
length
-
1
].
startTime
.
substr
(
0
,
10
)
this
.
customList
=
newValue
.
map
(
item
=>
{
//默认和最小日期都为第一天
return
item
.
startTime
.
substr
(
0
,
10
)
this
.
minDate
=
newValue
[
0
].
startTime
.
substr
(
0
,
10
)
}
)
this
.
defaultDate
=
newValue
[
0
].
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
,
deep
:
true
,
...
@@ -37,6 +40,7 @@ export default {
...
@@ -37,6 +40,7 @@ export default {
defaultDate
:
''
,
//默认日期
defaultDate
:
''
,
//默认日期
maxDate
:
''
,
//最大日期
maxDate
:
''
,
//最大日期
minDate
:
''
,
//最小日期
minDate
:
''
,
//最小日期
customList
:[],
//转化之后的日期列表
}
}
},
},
mounted
()
{
mounted
()
{
...
@@ -67,9 +71,6 @@ export default {
...
@@ -67,9 +71,6 @@ export default {
// day.dot = true
// day.dot = true
// }
// }
// })
// })
// if (!day.bottomInfo) {
// day.type = 'disabled'
// }
return
day
return
day
}
}
...
...
uview-ui/components/u-calendar/u-calendar.vue
View file @
e2b958b4
...
@@ -294,7 +294,9 @@ export default {
...
@@ -294,7 +294,9 @@ export default {
)
||
)
||
dayjs
(
date
).
isAfter
(
dayjs
(
date
).
isAfter
(
dayjs
(
maxDate
).
format
(
'YYYY-MM-DD'
)
dayjs
(
maxDate
).
format
(
'YYYY-MM-DD'
)
),
)
||
//自己修改的--用于禁用最大和最小日期之间的日期
this
.
customList
.
indexOf
(
date
)
===
-
1
,
// 返回一个日期对象,供外部的formatter获取当前日期的年月日等信息,进行加工处理
// 返回一个日期对象,供外部的formatter获取当前日期的年月日等信息,进行加工处理
date
:
new
Date
(
date
),
date
:
new
Date
(
date
),
bottomInfo
,
bottomInfo
,
...
@@ -331,7 +333,7 @@ export default {
...
@@ -331,7 +333,7 @@ export default {
})
})
// #endif
// #endif
// #ifdef MP-WEIXIN
// #ifdef MP-WEIXIN
this
.
scrollTop
=
this
.
months
[
_index
].
top
||
0
;
this
.
scrollTop
=
this
.
months
[
_index
].
top
||
0
// #endif
// #endif
}
}
},
},
...
@@ -356,16 +358,16 @@ export default {
...
@@ -356,16 +358,16 @@ export default {
// 获取默认日期的下标
// 获取默认日期的下标
if
(
!
this
.
defaultDate
)
{
if
(
!
this
.
defaultDate
)
{
// 如果没有设置默认日期,则将当天日期设置为默认选中的日期
// 如果没有设置默认日期,则将当天日期设置为默认选中的日期
const
selected
=
dayjs
().
format
(
"YYYY-MM"
)
const
selected
=
dayjs
().
format
(
'YYYY-MM'
)
this
.
scrollIntoDefaultMonth
(
selected
)
this
.
scrollIntoDefaultMonth
(
selected
)
return
return
}
}
let
selected
=
dayjs
().
format
(
"YYYY-MM"
);
let
selected
=
dayjs
().
format
(
'YYYY-MM'
)
// 单选模式,可以是字符串或数组,Date对象等
// 单选模式,可以是字符串或数组,Date对象等
if
(
!
uni
.
$u
.
test
.
array
(
this
.
defaultDate
))
{
if
(
!
uni
.
$u
.
test
.
array
(
this
.
defaultDate
))
{
selected
=
dayjs
(
this
.
defaultDate
).
format
(
"YYYY-MM"
)
selected
=
dayjs
(
this
.
defaultDate
).
format
(
'YYYY-MM'
)
}
else
{
}
else
{
selected
=
dayjs
(
this
.
defaultDate
[
0
]).
format
(
"YYYY-MM"
);
selected
=
dayjs
(
this
.
defaultDate
[
0
]).
format
(
'YYYY-MM'
)
}
}
this
.
scrollIntoDefaultMonth
(
selected
)
this
.
scrollIntoDefaultMonth
(
selected
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment