@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,934 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uni-datetime-picker">
|
|
3
|
+
<view @click="initTimePicker">
|
|
4
|
+
<slot>
|
|
5
|
+
<view class="uni-datetime-picker-timebox-pointer"
|
|
6
|
+
:class="{'uni-datetime-picker-disabled': disabled, 'uni-datetime-picker-timebox': border}">
|
|
7
|
+
<text class="uni-datetime-picker-text">{{time}}</text>
|
|
8
|
+
<view v-if="!time" class="uni-datetime-picker-time">
|
|
9
|
+
<text class="uni-datetime-picker-text">{{selectTimeText}}</text>
|
|
10
|
+
</view>
|
|
11
|
+
</view>
|
|
12
|
+
</slot>
|
|
13
|
+
</view>
|
|
14
|
+
<view v-if="visible" id="mask" class="uni-datetime-picker-mask" @click="tiggerTimePicker"></view>
|
|
15
|
+
<view v-if="visible" class="uni-datetime-picker-popup" :class="[dateShow && timeShow ? '' : 'fix-nvue-height']"
|
|
16
|
+
:style="fixNvueBug">
|
|
17
|
+
<view class="uni-title">
|
|
18
|
+
<text class="uni-datetime-picker-text">{{selectTimeText}}</text>
|
|
19
|
+
</view>
|
|
20
|
+
<view v-if="dateShow" class="uni-datetime-picker__container-box">
|
|
21
|
+
<picker-view class="uni-datetime-picker-view" :indicator-style="indicatorStyle" :value="ymd"
|
|
22
|
+
@change="bindDateChange">
|
|
23
|
+
<picker-view-column>
|
|
24
|
+
<view class="uni-datetime-picker-item" v-for="(item,index) in years" :key="index">
|
|
25
|
+
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
|
26
|
+
</view>
|
|
27
|
+
</picker-view-column>
|
|
28
|
+
<picker-view-column>
|
|
29
|
+
<view class="uni-datetime-picker-item" v-for="(item,index) in months" :key="index">
|
|
30
|
+
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
|
31
|
+
</view>
|
|
32
|
+
</picker-view-column>
|
|
33
|
+
<picker-view-column>
|
|
34
|
+
<view class="uni-datetime-picker-item" v-for="(item,index) in days" :key="index">
|
|
35
|
+
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
|
36
|
+
</view>
|
|
37
|
+
</picker-view-column>
|
|
38
|
+
</picker-view>
|
|
39
|
+
<!-- 兼容 nvue 不支持伪类 -->
|
|
40
|
+
<text class="uni-datetime-picker-sign sign-left">-</text>
|
|
41
|
+
<text class="uni-datetime-picker-sign sign-right">-</text>
|
|
42
|
+
</view>
|
|
43
|
+
<view v-if="timeShow" class="uni-datetime-picker__container-box">
|
|
44
|
+
<picker-view class="uni-datetime-picker-view" :class="[hideSecond ? 'time-hide-second' : '']"
|
|
45
|
+
:indicator-style="indicatorStyle" :value="hms" @change="bindTimeChange">
|
|
46
|
+
<picker-view-column>
|
|
47
|
+
<view class="uni-datetime-picker-item" v-for="(item,index) in hours" :key="index">
|
|
48
|
+
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
|
49
|
+
</view>
|
|
50
|
+
</picker-view-column>
|
|
51
|
+
<picker-view-column>
|
|
52
|
+
<view class="uni-datetime-picker-item" v-for="(item,index) in minutes" :key="index">
|
|
53
|
+
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
|
54
|
+
</view>
|
|
55
|
+
</picker-view-column>
|
|
56
|
+
<picker-view-column v-if="!hideSecond">
|
|
57
|
+
<view class="uni-datetime-picker-item" v-for="(item,index) in seconds" :key="index">
|
|
58
|
+
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
|
59
|
+
</view>
|
|
60
|
+
</picker-view-column>
|
|
61
|
+
</picker-view>
|
|
62
|
+
<!-- 兼容 nvue 不支持伪类 -->
|
|
63
|
+
<text class="uni-datetime-picker-sign" :class="[hideSecond ? 'sign-center' : 'sign-left']">:</text>
|
|
64
|
+
<text v-if="!hideSecond" class="uni-datetime-picker-sign sign-right">:</text>
|
|
65
|
+
</view>
|
|
66
|
+
<view class="uni-datetime-picker-btn">
|
|
67
|
+
<view @click="clearTime">
|
|
68
|
+
<text class="uni-datetime-picker-btn-text">{{clearText}}</text>
|
|
69
|
+
</view>
|
|
70
|
+
<view class="uni-datetime-picker-btn-group">
|
|
71
|
+
<view class="uni-datetime-picker-cancel" @click="tiggerTimePicker">
|
|
72
|
+
<text class="uni-datetime-picker-btn-text">{{cancelText}}</text>
|
|
73
|
+
</view>
|
|
74
|
+
<view @click="setTime">
|
|
75
|
+
<text class="uni-datetime-picker-btn-text">{{okText}}</text>
|
|
76
|
+
</view>
|
|
77
|
+
</view>
|
|
78
|
+
</view>
|
|
79
|
+
</view>
|
|
80
|
+
</view>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<script>
|
|
84
|
+
import { initVueI18n } from '@dcloudio/uni-i18n'
|
|
85
|
+
import i18nMessages from './i18n'
|
|
86
|
+
const { t } = initVueI18n(i18nMessages)
|
|
87
|
+
import { fixIosDateFormat } from './util'
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* DatetimePicker 时间选择器
|
|
91
|
+
* @description 可以同时选择日期和时间的选择器
|
|
92
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=xxx
|
|
93
|
+
* @property {String} type = [datetime | date | time] 显示模式
|
|
94
|
+
* @property {Boolean} multiple = [true|false] 是否多选
|
|
95
|
+
* @property {String|Number} value 默认值
|
|
96
|
+
* @property {String|Number} start 起始日期或时间
|
|
97
|
+
* @property {String|Number} end 起始日期或时间
|
|
98
|
+
* @property {String} return-type = [timestamp | string]
|
|
99
|
+
* @event {Function} change 选中发生变化触发
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
export default {
|
|
103
|
+
name: 'UniDatetimePicker',
|
|
104
|
+
data() {
|
|
105
|
+
return {
|
|
106
|
+
indicatorStyle: `height: 50px;`,
|
|
107
|
+
visible: false,
|
|
108
|
+
fixNvueBug: {},
|
|
109
|
+
dateShow: true,
|
|
110
|
+
timeShow: true,
|
|
111
|
+
title: '日期和时间',
|
|
112
|
+
// 输入框当前时间
|
|
113
|
+
time: '',
|
|
114
|
+
// 当前的年月日时分秒
|
|
115
|
+
year: 1920,
|
|
116
|
+
month: 0,
|
|
117
|
+
day: 0,
|
|
118
|
+
hour: 0,
|
|
119
|
+
minute: 0,
|
|
120
|
+
second: 0,
|
|
121
|
+
// 起始时间
|
|
122
|
+
startYear: 1920,
|
|
123
|
+
startMonth: 1,
|
|
124
|
+
startDay: 1,
|
|
125
|
+
startHour: 0,
|
|
126
|
+
startMinute: 0,
|
|
127
|
+
startSecond: 0,
|
|
128
|
+
// 结束时间
|
|
129
|
+
endYear: 2120,
|
|
130
|
+
endMonth: 12,
|
|
131
|
+
endDay: 31,
|
|
132
|
+
endHour: 23,
|
|
133
|
+
endMinute: 59,
|
|
134
|
+
endSecond: 59,
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
props: {
|
|
138
|
+
type: {
|
|
139
|
+
type: String,
|
|
140
|
+
default: 'datetime'
|
|
141
|
+
},
|
|
142
|
+
value: {
|
|
143
|
+
type: [String, Number],
|
|
144
|
+
default: ''
|
|
145
|
+
},
|
|
146
|
+
modelValue: {
|
|
147
|
+
type: [String, Number],
|
|
148
|
+
default: ''
|
|
149
|
+
},
|
|
150
|
+
start: {
|
|
151
|
+
type: [Number, String],
|
|
152
|
+
default: ''
|
|
153
|
+
},
|
|
154
|
+
end: {
|
|
155
|
+
type: [Number, String],
|
|
156
|
+
default: ''
|
|
157
|
+
},
|
|
158
|
+
returnType: {
|
|
159
|
+
type: String,
|
|
160
|
+
default: 'string'
|
|
161
|
+
},
|
|
162
|
+
disabled: {
|
|
163
|
+
type: [Boolean, String],
|
|
164
|
+
default: false
|
|
165
|
+
},
|
|
166
|
+
border: {
|
|
167
|
+
type: [Boolean, String],
|
|
168
|
+
default: true
|
|
169
|
+
},
|
|
170
|
+
hideSecond: {
|
|
171
|
+
type: [Boolean, String],
|
|
172
|
+
default: false
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
watch: {
|
|
176
|
+
// #ifndef VUE3
|
|
177
|
+
value: {
|
|
178
|
+
handler(newVal) {
|
|
179
|
+
if (newVal) {
|
|
180
|
+
this.parseValue(fixIosDateFormat(newVal))
|
|
181
|
+
this.initTime(false)
|
|
182
|
+
} else {
|
|
183
|
+
this.time = ''
|
|
184
|
+
this.parseValue(Date.now())
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
immediate: true
|
|
188
|
+
},
|
|
189
|
+
// #endif
|
|
190
|
+
// #ifdef VUE3
|
|
191
|
+
modelValue: {
|
|
192
|
+
handler(newVal) {
|
|
193
|
+
if (newVal) {
|
|
194
|
+
this.parseValue(fixIosDateFormat(newVal))
|
|
195
|
+
this.initTime(false)
|
|
196
|
+
} else {
|
|
197
|
+
this.time = ''
|
|
198
|
+
this.parseValue(Date.now())
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
immediate: true
|
|
202
|
+
},
|
|
203
|
+
// #endif
|
|
204
|
+
type: {
|
|
205
|
+
handler(newValue) {
|
|
206
|
+
if (newValue === 'date') {
|
|
207
|
+
this.dateShow = true
|
|
208
|
+
this.timeShow = false
|
|
209
|
+
this.title = '日期'
|
|
210
|
+
} else if (newValue === 'time') {
|
|
211
|
+
this.dateShow = false
|
|
212
|
+
this.timeShow = true
|
|
213
|
+
this.title = '时间'
|
|
214
|
+
} else {
|
|
215
|
+
this.dateShow = true
|
|
216
|
+
this.timeShow = true
|
|
217
|
+
this.title = '日期和时间'
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
immediate: true
|
|
221
|
+
},
|
|
222
|
+
start: {
|
|
223
|
+
handler(newVal) {
|
|
224
|
+
this.parseDatetimeRange(fixIosDateFormat(newVal), 'start')
|
|
225
|
+
},
|
|
226
|
+
immediate: true
|
|
227
|
+
},
|
|
228
|
+
end: {
|
|
229
|
+
handler(newVal) {
|
|
230
|
+
this.parseDatetimeRange(fixIosDateFormat(newVal), 'end')
|
|
231
|
+
},
|
|
232
|
+
immediate: true
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
// 月、日、时、分、秒可选范围变化后,检查当前值是否在范围内,不在则当前值重置为可选范围第一项
|
|
236
|
+
months(newVal) {
|
|
237
|
+
this.checkValue('month', this.month, newVal)
|
|
238
|
+
},
|
|
239
|
+
days(newVal) {
|
|
240
|
+
this.checkValue('day', this.day, newVal)
|
|
241
|
+
},
|
|
242
|
+
hours(newVal) {
|
|
243
|
+
this.checkValue('hour', this.hour, newVal)
|
|
244
|
+
},
|
|
245
|
+
minutes(newVal) {
|
|
246
|
+
this.checkValue('minute', this.minute, newVal)
|
|
247
|
+
},
|
|
248
|
+
seconds(newVal) {
|
|
249
|
+
this.checkValue('second', this.second, newVal)
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
computed: {
|
|
253
|
+
// 当前年、月、日、时、分、秒选择范围
|
|
254
|
+
years() {
|
|
255
|
+
return this.getCurrentRange('year')
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
months() {
|
|
259
|
+
return this.getCurrentRange('month')
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
days() {
|
|
263
|
+
return this.getCurrentRange('day')
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
hours() {
|
|
267
|
+
return this.getCurrentRange('hour')
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
minutes() {
|
|
271
|
+
return this.getCurrentRange('minute')
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
seconds() {
|
|
275
|
+
return this.getCurrentRange('second')
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
// picker 当前值数组
|
|
279
|
+
ymd() {
|
|
280
|
+
return [this.year - this.minYear, this.month - this.minMonth, this.day - this.minDay]
|
|
281
|
+
},
|
|
282
|
+
hms() {
|
|
283
|
+
return [this.hour - this.minHour, this.minute - this.minMinute, this.second - this.minSecond]
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
// 当前 date 是 start
|
|
287
|
+
currentDateIsStart() {
|
|
288
|
+
return this.year === this.startYear && this.month === this.startMonth && this.day === this.startDay
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
// 当前 date 是 end
|
|
292
|
+
currentDateIsEnd() {
|
|
293
|
+
return this.year === this.endYear && this.month === this.endMonth && this.day === this.endDay
|
|
294
|
+
},
|
|
295
|
+
|
|
296
|
+
// 当前年、月、日、时、分、秒的最小值和最大值
|
|
297
|
+
minYear() {
|
|
298
|
+
return this.startYear
|
|
299
|
+
},
|
|
300
|
+
maxYear() {
|
|
301
|
+
return this.endYear
|
|
302
|
+
},
|
|
303
|
+
minMonth() {
|
|
304
|
+
if (this.year === this.startYear) {
|
|
305
|
+
return this.startMonth
|
|
306
|
+
} else {
|
|
307
|
+
return 1
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
maxMonth() {
|
|
311
|
+
if (this.year === this.endYear) {
|
|
312
|
+
return this.endMonth
|
|
313
|
+
} else {
|
|
314
|
+
return 12
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
minDay() {
|
|
318
|
+
if (this.year === this.startYear && this.month === this.startMonth) {
|
|
319
|
+
return this.startDay
|
|
320
|
+
} else {
|
|
321
|
+
return 1
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
maxDay() {
|
|
325
|
+
if (this.year === this.endYear && this.month === this.endMonth) {
|
|
326
|
+
return this.endDay
|
|
327
|
+
} else {
|
|
328
|
+
return this.daysInMonth(this.year, this.month)
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
minHour() {
|
|
332
|
+
if (this.type === 'datetime') {
|
|
333
|
+
if (this.currentDateIsStart) {
|
|
334
|
+
return this.startHour
|
|
335
|
+
} else {
|
|
336
|
+
return 0
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (this.type === 'time') {
|
|
340
|
+
return this.startHour
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
maxHour() {
|
|
344
|
+
if (this.type === 'datetime') {
|
|
345
|
+
if (this.currentDateIsEnd) {
|
|
346
|
+
return this.endHour
|
|
347
|
+
} else {
|
|
348
|
+
return 23
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (this.type === 'time') {
|
|
352
|
+
return this.endHour
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
minMinute() {
|
|
356
|
+
if (this.type === 'datetime') {
|
|
357
|
+
if (this.currentDateIsStart && this.hour === this.startHour) {
|
|
358
|
+
return this.startMinute
|
|
359
|
+
} else {
|
|
360
|
+
return 0
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if (this.type === 'time') {
|
|
364
|
+
if (this.hour === this.startHour) {
|
|
365
|
+
return this.startMinute
|
|
366
|
+
} else {
|
|
367
|
+
return 0
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
maxMinute() {
|
|
372
|
+
if (this.type === 'datetime') {
|
|
373
|
+
if (this.currentDateIsEnd && this.hour === this.endHour) {
|
|
374
|
+
return this.endMinute
|
|
375
|
+
} else {
|
|
376
|
+
return 59
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (this.type === 'time') {
|
|
380
|
+
if (this.hour === this.endHour) {
|
|
381
|
+
return this.endMinute
|
|
382
|
+
} else {
|
|
383
|
+
return 59
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
minSecond() {
|
|
388
|
+
if (this.type === 'datetime') {
|
|
389
|
+
if (this.currentDateIsStart && this.hour === this.startHour && this.minute === this.startMinute) {
|
|
390
|
+
return this.startSecond
|
|
391
|
+
} else {
|
|
392
|
+
return 0
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (this.type === 'time') {
|
|
396
|
+
if (this.hour === this.startHour && this.minute === this.startMinute) {
|
|
397
|
+
return this.startSecond
|
|
398
|
+
} else {
|
|
399
|
+
return 0
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
maxSecond() {
|
|
404
|
+
if (this.type === 'datetime') {
|
|
405
|
+
if (this.currentDateIsEnd && this.hour === this.endHour && this.minute === this.endMinute) {
|
|
406
|
+
return this.endSecond
|
|
407
|
+
} else {
|
|
408
|
+
return 59
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (this.type === 'time') {
|
|
412
|
+
if (this.hour === this.endHour && this.minute === this.endMinute) {
|
|
413
|
+
return this.endSecond
|
|
414
|
+
} else {
|
|
415
|
+
return 59
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* for i18n
|
|
422
|
+
*/
|
|
423
|
+
selectTimeText() {
|
|
424
|
+
return t("uni-datetime-picker.selectTime")
|
|
425
|
+
},
|
|
426
|
+
okText() {
|
|
427
|
+
return t("uni-datetime-picker.ok")
|
|
428
|
+
},
|
|
429
|
+
clearText() {
|
|
430
|
+
return t("uni-datetime-picker.clear")
|
|
431
|
+
},
|
|
432
|
+
cancelText() {
|
|
433
|
+
return t("uni-datetime-picker.cancel")
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
|
|
437
|
+
mounted() {
|
|
438
|
+
// #ifdef APP-NVUE
|
|
439
|
+
const res = uni.getSystemInfoSync();
|
|
440
|
+
this.fixNvueBug = {
|
|
441
|
+
top: res.windowHeight / 2,
|
|
442
|
+
left: res.windowWidth / 2
|
|
443
|
+
}
|
|
444
|
+
// #endif
|
|
445
|
+
},
|
|
446
|
+
|
|
447
|
+
methods: {
|
|
448
|
+
/**
|
|
449
|
+
* @param {Object} item
|
|
450
|
+
* 小于 10 在前面加个 0
|
|
451
|
+
*/
|
|
452
|
+
|
|
453
|
+
lessThanTen(item) {
|
|
454
|
+
return item < 10 ? '0' + item : item
|
|
455
|
+
},
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* 解析时分秒字符串,例如:00:00:00
|
|
459
|
+
* @param {String} timeString
|
|
460
|
+
*/
|
|
461
|
+
parseTimeType(timeString) {
|
|
462
|
+
if (timeString) {
|
|
463
|
+
let timeArr = timeString.split(':')
|
|
464
|
+
this.hour = Number(timeArr[0])
|
|
465
|
+
this.minute = Number(timeArr[1])
|
|
466
|
+
this.second = Number(timeArr[2])
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* 解析选择器初始值,类型可以是字符串、时间戳,例如:2000-10-02、'08:30:00'、 1610695109000
|
|
472
|
+
* @param {String | Number} datetime
|
|
473
|
+
*/
|
|
474
|
+
initPickerValue(datetime) {
|
|
475
|
+
let defaultValue = null
|
|
476
|
+
if (datetime) {
|
|
477
|
+
defaultValue = this.compareValueWithStartAndEnd(datetime, this.start, this.end)
|
|
478
|
+
} else {
|
|
479
|
+
defaultValue = Date.now()
|
|
480
|
+
defaultValue = this.compareValueWithStartAndEnd(defaultValue, this.start, this.end)
|
|
481
|
+
}
|
|
482
|
+
this.parseValue(defaultValue)
|
|
483
|
+
},
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* 初始值规则:
|
|
487
|
+
* - 用户设置初始值 value
|
|
488
|
+
* - 设置了起始时间 start、终止时间 end,并 start < value < end,初始值为 value, 否则初始值为 start
|
|
489
|
+
* - 只设置了起始时间 start,并 start < value,初始值为 value,否则初始值为 start
|
|
490
|
+
* - 只设置了终止时间 end,并 value < end,初始值为 value,否则初始值为 end
|
|
491
|
+
* - 无起始终止时间,则初始值为 value
|
|
492
|
+
* - 无初始值 value,则初始值为当前本地时间 Date.now()
|
|
493
|
+
* @param {Object} value
|
|
494
|
+
* @param {Object} dateBase
|
|
495
|
+
*/
|
|
496
|
+
compareValueWithStartAndEnd(value, start, end) {
|
|
497
|
+
let winner = null
|
|
498
|
+
value = this.superTimeStamp(value)
|
|
499
|
+
start = this.superTimeStamp(start)
|
|
500
|
+
end = this.superTimeStamp(end)
|
|
501
|
+
|
|
502
|
+
if (start && end) {
|
|
503
|
+
if (value < start) {
|
|
504
|
+
winner = new Date(start)
|
|
505
|
+
} else if (value > end) {
|
|
506
|
+
winner = new Date(end)
|
|
507
|
+
} else {
|
|
508
|
+
winner = new Date(value)
|
|
509
|
+
}
|
|
510
|
+
} else if (start && !end) {
|
|
511
|
+
winner = start <= value ? new Date(value) : new Date(start)
|
|
512
|
+
} else if (!start && end) {
|
|
513
|
+
winner = value <= end ? new Date(value) : new Date(end)
|
|
514
|
+
} else {
|
|
515
|
+
winner = new Date(value)
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
return winner
|
|
519
|
+
},
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* 转换为可比较的时间戳,接受日期、时分秒、时间戳
|
|
523
|
+
* @param {Object} value
|
|
524
|
+
*/
|
|
525
|
+
superTimeStamp(value) {
|
|
526
|
+
let dateBase = ''
|
|
527
|
+
if (this.type === 'time' && value && typeof value === 'string') {
|
|
528
|
+
const now = new Date()
|
|
529
|
+
const year = now.getFullYear()
|
|
530
|
+
const month = now.getMonth() + 1
|
|
531
|
+
const day = now.getDate()
|
|
532
|
+
dateBase = year + '/' + month + '/' + day + ' '
|
|
533
|
+
}
|
|
534
|
+
if (Number(value)) {
|
|
535
|
+
value = parseInt(value)
|
|
536
|
+
dateBase = 0
|
|
537
|
+
}
|
|
538
|
+
return this.createTimeStamp(dateBase + value)
|
|
539
|
+
},
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* 解析默认值 value,字符串、时间戳
|
|
543
|
+
* @param {Object} defaultTime
|
|
544
|
+
*/
|
|
545
|
+
parseValue(value) {
|
|
546
|
+
if (!value) {
|
|
547
|
+
return
|
|
548
|
+
}
|
|
549
|
+
if (this.type === 'time' && typeof value === "string") {
|
|
550
|
+
this.parseTimeType(value)
|
|
551
|
+
} else {
|
|
552
|
+
let defaultDate = null
|
|
553
|
+
defaultDate = new Date(value)
|
|
554
|
+
if (this.type !== 'time') {
|
|
555
|
+
this.year = defaultDate.getFullYear()
|
|
556
|
+
this.month = defaultDate.getMonth() + 1
|
|
557
|
+
this.day = defaultDate.getDate()
|
|
558
|
+
}
|
|
559
|
+
if (this.type !== 'date') {
|
|
560
|
+
this.hour = defaultDate.getHours()
|
|
561
|
+
this.minute = defaultDate.getMinutes()
|
|
562
|
+
this.second = defaultDate.getSeconds()
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if (this.hideSecond) {
|
|
566
|
+
this.second = 0
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* 解析可选择时间范围 start、end,年月日字符串、时间戳
|
|
572
|
+
* @param {Object} defaultTime
|
|
573
|
+
*/
|
|
574
|
+
parseDatetimeRange(point, pointType) {
|
|
575
|
+
// 时间为空,则重置为初始值
|
|
576
|
+
if (!point) {
|
|
577
|
+
if (pointType === 'start') {
|
|
578
|
+
this.startYear = 1920
|
|
579
|
+
this.startMonth = 1
|
|
580
|
+
this.startDay = 1
|
|
581
|
+
this.startHour = 0
|
|
582
|
+
this.startMinute = 0
|
|
583
|
+
this.startSecond = 0
|
|
584
|
+
}
|
|
585
|
+
if (pointType === 'end') {
|
|
586
|
+
this.endYear = 2120
|
|
587
|
+
this.endMonth = 12
|
|
588
|
+
this.endDay = 31
|
|
589
|
+
this.endHour = 23
|
|
590
|
+
this.endMinute = 59
|
|
591
|
+
this.endSecond = 59
|
|
592
|
+
}
|
|
593
|
+
return
|
|
594
|
+
}
|
|
595
|
+
if (this.type === 'time') {
|
|
596
|
+
const pointArr = point.split(':')
|
|
597
|
+
this[pointType + 'Hour'] = Number(pointArr[0])
|
|
598
|
+
this[pointType + 'Minute'] = Number(pointArr[1])
|
|
599
|
+
this[pointType + 'Second'] = Number(pointArr[2])
|
|
600
|
+
} else {
|
|
601
|
+
if (!point) {
|
|
602
|
+
pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60
|
|
603
|
+
return
|
|
604
|
+
}
|
|
605
|
+
if (Number(point)) {
|
|
606
|
+
point = parseInt(point)
|
|
607
|
+
}
|
|
608
|
+
// datetime 的 end 没有时分秒, 则不限制
|
|
609
|
+
const hasTime = /[0-9]:[0-9]/
|
|
610
|
+
if (this.type === 'datetime' && pointType === 'end' && typeof point === 'string' && !hasTime.test(
|
|
611
|
+
point)) {
|
|
612
|
+
point = point + ' 23:59:59'
|
|
613
|
+
}
|
|
614
|
+
const pointDate = new Date(point)
|
|
615
|
+
this[pointType + 'Year'] = pointDate.getFullYear()
|
|
616
|
+
this[pointType + 'Month'] = pointDate.getMonth() + 1
|
|
617
|
+
this[pointType + 'Day'] = pointDate.getDate()
|
|
618
|
+
if (this.type === 'datetime') {
|
|
619
|
+
this[pointType + 'Hour'] = pointDate.getHours()
|
|
620
|
+
this[pointType + 'Minute'] = pointDate.getMinutes()
|
|
621
|
+
this[pointType + 'Second'] = pointDate.getSeconds()
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
|
|
626
|
+
// 获取 年、月、日、时、分、秒 当前可选范围
|
|
627
|
+
getCurrentRange(value) {
|
|
628
|
+
const range = []
|
|
629
|
+
for (let i = this['min' + this.capitalize(value)]; i <= this['max' + this.capitalize(value)]; i++) {
|
|
630
|
+
range.push(i)
|
|
631
|
+
}
|
|
632
|
+
return range
|
|
633
|
+
},
|
|
634
|
+
|
|
635
|
+
// 字符串首字母大写
|
|
636
|
+
capitalize(str) {
|
|
637
|
+
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
638
|
+
},
|
|
639
|
+
|
|
640
|
+
// 检查当前值是否在范围内,不在则当前值重置为可选范围第一项
|
|
641
|
+
checkValue(name, value, values) {
|
|
642
|
+
if (values.indexOf(value) === -1) {
|
|
643
|
+
this[name] = values[0]
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
|
|
647
|
+
// 每个月的实际天数
|
|
648
|
+
daysInMonth(year, month) { // Use 1 for January, 2 for February, etc.
|
|
649
|
+
return new Date(year, month, 0).getDate();
|
|
650
|
+
},
|
|
651
|
+
|
|
652
|
+
//兼容 iOS、safari 日期格式
|
|
653
|
+
fixIosDateFormat(value) {
|
|
654
|
+
if (typeof value === 'string') {
|
|
655
|
+
value = value.replace(/-/g, '/')
|
|
656
|
+
}
|
|
657
|
+
return value
|
|
658
|
+
},
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* 生成时间戳
|
|
662
|
+
* @param {Object} time
|
|
663
|
+
*/
|
|
664
|
+
createTimeStamp(time) {
|
|
665
|
+
if (!time) return
|
|
666
|
+
if (typeof time === "number") {
|
|
667
|
+
return time
|
|
668
|
+
} else {
|
|
669
|
+
time = time.replace(/-/g, '/')
|
|
670
|
+
if (this.type === 'date') {
|
|
671
|
+
time = time + ' ' + '00:00:00'
|
|
672
|
+
}
|
|
673
|
+
return Date.parse(time)
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* 生成日期或时间的字符串
|
|
679
|
+
*/
|
|
680
|
+
createDomSting() {
|
|
681
|
+
const yymmdd = this.year +
|
|
682
|
+
'-' +
|
|
683
|
+
this.lessThanTen(this.month) +
|
|
684
|
+
'-' +
|
|
685
|
+
this.lessThanTen(this.day)
|
|
686
|
+
|
|
687
|
+
let hhmmss = this.lessThanTen(this.hour) +
|
|
688
|
+
':' +
|
|
689
|
+
this.lessThanTen(this.minute)
|
|
690
|
+
|
|
691
|
+
if (!this.hideSecond) {
|
|
692
|
+
hhmmss = hhmmss + ':' + this.lessThanTen(this.second)
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
if (this.type === 'date') {
|
|
696
|
+
return yymmdd
|
|
697
|
+
} else if (this.type === 'time') {
|
|
698
|
+
return hhmmss
|
|
699
|
+
} else {
|
|
700
|
+
return yymmdd + ' ' + hhmmss
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* 初始化返回值,并抛出 change 事件
|
|
706
|
+
*/
|
|
707
|
+
initTime(emit = true) {
|
|
708
|
+
this.time = this.createDomSting()
|
|
709
|
+
if (!emit) return
|
|
710
|
+
if (this.returnType === 'timestamp' && this.type !== 'time') {
|
|
711
|
+
this.$emit('change', this.createTimeStamp(this.time))
|
|
712
|
+
this.$emit('input', this.createTimeStamp(this.time))
|
|
713
|
+
this.$emit('update:modelValue', this.createTimeStamp(this.time))
|
|
714
|
+
} else {
|
|
715
|
+
this.$emit('change', this.time)
|
|
716
|
+
this.$emit('input', this.time)
|
|
717
|
+
this.$emit('update:modelValue', this.time)
|
|
718
|
+
}
|
|
719
|
+
},
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* 用户选择日期或时间更新 data
|
|
723
|
+
* @param {Object} e
|
|
724
|
+
*/
|
|
725
|
+
bindDateChange(e) {
|
|
726
|
+
const val = e.detail.value
|
|
727
|
+
this.year = this.years[val[0]]
|
|
728
|
+
this.month = this.months[val[1]]
|
|
729
|
+
this.day = this.days[val[2]]
|
|
730
|
+
},
|
|
731
|
+
bindTimeChange(e) {
|
|
732
|
+
const val = e.detail.value
|
|
733
|
+
this.hour = this.hours[val[0]]
|
|
734
|
+
this.minute = this.minutes[val[1]]
|
|
735
|
+
this.second = this.seconds[val[2]]
|
|
736
|
+
},
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* 初始化弹出层
|
|
740
|
+
*/
|
|
741
|
+
initTimePicker() {
|
|
742
|
+
if (this.disabled) return
|
|
743
|
+
const value = fixIosDateFormat(this.time)
|
|
744
|
+
this.initPickerValue(value)
|
|
745
|
+
this.visible = !this.visible
|
|
746
|
+
},
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* 触发或关闭弹框
|
|
750
|
+
*/
|
|
751
|
+
tiggerTimePicker(e) {
|
|
752
|
+
this.visible = !this.visible
|
|
753
|
+
},
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* 用户点击“清空”按钮,清空当前值
|
|
757
|
+
*/
|
|
758
|
+
clearTime() {
|
|
759
|
+
this.time = ''
|
|
760
|
+
this.$emit('change', this.time)
|
|
761
|
+
this.$emit('input', this.time)
|
|
762
|
+
this.$emit('update:modelValue', this.time)
|
|
763
|
+
this.tiggerTimePicker()
|
|
764
|
+
},
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* 用户点击“确定”按钮
|
|
768
|
+
*/
|
|
769
|
+
setTime() {
|
|
770
|
+
this.initTime()
|
|
771
|
+
this.tiggerTimePicker()
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
</script>
|
|
776
|
+
|
|
777
|
+
<style lang="scss">
|
|
778
|
+
$uni-primary: #007aff !default;
|
|
779
|
+
|
|
780
|
+
.uni-datetime-picker {
|
|
781
|
+
/* #ifndef APP-NVUE */
|
|
782
|
+
/* width: 100%; */
|
|
783
|
+
/* #endif */
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.uni-datetime-picker-view {
|
|
787
|
+
height: 130px;
|
|
788
|
+
width: 270px;
|
|
789
|
+
/* #ifndef APP-NVUE */
|
|
790
|
+
cursor: pointer;
|
|
791
|
+
/* #endif */
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
.uni-datetime-picker-item {
|
|
795
|
+
height: 50px;
|
|
796
|
+
line-height: 50px;
|
|
797
|
+
text-align: center;
|
|
798
|
+
font-size: 14px;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
.uni-datetime-picker-btn {
|
|
802
|
+
margin-top: 60px;
|
|
803
|
+
/* #ifndef APP-NVUE */
|
|
804
|
+
display: flex;
|
|
805
|
+
cursor: pointer;
|
|
806
|
+
/* #endif */
|
|
807
|
+
flex-direction: row;
|
|
808
|
+
justify-content: space-between;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
.uni-datetime-picker-btn-text {
|
|
812
|
+
font-size: 14px;
|
|
813
|
+
color: $uni-primary;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
.uni-datetime-picker-btn-group {
|
|
817
|
+
/* #ifndef APP-NVUE */
|
|
818
|
+
display: flex;
|
|
819
|
+
/* #endif */
|
|
820
|
+
flex-direction: row;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
.uni-datetime-picker-cancel {
|
|
824
|
+
margin-right: 30px;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
.uni-datetime-picker-mask {
|
|
828
|
+
position: fixed;
|
|
829
|
+
bottom: 0px;
|
|
830
|
+
top: 0px;
|
|
831
|
+
left: 0px;
|
|
832
|
+
right: 0px;
|
|
833
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
834
|
+
transition-duration: 0.3s;
|
|
835
|
+
z-index: 998;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
.uni-datetime-picker-popup {
|
|
839
|
+
border-radius: 8px;
|
|
840
|
+
padding: 30px;
|
|
841
|
+
width: 270px;
|
|
842
|
+
/* #ifdef APP-NVUE */
|
|
843
|
+
height: 500px;
|
|
844
|
+
/* #endif */
|
|
845
|
+
/* #ifdef APP-NVUE */
|
|
846
|
+
width: 330px;
|
|
847
|
+
/* #endif */
|
|
848
|
+
background-color: #fff;
|
|
849
|
+
position: fixed;
|
|
850
|
+
top: 50%;
|
|
851
|
+
left: 50%;
|
|
852
|
+
transform: translate(-50%, -50%);
|
|
853
|
+
transition-duration: 0.3s;
|
|
854
|
+
z-index: 999;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
.fix-nvue-height {
|
|
858
|
+
/* #ifdef APP-NVUE */
|
|
859
|
+
height: 330px;
|
|
860
|
+
/* #endif */
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
.uni-datetime-picker-time {
|
|
864
|
+
color: grey;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
.uni-datetime-picker-column {
|
|
868
|
+
height: 50px;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
.uni-datetime-picker-timebox {
|
|
872
|
+
|
|
873
|
+
border: 1px solid #E5E5E5;
|
|
874
|
+
border-radius: 5px;
|
|
875
|
+
padding: 7px 10px;
|
|
876
|
+
/* #ifndef APP-NVUE */
|
|
877
|
+
box-sizing: border-box;
|
|
878
|
+
cursor: pointer;
|
|
879
|
+
/* #endif */
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
.uni-datetime-picker-timebox-pointer {
|
|
883
|
+
/* #ifndef APP-NVUE */
|
|
884
|
+
cursor: pointer;
|
|
885
|
+
/* #endif */
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
.uni-datetime-picker-disabled {
|
|
890
|
+
opacity: 0.4;
|
|
891
|
+
/* #ifdef H5 */
|
|
892
|
+
cursor: not-allowed !important;
|
|
893
|
+
/* #endif */
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
.uni-datetime-picker-text {
|
|
897
|
+
font-size: 14px;
|
|
898
|
+
line-height: 50px
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
.uni-datetime-picker-sign {
|
|
902
|
+
position: absolute;
|
|
903
|
+
top: 53px;
|
|
904
|
+
/* 减掉 10px 的元素高度,兼容nvue */
|
|
905
|
+
color: #999;
|
|
906
|
+
/* #ifdef APP-NVUE */
|
|
907
|
+
font-size: 16px;
|
|
908
|
+
/* #endif */
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
.sign-left {
|
|
912
|
+
left: 86px;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
.sign-right {
|
|
916
|
+
right: 86px;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
.sign-center {
|
|
920
|
+
left: 135px;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
.uni-datetime-picker__container-box {
|
|
924
|
+
position: relative;
|
|
925
|
+
display: flex;
|
|
926
|
+
align-items: center;
|
|
927
|
+
justify-content: center;
|
|
928
|
+
margin-top: 40px;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
.time-hide-second {
|
|
932
|
+
width: 180px;
|
|
933
|
+
}
|
|
934
|
+
</style>
|