uview-plus 3.8.49 → 3.8.86
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/changelog.md +2043 -1827
- package/components/u-action-sheet/props.js +3 -1
- package/components/u-action-sheet/u-action-sheet.vue +1 -0
- package/components/u-album/props.js +3 -1
- package/components/u-alert/props.js +4 -2
- package/components/u-avatar/props.js +4 -1
- package/components/u-avatar-group/props.js +4 -1
- package/components/u-back-top/props.js +4 -1
- package/components/u-badge/props.js +4 -1
- package/components/u-barcode/u-barcode.vue +46 -15
- package/components/u-box/props.js +5 -2
- package/components/u-button/props.js +4 -1
- package/components/u-button/vue.scss +3 -3
- package/components/u-calendar/calendar.js +14 -2
- package/components/u-calendar/month.vue +41 -6
- package/components/u-calendar/props.js +63 -1
- package/components/u-calendar/u-calendar.vue +311 -2
- package/components/u-calendar-strip/props.js +3 -1
- package/components/u-canvas/u-canvas.vue +734 -423
- package/components/u-car-keyboard/props.js +3 -1
- package/components/u-card/props.js +3 -1
- package/components/u-cell/props.js +4 -1
- package/components/u-cell/u-cell.vue +1 -1
- package/components/u-cell-group/props.js +4 -1
- package/components/u-checkbox/props.js +4 -1
- package/components/u-checkbox/u-checkbox.vue +7 -3
- package/components/u-checkbox-group/props.js +3 -1
- package/components/u-circle-progress/props.js +4 -1
- package/components/u-code/props.js +4 -1
- package/components/u-code-input/props.js +4 -1
- package/components/u-col/props.js +4 -1
- package/components/u-collapse/props.js +4 -1
- package/components/u-collapse-item/props.js +4 -1
- package/components/u-color-picker/u-color-picker.vue +1 -0
- package/components/u-column-notice/props.js +4 -1
- package/components/u-count-down/props.js +4 -1
- package/components/u-count-to/props.js +4 -1
- package/components/u-cropper/u-cropper.vue +95 -51
- package/components/u-datetime-picker/props.js +4 -1
- package/components/u-divider/props.js +4 -1
- package/components/u-dragsort/u-dragsort.vue +2 -1
- package/components/u-dropdown/props.js +3 -1
- package/components/u-dropdown-item/props.js +3 -1
- package/components/u-empty/props.js +4 -1
- package/components/u-form/props.js +4 -1
- package/components/u-form-item/props.js +4 -1
- package/components/u-gap/props.js +4 -1
- package/components/u-grid/props.js +4 -1
- package/components/u-grid-item/props.js +4 -1
- package/components/u-guide/props.js +3 -1
- package/components/u-icon/props.js +4 -1
- package/components/u-icon/u-icon.vue +2 -2
- package/components/u-icon/upicon.ttf +0 -0
- package/components/u-icon/util.js +29 -7
- package/components/u-image/props.js +4 -1
- package/components/u-image/u-image.vue +280 -267
- package/components/u-index-anchor/props.js +4 -1
- package/components/u-index-item/props.js +2 -1
- package/components/u-index-list/props.js +4 -1
- package/components/u-input/props.js +3 -1
- package/components/u-input/u-input.vue +10 -1
- package/components/u-keyboard/props.js +4 -1
- package/components/u-line/props.js +4 -1
- package/components/u-line-progress/props.js +6 -3
- package/components/u-link/props.js +4 -1
- package/components/u-list/props.js +4 -1
- package/components/u-list-item/props.js +4 -1
- package/components/u-loading-icon/props.js +4 -1
- package/components/u-loading-page/props.js +3 -1
- package/components/u-loadmore/props.js +4 -1
- package/components/u-markdown/u-markdown.vue +45 -3
- package/components/u-modal/props.js +4 -1
- package/components/u-navbar/props.js +4 -2
- package/components/u-navbar/u-navbar.vue +15 -9
- package/components/u-no-network/props.js +4 -1
- package/components/u-notice-bar/props.js +4 -1
- package/components/u-notify/props.js +4 -1
- package/components/u-number-box/props.js +4 -1
- package/components/u-number-box/u-number-box.vue +2 -2
- package/components/u-number-keyboard/props.js +4 -1
- package/components/u-overlay/props.js +4 -1
- package/components/u-pagination/u-pagination.vue +60 -39
- package/components/u-parse/props.js +4 -1
- package/components/u-picker/props.js +4 -1
- package/components/u-picker/u-picker.vue +15 -0
- package/components/u-picker-column/props.js +3 -1
- package/components/u-popover/props.js +2 -1
- package/components/u-popup/props.js +4 -1
- package/components/u-poster/u-poster.vue +29 -14
- package/components/u-qrcode/qrcode.js +88 -87
- package/components/u-qrcode/u-qrcode.vue +138 -256
- package/components/u-radio/props.js +4 -1
- package/components/u-radio/u-radio.vue +7 -3
- package/components/u-radio-group/props.js +4 -1
- package/components/u-rate/props.js +4 -1
- package/components/u-read-more/props.js +4 -1
- package/components/u-row/props.js +4 -1
- package/components/u-row-notice/props.js +4 -1
- package/components/u-safe-bottom/props.js +2 -1
- package/components/u-scroll-list/props.js +4 -1
- package/components/u-search/props.js +3 -1
- package/components/u-skeleton/props.js +4 -1
- package/components/u-slider/props.js +3 -1
- package/components/u-slider/u-slider.vue +70 -28
- package/components/u-status-bar/props.js +4 -1
- package/components/u-steps/props.js +4 -1
- package/components/u-steps-item/props.js +4 -1
- package/components/u-sticky/props.js +4 -1
- package/components/u-sticky/u-sticky.vue +11 -0
- package/components/u-subsection/props.js +3 -1
- package/components/u-swipe-action/props.js +4 -1
- package/components/u-swipe-action-item/props.js +4 -1
- package/components/u-swipe-action-item/u-swipe-action-item.vue +14 -0
- package/components/u-swiper/props.js +9 -1
- package/components/u-swiper/swiper.js +1 -0
- package/components/u-swiper/u-swiper.vue +2 -0
- package/components/u-swiper-indicator/props.js +4 -1
- package/components/u-switch/props.js +4 -1
- package/components/u-tabbar/props.js +3 -1
- package/components/u-tabbar-item/props.js +4 -1
- package/components/u-table/props.js +3 -1
- package/components/u-table2/tableRow.vue +155 -69
- package/components/u-table2/u-table2.vue +328 -140
- package/components/u-tabs/props.js +4 -1
- package/components/u-tabs-item/props.js +3 -1
- package/components/u-tag/props.js +4 -1
- package/components/u-td/props.js +3 -1
- package/components/u-text/props.js +4 -1
- package/components/u-textarea/props.js +3 -1
- package/components/u-textarea/u-textarea.vue +16 -5
- package/components/u-th/props.js +3 -1
- package/components/u-toolbar/props.js +4 -1
- package/components/u-tooltip/props.js +10 -2
- package/components/u-tooltip/tooltip.js +2 -1
- package/components/u-tooltip/u-tooltip.vue +31 -3
- package/components/u-tr/props.js +3 -1
- package/components/u-transition/nvue-ani-map.js +75 -68
- package/components/u-transition/props.js +4 -1
- package/components/u-transition/transitionMixin.js +164 -163
- package/components/u-upload/props.js +4 -1
- package/components/u-upload/u-upload.vue +47 -40
- package/components/u-waterfall/u-waterfall.vue +50 -51
- package/index.js +65 -8
- package/libs/config/props.js +179 -204
- package/libs/css/components.scss +3 -0
- package/libs/function/uni-api-shims.js +29 -0
- package/libs/i18n/index.js +71 -36
- package/libs/i18n/locale-packs.js +11 -0
- package/libs/i18n/locales/all.js +23 -0
- package/libs/i18n/locales/{de.json → de.js} +1 -1
- package/libs/i18n/locales/{en.json → en.js} +2 -2
- package/libs/i18n/locales/{es.json → es.js} +1 -1
- package/libs/i18n/locales/{fr.json → fr.js} +2 -2
- package/libs/i18n/locales/{ja.json → ja.js} +1 -1
- package/libs/i18n/locales/{ko.json → ko.js} +1 -1
- package/libs/i18n/locales/{ru.json → ru.js} +1 -1
- package/libs/i18n/locales/{th.json → th.js} +1 -1
- package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
- package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
- package/libs/mixin/mixin.js +14 -4
- package/libs/util/gcanvas/bridge/bridge-weex.js +10 -5
- package/package.json +4 -5
- package/tsconfig.json +18 -0
- package/types/comps/calendar.d.ts +57 -0
- package/types/comps/checkbox.d.ts +12 -0
- package/types/comps/lineProgress.d.ts +5 -0
- package/types/comps/navbar.d.ts +3 -3
- package/types/comps/swiper.d.ts +5 -0
- package/types/comps/tooltip.d.ts +36 -1
- /package/components/u-markdown/{marked.esm.js → marked.esm.mjs} +0 -0
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
<u-popup
|
|
3
3
|
:show="show"
|
|
4
4
|
mode="bottom"
|
|
5
|
+
:overlay="overlay"
|
|
6
|
+
:duration="duration"
|
|
7
|
+
:overlayStyle="overlayStyle"
|
|
8
|
+
:overlayOpacity="overlayOpacity"
|
|
9
|
+
:zIndex="zIndex"
|
|
10
|
+
:safeAreaInsetBottom="safeAreaInsetBottom"
|
|
11
|
+
:safeAreaInsetTop="safeAreaInsetTop"
|
|
12
|
+
:bgColor="bgColor"
|
|
5
13
|
:closeable="!pageInline"
|
|
6
14
|
@close="close"
|
|
7
15
|
:round="round"
|
|
@@ -29,6 +37,28 @@
|
|
|
29
37
|
@nextYear="nextYear"
|
|
30
38
|
@today="jumpToToday"
|
|
31
39
|
></uHeader>
|
|
40
|
+
<view v-if="showTimePanel" class="u-calendar__time-panel">
|
|
41
|
+
<view v-if="mode === 'single'" class="u-calendar__time-row">
|
|
42
|
+
<text class="u-calendar__time-date">{{ singleDateLabel }}</text>
|
|
43
|
+
<view class="u-calendar__time-trigger" @click="openTimePicker('single')">
|
|
44
|
+
<text class="u-calendar__time-text">{{ singleTime }}</text>
|
|
45
|
+
</view>
|
|
46
|
+
</view>
|
|
47
|
+
<view v-else-if="mode === 'range' && rangeResultMode === 'boundary'">
|
|
48
|
+
<view class="u-calendar__time-row">
|
|
49
|
+
<text class="u-calendar__time-date">{{ rangeStartDateLabel }}</text>
|
|
50
|
+
<view class="u-calendar__time-trigger" @click="openTimePicker('start')">
|
|
51
|
+
<text class="u-calendar__time-text">{{ rangeStartTime }}</text>
|
|
52
|
+
</view>
|
|
53
|
+
</view>
|
|
54
|
+
<view class="u-calendar__time-row">
|
|
55
|
+
<text class="u-calendar__time-date">{{ rangeEndDateLabel }}</text>
|
|
56
|
+
<view class="u-calendar__time-trigger" @click="openTimePicker('end')">
|
|
57
|
+
<text class="u-calendar__time-text">{{ rangeEndTime }}</text>
|
|
58
|
+
</view>
|
|
59
|
+
</view>
|
|
60
|
+
</view>
|
|
61
|
+
</view>
|
|
32
62
|
<scroll-view
|
|
33
63
|
v-if="!monthSwitch"
|
|
34
64
|
:style="{
|
|
@@ -61,6 +91,7 @@
|
|
|
61
91
|
:forbidDaysToast="forbidDaysToast"
|
|
62
92
|
:monthFormat="monthFormat"
|
|
63
93
|
:todayDate="todayDate"
|
|
94
|
+
:todayColor="todayColor"
|
|
64
95
|
ref="month"
|
|
65
96
|
@monthSelected="monthSelected"
|
|
66
97
|
@updateMonthTop="onUpdateMonthTop"
|
|
@@ -94,6 +125,7 @@
|
|
|
94
125
|
:forbidDaysToast="forbidDaysToast"
|
|
95
126
|
:monthFormat="monthFormat"
|
|
96
127
|
:todayDate="todayDate"
|
|
128
|
+
:todayColor="todayColor"
|
|
97
129
|
ref="month"
|
|
98
130
|
@monthSelected="monthSelected"
|
|
99
131
|
@updateMonthTop="onUpdateMonthTop"
|
|
@@ -114,6 +146,32 @@
|
|
|
114
146
|
</slot>
|
|
115
147
|
</view>
|
|
116
148
|
</u-popup>
|
|
149
|
+
<u-popup
|
|
150
|
+
:show="timePickerShow"
|
|
151
|
+
mode="center"
|
|
152
|
+
:round="8"
|
|
153
|
+
:closeOnClickOverlay="true"
|
|
154
|
+
@close="closeTimePicker"
|
|
155
|
+
>
|
|
156
|
+
<view class="u-calendar__time-picker">
|
|
157
|
+
<view class="u-calendar__time-picker__header">
|
|
158
|
+
<text class="u-calendar__time-picker__cancel" @click="closeTimePicker">取消</text>
|
|
159
|
+
<text class="u-calendar__time-picker__title">选择时间</text>
|
|
160
|
+
<text class="u-calendar__time-picker__confirm" @click="confirmTimePicker">确定</text>
|
|
161
|
+
</view>
|
|
162
|
+
<picker-view class="u-calendar__time-picker__body" :value="timePickerValue" @change="onTimePickerChange">
|
|
163
|
+
<picker-view-column>
|
|
164
|
+
<view v-for="(item, index) in hourOptions" :key="`h-${index}`" class="u-calendar__time-picker__item">{{ item }}</view>
|
|
165
|
+
</picker-view-column>
|
|
166
|
+
<picker-view-column v-if="timePrecision !== 'hour'">
|
|
167
|
+
<view v-for="(item, index) in minuteOptions" :key="`m-${index}`" class="u-calendar__time-picker__item">{{ item }}</view>
|
|
168
|
+
</picker-view-column>
|
|
169
|
+
<picker-view-column v-if="timePrecision === 'second'">
|
|
170
|
+
<view v-for="(item, index) in secondOptions" :key="`s-${index}`" class="u-calendar__time-picker__item">{{ item }}</view>
|
|
171
|
+
</picker-view-column>
|
|
172
|
+
</picker-view>
|
|
173
|
+
</view>
|
|
174
|
+
</u-popup>
|
|
117
175
|
</template>
|
|
118
176
|
|
|
119
177
|
<script>
|
|
@@ -152,6 +210,14 @@ import { t } from '../../libs/i18n'
|
|
|
152
210
|
* @property {String} confirmText 确定按钮的文字 (默认 '确定' )
|
|
153
211
|
* @property {String} confirmDisabledText 确认按钮处于禁用状态时的文字 (默认 '确定' )
|
|
154
212
|
* @property {Boolean} show 是否显示日历弹窗 (默认 false )
|
|
213
|
+
* @property {Boolean} overlay 是否显示遮罩 (默认 true )
|
|
214
|
+
* @property {String | Number} duration 动画时长,单位ms (默认 300 )
|
|
215
|
+
* @property {Object | String} overlayStyle 自定义遮罩的样式
|
|
216
|
+
* @property {Number | String} overlayOpacity 遮罩透明度,0-1之间 (默认 0.5 )
|
|
217
|
+
* @property {String | Number} zIndex 弹出层的z-index值 (默认 10075 )
|
|
218
|
+
* @property {Boolean} safeAreaInsetBottom 是否留出底部安全距离 (默认 true )
|
|
219
|
+
* @property {Boolean} safeAreaInsetTop 是否留出顶部安全距离(状态栏高度) (默认 false )
|
|
220
|
+
* @property {String} bgColor 弹窗背景色,设置为transparent可去除白色背景
|
|
155
221
|
* @property {Boolean} closeOnClickOverlay 是否允许点击遮罩关闭日历 (默认 false )
|
|
156
222
|
* @property {Boolean} readonly 是否为只读状态,只读状态下禁止选择日期 (默认 false )
|
|
157
223
|
* @property {String | Number} maxRange 日期区间最多可选天数,默认无限制,mode = range时有效
|
|
@@ -159,9 +225,13 @@ import { t } from '../../libs/i18n'
|
|
|
159
225
|
* @property {Boolean} showRangePrompt 范围选择超过最多可选天数时,是否展示提示文案,mode = range时有效 (默认 true )
|
|
160
226
|
* @property {Boolean} allowSameDay 是否允许日期范围的起止时间为同一天,mode = range时有效 (默认 false )
|
|
161
227
|
* @property {String} rangeResultMode 区间模式下确认返回值格式,all-返回区间内所有日期,boundary-仅返回起止日期 (默认 'all' )
|
|
228
|
+
* @property {Boolean} enableTime 是否开启时分秒选择 (默认 false )
|
|
229
|
+
* @property {String} timePrecision 时间精度,hour-仅时,minute-时分,second-时分秒 (默认 'minute' )
|
|
230
|
+
* @property {String} defaultTime 默认时间,支持HH/HH:mm/HH:mm:ss,不传则按00:00补齐
|
|
162
231
|
* @property {Number|String} round 圆角值,默认无圆角 (默认 0 )
|
|
163
232
|
* @property {Number|String} monthNum 最多展示的月份数量 (默认 3 )
|
|
164
233
|
* @property {Boolean} monthSwitch 是否启用非滚动的单月切换模式 (默认 false )
|
|
234
|
+
* @property {String} todayColor 今天日期的独立高亮颜色,默认跟随主题色
|
|
165
235
|
* @property {Array} weekText 星期文案 (默认 ['一', '二', '三', '四', '五', '六', '日'] )
|
|
166
236
|
*
|
|
167
237
|
* @event {Function()} confirm 点击确定按钮时触发 选择日期相关的返回参数
|
|
@@ -189,6 +259,15 @@ export default {
|
|
|
189
259
|
scrollIntoView: '',
|
|
190
260
|
scrollIntoViewScroll: '',
|
|
191
261
|
scrollTop:0,
|
|
262
|
+
timePickerShow: false,
|
|
263
|
+
timePickerTarget: 'single',
|
|
264
|
+
timePickerValue: [0, 0, 0],
|
|
265
|
+
hourOptions: [],
|
|
266
|
+
minuteOptions: [],
|
|
267
|
+
secondOptions: [],
|
|
268
|
+
singleTime: '00:00',
|
|
269
|
+
rangeStartTime: '00:00',
|
|
270
|
+
rangeEndTime: '00:00',
|
|
192
271
|
// 过滤处理方法
|
|
193
272
|
innerFormatter: (value) => value
|
|
194
273
|
}
|
|
@@ -206,6 +285,13 @@ export default {
|
|
|
206
285
|
this.setMonth()
|
|
207
286
|
}
|
|
208
287
|
},
|
|
288
|
+
timePrecision() {
|
|
289
|
+
this.initTimeOptions()
|
|
290
|
+
this.initTimeValues()
|
|
291
|
+
},
|
|
292
|
+
defaultTime() {
|
|
293
|
+
this.initTimeValues()
|
|
294
|
+
},
|
|
209
295
|
// 打开弹窗时,设置月份数据
|
|
210
296
|
show: {
|
|
211
297
|
immediate: true,
|
|
@@ -288,6 +374,26 @@ export default {
|
|
|
288
374
|
switchNextYearDisabled() {
|
|
289
375
|
return this.monthIndex + 12 > this.months.length - 1
|
|
290
376
|
},
|
|
377
|
+
showTimePanel() {
|
|
378
|
+
if (!this.enableTime) return false
|
|
379
|
+
if (this.mode === 'single') return true
|
|
380
|
+
if (this.mode === 'range' && this.rangeResultMode === 'boundary') {
|
|
381
|
+
return true
|
|
382
|
+
}
|
|
383
|
+
return false
|
|
384
|
+
},
|
|
385
|
+
singleDateLabel() {
|
|
386
|
+
return this.selected[0] || '--'
|
|
387
|
+
},
|
|
388
|
+
rangeStartDateLabel() {
|
|
389
|
+
return this.selected[0] || '--'
|
|
390
|
+
},
|
|
391
|
+
rangeEndDateLabel() {
|
|
392
|
+
if (this.selected.length >= 2) {
|
|
393
|
+
return this.selected[this.selected.length - 1]
|
|
394
|
+
}
|
|
395
|
+
return '--'
|
|
396
|
+
},
|
|
291
397
|
buttonDisabled() {
|
|
292
398
|
// 如果为range类型,且选择的日期个数不足1个时,让底部的按钮出于disabled状态
|
|
293
399
|
if (this.mode === 'range') {
|
|
@@ -308,16 +414,129 @@ export default {
|
|
|
308
414
|
emits: ["confirm", "close"],
|
|
309
415
|
methods: {
|
|
310
416
|
addUnit,
|
|
417
|
+
padTime(num) {
|
|
418
|
+
return String(num).padStart(2, '0')
|
|
419
|
+
},
|
|
420
|
+
initTimeOptions() {
|
|
421
|
+
this.hourOptions = Array.from({ length: 24 }, (_, i) => this.padTime(i))
|
|
422
|
+
this.minuteOptions = Array.from({ length: 60 }, (_, i) => this.padTime(i))
|
|
423
|
+
this.secondOptions = Array.from({ length: 60 }, (_, i) => this.padTime(i))
|
|
424
|
+
},
|
|
425
|
+
parseTimeValue(value = '') {
|
|
426
|
+
const raw = String(value || '').trim()
|
|
427
|
+
const parts = raw.length ? raw.split(':') : []
|
|
428
|
+
const getNumber = (index, max) => {
|
|
429
|
+
const current = Number(parts[index] || 0)
|
|
430
|
+
if (Number.isNaN(current)) return 0
|
|
431
|
+
return Math.max(0, Math.min(max, current))
|
|
432
|
+
}
|
|
433
|
+
const hour = getNumber(0, 23)
|
|
434
|
+
const minute = getNumber(1, 59)
|
|
435
|
+
const second = getNumber(2, 59)
|
|
436
|
+
return [hour, minute, second]
|
|
437
|
+
},
|
|
438
|
+
getDefaultTimeValue() {
|
|
439
|
+
const [hour, minute, second] = this.parseTimeValue(this.defaultTime)
|
|
440
|
+
if (this.timePrecision === 'hour') {
|
|
441
|
+
return this.padTime(hour)
|
|
442
|
+
}
|
|
443
|
+
if (this.timePrecision === 'second') {
|
|
444
|
+
return `${this.padTime(hour)}:${this.padTime(minute)}:${this.padTime(second)}`
|
|
445
|
+
}
|
|
446
|
+
return `${this.padTime(hour)}:${this.padTime(minute)}`
|
|
447
|
+
},
|
|
448
|
+
initTimeValues() {
|
|
449
|
+
const value = this.getDefaultTimeValue()
|
|
450
|
+
this.singleTime = value
|
|
451
|
+
this.rangeStartTime = value
|
|
452
|
+
this.rangeEndTime = value
|
|
453
|
+
},
|
|
454
|
+
timeToPickerValue(value = '') {
|
|
455
|
+
const [hour, minute, second] = this.parseTimeValue(value)
|
|
456
|
+
return [hour, minute, second]
|
|
457
|
+
},
|
|
458
|
+
pickerValueToTime(value = []) {
|
|
459
|
+
const hour = Number(value[0] || 0)
|
|
460
|
+
const minute = Number(value[1] || 0)
|
|
461
|
+
const second = Number(value[2] || 0)
|
|
462
|
+
if (this.timePrecision === 'hour') {
|
|
463
|
+
return this.padTime(hour)
|
|
464
|
+
}
|
|
465
|
+
if (this.timePrecision === 'second') {
|
|
466
|
+
return `${this.padTime(hour)}:${this.padTime(minute)}:${this.padTime(second)}`
|
|
467
|
+
}
|
|
468
|
+
return `${this.padTime(hour)}:${this.padTime(minute)}`
|
|
469
|
+
},
|
|
470
|
+
openTimePicker(target) {
|
|
471
|
+
this.timePickerTarget = target
|
|
472
|
+
let currentValue = this.singleTime
|
|
473
|
+
if (target === 'start') currentValue = this.rangeStartTime
|
|
474
|
+
if (target === 'end') currentValue = this.rangeEndTime
|
|
475
|
+
this.timePickerValue = this.timeToPickerValue(currentValue)
|
|
476
|
+
this.timePickerShow = true
|
|
477
|
+
},
|
|
478
|
+
onTimePickerChange(e) {
|
|
479
|
+
this.timePickerValue = e.detail.value
|
|
480
|
+
},
|
|
481
|
+
closeTimePicker() {
|
|
482
|
+
this.timePickerShow = false
|
|
483
|
+
},
|
|
484
|
+
confirmTimePicker() {
|
|
485
|
+
const value = this.pickerValueToTime(this.timePickerValue)
|
|
486
|
+
if (this.timePickerTarget === 'single') this.singleTime = value
|
|
487
|
+
if (this.timePickerTarget === 'start') this.rangeStartTime = value
|
|
488
|
+
if (this.timePickerTarget === 'end') this.rangeEndTime = value
|
|
489
|
+
this.timePickerShow = false
|
|
490
|
+
},
|
|
491
|
+
timeToSecond(timeText = '') {
|
|
492
|
+
const [hour, minute, second] = this.parseTimeValue(timeText)
|
|
493
|
+
return hour * 3600 + minute * 60 + second
|
|
494
|
+
},
|
|
495
|
+
validateSameDayRangeTime() {
|
|
496
|
+
if (!this.enableTime || this.mode !== 'range' || this.rangeResultMode !== 'boundary') {
|
|
497
|
+
return true
|
|
498
|
+
}
|
|
499
|
+
if (this.selected.length < 2) return true
|
|
500
|
+
const startDate = this.selected[0]
|
|
501
|
+
const endDate = this.selected[this.selected.length - 1]
|
|
502
|
+
if (startDate !== endDate) return true
|
|
503
|
+
const startSeconds = this.timeToSecond(this.rangeStartTime)
|
|
504
|
+
const endSeconds = this.timeToSecond(this.rangeEndTime)
|
|
505
|
+
if (endSeconds < startSeconds) {
|
|
506
|
+
uni.showToast({
|
|
507
|
+
title: '结束时间不能早于开始时间',
|
|
508
|
+
icon: 'none'
|
|
509
|
+
})
|
|
510
|
+
return false
|
|
511
|
+
}
|
|
512
|
+
return true
|
|
513
|
+
},
|
|
514
|
+
appendTime(dateText, timeText) {
|
|
515
|
+
return `${dateText} ${timeText}`
|
|
516
|
+
},
|
|
311
517
|
getConfirmValue(selected = this.selected) {
|
|
518
|
+
let result = selected
|
|
312
519
|
if (
|
|
313
520
|
this.mode === 'range' &&
|
|
314
521
|
this.rangeResultMode === 'boundary' &&
|
|
315
522
|
selected.length >= 2
|
|
316
523
|
) {
|
|
317
524
|
const len = selected.length - 1
|
|
318
|
-
|
|
525
|
+
result = [selected[0], selected[len]]
|
|
526
|
+
}
|
|
527
|
+
if (!this.showTimePanel || !this.enableTime) {
|
|
528
|
+
return result
|
|
529
|
+
}
|
|
530
|
+
if (this.mode === 'single' && result.length >= 1) {
|
|
531
|
+
return [this.appendTime(result[0], this.singleTime)]
|
|
532
|
+
}
|
|
533
|
+
if (this.mode === 'range' && this.rangeResultMode === 'boundary' && result.length >= 2) {
|
|
534
|
+
return [
|
|
535
|
+
this.appendTime(result[0], this.rangeStartTime),
|
|
536
|
+
this.appendTime(result[1], this.rangeEndTime)
|
|
537
|
+
]
|
|
319
538
|
}
|
|
320
|
-
return
|
|
539
|
+
return result
|
|
321
540
|
},
|
|
322
541
|
// 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
|
|
323
542
|
setFormatter(e) {
|
|
@@ -337,6 +556,7 @@ export default {
|
|
|
337
556
|
return
|
|
338
557
|
}
|
|
339
558
|
if( scene === 'tap') {
|
|
559
|
+
if (!this.validateSameDayRangeTime()) return
|
|
340
560
|
this.$emit('confirm', this.getConfirmValue())
|
|
341
561
|
}
|
|
342
562
|
}
|
|
@@ -359,6 +579,8 @@ export default {
|
|
|
359
579
|
bottomPadding = 30
|
|
360
580
|
}
|
|
361
581
|
this.listHeight = this.rowHeight * (this.monthSwitch ? 6 : 5) + bottomPadding
|
|
582
|
+
this.initTimeOptions()
|
|
583
|
+
this.initTimeValues()
|
|
362
584
|
this.setMonth()
|
|
363
585
|
},
|
|
364
586
|
close() {
|
|
@@ -367,6 +589,7 @@ export default {
|
|
|
367
589
|
// 点击确定按钮
|
|
368
590
|
confirm() {
|
|
369
591
|
if (!this.buttonDisabled) {
|
|
592
|
+
if (!this.validateSameDayRangeTime()) return
|
|
370
593
|
this.$emit('confirm', this.getConfirmValue())
|
|
371
594
|
}
|
|
372
595
|
},
|
|
@@ -495,16 +718,24 @@ export default {
|
|
|
495
718
|
return
|
|
496
719
|
}
|
|
497
720
|
const targetMonth = dayjs(this.todayDate).format('YYYY-MM')
|
|
721
|
+
const selectToday = () => {
|
|
722
|
+
if (this.mode === 'range') {
|
|
723
|
+
return
|
|
724
|
+
}
|
|
725
|
+
this.$refs.month && this.$refs.month.selectDate(this.todayDate)
|
|
726
|
+
}
|
|
498
727
|
if (this.monthSwitch) {
|
|
499
728
|
const todayMonthIndex = this.months.findIndex(({ year, month }) => {
|
|
500
729
|
return `${year}-${padZero(month)}` === targetMonth
|
|
501
730
|
})
|
|
502
731
|
if (todayMonthIndex !== -1) {
|
|
503
732
|
this.monthIndex = todayMonthIndex
|
|
733
|
+
this.$nextTick(selectToday)
|
|
504
734
|
}
|
|
505
735
|
return
|
|
506
736
|
}
|
|
507
737
|
this.scrollIntoDefaultMonth(targetMonth)
|
|
738
|
+
this.$nextTick(selectToday)
|
|
508
739
|
},
|
|
509
740
|
// 滚动到默认设置的月份
|
|
510
741
|
scrollIntoDefaultMonth(selected) {
|
|
@@ -579,6 +810,84 @@ export default {
|
|
|
579
810
|
color: var(--up-main-color, $u-main-color);
|
|
580
811
|
background-color: var(--up-card-bg-color, #ffffff);
|
|
581
812
|
|
|
813
|
+
&__time-panel {
|
|
814
|
+
padding: 8px 16px 0;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
&__time-row {
|
|
818
|
+
height: 34px;
|
|
819
|
+
display: flex;
|
|
820
|
+
align-items: center;
|
|
821
|
+
justify-content: space-between;
|
|
822
|
+
margin-bottom: 6px;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
&__time-date {
|
|
826
|
+
font-size: 13px;
|
|
827
|
+
color: #303133;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
&__time-trigger {
|
|
831
|
+
min-width: 92px;
|
|
832
|
+
height: 30px;
|
|
833
|
+
padding: 0 10px;
|
|
834
|
+
border-radius: 15px;
|
|
835
|
+
border: 1px solid #dcdfe6;
|
|
836
|
+
display: flex;
|
|
837
|
+
align-items: center;
|
|
838
|
+
justify-content: center;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
&__time-text {
|
|
842
|
+
font-size: 14px;
|
|
843
|
+
color: #303133;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
&__time-picker {
|
|
847
|
+
width: 320px;
|
|
848
|
+
background-color: #ffffff;
|
|
849
|
+
border-radius: 8px;
|
|
850
|
+
overflow: hidden;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
&__time-picker__header {
|
|
854
|
+
height: 44px;
|
|
855
|
+
padding: 0 14px;
|
|
856
|
+
display: flex;
|
|
857
|
+
align-items: center;
|
|
858
|
+
justify-content: space-between;
|
|
859
|
+
border-bottom: 1px solid #f0f0f0;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
&__time-picker__cancel {
|
|
863
|
+
font-size: 14px;
|
|
864
|
+
color: #909399;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
&__time-picker__title {
|
|
868
|
+
font-size: 15px;
|
|
869
|
+
color: #303133;
|
|
870
|
+
font-weight: 600;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
&__time-picker__confirm {
|
|
874
|
+
font-size: 14px;
|
|
875
|
+
color: #3c9cff;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
&__time-picker__body {
|
|
879
|
+
width: 320px;
|
|
880
|
+
height: 200px;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
&__time-picker__item {
|
|
884
|
+
height: 40px;
|
|
885
|
+
line-height: 40px;
|
|
886
|
+
text-align: center;
|
|
887
|
+
font-size: 16px;
|
|
888
|
+
color: #303133;
|
|
889
|
+
}
|
|
890
|
+
|
|
582
891
|
&__confirm {
|
|
583
892
|
padding: 7px 18px;
|
|
584
893
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import CalendarStripDefaultProps from './calendarStrip'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
3
4
|
|
|
5
|
+
const defProps = registerComponentProps(CalendarStripDefaultProps)
|
|
4
6
|
export const props = defineMixin({
|
|
5
7
|
props: {
|
|
6
8
|
modelValue: {
|