@gmcb/uv-ui 0.2.26
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 +295 -0
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/components/uv-action-sheet/props.js +50 -0
- package/components/uv-action-sheet/uv-action-sheet.vue +280 -0
- package/components/uv-album/uv-album.vue +312 -0
- package/components/uv-alert/props.js +45 -0
- package/components/uv-alert/uv-alert.vue +246 -0
- package/components/uv-avatar/props.js +85 -0
- package/components/uv-avatar/uv-avatar.vue +182 -0
- package/components/uv-avatar-group/props.js +53 -0
- package/components/uv-avatar-group/uv-avatar-group.vue +106 -0
- package/components/uv-back-top/props.js +58 -0
- package/components/uv-back-top/uv-back-top.vue +116 -0
- package/components/uv-badge/props.js +73 -0
- package/components/uv-badge/uv-badge.vue +176 -0
- package/components/uv-button/nvue.scss +46 -0
- package/components/uv-button/props.js +163 -0
- package/components/uv-button/uv-button.vue +529 -0
- package/components/uv-button/vue.scss +93 -0
- package/components/uv-calendar/calendar.js +546 -0
- package/components/uv-calendar/header.vue +104 -0
- package/components/uv-calendar/month.vue +616 -0
- package/components/uv-calendar/props.js +145 -0
- package/components/uv-calendar/uv-calendar.vue +390 -0
- package/components/uv-calendars/calendar-body.vue +376 -0
- package/components/uv-calendars/calendar-item.vue +248 -0
- package/components/uv-calendars/calendar.js +546 -0
- package/components/uv-calendars/i18n/en.json +12 -0
- package/components/uv-calendars/i18n/index.js +8 -0
- package/components/uv-calendars/i18n/zh-Hans.json +12 -0
- package/components/uv-calendars/i18n/zh-Hant.json +12 -0
- package/components/uv-calendars/util.js +435 -0
- package/components/uv-calendars/uv-calendars.vue +452 -0
- package/components/uv-cell/props.js +116 -0
- package/components/uv-cell/uv-cell.vue +209 -0
- package/components/uv-cell-group/props.js +15 -0
- package/components/uv-cell-group/uv-cell-group.vue +63 -0
- package/components/uv-checkbox/props.js +70 -0
- package/components/uv-checkbox/uv-checkbox.vue +371 -0
- package/components/uv-checkbox-group/props.js +84 -0
- package/components/uv-checkbox-group/uv-checkbox-group.vue +119 -0
- package/components/uv-code/props.js +35 -0
- package/components/uv-code/uv-code.vue +136 -0
- package/components/uv-code-input/props.js +83 -0
- package/components/uv-code-input/uv-code-input.vue +272 -0
- package/components/uv-col/props.js +30 -0
- package/components/uv-col/uv-col.vue +165 -0
- package/components/uv-collapse/props.js +20 -0
- package/components/uv-collapse/uv-collapse.vue +86 -0
- package/components/uv-collapse-item/props.js +60 -0
- package/components/uv-collapse-item/uv-collapse-item.vue +228 -0
- package/components/uv-column-notice/props.js +61 -0
- package/components/uv-column-notice/uv-column-notice.vue +176 -0
- package/components/uv-count-down/props.js +25 -0
- package/components/uv-count-down/utils.js +62 -0
- package/components/uv-count-down/uv-count-down.vue +169 -0
- package/components/uv-count-to/props.js +60 -0
- package/components/uv-count-to/uv-count-to.vue +187 -0
- package/components/uv-datetime-picker/props.js +130 -0
- package/components/uv-datetime-picker/uv-datetime-picker.vue +355 -0
- package/components/uv-divider/props.js +45 -0
- package/components/uv-divider/uv-divider.vue +113 -0
- package/components/uv-drop-down/uv-drop-down.vue +135 -0
- package/components/uv-drop-down-item/uv-drop-down-item.vue +169 -0
- package/components/uv-drop-down-popup/uv-drop-down-popup.vue +242 -0
- package/components/uv-empty/props.js +60 -0
- package/components/uv-empty/uv-empty.vue +126 -0
- package/components/uv-form/props.js +46 -0
- package/components/uv-form/uv-form.vue +209 -0
- package/components/uv-form/valid.js +1343 -0
- package/components/uv-form-item/props.js +49 -0
- package/components/uv-form-item/uv-form-item.vue +226 -0
- package/components/uv-gap/props.js +25 -0
- package/components/uv-gap/uv-gap.vue +36 -0
- package/components/uv-grid/props.js +20 -0
- package/components/uv-grid/uv-grid.vue +100 -0
- package/components/uv-grid-item/props.js +15 -0
- package/components/uv-grid-item/uv-grid-item.vue +223 -0
- package/components/uv-icon/icons.js +160 -0
- package/components/uv-icon/props.js +90 -0
- package/components/uv-icon/uv-icon.vue +226 -0
- package/components/uv-icon/uvicons.ttf +0 -0
- package/components/uv-image/props.js +100 -0
- package/components/uv-image/uv-image.vue +296 -0
- package/components/uv-index-anchor/props.js +30 -0
- package/components/uv-index-anchor/uv-index-anchor.vue +98 -0
- package/components/uv-index-item/uv-index-item.vue +87 -0
- package/components/uv-index-list/props.js +30 -0
- package/components/uv-index-list/uv-index-list.vue +461 -0
- package/components/uv-input/props.js +175 -0
- package/components/uv-input/uv-input.vue +348 -0
- package/components/uv-keyboard/props.js +95 -0
- package/components/uv-keyboard/uv-keyboard.vue +180 -0
- package/components/uv-keyboard-car/props.js +24 -0
- package/components/uv-keyboard-car/uv-keyboard-car.vue +347 -0
- package/components/uv-keyboard-number/props.js +19 -0
- package/components/uv-keyboard-number/uv-keyboard-number.vue +201 -0
- package/components/uv-line/props.js +34 -0
- package/components/uv-line/uv-line.vue +60 -0
- package/components/uv-line-progress/props.js +29 -0
- package/components/uv-line-progress/uv-line-progress.vue +146 -0
- package/components/uv-link/props.js +40 -0
- package/components/uv-link/uv-link.vue +83 -0
- package/components/uv-list/uv-list.vue +147 -0
- package/components/uv-list-item/uv-list-item.vue +535 -0
- package/components/uv-load-more/props.js +95 -0
- package/components/uv-load-more/uv-load-more.vue +152 -0
- package/components/uv-loading-icon/props.js +67 -0
- package/components/uv-loading-icon/uv-loading-icon.vue +347 -0
- package/components/uv-loading-page/props.js +55 -0
- package/components/uv-loading-page/uv-loading-page.vue +96 -0
- package/components/uv-modal/props.js +90 -0
- package/components/uv-modal/uv-modal.vue +245 -0
- package/components/uv-navbar/props.js +89 -0
- package/components/uv-navbar/uv-navbar.vue +245 -0
- package/components/uv-no-network/props.js +20 -0
- package/components/uv-no-network/uv-no-network.vue +222 -0
- package/components/uv-notice-bar/props.js +76 -0
- package/components/uv-notice-bar/uv-notice-bar.vue +110 -0
- package/components/uv-notify/props.js +45 -0
- package/components/uv-notify/uv-notify.vue +220 -0
- package/components/uv-number-box/props.js +118 -0
- package/components/uv-number-box/uv-number-box.vue +397 -0
- package/components/uv-overlay/props.js +25 -0
- package/components/uv-overlay/uv-overlay.vue +85 -0
- package/components/uv-parse/node/node.vue +576 -0
- package/components/uv-parse/parser.js +1335 -0
- package/components/uv-parse/uv-parse.vue +498 -0
- package/components/uv-pick-color/colors.js +217 -0
- package/components/uv-pick-color/props.js +47 -0
- package/components/uv-pick-color/uv-pick-color.vue +551 -0
- package/components/uv-picker/props.js +95 -0
- package/components/uv-picker/uv-picker.vue +329 -0
- package/components/uv-popup/keypress.js +45 -0
- package/components/uv-popup/uv-popup.vue +537 -0
- package/components/uv-preview-video/uv-preview-video.vue +52 -0
- package/components/uv-qrcode/cache.js +1 -0
- package/components/uv-qrcode/gcanvas/bridge/bridge-weex.js +241 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js +8 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
- package/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js +666 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Buffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Framebuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLenum.js +298 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js +142 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLtype.js +23 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Program.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Renderbuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js +1191 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Shader.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Texture.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/classUtils.js +3 -0
- package/components/uv-qrcode/gcanvas/env/canvas.js +74 -0
- package/components/uv-qrcode/gcanvas/env/image.js +96 -0
- package/components/uv-qrcode/gcanvas/env/tool.js +24 -0
- package/components/uv-qrcode/gcanvas/index.js +39 -0
- package/components/uv-qrcode/props.js +85 -0
- package/components/uv-qrcode/qrcode.js +34 -0
- package/components/uv-qrcode/queue.js +41 -0
- package/components/uv-qrcode/uv-qrcode.vue +1038 -0
- package/components/uv-radio/props.js +65 -0
- package/components/uv-radio/uv-radio.vue +349 -0
- package/components/uv-radio-group/props.js +89 -0
- package/components/uv-radio-group/uv-radio-group.vue +115 -0
- package/components/uv-rate/props.js +73 -0
- package/components/uv-rate/uv-rate.vue +274 -0
- package/components/uv-read-more/props.js +62 -0
- package/components/uv-read-more/uv-read-more.vue +162 -0
- package/components/uv-row/props.js +20 -0
- package/components/uv-row/uv-row.vue +95 -0
- package/components/uv-row-notice/props.js +40 -0
- package/components/uv-row-notice/uv-row-notice.vue +341 -0
- package/components/uv-safe-bottom/uv-safe-bottom.vue +67 -0
- package/components/uv-scroll-list/nvue.js +29 -0
- package/components/uv-scroll-list/props.js +35 -0
- package/components/uv-scroll-list/scrollWxs.wxs +51 -0
- package/components/uv-scroll-list/uv-scroll-list.vue +218 -0
- package/components/uv-search/props.js +127 -0
- package/components/uv-search/uv-search.vue +311 -0
- package/components/uv-skeleton/props.js +65 -0
- package/components/uv-skeleton/uv-skeleton.vue +250 -0
- package/components/uv-skeletons/uv-skeletons.vue +247 -0
- package/components/uv-slider/props.js +58 -0
- package/components/uv-slider/uv-slider.vue +58 -0
- package/components/uv-status-bar/props.js +8 -0
- package/components/uv-status-bar/uv-status-bar.vue +54 -0
- package/components/uv-steps/props.js +40 -0
- package/components/uv-steps/uv-steps.vue +83 -0
- package/components/uv-steps-item/props.js +25 -0
- package/components/uv-steps-item/uv-steps-item.vue +347 -0
- package/components/uv-sticky/props.js +41 -0
- package/components/uv-sticky/uv-sticky.vue +223 -0
- package/components/uv-subsection/props.js +54 -0
- package/components/uv-subsection/uv-subsection.vue +269 -0
- package/components/uv-swipe-action/props.js +10 -0
- package/components/uv-swipe-action/uv-swipe-action.vue +65 -0
- package/components/uv-swipe-action-item/index - backup.wxs +256 -0
- package/components/uv-swipe-action-item/index.wxs +225 -0
- package/components/uv-swipe-action-item/nvue - backup.js +264 -0
- package/components/uv-swipe-action-item/nvue.js +182 -0
- package/components/uv-swipe-action-item/props.js +40 -0
- package/components/uv-swipe-action-item/uv-swipe-action-item.vue +200 -0
- package/components/uv-swipe-action-item/wxs.js +15 -0
- package/components/uv-swiper/props.js +136 -0
- package/components/uv-swiper/uv-swiper.vue +263 -0
- package/components/uv-swiper-indicator/props.js +30 -0
- package/components/uv-swiper-indicator/uv-swiper-indicator.vue +112 -0
- package/components/uv-switch/props.js +58 -0
- package/components/uv-switch/uv-switch.vue +182 -0
- package/components/uv-tabbar/props.js +50 -0
- package/components/uv-tabbar/uv-tabbar.vue +146 -0
- package/components/uv-tabbar-item/props.js +40 -0
- package/components/uv-tabbar-item/uv-tabbar-item.vue +146 -0
- package/components/uv-tabs/props.js +71 -0
- package/components/uv-tabs/uv-tabs.vue +391 -0
- package/components/uv-tags/props.js +104 -0
- package/components/uv-tags/uv-tags.vue +379 -0
- package/components/uv-text/props.js +113 -0
- package/components/uv-text/uv-text.vue +218 -0
- package/components/uv-text/value.js +87 -0
- package/components/uv-textarea/props.js +138 -0
- package/components/uv-textarea/uv-textarea.vue +238 -0
- package/components/uv-toast/uv-toast.vue +292 -0
- package/components/uv-toolbar/props.js +40 -0
- package/components/uv-toolbar/uv-toolbar.vue +109 -0
- package/components/uv-tooltip/props.js +60 -0
- package/components/uv-tooltip/uv-tooltip.vue +372 -0
- package/components/uv-transition/createAnimation.js +131 -0
- package/components/uv-transition/props.js +31 -0
- package/components/uv-transition/uv-transition.vue +320 -0
- package/components/uv-upload/mixin.js +22 -0
- package/components/uv-upload/props.js +130 -0
- package/components/uv-upload/utils.js +151 -0
- package/components/uv-upload/uv-upload.vue +488 -0
- package/components/uv-vtabs/props.js +79 -0
- package/components/uv-vtabs/uv-vtabs.vue +438 -0
- package/components/uv-vtabs-item/uv-vtabs-item.vue +68 -0
- package/components/uv-waterfall/props.js +69 -0
- package/components/uv-waterfall/uv-waterfall.vue +265 -0
- package/index.js +82 -0
- package/index.scss +7 -0
- package/libs/config/config.js +34 -0
- package/libs/css/color.scss +32 -0
- package/libs/css/common.scss +100 -0
- package/libs/css/components.scss +23 -0
- package/libs/css/variable.scss +111 -0
- package/libs/css/vue.scss +40 -0
- package/libs/function/colorGradient.js +134 -0
- package/libs/function/compress.js +27 -0
- package/libs/function/debounce.js +29 -0
- package/libs/function/digit.js +167 -0
- package/libs/function/index.js +734 -0
- package/libs/function/platform.js +75 -0
- package/libs/function/test.js +287 -0
- package/libs/function/throttle.js +30 -0
- package/libs/luch-request/adapters/index.js +132 -0
- package/libs/luch-request/core/InterceptorManager.js +51 -0
- package/libs/luch-request/core/Request.js +201 -0
- package/libs/luch-request/core/buildFullPath.js +20 -0
- package/libs/luch-request/core/defaults.js +33 -0
- package/libs/luch-request/core/dispatchRequest.js +6 -0
- package/libs/luch-request/core/mergeConfig.js +126 -0
- package/libs/luch-request/core/settle.js +16 -0
- package/libs/luch-request/helpers/buildURL.js +64 -0
- package/libs/luch-request/helpers/combineURLs.js +14 -0
- package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
- package/libs/luch-request/index.d.ts +197 -0
- package/libs/luch-request/index.js +2 -0
- package/libs/luch-request/utils/clone.js +264 -0
- package/libs/luch-request/utils.js +135 -0
- package/libs/mixin/button.js +13 -0
- package/libs/mixin/mixin.js +172 -0
- package/libs/mixin/mpMixin.js +8 -0
- package/libs/mixin/mpShare.js +13 -0
- package/libs/mixin/openType.js +47 -0
- package/libs/mixin/touch.js +59 -0
- package/libs/util/dayjs.js +216 -0
- package/libs/util/route.js +126 -0
- package/package.json +28 -0
- package/theme.scss +43 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<uv-popup
|
|
3
|
+
ref="pickerPopup"
|
|
4
|
+
mode="bottom"
|
|
5
|
+
:round="round"
|
|
6
|
+
:close-on-click-overlay="closeOnClickOverlay"
|
|
7
|
+
@change="popupChange"
|
|
8
|
+
>
|
|
9
|
+
<view class="uv-picker">
|
|
10
|
+
<uv-toolbar
|
|
11
|
+
v-if="showToolbar"
|
|
12
|
+
:cancelColor="cancelColor"
|
|
13
|
+
:confirmColor="confirmColor"
|
|
14
|
+
:cancelText="cancelText"
|
|
15
|
+
:confirmText="confirmText"
|
|
16
|
+
:title="title"
|
|
17
|
+
@cancel="cancel"
|
|
18
|
+
@confirm="confirm"
|
|
19
|
+
></uv-toolbar>
|
|
20
|
+
<!-- #ifdef MP-TOUTIAO -->
|
|
21
|
+
<picker-view
|
|
22
|
+
class="uv-picker__view"
|
|
23
|
+
:indicatorStyle="`height: ${$uv.addUnit(itemHeight)}`"
|
|
24
|
+
:value="innerIndex"
|
|
25
|
+
:immediateChange="immediateChange"
|
|
26
|
+
:style="{
|
|
27
|
+
height: `${$uv.addUnit(visibleItemCount * itemHeight)}`
|
|
28
|
+
}"
|
|
29
|
+
@pickend="changeHandler"
|
|
30
|
+
>
|
|
31
|
+
<!-- #endif -->
|
|
32
|
+
<!-- #ifndef MP-TOUTIAO -->
|
|
33
|
+
<picker-view
|
|
34
|
+
class="uv-picker__view"
|
|
35
|
+
:indicatorStyle="`height: ${$uv.addUnit(itemHeight)}`"
|
|
36
|
+
:value="innerIndex"
|
|
37
|
+
:immediateChange="immediateChange"
|
|
38
|
+
:style="{
|
|
39
|
+
height: `${$uv.addUnit(visibleItemCount * itemHeight)}`
|
|
40
|
+
}"
|
|
41
|
+
@change="changeHandler"
|
|
42
|
+
>
|
|
43
|
+
<!-- #endif -->
|
|
44
|
+
<picker-view-column
|
|
45
|
+
v-for="(item, index) in innerColumns"
|
|
46
|
+
:key="index"
|
|
47
|
+
class="uv-picker__view__column"
|
|
48
|
+
>
|
|
49
|
+
<text
|
|
50
|
+
v-if="$uv.test.array(item)"
|
|
51
|
+
class="uv-picker__view__column__item uv-line-1"
|
|
52
|
+
v-for="(item1, index1) in item"
|
|
53
|
+
:key="index1"
|
|
54
|
+
:style="[{
|
|
55
|
+
height: $uv.addUnit(itemHeight),
|
|
56
|
+
lineHeight: $uv.addUnit(itemHeight),
|
|
57
|
+
fontWeight: index1 === innerIndex[index] ? 'bold' : 'normal'
|
|
58
|
+
},textStyle(index,index1)]"
|
|
59
|
+
>{{ getItemText(item1) }}</text>
|
|
60
|
+
</picker-view-column>
|
|
61
|
+
</picker-view>
|
|
62
|
+
<view
|
|
63
|
+
v-if="loading"
|
|
64
|
+
class="uv-picker--loading"
|
|
65
|
+
>
|
|
66
|
+
<uv-loading-icon mode="circle"></uv-loading-icon>
|
|
67
|
+
</view>
|
|
68
|
+
</view>
|
|
69
|
+
</uv-popup>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script>
|
|
73
|
+
/**
|
|
74
|
+
* uv-picker
|
|
75
|
+
* @description 选择器
|
|
76
|
+
* @property {Boolean} showToolbar 是否显示顶部的操作栏(默认 true )
|
|
77
|
+
* @property {String} title 顶部标题
|
|
78
|
+
* @property {Array} columns 对象数组,设置每一列的数据
|
|
79
|
+
* @property {Boolean} loading 是否显示加载中状态(默认 false )
|
|
80
|
+
* @property {String | Number} itemHeight 各列中,单个选项的高度(默认 44 )
|
|
81
|
+
* @property {String} cancelText 取消按钮的文字(默认 '取消' )
|
|
82
|
+
* @property {String} confirmText 确认按钮的文字(默认 '确定' )
|
|
83
|
+
* @property {String} cancelColor 取消按钮的颜色(默认 '#909193' )
|
|
84
|
+
* @property {String} confirmColor 确认按钮的颜色(默认 '#3c9cff' )
|
|
85
|
+
* @property {String} color 文字颜色(默认 '' )
|
|
86
|
+
* @property {String} activeColor 选中文字的颜色(默认 '' )
|
|
87
|
+
* @property {String | Number} visibleItemCount 每列中可见选项的数量(默认 5 )
|
|
88
|
+
* @property {String} keyName 选项对象中,需要展示的属性键名(默认 'text' )
|
|
89
|
+
* @property {Boolean} closeOnClickOverlay 是否允许点击遮罩关闭选择器(默认 false )
|
|
90
|
+
* @property {Array} defaultIndex 各列的默认索引
|
|
91
|
+
* @property {Boolean} immediateChange 是否在手指松开时立即触发change事件(默认 false )
|
|
92
|
+
* @event {Function} close 关闭选择器时触发
|
|
93
|
+
* @event {Function} cancel 点击取消按钮触发
|
|
94
|
+
* @event {Function} change 当选择值变化时触发
|
|
95
|
+
* @event {Function} confirm 点击确定按钮,返回当前选择的值
|
|
96
|
+
*/
|
|
97
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
98
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
99
|
+
import props from './props.js';
|
|
100
|
+
export default {
|
|
101
|
+
name: 'uv-picker',
|
|
102
|
+
emits: ['confirm','cancel','close','change'],
|
|
103
|
+
mixins: [mpMixin, mixin, props],
|
|
104
|
+
computed: {
|
|
105
|
+
// 为了解决支付宝不生效
|
|
106
|
+
textStyle(){
|
|
107
|
+
return (index,index1) => {
|
|
108
|
+
const style = {};
|
|
109
|
+
// #ifndef APP-NVUE
|
|
110
|
+
style.display = 'block';
|
|
111
|
+
// #endif
|
|
112
|
+
if(this.color) {
|
|
113
|
+
style.color = this.color;
|
|
114
|
+
}
|
|
115
|
+
if(this.activeColor && index1 === this.innerIndex[index]) {
|
|
116
|
+
style.color = this.activeColor;
|
|
117
|
+
}
|
|
118
|
+
return style;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
data() {
|
|
123
|
+
return {
|
|
124
|
+
// 上一次选择的列索引
|
|
125
|
+
lastIndex: [],
|
|
126
|
+
// 索引值 ,对应picker-view的value
|
|
127
|
+
innerIndex: [],
|
|
128
|
+
// 各列的值
|
|
129
|
+
innerColumns: [],
|
|
130
|
+
// 上一次的变化列索引
|
|
131
|
+
columnIndex: 0,
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
watch: {
|
|
135
|
+
// 监听默认索引的变化,重新设置对应的值
|
|
136
|
+
defaultIndex: {
|
|
137
|
+
immediate: true,
|
|
138
|
+
handler(n) {
|
|
139
|
+
this.setIndexs(n, true)
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
// 监听columns参数的变化
|
|
143
|
+
columns: {
|
|
144
|
+
deep: true,
|
|
145
|
+
immediate: true,
|
|
146
|
+
handler(n) {
|
|
147
|
+
this.setColumns(n)
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
methods: {
|
|
152
|
+
open() {
|
|
153
|
+
this.$refs.pickerPopup.open();
|
|
154
|
+
},
|
|
155
|
+
close() {
|
|
156
|
+
this.$refs.pickerPopup.close();
|
|
157
|
+
},
|
|
158
|
+
popupChange(e) {
|
|
159
|
+
if(!e.show) this.$emit('close');
|
|
160
|
+
},
|
|
161
|
+
// 获取item需要显示的文字,判别为对象还是文本
|
|
162
|
+
getItemText(item) {
|
|
163
|
+
if (this.$uv.test.object(item)) {
|
|
164
|
+
return item[this.keyName]
|
|
165
|
+
} else {
|
|
166
|
+
return item
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
// 点击工具栏的取消按钮
|
|
170
|
+
cancel() {
|
|
171
|
+
this.$emit('cancel');
|
|
172
|
+
this.close();
|
|
173
|
+
},
|
|
174
|
+
// 点击工具栏的确定按钮
|
|
175
|
+
confirm() {
|
|
176
|
+
// 在这里使用deepClone拷贝后,vue3会自动转换成原始对象,这样处理是因为cli项目可能出现不返回值的情况
|
|
177
|
+
this.$emit('confirm', this.$uv.deepClone({
|
|
178
|
+
indexs: this.innerIndex,
|
|
179
|
+
value: this.innerColumns.map((item, index) => item[this.innerIndex[index]]),
|
|
180
|
+
values: this.innerColumns
|
|
181
|
+
}));
|
|
182
|
+
if(this.closeOnClickConfirm) {
|
|
183
|
+
this.close();
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
// 选择器某一列的数据发生变化时触发
|
|
187
|
+
changeHandler(e) {
|
|
188
|
+
const {
|
|
189
|
+
value
|
|
190
|
+
} = e.detail
|
|
191
|
+
let index = 0,
|
|
192
|
+
columnIndex = 0
|
|
193
|
+
// 通过对比前后两次的列索引,得出当前变化的是哪一列
|
|
194
|
+
for (let i = 0; i < value.length; i++) {
|
|
195
|
+
let item = value[i]
|
|
196
|
+
if (item !== (this.lastIndex[i] || 0)) { // 把undefined转为合法假值0
|
|
197
|
+
// 设置columnIndex为当前变化列的索引
|
|
198
|
+
columnIndex = i
|
|
199
|
+
// index则为变化列中的变化项的索引
|
|
200
|
+
index = item
|
|
201
|
+
break // 终止循环,即使少一次循环,也是性能的提升
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
this.columnIndex = columnIndex
|
|
205
|
+
const values = this.innerColumns
|
|
206
|
+
// 将当前的各项变化索引,设置为"上一次"的索引变化值
|
|
207
|
+
this.setLastIndex(value)
|
|
208
|
+
this.setIndexs(value)
|
|
209
|
+
|
|
210
|
+
this.$emit('change', {
|
|
211
|
+
value: this.innerColumns.map((item, index) => item[value[index]]),
|
|
212
|
+
index,
|
|
213
|
+
indexs: value,
|
|
214
|
+
// values为当前变化列的数组内容
|
|
215
|
+
values,
|
|
216
|
+
columnIndex
|
|
217
|
+
})
|
|
218
|
+
},
|
|
219
|
+
// 设置index索引,此方法可被外部调用设置
|
|
220
|
+
setIndexs(index, setLastIndex) {
|
|
221
|
+
this.innerIndex = this.$uv.deepClone(index)
|
|
222
|
+
if (setLastIndex) {
|
|
223
|
+
this.setLastIndex(index)
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
// 记录上一次的各列索引位置
|
|
227
|
+
setLastIndex(index) {
|
|
228
|
+
// 当能进入此方法,意味着当前设置的各列默认索引,即为“上一次”的选中值,需要记录,是因为changeHandler中
|
|
229
|
+
// 需要拿前后的变化值进行对比,得出当前发生改变的是哪一列
|
|
230
|
+
this.lastIndex = this.$uv.deepClone(index)
|
|
231
|
+
},
|
|
232
|
+
// 设置对应列选项的所有值
|
|
233
|
+
setColumnValues(columnIndex, values) {
|
|
234
|
+
// 替换innerColumns数组中columnIndex索引的值为values,使用的是数组的splice方法
|
|
235
|
+
this.innerColumns.splice(columnIndex, 1, values)
|
|
236
|
+
// 拷贝一份原有的innerIndex做临时变量,将大于当前变化列的所有的列的默认索引设置为0
|
|
237
|
+
let tmpIndex = this.$uv.deepClone(this.innerIndex)
|
|
238
|
+
for (let i = 0; i < this.innerColumns.length; i++) {
|
|
239
|
+
if (i > this.columnIndex) {
|
|
240
|
+
tmpIndex[i] = 0
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// 一次性赋值,不能单个修改,否则无效
|
|
244
|
+
this.setIndexs(tmpIndex)
|
|
245
|
+
},
|
|
246
|
+
// 获取对应列的所有选项
|
|
247
|
+
getColumnValues(columnIndex) {
|
|
248
|
+
// 进行同步阻塞,因为外部得到change事件之后,可能需要执行setColumnValues更新列的值
|
|
249
|
+
// 索引如果在外部change的回调中调用getColumnValues的话,可能无法得到变更后的列值,这里进行一定延时,保证值的准确性
|
|
250
|
+
(async () => {
|
|
251
|
+
await this.$uv.sleep()
|
|
252
|
+
})()
|
|
253
|
+
return this.innerColumns[columnIndex]
|
|
254
|
+
},
|
|
255
|
+
// 设置整体各列的columns的值
|
|
256
|
+
setColumns(columns) {
|
|
257
|
+
this.innerColumns = this.$uv.deepClone(columns)
|
|
258
|
+
// 如果在设置各列数据时,没有被设置默认的各列索引defaultIndex,那么用0去填充它,数组长度为列的数量
|
|
259
|
+
if (this.innerIndex.length === 0) {
|
|
260
|
+
this.innerIndex = new Array(columns.length).fill(0)
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
// 获取各列选中值对应的索引
|
|
264
|
+
getIndexs() {
|
|
265
|
+
return this.innerIndex
|
|
266
|
+
},
|
|
267
|
+
// 获取各列选中的值
|
|
268
|
+
getValues() {
|
|
269
|
+
// 进行同步阻塞,因为外部得到change事件之后,可能需要执行setColumnValues更新列的值
|
|
270
|
+
// 索引如果在外部change的回调中调用getValues的话,可能无法得到变更后的列值,这里进行一定延时,保证值的准确性
|
|
271
|
+
(async () => {
|
|
272
|
+
await this.$uv.sleep()
|
|
273
|
+
})()
|
|
274
|
+
return this.innerColumns.map((item, index) => item[this.innerIndex[index]])
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
}
|
|
278
|
+
</script>
|
|
279
|
+
|
|
280
|
+
<style lang="scss" scoped>
|
|
281
|
+
$show-lines: 1;
|
|
282
|
+
@import '../../libs/css/variable.scss';
|
|
283
|
+
@import '../../libs/css/components.scss';
|
|
284
|
+
@import '../../libs/css/color.scss';
|
|
285
|
+
.uv-picker {
|
|
286
|
+
position: relative;
|
|
287
|
+
|
|
288
|
+
&__view {
|
|
289
|
+
|
|
290
|
+
&__column {
|
|
291
|
+
@include flex;
|
|
292
|
+
flex: 1;
|
|
293
|
+
justify-content: center;
|
|
294
|
+
|
|
295
|
+
&__item {
|
|
296
|
+
@include flex;
|
|
297
|
+
justify-content: center;
|
|
298
|
+
align-items: center;
|
|
299
|
+
font-size: 16px;
|
|
300
|
+
text-align: center;
|
|
301
|
+
/* #ifndef APP-NVUE */
|
|
302
|
+
display: block;
|
|
303
|
+
/* #endif */
|
|
304
|
+
color: $uv-main-color;
|
|
305
|
+
|
|
306
|
+
&--disabled {
|
|
307
|
+
/* #ifndef APP-NVUE */
|
|
308
|
+
cursor: not-allowed;
|
|
309
|
+
/* #endif */
|
|
310
|
+
opacity: 0.35;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
&--loading {
|
|
317
|
+
position: absolute;
|
|
318
|
+
top: 0;
|
|
319
|
+
right: 0;
|
|
320
|
+
left: 0;
|
|
321
|
+
bottom: 0;
|
|
322
|
+
@include flex;
|
|
323
|
+
justify-content: center;
|
|
324
|
+
align-items: center;
|
|
325
|
+
background-color: rgba(255, 255, 255, 0.87);
|
|
326
|
+
z-index: 1000;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
</style>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// #ifdef H5
|
|
2
|
+
export default {
|
|
3
|
+
name: 'Keypress',
|
|
4
|
+
props: {
|
|
5
|
+
disable: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
mounted () {
|
|
11
|
+
const keyNames = {
|
|
12
|
+
esc: ['Esc', 'Escape'],
|
|
13
|
+
tab: 'Tab',
|
|
14
|
+
enter: 'Enter',
|
|
15
|
+
space: [' ', 'Spacebar'],
|
|
16
|
+
up: ['Up', 'ArrowUp'],
|
|
17
|
+
left: ['Left', 'ArrowLeft'],
|
|
18
|
+
right: ['Right', 'ArrowRight'],
|
|
19
|
+
down: ['Down', 'ArrowDown'],
|
|
20
|
+
delete: ['Backspace', 'Delete', 'Del']
|
|
21
|
+
}
|
|
22
|
+
const listener = ($event) => {
|
|
23
|
+
if (this.disable) {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
const keyName = Object.keys(keyNames).find(key => {
|
|
27
|
+
const keyName = $event.key
|
|
28
|
+
const value = keyNames[key]
|
|
29
|
+
return value === keyName || (Array.isArray(value) && value.includes(keyName))
|
|
30
|
+
})
|
|
31
|
+
if (keyName) {
|
|
32
|
+
// 避免和其他按键事件冲突
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
this.$emit(keyName, {})
|
|
35
|
+
}, 0)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
document.addEventListener('keyup', listener)
|
|
39
|
+
// this.$once('hook:beforeDestroy', () => {
|
|
40
|
+
// document.removeEventListener('keyup', listener)
|
|
41
|
+
// })
|
|
42
|
+
},
|
|
43
|
+
render: () => {}
|
|
44
|
+
}
|
|
45
|
+
// #endif
|