sadais-piui 1.1.1 → 1.2.2-beta1
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 +482 -240
- package/README.md +2 -3
- package/components/pi-bottom-bar/index.vue +15 -2
- package/components/pi-canvas/index.vue +400 -0
- package/components/pi-circle-progress/index.vue +196 -173
- package/components/pi-count-up/index.vue +209 -0
- package/components/pi-dropdown/components/dropdown-tab.vue +62 -0
- package/components/pi-dropdown/index.vue +155 -149
- package/components/pi-dropdown-item/index.vue +169 -41
- package/components/pi-form-item/index.vue +13 -1
- package/components/pi-img/index.vue +1 -0
- package/components/pi-img-cropper/canvas.js +2 -2
- package/components/pi-img-cropper/index.vue +34 -16
- package/components/pi-img-cropper/touch.js +5 -3
- package/components/pi-input/index.vue +9 -2
- package/components/pi-notify/index.vue +133 -49
- package/components/pi-popup/index.vue +1 -3
- package/components/pi-radio/index.vue +1 -1
- package/components/pi-select/index.vue +16 -6
- package/components/pi-steps/index.vue +153 -97
- package/components/pi-switch/index.vue +2 -3
- package/components/pi-tabs/index.vue +1 -2
- package/components/pi-upload-img/index.vue +144 -39
- package/config/bottomBar.js +1 -0
- package/config/checkbox.js +1 -1
- package/config/circleProgress.js +13 -0
- package/config/countUp.js +13 -0
- package/config/dropdown.js +17 -8
- package/config/dropdownItem.js +23 -5
- package/config/form.js +3 -3
- package/config/imgCropper.js +7 -1
- package/config/notify.js +6 -2
- package/config/steps.js +11 -7
- package/config/{upload-img.js → uploadImg.js} +5 -1
- package/index.js +2 -2
- package/package.json +3 -3
- package/scss/common.scss +4 -0
- package/scss/variable.scss +1 -1
|
@@ -1,83 +1,36 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="pi-dropdown pi-rela pi-w-100P">
|
|
3
|
-
<view
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
borderRadius: show
|
|
11
|
-
? `${customStyle.borderRadius} ${customStyle.borderRadius} 0 0`
|
|
12
|
-
: customStyle.borderRadius
|
|
13
|
-
}
|
|
14
|
-
]"
|
|
15
|
-
>
|
|
16
|
-
<!-- tabs从dropdownItem中获取其name的值 -->
|
|
17
|
-
<scroll-view
|
|
18
|
-
class="pi-srcoll pi-w-100P pi-h-100P"
|
|
19
|
-
scroll-x
|
|
20
|
-
:scroll-left="scrollLeft"
|
|
21
|
-
scroll-with-animation
|
|
22
|
-
>
|
|
23
|
-
<view class="pi-align-center pi-h-100P">
|
|
24
|
-
<view
|
|
25
|
-
v-for="(item, index) in tabs"
|
|
26
|
-
:key="item._uid"
|
|
27
|
-
class="pi-dropdown-tab-item pi-pd-lr-20 pi-text-nowrap pi-h-100P pi-align-center"
|
|
28
|
-
:style="[{ color: show && item._uid === currentId ? activeColor : '' }]"
|
|
29
|
-
@tap="handleClickTab(item, index)"
|
|
30
|
-
>
|
|
31
|
-
<!-- todo 当前项存在value中高亮选项 目前还有问题,当插槽位置在中间时可能有问题 -->
|
|
32
|
-
<pi-icon
|
|
33
|
-
v-if="item.icon"
|
|
34
|
-
class="pi-mg-right-6"
|
|
35
|
-
:color="item.selected ? activeColor : ''"
|
|
36
|
-
:name="item.icon"
|
|
37
|
-
size="36"
|
|
38
|
-
/>
|
|
39
|
-
<text
|
|
40
|
-
class="pi-pd-right-8 pi-fz-28"
|
|
41
|
-
:style="{ color: item.selected ? activeColor : '' }"
|
|
42
|
-
>
|
|
43
|
-
{{ item.name }}
|
|
44
|
-
</text>
|
|
45
|
-
<pi-icon :class="{ rotate: show && item._uid === currentId }" name="unfold" size="16" />
|
|
46
|
-
</view>
|
|
47
|
-
</view>
|
|
48
|
-
</scroll-view>
|
|
49
|
-
<!-- 展示dropdownItem下的数据 -->
|
|
50
|
-
<view
|
|
51
|
-
v-show="show"
|
|
52
|
-
:class="[contentClass]"
|
|
53
|
-
:style="[
|
|
54
|
-
{ top: customStyle.height, left: 0, background: '#fff' },
|
|
55
|
-
contentStyle,
|
|
56
|
-
{
|
|
57
|
-
borderRadius: show
|
|
58
|
-
? `0 0 ${contentStyle.borderRadius} ${contentStyle.borderRadius}`
|
|
59
|
-
: contentStyle.borderRadius
|
|
60
|
-
}
|
|
61
|
-
]"
|
|
62
|
-
class="pi-abso pi-w-100P"
|
|
2
|
+
<view class="pi-dropdown pi-rela pi-w-100P" :class="[customClass]" :style="[customStyle]">
|
|
3
|
+
<view>
|
|
4
|
+
<pi-tabs
|
|
5
|
+
:value="activeItem"
|
|
6
|
+
:items="tabs"
|
|
7
|
+
:show-slider-bar="false"
|
|
8
|
+
show-item-split-line
|
|
9
|
+
active-text-color="inherit"
|
|
63
10
|
>
|
|
64
|
-
<view
|
|
65
|
-
|
|
11
|
+
<view slot="item" slot-scope="{ item, index }">
|
|
12
|
+
<!-- 注意:slot内不能使用父组件data -->
|
|
13
|
+
<dropdown-tab :item="item" @click="handleClickTab(item, index)" />
|
|
66
14
|
</view>
|
|
67
|
-
</
|
|
15
|
+
</pi-tabs>
|
|
16
|
+
</view>
|
|
17
|
+
<!-- 展示dropdownItem下的数据 -->
|
|
18
|
+
<view
|
|
19
|
+
class="pi-dropdown-content pi-mg-top-12"
|
|
20
|
+
:class="[contentClass, show ? 'pi-ani-slide-top-show' : 'pi-ani-slide-top-hide']"
|
|
21
|
+
:style="[contentStyle, contentCombinationStyle]"
|
|
22
|
+
>
|
|
23
|
+
<slot />
|
|
68
24
|
</view>
|
|
69
25
|
|
|
70
26
|
<!-- 遮罩层 -->
|
|
71
27
|
<view
|
|
72
28
|
v-if="!closed"
|
|
73
|
-
class="pi-
|
|
74
|
-
:class="[
|
|
75
|
-
show ? getMask.animationShow : getMask.animationHide,
|
|
76
|
-
getMask.hideTabBar ? 'include-tabbar' : 'exclude-tabbar'
|
|
77
|
-
]"
|
|
29
|
+
class="pi-abso pi-dropdown-mask"
|
|
30
|
+
:class="[show ? getMask.animationShow : getMask.animationHide]"
|
|
78
31
|
:style="[
|
|
79
32
|
{
|
|
80
|
-
'
|
|
33
|
+
'z-index': getMask.zIndex,
|
|
81
34
|
'background': getMask.background,
|
|
82
35
|
'animation-duration': getDuration.css
|
|
83
36
|
}
|
|
@@ -93,13 +46,27 @@ import ValueSync from '../../mixin/value-sync'
|
|
|
93
46
|
import { parentInit } from '../../mixin/props-sync'
|
|
94
47
|
import { getConfig } from '../../config'
|
|
95
48
|
import { parseDuration } from '@sadais/piui-tool/tools/common'
|
|
49
|
+
import DropdownTab from './components/dropdown-tab.vue'
|
|
96
50
|
|
|
97
51
|
const TAG = 'PiDropdown'
|
|
98
52
|
const { dropdown } = getConfig()
|
|
99
53
|
|
|
100
54
|
export default {
|
|
101
|
-
name:
|
|
102
|
-
|
|
55
|
+
name: 'PiDropdown',
|
|
56
|
+
components: {
|
|
57
|
+
DropdownTab
|
|
58
|
+
},
|
|
59
|
+
mixins: [
|
|
60
|
+
ValueSync,
|
|
61
|
+
parentInit([
|
|
62
|
+
'itemHeight',
|
|
63
|
+
'keyField',
|
|
64
|
+
'displayField',
|
|
65
|
+
'disabledField',
|
|
66
|
+
'selectedImg',
|
|
67
|
+
'selectedCheckbox'
|
|
68
|
+
])
|
|
69
|
+
], // 注入value与val,进行双向绑定
|
|
103
70
|
props: {
|
|
104
71
|
// 初始值
|
|
105
72
|
value: {
|
|
@@ -155,48 +122,76 @@ export default {
|
|
|
155
122
|
// ''
|
|
156
123
|
return dropdown.activeColor
|
|
157
124
|
}
|
|
125
|
+
},
|
|
126
|
+
// -------------以下属性为子组件pi-dropdown-item继承用--------------
|
|
127
|
+
// 行高 值为数字,则单位默认rpx
|
|
128
|
+
itemHeight: {
|
|
129
|
+
type: [String, Number],
|
|
130
|
+
// 110
|
|
131
|
+
default: dropdown.itemHeight
|
|
132
|
+
},
|
|
133
|
+
// 选项id字段
|
|
134
|
+
keyField: {
|
|
135
|
+
type: String,
|
|
136
|
+
// `id`
|
|
137
|
+
default: dropdown.keyField
|
|
138
|
+
},
|
|
139
|
+
// 选项显示字段
|
|
140
|
+
displayField: {
|
|
141
|
+
type: String,
|
|
142
|
+
// `text`
|
|
143
|
+
default: dropdown.displayField
|
|
144
|
+
},
|
|
145
|
+
// 选项禁用字段,默认为disabled
|
|
146
|
+
disabledField: {
|
|
147
|
+
type: String,
|
|
148
|
+
// `text`
|
|
149
|
+
default: dropdown.disabledField
|
|
150
|
+
},
|
|
151
|
+
// 选中图标的配置
|
|
152
|
+
selectedImg: {
|
|
153
|
+
type: Object,
|
|
154
|
+
default() {
|
|
155
|
+
// 参照img
|
|
156
|
+
return dropdown.selectedImg
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
// 选中checkbox配置
|
|
160
|
+
selectedCheckbox: {
|
|
161
|
+
type: Object,
|
|
162
|
+
default() {
|
|
163
|
+
// 参照checkbox
|
|
164
|
+
return dropdown.selectedCheckbox
|
|
165
|
+
}
|
|
158
166
|
}
|
|
159
167
|
},
|
|
160
168
|
data() {
|
|
161
169
|
return {
|
|
170
|
+
containerRect: { left: 0, right: 0, top: 0 }, // 容器的位置
|
|
171
|
+
|
|
162
172
|
tabs: [], // 下拉菜单
|
|
163
|
-
|
|
173
|
+
activeItem: {}, // 当前选中项
|
|
164
174
|
|
|
165
175
|
show: false, // 是否显示节点
|
|
166
176
|
showed: false, // 是否显示动画执行完毕
|
|
167
|
-
closed: true
|
|
168
|
-
|
|
169
|
-
// 位置计算
|
|
170
|
-
tabsWidth: 0, // 组件区域宽度
|
|
171
|
-
tabRects: [], // 标签节点信息
|
|
172
|
-
activeIndex: 0 // 当前选中项
|
|
177
|
+
closed: true // 是否已关闭(用来防止val为false的情况,动画无法执行)
|
|
173
178
|
}
|
|
174
179
|
},
|
|
175
180
|
computed: {
|
|
181
|
+
contentCombinationStyle() {
|
|
182
|
+
const { containerRect, closed } = this
|
|
183
|
+
return {
|
|
184
|
+
top: `${containerRect.height}px`,
|
|
185
|
+
left: 0,
|
|
186
|
+
width: `${containerRect.width}px`,
|
|
187
|
+
zIndex: !closed ? 101 : -1
|
|
188
|
+
}
|
|
189
|
+
},
|
|
176
190
|
getMask() {
|
|
177
191
|
return this.$pi.lang.mergeDeep(dropdown.mask, this.mask)
|
|
178
192
|
},
|
|
179
193
|
getDuration() {
|
|
180
194
|
return parseDuration(this.getMask.duration, dropdown.mask.duration)
|
|
181
|
-
},
|
|
182
|
-
activeRect() {
|
|
183
|
-
const rect = {
|
|
184
|
-
left: 0,
|
|
185
|
-
width: 0
|
|
186
|
-
}
|
|
187
|
-
if (!this.tabRects.length) return rect
|
|
188
|
-
const activeIndex =
|
|
189
|
-
this.activeIndex >= this.tabRects.length ? this.tabRects.length - 1 : this.activeIndex
|
|
190
|
-
rect.left = this.tabRects.slice(0, activeIndex).reduce((previous, current) => {
|
|
191
|
-
return previous + current.width
|
|
192
|
-
}, 0)
|
|
193
|
-
rect.width = this.tabRects[activeIndex].width
|
|
194
|
-
return rect
|
|
195
|
-
},
|
|
196
|
-
scrollLeft() {
|
|
197
|
-
// 计算当前激活item移动到容器中心距离左边距离
|
|
198
|
-
const scrollLeft = this.activeRect.left - this.tabsWidth / 2 + this.activeRect.width / 2
|
|
199
|
-
return scrollLeft < 0 ? 0 : scrollLeft
|
|
200
195
|
}
|
|
201
196
|
},
|
|
202
197
|
watch: {
|
|
@@ -210,47 +205,63 @@ export default {
|
|
|
210
205
|
},
|
|
211
206
|
mounted() {
|
|
212
207
|
this.init()
|
|
213
|
-
this.tabsInit()
|
|
214
208
|
},
|
|
215
209
|
methods: {
|
|
216
|
-
async tabsInit() {
|
|
217
|
-
const srollWrapRect = await this.$pi.common.queryRect(this, '.pi-dropdown', false)
|
|
218
|
-
if (srollWrapRect) {
|
|
219
|
-
this.tabsWidth = srollWrapRect.width
|
|
220
|
-
}
|
|
221
|
-
this.tabRects = await this.$pi.common.queryRect(this, '.pi-dropdown-tab-item', true)
|
|
222
|
-
},
|
|
223
210
|
init() {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
})
|
|
228
|
-
// 定义新的对象数组渲染界面
|
|
211
|
+
console.log(TAG, 'init')
|
|
212
|
+
let hasValueChange = false
|
|
213
|
+
const val = this.$pi.lang.cloneDeep(this.val)
|
|
229
214
|
this.tabs = this._children.map((item, index) => {
|
|
230
|
-
|
|
231
|
-
|
|
215
|
+
if (this.val[index] === undefined) {
|
|
216
|
+
this.val[index] = ''
|
|
217
|
+
}
|
|
218
|
+
// 同步父子组件的值
|
|
219
|
+
if (this.val[index] !== item.val) {
|
|
220
|
+
console.log(TAG, 'Dropdown和DropdownItem绑定值不一致,即将同步')
|
|
221
|
+
if (item.val) {
|
|
222
|
+
// 以子组件的值为准
|
|
223
|
+
hasValueChange = true
|
|
224
|
+
val[index] = item.val
|
|
225
|
+
} else if (this.val[index]) {
|
|
226
|
+
item.emitChange(this.val[index])
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const currentOption = item.options?.find(opt => opt[item.getKeyField] === this.val[index])
|
|
232
230
|
const newItem = {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
231
|
+
showIcon: item.showIcon,
|
|
232
|
+
iconOption: item.getIconOption,
|
|
233
|
+
id: item._uid,
|
|
234
|
+
text: currentOption ? currentOption[item.getDisplayField] : item.title,
|
|
235
|
+
disabled: item.disabled,
|
|
236
|
+
opened: false,
|
|
237
|
+
activeColor: this.activeColor
|
|
237
238
|
}
|
|
238
239
|
return newItem
|
|
239
240
|
})
|
|
241
|
+
if (hasValueChange) {
|
|
242
|
+
this.val = val
|
|
243
|
+
this.handleEmitChange()
|
|
244
|
+
}
|
|
240
245
|
},
|
|
241
246
|
// 显示当前Tab
|
|
242
|
-
handleClickTab(item
|
|
243
|
-
|
|
247
|
+
async handleClickTab(item) {
|
|
248
|
+
if (item.disabled) return
|
|
249
|
+
// 更新打开的tab标志
|
|
250
|
+
this.tabs = this.tabs.map(tab => {
|
|
251
|
+
tab.opened = tab.id === item.id
|
|
252
|
+
return tab
|
|
253
|
+
})
|
|
254
|
+
this.activeItem = item
|
|
255
|
+
// 每次点击都重新更新父容器的位置
|
|
256
|
+
this.containerRect = await this.$pi.common.queryRect(this, '.pi-dropdown', false)
|
|
244
257
|
this.openMask()
|
|
245
|
-
this.
|
|
246
|
-
|
|
247
|
-
const showTab = child._uid === item._uid
|
|
248
|
-
child.showOption(showTab)
|
|
258
|
+
this._children.find(child => {
|
|
259
|
+
child.show = child._uid === item.id
|
|
249
260
|
})
|
|
250
261
|
},
|
|
251
262
|
openMask() {
|
|
252
263
|
if (this.show) return
|
|
253
|
-
console.log(TAG, '
|
|
264
|
+
console.log(TAG, '显示下拉菜单遮罩层')
|
|
254
265
|
this.closed = false
|
|
255
266
|
this.show = true
|
|
256
267
|
this.showed = false
|
|
@@ -262,23 +273,27 @@ export default {
|
|
|
262
273
|
// 仅关闭窗口,不作数据操作
|
|
263
274
|
closeMask() {
|
|
264
275
|
if (!this.show || !this.showed) return
|
|
265
|
-
console.log(TAG, '
|
|
276
|
+
console.log(TAG, '隐藏下拉菜单遮罩层')
|
|
266
277
|
this.show = false
|
|
267
278
|
this.showed = false
|
|
279
|
+
this.tabs = this.tabs.map(tab => {
|
|
280
|
+
tab.opened = false
|
|
281
|
+
return tab
|
|
282
|
+
})
|
|
268
283
|
setTimeout(() => {
|
|
269
284
|
this.closed = true
|
|
270
285
|
this.getMask.hideTabBar && uni.showTabBar()
|
|
271
286
|
}, this.getDuration.js)
|
|
272
287
|
},
|
|
273
288
|
// 关闭弹窗并返回结果
|
|
274
|
-
|
|
289
|
+
submit() {
|
|
275
290
|
this.closeMask()
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
submitVal.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
291
|
+
setTimeout(() => {
|
|
292
|
+
// 延迟执行,防止父子组件的值同步不上
|
|
293
|
+
const submitVal = this._children.map(item => item.val)
|
|
294
|
+
this.val = submitVal // 把最终结果传给绑定的v-model值
|
|
295
|
+
this.handleEmitChange()
|
|
296
|
+
}, 20)
|
|
282
297
|
}
|
|
283
298
|
}
|
|
284
299
|
}
|
|
@@ -286,25 +301,16 @@ export default {
|
|
|
286
301
|
|
|
287
302
|
<style lang="scss" scoped>
|
|
288
303
|
.pi-dropdown {
|
|
289
|
-
z-index: 2;
|
|
290
304
|
.pi-dropdown-content {
|
|
291
|
-
|
|
292
|
-
|
|
305
|
+
position: absolute;
|
|
306
|
+
background: #ffffff;
|
|
307
|
+
border-radius: 12rpx;
|
|
293
308
|
}
|
|
294
|
-
.pi-dropdown-
|
|
295
|
-
|
|
309
|
+
.pi-dropdown-mask {
|
|
310
|
+
top: -9999px;
|
|
311
|
+
left: -9999px;
|
|
312
|
+
right: -9999px;
|
|
313
|
+
bottom: -9999px;
|
|
296
314
|
}
|
|
297
|
-
.current {
|
|
298
|
-
color: #ff9900;
|
|
299
|
-
}
|
|
300
|
-
.rotate {
|
|
301
|
-
transform: rotate(180deg);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
.pi-dropdown-mask {
|
|
305
|
-
top: 0;
|
|
306
|
-
left: 0;
|
|
307
|
-
width: 100%;
|
|
308
|
-
height: 100%;
|
|
309
315
|
}
|
|
310
316
|
</style>
|
|
@@ -1,18 +1,56 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view v-if="show" class="pi-dropdown-item pi-
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
<scroll-view v-if="show" scroll-y class="pi-dropdown-item pi-w-100P">
|
|
3
|
+
<slot>
|
|
4
|
+
<view
|
|
5
|
+
v-for="item in options"
|
|
6
|
+
:key="item[getKeyField]"
|
|
7
|
+
class="item-wrap pi-pd-tb-24 pi-pd-lr-32 pi-w-100P pi-justify-between pi-align-center"
|
|
8
|
+
:class="[customClass, item[getDisabledField] ? 'disabled' : '']"
|
|
9
|
+
:style="[customStyle, getItemStyle]"
|
|
10
|
+
@tap="handleSelectItem(item)"
|
|
11
|
+
>
|
|
12
|
+
<view>
|
|
13
|
+
{{ item[getDisplayField] }}
|
|
14
|
+
</view>
|
|
15
|
+
<!-- 如果配置了图片地址,使用图片 -->
|
|
16
|
+
<pi-img
|
|
17
|
+
v-if="getSelectedImg.src && item.id === val"
|
|
18
|
+
:src="getSelectedImg.src"
|
|
19
|
+
:mode="getSelectedImg.mode"
|
|
20
|
+
:width="getSelectedImg.width"
|
|
21
|
+
:height="getSelectedImg.height"
|
|
22
|
+
:dot="getSelectedImg.dot"
|
|
23
|
+
:dot-radius="getSelectedImg.dotRadius"
|
|
24
|
+
:badge="getSelectedImg.badge"
|
|
25
|
+
:shape="getSelectedImg.shape"
|
|
26
|
+
:border-radius="getSelectedImg.borderRadius"
|
|
27
|
+
:show-loading="getSelectedImg.showLoading"
|
|
28
|
+
:loading-color="getSelectedImg.loadingColor"
|
|
29
|
+
:loading-type="getSelectedImg.loadingType"
|
|
30
|
+
:loading-size="getSelectedImg.loadingSize"
|
|
31
|
+
:show-error="getSelectedImg.showError"
|
|
32
|
+
:webp="getSelectedImg.webp"
|
|
33
|
+
custom-class="pi-mg-left-24"
|
|
34
|
+
/>
|
|
35
|
+
<!-- 默认使用复选框 -->
|
|
36
|
+
<pi-checkbox
|
|
37
|
+
v-if="!getSelectedImg.src"
|
|
38
|
+
readonly
|
|
39
|
+
:value="item.id === val"
|
|
40
|
+
:name="getSelectedCheckbox.name"
|
|
41
|
+
:shape="getSelectedCheckbox.shape"
|
|
42
|
+
:border-radius="getSelectedCheckbox.borderRadius"
|
|
43
|
+
:border="getSelectedCheckbox.border"
|
|
44
|
+
:disabled="getSelectedCheckbox.disabled"
|
|
45
|
+
:size="getSelectedCheckbox.size"
|
|
46
|
+
:icon-size="getSelectedCheckbox.iconSize"
|
|
47
|
+
:active-color="getSelectedCheckbox.activeColor"
|
|
48
|
+
:active-mode="getSelectedCheckbox.activeMode"
|
|
49
|
+
custom-class="pi-mg-left-24"
|
|
50
|
+
/>
|
|
51
|
+
</view>
|
|
52
|
+
</slot>
|
|
53
|
+
</scroll-view>
|
|
16
54
|
</template>
|
|
17
55
|
|
|
18
56
|
<script>
|
|
@@ -20,13 +58,12 @@ import ValueSync from '../../mixin/value-sync'
|
|
|
20
58
|
import { childInit } from '../../mixin/props-sync'
|
|
21
59
|
import { getConfig } from '../../config'
|
|
22
60
|
|
|
23
|
-
const TAG = 'PiDropdownItem'
|
|
24
61
|
const { dropdownItem } = getConfig()
|
|
25
|
-
const
|
|
62
|
+
const extendPiDropDown = childInit('PiDropdown')
|
|
26
63
|
|
|
27
64
|
export default {
|
|
28
|
-
name:
|
|
29
|
-
mixins: [ValueSync,
|
|
65
|
+
name: 'PiDropdownItem',
|
|
66
|
+
mixins: [ValueSync, extendPiDropDown], // 注入value与val,进行双向绑定、混入自定义样式customStyle和customClass
|
|
30
67
|
props: {
|
|
31
68
|
// 初始值
|
|
32
69
|
value: {
|
|
@@ -48,57 +85,148 @@ export default {
|
|
|
48
85
|
return dropdownItem.customClass
|
|
49
86
|
}
|
|
50
87
|
},
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
type:
|
|
54
|
-
default:
|
|
88
|
+
// 是否显示菜单
|
|
89
|
+
showIcon: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: dropdownItem.showIcon
|
|
92
|
+
},
|
|
93
|
+
// 菜单图标配置
|
|
94
|
+
iconOption: {
|
|
95
|
+
type: Object,
|
|
96
|
+
default() {
|
|
97
|
+
return dropdownItem.iconOption
|
|
98
|
+
}
|
|
55
99
|
},
|
|
56
|
-
//
|
|
57
|
-
|
|
100
|
+
// 菜单标题
|
|
101
|
+
title: {
|
|
58
102
|
type: String,
|
|
59
|
-
default:
|
|
103
|
+
default: dropdownItem.title
|
|
104
|
+
},
|
|
105
|
+
// 是否禁用
|
|
106
|
+
disabled: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
default: dropdownItem.disabled
|
|
60
109
|
},
|
|
61
110
|
// 选项列表,默认
|
|
62
|
-
|
|
111
|
+
options: {
|
|
63
112
|
type: Array,
|
|
64
113
|
default() {
|
|
65
|
-
return dropdownItem.
|
|
114
|
+
return dropdownItem.options
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
// 行高 值为数字,则单位默认rpx
|
|
118
|
+
itemHeight: {
|
|
119
|
+
type: [String, Number],
|
|
120
|
+
// 110
|
|
121
|
+
default: dropdownItem.itemHeight
|
|
122
|
+
},
|
|
123
|
+
// 选项id字段
|
|
124
|
+
keyField: {
|
|
125
|
+
type: String,
|
|
126
|
+
// `id`
|
|
127
|
+
default: dropdownItem.keyField
|
|
128
|
+
},
|
|
129
|
+
// 选项显示字段
|
|
130
|
+
displayField: {
|
|
131
|
+
type: String,
|
|
132
|
+
// `text`
|
|
133
|
+
default: dropdownItem.displayField
|
|
134
|
+
},
|
|
135
|
+
// 选项禁用字段,默认为disabled
|
|
136
|
+
disabledField: {
|
|
137
|
+
type: String,
|
|
138
|
+
// `text`
|
|
139
|
+
default: dropdownItem.disabledField
|
|
140
|
+
},
|
|
141
|
+
// 选中图标的配置
|
|
142
|
+
selectedImg: {
|
|
143
|
+
type: Object,
|
|
144
|
+
default() {
|
|
145
|
+
// 参照img
|
|
146
|
+
return dropdownItem.selectedImg
|
|
66
147
|
}
|
|
67
148
|
},
|
|
68
|
-
|
|
69
|
-
|
|
149
|
+
// 选中checkbox配置
|
|
150
|
+
selectedCheckbox: {
|
|
151
|
+
type: Object,
|
|
152
|
+
default() {
|
|
153
|
+
// 参照checkbox
|
|
154
|
+
return dropdownItem.selectedCheckbox
|
|
155
|
+
}
|
|
70
156
|
}
|
|
71
157
|
},
|
|
72
158
|
data() {
|
|
73
159
|
return {
|
|
74
|
-
options: this.option,
|
|
75
160
|
show: false // 显示当前Item组件
|
|
76
161
|
}
|
|
77
162
|
},
|
|
78
163
|
computed: {
|
|
79
|
-
|
|
80
|
-
return this.
|
|
164
|
+
getIconOption() {
|
|
165
|
+
return this.$pi.lang.mergeDeep(dropdownItem.iconOption, this.iconOption)
|
|
166
|
+
},
|
|
167
|
+
getItemHeight() {
|
|
168
|
+
return this.inheritProps.itemHeight !== null ? this.inheritProps.itemHeight : this.itemHeight
|
|
169
|
+
},
|
|
170
|
+
getKeyField() {
|
|
171
|
+
return this.inheritProps.keyField !== null ? this.inheritProps.keyField : this.keyField
|
|
172
|
+
},
|
|
173
|
+
getDisplayField() {
|
|
174
|
+
return this.inheritProps.displayField !== null
|
|
175
|
+
? this.inheritProps.displayField
|
|
176
|
+
: this.displayField
|
|
177
|
+
},
|
|
178
|
+
getDisabledField() {
|
|
179
|
+
return this.inheritProps.disabledField !== null
|
|
180
|
+
? this.inheritProps.disabledField
|
|
181
|
+
: this.disabledField
|
|
182
|
+
},
|
|
183
|
+
getSelectedImg() {
|
|
184
|
+
const selectedImg = this.inheritProps.selectedImg || dropdownItem.selectedImg
|
|
185
|
+
return this.$pi.lang.mergeDeep(selectedImg, this.selectedImg)
|
|
186
|
+
},
|
|
187
|
+
getSelectedCheckbox() {
|
|
188
|
+
const selectedCheckbox = this.inheritProps.selectedCheckbox || dropdownItem.selectedCheckbox
|
|
189
|
+
return this.$pi.lang.mergeDeep(selectedCheckbox, this.selectedCheckbox)
|
|
190
|
+
},
|
|
191
|
+
getItemStyle() {
|
|
192
|
+
return {
|
|
193
|
+
height: this.$pi.common.addUnit(this.getItemHeight)
|
|
194
|
+
}
|
|
81
195
|
}
|
|
82
196
|
},
|
|
83
197
|
methods: {
|
|
84
|
-
|
|
85
|
-
this.
|
|
198
|
+
emitChange(val) {
|
|
199
|
+
this.val = val
|
|
200
|
+
this.handleEmitChange()
|
|
86
201
|
},
|
|
87
|
-
|
|
88
|
-
this.
|
|
202
|
+
handleSelectItem(item) {
|
|
203
|
+
if (item[this.getDisabledField]) {
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
this.emitChange(item.id)
|
|
89
207
|
setTimeout(() => {
|
|
90
|
-
this._parent.
|
|
91
|
-
},
|
|
208
|
+
this._parent.submit()
|
|
209
|
+
}, 300) // 延迟 可见按钮点击动画
|
|
92
210
|
}
|
|
93
211
|
}
|
|
94
212
|
}
|
|
95
213
|
</script>
|
|
96
214
|
|
|
97
215
|
<style lang="scss" scoped>
|
|
216
|
+
@import '../../scss/mixin.scss';
|
|
217
|
+
|
|
98
218
|
.pi-dropdown-item {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
219
|
+
max-height: 600rpx;
|
|
220
|
+
.item-wrap {
|
|
221
|
+
&:not(:last-child) {
|
|
222
|
+
@include pi-border;
|
|
223
|
+
&::after {
|
|
224
|
+
border: 0 solid $pi-list-border-color;
|
|
225
|
+
border-bottom-width: $pi-list-border-width;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
&.disabled {
|
|
229
|
+
opacity: $pi-disabled-opacity;
|
|
102
230
|
}
|
|
103
231
|
}
|
|
104
232
|
}
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
<view
|
|
3
3
|
class="pi-form-item"
|
|
4
4
|
:style="[customStyle, itemStyle]"
|
|
5
|
-
:class="[
|
|
5
|
+
:class="[
|
|
6
|
+
{ disabled: getDisabled },
|
|
7
|
+
{ border: getBorder },
|
|
8
|
+
{ 'pi-align-center': !getWrap },
|
|
9
|
+
customClass
|
|
10
|
+
]"
|
|
6
11
|
@tap.stop="handleItemClick"
|
|
7
12
|
>
|
|
8
13
|
<!-- 表单标题 -->
|
|
@@ -263,6 +268,9 @@ export default {
|
|
|
263
268
|
getColon() {
|
|
264
269
|
return this.inheritProps.colon !== null ? this.inheritProps.colon : this.colon
|
|
265
270
|
},
|
|
271
|
+
getDisabled() {
|
|
272
|
+
return this.inheritProps.disabled !== null ? this.inheritProps.disabled : this.disabled
|
|
273
|
+
},
|
|
266
274
|
getLabelAlign() {
|
|
267
275
|
return this.inheritProps.labelAlign !== null ? this.inheritProps.labelAlign : this.labelAlign
|
|
268
276
|
},
|
|
@@ -430,6 +438,10 @@ export default {
|
|
|
430
438
|
.pi-form-item {
|
|
431
439
|
overflow: hidden;
|
|
432
440
|
font-size: $pi-form-size;
|
|
441
|
+
&.disabled {
|
|
442
|
+
pointer-events: none;
|
|
443
|
+
opacity: $pi-disabled-opacity;
|
|
444
|
+
}
|
|
433
445
|
&.border {
|
|
434
446
|
@include pi-border;
|
|
435
447
|
&::after {
|