@kengic/uni 0.3.2-beta.10
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/README.md +1 -0
- package/dist/index.css +1 -0
- package/dist/kengic-uni.js +5 -0
- package/dist/src/consts/i18n/en.d.ts +45 -0
- package/dist/src/consts/i18n/index.d.ts +90 -0
- package/dist/src/consts/i18n/zh_CN.d.ts +45 -0
- package/dist/src/consts/index.d.ts +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/kg.util.d.ts +5 -0
- package/dist/uni-ui/index.ts +11 -0
- package/dist/uni-ui/uni-badge/uni-badge.vue +253 -0
- package/dist/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +41 -0
- package/dist/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +121 -0
- package/dist/uni-ui/uni-calendar/calendar.js +546 -0
- package/dist/uni-ui/uni-calendar/i18n/en.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hans.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hant.json +12 -0
- package/dist/uni-ui/uni-calendar/uni-calendar-item.vue +187 -0
- package/dist/uni-ui/uni-calendar/uni-calendar.vue +566 -0
- package/dist/uni-ui/uni-calendar/util.js +360 -0
- package/dist/uni-ui/uni-card/uni-card.vue +281 -0
- package/dist/uni-ui/uni-col/uni-col.vue +317 -0
- package/dist/uni-ui/uni-collapse/uni-collapse.vue +147 -0
- package/dist/uni-ui/uni-collapse-item/uni-collapse-item.vue +402 -0
- package/dist/uni-ui/uni-combox/uni-combox.vue +294 -0
- package/dist/uni-ui/uni-countdown/i18n/en.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/index.js +8 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-countdown/uni-countdown.vue +267 -0
- package/dist/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +821 -0
- package/dist/uni-ui/uni-data-picker/keypress.js +45 -0
- package/dist/uni-ui/uni-data-picker/uni-data-picker.vue +551 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-picker.js +622 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +323 -0
- package/dist/uni-ui/uni-data-select/uni-data-select.vue +517 -0
- package/dist/uni-ui/uni-dateformat/date-format.js +200 -0
- package/dist/uni-ui/uni-dateformat/uni-dateformat.vue +88 -0
- package/dist/uni-ui/uni-datetime-picker/calendar-item.vue +177 -0
- package/dist/uni-ui/uni-datetime-picker/calendar.vue +928 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/en.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/index.js +8 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/time-picker.vue +934 -0
- package/dist/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1026 -0
- package/dist/uni-ui/uni-datetime-picker/util.js +403 -0
- package/dist/uni-ui/uni-drawer/keypress.js +45 -0
- package/dist/uni-ui/uni-drawer/uni-drawer.vue +181 -0
- package/dist/uni-ui/uni-easyinput/common.js +56 -0
- package/dist/uni-ui/uni-easyinput/uni-easyinput.vue +660 -0
- package/dist/uni-ui/uni-fab/uni-fab.vue +491 -0
- package/dist/uni-ui/uni-fav/i18n/en.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-fav/uni-fav.vue +161 -0
- package/dist/uni-ui/uni-file-picker/choose-and-upload-file.js +224 -0
- package/dist/uni-ui/uni-file-picker/uni-file-picker.vue +667 -0
- package/dist/uni-ui/uni-file-picker/upload-file.vue +325 -0
- package/dist/uni-ui/uni-file-picker/upload-image.vue +292 -0
- package/dist/uni-ui/uni-file-picker/utils.js +109 -0
- package/dist/uni-ui/uni-forms/uni-forms.vue +398 -0
- package/dist/uni-ui/uni-forms/utils.js +293 -0
- package/dist/uni-ui/uni-forms/validate.js +486 -0
- package/dist/uni-ui/uni-forms-item/uni-forms-item.vue +601 -0
- package/dist/uni-ui/uni-goods-nav/i18n/en.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-goods-nav/uni-goods-nav.vue +229 -0
- package/dist/uni-ui/uni-grid/uni-grid.vue +143 -0
- package/dist/uni-ui/uni-grid-item/uni-grid-item.vue +129 -0
- package/dist/uni-ui/uni-group/uni-group.vue +134 -0
- package/dist/uni-ui/uni-icons/icons.js +1169 -0
- package/dist/uni-ui/uni-icons/uni-icons.vue +96 -0
- package/dist/uni-ui/uni-icons/uniicons.css +663 -0
- package/dist/uni-ui/uni-icons/uniicons.ttf +0 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +144 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list.vue +367 -0
- package/dist/uni-ui/uni-link/uni-link.vue +128 -0
- package/dist/uni-ui/uni-list/uni-list.vue +123 -0
- package/dist/uni-ui/uni-list/uni-refresh.vue +65 -0
- package/dist/uni-ui/uni-list/uni-refresh.wxs +87 -0
- package/dist/uni-ui/uni-list-ad/uni-list-ad.vue +107 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.scss +58 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.vue +593 -0
- package/dist/uni-ui/uni-list-item/uni-list-item.vue +534 -0
- package/dist/uni-ui/uni-load-more/i18n/en.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/index.js +8 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-load-more/uni-load-more.vue +399 -0
- package/dist/uni-ui/uni-nav-bar/uni-nav-bar.vue +357 -0
- package/dist/uni-ui/uni-nav-bar/uni-status-bar.vue +24 -0
- package/dist/uni-ui/uni-notice-bar/uni-notice-bar.vue +426 -0
- package/dist/uni-ui/uni-number-box/uni-number-box.vue +221 -0
- package/dist/uni-ui/uni-pagination/i18n/en.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/es.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/fr.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/index.js +12 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-pagination/uni-pagination.vue +465 -0
- package/dist/uni-ui/uni-popup/i18n/en.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/index.js +9 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hans.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hant.json +7 -0
- package/dist/uni-ui/uni-popup/keypress.js +45 -0
- package/dist/uni-ui/uni-popup/popup.js +23 -0
- package/dist/uni-ui/uni-popup/uni-popup.vue +464 -0
- package/dist/uni-ui/uni-popup-dialog/keypress.js +45 -0
- package/dist/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +275 -0
- package/dist/uni-ui/uni-popup-message/uni-popup-message.vue +143 -0
- package/dist/uni-ui/uni-popup-share/uni-popup-share.vue +187 -0
- package/dist/uni-ui/uni-rate/uni-rate.vue +365 -0
- package/dist/uni-ui/uni-row/uni-row.vue +190 -0
- package/dist/uni-ui/uni-scss/changelog.md +8 -0
- package/dist/uni-ui/uni-scss/index.scss +1 -0
- package/dist/uni-ui/uni-scss/package.json +82 -0
- package/dist/uni-ui/uni-scss/readme.md +4 -0
- package/dist/uni-ui/uni-scss/styles/index.scss +7 -0
- package/dist/uni-ui/uni-scss/styles/setting/_border.scss +3 -0
- package/dist/uni-ui/uni-scss/styles/setting/_color.scss +66 -0
- package/dist/uni-ui/uni-scss/styles/setting/_radius.scss +55 -0
- package/dist/uni-ui/uni-scss/styles/setting/_space.scss +56 -0
- package/dist/uni-ui/uni-scss/styles/setting/_styles.scss +167 -0
- package/dist/uni-ui/uni-scss/styles/setting/_text.scss +24 -0
- package/dist/uni-ui/uni-scss/styles/setting/_variables.scss +146 -0
- package/dist/uni-ui/uni-scss/styles/tools/functions.scss +19 -0
- package/dist/uni-ui/uni-scss/theme.scss +31 -0
- package/dist/uni-ui/uni-scss/variables.scss +62 -0
- package/dist/uni-ui/uni-search-bar/i18n/en.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-search-bar/uni-search-bar.vue +298 -0
- package/dist/uni-ui/uni-section/uni-section.vue +167 -0
- package/dist/uni-ui/uni-segmented-control/uni-segmented-control.vue +145 -0
- package/dist/uni-ui/uni-steps/uni-steps.vue +269 -0
- package/dist/uni-ui/uni-swipe-action/uni-swipe-action.vue +60 -0
- package/dist/uni-ui/uni-swipe-action-item/bindingx.js +302 -0
- package/dist/uni-ui/uni-swipe-action-item/isPC.js +12 -0
- package/dist/uni-ui/uni-swipe-action-item/mpalipay.js +195 -0
- package/dist/uni-ui/uni-swipe-action-item/mpother.js +260 -0
- package/dist/uni-ui/uni-swipe-action-item/mpwxs.js +84 -0
- package/dist/uni-ui/uni-swipe-action-item/render.js +270 -0
- package/dist/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +347 -0
- package/dist/uni-ui/uni-swipe-action-item/wx.wxs +341 -0
- package/dist/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +218 -0
- package/dist/uni-ui/uni-table/uni-table.vue +455 -0
- package/dist/uni-ui/uni-tag/uni-tag.vue +252 -0
- package/dist/uni-ui/uni-tbody/uni-tbody.vue +29 -0
- package/dist/uni-ui/uni-td/uni-td.vue +90 -0
- package/dist/uni-ui/uni-th/filter-dropdown.vue +511 -0
- package/dist/uni-ui/uni-th/uni-th.vue +285 -0
- package/dist/uni-ui/uni-thead/uni-thead.vue +129 -0
- package/dist/uni-ui/uni-title/uni-title.vue +171 -0
- package/dist/uni-ui/uni-tooltip/uni-tooltip.vue +68 -0
- package/dist/uni-ui/uni-tr/table-checkbox.vue +179 -0
- package/dist/uni-ui/uni-tr/uni-tr.vue +171 -0
- package/dist/uni-ui/uni-transition/createAnimation.js +131 -0
- package/dist/uni-ui/uni-transition/uni-transition.vue +281 -0
- package/package.json +90 -0
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
class Calendar {
|
|
2
|
+
constructor({
|
|
3
|
+
selected,
|
|
4
|
+
startDate,
|
|
5
|
+
endDate,
|
|
6
|
+
range,
|
|
7
|
+
} = {}) {
|
|
8
|
+
// 当前日期
|
|
9
|
+
this.date = this.getDateObj(new Date()) // 当前初入日期
|
|
10
|
+
// 打点信息
|
|
11
|
+
this.selected = selected || [];
|
|
12
|
+
// 起始时间
|
|
13
|
+
this.startDate = startDate
|
|
14
|
+
// 终止时间
|
|
15
|
+
this.endDate = endDate
|
|
16
|
+
// 是否范围选择
|
|
17
|
+
this.range = range
|
|
18
|
+
// 多选状态
|
|
19
|
+
this.cleanMultipleStatus()
|
|
20
|
+
// 每周日期
|
|
21
|
+
this.weeks = {}
|
|
22
|
+
this.lastHover = false
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 设置日期
|
|
26
|
+
* @param {Object} date
|
|
27
|
+
*/
|
|
28
|
+
setDate(date) {
|
|
29
|
+
const selectDate = this.getDateObj(date)
|
|
30
|
+
this.getWeeks(selectDate.fullDate)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 清理多选状态
|
|
35
|
+
*/
|
|
36
|
+
cleanMultipleStatus() {
|
|
37
|
+
this.multipleStatus = {
|
|
38
|
+
before: '',
|
|
39
|
+
after: '',
|
|
40
|
+
data: []
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
setStartDate(startDate) {
|
|
45
|
+
this.startDate = startDate
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setEndDate(endDate) {
|
|
49
|
+
this.endDate = endDate
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getPreMonthObj(date){
|
|
53
|
+
date = fixIosDateFormat(date)
|
|
54
|
+
date = new Date(date)
|
|
55
|
+
|
|
56
|
+
const oldMonth = date.getMonth()
|
|
57
|
+
date.setMonth(oldMonth - 1)
|
|
58
|
+
const newMonth = date.getMonth()
|
|
59
|
+
if(oldMonth !== 0 && newMonth - oldMonth === 0){
|
|
60
|
+
date.setMonth(newMonth - 1)
|
|
61
|
+
}
|
|
62
|
+
return this.getDateObj(date)
|
|
63
|
+
}
|
|
64
|
+
getNextMonthObj(date){
|
|
65
|
+
date = fixIosDateFormat(date)
|
|
66
|
+
date = new Date(date)
|
|
67
|
+
|
|
68
|
+
const oldMonth = date.getMonth()
|
|
69
|
+
date.setMonth(oldMonth + 1)
|
|
70
|
+
const newMonth = date.getMonth()
|
|
71
|
+
if(newMonth - oldMonth > 1){
|
|
72
|
+
date.setMonth(newMonth - 1)
|
|
73
|
+
}
|
|
74
|
+
return this.getDateObj(date)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 获取指定格式Date对象
|
|
79
|
+
*/
|
|
80
|
+
getDateObj(date) {
|
|
81
|
+
date = fixIosDateFormat(date)
|
|
82
|
+
date = new Date(date)
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
fullDate: getDate(date),
|
|
86
|
+
year: date.getFullYear(),
|
|
87
|
+
month: addZero(date.getMonth() + 1),
|
|
88
|
+
date: addZero(date.getDate()),
|
|
89
|
+
day: date.getDay()
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 获取上一个月日期集合
|
|
95
|
+
*/
|
|
96
|
+
getPreMonthDays(amount, dateObj) {
|
|
97
|
+
const result = []
|
|
98
|
+
for (let i = amount - 1; i >= 0; i--) {
|
|
99
|
+
const month = dateObj.month - 1
|
|
100
|
+
result.push({
|
|
101
|
+
date: new Date(dateObj.year, month, -i).getDate(),
|
|
102
|
+
month,
|
|
103
|
+
disable: true
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
return result
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 获取本月日期集合
|
|
110
|
+
*/
|
|
111
|
+
getCurrentMonthDays(amount, dateObj) {
|
|
112
|
+
const result = []
|
|
113
|
+
const fullDate = this.date.fullDate
|
|
114
|
+
for (let i = 1; i <= amount; i++) {
|
|
115
|
+
const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}`
|
|
116
|
+
const isToday = fullDate === currentDate
|
|
117
|
+
// 获取打点信息
|
|
118
|
+
const info = this.selected && this.selected.find((item) => {
|
|
119
|
+
if (this.dateEqual(currentDate, item.date)) {
|
|
120
|
+
return item
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
// 日期禁用
|
|
125
|
+
let disableBefore = true
|
|
126
|
+
let disableAfter = true
|
|
127
|
+
if (this.startDate) {
|
|
128
|
+
disableBefore = dateCompare(this.startDate, currentDate)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (this.endDate) {
|
|
132
|
+
disableAfter = dateCompare(currentDate, this.endDate)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let multiples = this.multipleStatus.data
|
|
136
|
+
let multiplesStatus = -1
|
|
137
|
+
if (this.range && multiples) {
|
|
138
|
+
multiplesStatus = multiples.findIndex((item) => {
|
|
139
|
+
return this.dateEqual(item, currentDate)
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
const checked = multiplesStatus !== -1
|
|
143
|
+
|
|
144
|
+
result.push({
|
|
145
|
+
fullDate: currentDate,
|
|
146
|
+
year: dateObj.year,
|
|
147
|
+
date: i,
|
|
148
|
+
multiple: this.range ? checked : false,
|
|
149
|
+
beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after),
|
|
150
|
+
afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after),
|
|
151
|
+
month: dateObj.month,
|
|
152
|
+
disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(currentDate,this.endDate)),
|
|
153
|
+
isToday,
|
|
154
|
+
userChecked: false,
|
|
155
|
+
extraInfo: info
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
return result
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 获取下一个月日期集合
|
|
162
|
+
*/
|
|
163
|
+
_getNextMonthDays(amount, dateObj) {
|
|
164
|
+
const result = []
|
|
165
|
+
const month = dateObj.month + 1
|
|
166
|
+
for (let i = 1; i <= amount; i++) {
|
|
167
|
+
result.push({
|
|
168
|
+
date: i,
|
|
169
|
+
month,
|
|
170
|
+
disable: true
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
return result
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 获取当前日期详情
|
|
178
|
+
* @param {Object} date
|
|
179
|
+
*/
|
|
180
|
+
getInfo(date) {
|
|
181
|
+
if (!date) {
|
|
182
|
+
date = new Date()
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 比较时间是否相等
|
|
190
|
+
*/
|
|
191
|
+
dateEqual(before, after) {
|
|
192
|
+
before = new Date(fixIosDateFormat(before))
|
|
193
|
+
after = new Date(fixIosDateFormat(after))
|
|
194
|
+
return before.valueOf() === after.valueOf()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 比较真实起始日期
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
isLogicBefore(currentDate, before, after) {
|
|
202
|
+
let logicBefore = before
|
|
203
|
+
if (before && after) {
|
|
204
|
+
logicBefore = dateCompare(before, after) ? before : after
|
|
205
|
+
}
|
|
206
|
+
return this.dateEqual(logicBefore, currentDate)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
isLogicAfter(currentDate, before, after) {
|
|
210
|
+
let logicAfter = after
|
|
211
|
+
if (before && after) {
|
|
212
|
+
logicAfter = dateCompare(before, after) ? after : before
|
|
213
|
+
}
|
|
214
|
+
return this.dateEqual(logicAfter, currentDate)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 获取日期范围内所有日期
|
|
219
|
+
* @param {Object} begin
|
|
220
|
+
* @param {Object} end
|
|
221
|
+
*/
|
|
222
|
+
geDateAll(begin, end) {
|
|
223
|
+
var arr = []
|
|
224
|
+
var ab = begin.split('-')
|
|
225
|
+
var ae = end.split('-')
|
|
226
|
+
var db = new Date()
|
|
227
|
+
db.setFullYear(ab[0], ab[1] - 1, ab[2])
|
|
228
|
+
var de = new Date()
|
|
229
|
+
de.setFullYear(ae[0], ae[1] - 1, ae[2])
|
|
230
|
+
var unixDb = db.getTime() - 24 * 60 * 60 * 1000
|
|
231
|
+
var unixDe = de.getTime() - 24 * 60 * 60 * 1000
|
|
232
|
+
for (var k = unixDb; k <= unixDe;) {
|
|
233
|
+
k = k + 24 * 60 * 60 * 1000
|
|
234
|
+
arr.push(this.getDateObj(new Date(parseInt(k))).fullDate)
|
|
235
|
+
}
|
|
236
|
+
return arr
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* 获取多选状态
|
|
241
|
+
*/
|
|
242
|
+
setMultiple(fullDate) {
|
|
243
|
+
if (!this.range) return
|
|
244
|
+
|
|
245
|
+
let {
|
|
246
|
+
before,
|
|
247
|
+
after
|
|
248
|
+
} = this.multipleStatus
|
|
249
|
+
if (before && after) {
|
|
250
|
+
if (!this.lastHover) {
|
|
251
|
+
this.lastHover = true
|
|
252
|
+
return
|
|
253
|
+
}
|
|
254
|
+
this.multipleStatus.before = fullDate
|
|
255
|
+
this.multipleStatus.after = ''
|
|
256
|
+
this.multipleStatus.data = []
|
|
257
|
+
this.multipleStatus.fulldate = ''
|
|
258
|
+
this.lastHover = false
|
|
259
|
+
} else {
|
|
260
|
+
if (!before) {
|
|
261
|
+
this.multipleStatus.before = fullDate
|
|
262
|
+
this.lastHover = false
|
|
263
|
+
} else {
|
|
264
|
+
this.multipleStatus.after = fullDate
|
|
265
|
+
if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
|
|
266
|
+
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
|
|
267
|
+
.after);
|
|
268
|
+
} else {
|
|
269
|
+
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus
|
|
270
|
+
.before);
|
|
271
|
+
}
|
|
272
|
+
this.lastHover = true
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
this.getWeeks(fullDate)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* 鼠标 hover 更新多选状态
|
|
280
|
+
*/
|
|
281
|
+
setHoverMultiple(fullDate) {
|
|
282
|
+
if (!this.range || this.lastHover) return
|
|
283
|
+
|
|
284
|
+
const { before } = this.multipleStatus
|
|
285
|
+
|
|
286
|
+
if (!before) {
|
|
287
|
+
this.multipleStatus.before = fullDate
|
|
288
|
+
} else {
|
|
289
|
+
this.multipleStatus.after = fullDate
|
|
290
|
+
if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
|
|
291
|
+
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
|
|
292
|
+
} else {
|
|
293
|
+
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
this.getWeeks(fullDate)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* 更新默认值多选状态
|
|
301
|
+
*/
|
|
302
|
+
setDefaultMultiple(before, after) {
|
|
303
|
+
this.multipleStatus.before = before
|
|
304
|
+
this.multipleStatus.after = after
|
|
305
|
+
if (before && after) {
|
|
306
|
+
if (dateCompare(before, after)) {
|
|
307
|
+
this.multipleStatus.data = this.geDateAll(before, after);
|
|
308
|
+
this.getWeeks(after)
|
|
309
|
+
} else {
|
|
310
|
+
this.multipleStatus.data = this.geDateAll(after, before);
|
|
311
|
+
this.getWeeks(before)
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* 获取每周数据
|
|
318
|
+
* @param {Object} dateData
|
|
319
|
+
*/
|
|
320
|
+
getWeeks(dateData) {
|
|
321
|
+
const {
|
|
322
|
+
year,
|
|
323
|
+
month,
|
|
324
|
+
} = this.getDateObj(dateData)
|
|
325
|
+
|
|
326
|
+
const preMonthDayAmount = new Date(year, month - 1, 1).getDay()
|
|
327
|
+
const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData))
|
|
328
|
+
|
|
329
|
+
const currentMonthDayAmount = new Date(year, month, 0).getDate()
|
|
330
|
+
const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData))
|
|
331
|
+
|
|
332
|
+
const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount
|
|
333
|
+
const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData))
|
|
334
|
+
|
|
335
|
+
const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays]
|
|
336
|
+
|
|
337
|
+
const weeks = new Array(6)
|
|
338
|
+
for (let i = 0; i < calendarDays.length; i++) {
|
|
339
|
+
const index = Math.floor(i / 7)
|
|
340
|
+
if(!weeks[index]){
|
|
341
|
+
weeks[index] = new Array(7)
|
|
342
|
+
}
|
|
343
|
+
weeks[index][i % 7] = calendarDays[i]
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
this.calendar = calendarDays
|
|
347
|
+
this.weeks = weeks
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function getDateTime(date, hideSecond){
|
|
352
|
+
return `${getDate(date)} ${getTime(date, hideSecond)}`
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function getDate(date) {
|
|
356
|
+
date = fixIosDateFormat(date)
|
|
357
|
+
date = new Date(date)
|
|
358
|
+
const year = date.getFullYear()
|
|
359
|
+
const month = date.getMonth()+1
|
|
360
|
+
const day = date.getDate()
|
|
361
|
+
return `${year}-${addZero(month)}-${addZero(day)}`
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function getTime(date, hideSecond){
|
|
365
|
+
date = fixIosDateFormat(date)
|
|
366
|
+
date = new Date(date)
|
|
367
|
+
const hour = date.getHours()
|
|
368
|
+
const minute = date.getMinutes()
|
|
369
|
+
const second = date.getSeconds()
|
|
370
|
+
return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}`
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function addZero(num) {
|
|
374
|
+
if(num < 10){
|
|
375
|
+
num = `0${num}`
|
|
376
|
+
}
|
|
377
|
+
return num
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function getDefaultSecond(hideSecond) {
|
|
381
|
+
return hideSecond ? '00:00' : '00:00:00'
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function dateCompare(startDate, endDate) {
|
|
385
|
+
startDate = new Date(fixIosDateFormat(startDate))
|
|
386
|
+
endDate = new Date(fixIosDateFormat(endDate))
|
|
387
|
+
return startDate <= endDate
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function checkDate(date){
|
|
391
|
+
const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g
|
|
392
|
+
return date.match(dateReg)
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const dateTimeReg = /^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])( [0-5][0-9]:[0-5][0-9]:[0-5][0-9])?$/
|
|
396
|
+
function fixIosDateFormat(value) {
|
|
397
|
+
if (typeof value === 'string' && dateTimeReg.test(value)) {
|
|
398
|
+
value = value.replace(/-/g, '/')
|
|
399
|
+
}
|
|
400
|
+
return value
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export {Calendar, getDateTime, getDate, getTime, addZero, getDefaultSecond, dateCompare, checkDate, fixIosDateFormat}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// #ifdef H5
|
|
2
|
+
export default {
|
|
3
|
+
name: 'Keypress',
|
|
4
|
+
props: {
|
|
5
|
+
disable: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
mounted () {
|
|
11
|
+
const keyNames = {
|
|
12
|
+
esc: ['Esc', 'Escape'],
|
|
13
|
+
tab: 'Tab',
|
|
14
|
+
enter: 'Enter',
|
|
15
|
+
space: [' ', 'Spacebar'],
|
|
16
|
+
up: ['Up', 'ArrowUp'],
|
|
17
|
+
left: ['Left', 'ArrowLeft'],
|
|
18
|
+
right: ['Right', 'ArrowRight'],
|
|
19
|
+
down: ['Down', 'ArrowDown'],
|
|
20
|
+
delete: ['Backspace', 'Delete', 'Del']
|
|
21
|
+
}
|
|
22
|
+
const listener = ($event) => {
|
|
23
|
+
if (this.disable) {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
const keyName = Object.keys(keyNames).find(key => {
|
|
27
|
+
const keyName = $event.key
|
|
28
|
+
const value = keyNames[key]
|
|
29
|
+
return value === keyName || (Array.isArray(value) && value.includes(keyName))
|
|
30
|
+
})
|
|
31
|
+
if (keyName) {
|
|
32
|
+
// 避免和其他按键事件冲突
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
this.$emit(keyName, {})
|
|
35
|
+
}, 0)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
document.addEventListener('keyup', listener)
|
|
39
|
+
// this.$once('hook:beforeDestroy', () => {
|
|
40
|
+
// document.removeEventListener('keyup', listener)
|
|
41
|
+
// })
|
|
42
|
+
},
|
|
43
|
+
render: () => {}
|
|
44
|
+
}
|
|
45
|
+
// #endif
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view v-if="visibleSync" :class="{ 'uni-drawer--visible': showDrawer }" class="uni-drawer" @touchmove.stop.prevent="clear">
|
|
3
|
+
<view class="uni-drawer__mask" :class="{ 'uni-drawer__mask--visible': showDrawer && mask }" @tap="close('mask')" />
|
|
4
|
+
<view class="uni-drawer__content" :class="{'uni-drawer--right': rightMode,'uni-drawer--left': !rightMode, 'uni-drawer__content--visible': showDrawer}" :style="{width:drawerWidth+'px'}">
|
|
5
|
+
<slot />
|
|
6
|
+
</view>
|
|
7
|
+
<!-- #ifdef H5 -->
|
|
8
|
+
<keypress @esc="close('mask')" />
|
|
9
|
+
<!-- #endif -->
|
|
10
|
+
</view>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
// #ifdef H5
|
|
15
|
+
import keypress from './keypress.js'
|
|
16
|
+
// #endif
|
|
17
|
+
/**
|
|
18
|
+
* Drawer 抽屉
|
|
19
|
+
* @description 抽屉侧滑菜单
|
|
20
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=26
|
|
21
|
+
* @property {Boolean} mask = [true | false] 是否显示遮罩
|
|
22
|
+
* @property {Boolean} maskClick = [true | false] 点击遮罩是否关闭
|
|
23
|
+
* @property {Boolean} mode = [left | right] Drawer 滑出位置
|
|
24
|
+
* @value left 从左侧滑出
|
|
25
|
+
* @value right 从右侧侧滑出
|
|
26
|
+
* @property {Number} width 抽屉的宽度 ,仅 vue 页面生效
|
|
27
|
+
* @event {Function} close 组件关闭时触发事件
|
|
28
|
+
*/
|
|
29
|
+
export default {
|
|
30
|
+
name: 'UniDrawer',
|
|
31
|
+
components: {
|
|
32
|
+
// #ifdef H5
|
|
33
|
+
keypress
|
|
34
|
+
// #endif
|
|
35
|
+
},
|
|
36
|
+
emits:['change'],
|
|
37
|
+
props: {
|
|
38
|
+
/**
|
|
39
|
+
* 显示模式(左、右),只在初始化生效
|
|
40
|
+
*/
|
|
41
|
+
mode: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: ''
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* 蒙层显示状态
|
|
47
|
+
*/
|
|
48
|
+
mask: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: true
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* 遮罩是否可点击关闭
|
|
54
|
+
*/
|
|
55
|
+
maskClick:{
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: true
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* 抽屉宽度
|
|
61
|
+
*/
|
|
62
|
+
width: {
|
|
63
|
+
type: Number,
|
|
64
|
+
default: 220
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
data() {
|
|
68
|
+
return {
|
|
69
|
+
visibleSync: false,
|
|
70
|
+
showDrawer: false,
|
|
71
|
+
rightMode: false,
|
|
72
|
+
watchTimer: null,
|
|
73
|
+
drawerWidth: 220
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
created() {
|
|
77
|
+
// #ifndef APP-NVUE
|
|
78
|
+
this.drawerWidth = this.width
|
|
79
|
+
// #endif
|
|
80
|
+
this.rightMode = this.mode === 'right'
|
|
81
|
+
},
|
|
82
|
+
methods: {
|
|
83
|
+
clear(){},
|
|
84
|
+
close(type) {
|
|
85
|
+
// fixed by mehaotian 抽屉尚未完全关闭或遮罩禁止点击时不触发以下逻辑
|
|
86
|
+
if((type === 'mask' && !this.maskClick) || !this.visibleSync) return
|
|
87
|
+
this._change('showDrawer', 'visibleSync', false)
|
|
88
|
+
},
|
|
89
|
+
open() {
|
|
90
|
+
// fixed by mehaotian 处理重复点击打开的事件
|
|
91
|
+
if(this.visibleSync) return
|
|
92
|
+
this._change('visibleSync', 'showDrawer', true)
|
|
93
|
+
},
|
|
94
|
+
_change(param1, param2, status) {
|
|
95
|
+
this[param1] = status
|
|
96
|
+
if (this.watchTimer) {
|
|
97
|
+
clearTimeout(this.watchTimer)
|
|
98
|
+
}
|
|
99
|
+
this.watchTimer = setTimeout(() => {
|
|
100
|
+
this[param2] = status
|
|
101
|
+
this.$emit('change',status)
|
|
102
|
+
}, status ? 50 : 300)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<style lang="scss" >
|
|
109
|
+
$uni-mask: rgba($color: #000000, $alpha: 0.4) ;
|
|
110
|
+
// 抽屉宽度
|
|
111
|
+
$drawer-width: 220px;
|
|
112
|
+
|
|
113
|
+
.uni-drawer {
|
|
114
|
+
/* #ifndef APP-NVUE */
|
|
115
|
+
display: block;
|
|
116
|
+
/* #endif */
|
|
117
|
+
position: fixed;
|
|
118
|
+
top: 0;
|
|
119
|
+
left: 0;
|
|
120
|
+
right: 0;
|
|
121
|
+
bottom: 0;
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
z-index: 999;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.uni-drawer__content {
|
|
127
|
+
/* #ifndef APP-NVUE */
|
|
128
|
+
display: block;
|
|
129
|
+
/* #endif */
|
|
130
|
+
position: absolute;
|
|
131
|
+
top: 0;
|
|
132
|
+
width: $drawer-width;
|
|
133
|
+
bottom: 0;
|
|
134
|
+
background-color: $uni-bg-color;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.uni-drawer--left {
|
|
138
|
+
left: 0;
|
|
139
|
+
/* #ifdef APP-NVUE */
|
|
140
|
+
transform: translateX(-$drawer-width);
|
|
141
|
+
/* #endif */
|
|
142
|
+
/* #ifndef APP-NVUE */
|
|
143
|
+
transform: translateX(-100%);
|
|
144
|
+
/* #endif */
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.uni-drawer--right {
|
|
148
|
+
right: 0;
|
|
149
|
+
/* #ifdef APP-NVUE */
|
|
150
|
+
transform: translateX($drawer-width);
|
|
151
|
+
/* #endif */
|
|
152
|
+
/* #ifndef APP-NVUE */
|
|
153
|
+
transform: translateX(100%);
|
|
154
|
+
/* #endif */
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.uni-drawer__content--visible {
|
|
158
|
+
transform: translateX(0px);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
.uni-drawer__mask {
|
|
163
|
+
/* #ifndef APP-NVUE */
|
|
164
|
+
display: block;
|
|
165
|
+
/* #endif */
|
|
166
|
+
opacity: 0;
|
|
167
|
+
position: absolute;
|
|
168
|
+
top: 0;
|
|
169
|
+
left: 0;
|
|
170
|
+
bottom: 0;
|
|
171
|
+
right: 0;
|
|
172
|
+
background-color: $uni-mask;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.uni-drawer__mask--visible {
|
|
176
|
+
/* #ifndef APP-NVUE */
|
|
177
|
+
display: block;
|
|
178
|
+
/* #endif */
|
|
179
|
+
opacity: 1;
|
|
180
|
+
}
|
|
181
|
+
</style>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @desc 函数防抖
|
|
3
|
+
* @param func 目标函数
|
|
4
|
+
* @param wait 延迟执行毫秒数
|
|
5
|
+
* @param immediate true - 立即执行, false - 延迟执行
|
|
6
|
+
*/
|
|
7
|
+
export const debounce = function(func, wait = 1000, immediate = true) {
|
|
8
|
+
let timer;
|
|
9
|
+
console.log(1);
|
|
10
|
+
return function() {
|
|
11
|
+
console.log(123);
|
|
12
|
+
let context = this,
|
|
13
|
+
args = arguments;
|
|
14
|
+
if (timer) clearTimeout(timer);
|
|
15
|
+
if (immediate) {
|
|
16
|
+
let callNow = !timer;
|
|
17
|
+
timer = setTimeout(() => {
|
|
18
|
+
timer = null;
|
|
19
|
+
}, wait);
|
|
20
|
+
if (callNow) func.apply(context, args);
|
|
21
|
+
} else {
|
|
22
|
+
timer = setTimeout(() => {
|
|
23
|
+
func.apply(context, args);
|
|
24
|
+
}, wait)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @desc 函数节流
|
|
30
|
+
* @param func 函数
|
|
31
|
+
* @param wait 延迟执行毫秒数
|
|
32
|
+
* @param type 1 使用表时间戳,在时间段开始的时候触发 2 使用表定时器,在时间段结束的时候触发
|
|
33
|
+
*/
|
|
34
|
+
export const throttle = (func, wait = 1000, type = 1) => {
|
|
35
|
+
let previous = 0;
|
|
36
|
+
let timeout;
|
|
37
|
+
return function() {
|
|
38
|
+
let context = this;
|
|
39
|
+
let args = arguments;
|
|
40
|
+
if (type === 1) {
|
|
41
|
+
let now = Date.now();
|
|
42
|
+
|
|
43
|
+
if (now - previous > wait) {
|
|
44
|
+
func.apply(context, args);
|
|
45
|
+
previous = now;
|
|
46
|
+
}
|
|
47
|
+
} else if (type === 2) {
|
|
48
|
+
if (!timeout) {
|
|
49
|
+
timeout = setTimeout(() => {
|
|
50
|
+
timeout = null;
|
|
51
|
+
func.apply(context, args)
|
|
52
|
+
}, wait)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|