v-uni-app-ui 1.0.4 → 1.0.6
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 +62 -82
- package/dist/v-uni-app-ui.css +1 -0
- package/dist/v-uni-app-ui.es.js +6569 -0
- package/dist/v-uni-app-ui.umd.js +7 -0
- package/package.json +17 -5
- package/components/config/css/basic.scss +0 -19
- package/components/config/interface/basic-type.js +0 -16
- package/components/config/interface/components-interface.ts +0 -0
- package/components/config/interface/monitor/components/input-monitor.js +0 -0
- package/components/config/interface/monitor/property-monitor.ts +0 -136
- package/components/config/interface/props/basic-props.ts +0 -88
- package/components/config/interface/props/components/button-props.ts +0 -85
- package/components/config/interface/props/components/input-props.ts +0 -69
- package/components/config/interface/props/props-tools.ts +0 -64
- package/components/config/style/basic.js +0 -346
- package/components/config/style/component-registry.js +0 -142
- package/components/config/style/components/button-style.js +0 -160
- package/components/config/style/components/input-style.js +0 -98
- package/components/config/style/components-style.js +0 -622
- package/components/config/style/property-mapper.js +0 -377
- package/components/config/style/pseudo-processor.js +0 -213
- package/components/config.js +0 -123
- package/components/icon/iconfont.css +0 -87
- package/components/icon/iconfont.js +0 -1
- package/components/icon/iconfont.json +0 -135
- package/components/icon/iconfont.ttf +0 -0
- package/components/icon/iconfont.woff +0 -0
- package/components/icon/iconfont.woff2 +0 -0
- package/components/layout/v-card/v-card.vue +0 -108
- package/components/layout/v-grid/v-grid.vue +0 -162
- package/components/layout/v-icon-grid/v-icon-grid.vue +0 -195
- package/components/layout/v-infinite-scroll/v-infinite-scroll.vue +0 -172
- package/components/layout/v-list/v-list.vue +0 -43
- package/components/layout/v-row/v-row.vue +0 -142
- package/components/layout/v-waterfall/v-waterfall.vue +0 -79
- package/components/model/compound/v-checkbox-group/v-checkbox-group.vue +0 -96
- package/components/model/compound/v-console/v-console.js +0 -20
- package/components/model/compound/v-console/v-console.vue +0 -299
- package/components/model/compound/v-date-time/v-date-time.vue +0 -261
- package/components/model/compound/v-dialog/v-dialog.vue +0 -178
- package/components/model/compound/v-drum-select-picker/v-drum-select-picker.vue +0 -83
- package/components/model/compound/v-form/v-form.vue +0 -226
- package/components/model/compound/v-form-item/v-form-item.vue +0 -255
- package/components/model/compound/v-image/v-image.vue +0 -357
- package/components/model/compound/v-input-desensitize/v-input-desensitize.vue +0 -101
- package/components/model/compound/v-page/v-page.vue +0 -11
- package/components/model/compound/v-pages/v-pages.vue +0 -141
- package/components/model/compound/v-picker-list/v-picker-list.vue +0 -109
- package/components/model/compound/v-popup/v-popup.vue +0 -151
- package/components/model/compound/v-radio-group/v-radio-group.vue +0 -86
- package/components/model/compound/v-select-picker/v-select-picker.vue +0 -202
- package/components/model/compound/v-series-picker-list/v-series-picker-list.vue +0 -221
- package/components/model/compound/v-series-select-picker/v-series-select-picker.vue +0 -203
- package/components/model/compound/v-switch/v-switch.vue +0 -136
- package/components/model/compound/v-tabs-page/v-tabs-page.vue +0 -138
- package/components/model/native/v-badge/v-badge.vue +0 -143
- package/components/model/native/v-button/v-button.vue +0 -81
- package/components/model/native/v-carousel/v-carousel.vue +0 -138
- package/components/model/native/v-checkbox/v-checkbox.vue +0 -215
- package/components/model/native/v-collapse/v-collapse.vue +0 -190
- package/components/model/native/v-header-navigation-bar/v-header-navigation-bar.vue +0 -92
- package/components/model/native/v-input/v-input.vue +0 -163
- package/components/model/native/v-input-code/v-input-code.vue +0 -146
- package/components/model/native/v-loading/v-loading.vue +0 -206
- package/components/model/native/v-menu/v-menu.vue +0 -222
- package/components/model/native/v-menu-slide/v-menu-slide.vue +0 -364
- package/components/model/native/v-min-loading/v-min-loading.vue +0 -80
- package/components/model/native/v-null/v-null.vue +0 -97
- package/components/model/native/v-overlay/v-overlay.vue +0 -96
- package/components/model/native/v-pull-up-refresh/v-pull-up-refresh.vue +0 -157
- package/components/model/native/v-radio/v-radio.vue +0 -138
- package/components/model/native/v-scroll-list/v-scroll-list.vue +0 -169
- package/components/model/native/v-steps/v-steps.vue +0 -253
- package/components/model/native/v-table/v-table.vue +0 -203
- package/components/model/native/v-tabs/v-tabs.vue +0 -235
- package/components/model/native/v-tag/v-tag.vue +0 -206
- package/components/model/native/v-text/v-text.vue +0 -187
- package/components/model/native/v-textarea/v-textarea.vue +0 -178
- package/components/model/native/v-title/v-title.vue +0 -91
- package/components/model/native/v-toast/info.png +0 -0
- package/components/model/native/v-toast/success.png +0 -0
- package/components/model/native/v-toast/v-toast.vue +0 -198
- package/components/model/native/v-toast/warn.png +0 -0
- package/components/model/native/v-upload-file-button/v-upload-file-button.vue +0 -296
- package/components/model/native/v-video/v-video.vue +0 -175
- package/components/model/native/v-window/v-window.vue +0 -158
- package/components/utils/event-modifiers.ts +0 -139
- package/components/utils/validator.ts +0 -451
- package/index.js +0 -372
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="v-pages">
|
|
3
|
-
<view class="pages-container">
|
|
4
|
-
<v-button :disabled="currentPage <= 1" @click="changePage(currentPage - 1)" size="small">上一页</v-button>
|
|
5
|
-
<template v-for="(page, index) in pageList" :key="index">
|
|
6
|
-
<view v-if="page === '...'" class="page-item" :class="{ active: currentPage === page }" style="cursor: default; color: #ccc">
|
|
7
|
-
{{ page }}
|
|
8
|
-
</view>
|
|
9
|
-
<view v-else class="page-item" :class="{ active: page === currentPage }" @click="changePage(page)">
|
|
10
|
-
{{ page }}
|
|
11
|
-
</view>
|
|
12
|
-
</template>
|
|
13
|
-
<v-button :disabled="currentPage >= totalPages" @click="changePage(currentPage + 1)" size="small">下一页</v-button>
|
|
14
|
-
</view>
|
|
15
|
-
</view>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<script setup lang="ts">
|
|
19
|
-
import { computed, inject } from 'vue';
|
|
20
|
-
|
|
21
|
-
const props = defineProps({
|
|
22
|
-
total: {
|
|
23
|
-
type: Number,
|
|
24
|
-
default: 0
|
|
25
|
-
},
|
|
26
|
-
pageSize: {
|
|
27
|
-
type: Number,
|
|
28
|
-
default: 10
|
|
29
|
-
},
|
|
30
|
-
currentPage: {
|
|
31
|
-
type: Number,
|
|
32
|
-
default: 1
|
|
33
|
-
},
|
|
34
|
-
pageRange: {
|
|
35
|
-
type: Number,
|
|
36
|
-
default: 3
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const emit = defineEmits(['update:currentPage', 'change']);
|
|
41
|
-
|
|
42
|
-
const config = inject<any>('config');
|
|
43
|
-
const totalPages = computed(() => {
|
|
44
|
-
return Math.ceil(props.total / props.pageSize);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const pageList = computed(() => {
|
|
48
|
-
const list = [];
|
|
49
|
-
const totalPage = totalPages.value;
|
|
50
|
-
const maxPagesToShow = props.pageRange * 2 + 1;
|
|
51
|
-
|
|
52
|
-
if (totalPage <= maxPagesToShow) {
|
|
53
|
-
for (let i = 1; i <= totalPage; i++) {
|
|
54
|
-
list.push(i);
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
const startPage = Math.max(1, props.currentPage - props.pageRange);
|
|
58
|
-
const endPage = Math.min(totalPage, props.currentPage + props.pageRange);
|
|
59
|
-
|
|
60
|
-
if (startPage > 1) {
|
|
61
|
-
list.push(1);
|
|
62
|
-
if (startPage > 2) {
|
|
63
|
-
list.push('...');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
for (let i = startPage; i <= endPage; i++) {
|
|
68
|
-
list.push(i);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (endPage < totalPage - 1) {
|
|
72
|
-
list.push('...');
|
|
73
|
-
if (endPage < totalPage) {
|
|
74
|
-
list.push(totalPage);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return list;
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const changePage = (page: number) => {
|
|
83
|
-
if (page < 1 || page > totalPages.value) return;
|
|
84
|
-
emit('update:currentPage', page);
|
|
85
|
-
emit('change', page);
|
|
86
|
-
};
|
|
87
|
-
</script>
|
|
88
|
-
|
|
89
|
-
<style lang="scss" scoped>
|
|
90
|
-
.v-pages {
|
|
91
|
-
display: flex;
|
|
92
|
-
justify-content: center;
|
|
93
|
-
padding: 20rpx 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.pages-container {
|
|
97
|
-
display: flex;
|
|
98
|
-
align-items: center;
|
|
99
|
-
justify-content: center;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.page-item {
|
|
103
|
-
width: 45rpx;
|
|
104
|
-
height: 45rpx;
|
|
105
|
-
display: flex;
|
|
106
|
-
align-items: center;
|
|
107
|
-
justify-content: center;
|
|
108
|
-
margin: 0 5rpx;
|
|
109
|
-
border-radius: 6rpx;
|
|
110
|
-
background-color: v-bind('config.backgroundColor.reversal');
|
|
111
|
-
cursor: pointer;
|
|
112
|
-
transition: all 0.3s;
|
|
113
|
-
border: 1px solid v-bind('config.border.color');
|
|
114
|
-
|
|
115
|
-
&:hover {
|
|
116
|
-
border-color: v-bind('config.border.default');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
&:disabled {
|
|
120
|
-
cursor: not-allowed;
|
|
121
|
-
opacity: v-bind('config.opacity.disabled');
|
|
122
|
-
border-color: v-bind('config.border.color');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
&.active {
|
|
126
|
-
background-color: v-bind('config.backgroundColor.default');
|
|
127
|
-
color: v-bind('config.fontColor.reversal');
|
|
128
|
-
border-color: v-bind('config.border.default');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
&.page-item--no-border {
|
|
132
|
-
border: none;
|
|
133
|
-
box-shadow: none;
|
|
134
|
-
background-color: transparent;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
&.page-item--no-bg {
|
|
138
|
-
background-color: transparent;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
</style>
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view>
|
|
3
|
-
<v-popup v-model:value="isShow" :title="title" :scrollHeight="scrollHeight" @close="handleClose" @confirm="handleConfirm">
|
|
4
|
-
<view class="popup-content">
|
|
5
|
-
<view v-for="(item, index) in safeList" :key="index" class="picker-item" :class="{ active: item.value === selectedValue }" @click="handleSelect(item)">
|
|
6
|
-
{{ item.label }}
|
|
7
|
-
</view>
|
|
8
|
-
<view v-show="safeList.length === 0">
|
|
9
|
-
<slot name="is-null">
|
|
10
|
-
<v-null text="暂无数据"></v-null>
|
|
11
|
-
</slot>
|
|
12
|
-
</view>
|
|
13
|
-
</view>
|
|
14
|
-
</v-popup>
|
|
15
|
-
</view>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<script setup lang="ts">
|
|
19
|
-
import { ref, computed, watch,inject } from 'vue';
|
|
20
|
-
|
|
21
|
-
interface PickerItem {
|
|
22
|
-
label: string;
|
|
23
|
-
value: string | number;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* v-picker 拾取器
|
|
27
|
-
* value 是否显示拾取器 默认值:false 可选值true显示、false隐藏
|
|
28
|
-
* list 拾取器数据列表
|
|
29
|
-
* title 拾取器标题
|
|
30
|
-
* selected 默认选中项 默认值:null
|
|
31
|
-
* scrollHeight 拾取器滚动区域高度 默认值:400
|
|
32
|
-
* 相关事件:confirm 选中事件 select选择事件
|
|
33
|
-
*/
|
|
34
|
-
const props = defineProps({
|
|
35
|
-
value: {
|
|
36
|
-
type: Boolean,
|
|
37
|
-
default: false,
|
|
38
|
-
required: true
|
|
39
|
-
},
|
|
40
|
-
list: {
|
|
41
|
-
type: Array as () => PickerItem[],
|
|
42
|
-
required: true
|
|
43
|
-
},
|
|
44
|
-
title: {
|
|
45
|
-
type: String,
|
|
46
|
-
default: ''
|
|
47
|
-
},
|
|
48
|
-
selected: {
|
|
49
|
-
type: [String, Number],
|
|
50
|
-
default: null
|
|
51
|
-
},
|
|
52
|
-
scrollHeight: {
|
|
53
|
-
type: Number,
|
|
54
|
-
default: 400
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const emit = defineEmits(['update:value', 'close', 'confirm', 'select']);
|
|
59
|
-
|
|
60
|
-
const isShow = ref(props.value);
|
|
61
|
-
// 安全列表计算属性
|
|
62
|
-
const safeList = computed(() => props.list || []);
|
|
63
|
-
const selectedValue = ref(
|
|
64
|
-
props.selected !== null && props.selected !== undefined
|
|
65
|
-
? props.selected
|
|
66
|
-
: (safeList.value.length > 0 && safeList.value[0].value !== undefined ? safeList.value[0].value : '')
|
|
67
|
-
);
|
|
68
|
-
const config = inject<any>('config');
|
|
69
|
-
const selectedItem = computed(() => {
|
|
70
|
-
return safeList.value.find((item) => item.value === selectedValue.value) || null;
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
watch(
|
|
74
|
-
() => props.value,
|
|
75
|
-
(newValue) => {
|
|
76
|
-
isShow.value = newValue;
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
function handleClose() {
|
|
81
|
-
isShow.value = false;
|
|
82
|
-
emit('update:value', false);
|
|
83
|
-
emit('close', false);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function handleSelect(item: PickerItem) {
|
|
87
|
-
selectedValue.value = item.value;
|
|
88
|
-
emit('select', item);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function handleConfirm() {
|
|
92
|
-
isShow.value = false;
|
|
93
|
-
emit('confirm', selectedItem.value);
|
|
94
|
-
emit('update:value', false);
|
|
95
|
-
}
|
|
96
|
-
</script>
|
|
97
|
-
<style lang="scss">
|
|
98
|
-
.picker-item {
|
|
99
|
-
padding: 20rpx 30rpx;
|
|
100
|
-
font-size: v-bind("config.fontSize.mediumText");
|
|
101
|
-
color: v-bind("config.fontColor.mainText");
|
|
102
|
-
border-bottom: 1rpx solid v-bind("config.border.color");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.picker-item.active {
|
|
106
|
-
color: v-bind("config.fontColor.default");
|
|
107
|
-
font-weight: 500;
|
|
108
|
-
}
|
|
109
|
-
</style>
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view v-if="isShow" class="popup-list-container" :class="{ active: props.value }">
|
|
3
|
-
<v-overlay v-model:value="props.value" :z-index="8" @click="handleClose"></v-overlay>
|
|
4
|
-
<view :class="['popup-list', `popup-list--border--${model}`]">
|
|
5
|
-
<view class="popup-header">
|
|
6
|
-
<slot name="title-header">
|
|
7
|
-
<view class="popup-title">{{ title }}</view>
|
|
8
|
-
<view class="popup-close" @click.stop="handleClose">取消</view>
|
|
9
|
-
</slot>
|
|
10
|
-
</view>
|
|
11
|
-
<view class="popup-content">
|
|
12
|
-
<scroll-view class="popup-scroll" scroll-y :style="{ height: scrollHeight + 'rpx' }">
|
|
13
|
-
<slot></slot>
|
|
14
|
-
</scroll-view>
|
|
15
|
-
</view>
|
|
16
|
-
<view class="popup-footer">
|
|
17
|
-
<slot name="buttons-footer">
|
|
18
|
-
<v-button class="popup-confirm" @click="handleConfirm" model="circle">确定</v-button>
|
|
19
|
-
</slot>
|
|
20
|
-
</view>
|
|
21
|
-
</view>
|
|
22
|
-
</view>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<script setup lang="ts">
|
|
26
|
-
import { ref, computed, watch, inject } from 'vue';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* v-popup 弹窗
|
|
30
|
-
* show 是否显示弹窗 默认值:false 可选值true显示、false隐藏
|
|
31
|
-
* title 弹窗标题
|
|
32
|
-
* scrollHeight 滚动区域高度 默认值:400
|
|
33
|
-
* model 模式 默认值:square 可选值:semicircle半圆、square方形
|
|
34
|
-
*/
|
|
35
|
-
const props = defineProps({
|
|
36
|
-
value: {
|
|
37
|
-
type: Boolean,
|
|
38
|
-
default: false,
|
|
39
|
-
required: true
|
|
40
|
-
},
|
|
41
|
-
title: {
|
|
42
|
-
type: String,
|
|
43
|
-
default: ''
|
|
44
|
-
},
|
|
45
|
-
scrollHeight: {
|
|
46
|
-
type: Number,
|
|
47
|
-
default: 400
|
|
48
|
-
},
|
|
49
|
-
model: {
|
|
50
|
-
type: String,
|
|
51
|
-
default: 'square'
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const emit = defineEmits(['update:value', 'close', 'confirm']);
|
|
56
|
-
const config = inject<any>('config');
|
|
57
|
-
const isShow = ref(props.value);
|
|
58
|
-
|
|
59
|
-
watch(
|
|
60
|
-
() => props.value,
|
|
61
|
-
(newVal) => {
|
|
62
|
-
isShow.value = newVal;
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
function handleClose() {
|
|
67
|
-
isShow.value = false;
|
|
68
|
-
emit('update:value', false);
|
|
69
|
-
emit('close', false);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function handleConfirm() {
|
|
73
|
-
isShow.value = false;
|
|
74
|
-
emit('update:value', false);
|
|
75
|
-
emit('confirm', false);
|
|
76
|
-
}
|
|
77
|
-
</script>
|
|
78
|
-
<style lang="scss">
|
|
79
|
-
.popup-list-container {
|
|
80
|
-
position: relative;
|
|
81
|
-
width: 100%;
|
|
82
|
-
height: 100%;
|
|
83
|
-
}
|
|
84
|
-
.popup-list {
|
|
85
|
-
position: fixed;
|
|
86
|
-
bottom: 0;
|
|
87
|
-
left: 0;
|
|
88
|
-
width: 100%;
|
|
89
|
-
background-color: v-bind('config.backgroundColor.reversal');
|
|
90
|
-
overflow: hidden;
|
|
91
|
-
transform: translateY(100%);
|
|
92
|
-
transition: transform 0.5s ease;
|
|
93
|
-
z-index: 10;
|
|
94
|
-
|
|
95
|
-
&--border--square {
|
|
96
|
-
border-radius: 0;
|
|
97
|
-
}
|
|
98
|
-
&--border--semicircle {
|
|
99
|
-
border-radius: 15rpx;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.popup-list-container.active {
|
|
104
|
-
.popup-list {
|
|
105
|
-
transform: translateY(0);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.popup-header {
|
|
110
|
-
display: flex;
|
|
111
|
-
justify-content: space-between;
|
|
112
|
-
align-items: center;
|
|
113
|
-
padding: 30rpx;
|
|
114
|
-
background-color: v-bind('config.backgroundColor.reversal');
|
|
115
|
-
border-bottom: 1rpx solid v-bind('config.border.color');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.popup-title {
|
|
119
|
-
font-size: v-bind('config.fontSize.smallTitle');
|
|
120
|
-
font-weight: 500;
|
|
121
|
-
color: v-bind('config.fontColor.mianTitle');
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.popup-close {
|
|
125
|
-
font-size: v-bind('config.fontSize.mediumText');
|
|
126
|
-
color: v-bind('config.fontColor.mainText');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.popup-content {
|
|
130
|
-
max-height: 500rpx;
|
|
131
|
-
overflow: hidden;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.popup-scroll {
|
|
135
|
-
height: 100%;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.popup-footer {
|
|
139
|
-
display: flex;
|
|
140
|
-
justify-content: flex-end;
|
|
141
|
-
padding: 20rpx 30rpx;
|
|
142
|
-
background-color: v-bind('config.backgroundColor.reversal');
|
|
143
|
-
border-top: 1rpx solid v-bind('config.border.color');
|
|
144
|
-
min-height: 125rpx;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.popup-confirm {
|
|
148
|
-
width: 160rpx;
|
|
149
|
-
height: 60rpx;
|
|
150
|
-
}
|
|
151
|
-
</style>
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view :class="['v-radio-group', vertical ? 'vertical' : 'horizontal']" :style="groupStyle" role="radiogroup">
|
|
3
|
-
<slot />
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script lang="ts" setup>
|
|
8
|
-
import { ref, provide, computed, watch } from 'vue';
|
|
9
|
-
|
|
10
|
-
const props = defineProps({
|
|
11
|
-
value: {
|
|
12
|
-
type: [String, Number],
|
|
13
|
-
default: ''
|
|
14
|
-
},
|
|
15
|
-
vertical: {
|
|
16
|
-
type: Boolean,
|
|
17
|
-
default: false
|
|
18
|
-
},
|
|
19
|
-
disabled: {
|
|
20
|
-
type: Boolean,
|
|
21
|
-
default: false
|
|
22
|
-
},
|
|
23
|
-
groupStyle: {
|
|
24
|
-
type: Object,
|
|
25
|
-
default: () => ({})
|
|
26
|
-
},
|
|
27
|
-
defaultValue: {
|
|
28
|
-
type: [String, Number],
|
|
29
|
-
default: ''
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const emit = defineEmits(['update:value', 'change']);
|
|
34
|
-
const currentValue = ref(props.value);
|
|
35
|
-
|
|
36
|
-
watch(
|
|
37
|
-
() => props.value,
|
|
38
|
-
(newVal) => {
|
|
39
|
-
currentValue.value = newVal;
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
provide('radioGroup', {
|
|
44
|
-
value: currentValue,
|
|
45
|
-
disabled: computed(() => props.disabled),
|
|
46
|
-
defaultValue: computed(() => props.defaultValue), // 提供默认值
|
|
47
|
-
emitUpdate: (newValue: any) => {
|
|
48
|
-
currentValue.value = newValue;
|
|
49
|
-
emit('update:value', newValue);
|
|
50
|
-
emit('change', newValue);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
watch(currentValue, (newVal) => {
|
|
55
|
-
emit('update:value', newVal);
|
|
56
|
-
emit('change', newVal);
|
|
57
|
-
});
|
|
58
|
-
</script>
|
|
59
|
-
|
|
60
|
-
<style lang="scss">
|
|
61
|
-
.v-radio-group {
|
|
62
|
-
height: 72rpx;
|
|
63
|
-
&.horizontal {
|
|
64
|
-
display: flex;
|
|
65
|
-
flex-wrap: wrap;
|
|
66
|
-
|
|
67
|
-
.v-radio {
|
|
68
|
-
margin-right: 32rpx;
|
|
69
|
-
|
|
70
|
-
&:last-child {
|
|
71
|
-
margin-right: 0;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
&.vertical {
|
|
77
|
-
.v-radio {
|
|
78
|
-
margin-bottom: 24rpx;
|
|
79
|
-
|
|
80
|
-
&:last-child {
|
|
81
|
-
margin-bottom: 0;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
</style>
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="select-picker">
|
|
3
|
-
<view :class="['select-input', `select-input--border-${borderModel}`, { 'select-input--disabled': disabled }]" @click="handleClick">
|
|
4
|
-
<slot :placeholder="placeholder" :row="row">
|
|
5
|
-
<view class="input">
|
|
6
|
-
{{ row.label != null ? row.label : props.placeholder }}
|
|
7
|
-
</view>
|
|
8
|
-
</slot>
|
|
9
|
-
</view>
|
|
10
|
-
<v-picker-list
|
|
11
|
-
v-model:value="showPicker"
|
|
12
|
-
:list="options"
|
|
13
|
-
:title="title"
|
|
14
|
-
@confirm="handleConfirm"
|
|
15
|
-
@select="handleSelect"
|
|
16
|
-
:scroll-height="scrollHeight"
|
|
17
|
-
:selected="value"
|
|
18
|
-
></v-picker-list>
|
|
19
|
-
</view>
|
|
20
|
-
</template>
|
|
21
|
-
|
|
22
|
-
<script setup lang="ts">
|
|
23
|
-
import { ref, watch, onMounted, reactive, inject, computed } from 'vue';
|
|
24
|
-
|
|
25
|
-
interface OptionsList {
|
|
26
|
-
label: String;
|
|
27
|
-
value: String | Number;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* v-select-picker 下拉框
|
|
31
|
-
* value 双向绑定
|
|
32
|
-
* placeholder 提示语
|
|
33
|
-
* title 标题
|
|
34
|
-
* options 选择值
|
|
35
|
-
* initializeCustomizeFunction 自定义初始函数
|
|
36
|
-
* borderModel 边框模式 默认:all 可选值:all普通边框 nont无边框模式 bottom底部边框模式 top上边框模式 left左边框模式 right右边框模式 ends左右两端边框模式 up-down上下边框模式
|
|
37
|
-
* disabled 是否禁用 默认:false 可选值:true禁用 false不禁用
|
|
38
|
-
* 相关事件:confirm、select
|
|
39
|
-
*/
|
|
40
|
-
const props = defineProps({
|
|
41
|
-
value: {
|
|
42
|
-
type: [String, Number],
|
|
43
|
-
required: true
|
|
44
|
-
},
|
|
45
|
-
placeholder: {
|
|
46
|
-
type: String,
|
|
47
|
-
default: null
|
|
48
|
-
},
|
|
49
|
-
title: {
|
|
50
|
-
type: String,
|
|
51
|
-
required: true
|
|
52
|
-
},
|
|
53
|
-
options: {
|
|
54
|
-
type: Array as () => OptionsList[],
|
|
55
|
-
required: true
|
|
56
|
-
},
|
|
57
|
-
initializeCustomizeFunction: {
|
|
58
|
-
type: Function,
|
|
59
|
-
default: () => {
|
|
60
|
-
return () => {};
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
borderModel: {
|
|
64
|
-
type: String,
|
|
65
|
-
default: 'all',
|
|
66
|
-
validator: (value: any) => {
|
|
67
|
-
return ['all', 'none', 'bottom', 'top', 'left', 'right', 'ends', 'up-down'].includes(value);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
disabled: {
|
|
71
|
-
type: Boolean,
|
|
72
|
-
default: false
|
|
73
|
-
},
|
|
74
|
-
scrollHeight: {
|
|
75
|
-
type: Number,
|
|
76
|
-
default: 400
|
|
77
|
-
},
|
|
78
|
-
backgroundColor: {
|
|
79
|
-
type: String,
|
|
80
|
-
default: null
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
let showPicker = ref(false);
|
|
85
|
-
|
|
86
|
-
let row = reactive({
|
|
87
|
-
label: null,
|
|
88
|
-
value: null
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const emit = defineEmits(['update:value', 'confirm', 'select']);
|
|
92
|
-
const config = inject<any>('config');
|
|
93
|
-
|
|
94
|
-
const computedBackgroundColor = computed(() => {
|
|
95
|
-
if (props.backgroundColor) {
|
|
96
|
-
return props.backgroundColor;
|
|
97
|
-
}
|
|
98
|
-
if (config && config.backgroundColor && config.backgroundColor.reversal) {
|
|
99
|
-
return config.backgroundColor.reversal;
|
|
100
|
-
}
|
|
101
|
-
return '#ffffff';
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
onMounted(async () => {
|
|
105
|
-
await props.initializeCustomizeFunction(props.value);
|
|
106
|
-
matchingData(props.value);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
watch(
|
|
110
|
-
() => props.value,
|
|
111
|
-
(newValue: any) => {
|
|
112
|
-
matchingData(newValue);
|
|
113
|
-
}
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
watch(
|
|
117
|
-
() => props.options,
|
|
118
|
-
(newValue: any) => {
|
|
119
|
-
matchingData(props.value);
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
function matchingData(value: any) {
|
|
124
|
-
const matchedItem = props.options.find((item) => item.value === value);
|
|
125
|
-
if (matchedItem != undefined) {
|
|
126
|
-
Object.assign(row, matchedItem);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function handleClick() {
|
|
131
|
-
if (!props.disabled) {
|
|
132
|
-
showPicker.value = true;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function handleConfirm(selected: any) {
|
|
137
|
-
Object.assign(row, selected);
|
|
138
|
-
emit('update:value', row.value);
|
|
139
|
-
emit('confirm', row.value, row);
|
|
140
|
-
showPicker.value = false;
|
|
141
|
-
}
|
|
142
|
-
function handleSelect(selected: any) {
|
|
143
|
-
emit('select', selected);
|
|
144
|
-
}
|
|
145
|
-
</script>
|
|
146
|
-
|
|
147
|
-
<style lang="scss" scoped>
|
|
148
|
-
.select-input {
|
|
149
|
-
width: 100%;
|
|
150
|
-
height: 72rpx;
|
|
151
|
-
line-height: 72rpx;
|
|
152
|
-
background-color: v-bind('computedBackgroundColor');
|
|
153
|
-
border-radius: 10rpx;
|
|
154
|
-
box-sizing: border-box;
|
|
155
|
-
|
|
156
|
-
&--border-all {
|
|
157
|
-
border: 1rpx solid v-bind('config.border.color');
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
&--border-none {
|
|
161
|
-
border: none;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
&--border-bottom {
|
|
165
|
-
border-bottom: 1rpx solid v-bind('config.border.color');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
&--border-top {
|
|
169
|
-
border-top: 1rpx solid v-bind('config.border.color');
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
&--border-left {
|
|
173
|
-
border-left: 1rpx solid v-bind('config.border.color');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
&--border-right {
|
|
177
|
-
border-right: 1rpx solid v-bind('config.border.color');
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
&--border-ends {
|
|
181
|
-
border-left: 1rpx solid v-bind('config.border.color');
|
|
182
|
-
border-right: 1rpx solid v-bind('config.border.color');
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
&--border-up-down {
|
|
186
|
-
border-top: 1rpx solid v-bind('config.border.color');
|
|
187
|
-
border-bottom: 1rpx solid v-bind('config.border.color');
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
&--disabled {
|
|
191
|
-
background-color: v-bind('config.backgroundColor.disabled');
|
|
192
|
-
color: v-bind('config.fontColor.text');
|
|
193
|
-
opacity: v-bind('config.opacity.disabled');
|
|
194
|
-
cursor: not-allowed;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.input {
|
|
198
|
-
margin-left: 2%;
|
|
199
|
-
font-size: v-bind('config.fontSize.mediumText');
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
</style>
|