1
This commit is contained in:
42
uview-plus/components/u-calendar/calendar.js
Normal file
42
uview-plus/components/u-calendar/calendar.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* @Author : LQ
|
||||
* @Description :
|
||||
* @version : 1.0
|
||||
* @Date : 2021-08-20 16:44:21
|
||||
* @LastAuthor : LQ
|
||||
* @lastTime : 2021-08-20 16:52:43
|
||||
* @FilePath : /u-view2.0/uview-ui/libs/config/props/calendar.js
|
||||
*/
|
||||
export default {
|
||||
// calendar 组件
|
||||
calendar: {
|
||||
title: '日期选择',
|
||||
showTitle: true,
|
||||
showSubtitle: true,
|
||||
mode: 'single',
|
||||
startText: '开始',
|
||||
endText: '结束',
|
||||
customList: [],
|
||||
color: '#3c9cff',
|
||||
minDate: 0,
|
||||
maxDate: 0,
|
||||
defaultDate: null,
|
||||
maxCount: Number.MAX_SAFE_INTEGER, // Infinity
|
||||
rowHeight: 56,
|
||||
formatter: null,
|
||||
showLunar: false,
|
||||
showMark: true,
|
||||
confirmText: '确定',
|
||||
confirmDisabledText: '确定',
|
||||
show: false,
|
||||
closeOnClickOverlay: false,
|
||||
readonly: false,
|
||||
showConfirm: true,
|
||||
maxRange: Number.MAX_SAFE_INTEGER, // Infinity
|
||||
rangePrompt: '',
|
||||
showRangePrompt: true,
|
||||
allowSameDay: false,
|
||||
round: 0,
|
||||
monthNum: 3
|
||||
}
|
||||
}
|
||||
103
uview-plus/components/u-calendar/header.vue
Normal file
103
uview-plus/components/u-calendar/header.vue
Normal file
File diff suppressed because it is too large
Load Diff
587
uview-plus/components/u-calendar/month.vue
Normal file
587
uview-plus/components/u-calendar/month.vue
Normal file
File diff suppressed because it is too large
Load Diff
147
uview-plus/components/u-calendar/props.js
Normal file
147
uview-plus/components/u-calendar/props.js
Normal file
File diff suppressed because it is too large
Load Diff
409
uview-plus/components/u-calendar/u-calendar.vue
Normal file
409
uview-plus/components/u-calendar/u-calendar.vue
Normal file
File diff suppressed because it is too large
Load Diff
86
uview-plus/components/u-calendar/util.js
Normal file
86
uview-plus/components/u-calendar/util.js
Normal file
@@ -0,0 +1,86 @@
|
||||
import dayjs from 'dayjs/esm/index'
|
||||
export default {
|
||||
methods: {
|
||||
// 设置月份数据
|
||||
setMonth() {
|
||||
// 月初是周几
|
||||
const day = dayjs(this.date).date(1).day()
|
||||
const start = day == 0 ? 6 : day - 1
|
||||
|
||||
// 本月天数
|
||||
const days = dayjs(this.date).endOf('month').format('D')
|
||||
|
||||
// 上个月天数
|
||||
const prevDays = dayjs(this.date).endOf('month').subtract(1, 'month').format('D')
|
||||
|
||||
// 日期数据
|
||||
const arr = []
|
||||
// 清空表格
|
||||
this.month = []
|
||||
|
||||
// 添加上月数据
|
||||
arr.push(
|
||||
...new Array(start).fill(1).map((e, i) => {
|
||||
const day = prevDays - start + i + 1
|
||||
|
||||
return {
|
||||
value: day,
|
||||
disabled: true,
|
||||
date: dayjs(this.date).subtract(1, 'month').date(day).format('YYYY-MM-DD')
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
// 添加本月数据
|
||||
arr.push(
|
||||
...new Array(days - 0).fill(1).map((e, i) => {
|
||||
const day = i + 1
|
||||
|
||||
return {
|
||||
value: day,
|
||||
date: dayjs(this.date).date(day).format('YYYY-MM-DD')
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
// 添加下个月
|
||||
arr.push(
|
||||
...new Array(42 - days - start).fill(1).map((e, i) => {
|
||||
const day = i + 1
|
||||
|
||||
return {
|
||||
value: day,
|
||||
disabled: true,
|
||||
date: dayjs(this.date).add(1, 'month').date(day).format('YYYY-MM-DD')
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
// 分割数组
|
||||
for (let n = 0; n < arr.length; n += 7) {
|
||||
this.month.push(
|
||||
arr.slice(n, n + 7).map((e, i) => {
|
||||
e.index = i + n
|
||||
|
||||
// 自定义信息
|
||||
const custom = this.customList.find((c) => c.date == e.date)
|
||||
|
||||
// 农历
|
||||
if (this.lunar) {
|
||||
const {
|
||||
IDayCn,
|
||||
IMonthCn
|
||||
} = this.getLunar(e.date)
|
||||
e.lunar = IDayCn == '初一' ? IMonthCn : IDayCn
|
||||
}
|
||||
|
||||
return {
|
||||
...e,
|
||||
...custom
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user