@kyfe/hroa-ui 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hroa-ui.common.js +5345 -271
- package/dist/hroa-ui.css +1 -1
- package/dist/hroa-ui.umd.js +5345 -271
- package/dist/hroa-ui.umd.min.js +2 -2
- package/dist/img/header.7e31b1d5.png +0 -0
- package/lib/getJsModule/index.css +1 -1
- package/lib/getJsModule/index.js +2 -2
- package/lib/hr-add-list/index.js +1 -1
- package/lib/hr-bottom-button/index.js +1 -1
- package/lib/hr-breadcrumb/index.js +1 -1
- package/lib/hr-button/index.js +1 -1
- package/lib/hr-checkbox/index.css +1 -0
- package/lib/hr-checkbox/index.js +1 -0
- package/lib/hr-checkbox-group/index.css +1 -0
- package/lib/hr-checkbox-group/index.js +1 -0
- package/lib/hr-clipboard/index.js +1 -1
- package/lib/hr-collapse-card/index.css +1 -0
- package/lib/hr-collapse-card/index.js +1 -0
- package/lib/hr-condition-filtrate/index.js +1 -1
- package/lib/hr-condition-filtrate-popup/index.js +1 -1
- package/lib/hr-date-filter/index.css +1 -0
- package/lib/hr-date-filter/index.js +1 -0
- package/lib/hr-dropdown-date/index.css +1 -0
- package/lib/hr-dropdown-date/index.js +1 -0
- package/lib/hr-elasticity-box/index.js +1 -1
- package/lib/hr-elasticity-box-item/index.js +1 -1
- package/lib/hr-emotional-picture/index.js +1 -1
- package/lib/hr-employee-choose/index.js +1 -1
- package/lib/hr-file-list/index.css +1 -1
- package/lib/hr-file-list/index.js +1 -1
- package/lib/hr-full-screen/index.css +1 -0
- package/lib/hr-full-screen/index.js +1 -0
- package/lib/hr-img-list/index.js +1 -1
- package/lib/hr-info-card/index.js +1 -1
- package/lib/hr-information/index.css +1 -1
- package/lib/hr-information/index.js +1 -1
- package/lib/hr-license-plate-number/index.js +1 -1
- package/lib/hr-module-card/index.js +1 -1
- package/lib/hr-multiterm-choose/index.css +1 -1
- package/lib/hr-multiterm-choose/index.js +1 -1
- package/lib/hr-no-data/index.js +1 -1
- package/lib/hr-notice-bar/index.js +1 -1
- package/lib/hr-notification-dialog/index.css +1 -0
- package/lib/hr-notification-dialog/index.js +1 -0
- package/lib/hr-open-ks/index.js +1 -1
- package/lib/hr-pager/index.css +1 -1
- package/lib/hr-pager/index.js +1 -1
- package/lib/hr-popup/index.js +1 -1
- package/lib/hr-preview-file/index.js +1 -1
- package/lib/hr-radiobox/index.css +1 -0
- package/lib/hr-radiobox/index.js +1 -0
- package/lib/hr-radiobox-group/index.css +1 -0
- package/lib/hr-radiobox-group/index.js +1 -0
- package/lib/hr-rate/index.js +1 -1
- package/lib/hr-reason-textarea/index.js +1 -1
- package/lib/hr-search-input/index.js +1 -1
- package/lib/hr-search-tips/index.css +1 -0
- package/lib/hr-search-tips/index.js +9 -0
- package/lib/hr-select/index.js +1 -1
- package/lib/hr-select-list/index.js +1 -1
- package/lib/hr-single-choose/index.css +1 -1
- package/lib/hr-single-choose/index.js +1 -1
- package/lib/hr-slide-pager/index.css +1 -1
- package/lib/hr-slide-pager/index.js +1 -1
- package/lib/hr-sort/index.js +1 -1
- package/lib/hr-stack-image/index.js +1 -1
- package/lib/hr-tab-nav/index.css +1 -1
- package/lib/hr-tab-nav/index.js +1 -1
- package/lib/hr-time-picker/index.css +1 -0
- package/lib/hr-time-picker/index.js +1 -0
- package/lib/hr-view-item/index.js +1 -1
- package/lib/hr-virtual-list/index.css +1 -0
- package/lib/hr-virtual-list/index.js +1 -0
- package/lib/img/header.7e31b1d5.png +0 -0
- package/lib/index/index.css +1 -1
- package/lib/index/index.js +2 -2
- package/lib/utils/index.js +1 -1
- package/package.json +7 -3
- package/packages/hr-checkbox/index.js +8 -0
- package/packages/hr-checkbox/src/active-icon.png +0 -0
- package/packages/hr-checkbox/src/checkbox-group.vue +74 -0
- package/packages/hr-checkbox/src/checkbox.vue +226 -0
- package/packages/hr-checkbox/src/data.js +46 -0
- package/packages/hr-checkbox//345/244/215/351/200/211/346/241/206-/345/215/225/351/200/211/346/241/206.md +0 -0
- package/packages/hr-checkbox-group/index.js +8 -0
- package/packages/hr-collapse-card/index.js +3 -0
- package/packages/hr-collapse-card/src/images/icon_up.png +0 -0
- package/packages/hr-collapse-card/src/index.vue +151 -0
- package/packages/hr-collapse-card//346/212/230/345/217/240/345/215/241/347/211/207.md +0 -0
- package/packages/hr-date-filter/index.js +7 -0
- package/packages/hr-date-filter/src/date-select.vue +153 -0
- package/packages/hr-date-filter/src/index.vue +243 -0
- package/packages/hr-date-filter/src/style.less +130 -0
- package/packages/hr-date-filter/src/utils.js +109 -0
- package/packages/hr-dropdown-date/index.js +7 -0
- package/packages/hr-dropdown-date/src/calendar/calendar.js +128 -0
- package/packages/hr-dropdown-date/src/calendar/calendar.vue +485 -0
- package/packages/hr-dropdown-date/src/calendar/images/arrow@3x.png +0 -0
- package/packages/hr-dropdown-date/src/calendar/index.js +5 -0
- package/packages/hr-dropdown-date/src/date-picker/date-range-select.vue +92 -0
- package/packages/hr-dropdown-date/src/date-picker/month-range-select.vue +128 -0
- package/packages/hr-dropdown-date/src/date-picker/month-select.vue +98 -0
- package/packages/hr-dropdown-date/src/date-picker/style.less +120 -0
- package/packages/hr-dropdown-date/src/date-picker/utils.js +109 -0
- package/packages/hr-dropdown-date/src/index.vue +482 -0
- package/packages/hr-dropdown-date/src/week.js +194 -0
- package/packages/hr-file-list/src/index.vue +2 -2
- package/packages/hr-full-screen/index.js +7 -0
- package/packages/hr-full-screen/src/index.vue +117 -0
- package/packages/hr-information/src/index.vue +1 -0
- package/packages/hr-multiterm-choose/src/index.vue +4 -5
- package/packages/hr-notification-dialog/images/header.png +0 -0
- package/packages/hr-notification-dialog/index.js +7 -0
- package/packages/hr-notification-dialog/src/index.vue +293 -0
- package/packages/hr-notification-dialog//345/274/271/347/252/227/346/217/220/347/244/272/347/273/204/344/273/266.md +0 -0
- package/packages/hr-pager/index.js +1 -1
- package/packages/hr-pager/src/index.vue +34 -9
- package/packages/hr-radiobox/index.js +8 -0
- package/packages/hr-radiobox/src/data.js +46 -0
- package/packages/hr-radiobox/src/radiobox-group.vue +64 -0
- package/packages/hr-radiobox/src/radiobox.vue +191 -0
- package/packages/hr-radiobox-group/index.js +8 -0
- package/packages/hr-search-tips/index.js +3 -0
- package/packages/hr-search-tips/src/index.vue +213 -0
- package/packages/hr-search-tips//350/277/234/347/250/213/346/250/241/347/263/212/346/220/234/347/264/242.md +0 -0
- package/packages/hr-single-choose/src/index.vue +4 -5
- package/packages/hr-slide-pager/src/index.vue +3 -10
- package/packages/hr-tab-nav/src/index.vue +79 -4
- package/packages/hr-time-picker/index.js +3 -0
- package/packages/hr-time-picker/src/index.vue +85 -0
- package/packages/hr-time-picker//346/227/266/351/227/264/351/200/211/346/213/251/345/231/250.md +0 -0
- package/packages/hr-virtual-list/index.js +7 -0
- package/packages/hr-virtual-list/src/cc-item.vue +105 -0
- package/packages/hr-virtual-list/src/index.vue +227 -0
- package/packages/hr-virtual-list//350/231/232/346/213/237/345/210/227/350/241/250.md +0 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
// 当某月的天数
|
|
3
|
+
getDaysInOneMonth (date) {
|
|
4
|
+
const year = date.getFullYear()
|
|
5
|
+
const month = date.getMonth() + 1
|
|
6
|
+
const d = new Date(year, month, 0)
|
|
7
|
+
return d.getDate()
|
|
8
|
+
},
|
|
9
|
+
// 向前空几个
|
|
10
|
+
getMonthweek (date) {
|
|
11
|
+
const year = date.getFullYear()
|
|
12
|
+
const month = date.getMonth() + 1
|
|
13
|
+
const dateFirstOne = new Date(year + '/' + month + '/1')
|
|
14
|
+
return this.sundayStart ?
|
|
15
|
+
dateFirstOne.getDay() == 0 ? 7 : dateFirstOne.getDay() :
|
|
16
|
+
dateFirstOne.getDay() == 0 ? 6 : dateFirstOne.getDay() - 1
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* 获取当前日期上个月或者下个月
|
|
20
|
+
*/
|
|
21
|
+
getOtherMonth (date, str = 'nextMonth') {
|
|
22
|
+
const timeArray = this.dateFormat(date).split('/')
|
|
23
|
+
const year = timeArray[0]
|
|
24
|
+
const month = timeArray[1]
|
|
25
|
+
const day = timeArray[2]
|
|
26
|
+
let year2 = year
|
|
27
|
+
let month2
|
|
28
|
+
if (str === 'nextMonth') {
|
|
29
|
+
month2 = parseInt(month) + 1
|
|
30
|
+
if (month2 == 13) {
|
|
31
|
+
year2 = parseInt(year2) + 1
|
|
32
|
+
month2 = 1
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
month2 = parseInt(month) - 1
|
|
36
|
+
if (month2 == 0) {
|
|
37
|
+
year2 = parseInt(year2) - 1
|
|
38
|
+
month2 = 12
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
let day2 = day
|
|
42
|
+
const days2 = new Date(year2, month2, 0).getDate()
|
|
43
|
+
if (day2 > days2) {
|
|
44
|
+
day2 = days2
|
|
45
|
+
}
|
|
46
|
+
if (month2 < 10) {
|
|
47
|
+
month2 = '0' + month2
|
|
48
|
+
}
|
|
49
|
+
if (day2 < 10) {
|
|
50
|
+
day2 = '0' + day2
|
|
51
|
+
}
|
|
52
|
+
const t2 = year2 + '/' + month2 + '/' + day2
|
|
53
|
+
return new Date(t2)
|
|
54
|
+
},
|
|
55
|
+
// 上个月末尾的一些日期
|
|
56
|
+
getLeftArr (date) {
|
|
57
|
+
const arr = []
|
|
58
|
+
const leftNum = this.getMonthweek(date)
|
|
59
|
+
const num = this.getDaysInOneMonth(this.getOtherMonth(date, 'preMonth')) - leftNum + 1
|
|
60
|
+
const preDate = this.getOtherMonth(date, 'preMonth')
|
|
61
|
+
// 上个月多少开始
|
|
62
|
+
for (let i = 0; i < leftNum; i++) {
|
|
63
|
+
const nowTime = preDate.getFullYear() + '/' + (preDate.getMonth() + 1) + '/' + (num + i)
|
|
64
|
+
const timestamp = (new Date(nowTime)).getTime()
|
|
65
|
+
arr.push({
|
|
66
|
+
id: num + i,
|
|
67
|
+
timestamp: timestamp,
|
|
68
|
+
date: nowTime,
|
|
69
|
+
isToday: false,
|
|
70
|
+
otherMonth: 'preMonth',
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
return arr
|
|
74
|
+
},
|
|
75
|
+
// 下个月末尾的一些日期
|
|
76
|
+
getRightArr (date) {
|
|
77
|
+
const arr = []
|
|
78
|
+
const nextDate = this.getOtherMonth(date, 'nextMonth')
|
|
79
|
+
const leftLength = this.getDaysInOneMonth(date) + this.getMonthweek(date)
|
|
80
|
+
const _length = 7 - leftLength % 7
|
|
81
|
+
for (let i = 0; i < _length; i++) {
|
|
82
|
+
const nowTime = nextDate.getFullYear() + '/' + (nextDate.getMonth() + 1) + '/' + (i + 1)
|
|
83
|
+
const timestamp = (new Date(nowTime)).getTime()
|
|
84
|
+
arr.push({
|
|
85
|
+
id: i + 1,
|
|
86
|
+
timestamp: timestamp,
|
|
87
|
+
date: nowTime,
|
|
88
|
+
isToday: false,
|
|
89
|
+
otherMonth: 'nextMonth',
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
return arr
|
|
93
|
+
},
|
|
94
|
+
// format日期
|
|
95
|
+
dateFormat (date) {
|
|
96
|
+
if (typeof date === 'string') {
|
|
97
|
+
date = new Date(date.replace(/-/g, '/'))
|
|
98
|
+
}
|
|
99
|
+
return date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate()
|
|
100
|
+
},
|
|
101
|
+
// 获取某月的列表不包括上月和下月
|
|
102
|
+
getMonthListNoOther (date) {
|
|
103
|
+
const arr = []
|
|
104
|
+
const num = this.getDaysInOneMonth(date)
|
|
105
|
+
const year = date.getFullYear()
|
|
106
|
+
const month = date.getMonth() + 1
|
|
107
|
+
const toDay = this.dateFormat(new Date())
|
|
108
|
+
|
|
109
|
+
for (let i = 0; i < num; i++) {
|
|
110
|
+
const nowTime = year + '/' + month + '/' + (i + 1)
|
|
111
|
+
const timestamp = (new Date(nowTime)).getTime()
|
|
112
|
+
arr.push({
|
|
113
|
+
id: i + 1,
|
|
114
|
+
timestamp: timestamp,
|
|
115
|
+
date: nowTime,
|
|
116
|
+
isToday: toDay === nowTime,
|
|
117
|
+
otherMonth: 'nowMonth',
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
return arr
|
|
121
|
+
},
|
|
122
|
+
// 获取某月的列表 用于渲染
|
|
123
|
+
getMonthList (date) {
|
|
124
|
+
return [...this.getLeftArr(date), ...this.getMonthListNoOther(date), ...this.getRightArr(date)]
|
|
125
|
+
},
|
|
126
|
+
// 默认是周一开始
|
|
127
|
+
sundayStart: false,
|
|
128
|
+
}
|
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section class="wh_container">
|
|
3
|
+
<div class="wh_content_all">
|
|
4
|
+
<!-- 月份切换栏 -->
|
|
5
|
+
<div class="wh_top_changge">
|
|
6
|
+
<li>
|
|
7
|
+
<slot name="left"></slot>
|
|
8
|
+
</li>
|
|
9
|
+
<li @click="PreMonth(myDate,false)"
|
|
10
|
+
class="pre-warp">
|
|
11
|
+
<div class="wh_jiantou1">
|
|
12
|
+
</div>
|
|
13
|
+
</li>
|
|
14
|
+
<li class="wh_content_li">{{dateTop}}</li>
|
|
15
|
+
<li @click="NextMonth(myDate,false)"
|
|
16
|
+
class="next-warp">
|
|
17
|
+
<div class="wh_jiantou2"></div>
|
|
18
|
+
</li>
|
|
19
|
+
<li>
|
|
20
|
+
<slot name="right"></slot>
|
|
21
|
+
</li>
|
|
22
|
+
</div>
|
|
23
|
+
<!-- 星期指示栏 -->
|
|
24
|
+
<div class="wh_content">
|
|
25
|
+
<div class="wh_content_item wh_content_item-header"
|
|
26
|
+
v-for="tag in textTop"
|
|
27
|
+
:key="tag">
|
|
28
|
+
<div class="wh_top_tag">{{tag}}</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
<!-- 日期容器 -->
|
|
32
|
+
<div class="wh_content">
|
|
33
|
+
<div class="wh_content_item wh_content_item-content"
|
|
34
|
+
v-for="(item,index) in list"
|
|
35
|
+
:key="item"
|
|
36
|
+
:class="{'is-week':isWeekClass(item),'is-before-half-week':isHalfWeekClass('1',item),'is-after-half-week':isHalfWeekClass('2',item)}"
|
|
37
|
+
@click="clickDay(item,index)">
|
|
38
|
+
<div class="wh_item_date"
|
|
39
|
+
v-bind:class="[{ wh_isMark: item.isMark},{wh_other_dayhide:item.otherMonth!=='nowMonth' || disableCheck(item.date)},{wh_want_dayhide:item.dayHide},{wh_isToday:item.isToday},{wh_chose_day:item.chooseDay}]">
|
|
40
|
+
<p class="wh_item_date_h1">{{item.id}}</p>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</section>
|
|
46
|
+
</template>
|
|
47
|
+
<script>
|
|
48
|
+
import timeUtil from "./calendar.js";
|
|
49
|
+
import { getWeekRange, getDayForMill } from '../week.js'
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
data () {
|
|
53
|
+
return {
|
|
54
|
+
myDate: new Date(),
|
|
55
|
+
list: [],
|
|
56
|
+
dateTop: '',
|
|
57
|
+
minStartTimestamp: null,
|
|
58
|
+
maxStartTimestamp: null,
|
|
59
|
+
minEndTimestamp: null,
|
|
60
|
+
maxEndTimestamp: null,
|
|
61
|
+
dayTimestamp: getDayForMill(1),
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
props: {
|
|
65
|
+
// 周选择器组件的时间范围
|
|
66
|
+
weekRange: {
|
|
67
|
+
type: Object
|
|
68
|
+
},
|
|
69
|
+
textTop: {
|
|
70
|
+
type: Array,
|
|
71
|
+
default: () => ["一", "二", "三", "四", "五", "六", "日"]
|
|
72
|
+
},
|
|
73
|
+
formatter: {
|
|
74
|
+
type: Function
|
|
75
|
+
},
|
|
76
|
+
agoDayHide: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: `0`
|
|
79
|
+
},
|
|
80
|
+
futureDayHide: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: `2554387200`
|
|
83
|
+
},
|
|
84
|
+
// 是否为周选择器
|
|
85
|
+
isWeek: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: true
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
created () {
|
|
91
|
+
if (this.weekRange && this.weekRange.monday) {
|
|
92
|
+
this.myDate = new Date(this.weekRange.monday)
|
|
93
|
+
} else {
|
|
94
|
+
this.myDate = new Date(getWeekRange(new Date()).monday)
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
mounted () {
|
|
98
|
+
console.log('周选择器----------weekRange', this.weekRange)
|
|
99
|
+
this.getList(this.myDate, this.weekRange)
|
|
100
|
+
},
|
|
101
|
+
watch: {
|
|
102
|
+
// 监听时间变化做状态回显
|
|
103
|
+
weekRange () {
|
|
104
|
+
console.log('weekRange change!!')
|
|
105
|
+
this.setWeekRange(this.weekRange)
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
methods: {
|
|
109
|
+
/**
|
|
110
|
+
* 本周之后的时间禁用
|
|
111
|
+
*/
|
|
112
|
+
disableCheck (time) {
|
|
113
|
+
let week = getWeekRange(new Date())
|
|
114
|
+
let maxEndTimestamp = week.sunday
|
|
115
|
+
return (+new Date(time) > maxEndTimestamp)
|
|
116
|
+
},
|
|
117
|
+
/**
|
|
118
|
+
* @description 判断是否为选中日期的头尾
|
|
119
|
+
* @param { type } type 1头 2尾
|
|
120
|
+
* @param { Object } date 日历时间数据对象
|
|
121
|
+
* @returns { Boolean }
|
|
122
|
+
*/
|
|
123
|
+
isHalfWeekClass (type, date) {
|
|
124
|
+
if (!this.isWeek) return false
|
|
125
|
+
switch (type) {
|
|
126
|
+
case '1':
|
|
127
|
+
if (date.timestamp >= this.minStartTimestamp && date.timestamp <= this.maxStartTimestamp) return true
|
|
128
|
+
break
|
|
129
|
+
case '2':
|
|
130
|
+
if (date.timestamp >= this.minEndTimestamp && date.timestamp <= this.maxEndTimestamp) return true
|
|
131
|
+
break
|
|
132
|
+
default:
|
|
133
|
+
break
|
|
134
|
+
}
|
|
135
|
+
return false
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* @description 判断是否为选中的日期
|
|
139
|
+
* @param { Object } 日历时间数据对象
|
|
140
|
+
* @returns { Boolean }
|
|
141
|
+
*/
|
|
142
|
+
isWeekClass (date) {
|
|
143
|
+
if (!this.isWeek) return false
|
|
144
|
+
if (date.timestamp >= this.maxStartTimestamp && date.timestamp < this.minEndTimestamp) {
|
|
145
|
+
return true
|
|
146
|
+
}
|
|
147
|
+
return false
|
|
148
|
+
},
|
|
149
|
+
setClass (data) {
|
|
150
|
+
let obj = {};
|
|
151
|
+
obj[data.markClassName] = data.markClassName;
|
|
152
|
+
return obj;
|
|
153
|
+
},
|
|
154
|
+
clickDay (item) {
|
|
155
|
+
// 周选择器
|
|
156
|
+
if (this.isWeek) {
|
|
157
|
+
// 禁止选中当前之后的时间
|
|
158
|
+
let week = getWeekRange(new Date(item.date))
|
|
159
|
+
let _minStartTimestamp = week.monday
|
|
160
|
+
if (+new Date() < _minStartTimestamp) {
|
|
161
|
+
return false
|
|
162
|
+
}
|
|
163
|
+
// 根据选中的日期设置选中的周范围
|
|
164
|
+
this.setWeekRange(new Date(item.date))
|
|
165
|
+
this.$emit('confirm', {
|
|
166
|
+
monday: this.minStartTimestamp,
|
|
167
|
+
sunday: this.maxEndTimestamp
|
|
168
|
+
})
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
/**
|
|
173
|
+
* @description 获取上个月日历内容
|
|
174
|
+
*/
|
|
175
|
+
PreMonth () {
|
|
176
|
+
// 获取当前日期的上个月日期
|
|
177
|
+
this.myDate = timeUtil.getOtherMonth(this.myDate, 'preMonth')
|
|
178
|
+
this.getList(this.myDate)
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* @description 获取下个月日历内容
|
|
182
|
+
*/
|
|
183
|
+
NextMonth () {
|
|
184
|
+
// 获取当前日期的下个月日期
|
|
185
|
+
this.myDate = timeUtil.getOtherMonth(this.myDate, 'nextMonth')
|
|
186
|
+
this.getList(this.myDate)
|
|
187
|
+
},
|
|
188
|
+
/**
|
|
189
|
+
* @description 获取所选日期月份的所有日期
|
|
190
|
+
* @param { Date } date 所选日期的date对象
|
|
191
|
+
* @param { Object } dateRange 需要设置的选中范围
|
|
192
|
+
*/
|
|
193
|
+
async getList (date, dateRange = null) {
|
|
194
|
+
this.dateTop = `${date.getFullYear()}年${date.getMonth() + 1}月`
|
|
195
|
+
// 获取所选月份的所有日期
|
|
196
|
+
let arr = timeUtil.getMonthList(this.myDate)
|
|
197
|
+
for (let i = 0; i < arr.length; i++) {
|
|
198
|
+
let markClassName = ''
|
|
199
|
+
let k = arr[i]
|
|
200
|
+
if (typeof (this.formatter) === 'function') {
|
|
201
|
+
this.formatter(k)
|
|
202
|
+
}
|
|
203
|
+
k.chooseDay = false
|
|
204
|
+
const nowTime = k.date
|
|
205
|
+
const t = new Date(nowTime).getTime() / 1000
|
|
206
|
+
|
|
207
|
+
//标记选中某些天 设置class
|
|
208
|
+
k.markClassName = markClassName
|
|
209
|
+
k.isMark = false
|
|
210
|
+
//无法选中某天
|
|
211
|
+
k.dayHide = t < this.agoDayHide || t > this.futureDayHide
|
|
212
|
+
if (k.isToday) {
|
|
213
|
+
k.isToday = false
|
|
214
|
+
this.$emit("isToday", nowTime)
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (this.isWeek) {
|
|
218
|
+
// 如果有传入dateRange,则进行日期范围回显
|
|
219
|
+
if (dateRange) {
|
|
220
|
+
this.setWeekRange(dateRange)
|
|
221
|
+
}
|
|
222
|
+
this.list = arr
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
/**
|
|
226
|
+
* @description 根据选中的日期设置选中的周范围
|
|
227
|
+
* @param { Date, Object } date 查询的日期/需要选中回显的日期范围
|
|
228
|
+
*/
|
|
229
|
+
setWeekRange (date) {
|
|
230
|
+
if (typeof date === 'number') {
|
|
231
|
+
date = new Date(date)
|
|
232
|
+
}
|
|
233
|
+
if (date.monday && date.sunday) {
|
|
234
|
+
// 传入的date为指定的对象类型 则直接设置时间范围
|
|
235
|
+
this.minStartTimestamp = date.monday
|
|
236
|
+
this.maxStartTimestamp = date.monday + this.dayTimestamp - 1
|
|
237
|
+
this.minEndTimestamp = date.sunday - this.dayTimestamp + 1
|
|
238
|
+
this.maxEndTimestamp = date.sunday
|
|
239
|
+
} else {
|
|
240
|
+
let week = getWeekRange(date)
|
|
241
|
+
this.minStartTimestamp = week.monday
|
|
242
|
+
this.maxStartTimestamp = week.monday + this.dayTimestamp - 1
|
|
243
|
+
this.minEndTimestamp = week.sunday - this.dayTimestamp + 1
|
|
244
|
+
this.maxEndTimestamp = week.sunday
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
}
|
|
249
|
+
</script>
|
|
250
|
+
|
|
251
|
+
<style scoped lang="less">
|
|
252
|
+
@selectColor: #7972fe;
|
|
253
|
+
@dateHeaderHeight: 88px;
|
|
254
|
+
@itemDateHeight: 80px;
|
|
255
|
+
@isWeekColor: #ecebff;
|
|
256
|
+
|
|
257
|
+
.wh_container {
|
|
258
|
+
position: relative;
|
|
259
|
+
width: 750px;
|
|
260
|
+
height: 780px;
|
|
261
|
+
margin: auto;
|
|
262
|
+
}
|
|
263
|
+
.loading {
|
|
264
|
+
position: absolute;
|
|
265
|
+
width: 100%;
|
|
266
|
+
height: 100%;
|
|
267
|
+
top: 0;
|
|
268
|
+
/deep/ .van-loading {
|
|
269
|
+
margin: 40% 0 0 47%;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
li {
|
|
274
|
+
list-style-type: none;
|
|
275
|
+
}
|
|
276
|
+
.wh_top_changge {
|
|
277
|
+
height: 90px;
|
|
278
|
+
display: flex;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.wh_top_changge li {
|
|
282
|
+
cursor: pointer;
|
|
283
|
+
display: flex;
|
|
284
|
+
color: #666666;
|
|
285
|
+
font-size: 30px;
|
|
286
|
+
flex: 1;
|
|
287
|
+
justify-content: center;
|
|
288
|
+
align-items: center;
|
|
289
|
+
height: 90px;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.wh_top_changge .wh_content_li {
|
|
293
|
+
cursor: auto;
|
|
294
|
+
flex: 1;
|
|
295
|
+
}
|
|
296
|
+
.wh_content_all {
|
|
297
|
+
background-color: #ffffff;
|
|
298
|
+
width: 100%;
|
|
299
|
+
overflow: hidden;
|
|
300
|
+
padding-bottom: 8px;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.wh_content {
|
|
304
|
+
display: flex;
|
|
305
|
+
flex-wrap: wrap;
|
|
306
|
+
padding: 0 3% 0 3%;
|
|
307
|
+
width: 100%;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.wh_content:first-child .wh_content_item_tag,
|
|
311
|
+
.wh_content:first-child .wh_content_item {
|
|
312
|
+
color: #666666;
|
|
313
|
+
font-size: 16px;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.wh_content_item,
|
|
317
|
+
.wh_content_item_tag {
|
|
318
|
+
font-size: 15px;
|
|
319
|
+
width: 13.4%;
|
|
320
|
+
text-align: center;
|
|
321
|
+
color: #666666;
|
|
322
|
+
position: relative;
|
|
323
|
+
}
|
|
324
|
+
.wh_content_item-header {
|
|
325
|
+
height: @dateHeaderHeight;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.wh_content_item-content {
|
|
329
|
+
height: @itemDateHeight;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.wh_top_tag {
|
|
333
|
+
font-size: 30px;
|
|
334
|
+
width: @dateHeaderHeight;
|
|
335
|
+
height: @dateHeaderHeight;
|
|
336
|
+
line-height: @dateHeaderHeight;
|
|
337
|
+
margin: auto;
|
|
338
|
+
display: flex;
|
|
339
|
+
justify-content: center;
|
|
340
|
+
align-items: center;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.wh_item_date {
|
|
344
|
+
width: @itemDateHeight;
|
|
345
|
+
height: @itemDateHeight;
|
|
346
|
+
line-height: @itemDateHeight;
|
|
347
|
+
margin: auto;
|
|
348
|
+
display: flex;
|
|
349
|
+
justify-content: center;
|
|
350
|
+
align-items: center;
|
|
351
|
+
flex-direction: column;
|
|
352
|
+
|
|
353
|
+
.wh_item_date_h1 {
|
|
354
|
+
margin-top: 4px;
|
|
355
|
+
width: 100%;
|
|
356
|
+
height: 30px;
|
|
357
|
+
line-height: 30px;
|
|
358
|
+
font-size: 28px;
|
|
359
|
+
}
|
|
360
|
+
.wh_item_date_h2 {
|
|
361
|
+
line-height: normal;
|
|
362
|
+
// max-width: 100%;
|
|
363
|
+
display: inline-block;
|
|
364
|
+
height: 30px;
|
|
365
|
+
font-size: 24px;
|
|
366
|
+
padding: 4px 10px;
|
|
367
|
+
white-space: nowrap;
|
|
368
|
+
overflow: hidden;
|
|
369
|
+
text-overflow: ellipsis;
|
|
370
|
+
transform: scale(0.9);
|
|
371
|
+
}
|
|
372
|
+
&__0 {
|
|
373
|
+
color: #cecece;
|
|
374
|
+
}
|
|
375
|
+
&__1 {
|
|
376
|
+
color: #ff5804;
|
|
377
|
+
background-color: #ffeee7;
|
|
378
|
+
}
|
|
379
|
+
&__2 {
|
|
380
|
+
color: #00ac00;
|
|
381
|
+
background-color: #e3fff4;
|
|
382
|
+
}
|
|
383
|
+
&__3 {
|
|
384
|
+
color: #7972fe;
|
|
385
|
+
background-color: #f0edff;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
.wh_chose_day {
|
|
389
|
+
.wh_item_date_h2 {
|
|
390
|
+
color: #fff !important;
|
|
391
|
+
background-color: rgba(0, 0, 0, 0) !important;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.wh_isToday {
|
|
396
|
+
.wh_item_date_h2 {
|
|
397
|
+
color: #fff !important;
|
|
398
|
+
background-color: rgba(0, 0, 0, 0) !important;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
.wh_top_changge .pre-warp {
|
|
402
|
+
flex: none;
|
|
403
|
+
flex-basis: 20px;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.wh_top_changge .next-warp {
|
|
407
|
+
flex: none;
|
|
408
|
+
flex-basis: 20px;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.wh_jiantou1 {
|
|
412
|
+
width: 48px;
|
|
413
|
+
height: 48px;
|
|
414
|
+
background-size: 30px 30px;
|
|
415
|
+
background-repeat: no-repeat;
|
|
416
|
+
background-position: center center;
|
|
417
|
+
background-image: url("./images/arrow@3x.png");
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.wh_jiantou1:active,
|
|
421
|
+
.wh_jiantou2:active {
|
|
422
|
+
border-color: #ddd;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.wh_jiantou2 {
|
|
426
|
+
width: 48px;
|
|
427
|
+
height: 48px;
|
|
428
|
+
transform: rotate(-180deg);
|
|
429
|
+
background-size: 30px 30px;
|
|
430
|
+
background-repeat: no-repeat;
|
|
431
|
+
background-position: center center;
|
|
432
|
+
background-image: url("./images/arrow@3x.png");
|
|
433
|
+
}
|
|
434
|
+
.wh_content_item > .wh_isMark {
|
|
435
|
+
margin: auto;
|
|
436
|
+
border-radius: 100px;
|
|
437
|
+
background: #7972fe;
|
|
438
|
+
z-index: 2;
|
|
439
|
+
}
|
|
440
|
+
.wh_content_item .wh_other_dayhide {
|
|
441
|
+
color: #bfbfbf;
|
|
442
|
+
}
|
|
443
|
+
.wh_content_item .wh_want_dayhide {
|
|
444
|
+
color: #bfbfbf;
|
|
445
|
+
}
|
|
446
|
+
.wh_content_item .wh_isToday {
|
|
447
|
+
color: #fff;
|
|
448
|
+
background: #7972fe;
|
|
449
|
+
border-radius: 100px;
|
|
450
|
+
}
|
|
451
|
+
.wh_content_item .wh_chose_day {
|
|
452
|
+
background: #7972fe;
|
|
453
|
+
color: #fff;
|
|
454
|
+
border-radius: 100px;
|
|
455
|
+
}
|
|
456
|
+
.is-week {
|
|
457
|
+
background: @isWeekColor;
|
|
458
|
+
}
|
|
459
|
+
.is-before-half-week {
|
|
460
|
+
.wh_item_date {
|
|
461
|
+
color: #fff;
|
|
462
|
+
border-radius: 100px;
|
|
463
|
+
background: @selectColor;
|
|
464
|
+
}
|
|
465
|
+
background: linear-gradient(
|
|
466
|
+
to left,
|
|
467
|
+
white 51%,
|
|
468
|
+
white 100% #fff 0%,
|
|
469
|
+
#ecebff 50%
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
.is-after-half-week {
|
|
473
|
+
.wh_item_date {
|
|
474
|
+
color: #fff;
|
|
475
|
+
border-radius: 100px;
|
|
476
|
+
background: @selectColor;
|
|
477
|
+
}
|
|
478
|
+
background: linear-gradient(
|
|
479
|
+
to left,
|
|
480
|
+
#ecebff 51%,
|
|
481
|
+
white 0% #fff 100%,
|
|
482
|
+
white 50%
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
</style>
|
|
Binary file
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<van-calendar class="ks-daterange-select ks-calendar"
|
|
3
|
+
:default-date="currentDate"
|
|
4
|
+
ref="ksDaterangedSelect"
|
|
5
|
+
:poppable="false"
|
|
6
|
+
:show-confirm="false"
|
|
7
|
+
:show-title="false"
|
|
8
|
+
:show-subtitle="false"
|
|
9
|
+
:min-date="currentMin"
|
|
10
|
+
:max-date="currentMax"
|
|
11
|
+
:lazy-render="false"
|
|
12
|
+
:safe-area-inset-bottom="false"
|
|
13
|
+
:allow-same-day="true"
|
|
14
|
+
type="range"
|
|
15
|
+
@select="handleSelect" />
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import { formatToDate, formatToString } from './utils'
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
name: 'date-range-select',
|
|
23
|
+
props: {
|
|
24
|
+
defaultValue: {
|
|
25
|
+
type: Array,
|
|
26
|
+
default: () => ([])
|
|
27
|
+
},
|
|
28
|
+
min: [String, Number, Date],
|
|
29
|
+
max: [String, Number, Date]
|
|
30
|
+
},
|
|
31
|
+
data () {
|
|
32
|
+
return {
|
|
33
|
+
currentDate: [],
|
|
34
|
+
currentMin: new Date(),
|
|
35
|
+
currentMax: new Date()
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
created () {
|
|
39
|
+
this.init()
|
|
40
|
+
},
|
|
41
|
+
methods: {
|
|
42
|
+
init () {
|
|
43
|
+
if (this.defaultValue.length) {
|
|
44
|
+
this.currentDate = [formatToDate(this.defaultValue[0]), formatToDate(this.defaultValue[1])]
|
|
45
|
+
}
|
|
46
|
+
if (!this.min) {
|
|
47
|
+
let _date = new Date()
|
|
48
|
+
let y = _date.getFullYear()
|
|
49
|
+
let m = _date.getMonth() + 1
|
|
50
|
+
this.currentMin = (m - 6) < 1 ? new Date(y - 1, 12 + m - 5, 1) : new Date(y, m - 5, 1)
|
|
51
|
+
} else {
|
|
52
|
+
this.currentMin = formatToDate(this.min)
|
|
53
|
+
}
|
|
54
|
+
if (!this.max) {
|
|
55
|
+
let _date = new Date()
|
|
56
|
+
let y = _date.getFullYear()
|
|
57
|
+
let m = _date.getMonth() + 1
|
|
58
|
+
this.currentMax = (m + 6) > 12 ? new Date(y + 1, m + 6 - 12, 0) : new Date(y, m + 6, 0)
|
|
59
|
+
} else {
|
|
60
|
+
this.currentMax = formatToDate(this.max)
|
|
61
|
+
}
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
this.autoScroll()
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* @description 初始化时自动往上滚动 用于解决ios部分机型初始化日历时白屏问题
|
|
68
|
+
*/
|
|
69
|
+
autoScroll () {
|
|
70
|
+
this.$refs.ksDaterangedSelect.$refs.body.scrollTop -= 46
|
|
71
|
+
},
|
|
72
|
+
handleSelect (e) {
|
|
73
|
+
this.$emit('select', { date: e, str: [formatToString(e[0]), formatToString(e[1])] })
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<style lang="less">
|
|
80
|
+
.ks-daterange-select {
|
|
81
|
+
.van-calendar__day {
|
|
82
|
+
margin: 3px 0;
|
|
83
|
+
}
|
|
84
|
+
.van-calendar__day--middle {
|
|
85
|
+
color: #7972fe !important;
|
|
86
|
+
&::after {
|
|
87
|
+
top: 0 !important;
|
|
88
|
+
bottom: 0 !important;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
</style>
|