@10yun/cv-mobile-ui 0.5.20 → 0.5.22
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/package.json +1 -1
- package/plugins/jumps.js +57 -12
- package/plugins/lbs.js +17 -8
- package/ui-cv/components/cv-grid-item/cv-grid-item.vue +1 -1
- package/uni-ui/lib/uni-badge/uni-badge.vue +150 -1
- package/uni-ui/lib/uni-breadcrumb/uni-breadcrumb.vue +37 -1
- package/uni-ui/lib/uni-breadcrumb-item/uni-breadcrumb-item.vue +83 -1
- package/uni-ui/lib/uni-calendar/uni-calendar-item.vue +122 -1
- package/uni-ui/lib/uni-calendar/uni-calendar.vue +366 -1
- package/uni-ui/lib/uni-card/uni-card.vue +124 -1
- package/uni-ui/lib/uni-col/uni-col.vue +1 -1
- package/uni-ui/lib/uni-collapse/uni-collapse.vue +135 -1
- package/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +266 -1
- package/uni-ui/lib/uni-combox/uni-combox.vue +1 -1
- package/uni-ui/lib/uni-countdown/uni-countdown.vue +239 -1
- package/uni-ui/lib/uni-data-checkbox/uni-data-checkbox.vue +487 -1
- package/uni-ui/lib/uni-data-picker/uni-data-picker.vue +530 -1
- package/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +157 -150
- package/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +166 -1
- package/uni-ui/lib/uni-data-select/uni-data-select.vue +289 -1
- package/uni-ui/lib/uni-datetime-picker/calendar-item.vue +70 -1
- package/uni-ui/lib/uni-datetime-picker/calendar.vue +629 -1
- package/uni-ui/lib/uni-datetime-picker/time-picker.vue +741 -1
- package/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +847 -1
- package/uni-ui/lib/uni-drawer/uni-drawer.vue +115 -1
- package/uni-ui/lib/uni-easyinput/uni-easyinput.vue +515 -1
- package/uni-ui/lib/uni-fab/uni-fab.vue +257 -1
- package/uni-ui/lib/uni-fav/uni-fav.vue +123 -1
- package/uni-ui/lib/uni-file-picker/uni-file-picker.vue +642 -1
- package/uni-ui/lib/uni-file-picker/upload-file.vue +177 -1
- package/uni-ui/lib/uni-file-picker/upload-image.vue +176 -1
- package/uni-ui/lib/uni-forms/uni-forms.vue +375 -1
- package/uni-ui/lib/uni-forms-item/uni-forms-item.vue +429 -1
- package/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +129 -1
- package/uni-ui/lib/uni-grid/uni-grid.vue +115 -1
- package/uni-ui/lib/uni-grid-item/uni-grid-item.vue +78 -1
- package/uni-ui/lib/uni-group/uni-group.vue +85 -1
- package/uni-ui/lib/uni-icons/uni-icons.vue +85 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +68 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +294 -1
- package/uni-ui/lib/uni-list/uni-list.vue +81 -1
- package/uni-ui/lib/uni-list-ad/uni-list-ad.vue +77 -1
- package/uni-ui/lib/uni-list-chat/uni-list-chat.vue +294 -1
- package/uni-ui/lib/uni-list-item/uni-list-item.vue +346 -1
- package/uni-ui/lib/uni-load-more/uni-load-more.vue +172 -1
- package/uni-ui/lib/uni-nav-bar/uni-nav-bar.vue +205 -1
- package/uni-ui/lib/uni-nav-bar/uni-status-bar.vue +18 -1
- package/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +331 -1
- package/uni-ui/lib/uni-number-box/uni-number-box.vue +166 -1
- package/uni-ui/lib/uni-pagination/uni-pagination.vue +323 -1
- package/uni-ui/lib/uni-popup/uni-popup.vue +1 -1
- package/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +173 -1
- package/uni-ui/lib/uni-popup-message/uni-popup-message.vue +74 -1
- package/uni-ui/lib/uni-popup-share/uni-popup-share.vue +106 -1
- package/uni-ui/lib/uni-rate/uni-rate.vue +322 -1
- package/uni-ui/lib/uni-row/uni-row.vue +1 -1
- package/uni-ui/lib/uni-search-bar/uni-search-bar.vue +236 -1
- package/uni-ui/lib/uni-section/uni-section.vue +109 -1
- package/uni-ui/lib/uni-segmented-control/uni-segmented-control.vue +103 -1
- package/uni-ui/lib/uni-status-bar/uni-status-bar.vue +1 -1
- package/uni-ui/lib/uni-steps/uni-steps.vue +120 -1
- package/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +226 -3
- package/uni-ui/lib/uni-swiper-dot/uni-swiper-dot.vue +167 -1
- package/uni-ui/lib/uni-table/uni-table.vue +297 -1
- package/uni-ui/lib/uni-tag/uni-tag.vue +100 -1
- package/uni-ui/lib/uni-td/uni-td.vue +78 -1
- package/uni-ui/lib/uni-th/filter-dropdown.vue +1 -1
- package/uni-ui/lib/uni-th/uni-th.vue +224 -1
- package/uni-ui/lib/uni-thead/uni-thead.vue +77 -1
- package/uni-ui/lib/uni-tr/table-checkbox.vue +79 -1
- package/uni-ui/lib/uni-tr/uni-tr.vue +135 -1
|
@@ -1 +1,124 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<view
|
|
3
2
|
class="uni-card"
|
|
4
3
|
:class="{ 'uni-card--full': isFull, 'uni-card--shadow': isShadow, 'uni-card--border': border }"
|
|
5
4
|
:style="{ margin: isFull ? 0 : margin, padding: spacing, 'box-shadow': isShadow ? shadow : '' }"
|
|
6
5
|
>
|
|
7
6
|
<!-- 封面 -->
|
|
8
7
|
<slot name="cover">
|
|
9
8
|
<view v-if="cover" class="uni-card__cover">
|
|
10
9
|
<image class="uni-card__cover-image" mode="widthFix" @click="onClick('cover')" :src="cover"></image>
|
|
11
10
|
</view>
|
|
12
11
|
</slot>
|
|
13
12
|
<slot name="title">
|
|
14
13
|
<view v-if="title || extra" class="uni-card__header">
|
|
15
14
|
<!-- 卡片标题 -->
|
|
16
15
|
<view class="uni-card__header-box" @click="onClick('title')">
|
|
17
16
|
<view v-if="thumbnail" class="uni-card__header-avatar">
|
|
18
17
|
<image class="uni-card__header-avatar-image" :src="thumbnail" mode="aspectFit" />
|
|
19
18
|
</view>
|
|
20
19
|
<view class="uni-card__header-content">
|
|
21
20
|
<text class="uni-card__header-content-title uni-ellipsis">{{ title }}</text>
|
|
22
21
|
<text v-if="title && subTitle" class="uni-card__header-content-subtitle uni-ellipsis">{{ subTitle }}</text>
|
|
23
22
|
</view>
|
|
24
23
|
</view>
|
|
25
24
|
<view class="uni-card__header-extra" @click="onClick('extra')">
|
|
26
25
|
<slot name="extra">
|
|
27
26
|
<text class="uni-card__header-extra-text">{{ extra }}</text>
|
|
28
27
|
</slot>
|
|
29
28
|
</view>
|
|
30
29
|
</view>
|
|
31
30
|
</slot>
|
|
32
31
|
<!-- 卡片内容 -->
|
|
33
32
|
<view class="uni-card__content" :style="{ padding: padding }" @click="onClick('content')">
|
|
34
33
|
<slot></slot>
|
|
35
34
|
</view>
|
|
36
35
|
<view class="uni-card__actions" @click="onClick('actions')">
|
|
37
36
|
<slot name="actions"></slot>
|
|
38
37
|
</view>
|
|
39
38
|
</view>
|
|
40
39
|
* Card 卡片
|
|
41
40
|
* @description 卡片视图组件
|
|
42
41
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=22
|
|
43
42
|
* @property {String} title 标题文字
|
|
44
43
|
* @property {String} subTitle 副标题
|
|
45
44
|
* @property {Number} padding 内容内边距
|
|
46
45
|
* @property {Number} margin 卡片外边距
|
|
47
46
|
* @property {Number} spacing 卡片内边距
|
|
48
47
|
* @property {String} extra 标题额外信息
|
|
49
48
|
* @property {String} cover 封面图(本地路径需要引入)
|
|
50
49
|
* @property {String} thumbnail 标题左侧缩略图
|
|
51
50
|
* @property {Boolean} is-full = [true | false] 卡片内容是否通栏,为 true 时将去除padding值
|
|
52
51
|
* @property {Boolean} is-shadow = [true | false] 卡片内容是否开启阴影
|
|
53
52
|
* @property {String} shadow 卡片阴影
|
|
54
53
|
* @property {Boolean} border 卡片边框
|
|
55
54
|
* @event {Function} click 点击 Card 触发事件
|
|
56
55
|
*/
|
|
57
56
|
name: 'UniCard',
|
|
58
57
|
emits: ['click'],
|
|
59
58
|
props: {
|
|
60
59
|
title: {
|
|
61
60
|
type: String,
|
|
62
61
|
default: ''
|
|
63
62
|
},
|
|
64
63
|
subTitle: {
|
|
65
64
|
type: String,
|
|
66
65
|
default: ''
|
|
67
66
|
},
|
|
68
67
|
padding: {
|
|
69
68
|
type: String,
|
|
70
69
|
default: '10px'
|
|
71
70
|
},
|
|
72
71
|
margin: {
|
|
73
72
|
type: String,
|
|
74
73
|
default: '15px'
|
|
75
74
|
},
|
|
76
75
|
spacing: {
|
|
77
76
|
type: String,
|
|
78
77
|
default: '0 10px'
|
|
79
78
|
},
|
|
80
79
|
extra: {
|
|
81
80
|
type: String,
|
|
82
81
|
default: ''
|
|
83
82
|
},
|
|
84
83
|
cover: {
|
|
85
84
|
type: String,
|
|
86
85
|
default: ''
|
|
87
86
|
},
|
|
88
87
|
thumbnail: {
|
|
89
88
|
type: String,
|
|
90
89
|
default: ''
|
|
91
90
|
},
|
|
92
91
|
isFull: {
|
|
93
92
|
// 内容区域是否通栏
|
|
94
93
|
type: Boolean,
|
|
95
94
|
default: false
|
|
96
95
|
},
|
|
97
96
|
isShadow: {
|
|
98
97
|
// 是否开启阴影
|
|
99
98
|
type: Boolean,
|
|
100
99
|
default: true
|
|
101
100
|
},
|
|
102
101
|
shadow: {
|
|
103
102
|
type: String,
|
|
104
103
|
default: '0px 0px 3px 1px rgba(0, 0, 0, 0.08)'
|
|
105
104
|
},
|
|
106
105
|
border: {
|
|
107
106
|
type: Boolean,
|
|
108
107
|
default: true
|
|
109
108
|
}
|
|
110
109
|
},
|
|
111
110
|
methods: {
|
|
112
111
|
onClick(type) {
|
|
113
112
|
this.$emit('click', type);
|
|
114
113
|
}
|
|
115
114
|
}
|
|
115
|
+
<template>
|
|
116
|
+
<view
|
|
117
|
+
class="uni-card"
|
|
118
|
+
:class="{ 'uni-card--full': isFull, 'uni-card--shadow': isShadow, 'uni-card--border': border }"
|
|
119
|
+
:style="{ margin: isFull ? 0 : margin, padding: spacing, 'box-shadow': isShadow ? shadow : '' }"
|
|
120
|
+
>
|
|
121
|
+
<!-- 封面 -->
|
|
122
|
+
<slot name="cover">
|
|
123
|
+
<view v-if="cover" class="uni-card__cover">
|
|
124
|
+
<image class="uni-card__cover-image" mode="widthFix" @click="onClick('cover')" :src="cover"></image>
|
|
125
|
+
</view>
|
|
126
|
+
</slot>
|
|
127
|
+
<slot name="title">
|
|
128
|
+
<view v-if="title || extra" class="uni-card__header">
|
|
129
|
+
<!-- 卡片标题 -->
|
|
130
|
+
<view class="uni-card__header-box" @click="onClick('title')">
|
|
131
|
+
<view v-if="thumbnail" class="uni-card__header-avatar">
|
|
132
|
+
<image class="uni-card__header-avatar-image" :src="thumbnail" mode="aspectFit" />
|
|
133
|
+
</view>
|
|
134
|
+
<view class="uni-card__header-content">
|
|
135
|
+
<text class="uni-card__header-content-title uni-ellipsis">{{ title }}</text>
|
|
136
|
+
<text v-if="title && subTitle" class="uni-card__header-content-subtitle uni-ellipsis">{{ subTitle }}</text>
|
|
137
|
+
</view>
|
|
138
|
+
</view>
|
|
139
|
+
<view class="uni-card__header-extra" @click="onClick('extra')">
|
|
140
|
+
<slot name="extra">
|
|
141
|
+
<text class="uni-card__header-extra-text">{{ extra }}</text>
|
|
142
|
+
</slot>
|
|
143
|
+
</view>
|
|
144
|
+
</view>
|
|
145
|
+
</slot>
|
|
146
|
+
<!-- 卡片内容 -->
|
|
147
|
+
<view class="uni-card__content" :style="{ padding: padding }" @click="onClick('content')">
|
|
148
|
+
<slot></slot>
|
|
149
|
+
</view>
|
|
150
|
+
<view class="uni-card__actions" @click="onClick('actions')">
|
|
151
|
+
<slot name="actions"></slot>
|
|
152
|
+
</view>
|
|
153
|
+
</view>
|
|
154
|
+
</template>
|
|
155
|
+
<script>
|
|
156
|
+
/**
|
|
157
|
+
* Card 卡片
|
|
158
|
+
* @description 卡片视图组件
|
|
159
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=22
|
|
160
|
+
* @property {String} title 标题文字
|
|
161
|
+
* @property {String} subTitle 副标题
|
|
162
|
+
* @property {Number} padding 内容内边距
|
|
163
|
+
* @property {Number} margin 卡片外边距
|
|
164
|
+
* @property {Number} spacing 卡片内边距
|
|
165
|
+
* @property {String} extra 标题额外信息
|
|
166
|
+
* @property {String} cover 封面图(本地路径需要引入)
|
|
167
|
+
* @property {String} thumbnail 标题左侧缩略图
|
|
168
|
+
* @property {Boolean} is-full = [true | false] 卡片内容是否通栏,为 true 时将去除padding值
|
|
169
|
+
* @property {Boolean} is-shadow = [true | false] 卡片内容是否开启阴影
|
|
170
|
+
* @property {String} shadow 卡片阴影
|
|
171
|
+
* @property {Boolean} border 卡片边框
|
|
172
|
+
* @event {Function} click 点击 Card 触发事件
|
|
173
|
+
*/
|
|
174
|
+
export default {
|
|
175
|
+
name: 'UniCard',
|
|
176
|
+
emits: ['click'],
|
|
177
|
+
props: {
|
|
178
|
+
title: {
|
|
179
|
+
type: String,
|
|
180
|
+
default: ''
|
|
181
|
+
},
|
|
182
|
+
subTitle: {
|
|
183
|
+
type: String,
|
|
184
|
+
default: ''
|
|
185
|
+
},
|
|
186
|
+
padding: {
|
|
187
|
+
type: String,
|
|
188
|
+
default: '10px'
|
|
189
|
+
},
|
|
190
|
+
margin: {
|
|
191
|
+
type: String,
|
|
192
|
+
default: '15px'
|
|
193
|
+
},
|
|
194
|
+
spacing: {
|
|
195
|
+
type: String,
|
|
196
|
+
default: '0 10px'
|
|
197
|
+
},
|
|
198
|
+
extra: {
|
|
199
|
+
type: String,
|
|
200
|
+
default: ''
|
|
201
|
+
},
|
|
202
|
+
cover: {
|
|
203
|
+
type: String,
|
|
204
|
+
default: ''
|
|
205
|
+
},
|
|
206
|
+
thumbnail: {
|
|
207
|
+
type: String,
|
|
208
|
+
default: ''
|
|
209
|
+
},
|
|
210
|
+
isFull: {
|
|
211
|
+
// 内容区域是否通栏
|
|
212
|
+
type: Boolean,
|
|
213
|
+
default: false
|
|
214
|
+
},
|
|
215
|
+
isShadow: {
|
|
216
|
+
// 是否开启阴影
|
|
217
|
+
type: Boolean,
|
|
218
|
+
default: true
|
|
219
|
+
},
|
|
220
|
+
shadow: {
|
|
221
|
+
type: String,
|
|
222
|
+
default: '0px 0px 3px 1px rgba(0, 0, 0, 0.08)'
|
|
223
|
+
},
|
|
224
|
+
border: {
|
|
225
|
+
type: Boolean,
|
|
226
|
+
default: true
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
methods: {
|
|
230
|
+
onClick(type) {
|
|
231
|
+
this.$emit('click', type);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
</script>
|
|
236
|
+
<style>
|
|
237
|
+
@import 'style.css';
|
|
238
|
+
</style>
|
|
@@ -1 +1,135 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<view class="uni-collapse">
|
|
3
2
|
<slot />
|
|
4
3
|
</view>
|
|
5
4
|
* Collapse 折叠面板
|
|
6
5
|
* @description 展示可以折叠 / 展开的内容区域
|
|
7
6
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=23
|
|
8
7
|
* @property {String|Array} value 当前激活面板改变时触发(如果是手风琴模式,参数类型为string,否则为array)
|
|
9
8
|
* @property {Boolean} accordion = [true|false] 是否开启手风琴效果是否开启手风琴效果
|
|
10
9
|
* @event {Function} change 切换面板时触发,如果是手风琴模式,返回类型为string,否则为array
|
|
11
10
|
*/
|
|
12
11
|
name: 'uniCollapse',
|
|
13
12
|
emits: ['change', 'activeItem', 'input', 'update:modelValue'],
|
|
14
13
|
props: {
|
|
15
14
|
value: {
|
|
16
15
|
type: [String, Array],
|
|
17
16
|
default: ''
|
|
18
17
|
},
|
|
19
18
|
modelValue: {
|
|
20
19
|
type: [String, Array],
|
|
21
20
|
default: ''
|
|
22
21
|
},
|
|
23
22
|
accordion: {
|
|
24
23
|
// 是否开启手风琴效果
|
|
25
24
|
type: [Boolean, String],
|
|
26
25
|
default: false
|
|
27
26
|
}
|
|
28
27
|
},
|
|
29
28
|
data() {
|
|
30
29
|
return {};
|
|
31
30
|
},
|
|
32
31
|
computed: {
|
|
33
32
|
// TODO 兼容 vue2 和 vue3
|
|
34
33
|
dataValue() {
|
|
35
34
|
let value = (typeof this.value === 'string' && this.value === '') || (Array.isArray(this.value) && this.value.length === 0);
|
|
36
35
|
let modelValue =
|
|
37
36
|
(typeof this.modelValue === 'string' && this.modelValue === '') ||
|
|
38
37
|
(Array.isArray(this.modelValue) && this.modelValue.length === 0);
|
|
39
38
|
if (value) {
|
|
40
39
|
return this.modelValue;
|
|
41
40
|
}
|
|
42
41
|
if (modelValue) {
|
|
43
42
|
return this.value;
|
|
44
43
|
}
|
|
45
44
|
return this.value;
|
|
46
45
|
}
|
|
47
46
|
},
|
|
48
47
|
watch: {
|
|
49
48
|
dataValue(val) {
|
|
50
49
|
this.setOpen(val);
|
|
51
50
|
}
|
|
52
51
|
},
|
|
53
52
|
created() {
|
|
54
53
|
this.childrens = [];
|
|
55
54
|
this.names = [];
|
|
56
55
|
},
|
|
57
56
|
mounted() {
|
|
58
57
|
this.$nextTick(() => {
|
|
59
58
|
this.setOpen(this.dataValue);
|
|
60
59
|
});
|
|
61
60
|
},
|
|
62
61
|
methods: {
|
|
63
62
|
setOpen(val) {
|
|
64
63
|
let str = typeof val === 'string';
|
|
65
64
|
let arr = Array.isArray(val);
|
|
66
65
|
this.childrens.forEach((vm, index) => {
|
|
67
66
|
if (str) {
|
|
68
67
|
if (val === vm.nameSync) {
|
|
69
68
|
if (!this.accordion) {
|
|
70
69
|
console.warn('accordion 属性为 false ,v-model 类型应该为 array');
|
|
71
70
|
return;
|
|
72
71
|
}
|
|
73
72
|
vm.isOpen = true;
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
if (arr) {
|
|
77
76
|
val.forEach((v) => {
|
|
78
77
|
if (v === vm.nameSync) {
|
|
79
78
|
if (this.accordion) {
|
|
80
79
|
console.warn('accordion 属性为 true ,v-model 类型应该为 string');
|
|
81
80
|
return;
|
|
82
81
|
}
|
|
83
82
|
vm.isOpen = true;
|
|
84
83
|
}
|
|
85
84
|
});
|
|
86
85
|
}
|
|
87
86
|
});
|
|
88
87
|
this.emit(val);
|
|
89
88
|
},
|
|
90
89
|
setAccordion(self) {
|
|
91
90
|
if (!this.accordion) return;
|
|
92
91
|
this.childrens.forEach((vm, index) => {
|
|
93
92
|
if (self !== vm) {
|
|
94
93
|
vm.isOpen = false;
|
|
95
94
|
}
|
|
96
95
|
});
|
|
97
96
|
},
|
|
98
97
|
resize() {
|
|
99
98
|
this.childrens.forEach((vm, index) => {
|
|
100
99
|
// #ifndef APP-NVUE
|
|
101
100
|
vm.getCollapseHeight();
|
|
102
101
|
// #endif
|
|
103
102
|
// #ifdef APP-NVUE
|
|
104
103
|
vm.getNvueHwight();
|
|
105
104
|
// #endif
|
|
106
105
|
});
|
|
107
106
|
},
|
|
108
107
|
onChange(isOpen, self) {
|
|
109
108
|
let activeItem = [];
|
|
110
109
|
if (this.accordion) {
|
|
111
110
|
activeItem = isOpen ? self.nameSync : '';
|
|
112
111
|
} else {
|
|
113
112
|
this.childrens.forEach((vm, index) => {
|
|
114
113
|
if (vm.isOpen) {
|
|
115
114
|
activeItem.push(vm.nameSync);
|
|
116
115
|
}
|
|
117
116
|
});
|
|
118
117
|
}
|
|
119
118
|
this.$emit('change', activeItem);
|
|
120
119
|
this.emit(activeItem);
|
|
121
120
|
},
|
|
122
121
|
emit(val) {
|
|
123
122
|
this.$emit('input', val);
|
|
124
123
|
this.$emit('update:modelValue', val);
|
|
125
124
|
}
|
|
126
125
|
}
|
|
126
|
+
<template>
|
|
127
|
+
<view class="uni-collapse">
|
|
128
|
+
<slot />
|
|
129
|
+
</view>
|
|
130
|
+
</template>
|
|
131
|
+
<script>
|
|
132
|
+
/**
|
|
133
|
+
* Collapse 折叠面板
|
|
134
|
+
* @description 展示可以折叠 / 展开的内容区域
|
|
135
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=23
|
|
136
|
+
* @property {String|Array} value 当前激活面板改变时触发(如果是手风琴模式,参数类型为string,否则为array)
|
|
137
|
+
* @property {Boolean} accordion = [true|false] 是否开启手风琴效果是否开启手风琴效果
|
|
138
|
+
* @event {Function} change 切换面板时触发,如果是手风琴模式,返回类型为string,否则为array
|
|
139
|
+
*/
|
|
140
|
+
export default {
|
|
141
|
+
name: 'uniCollapse',
|
|
142
|
+
emits: ['change', 'activeItem', 'input', 'update:modelValue'],
|
|
143
|
+
props: {
|
|
144
|
+
value: {
|
|
145
|
+
type: [String, Array],
|
|
146
|
+
default: ''
|
|
147
|
+
},
|
|
148
|
+
modelValue: {
|
|
149
|
+
type: [String, Array],
|
|
150
|
+
default: ''
|
|
151
|
+
},
|
|
152
|
+
accordion: {
|
|
153
|
+
// 是否开启手风琴效果
|
|
154
|
+
type: [Boolean, String],
|
|
155
|
+
default: false
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
data() {
|
|
159
|
+
return {};
|
|
160
|
+
},
|
|
161
|
+
computed: {
|
|
162
|
+
// TODO 兼容 vue2 和 vue3
|
|
163
|
+
dataValue() {
|
|
164
|
+
let value = (typeof this.value === 'string' && this.value === '') || (Array.isArray(this.value) && this.value.length === 0);
|
|
165
|
+
let modelValue =
|
|
166
|
+
(typeof this.modelValue === 'string' && this.modelValue === '') ||
|
|
167
|
+
(Array.isArray(this.modelValue) && this.modelValue.length === 0);
|
|
168
|
+
if (value) {
|
|
169
|
+
return this.modelValue;
|
|
170
|
+
}
|
|
171
|
+
if (modelValue) {
|
|
172
|
+
return this.value;
|
|
173
|
+
}
|
|
174
|
+
return this.value;
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
watch: {
|
|
178
|
+
dataValue(val) {
|
|
179
|
+
this.setOpen(val);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
created() {
|
|
183
|
+
this.childrens = [];
|
|
184
|
+
this.names = [];
|
|
185
|
+
},
|
|
186
|
+
mounted() {
|
|
187
|
+
this.$nextTick(() => {
|
|
188
|
+
this.setOpen(this.dataValue);
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
methods: {
|
|
192
|
+
setOpen(val) {
|
|
193
|
+
let str = typeof val === 'string';
|
|
194
|
+
let arr = Array.isArray(val);
|
|
195
|
+
this.childrens.forEach((vm, index) => {
|
|
196
|
+
if (str) {
|
|
197
|
+
if (val === vm.nameSync) {
|
|
198
|
+
if (!this.accordion) {
|
|
199
|
+
console.warn('accordion 属性为 false ,v-model 类型应该为 array');
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
vm.isOpen = true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (arr) {
|
|
206
|
+
val.forEach((v) => {
|
|
207
|
+
if (v === vm.nameSync) {
|
|
208
|
+
if (this.accordion) {
|
|
209
|
+
console.warn('accordion 属性为 true ,v-model 类型应该为 string');
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
vm.isOpen = true;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
this.emit(val);
|
|
218
|
+
},
|
|
219
|
+
setAccordion(self) {
|
|
220
|
+
if (!this.accordion) return;
|
|
221
|
+
this.childrens.forEach((vm, index) => {
|
|
222
|
+
if (self !== vm) {
|
|
223
|
+
vm.isOpen = false;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
resize() {
|
|
228
|
+
this.childrens.forEach((vm, index) => {
|
|
229
|
+
// #ifndef APP-NVUE
|
|
230
|
+
vm.getCollapseHeight();
|
|
231
|
+
// #endif
|
|
232
|
+
// #ifdef APP-NVUE
|
|
233
|
+
vm.getNvueHwight();
|
|
234
|
+
// #endif
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
onChange(isOpen, self) {
|
|
238
|
+
let activeItem = [];
|
|
239
|
+
if (this.accordion) {
|
|
240
|
+
activeItem = isOpen ? self.nameSync : '';
|
|
241
|
+
} else {
|
|
242
|
+
this.childrens.forEach((vm, index) => {
|
|
243
|
+
if (vm.isOpen) {
|
|
244
|
+
activeItem.push(vm.nameSync);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
this.$emit('change', activeItem);
|
|
249
|
+
this.emit(activeItem);
|
|
250
|
+
},
|
|
251
|
+
emit(val) {
|
|
252
|
+
this.$emit('input', val);
|
|
253
|
+
this.$emit('update:modelValue', val);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
</script>
|
|
258
|
+
<style>
|
|
259
|
+
@import 'style.css';
|
|
260
|
+
</style>
|