misp-ui-library-test 0.0.1
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 +113 -0
- package/dist/theme-chalk/alert/index.scss +152 -0
- package/dist/theme-chalk/avatar/index.scss +51 -0
- package/dist/theme-chalk/backtop/index.scss +38 -0
- package/dist/theme-chalk/badge/index.scss +63 -0
- package/dist/theme-chalk/breadcrumb/index.scss +36 -0
- package/dist/theme-chalk/breadcrumb-item/index.scss +36 -0
- package/dist/theme-chalk/button/index.scss +157 -0
- package/dist/theme-chalk/card/index.scss +38 -0
- package/dist/theme-chalk/chart/index.scss +21 -0
- package/dist/theme-chalk/checkbox/index.scss +358 -0
- package/dist/theme-chalk/col/index.scss +131 -0
- package/dist/theme-chalk/container/index.scss +40 -0
- package/dist/theme-chalk/css/alert.css +484 -0
- package/dist/theme-chalk/css/avatar.css +409 -0
- package/dist/theme-chalk/css/backtop.css +401 -0
- package/dist/theme-chalk/css/badge.css +419 -0
- package/dist/theme-chalk/css/breadcrumb-item.css +395 -0
- package/dist/theme-chalk/css/breadcrumb.css +395 -0
- package/dist/theme-chalk/css/button.css +587 -0
- package/dist/theme-chalk/css/card.css +397 -0
- package/dist/theme-chalk/css/chart.css +386 -0
- package/dist/theme-chalk/css/checkbox.css +648 -0
- package/dist/theme-chalk/css/col.css +2111 -0
- package/dist/theme-chalk/css/container.css +404 -0
- package/dist/theme-chalk/css/dialog.css +505 -0
- package/dist/theme-chalk/css/divider.css +405 -0
- package/dist/theme-chalk/css/drawer.css +546 -0
- package/dist/theme-chalk/css/empty.css +394 -0
- package/dist/theme-chalk/css/form.css +561 -0
- package/dist/theme-chalk/css/icon.css +1534 -0
- package/dist/theme-chalk/css/image.css +400 -0
- package/dist/theme-chalk/css/input-number.css +424 -0
- package/dist/theme-chalk/css/input.css +721 -0
- package/dist/theme-chalk/css/link.css +424 -0
- package/dist/theme-chalk/css/loading.css +483 -0
- package/dist/theme-chalk/css/message-box.css +479 -0
- package/dist/theme-chalk/css/message.css +456 -0
- package/dist/theme-chalk/css/no-data.css +397 -0
- package/dist/theme-chalk/css/notification.css +431 -0
- package/dist/theme-chalk/css/page-header.css +396 -0
- package/dist/theme-chalk/css/pagination.css +565 -0
- package/dist/theme-chalk/css/popover.css +421 -0
- package/dist/theme-chalk/css/popper.css +454 -0
- package/dist/theme-chalk/css/progress.css +451 -0
- package/dist/theme-chalk/css/radio.css +626 -0
- package/dist/theme-chalk/css/rate.css +414 -0
- package/dist/theme-chalk/css/result.css +403 -0
- package/dist/theme-chalk/css/row.css +433 -0
- package/dist/theme-chalk/css/scrollbar.css +422 -0
- package/dist/theme-chalk/css/select.css +1897 -0
- package/dist/theme-chalk/css/skeleton-item.css +407 -0
- package/dist/theme-chalk/css/skeleton.css +390 -0
- package/dist/theme-chalk/css/slider.css +460 -0
- package/dist/theme-chalk/css/spinner.css +403 -0
- package/dist/theme-chalk/css/statistic.css +396 -0
- package/dist/theme-chalk/css/status-timeline-chart.css +388 -0
- package/dist/theme-chalk/css/step.css +496 -0
- package/dist/theme-chalk/css/steps.css +496 -0
- package/dist/theme-chalk/css/switch.css +507 -0
- package/dist/theme-chalk/css/tab-pane.css +457 -0
- package/dist/theme-chalk/css/table.css +461 -0
- package/dist/theme-chalk/css/tabs-navigation.css +925 -0
- package/dist/theme-chalk/css/tabs.css +457 -0
- package/dist/theme-chalk/css/tag.css +599 -0
- package/dist/theme-chalk/css/time-picker.css +683 -0
- package/dist/theme-chalk/css/timeline-item.css +459 -0
- package/dist/theme-chalk/css/timeline.css +459 -0
- package/dist/theme-chalk/css/tooltip.css +485 -0
- package/dist/theme-chalk/css/tree.css +473 -0
- package/dist/theme-chalk/css/upload.css +665 -0
- package/dist/theme-chalk/dialog/index.scss +168 -0
- package/dist/theme-chalk/divider/index.scss +46 -0
- package/dist/theme-chalk/drawer/index.scss +172 -0
- package/dist/theme-chalk/empty/index.scss +36 -0
- package/dist/theme-chalk/fonts/element-icons.ttf +0 -0
- package/dist/theme-chalk/fonts/element-icons.woff +0 -0
- package/dist/theme-chalk/form/index.scss +220 -0
- package/dist/theme-chalk/icon/index.scss +1171 -0
- package/dist/theme-chalk/image/index.scss +39 -0
- package/dist/theme-chalk/index.scss +127 -0
- package/dist/theme-chalk/input/index.scss +363 -0
- package/dist/theme-chalk/input-number/index.scss +71 -0
- package/dist/theme-chalk/link/index.scss +75 -0
- package/dist/theme-chalk/loading/index.scss +131 -0
- package/dist/theme-chalk/message/index.scss +100 -0
- package/dist/theme-chalk/message-box/index.scss +131 -0
- package/dist/theme-chalk/mixins.scss +203 -0
- package/dist/theme-chalk/no-data/index.scss +36 -0
- package/dist/theme-chalk/notification/index.scss +76 -0
- package/dist/theme-chalk/page-header/index.scss +36 -0
- package/dist/theme-chalk/pagination/index.scss +225 -0
- package/dist/theme-chalk/popover/index.scss +56 -0
- package/dist/theme-chalk/popper/index.scss +89 -0
- package/dist/theme-chalk/progress/index.scss +105 -0
- package/dist/theme-chalk/radio/index.scss +328 -0
- package/dist/theme-chalk/rate/index.scss +56 -0
- package/dist/theme-chalk/reset.scss +262 -0
- package/dist/theme-chalk/result/index.scss +46 -0
- package/dist/theme-chalk/row/index.scss +88 -0
- package/dist/theme-chalk/scrollbar/index.scss +67 -0
- package/dist/theme-chalk/select/index.scss +223 -0
- package/dist/theme-chalk/skeleton/index.scss +30 -0
- package/dist/theme-chalk/skeleton-item/index.scss +49 -0
- package/dist/theme-chalk/slider/index.scss +113 -0
- package/dist/theme-chalk/spinner/index.scss +40 -0
- package/dist/theme-chalk/statistic/index.scss +38 -0
- package/dist/theme-chalk/status-timeline-chart/index.scss +23 -0
- package/dist/theme-chalk/step/index.scss +160 -0
- package/dist/theme-chalk/steps/index.scss +160 -0
- package/dist/theme-chalk/switch/index.scss +153 -0
- package/dist/theme-chalk/tab-pane/index.scss +112 -0
- package/dist/theme-chalk/table/index.scss +110 -0
- package/dist/theme-chalk/tabs/index.scss +112 -0
- package/dist/theme-chalk/tabs-navigation/index.scss +631 -0
- package/dist/theme-chalk/tag/index.scss +138 -0
- package/dist/theme-chalk/themes/blue.scss +76 -0
- package/dist/theme-chalk/themes/dark.scss +99 -0
- package/dist/theme-chalk/themes/index.scss +260 -0
- package/dist/theme-chalk/themes/light.scss +99 -0
- package/dist/theme-chalk/time-picker/index.scss +332 -0
- package/dist/theme-chalk/timeline/index.scss +119 -0
- package/dist/theme-chalk/timeline-item/index.scss +119 -0
- package/dist/theme-chalk/tooltip/index.scss +122 -0
- package/dist/theme-chalk/tree/index.scss +125 -0
- package/dist/theme-chalk/upload/index.scss +348 -0
- package/dist/theme-chalk/variables.scss +93 -0
- package/dist/vue2-ui-library.cjs.temp.js.map +1 -0
- package/dist/vue2-ui-library.common.js +28 -0
- package/dist/vue2-ui-library.common.js.map +1 -0
- package/dist/vue2-ui-library.esm.js +29 -0
- package/dist/vue2-ui-library.umd.js +27 -0
- package/package.json +161 -0
- package/src/directives/clickoutside/index.js +111 -0
- package/src/directives/init/index.js +50 -0
- package/src/directives/resize/index.js +69 -0
- package/src/index.js +174 -0
- package/src/mixins/emitter.js +47 -0
- package/src/mixins/focus.js +42 -0
- package/src/mixins/locale.js +24 -0
- package/src/mixins/migrating.js +46 -0
- package/src/packages/alert/index.js +12 -0
- package/src/packages/alert/src/main.vue +98 -0
- package/src/packages/aside/index.js +12 -0
- package/src/packages/aside/src/main.vue +20 -0
- package/src/packages/auto-grid-layout/index.js +18 -0
- package/src/packages/auto-grid-layout/prop.js +92 -0
- package/src/packages/auto-grid-layout/src/components/GridItem.vue +759 -0
- package/src/packages/auto-grid-layout/src/components/GridLayout.vue +367 -0
- package/src/packages/auto-grid-layout/src/main.vue +287 -0
- package/src/packages/auto-grid-layout/src/utils/DOM.js +46 -0
- package/src/packages/auto-grid-layout/src/utils/interact.js +333 -0
- package/src/packages/auto-grid-layout/src/utils/responsiveUtils.js +75 -0
- package/src/packages/auto-grid-layout/src/utils/utils.js +339 -0
- package/src/packages/autocomplete/index.js +12 -0
- package/src/packages/autocomplete/src/main.vue +170 -0
- package/src/packages/avatar/index.js +12 -0
- package/src/packages/avatar/src/main.vue +87 -0
- package/src/packages/backtop/index.js +12 -0
- package/src/packages/backtop/src/main.vue +120 -0
- package/src/packages/badge/index.js +12 -0
- package/src/packages/badge/src/main.vue +53 -0
- package/src/packages/breadcrumb/index.js +12 -0
- package/src/packages/breadcrumb/src/main.vue +34 -0
- package/src/packages/breadcrumb-item/index.js +12 -0
- package/src/packages/breadcrumb-item/src/main.vue +41 -0
- package/src/packages/button/index.js +13 -0
- package/src/packages/button/src/main.vue +106 -0
- package/src/packages/calendar/index.js +12 -0
- package/src/packages/calendar/src/main.vue +173 -0
- package/src/packages/card/index.js +12 -0
- package/src/packages/card/src/main.vue +26 -0
- package/src/packages/carousel/index.js +12 -0
- package/src/packages/carousel/src/main.vue +186 -0
- package/src/packages/carousel-item/index.js +12 -0
- package/src/packages/carousel-item/src/main.vue +34 -0
- package/src/packages/cascader/index.js +12 -0
- package/src/packages/cascader/src/main.vue +232 -0
- package/src/packages/chart/index.js +7 -0
- package/src/packages/chart/src/axis-chart.js +700 -0
- package/src/packages/chart/src/main.vue +828 -0
- package/src/packages/chart/src/utils.js +21 -0
- package/src/packages/checkbox/index.js +44 -0
- package/src/packages/checkbox/src/main.vue +312 -0
- package/src/packages/col/index.js +12 -0
- package/src/packages/col/src/main.vue +85 -0
- package/src/packages/collapse/index.js +12 -0
- package/src/packages/collapse/src/main.vue +69 -0
- package/src/packages/collapse-item/index.js +12 -0
- package/src/packages/collapse-item/src/main.vue +75 -0
- package/src/packages/color-picker/index.js +12 -0
- package/src/packages/color-picker/src/main.vue +206 -0
- package/src/packages/container/index.js +12 -0
- package/src/packages/container/src/main.vue +33 -0
- package/src/packages/date-picker/index.js +12 -0
- package/src/packages/date-picker/src/main.vue +246 -0
- package/src/packages/descriptions/index.js +12 -0
- package/src/packages/descriptions/src/main.vue +89 -0
- package/src/packages/descriptions-item/index.js +12 -0
- package/src/packages/descriptions-item/src/main.vue +26 -0
- package/src/packages/dialog/index.js +12 -0
- package/src/packages/dialog/src/main.vue +336 -0
- package/src/packages/divider/index.js +12 -0
- package/src/packages/divider/src/main.vue +37 -0
- package/src/packages/drawer/index.js +7 -0
- package/src/packages/drawer/src/main.vue +310 -0
- package/src/packages/dropdown/index.js +12 -0
- package/src/packages/dropdown/src/main.vue +82 -0
- package/src/packages/dropdown-menu-item/index.js +12 -0
- package/src/packages/dropdown-menu-item/src/main.vue +29 -0
- package/src/packages/empty/index.js +12 -0
- package/src/packages/empty/src/img-empty.vue +12 -0
- package/src/packages/empty/src/main.vue +49 -0
- package/src/packages/footer/index.js +12 -0
- package/src/packages/footer/src/main.vue +20 -0
- package/src/packages/form/index.js +13 -0
- package/src/packages/form/src/form-field.vue +790 -0
- package/src/packages/form/src/form-item.vue +464 -0
- package/src/packages/form/src/label-wrap.vue +127 -0
- package/src/packages/form/src/main.vue +442 -0
- package/src/packages/form-item/index.js +11 -0
- package/src/packages/header/index.js +12 -0
- package/src/packages/header/src/main.vue +20 -0
- package/src/packages/icon/index.js +12 -0
- package/src/packages/icon/src/main.vue +48 -0
- package/src/packages/image/index.js +12 -0
- package/src/packages/image/src/main.vue +224 -0
- package/src/packages/input/index.js +13 -0
- package/src/packages/input/src/calcTextareaHeight.js +123 -0
- package/src/packages/input/src/main.vue +510 -0
- package/src/packages/input-number/index.js +12 -0
- package/src/packages/input-number/src/main.vue +121 -0
- package/src/packages/link/index.js +12 -0
- package/src/packages/link/src/main.vue +53 -0
- package/src/packages/loading/index.js +17 -0
- package/src/packages/loading/src/directive.js +54 -0
- package/src/packages/loading/src/main.vue +38 -0
- package/src/packages/loading/src/service.js +63 -0
- package/src/packages/main/index.js +12 -0
- package/src/packages/main/src/main.vue +12 -0
- package/src/packages/menu/index.js +12 -0
- package/src/packages/menu/src/main.vue +117 -0
- package/src/packages/menu-item/index.js +12 -0
- package/src/packages/menu-item/src/main.vue +61 -0
- package/src/packages/message/index.js +95 -0
- package/src/packages/message/src/main.vue +131 -0
- package/src/packages/message-box/index.js +75 -0
- package/src/packages/message-box/src/main.vue +207 -0
- package/src/packages/no-data/index.js +8 -0
- package/src/packages/no-data/src/main.vue +23 -0
- package/src/packages/notification/index.js +72 -0
- package/src/packages/notification/src/main.vue +139 -0
- package/src/packages/option/index.js +13 -0
- package/src/packages/page-header/index.js +12 -0
- package/src/packages/page-header/src/main.vue +27 -0
- package/src/packages/pagination/index.js +12 -0
- package/src/packages/pagination/src/main.vue +255 -0
- package/src/packages/popconfirm/index.js +12 -0
- package/src/packages/popconfirm/src/main.vue +89 -0
- package/src/packages/popover/index.js +12 -0
- package/src/packages/popover/src/main.vue +452 -0
- package/src/packages/progress/index.js +12 -0
- package/src/packages/progress/src/main.vue +236 -0
- package/src/packages/radio/index.js +44 -0
- package/src/packages/radio/src/main.vue +291 -0
- package/src/packages/rate/index.js +12 -0
- package/src/packages/rate/src/main.vue +129 -0
- package/src/packages/result/index.js +12 -0
- package/src/packages/result/src/main.vue +52 -0
- package/src/packages/row/index.js +12 -0
- package/src/packages/row/src/main.vue +57 -0
- package/src/packages/scrollbar/index.js +12 -0
- package/src/packages/scrollbar/src/bar.vue +116 -0
- package/src/packages/scrollbar/src/main.vue +124 -0
- package/src/packages/select/index.js +15 -0
- package/src/packages/select/src/clickoutside.js +20 -0
- package/src/packages/select/src/main.vue +1055 -0
- package/src/packages/select/src/navigation-mixin.js +49 -0
- package/src/packages/select/src/option.vue +249 -0
- package/src/packages/select/src/select-dropdown.vue +95 -0
- package/src/packages/select/src/utils.js +5 -0
- package/src/packages/skeleton/index.js +12 -0
- package/src/packages/skeleton/src/main.vue +76 -0
- package/src/packages/skeleton-item/index.js +12 -0
- package/src/packages/skeleton-item/src/img-placeholder.vue +13 -0
- package/src/packages/skeleton-item/src/main.vue +22 -0
- package/src/packages/slider/index.js +12 -0
- package/src/packages/slider/src/main.vue +176 -0
- package/src/packages/spinner/index.js +12 -0
- package/src/packages/spinner/src/main.vue +27 -0
- package/src/packages/statistic/index.js +12 -0
- package/src/packages/statistic/src/main.vue +100 -0
- package/src/packages/status-timeline-chart/index.js +7 -0
- package/src/packages/status-timeline-chart/src/constants.js +20 -0
- package/src/packages/status-timeline-chart/src/main.vue +499 -0
- package/src/packages/status-timeline-chart/src/option-builder.js +475 -0
- package/src/packages/step/index.js +12 -0
- package/src/packages/step/src/main.vue +183 -0
- package/src/packages/steps/index.js +12 -0
- package/src/packages/steps/src/main.vue +57 -0
- package/src/packages/submenu/index.js +12 -0
- package/src/packages/submenu/src/main.vue +68 -0
- package/src/packages/switch/index.js +12 -0
- package/src/packages/switch/src/main.vue +166 -0
- package/src/packages/tab-pane/index.js +12 -0
- package/src/packages/tab-pane/src/main.vue +74 -0
- package/src/packages/table/index.js +8 -0
- package/src/packages/table/src/components/PagePagination.vue +82 -0
- package/src/packages/table/src/main.vue +153 -0
- package/src/packages/tabs/index.js +12 -0
- package/src/packages/tabs/src/main.vue +167 -0
- package/src/packages/tabs-navigation/index.js +7 -0
- package/src/packages/tabs-navigation/src/main.vue +462 -0
- package/src/packages/tag/index.js +12 -0
- package/src/packages/tag/src/main.vue +194 -0
- package/src/packages/time-picker/index.js +17 -0
- package/src/packages/time-picker/src/date-utils.js +455 -0
- package/src/packages/time-picker/src/main.vue +321 -0
- package/src/packages/time-picker/src/pane/date-range.vue +193 -0
- package/src/packages/time-picker/src/pane/date-time-range.vue +362 -0
- package/src/packages/time-picker/src/pane/date-time.vue +362 -0
- package/src/packages/time-picker/src/pane/date.vue +441 -0
- package/src/packages/time-picker/src/pane/time.vue +260 -0
- package/src/packages/time-picker/src/time-input.vue +203 -0
- package/src/packages/time-picker/src/time-range-input.vue +170 -0
- package/src/packages/timeline/index.js +12 -0
- package/src/packages/timeline/src/main.vue +24 -0
- package/src/packages/timeline-item/index.js +12 -0
- package/src/packages/timeline-item/src/main.vue +78 -0
- package/src/packages/tooltip/index.js +12 -0
- package/src/packages/tooltip/src/main.js +367 -0
- package/src/packages/transfer/index.js +8 -0
- package/src/packages/transfer/src/main.vue +229 -0
- package/src/packages/transfer/src/transfer-panel.vue +245 -0
- package/src/packages/transitions/collapse-transition.js +75 -0
- package/src/packages/tree/index.js +12 -0
- package/src/packages/tree/src/main.vue +322 -0
- package/src/packages/tree/src/model/node.js +348 -0
- package/src/packages/tree/src/model/tree-store.js +354 -0
- package/src/packages/tree/src/model/util.js +10 -0
- package/src/packages/tree/src/tree-node.vue +262 -0
- package/src/packages/upload/index.js +9 -0
- package/src/packages/upload/src/main.vue +415 -0
- package/src/playground/mixins/element.js +98 -0
- package/src/playground/types/element.js +197 -0
- package/src/playground/types/layout.js +80 -0
- package/src/plugins/i18n.js +125 -0
- package/src/styles/fonts/element-icons.ttf +0 -0
- package/src/styles/fonts/element-icons.woff +0 -0
- package/src/styles/index.scss +138 -0
- package/src/styles/reset.scss +257 -0
- package/src/styles/themes/blue.scss +75 -0
- package/src/styles/themes/dark.scss +98 -0
- package/src/styles/themes/index.scss +34 -0
- package/src/styles/themes/light.scss +98 -0
- package/src/styles/themes/variables.scss +233 -0
- package/src/styles/variables.scss +146 -0
- package/src/utils/async-validator/index.js +659 -0
- package/src/utils/browser/index.js +39 -0
- package/src/utils/color.js +76 -0
- package/src/utils/dom/index.js +421 -0
- package/src/utils/dom/scrollbar-width.js +49 -0
- package/src/utils/draggable/core.js +379 -0
- package/src/utils/draggable/draggable.js +478 -0
- package/src/utils/draggable/index.js +61 -0
- package/src/utils/draggable/sortable.js +751 -0
- package/src/utils/lodash/index.js +2395 -0
- package/src/utils/moment/index.js +909 -0
- package/src/utils/playground/index.js +37 -0
- package/src/utils/popper/index.js +308 -0
- package/src/utils/popper/popper.js +1132 -0
- package/src/utils/popper/popup-manager.js +288 -0
- package/src/utils/popper/popup.js +344 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-clickoutside="handleClose" class="ui-timepicker-date-pane">
|
|
3
|
+
<!-- 头部:显示年月 -->
|
|
4
|
+
<div class="pane-header">
|
|
5
|
+
<span class="switch-button year-up" @click="handleYearChange(-1)">
|
|
6
|
+
<i class="ui-icon-d-arrow-left" />
|
|
7
|
+
</span>
|
|
8
|
+
<span class="switch-button month-up" @click="handleMonthChange(-1)">
|
|
9
|
+
<i class="ui-icon-arrow-left" />
|
|
10
|
+
</span>
|
|
11
|
+
|
|
12
|
+
<span class="year-month">{{ currentYear }}年 {{ currentMonth + 1 }}月</span>
|
|
13
|
+
|
|
14
|
+
<span class="switch-button year-down" @click="handleMonthChange(1)">
|
|
15
|
+
<i class="ui-icon-arrow-right" />
|
|
16
|
+
</span>
|
|
17
|
+
<span class="switch-button month-down" @click="handleYearChange(1)">
|
|
18
|
+
<i class="ui-icon-d-arrow-right" />
|
|
19
|
+
</span>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<!-- 星期标题 -->
|
|
23
|
+
<div class="week-days">
|
|
24
|
+
<span v-for="(day, index) in weekDays" :key="index" class="week-day-item">
|
|
25
|
+
{{ day }}
|
|
26
|
+
</span>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<!-- 日期网格 -->
|
|
30
|
+
<div class="date-grid">
|
|
31
|
+
<div
|
|
32
|
+
v-for="(item, index) in calendarList"
|
|
33
|
+
:key="item.date.getTime()"
|
|
34
|
+
class="date-cell"
|
|
35
|
+
:class="{
|
|
36
|
+
'is-other-month': item.type !== 'current',
|
|
37
|
+
'in-range': isInRange(item.date),
|
|
38
|
+
'start-date': isStartDate(item.date),
|
|
39
|
+
'end-date': isEndDate(item.date),
|
|
40
|
+
}"
|
|
41
|
+
@click="handleSelectDay(item)"
|
|
42
|
+
@mouseenter="handleHoverDay(item)"
|
|
43
|
+
>
|
|
44
|
+
<div
|
|
45
|
+
class="date-cell__inner"
|
|
46
|
+
:class="{
|
|
47
|
+
'is-selected': isSelectedDay(item),
|
|
48
|
+
'is-today': isToday(item),
|
|
49
|
+
}"
|
|
50
|
+
>
|
|
51
|
+
{{ item.day }}
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</template>
|
|
57
|
+
|
|
58
|
+
<script>
|
|
59
|
+
import clickoutside from '../../../../directives/clickoutside/index.js'
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 日期选择面板组件
|
|
63
|
+
* 用于展示日历网格,支持单选日期模式和范围选择模式。
|
|
64
|
+
* 提供年月切换、日期高亮(选中、今天、范围内)以及交互事件发射。
|
|
65
|
+
*
|
|
66
|
+
* @component
|
|
67
|
+
*/
|
|
68
|
+
export default {
|
|
69
|
+
name: 'UiTimePickerDatePane',
|
|
70
|
+
props: {
|
|
71
|
+
/**
|
|
72
|
+
* 当前选中的日期值(单选模式下使用)
|
|
73
|
+
* @type {Date}
|
|
74
|
+
* @default null
|
|
75
|
+
*/
|
|
76
|
+
value: {
|
|
77
|
+
type: Date,
|
|
78
|
+
default: null,
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* 选择模式
|
|
82
|
+
* - 'date': 单选日期
|
|
83
|
+
* - 'range': 范围选择
|
|
84
|
+
* @type {'date' | 'range'}
|
|
85
|
+
* @default 'date'
|
|
86
|
+
*/
|
|
87
|
+
mode: {
|
|
88
|
+
type: String,
|
|
89
|
+
default: 'date',
|
|
90
|
+
},
|
|
91
|
+
readonly: Boolean,
|
|
92
|
+
/**
|
|
93
|
+
* 已选中的日期范围数组 [startDate, endDate]
|
|
94
|
+
* 仅在 mode 为 'range' 时有效
|
|
95
|
+
* @type {Date[]}
|
|
96
|
+
* @default []
|
|
97
|
+
*/
|
|
98
|
+
range: {
|
|
99
|
+
type: Array,
|
|
100
|
+
default: () => [],
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* 鼠标悬停的日期
|
|
104
|
+
* 用于在范围选择模式下动态显示预选范围
|
|
105
|
+
* @type {Date}
|
|
106
|
+
* @default null
|
|
107
|
+
*/
|
|
108
|
+
hoverDate: {
|
|
109
|
+
type: Date,
|
|
110
|
+
default: null,
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* 外部控制的视图日期(当前显示的年月)
|
|
114
|
+
* 如果未提供,组件将使用内部状态或默认当前时间
|
|
115
|
+
* @type {Date}
|
|
116
|
+
* @default null
|
|
117
|
+
*/
|
|
118
|
+
viewDate: {
|
|
119
|
+
type: Date,
|
|
120
|
+
default: null,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
data: () => ({
|
|
124
|
+
/**
|
|
125
|
+
* 星期几的显示标签
|
|
126
|
+
* @type {string[]}
|
|
127
|
+
*/
|
|
128
|
+
weekDays: ['日', '一', '二', '三', '四', '五', '六'],
|
|
129
|
+
/**
|
|
130
|
+
* 内部维护的视图日期状态
|
|
131
|
+
* @type {Date|null}
|
|
132
|
+
*/
|
|
133
|
+
innerViewDate: null,
|
|
134
|
+
}),
|
|
135
|
+
computed: {
|
|
136
|
+
/**
|
|
137
|
+
* 获取最终有效的视图日期
|
|
138
|
+
* 优先级:外部传入的 viewDate > 内部 innerViewDate > 当前系统时间
|
|
139
|
+
* @returns {Date}
|
|
140
|
+
*/
|
|
141
|
+
effectiveViewDate() {
|
|
142
|
+
return this.viewDate || this.innerViewDate || new Date()
|
|
143
|
+
},
|
|
144
|
+
/**
|
|
145
|
+
* 当前视图的年份
|
|
146
|
+
* @returns {number}
|
|
147
|
+
*/
|
|
148
|
+
currentYear() {
|
|
149
|
+
return this.effectiveViewDate.getFullYear()
|
|
150
|
+
},
|
|
151
|
+
/**
|
|
152
|
+
* 当前视图的月份 (0-11)
|
|
153
|
+
* @returns {number}
|
|
154
|
+
*/
|
|
155
|
+
currentMonth() {
|
|
156
|
+
return this.effectiveViewDate.getMonth()
|
|
157
|
+
},
|
|
158
|
+
/**
|
|
159
|
+
* 生成日历网格数据列表
|
|
160
|
+
* 包含上月末尾、本月全部、下月开头的日期,总共 42 个单元格(6行7列)
|
|
161
|
+
* @returns {Array<{ day: number, type: 'prev'|'current'|'next', date: Date }>}
|
|
162
|
+
*/
|
|
163
|
+
calendarList() {
|
|
164
|
+
const list = []
|
|
165
|
+
const year = this.currentYear
|
|
166
|
+
const month = this.currentMonth
|
|
167
|
+
|
|
168
|
+
const firstDayOfWeek = new Date(year, month, 1).getDay()
|
|
169
|
+
const daysInCurrentMonth = new Date(year, month + 1, 0).getDate()
|
|
170
|
+
const daysInPrevMonth = new Date(year, month, 0).getDate()
|
|
171
|
+
|
|
172
|
+
// 填充上个月的剩余天数
|
|
173
|
+
for (let i = firstDayOfWeek - 1; i >= 0; i--) {
|
|
174
|
+
list.push({
|
|
175
|
+
day: daysInPrevMonth - i,
|
|
176
|
+
type: 'prev',
|
|
177
|
+
date: new Date(year, month - 1, daysInPrevMonth - i),
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
// 填充当月天数
|
|
181
|
+
for (let i = 1; i <= daysInCurrentMonth; i++) {
|
|
182
|
+
list.push({
|
|
183
|
+
day: i,
|
|
184
|
+
type: 'current',
|
|
185
|
+
date: new Date(year, month, i),
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
// 填充下个月的天数以补足 42 格
|
|
189
|
+
const remainingCells = 42 - list.length
|
|
190
|
+
for (let i = 1; i <= remainingCells; i++) {
|
|
191
|
+
list.push({
|
|
192
|
+
day: i,
|
|
193
|
+
type: 'next',
|
|
194
|
+
date: new Date(year, month + 1, i),
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
return list
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
watch: {
|
|
201
|
+
/**
|
|
202
|
+
* 监听外部 viewDate 变化,同步到内部视图状态
|
|
203
|
+
* @param {Date} newVal - 新的视图日期
|
|
204
|
+
*/
|
|
205
|
+
viewDate: {
|
|
206
|
+
handler(newVal) {
|
|
207
|
+
if (newVal) {
|
|
208
|
+
this.innerViewDate = new Date(newVal)
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
immediate: true,
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* 监听单选值变化,如果是 date 模式且没有外部控制视图,则自动调整视图到选中日期
|
|
215
|
+
* @param {Date} newVal - 新的选中日期
|
|
216
|
+
*/
|
|
217
|
+
value: {
|
|
218
|
+
handler(newVal) {
|
|
219
|
+
if (newVal && this.mode === 'date' && !this.viewDate) {
|
|
220
|
+
this.innerViewDate = new Date(newVal)
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
immediate: true,
|
|
224
|
+
},
|
|
225
|
+
/**
|
|
226
|
+
* 监听范围选择值变化,如果是 range 模式且没有外部控制视图,则自动调整视图到起始日期
|
|
227
|
+
* @param {Date[]} newVal - 新的范围数组
|
|
228
|
+
*/
|
|
229
|
+
range: {
|
|
230
|
+
handler(newVal) {
|
|
231
|
+
if (newVal && newVal.length > 0 && this.mode === 'range' && !this.viewDate && !this.innerViewDate) {
|
|
232
|
+
this.innerViewDate = new Date(newVal[0])
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
immediate: true,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
directives: { clickoutside },
|
|
239
|
+
mounted() {
|
|
240
|
+
// 初始化默认视图为当前时间
|
|
241
|
+
if (!this.innerViewDate) {
|
|
242
|
+
this.innerViewDate = new Date()
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
methods: {
|
|
246
|
+
/**
|
|
247
|
+
* 滚动初始化钩子(预留接口,当前无具体实现)
|
|
248
|
+
*/
|
|
249
|
+
scrollInit() {},
|
|
250
|
+
handleClose(mouseup, mousedown) {
|
|
251
|
+
// 获取点击的元素
|
|
252
|
+
const target = mousedown.target
|
|
253
|
+
// 获取点击的元素是否在父触发器内
|
|
254
|
+
const clickParentTrigger = this.$parent.$el.contains(target)
|
|
255
|
+
!clickParentTrigger && this.$emit('close')
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* 处理年份切换
|
|
260
|
+
* @param {number} offset - 年份偏移量,-1 为上一年,1 为下一年
|
|
261
|
+
* @emits view-change - 当视图日期改变时发射,携带新的视图日期
|
|
262
|
+
*/
|
|
263
|
+
handleYearChange(offset) {
|
|
264
|
+
if (this.readonly) return
|
|
265
|
+
const newDate = new Date(this.effectiveViewDate)
|
|
266
|
+
newDate.setFullYear(newDate.getFullYear() + offset)
|
|
267
|
+
this.innerViewDate = newDate
|
|
268
|
+
this.$emit('view-change', newDate)
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* 处理月份切换
|
|
273
|
+
* @param {number} offset - 月份偏移量,-1 为上一月,1 为下一月
|
|
274
|
+
* @emits view-change - 当视图日期改变时发射,携带新的视图日期
|
|
275
|
+
*/
|
|
276
|
+
handleMonthChange(offset) {
|
|
277
|
+
if (this.readonly) return
|
|
278
|
+
const newDate = new Date(this.effectiveViewDate)
|
|
279
|
+
newDate.setMonth(newDate.getMonth() + offset)
|
|
280
|
+
this.innerViewDate = newDate
|
|
281
|
+
this.$emit('view-change', newDate)
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* 获取范围选择的边界日期
|
|
286
|
+
* 根据已选中的范围和鼠标悬停状态动态计算起始和结束日期
|
|
287
|
+
* @returns {{ start: Date, end: Date } | null} 返回起止日期对象,如果无法构成范围则返回 null
|
|
288
|
+
*/
|
|
289
|
+
getRangeBoundaries() {
|
|
290
|
+
if (this.mode !== 'range') return null
|
|
291
|
+
|
|
292
|
+
// 固定的起始点(通常是用户点击的第一个日期)
|
|
293
|
+
const fixedDate = this.range && this.range[0] ? this.range[0] : null
|
|
294
|
+
let dynamicDate = null
|
|
295
|
+
|
|
296
|
+
// 动态结束点:优先使用已确认选择的结束日期,其次使用鼠标悬停的日期
|
|
297
|
+
if (this.range && this.range[1]) {
|
|
298
|
+
dynamicDate = this.range[1]
|
|
299
|
+
} else if (this.hoverDate) {
|
|
300
|
+
dynamicDate = this.hoverDate
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// 如果缺少起始点或动态点,无法构成范围
|
|
304
|
+
if (!fixedDate || !dynamicDate) return null
|
|
305
|
+
|
|
306
|
+
const time1 = fixedDate.getTime()
|
|
307
|
+
const time2 = dynamicDate.getTime()
|
|
308
|
+
|
|
309
|
+
// 确保 start 总是早于或等于 end
|
|
310
|
+
if (time1 <= time2) {
|
|
311
|
+
return { start: fixedDate, end: dynamicDate }
|
|
312
|
+
} else {
|
|
313
|
+
return { start: dynamicDate, end: fixedDate }
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* 判断某个日期单元格是否被选中
|
|
319
|
+
* 在 range 模式下,选中状态指起始或结束日期;在 date 模式下,指与 value 相同
|
|
320
|
+
* @param {{ date: Date }} item - 日历单元格数据项
|
|
321
|
+
* @returns {boolean}
|
|
322
|
+
*/
|
|
323
|
+
isSelectedDay(item) {
|
|
324
|
+
if (this.mode === 'range') {
|
|
325
|
+
return this.isStartDate(item.date) || this.isEndDate(item.date)
|
|
326
|
+
}
|
|
327
|
+
if (!this.value) return false
|
|
328
|
+
return this.isSameDate(item.date, this.value)
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* 判断某个日期是否是今天
|
|
333
|
+
* @param {{ date: Date }} item - 日历单元格数据项
|
|
334
|
+
* @returns {boolean}
|
|
335
|
+
*/
|
|
336
|
+
isToday(item) {
|
|
337
|
+
const today = new Date()
|
|
338
|
+
return this.isSameDate(item.date, today)
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* 判断某个日期是否在选中范围内
|
|
343
|
+
* @param {Date} date - 待判断的日期
|
|
344
|
+
* @returns {boolean}
|
|
345
|
+
*/
|
|
346
|
+
isInRange(date) {
|
|
347
|
+
const boundaries = this.getRangeBoundaries()
|
|
348
|
+
if (!boundaries) return false
|
|
349
|
+
|
|
350
|
+
const targetTime = date.getTime()
|
|
351
|
+
|
|
352
|
+
// 创建 Start 边界的标准化时间 (00:00:00.000)
|
|
353
|
+
const startTime = new Date(boundaries.start)
|
|
354
|
+
startTime.setHours(0, 0, 0, 0)
|
|
355
|
+
|
|
356
|
+
// 创建 End 边界的标准化时间 (23:59:59.999)
|
|
357
|
+
const endTime = new Date(boundaries.end)
|
|
358
|
+
endTime.setHours(23, 59, 59, 999)
|
|
359
|
+
|
|
360
|
+
return targetTime >= startTime.getTime() && targetTime <= endTime.getTime()
|
|
361
|
+
},
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* 判断某个日期是否是范围的起始日期
|
|
365
|
+
* @param {Date} date - 待判断的日期
|
|
366
|
+
* @returns {boolean}
|
|
367
|
+
*/
|
|
368
|
+
isStartDate(date) {
|
|
369
|
+
const boundaries = this.getRangeBoundaries()
|
|
370
|
+
if (!boundaries) return false
|
|
371
|
+
return this.isSameDate(date, boundaries.start)
|
|
372
|
+
},
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* 判断某个日期是否是范围的结束日期
|
|
376
|
+
* @param {Date} date - 待判断的日期
|
|
377
|
+
* @returns {boolean}
|
|
378
|
+
*/
|
|
379
|
+
isEndDate(date) {
|
|
380
|
+
const boundaries = this.getRangeBoundaries()
|
|
381
|
+
if (!boundaries) return false
|
|
382
|
+
return this.isSameDate(date, boundaries.end)
|
|
383
|
+
},
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* 判断两个日期是否表示同一天(忽略时间部分)
|
|
387
|
+
* @param {Date} d1 - 第一个日期
|
|
388
|
+
* @param {Date} d2 - 第二个日期
|
|
389
|
+
* @returns {boolean}
|
|
390
|
+
*/
|
|
391
|
+
isSameDate(d1, d2) {
|
|
392
|
+
if (!d1 || !d2) return false
|
|
393
|
+
return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate()
|
|
394
|
+
},
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* 处理日期单元格点击事件
|
|
398
|
+
* 根据模式发射 input 或 pick 事件,并在点击非当前月日期时切换视图
|
|
399
|
+
* @param {{ date: Date, type: string }} item - 被点击的单元格数据
|
|
400
|
+
* @emits input - 在 date 模式下,发射选中的日期
|
|
401
|
+
* @emits pick - 在所有模式下,发射选中的日期(用于范围选择的中间状态)
|
|
402
|
+
* @emits view-change - 当点击非当前月日期导致视图切换时发射
|
|
403
|
+
*/
|
|
404
|
+
handleSelectDay(item) {
|
|
405
|
+
if (this.readonly) return;
|
|
406
|
+
|
|
407
|
+
const clickedDate = item.date
|
|
408
|
+
if (this.mode === 'date') {
|
|
409
|
+
// 如果点击的是非当前月的日期,先切换视图
|
|
410
|
+
if (item.type !== 'current') {
|
|
411
|
+
this.innerViewDate = new Date(clickedDate)
|
|
412
|
+
this.$emit('view-change', this.innerViewDate)
|
|
413
|
+
}
|
|
414
|
+
this.$emit('input', clickedDate)
|
|
415
|
+
this.$emit('pick', clickedDate)
|
|
416
|
+
} else {
|
|
417
|
+
// 范围选择模式
|
|
418
|
+
if (item.type !== 'current') {
|
|
419
|
+
this.innerViewDate = new Date(clickedDate)
|
|
420
|
+
this.$emit('view-change', this.innerViewDate)
|
|
421
|
+
}
|
|
422
|
+
this.$emit('pick', clickedDate)
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* 处理日期单元格鼠标悬停事件
|
|
428
|
+
* 仅在 range 模式下发射 hover 事件,用于更新动态范围显示
|
|
429
|
+
* @param {{ date: Date }} item - 悬停的单元格数据
|
|
430
|
+
* @emits hover - 发射悬停的日期
|
|
431
|
+
*/
|
|
432
|
+
handleHoverDay(item) {
|
|
433
|
+
if (this.mode === 'range') {
|
|
434
|
+
this.$emit('hover', item.date)
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
}
|
|
439
|
+
</script>
|
|
440
|
+
|
|
441
|
+
<style lang="scss" scoped></style>
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-clickoutside="handleClose" :class="['ui-timepicker-time-pane', arrowControl ? 'is-arrow-control' : '']">
|
|
3
|
+
<!-- 向上箭头 -->
|
|
4
|
+
<div v-if="arrowControl" class="ui-timepicker-time-pane__arrow arrow-up">
|
|
5
|
+
<ui-button v-if="showHour" class="hour-arrow" textual @click.stop="handleArrowClick('hour', -1)">
|
|
6
|
+
<i class="ui-icon-arrow-up" />
|
|
7
|
+
</ui-button>
|
|
8
|
+
<ui-button v-if="showMinute" class="minute-arrow" textual @click.stop="handleArrowClick('minute', -1)">
|
|
9
|
+
<i class="ui-icon-arrow-up" />
|
|
10
|
+
</ui-button>
|
|
11
|
+
<ui-button v-if="showSecond" class="second-arrow" textual @click.stop="handleArrowClick('second', -1)">
|
|
12
|
+
<i class="ui-icon-arrow-up" />
|
|
13
|
+
</ui-button>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<!-- 小时列 -->
|
|
17
|
+
<div v-if="showHour" ref="hourCol" class="ui-timepicker-time-pane__column" @scroll="handleScroll('hour', $event)">
|
|
18
|
+
<ul class="ui-timepicker-time-pane__list">
|
|
19
|
+
<li v-for="item in hours" :key="item" class="ui-timepicker-time-pane__item" :class="{ 'is-selected': item === currentHour }" @click="handleItemClick('hour', item)">
|
|
20
|
+
{{ formatTime(item) }}
|
|
21
|
+
</li>
|
|
22
|
+
</ul>
|
|
23
|
+
<div class="ui-timepicker-time-pane__mask" />
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<!-- 分钟列 -->
|
|
27
|
+
<div v-if="showMinute" ref="minuteCol" class="ui-timepicker-time-pane__column" @scroll="handleScroll('minute', $event)">
|
|
28
|
+
<ul class="ui-timepicker-time-pane__list">
|
|
29
|
+
<li v-for="item in minutes" :key="item" class="ui-timepicker-time-pane__item" :class="{ 'is-selected': item === currentMinute }" @click="handleItemClick('minute', item)">
|
|
30
|
+
{{ formatTime(item) }}
|
|
31
|
+
</li>
|
|
32
|
+
</ul>
|
|
33
|
+
<div class="ui-timepicker-time-pane__mask" />
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<!-- 秒数列 -->
|
|
37
|
+
<div v-if="showSecond" ref="secondCol" class="ui-timepicker-time-pane__column" @scroll="handleScroll('second', $event)">
|
|
38
|
+
<ul class="ui-timepicker-time-pane__list">
|
|
39
|
+
<li v-for="item in seconds" :key="item" class="ui-timepicker-time-pane__item" :class="{ 'is-selected': item === currentSecond }" @click="handleItemClick('second', item)">
|
|
40
|
+
{{ formatTime(item) }}
|
|
41
|
+
</li>
|
|
42
|
+
</ul>
|
|
43
|
+
<div class="ui-timepicker-time-pane__mask" />
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<!-- 向下箭头 -->
|
|
47
|
+
<div v-if="arrowControl" class="ui-timepicker-time-pane__arrow arrow-down">
|
|
48
|
+
<ui-button v-if="showHour" class="hour-arrow" textual @click.stop="handleArrowClick('hour', 1)">
|
|
49
|
+
<i class="ui-icon-arrow-down" />
|
|
50
|
+
</ui-button>
|
|
51
|
+
<ui-button v-if="showMinute" class="minute-arrow" textual @click.stop="handleArrowClick('minute', 1)">
|
|
52
|
+
<i class="ui-icon-arrow-down" />
|
|
53
|
+
</ui-button>
|
|
54
|
+
<ui-button v-if="showSecond" class="second-arrow" textual @click.stop="handleArrowClick('second', 1)">
|
|
55
|
+
<i class="ui-icon-arrow-down" />
|
|
56
|
+
</ui-button>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<script>
|
|
62
|
+
import UiButton from '../../../button/src/main.vue'
|
|
63
|
+
|
|
64
|
+
import clickoutside from '../../../../directives/clickoutside/index.js'
|
|
65
|
+
|
|
66
|
+
const formatTime = (num) => (num < 10 ? `0${num}` : `${num}`)
|
|
67
|
+
|
|
68
|
+
export default {
|
|
69
|
+
name: 'UiTimePickerTimePane',
|
|
70
|
+
components: { UiButton },
|
|
71
|
+
props: {
|
|
72
|
+
value: {
|
|
73
|
+
type: Date,
|
|
74
|
+
},
|
|
75
|
+
type: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: 'hour-minute-second',
|
|
78
|
+
},
|
|
79
|
+
readonly: Boolean,
|
|
80
|
+
arrowControl: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: false,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
data() {
|
|
86
|
+
return {
|
|
87
|
+
hours: Array.from({ length: 24 }, (_, i) => i),
|
|
88
|
+
minutes: Array.from({ length: 60 }, (_, i) => i),
|
|
89
|
+
seconds: Array.from({ length: 60 }, (_, i) => i),
|
|
90
|
+
timers: {},
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
computed: {
|
|
94
|
+
showHour() {
|
|
95
|
+
return this.type.includes('hour')
|
|
96
|
+
},
|
|
97
|
+
showMinute() {
|
|
98
|
+
return this.type.includes('minute')
|
|
99
|
+
},
|
|
100
|
+
showSecond() {
|
|
101
|
+
return this.type.includes('second')
|
|
102
|
+
},
|
|
103
|
+
currentHour() {
|
|
104
|
+
return this.value ? this.value.getHours() : 0
|
|
105
|
+
},
|
|
106
|
+
currentMinute() {
|
|
107
|
+
return this.value ? this.value.getMinutes() : 0
|
|
108
|
+
},
|
|
109
|
+
currentSecond() {
|
|
110
|
+
return this.value ? this.value.getSeconds() : 0
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
watch: {
|
|
114
|
+
value: {
|
|
115
|
+
handler(val) {
|
|
116
|
+
if (!val) return
|
|
117
|
+
this.$nextTick(this.scrollInit)
|
|
118
|
+
},
|
|
119
|
+
immediate: true,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
directives: { clickoutside },
|
|
123
|
+
mounted() {
|
|
124
|
+
this.$nextTick(this.scrollInit)
|
|
125
|
+
},
|
|
126
|
+
updated() {
|
|
127
|
+
this.$nextTick(this.scrollInit)
|
|
128
|
+
},
|
|
129
|
+
methods: {
|
|
130
|
+
formatTime,
|
|
131
|
+
handleClose(mouseup, mousedown) {
|
|
132
|
+
// 获取点击的元素
|
|
133
|
+
const target = mousedown.target
|
|
134
|
+
// 获取点击的元素是否在父触发器内
|
|
135
|
+
const clickParentTrigger = this.$parent.$el.contains(target)
|
|
136
|
+
!clickParentTrigger && this.$emit('close', mouseup, mousedown)
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 处理箭头点击事件
|
|
141
|
+
* @param {string} type - 'hour', 'minute', or 'second'
|
|
142
|
+
* @param {number} step - -1 for up, 1 for down
|
|
143
|
+
*/
|
|
144
|
+
handleArrowClick(type, step) {
|
|
145
|
+
let currentValue = 0
|
|
146
|
+
let max = 59
|
|
147
|
+
|
|
148
|
+
if (type === 'hour') {
|
|
149
|
+
currentValue = this.currentHour
|
|
150
|
+
max = 23
|
|
151
|
+
} else if (type === 'minute') {
|
|
152
|
+
currentValue = this.currentMinute
|
|
153
|
+
} else if (type === 'second') {
|
|
154
|
+
currentValue = this.currentSecond
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 计算新值,处理循环
|
|
158
|
+
let newValue = currentValue + step
|
|
159
|
+
if (newValue < 0) {
|
|
160
|
+
newValue = max
|
|
161
|
+
} else if (newValue > max) {
|
|
162
|
+
newValue = 0
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// 更新值
|
|
166
|
+
this.updateValue(type, newValue)
|
|
167
|
+
|
|
168
|
+
// 滚动到对应位置
|
|
169
|
+
this.scrollToPosition(type, newValue)
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 处理点击列表项事件
|
|
174
|
+
* @param {string} type - 'hour', 'minute', or 'second'
|
|
175
|
+
* @param {number} index - 点击的时间值
|
|
176
|
+
*/
|
|
177
|
+
handleItemClick(type, index) {
|
|
178
|
+
this.updateValue(type, index)
|
|
179
|
+
this.scrollToPosition(type, index)
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 获取单个列表项的高度
|
|
184
|
+
* @param {string} type - 'hour', 'minute', or 'second'
|
|
185
|
+
* @returns {number} 元素高度,如果未找到则返回默认值 32
|
|
186
|
+
*/
|
|
187
|
+
getItemHeight(type) {
|
|
188
|
+
let refName = ''
|
|
189
|
+
if (type === 'hour') refName = 'hourCol'
|
|
190
|
+
if (type === 'minute') refName = 'minuteCol'
|
|
191
|
+
if (type === 'second') refName = 'secondCol'
|
|
192
|
+
|
|
193
|
+
const colEl = this.$refs[refName]
|
|
194
|
+
if (colEl) {
|
|
195
|
+
const firstItem = colEl.querySelector('.ui-timepicker-time-pane__item')
|
|
196
|
+
if (firstItem) {
|
|
197
|
+
return firstItem.offsetHeight
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return 32
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
scrollInit() {
|
|
204
|
+
this.scrollToPosition('hour', this.currentHour)
|
|
205
|
+
this.scrollToPosition('minute', this.currentMinute)
|
|
206
|
+
this.scrollToPosition('second', this.currentSecond)
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
scrollToPosition(type, value) {
|
|
210
|
+
let refName = ''
|
|
211
|
+
if (type === 'hour') refName = 'hourCol'
|
|
212
|
+
if (type === 'minute') refName = 'minuteCol'
|
|
213
|
+
if (type === 'second') refName = 'secondCol'
|
|
214
|
+
|
|
215
|
+
const el = this.$refs[refName]
|
|
216
|
+
if (!el) return
|
|
217
|
+
|
|
218
|
+
const itemHeight = this.getItemHeight(type)
|
|
219
|
+
const targetScrollTop = value * itemHeight
|
|
220
|
+
|
|
221
|
+
if (el.scrollTop !== targetScrollTop) {
|
|
222
|
+
el.scrollTop = targetScrollTop
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
handleScroll(type, event) {
|
|
227
|
+
const el = event.target
|
|
228
|
+
if (this.timers[type]) clearTimeout(this.timers[type])
|
|
229
|
+
|
|
230
|
+
this.timers[type] = setTimeout(() => {
|
|
231
|
+
const scrollTop = el.scrollTop
|
|
232
|
+
const itemHeight = this.getItemHeight(type)
|
|
233
|
+
|
|
234
|
+
if (itemHeight <= 0) return
|
|
235
|
+
|
|
236
|
+
let index = Math.round(scrollTop / itemHeight)
|
|
237
|
+
const maxIndex = type === 'hour' ? 23 : 59
|
|
238
|
+
|
|
239
|
+
if (index < 0) index = 0
|
|
240
|
+
if (index > maxIndex) index = maxIndex
|
|
241
|
+
|
|
242
|
+
el.scrollTop = index * itemHeight
|
|
243
|
+
this.updateValue(type, index)
|
|
244
|
+
}, 50)
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
updateValue(type, index) {
|
|
248
|
+
const time = this.value || new Date(new Date().setHours(0, 0, 0, 0))
|
|
249
|
+
const date = new Date(time.getTime())
|
|
250
|
+
if (type === 'hour') date.setHours(index)
|
|
251
|
+
if (type === 'minute') date.setMinutes(index)
|
|
252
|
+
if (type === 'second') date.setSeconds(index)
|
|
253
|
+
|
|
254
|
+
!this.readonly && this.$emit('input', date)
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
}
|
|
258
|
+
</script>
|
|
259
|
+
|
|
260
|
+
<style lang="scss" scoped></style>
|