uview-plus 3.4.37 → 3.4.38
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
CHANGED
|
@@ -93,6 +93,11 @@ export const props = defineMixin({
|
|
|
93
93
|
type: String,
|
|
94
94
|
default: () => defProps.picker.keyName
|
|
95
95
|
},
|
|
96
|
+
// 选项对象中,需要获取的属性值键名
|
|
97
|
+
valueName: {
|
|
98
|
+
type: String,
|
|
99
|
+
default: () => defProps.picker.valueName
|
|
100
|
+
},
|
|
96
101
|
// 是否允许点击遮罩关闭选择器
|
|
97
102
|
closeOnClickOverlay: {
|
|
98
103
|
type: Boolean,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="u-picker-
|
|
2
|
+
<view class="u-picker-wraper">
|
|
3
3
|
<view v-if="hasInput" class="u-picker-input cursor-pointer" @click="onShowByClickInput">
|
|
4
4
|
<slot :value="inputLabel">
|
|
5
5
|
</slot>
|
|
@@ -124,6 +124,14 @@ export default {
|
|
|
124
124
|
}
|
|
125
125
|
},
|
|
126
126
|
watch: {
|
|
127
|
+
// 监听columns参数的变化
|
|
128
|
+
columns: {
|
|
129
|
+
immediate: true,
|
|
130
|
+
deep:true,
|
|
131
|
+
handler(n) {
|
|
132
|
+
this.setColumns(n)
|
|
133
|
+
}
|
|
134
|
+
},
|
|
127
135
|
// 监听默认索引的变化,重新设置对应的值
|
|
128
136
|
defaultIndex: {
|
|
129
137
|
immediate: true,
|
|
@@ -137,14 +145,41 @@ export default {
|
|
|
137
145
|
}
|
|
138
146
|
}
|
|
139
147
|
},
|
|
140
|
-
|
|
141
|
-
columns: {
|
|
148
|
+
modelValue: {
|
|
142
149
|
immediate: true,
|
|
143
150
|
deep:true,
|
|
144
|
-
handler(n) {
|
|
145
|
-
|
|
151
|
+
handler(n,o) {
|
|
152
|
+
// 修复uniapp调用子组件直接:defaultIndex="[0]"这样写
|
|
153
|
+
// v-model的值变化时候导致defaultIndexwatch也会执行的问题
|
|
154
|
+
//单纯vue不会出现
|
|
155
|
+
if (!o || n.join("/") != o.join("/")) {
|
|
156
|
+
let arr = [];
|
|
157
|
+
if (n != null) {
|
|
158
|
+
n.forEach((element, index) => {
|
|
159
|
+
let currentCols = this.getColumnValues(index)
|
|
160
|
+
if (currentCols && Object.prototype.toString.call(currentCols) === '[object Object]') {
|
|
161
|
+
currentCols.forEach((item, index2) => {
|
|
162
|
+
if (item[this.keyName] == element) {
|
|
163
|
+
arr.push(index2)
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
} else {
|
|
167
|
+
currentCols.forEach((item, index2) => {
|
|
168
|
+
if (item == element) {
|
|
169
|
+
arr.push(index2)
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
// alert(arr)
|
|
175
|
+
if (arr.length == 0 && this.defaultIndex) {
|
|
176
|
+
} else {
|
|
177
|
+
this.setIndexs(arr, true)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
146
181
|
}
|
|
147
|
-
}
|
|
182
|
+
}
|
|
148
183
|
},
|
|
149
184
|
emits: ['close', 'cancel', 'confirm', 'change', 'update:modelValue', 'update:show'],
|
|
150
185
|
computed: {
|
|
@@ -178,9 +213,9 @@ export default {
|
|
|
178
213
|
let res = []
|
|
179
214
|
//区分是不是对象数组
|
|
180
215
|
if (items[0] && Object.prototype.toString.call(items[0]) === '[object Object]') {
|
|
181
|
-
|
|
216
|
+
//对象数组返回属性值集合
|
|
182
217
|
items.forEach(element => {
|
|
183
|
-
res.push(element && element[
|
|
218
|
+
res.push(element && element[this.valueName])
|
|
184
219
|
});
|
|
185
220
|
} else {
|
|
186
221
|
//非对象数组返回元素集合
|
|
@@ -213,6 +248,7 @@ export default {
|
|
|
213
248
|
if (this.hasInput) {
|
|
214
249
|
this.showByClickInput = false
|
|
215
250
|
}
|
|
251
|
+
this.setDefault()
|
|
216
252
|
this.$emit('update:show', false)
|
|
217
253
|
this.$emit('close')
|
|
218
254
|
}
|
|
@@ -222,14 +258,13 @@ export default {
|
|
|
222
258
|
if (this.hasInput) {
|
|
223
259
|
this.showByClickInput = false
|
|
224
260
|
}
|
|
261
|
+
this.setDefault()
|
|
225
262
|
this.$emit('update:show', false)
|
|
226
263
|
this.$emit('cancel')
|
|
227
264
|
},
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (!this.currentActiveValue.length) {
|
|
232
|
-
let arr = [0]
|
|
265
|
+
setDefault() {
|
|
266
|
+
let arr = [0]
|
|
267
|
+
if (this.lastIndex.length == 0) {
|
|
233
268
|
//如果有默认值&&默认值的数组长度是正确的,就用默认值
|
|
234
269
|
if (Array.isArray(this.defaultIndex) && this.defaultIndex.length == this.innerColumns.length) {
|
|
235
270
|
arr = [...this.defaultIndex];
|
|
@@ -237,13 +272,23 @@ export default {
|
|
|
237
272
|
//否则默认都选中第一个
|
|
238
273
|
arr = Array(this.innerColumns.length).fill(0);
|
|
239
274
|
}
|
|
240
|
-
|
|
241
|
-
this.
|
|
275
|
+
} else {
|
|
276
|
+
arr = deepClone(this.lastIndex)
|
|
277
|
+
}
|
|
278
|
+
this.setLastIndex(arr)
|
|
279
|
+
this.setIndexs(arr)
|
|
280
|
+
},
|
|
281
|
+
// 点击工具栏的确定按钮
|
|
282
|
+
confirm() {
|
|
283
|
+
// 如果用户有没有触发过change
|
|
284
|
+
if (!this.currentActiveValue.length) {
|
|
285
|
+
this.setDefault()
|
|
242
286
|
}
|
|
243
287
|
this.$emit('update:modelValue', this.inputValue)
|
|
244
288
|
if (this.hasInput) {
|
|
245
289
|
this.showByClickInput = false
|
|
246
290
|
}
|
|
291
|
+
this.setLastIndex(this.innerIndex)
|
|
247
292
|
this.$emit('update:show', false)
|
|
248
293
|
this.$emit('confirm', {
|
|
249
294
|
indexs: this.innerIndex,
|
|
@@ -274,13 +319,14 @@ export default {
|
|
|
274
319
|
this.columnIndex = columnIndex
|
|
275
320
|
const values = this.innerColumns
|
|
276
321
|
// 将当前的各项变化索引,设置为"上一次"的索引变化值
|
|
277
|
-
this.setLastIndex(value)
|
|
322
|
+
// this.setLastIndex(value)
|
|
278
323
|
this.setIndexs(value)
|
|
279
324
|
//如果是非自带输入框才会在change时候触发v-model绑值的变化
|
|
280
325
|
//否则会非常的奇怪,用户未确认,值就变了
|
|
281
|
-
if (!this.hasInput) {
|
|
282
|
-
|
|
283
|
-
}
|
|
326
|
+
// if (!this.hasInput) {
|
|
327
|
+
// this.$emit('update:modelValue', this.inputValue)
|
|
328
|
+
// }
|
|
329
|
+
|
|
284
330
|
this.$emit('change', {
|
|
285
331
|
// #ifndef MP-WEIXIN || MP-LARK
|
|
286
332
|
// 微信小程序不能传递this,会因为循环引用而报错
|
|
@@ -74,7 +74,7 @@ export default {
|
|
|
74
74
|
watch: {
|
|
75
75
|
modelValue() {
|
|
76
76
|
if (this.modelValue) {
|
|
77
|
-
this.options.forEach((ele) => {
|
|
77
|
+
this.options.forEach((ele, index) => {
|
|
78
78
|
if (ele[this.valueKey] == this.modelValue) {
|
|
79
79
|
this.current = ele[this.labelKey]
|
|
80
80
|
this.defaultIndex = [index]
|
package/package.json
CHANGED