@vtj/materials 0.10.1-alpha.1 → 0.10.1-alpha.2
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/assets/antdv/index.umd.js +2 -2
- package/dist/assets/charts/index.umd.js +2 -2
- package/dist/assets/element/index.umd.js +2 -2
- package/dist/assets/ui/index.umd.js +2 -2
- package/dist/assets/uni-h5/index.umd.js +2 -2
- package/dist/assets/uni-ui/index.umd.js +3 -3
- package/dist/assets/vant/index.umd.js +2 -2
- package/dist/deps/@vtj/charts/index.umd.js +2 -2
- package/dist/deps/@vtj/icons/index.umd.js +2 -2
- package/dist/deps/@vtj/ui/index.umd.js +2 -2
- package/dist/deps/@vtj/uni/index.umd.js +2 -2
- package/dist/deps/@vtj/utils/index.umd.js +2 -2
- package/dist/deps/mockjs/mock-min.js +10 -0
- package/dist/deps/uni-ui/index.umd.js +1 -1
- package/dist/deps/uni-ui/style.css +1 -1
- package/package.json +5 -5
- package/src/uni-ui/components/badge.ts +52 -0
- package/src/uni-ui/index.ts +197 -3
- package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +177 -0
- package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +947 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/en.json +22 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hans.json +22 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hant.json +22 -0
- package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +940 -0
- package/src/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +1232 -0
- package/src/uni-ui/lib/uni-datetime-picker/util.js +421 -0
- package/src/uni-ui/lib/uni-forms/uni-forms.vue +416 -0
- package/src/uni-ui/lib/uni-forms/utils.js +293 -0
- package/src/uni-ui/lib/uni-forms/validate.js +486 -0
- package/src/uni-ui/lib/uni-popup/i18n/en.json +7 -0
- package/src/uni-ui/lib/uni-popup/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hans.json +7 -0
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hant.json +7 -0
- package/src/uni-ui/lib/uni-popup/keypress.js +45 -0
- package/src/uni-ui/lib/uni-popup/popup.js +26 -0
- package/src/uni-ui/lib/uni-popup/uni-popup.uvue +90 -0
- package/src/uni-ui/lib/uni-popup/uni-popup.vue +552 -0
- package/src/uni-ui/lib/uni-swipe-action-item/bindingx.js +302 -0
- package/src/uni-ui/lib/uni-swipe-action-item/isPC.js +12 -0
- package/src/uni-ui/lib/uni-swipe-action-item/mpalipay.js +195 -0
- package/src/uni-ui/lib/uni-swipe-action-item/mpother.js +260 -0
- package/src/uni-ui/lib/uni-swipe-action-item/mpwxs.js +84 -0
- package/src/uni-ui/lib/uni-swipe-action-item/render.js +270 -0
- package/src/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +494 -0
- package/src/uni-ui/lib/uni-swipe-action-item/wx.wxs +341 -0
- package/src/uni-ui/lib/uni-th/filter-dropdown.vue +511 -0
- package/src/uni-ui/lib/uni-th/uni-th.vue +295 -0
- package/src/uni-ui/lib/uni-tr/table-checkbox.vue +179 -0
- package/src/uni-ui/lib/uni-tr/uni-tr.vue +184 -0
- package/src/uni-ui/lib/uni.scss +76 -0
- package/src/uni-ui/polyfill.ts +41 -0
- package/src/version.ts +2 -2
@@ -0,0 +1,947 @@
|
|
1
|
+
<template>
|
2
|
+
<view class="uni-calendar" @mouseleave="leaveCale">
|
3
|
+
|
4
|
+
<view v-if="!insert && show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}"
|
5
|
+
@click="maskClick"></view>
|
6
|
+
|
7
|
+
<view v-if="insert || show" class="uni-calendar__content"
|
8
|
+
:class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow, 'uni-calendar__content-mobile': aniMaskShow}">
|
9
|
+
<view class="uni-calendar__header" :class="{'uni-calendar__header-mobile' :!insert}">
|
10
|
+
|
11
|
+
<view class="uni-calendar__header-btn-box" @click.stop="changeMonth('pre')">
|
12
|
+
<view class="uni-calendar__header-btn uni-calendar--left"></view>
|
13
|
+
</view>
|
14
|
+
|
15
|
+
<picker mode="date" :value="date" fields="month" @change="bindDateChange">
|
16
|
+
<text
|
17
|
+
class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text>
|
18
|
+
</picker>
|
19
|
+
|
20
|
+
<view class="uni-calendar__header-btn-box" @click.stop="changeMonth('next')">
|
21
|
+
<view class="uni-calendar__header-btn uni-calendar--right"></view>
|
22
|
+
</view>
|
23
|
+
|
24
|
+
<view v-if="!insert" class="dialog-close" @click="maskClick">
|
25
|
+
<view class="dialog-close-plus" data-id="close"></view>
|
26
|
+
<view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
|
27
|
+
</view>
|
28
|
+
</view>
|
29
|
+
<view class="uni-calendar__box">
|
30
|
+
|
31
|
+
<view v-if="showMonth" class="uni-calendar__box-bg">
|
32
|
+
<text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
|
33
|
+
</view>
|
34
|
+
|
35
|
+
<view class="uni-calendar__weeks" style="padding-bottom: 7px;">
|
36
|
+
<view class="uni-calendar__weeks-day">
|
37
|
+
<text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
|
38
|
+
</view>
|
39
|
+
<view class="uni-calendar__weeks-day">
|
40
|
+
<text class="uni-calendar__weeks-day-text">{{MONText}}</text>
|
41
|
+
</view>
|
42
|
+
<view class="uni-calendar__weeks-day">
|
43
|
+
<text class="uni-calendar__weeks-day-text">{{TUEText}}</text>
|
44
|
+
</view>
|
45
|
+
<view class="uni-calendar__weeks-day">
|
46
|
+
<text class="uni-calendar__weeks-day-text">{{WEDText}}</text>
|
47
|
+
</view>
|
48
|
+
<view class="uni-calendar__weeks-day">
|
49
|
+
<text class="uni-calendar__weeks-day-text">{{THUText}}</text>
|
50
|
+
</view>
|
51
|
+
<view class="uni-calendar__weeks-day">
|
52
|
+
<text class="uni-calendar__weeks-day-text">{{FRIText}}</text>
|
53
|
+
</view>
|
54
|
+
<view class="uni-calendar__weeks-day">
|
55
|
+
<text class="uni-calendar__weeks-day-text">{{SATText}}</text>
|
56
|
+
</view>
|
57
|
+
</view>
|
58
|
+
|
59
|
+
<view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex">
|
60
|
+
<view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex">
|
61
|
+
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar" :selected="selected"
|
62
|
+
:checkHover="range" @change="choiceDate" @handleMouse="handleMouse">
|
63
|
+
</calendar-item>
|
64
|
+
</view>
|
65
|
+
</view>
|
66
|
+
</view>
|
67
|
+
|
68
|
+
<view v-if="!insert && !range && hasTime" class="uni-date-changed uni-calendar--fixed-top"
|
69
|
+
style="padding: 0 80px;">
|
70
|
+
<view class="uni-date-changed--time-date">{{tempSingleDate ? tempSingleDate : selectDateText}}</view>
|
71
|
+
<time-picker type="time" :start="timepickerStartTime" :end="timepickerEndTime" v-model="time"
|
72
|
+
:disabled="!tempSingleDate" :border="false" :hide-second="hideSecond" class="time-picker-style">
|
73
|
+
</time-picker>
|
74
|
+
</view>
|
75
|
+
|
76
|
+
<view v-if="!insert && range && hasTime" class="uni-date-changed uni-calendar--fixed-top">
|
77
|
+
<view class="uni-date-changed--time-start">
|
78
|
+
<view class="uni-date-changed--time-date">{{tempRange.before ? tempRange.before : startDateText}}
|
79
|
+
</view>
|
80
|
+
<time-picker type="time" :start="timepickerStartTime" v-model="timeRange.startTime" :border="false"
|
81
|
+
:hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style">
|
82
|
+
</time-picker>
|
83
|
+
</view>
|
84
|
+
<view style="line-height: 50px;">
|
85
|
+
<uni-icons type="arrowthinright" color="#999"></uni-icons>
|
86
|
+
</view>
|
87
|
+
<view class="uni-date-changed--time-end">
|
88
|
+
<view class="uni-date-changed--time-date">{{tempRange.after ? tempRange.after : endDateText}}</view>
|
89
|
+
<time-picker type="time" :end="timepickerEndTime" v-model="timeRange.endTime" :border="false"
|
90
|
+
:hide-second="hideSecond" :disabled="!tempRange.after" class="time-picker-style">
|
91
|
+
</time-picker>
|
92
|
+
</view>
|
93
|
+
</view>
|
94
|
+
|
95
|
+
<view v-if="!insert" class="uni-date-changed uni-date-btn--ok">
|
96
|
+
<view class="uni-datetime-picker--btn" @click="confirm">{{confirmText}}</view>
|
97
|
+
</view>
|
98
|
+
</view>
|
99
|
+
</view>
|
100
|
+
</template>
|
101
|
+
|
102
|
+
<script>
|
103
|
+
import {
|
104
|
+
Calendar,
|
105
|
+
getDate,
|
106
|
+
getTime
|
107
|
+
} from './util.js';
|
108
|
+
import calendarItem from './calendar-item.vue'
|
109
|
+
import timePicker from './time-picker.vue'
|
110
|
+
|
111
|
+
import {
|
112
|
+
initVueI18n
|
113
|
+
} from '@dcloudio/uni-i18n'
|
114
|
+
import i18nMessages from './i18n/index.js'
|
115
|
+
const {
|
116
|
+
t
|
117
|
+
} = initVueI18n(i18nMessages)
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Calendar 日历
|
121
|
+
* @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
|
122
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=56
|
123
|
+
* @property {String} date 自定义当前时间,默认为今天
|
124
|
+
* @property {String} startDate 日期选择范围-开始日期
|
125
|
+
* @property {String} endDate 日期选择范围-结束日期
|
126
|
+
* @property {Boolean} range 范围选择
|
127
|
+
* @property {Boolean} insert = [true|false] 插入模式,默认为false
|
128
|
+
* @value true 弹窗模式
|
129
|
+
* @value false 插入模式
|
130
|
+
* @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
|
131
|
+
* @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
|
132
|
+
* @property {Boolean} showMonth 是否选择月份为背景
|
133
|
+
* @property {[String} defaultValue 选择器打开时默认显示的时间
|
134
|
+
* @event {Function} change 日期改变,`insert :ture` 时生效
|
135
|
+
* @event {Function} confirm 确认选择`insert :false` 时生效
|
136
|
+
* @event {Function} monthSwitch 切换月份时触发
|
137
|
+
* @example <uni-calendar :insert="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
|
138
|
+
*/
|
139
|
+
export default {
|
140
|
+
components: {
|
141
|
+
calendarItem,
|
142
|
+
timePicker
|
143
|
+
},
|
144
|
+
|
145
|
+
options: {
|
146
|
+
// #ifdef MP-TOUTIAO
|
147
|
+
virtualHost: false,
|
148
|
+
// #endif
|
149
|
+
// #ifndef MP-TOUTIAO
|
150
|
+
virtualHost: true
|
151
|
+
// #endif
|
152
|
+
},
|
153
|
+
props: {
|
154
|
+
date: {
|
155
|
+
type: String,
|
156
|
+
default: ''
|
157
|
+
},
|
158
|
+
defTime: {
|
159
|
+
type: [String, Object],
|
160
|
+
default: ''
|
161
|
+
},
|
162
|
+
selectableTimes: {
|
163
|
+
type: [Object],
|
164
|
+
default () {
|
165
|
+
return {}
|
166
|
+
}
|
167
|
+
},
|
168
|
+
selected: {
|
169
|
+
type: Array,
|
170
|
+
default () {
|
171
|
+
return []
|
172
|
+
}
|
173
|
+
},
|
174
|
+
startDate: {
|
175
|
+
type: String,
|
176
|
+
default: ''
|
177
|
+
},
|
178
|
+
endDate: {
|
179
|
+
type: String,
|
180
|
+
default: ''
|
181
|
+
},
|
182
|
+
startPlaceholder: {
|
183
|
+
type: String,
|
184
|
+
default: ''
|
185
|
+
},
|
186
|
+
endPlaceholder: {
|
187
|
+
type: String,
|
188
|
+
default: ''
|
189
|
+
},
|
190
|
+
range: {
|
191
|
+
type: Boolean,
|
192
|
+
default: false
|
193
|
+
},
|
194
|
+
hasTime: {
|
195
|
+
type: Boolean,
|
196
|
+
default: false
|
197
|
+
},
|
198
|
+
insert: {
|
199
|
+
type: Boolean,
|
200
|
+
default: true
|
201
|
+
},
|
202
|
+
showMonth: {
|
203
|
+
type: Boolean,
|
204
|
+
default: true
|
205
|
+
},
|
206
|
+
clearDate: {
|
207
|
+
type: Boolean,
|
208
|
+
default: true
|
209
|
+
},
|
210
|
+
checkHover: {
|
211
|
+
type: Boolean,
|
212
|
+
default: true
|
213
|
+
},
|
214
|
+
hideSecond: {
|
215
|
+
type: [Boolean],
|
216
|
+
default: false
|
217
|
+
},
|
218
|
+
pleStatus: {
|
219
|
+
type: Object,
|
220
|
+
default () {
|
221
|
+
return {
|
222
|
+
before: '',
|
223
|
+
after: '',
|
224
|
+
data: [],
|
225
|
+
fulldate: ''
|
226
|
+
}
|
227
|
+
}
|
228
|
+
},
|
229
|
+
defaultValue: {
|
230
|
+
type: [String, Object, Array],
|
231
|
+
default: ''
|
232
|
+
}
|
233
|
+
},
|
234
|
+
data() {
|
235
|
+
return {
|
236
|
+
show: false,
|
237
|
+
weeks: [],
|
238
|
+
calendar: {},
|
239
|
+
nowDate: {},
|
240
|
+
aniMaskShow: false,
|
241
|
+
firstEnter: true,
|
242
|
+
time: '',
|
243
|
+
timeRange: {
|
244
|
+
startTime: '',
|
245
|
+
endTime: ''
|
246
|
+
},
|
247
|
+
tempSingleDate: '',
|
248
|
+
tempRange: {
|
249
|
+
before: '',
|
250
|
+
after: ''
|
251
|
+
}
|
252
|
+
}
|
253
|
+
},
|
254
|
+
watch: {
|
255
|
+
date: {
|
256
|
+
immediate: true,
|
257
|
+
handler(newVal) {
|
258
|
+
if (!this.range) {
|
259
|
+
this.tempSingleDate = newVal
|
260
|
+
setTimeout(() => {
|
261
|
+
this.init(newVal)
|
262
|
+
}, 100)
|
263
|
+
}
|
264
|
+
}
|
265
|
+
},
|
266
|
+
defTime: {
|
267
|
+
immediate: true,
|
268
|
+
handler(newVal) {
|
269
|
+
if (!this.range) {
|
270
|
+
this.time = newVal
|
271
|
+
} else {
|
272
|
+
this.timeRange.startTime = newVal.start
|
273
|
+
this.timeRange.endTime = newVal.end
|
274
|
+
}
|
275
|
+
}
|
276
|
+
},
|
277
|
+
startDate(val) {
|
278
|
+
// 字节小程序 watch 早于 created
|
279
|
+
if (!this.cale) {
|
280
|
+
return
|
281
|
+
}
|
282
|
+
this.cale.setStartDate(val)
|
283
|
+
this.cale.setDate(this.nowDate.fullDate)
|
284
|
+
this.weeks = this.cale.weeks
|
285
|
+
},
|
286
|
+
endDate(val) {
|
287
|
+
// 字节小程序 watch 早于 created
|
288
|
+
if (!this.cale) {
|
289
|
+
return
|
290
|
+
}
|
291
|
+
this.cale.setEndDate(val)
|
292
|
+
this.cale.setDate(this.nowDate.fullDate)
|
293
|
+
this.weeks = this.cale.weeks
|
294
|
+
},
|
295
|
+
selected(newVal) {
|
296
|
+
// 字节小程序 watch 早于 created
|
297
|
+
if (!this.cale) {
|
298
|
+
return
|
299
|
+
}
|
300
|
+
this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
|
301
|
+
this.weeks = this.cale.weeks
|
302
|
+
},
|
303
|
+
pleStatus: {
|
304
|
+
immediate: true,
|
305
|
+
handler(newVal) {
|
306
|
+
const {
|
307
|
+
before,
|
308
|
+
after,
|
309
|
+
fulldate,
|
310
|
+
which
|
311
|
+
} = newVal
|
312
|
+
this.tempRange.before = before
|
313
|
+
this.tempRange.after = after
|
314
|
+
setTimeout(() => {
|
315
|
+
if (fulldate) {
|
316
|
+
this.cale.setHoverMultiple(fulldate)
|
317
|
+
if (before && after) {
|
318
|
+
this.cale.lastHover = true
|
319
|
+
if (this.rangeWithinMonth(after, before)) return
|
320
|
+
this.setDate(before)
|
321
|
+
} else {
|
322
|
+
this.cale.setMultiple(fulldate)
|
323
|
+
this.setDate(this.nowDate.fullDate)
|
324
|
+
this.calendar.fullDate = ''
|
325
|
+
this.cale.lastHover = false
|
326
|
+
}
|
327
|
+
} else {
|
328
|
+
// 字节小程序 watch 早于 created
|
329
|
+
if (!this.cale) {
|
330
|
+
return
|
331
|
+
}
|
332
|
+
|
333
|
+
this.cale.setDefaultMultiple(before, after)
|
334
|
+
if (which === 'left' && before) {
|
335
|
+
this.setDate(before)
|
336
|
+
this.weeks = this.cale.weeks
|
337
|
+
} else if (after) {
|
338
|
+
this.setDate(after)
|
339
|
+
this.weeks = this.cale.weeks
|
340
|
+
}
|
341
|
+
this.cale.lastHover = true
|
342
|
+
}
|
343
|
+
}, 16)
|
344
|
+
}
|
345
|
+
}
|
346
|
+
},
|
347
|
+
computed: {
|
348
|
+
timepickerStartTime() {
|
349
|
+
const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate
|
350
|
+
return activeDate === this.startDate ? this.selectableTimes.start : ''
|
351
|
+
},
|
352
|
+
timepickerEndTime() {
|
353
|
+
const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate
|
354
|
+
return activeDate === this.endDate ? this.selectableTimes.end : ''
|
355
|
+
},
|
356
|
+
/**
|
357
|
+
* for i18n
|
358
|
+
*/
|
359
|
+
selectDateText() {
|
360
|
+
return t("uni-datetime-picker.selectDate")
|
361
|
+
},
|
362
|
+
startDateText() {
|
363
|
+
return this.startPlaceholder || t("uni-datetime-picker.startDate")
|
364
|
+
},
|
365
|
+
endDateText() {
|
366
|
+
return this.endPlaceholder || t("uni-datetime-picker.endDate")
|
367
|
+
},
|
368
|
+
okText() {
|
369
|
+
return t("uni-datetime-picker.ok")
|
370
|
+
},
|
371
|
+
yearText() {
|
372
|
+
return t("uni-datetime-picker.year")
|
373
|
+
},
|
374
|
+
monthText() {
|
375
|
+
return t("uni-datetime-picker.month")
|
376
|
+
},
|
377
|
+
MONText() {
|
378
|
+
return t("uni-calender.MON")
|
379
|
+
},
|
380
|
+
TUEText() {
|
381
|
+
return t("uni-calender.TUE")
|
382
|
+
},
|
383
|
+
WEDText() {
|
384
|
+
return t("uni-calender.WED")
|
385
|
+
},
|
386
|
+
THUText() {
|
387
|
+
return t("uni-calender.THU")
|
388
|
+
},
|
389
|
+
FRIText() {
|
390
|
+
return t("uni-calender.FRI")
|
391
|
+
},
|
392
|
+
SATText() {
|
393
|
+
return t("uni-calender.SAT")
|
394
|
+
},
|
395
|
+
SUNText() {
|
396
|
+
return t("uni-calender.SUN")
|
397
|
+
},
|
398
|
+
confirmText() {
|
399
|
+
return t("uni-calender.confirm")
|
400
|
+
},
|
401
|
+
},
|
402
|
+
created() {
|
403
|
+
// 获取日历方法实例
|
404
|
+
this.cale = new Calendar({
|
405
|
+
selected: this.selected,
|
406
|
+
startDate: this.startDate,
|
407
|
+
endDate: this.endDate,
|
408
|
+
range: this.range,
|
409
|
+
})
|
410
|
+
// 选中某一天
|
411
|
+
this.init(this.date)
|
412
|
+
},
|
413
|
+
methods: {
|
414
|
+
leaveCale() {
|
415
|
+
this.firstEnter = true
|
416
|
+
},
|
417
|
+
handleMouse(weeks) {
|
418
|
+
if (weeks.disable) return
|
419
|
+
if (this.cale.lastHover) return
|
420
|
+
let {
|
421
|
+
before,
|
422
|
+
after
|
423
|
+
} = this.cale.multipleStatus
|
424
|
+
if (!before) return
|
425
|
+
this.calendar = weeks
|
426
|
+
// 设置范围选
|
427
|
+
this.cale.setHoverMultiple(this.calendar.fullDate)
|
428
|
+
this.weeks = this.cale.weeks
|
429
|
+
// hover时,进入一个日历,更新另一个
|
430
|
+
if (this.firstEnter) {
|
431
|
+
this.$emit('firstEnterCale', this.cale.multipleStatus)
|
432
|
+
this.firstEnter = false
|
433
|
+
}
|
434
|
+
},
|
435
|
+
rangeWithinMonth(A, B) {
|
436
|
+
const [yearA, monthA] = A.split('-')
|
437
|
+
const [yearB, monthB] = B.split('-')
|
438
|
+
return yearA === yearB && monthA === monthB
|
439
|
+
},
|
440
|
+
// 蒙版点击事件
|
441
|
+
maskClick() {
|
442
|
+
this.close()
|
443
|
+
this.$emit('maskClose')
|
444
|
+
},
|
445
|
+
|
446
|
+
clearCalender() {
|
447
|
+
if (this.range) {
|
448
|
+
this.timeRange.startTime = ''
|
449
|
+
this.timeRange.endTime = ''
|
450
|
+
this.tempRange.before = ''
|
451
|
+
this.tempRange.after = ''
|
452
|
+
this.cale.multipleStatus.before = ''
|
453
|
+
this.cale.multipleStatus.after = ''
|
454
|
+
this.cale.multipleStatus.data = []
|
455
|
+
this.cale.lastHover = false
|
456
|
+
} else {
|
457
|
+
this.time = ''
|
458
|
+
this.tempSingleDate = ''
|
459
|
+
}
|
460
|
+
this.calendar.fullDate = ''
|
461
|
+
this.setDate(new Date())
|
462
|
+
},
|
463
|
+
|
464
|
+
bindDateChange(e) {
|
465
|
+
const value = e.detail.value + '-1'
|
466
|
+
this.setDate(value)
|
467
|
+
},
|
468
|
+
/**
|
469
|
+
* 初始化日期显示
|
470
|
+
* @param {Object} date
|
471
|
+
*/
|
472
|
+
init(date) {
|
473
|
+
// 字节小程序 watch 早于 created
|
474
|
+
if (!this.cale) {
|
475
|
+
return
|
476
|
+
}
|
477
|
+
this.cale.setDate(date || new Date())
|
478
|
+
this.weeks = this.cale.weeks
|
479
|
+
this.nowDate = this.cale.getInfo(date)
|
480
|
+
this.calendar = {
|
481
|
+
...this.nowDate
|
482
|
+
}
|
483
|
+
if (!date) {
|
484
|
+
// 优化date为空默认不选中今天
|
485
|
+
this.calendar.fullDate = ''
|
486
|
+
if (this.defaultValue && !this.range) {
|
487
|
+
// 暂时只支持移动端非范围选择
|
488
|
+
const defaultDate = new Date(this.defaultValue)
|
489
|
+
const fullDate = getDate(defaultDate)
|
490
|
+
const year = defaultDate.getFullYear()
|
491
|
+
const month = defaultDate.getMonth() + 1
|
492
|
+
const date = defaultDate.getDate()
|
493
|
+
const day = defaultDate.getDay()
|
494
|
+
this.calendar = {
|
495
|
+
fullDate,
|
496
|
+
year,
|
497
|
+
month,
|
498
|
+
date,
|
499
|
+
day
|
500
|
+
},
|
501
|
+
this.tempSingleDate = fullDate
|
502
|
+
this.time = getTime(defaultDate, this.hideSecond)
|
503
|
+
}
|
504
|
+
}
|
505
|
+
},
|
506
|
+
/**
|
507
|
+
* 打开日历弹窗
|
508
|
+
*/
|
509
|
+
open() {
|
510
|
+
// 弹窗模式并且清理数据
|
511
|
+
if (this.clearDate && !this.insert) {
|
512
|
+
this.cale.cleanMultipleStatus()
|
513
|
+
this.init(this.date)
|
514
|
+
}
|
515
|
+
this.show = true
|
516
|
+
this.$nextTick(() => {
|
517
|
+
setTimeout(() => {
|
518
|
+
this.aniMaskShow = true
|
519
|
+
}, 50)
|
520
|
+
})
|
521
|
+
},
|
522
|
+
/**
|
523
|
+
* 关闭日历弹窗
|
524
|
+
*/
|
525
|
+
close() {
|
526
|
+
this.aniMaskShow = false
|
527
|
+
this.$nextTick(() => {
|
528
|
+
setTimeout(() => {
|
529
|
+
this.show = false
|
530
|
+
this.$emit('close')
|
531
|
+
}, 300)
|
532
|
+
})
|
533
|
+
},
|
534
|
+
/**
|
535
|
+
* 确认按钮
|
536
|
+
*/
|
537
|
+
confirm() {
|
538
|
+
this.setEmit('confirm')
|
539
|
+
this.close()
|
540
|
+
},
|
541
|
+
/**
|
542
|
+
* 变化触发
|
543
|
+
*/
|
544
|
+
change(isSingleChange) {
|
545
|
+
if (!this.insert && !isSingleChange) return
|
546
|
+
this.setEmit('change')
|
547
|
+
},
|
548
|
+
/**
|
549
|
+
* 选择月份触发
|
550
|
+
*/
|
551
|
+
monthSwitch() {
|
552
|
+
let {
|
553
|
+
year,
|
554
|
+
month
|
555
|
+
} = this.nowDate
|
556
|
+
this.$emit('monthSwitch', {
|
557
|
+
year,
|
558
|
+
month: Number(month)
|
559
|
+
})
|
560
|
+
},
|
561
|
+
/**
|
562
|
+
* 派发事件
|
563
|
+
* @param {Object} name
|
564
|
+
*/
|
565
|
+
setEmit(name) {
|
566
|
+
if (!this.range) {
|
567
|
+
if (!this.calendar.fullDate) {
|
568
|
+
this.calendar = this.cale.getInfo(new Date())
|
569
|
+
this.tempSingleDate = this.calendar.fullDate
|
570
|
+
}
|
571
|
+
if (this.hasTime && !this.time) {
|
572
|
+
this.time = getTime(new Date(), this.hideSecond)
|
573
|
+
}
|
574
|
+
}
|
575
|
+
let {
|
576
|
+
year,
|
577
|
+
month,
|
578
|
+
date,
|
579
|
+
fullDate,
|
580
|
+
extraInfo
|
581
|
+
} = this.calendar
|
582
|
+
this.$emit(name, {
|
583
|
+
range: this.cale.multipleStatus,
|
584
|
+
year,
|
585
|
+
month,
|
586
|
+
date,
|
587
|
+
time: this.time,
|
588
|
+
timeRange: this.timeRange,
|
589
|
+
fulldate: fullDate,
|
590
|
+
extraInfo: extraInfo || {}
|
591
|
+
})
|
592
|
+
},
|
593
|
+
/**
|
594
|
+
* 选择天触发
|
595
|
+
* @param {Object} weeks
|
596
|
+
*/
|
597
|
+
choiceDate(weeks) {
|
598
|
+
if (weeks.disable) return
|
599
|
+
this.calendar = weeks
|
600
|
+
this.calendar.userChecked = true
|
601
|
+
// 设置多选
|
602
|
+
this.cale.setMultiple(this.calendar.fullDate, true)
|
603
|
+
this.weeks = this.cale.weeks
|
604
|
+
this.tempSingleDate = this.calendar.fullDate
|
605
|
+
const beforeDate = new Date(this.cale.multipleStatus.before).getTime()
|
606
|
+
const afterDate = new Date(this.cale.multipleStatus.after).getTime()
|
607
|
+
if (beforeDate > afterDate && afterDate) {
|
608
|
+
this.tempRange.before = this.cale.multipleStatus.after
|
609
|
+
this.tempRange.after = this.cale.multipleStatus.before
|
610
|
+
} else {
|
611
|
+
this.tempRange.before = this.cale.multipleStatus.before
|
612
|
+
this.tempRange.after = this.cale.multipleStatus.after
|
613
|
+
}
|
614
|
+
this.change(true)
|
615
|
+
},
|
616
|
+
changeMonth(type) {
|
617
|
+
let newDate
|
618
|
+
if (type === 'pre') {
|
619
|
+
newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate
|
620
|
+
} else if (type === 'next') {
|
621
|
+
newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate
|
622
|
+
}
|
623
|
+
|
624
|
+
this.setDate(newDate)
|
625
|
+
this.monthSwitch()
|
626
|
+
},
|
627
|
+
/**
|
628
|
+
* 设置日期
|
629
|
+
* @param {Object} date
|
630
|
+
*/
|
631
|
+
setDate(date) {
|
632
|
+
this.cale.setDate(date)
|
633
|
+
this.weeks = this.cale.weeks
|
634
|
+
this.nowDate = this.cale.getInfo(date)
|
635
|
+
}
|
636
|
+
}
|
637
|
+
}
|
638
|
+
</script>
|
639
|
+
|
640
|
+
<style lang="scss">
|
641
|
+
$uni-primary: #007aff !default;
|
642
|
+
|
643
|
+
.uni-calendar {
|
644
|
+
/* #ifndef APP-NVUE */
|
645
|
+
display: flex;
|
646
|
+
/* #endif */
|
647
|
+
flex-direction: column;
|
648
|
+
}
|
649
|
+
|
650
|
+
.uni-calendar__mask {
|
651
|
+
position: fixed;
|
652
|
+
bottom: 0;
|
653
|
+
top: 0;
|
654
|
+
left: 0;
|
655
|
+
right: 0;
|
656
|
+
background-color: rgba(0, 0, 0, 0.4);
|
657
|
+
transition-property: opacity;
|
658
|
+
transition-duration: 0.3s;
|
659
|
+
opacity: 0;
|
660
|
+
/* #ifndef APP-NVUE */
|
661
|
+
z-index: 99;
|
662
|
+
/* #endif */
|
663
|
+
}
|
664
|
+
|
665
|
+
.uni-calendar--mask-show {
|
666
|
+
opacity: 1
|
667
|
+
}
|
668
|
+
|
669
|
+
.uni-calendar--fixed {
|
670
|
+
position: fixed;
|
671
|
+
bottom: calc(var(--window-bottom));
|
672
|
+
left: 0;
|
673
|
+
right: 0;
|
674
|
+
transition-property: transform;
|
675
|
+
transition-duration: 0.3s;
|
676
|
+
transform: translateY(460px);
|
677
|
+
/* #ifndef APP-NVUE */
|
678
|
+
z-index: 99;
|
679
|
+
/* #endif */
|
680
|
+
}
|
681
|
+
|
682
|
+
.uni-calendar--ani-show {
|
683
|
+
transform: translateY(0);
|
684
|
+
}
|
685
|
+
|
686
|
+
.uni-calendar__content {
|
687
|
+
background-color: #fff;
|
688
|
+
}
|
689
|
+
|
690
|
+
.uni-calendar__content-mobile {
|
691
|
+
border-top-left-radius: 10px;
|
692
|
+
border-top-right-radius: 10px;
|
693
|
+
box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, 0.1);
|
694
|
+
}
|
695
|
+
|
696
|
+
.uni-calendar__header {
|
697
|
+
position: relative;
|
698
|
+
/* #ifndef APP-NVUE */
|
699
|
+
display: flex;
|
700
|
+
/* #endif */
|
701
|
+
flex-direction: row;
|
702
|
+
justify-content: center;
|
703
|
+
align-items: center;
|
704
|
+
height: 50px;
|
705
|
+
}
|
706
|
+
|
707
|
+
.uni-calendar__header-mobile {
|
708
|
+
padding: 10px;
|
709
|
+
padding-bottom: 0;
|
710
|
+
}
|
711
|
+
|
712
|
+
.uni-calendar--fixed-top {
|
713
|
+
/* #ifndef APP-NVUE */
|
714
|
+
display: flex;
|
715
|
+
/* #endif */
|
716
|
+
flex-direction: row;
|
717
|
+
justify-content: space-between;
|
718
|
+
border-top-color: rgba(0, 0, 0, 0.4);
|
719
|
+
border-top-style: solid;
|
720
|
+
border-top-width: 1px;
|
721
|
+
}
|
722
|
+
|
723
|
+
.uni-calendar--fixed-width {
|
724
|
+
width: 50px;
|
725
|
+
}
|
726
|
+
|
727
|
+
.uni-calendar__backtoday {
|
728
|
+
position: absolute;
|
729
|
+
right: 0;
|
730
|
+
top: 25rpx;
|
731
|
+
padding: 0 5px;
|
732
|
+
padding-left: 10px;
|
733
|
+
height: 25px;
|
734
|
+
line-height: 25px;
|
735
|
+
font-size: 12px;
|
736
|
+
border-top-left-radius: 25px;
|
737
|
+
border-bottom-left-radius: 25px;
|
738
|
+
color: #fff;
|
739
|
+
background-color: #f1f1f1;
|
740
|
+
}
|
741
|
+
|
742
|
+
.uni-calendar__header-text {
|
743
|
+
text-align: center;
|
744
|
+
width: 100px;
|
745
|
+
font-size: 15px;
|
746
|
+
color: #666;
|
747
|
+
}
|
748
|
+
|
749
|
+
.uni-calendar__button-text {
|
750
|
+
text-align: center;
|
751
|
+
width: 100px;
|
752
|
+
font-size: 14px;
|
753
|
+
color: $uni-primary;
|
754
|
+
/* #ifndef APP-NVUE */
|
755
|
+
letter-spacing: 3px;
|
756
|
+
/* #endif */
|
757
|
+
}
|
758
|
+
|
759
|
+
.uni-calendar__header-btn-box {
|
760
|
+
/* #ifndef APP-NVUE */
|
761
|
+
display: flex;
|
762
|
+
/* #endif */
|
763
|
+
flex-direction: row;
|
764
|
+
align-items: center;
|
765
|
+
justify-content: center;
|
766
|
+
width: 50px;
|
767
|
+
height: 50px;
|
768
|
+
}
|
769
|
+
|
770
|
+
.uni-calendar__header-btn {
|
771
|
+
width: 9px;
|
772
|
+
height: 9px;
|
773
|
+
border-left-color: #808080;
|
774
|
+
border-left-style: solid;
|
775
|
+
border-left-width: 1px;
|
776
|
+
border-top-color: #555555;
|
777
|
+
border-top-style: solid;
|
778
|
+
border-top-width: 1px;
|
779
|
+
}
|
780
|
+
|
781
|
+
.uni-calendar--left {
|
782
|
+
transform: rotate(-45deg);
|
783
|
+
}
|
784
|
+
|
785
|
+
.uni-calendar--right {
|
786
|
+
transform: rotate(135deg);
|
787
|
+
}
|
788
|
+
|
789
|
+
|
790
|
+
.uni-calendar__weeks {
|
791
|
+
position: relative;
|
792
|
+
/* #ifndef APP-NVUE */
|
793
|
+
display: flex;
|
794
|
+
/* #endif */
|
795
|
+
flex-direction: row;
|
796
|
+
}
|
797
|
+
|
798
|
+
.uni-calendar__weeks-item {
|
799
|
+
flex: 1;
|
800
|
+
}
|
801
|
+
|
802
|
+
.uni-calendar__weeks-day {
|
803
|
+
flex: 1;
|
804
|
+
/* #ifndef APP-NVUE */
|
805
|
+
display: flex;
|
806
|
+
/* #endif */
|
807
|
+
flex-direction: column;
|
808
|
+
justify-content: center;
|
809
|
+
align-items: center;
|
810
|
+
height: 40px;
|
811
|
+
border-bottom-color: #F5F5F5;
|
812
|
+
border-bottom-style: solid;
|
813
|
+
border-bottom-width: 1px;
|
814
|
+
}
|
815
|
+
|
816
|
+
.uni-calendar__weeks-day-text {
|
817
|
+
font-size: 12px;
|
818
|
+
color: #B2B2B2;
|
819
|
+
}
|
820
|
+
|
821
|
+
.uni-calendar__box {
|
822
|
+
position: relative;
|
823
|
+
// padding: 0 10px;
|
824
|
+
padding-bottom: 7px;
|
825
|
+
}
|
826
|
+
|
827
|
+
.uni-calendar__box-bg {
|
828
|
+
/* #ifndef APP-NVUE */
|
829
|
+
display: flex;
|
830
|
+
/* #endif */
|
831
|
+
justify-content: center;
|
832
|
+
align-items: center;
|
833
|
+
position: absolute;
|
834
|
+
top: 0;
|
835
|
+
left: 0;
|
836
|
+
right: 0;
|
837
|
+
bottom: 0;
|
838
|
+
}
|
839
|
+
|
840
|
+
.uni-calendar__box-bg-text {
|
841
|
+
font-size: 200px;
|
842
|
+
font-weight: bold;
|
843
|
+
color: #999;
|
844
|
+
opacity: 0.1;
|
845
|
+
text-align: center;
|
846
|
+
/* #ifndef APP-NVUE */
|
847
|
+
line-height: 1;
|
848
|
+
/* #endif */
|
849
|
+
}
|
850
|
+
|
851
|
+
.uni-date-changed {
|
852
|
+
padding: 0 10px;
|
853
|
+
// line-height: 50px;
|
854
|
+
text-align: center;
|
855
|
+
color: #333;
|
856
|
+
border-top-color: #DCDCDC;
|
857
|
+
;
|
858
|
+
border-top-style: solid;
|
859
|
+
border-top-width: 1px;
|
860
|
+
flex: 1;
|
861
|
+
}
|
862
|
+
|
863
|
+
.uni-date-btn--ok {
|
864
|
+
padding: 20px 15px;
|
865
|
+
}
|
866
|
+
|
867
|
+
.uni-date-changed--time-start {
|
868
|
+
/* #ifndef APP-NVUE */
|
869
|
+
display: flex;
|
870
|
+
/* #endif */
|
871
|
+
align-items: center;
|
872
|
+
}
|
873
|
+
|
874
|
+
.uni-date-changed--time-end {
|
875
|
+
/* #ifndef APP-NVUE */
|
876
|
+
display: flex;
|
877
|
+
/* #endif */
|
878
|
+
align-items: center;
|
879
|
+
}
|
880
|
+
|
881
|
+
.uni-date-changed--time-date {
|
882
|
+
color: #999;
|
883
|
+
line-height: 50px;
|
884
|
+
/* #ifdef MP-TOUTIAO */
|
885
|
+
font-size: 16px;
|
886
|
+
/* #endif */
|
887
|
+
margin-right: 5px;
|
888
|
+
// opacity: 0.6;
|
889
|
+
}
|
890
|
+
|
891
|
+
.time-picker-style {
|
892
|
+
// width: 62px;
|
893
|
+
/* #ifndef APP-NVUE */
|
894
|
+
display: flex;
|
895
|
+
/* #endif */
|
896
|
+
justify-content: center;
|
897
|
+
align-items: center
|
898
|
+
}
|
899
|
+
|
900
|
+
.mr-10 {
|
901
|
+
margin-right: 10px;
|
902
|
+
}
|
903
|
+
|
904
|
+
.dialog-close {
|
905
|
+
position: absolute;
|
906
|
+
top: 0;
|
907
|
+
right: 0;
|
908
|
+
bottom: 0;
|
909
|
+
/* #ifndef APP-NVUE */
|
910
|
+
display: flex;
|
911
|
+
/* #endif */
|
912
|
+
flex-direction: row;
|
913
|
+
align-items: center;
|
914
|
+
padding: 0 25px;
|
915
|
+
margin-top: 10px;
|
916
|
+
}
|
917
|
+
|
918
|
+
.dialog-close-plus {
|
919
|
+
width: 16px;
|
920
|
+
height: 2px;
|
921
|
+
background-color: #737987;
|
922
|
+
border-radius: 2px;
|
923
|
+
transform: rotate(45deg);
|
924
|
+
}
|
925
|
+
|
926
|
+
.dialog-close-rotate {
|
927
|
+
position: absolute;
|
928
|
+
transform: rotate(-45deg);
|
929
|
+
}
|
930
|
+
|
931
|
+
.uni-datetime-picker--btn {
|
932
|
+
border-radius: 100px;
|
933
|
+
height: 40px;
|
934
|
+
line-height: 40px;
|
935
|
+
background-color: $uni-primary;
|
936
|
+
color: #fff;
|
937
|
+
font-size: 16px;
|
938
|
+
letter-spacing: 2px;
|
939
|
+
}
|
940
|
+
|
941
|
+
/* #ifndef APP-NVUE */
|
942
|
+
.uni-datetime-picker--btn:active {
|
943
|
+
opacity: 0.7;
|
944
|
+
}
|
945
|
+
|
946
|
+
/* #endif */
|
947
|
+
</style>
|