sadais-piui 1.2.2-beta4 → 1.2.3
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/components/pi-action-sheet/index.vue +247 -0
- package/components/pi-form-item/index.vue +10 -12
- package/components/pi-input/index.vue +1 -1
- package/components/pi-select/index.vue +13 -2
- package/config/actionSheet.js +25 -0
- package/config/select.js +1 -0
- package/package.json +1 -1
- package/scss/common.scss +5 -0
- package/tools/index.js +8 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<pi-popup-select
|
|
3
|
+
:value="val"
|
|
4
|
+
:custom-style="getPopupSelect.customStyle"
|
|
5
|
+
:custom-class="getPopupSelect.customClass"
|
|
6
|
+
:height="getPopupSelect.height"
|
|
7
|
+
:show-title="getPopupSelect.showTitle"
|
|
8
|
+
:title="getPopupSelect.title"
|
|
9
|
+
:title-padding="getPopupSelect.titlePadding"
|
|
10
|
+
:toolbar-position="getPopupSelect.toolbarPosition"
|
|
11
|
+
:on-confirm-close="getPopupSelect.onConfirmClose"
|
|
12
|
+
:on-cancel-close="getPopupSelect.onCancelClose"
|
|
13
|
+
:confirm-btn="getPopupSelect.confirmBtn"
|
|
14
|
+
:cancel-btn="getPopupSelect.cancelBtn"
|
|
15
|
+
:popup="getPopup"
|
|
16
|
+
@close="handlePopupClose"
|
|
17
|
+
@cancel="handleCancel"
|
|
18
|
+
@confirm="handleConfirm"
|
|
19
|
+
>
|
|
20
|
+
<slot name="header" />
|
|
21
|
+
<!-- 描述列 -->
|
|
22
|
+
<view
|
|
23
|
+
v-if="description"
|
|
24
|
+
class="pi-solid-bottom-2 pi-align-center pi-pd-32 pi-light-gray"
|
|
25
|
+
:style="[getItemAlignStyle]"
|
|
26
|
+
>
|
|
27
|
+
{{ description }}
|
|
28
|
+
</view>
|
|
29
|
+
<view
|
|
30
|
+
v-for="item in items"
|
|
31
|
+
:id="`id-${item[keyField]}`"
|
|
32
|
+
:key="item[keyField]"
|
|
33
|
+
:style="[itemStyle, getItemStyle, getItemAlignStyle, { color: item.color }]"
|
|
34
|
+
:class="{
|
|
35
|
+
'pi-solid-bottom-1': showItemBottomBorder,
|
|
36
|
+
'pi-disabled': item.disabled
|
|
37
|
+
}"
|
|
38
|
+
class="pi-align-center pi-fz-30 pi-pd-lr-32"
|
|
39
|
+
hover-class="pi-hover-class"
|
|
40
|
+
@tap.stop="handleSelectItem(item)"
|
|
41
|
+
>
|
|
42
|
+
<!-- 自定义列表项 -->
|
|
43
|
+
<slot name="item" :item="item" class="pi-w-100P">
|
|
44
|
+
<template v-if="!item.loading">
|
|
45
|
+
{{ item[displayField] }}
|
|
46
|
+
</template>
|
|
47
|
+
<pi-loading v-else show />
|
|
48
|
+
</slot>
|
|
49
|
+
</view>
|
|
50
|
+
<!-- 取消action -->
|
|
51
|
+
<template v-if="cancelText">
|
|
52
|
+
<pi-gap height="20" />
|
|
53
|
+
<view
|
|
54
|
+
class="pi-align-center pi-fz-30 pi-pd-32 pi-light-gray"
|
|
55
|
+
hover-class="pi-hover-class"
|
|
56
|
+
:style="[getItemAlignStyle]"
|
|
57
|
+
@tap="handleCancel"
|
|
58
|
+
>
|
|
59
|
+
{{ cancelText }}
|
|
60
|
+
</view>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<slot name="footer" />
|
|
64
|
+
</pi-popup-select>
|
|
65
|
+
</template>
|
|
66
|
+
|
|
67
|
+
<script>
|
|
68
|
+
import ValueSync from '../../mixin/value-sync'
|
|
69
|
+
import { getConfig } from '../../config'
|
|
70
|
+
|
|
71
|
+
const TAG = 'PiActionSheet'
|
|
72
|
+
const { actionSheet } = getConfig()
|
|
73
|
+
|
|
74
|
+
const alignFlexMap = {
|
|
75
|
+
left: 'flex-start',
|
|
76
|
+
center: 'center',
|
|
77
|
+
right: 'flex-end'
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
name: 'PiActionSheet',
|
|
82
|
+
// 混入v-model
|
|
83
|
+
mixins: [ValueSync],
|
|
84
|
+
props: {
|
|
85
|
+
// 初始值
|
|
86
|
+
value: {
|
|
87
|
+
required: false
|
|
88
|
+
},
|
|
89
|
+
// 自定义样式
|
|
90
|
+
customStyle: {
|
|
91
|
+
type: Object,
|
|
92
|
+
// {}
|
|
93
|
+
default() {
|
|
94
|
+
return actionSheet.customStyle
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
// 自定义样式类
|
|
98
|
+
customClass: {
|
|
99
|
+
type: String,
|
|
100
|
+
// ''
|
|
101
|
+
default() {
|
|
102
|
+
return actionSheet.customClass
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
// 选项列表
|
|
106
|
+
items: {
|
|
107
|
+
type: Array,
|
|
108
|
+
// []
|
|
109
|
+
default() {
|
|
110
|
+
return actionSheet.items
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
// 选项id字段
|
|
114
|
+
keyField: {
|
|
115
|
+
type: String,
|
|
116
|
+
// 'id'
|
|
117
|
+
default: actionSheet.keyField
|
|
118
|
+
},
|
|
119
|
+
// 选项显示字段
|
|
120
|
+
displayField: {
|
|
121
|
+
type: String,
|
|
122
|
+
// 'text'
|
|
123
|
+
default: actionSheet.displayField
|
|
124
|
+
},
|
|
125
|
+
// 自定义多列联动模式的children属性名
|
|
126
|
+
childField: {
|
|
127
|
+
type: String,
|
|
128
|
+
// 'children'
|
|
129
|
+
default: actionSheet.childField
|
|
130
|
+
},
|
|
131
|
+
// 行高 单位默认rpx
|
|
132
|
+
itemHeight: {
|
|
133
|
+
type: [String, Number],
|
|
134
|
+
// 110
|
|
135
|
+
default: actionSheet.itemHeight
|
|
136
|
+
},
|
|
137
|
+
// 是否显示item下边框
|
|
138
|
+
showItemBottomBorder: {
|
|
139
|
+
type: Boolean,
|
|
140
|
+
// true
|
|
141
|
+
default: actionSheet.showItemBottomBorder
|
|
142
|
+
},
|
|
143
|
+
// 行样式
|
|
144
|
+
itemStyle: {
|
|
145
|
+
type: Object,
|
|
146
|
+
// {}
|
|
147
|
+
default() {
|
|
148
|
+
return actionSheet.itemStyle
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
itemAlign: {
|
|
152
|
+
type: String,
|
|
153
|
+
// 'center'
|
|
154
|
+
default: actionSheet.itemAlign,
|
|
155
|
+
validator: function(value) {
|
|
156
|
+
return ['left', 'center', 'right'].includes(value)
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
// 弹窗选择参数设置
|
|
160
|
+
popupSelect: {
|
|
161
|
+
type: Object,
|
|
162
|
+
default() {
|
|
163
|
+
// 参照popup
|
|
164
|
+
return actionSheet.popupSelect
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
// 弹窗参数设置
|
|
168
|
+
popup: {
|
|
169
|
+
type: Object,
|
|
170
|
+
default() {
|
|
171
|
+
// 参照popup
|
|
172
|
+
return actionSheet.popup
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
// 选项上方的描述信息,不填则不显示
|
|
176
|
+
description: {
|
|
177
|
+
type: String,
|
|
178
|
+
// ''
|
|
179
|
+
default: actionSheet.description
|
|
180
|
+
},
|
|
181
|
+
// 取消按钮文字,不填则不显示
|
|
182
|
+
cancelText: {
|
|
183
|
+
type: String,
|
|
184
|
+
// ''
|
|
185
|
+
default: actionSheet.cancelText
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
data() {
|
|
189
|
+
return {}
|
|
190
|
+
},
|
|
191
|
+
computed: {
|
|
192
|
+
getPopupSelect() {
|
|
193
|
+
return this.$pi.lang.mergeDeep(actionSheet.popupSelect, this.popupSelect)
|
|
194
|
+
},
|
|
195
|
+
getPopup() {
|
|
196
|
+
const actionSheetPopup = this.$pi.lang.mergeDeep(actionSheet.popup, this.popupSelect.popup)
|
|
197
|
+
return this.$pi.lang.mergeDeep(actionSheetPopup, this.popup)
|
|
198
|
+
},
|
|
199
|
+
getItemAlignStyle() {
|
|
200
|
+
return {
|
|
201
|
+
justifyContent: alignFlexMap[this.itemAlign]
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
getItemStyle() {
|
|
205
|
+
const itemHeight = this.$pi.common.addUnit(this.itemHeight)
|
|
206
|
+
return {
|
|
207
|
+
height: itemHeight,
|
|
208
|
+
lineHeight: itemHeight
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
indicatorStyle() {
|
|
212
|
+
const itemHeight = uni.upx2px(this.itemHeight)
|
|
213
|
+
return `height: ${itemHeight}px;line-height: ${itemHeight}px;`
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
methods: {
|
|
217
|
+
handlePopupClose() {
|
|
218
|
+
this.val = false
|
|
219
|
+
// 弹窗关闭
|
|
220
|
+
this.$emit('close')
|
|
221
|
+
this.handleEmitChange()
|
|
222
|
+
},
|
|
223
|
+
/**
|
|
224
|
+
* @vuese
|
|
225
|
+
* 取消选择
|
|
226
|
+
*/
|
|
227
|
+
handleCancel() {
|
|
228
|
+
this.$emit('cancel')
|
|
229
|
+
this.getPopupSelect.onConfirmClose && this.handlePopupClose()
|
|
230
|
+
},
|
|
231
|
+
/**
|
|
232
|
+
* @vuese
|
|
233
|
+
* 确认选择
|
|
234
|
+
*/
|
|
235
|
+
handleSelectItem(item) {
|
|
236
|
+
if (item.disabled) return
|
|
237
|
+
this.$emit('select', item)
|
|
238
|
+
this.getPopupSelect.onConfirmClose && this.handlePopupClose()
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
</script>
|
|
243
|
+
|
|
244
|
+
<style lang="scss" scoped>
|
|
245
|
+
.pi-action-sheet {
|
|
246
|
+
}
|
|
247
|
+
</style>
|
|
@@ -246,19 +246,17 @@ export default {
|
|
|
246
246
|
},
|
|
247
247
|
computed: {
|
|
248
248
|
getShowRightIcon() {
|
|
249
|
-
return this.inheritProps.showRightIcon
|
|
250
|
-
? this.inheritProps.showRightIcon
|
|
251
|
-
: this.showRightIcon
|
|
249
|
+
return this.$pi.expand.getPropValue(this.inheritProps.showRightIcon, this.showRightIcon)
|
|
252
250
|
},
|
|
253
251
|
getRightIcon() {
|
|
254
252
|
const rightIcon = this.$pi.lang.mergeDeep(this.inheritProps.rightIcon, this.rightIcon)
|
|
255
253
|
return this.$pi.lang.mergeDeep(formItem.rightIcon, rightIcon)
|
|
256
254
|
},
|
|
257
255
|
getBorder() {
|
|
258
|
-
return this.
|
|
256
|
+
return this.$pi.expand.getPropValue(this.inheritProps.border, this.border)
|
|
259
257
|
},
|
|
260
258
|
getWrap() {
|
|
261
|
-
return this.
|
|
259
|
+
return this.$pi.expand.getPropValue(this.inheritProps.wrap, this.wrap)
|
|
262
260
|
},
|
|
263
261
|
getLabelWrapBorder() {
|
|
264
262
|
return this.inheritProps.labelWrapBorder !== null
|
|
@@ -266,26 +264,26 @@ export default {
|
|
|
266
264
|
: this.labelWrapBorder
|
|
267
265
|
},
|
|
268
266
|
getColon() {
|
|
269
|
-
return this.
|
|
267
|
+
return this.$pi.expand.getPropValue(this.inheritProps.colon, this.colon)
|
|
270
268
|
},
|
|
271
269
|
getDisabled() {
|
|
272
|
-
return this.
|
|
270
|
+
return this.$pi.expand.getPropValue(this.inheritProps.disabled, this.disabled)
|
|
273
271
|
},
|
|
274
272
|
getLabelAlign() {
|
|
275
|
-
return this.
|
|
273
|
+
return this.$pi.expand.getPropValue(this.inheritProps.labelAlign, this.labelAlign)
|
|
276
274
|
},
|
|
277
275
|
getInputAlign() {
|
|
278
|
-
return this.
|
|
276
|
+
return this.$pi.expand.getPropValue(this.inheritProps.inputAlign, this.inputAlign)
|
|
279
277
|
},
|
|
280
278
|
getErrorType() {
|
|
281
279
|
return this.inheritProps.errorType
|
|
282
280
|
},
|
|
283
281
|
getPadding() {
|
|
284
|
-
const padding = this.
|
|
282
|
+
const padding = this.$pi.expand.getPropValue(this.inheritProps.padding, this.padding)
|
|
285
283
|
return this.$pi.common.addUnit(padding)
|
|
286
284
|
},
|
|
287
285
|
getHeight() {
|
|
288
|
-
const height = this.
|
|
286
|
+
const height = this.$pi.expand.getPropValue(this.inheritProps.height, this.height)
|
|
289
287
|
return this.$pi.common.addUnit(height)
|
|
290
288
|
},
|
|
291
289
|
itemStyle() {
|
|
@@ -296,7 +294,7 @@ export default {
|
|
|
296
294
|
return style
|
|
297
295
|
},
|
|
298
296
|
getLabelStyle() {
|
|
299
|
-
return this.
|
|
297
|
+
return this.$pi.expand.getPropValue(this.inheritProps.labelStyle, this.labelStyle)
|
|
300
298
|
},
|
|
301
299
|
computedLabelStyle() {
|
|
302
300
|
const style = {}
|
|
@@ -155,6 +155,12 @@ export default {
|
|
|
155
155
|
// true
|
|
156
156
|
default: select.singleCancel
|
|
157
157
|
},
|
|
158
|
+
// 单选模式下,是否直接选中,不需要点击确认按钮
|
|
159
|
+
singleConfirm: {
|
|
160
|
+
type: Boolean,
|
|
161
|
+
// false
|
|
162
|
+
default: select.singleConfirm
|
|
163
|
+
},
|
|
158
164
|
// 行高 值为数字,则单位默认rpx
|
|
159
165
|
itemHeight: {
|
|
160
166
|
type: [String, Number],
|
|
@@ -235,7 +241,11 @@ export default {
|
|
|
235
241
|
return this.$pi.lang.mergeDeep(select.selectedCheckbox, this.selectedCheckbox)
|
|
236
242
|
},
|
|
237
243
|
getPopupSelect() {
|
|
238
|
-
|
|
244
|
+
const popupSelect = this.$pi.lang.mergeDeep(select.popupSelect, this.popupSelect)
|
|
245
|
+
if (!this.singleCancel && this.singleConfirm) {
|
|
246
|
+
popupSelect.toolbarPosition = 'none'
|
|
247
|
+
}
|
|
248
|
+
return popupSelect
|
|
239
249
|
},
|
|
240
250
|
getConfirmBtn() {
|
|
241
251
|
const selectConfirmBtn = this.$pi.lang.mergeDeep(
|
|
@@ -303,6 +313,7 @@ export default {
|
|
|
303
313
|
// 单选
|
|
304
314
|
if (!this.singleCancel) {
|
|
305
315
|
this.selected = item
|
|
316
|
+
this.singleConfirm && this.handleConfirm()
|
|
306
317
|
return
|
|
307
318
|
}
|
|
308
319
|
// 如果单选允许取消,需要判断是否点击了同一个选项
|
|
@@ -351,7 +362,7 @@ export default {
|
|
|
351
362
|
*/
|
|
352
363
|
handleCancel() {
|
|
353
364
|
this.$emit('cancel')
|
|
354
|
-
this.onCancelClose && this.handlePopupClose()
|
|
365
|
+
this.getPopupSelect.onCancelClose && this.handlePopupClose()
|
|
355
366
|
},
|
|
356
367
|
/**
|
|
357
368
|
* @vuese
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import popupSelect from './popupSelect'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
customClass: '', // 自定义样式类,字符串形式('')
|
|
5
|
+
customStyle: {}, // 自定义样式,对象形式(默认值:{})
|
|
6
|
+
type: 'single', // 选择器类型:single:单列,multi 多列,multi-auto 多列联动
|
|
7
|
+
items: [], // 选项列表,默认([])
|
|
8
|
+
keyField: 'id', // 选项id字段,默认为id
|
|
9
|
+
displayField: 'text', // 选项显示字段,默认为text
|
|
10
|
+
itemHeight: 110, // 行高(默认:'110rpx')
|
|
11
|
+
itemStyle: {}, // 行样式(默认:{})
|
|
12
|
+
itemAlign: 'center', // 行对齐方式,默认值:'center'
|
|
13
|
+
showItemBottomBorder: true, // 是否显示底部边线
|
|
14
|
+
popupSelect: {
|
|
15
|
+
...popupSelect,
|
|
16
|
+
height: 'auto',
|
|
17
|
+
toolbarPosition: 'none'
|
|
18
|
+
}, // popupSelect配置
|
|
19
|
+
popup: {
|
|
20
|
+
...popupSelect.popup,
|
|
21
|
+
borderRadius: '24rpx 24rpx 0 0'
|
|
22
|
+
}, // 弹窗的配置,默认选项请参照popup
|
|
23
|
+
description: '', // 选项上方的描述信息,不填则不显示
|
|
24
|
+
cancelText: '' // 取消按钮文字,不填则不显示
|
|
25
|
+
}
|
package/config/select.js
CHANGED
|
@@ -11,6 +11,7 @@ export default {
|
|
|
11
11
|
defaultValue: null, // 默认值,单选是传Object,多选时传Array,默认null
|
|
12
12
|
isMulti: false, // 是否多选,(默认:false)
|
|
13
13
|
singleCancel: true, // 单选模式下,是否可取消选中
|
|
14
|
+
singleConfirm: false, // 单选模式下,是否直接选中,不需要点击确认按钮(需要设置singleCancel:false)
|
|
14
15
|
itemHeight: 110, // 行高(默认:'110rpx')
|
|
15
16
|
showItemBottomBorder: true, // 是否显示item下边框(默认:'true')
|
|
16
17
|
itemStyle: {}, // 行样式(默认:'{}')
|
package/package.json
CHANGED
package/scss/common.scss
CHANGED
package/tools/index.js
CHANGED