@kaiyinchem/ky-uniui 1.0.11 → 1.0.13
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/ky-picker.vue
CHANGED
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
|
|
25
25
|
<script>
|
|
26
26
|
export default {
|
|
27
|
-
emits: ['update:value', 'change'],
|
|
27
|
+
emits: ['update:value', 'update:label', 'change'],
|
|
28
28
|
props: {
|
|
29
|
-
/**
|
|
30
|
-
* 回显对象
|
|
31
|
-
*/
|
|
32
29
|
value: {
|
|
33
30
|
type: [Object, String, Number, Array],
|
|
34
31
|
},
|
|
32
|
+
label: {
|
|
33
|
+
type: [Object, String, Number, Array],
|
|
34
|
+
},
|
|
35
35
|
/**
|
|
36
36
|
* 格式,[{ name: 'xx': id: 'xxx' }]
|
|
37
37
|
*/
|
|
@@ -97,10 +97,14 @@
|
|
|
97
97
|
this.index = index
|
|
98
98
|
currVal.index = index
|
|
99
99
|
this.$emit('update:value', this.checked)
|
|
100
|
+
this.$emit('update:label', this.names[index])
|
|
100
101
|
this.$emit('change', currVal)
|
|
101
102
|
},
|
|
102
103
|
mapVal(v) {
|
|
103
104
|
if (typeof v === 'undefined') {
|
|
105
|
+
this.index = 0
|
|
106
|
+
this.multiIndex = [0, 0]
|
|
107
|
+
this.checked = ''
|
|
104
108
|
return
|
|
105
109
|
}
|
|
106
110
|
this.$nextTick(function() {
|
|
@@ -115,9 +119,6 @@
|
|
|
115
119
|
},
|
|
116
120
|
mapList(v) {
|
|
117
121
|
if (typeof v === 'undefined') {
|
|
118
|
-
this.index = 0
|
|
119
|
-
this.multiIndex = [0, 0]
|
|
120
|
-
this.checked = ''
|
|
121
122
|
return
|
|
122
123
|
}
|
|
123
124
|
if (this.mode === 'multiSelector') {
|
|
@@ -199,13 +200,20 @@
|
|
|
199
200
|
},
|
|
200
201
|
|
|
201
202
|
// 多列完成的时候触发
|
|
202
|
-
onMultichange(val, noEmit) {
|
|
203
|
+
onMultichange(val, noEmit) {
|
|
204
|
+
const data1 = this.names[0][val[0]]
|
|
205
|
+
const data2 = this.names[1][val[1]]
|
|
206
|
+
const emitValue = [data1[this.valueName], data2[this.valueName]]
|
|
207
|
+
const emitName = [data1[this.keyName], data2[this.keyName]]
|
|
203
208
|
this.checked = {
|
|
204
209
|
index: val,
|
|
205
|
-
data: [
|
|
206
|
-
}
|
|
210
|
+
data: [data1, data2]
|
|
211
|
+
}
|
|
212
|
+
console.log(emitValue, emitName)
|
|
207
213
|
if (!noEmit) {
|
|
208
|
-
this.$emit('update:value',
|
|
214
|
+
this.$emit('update:value', emitValue)
|
|
215
|
+
this.$emit('update:label', emitName)
|
|
216
|
+
this.$emit('change', this.checked)
|
|
209
217
|
}
|
|
210
218
|
}
|
|
211
219
|
}
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
|
|
44
44
|
<script>
|
|
45
45
|
export default {
|
|
46
|
-
emits: ['select', 'search'],
|
|
46
|
+
emits: ['select', 'search', 'update:keyword', 'update:visible'],
|
|
47
47
|
props: {
|
|
48
48
|
keyword: {
|
|
49
49
|
type: String,
|
|
@@ -96,9 +96,11 @@
|
|
|
96
96
|
methods: {
|
|
97
97
|
show() {
|
|
98
98
|
this.state = true
|
|
99
|
+
this.$emit('update:visible', true)
|
|
99
100
|
},
|
|
100
101
|
hide() {
|
|
101
102
|
this.state = false
|
|
103
|
+
this.$emit('update:visible', false)
|
|
102
104
|
},
|
|
103
105
|
save() {
|
|
104
106
|
const hasSame = this.historyList.some(e => e === this.str)
|
|
@@ -106,12 +108,12 @@
|
|
|
106
108
|
this.historyList.push(this.str)
|
|
107
109
|
this.$db.set(this.keyStr, this.historyList)
|
|
108
110
|
}
|
|
109
|
-
this.
|
|
111
|
+
this.hide()
|
|
110
112
|
uni.hideKeyboard()
|
|
111
113
|
},
|
|
112
114
|
handleClear() {
|
|
113
115
|
this.str = undefined
|
|
114
|
-
this.
|
|
116
|
+
this.hide()
|
|
115
117
|
},
|
|
116
118
|
handleSearch() {
|
|
117
119
|
this.$emit('search', this.str)
|
|
@@ -121,7 +123,7 @@
|
|
|
121
123
|
},
|
|
122
124
|
handleFocus() {
|
|
123
125
|
if (!this.str) {
|
|
124
|
-
this.
|
|
126
|
+
this.show()
|
|
125
127
|
}
|
|
126
128
|
},
|
|
127
129
|
selectKeyword(str) {
|
|
@@ -131,6 +133,9 @@
|
|
|
131
133
|
clearSignle(index) {
|
|
132
134
|
this.historyList.splice(index, 1)
|
|
133
135
|
this.$db.set(this.keyStr, this.historyList)
|
|
136
|
+
if (!this.historyList.length) {
|
|
137
|
+
this.hide()
|
|
138
|
+
}
|
|
134
139
|
},
|
|
135
140
|
clearHistory() {
|
|
136
141
|
this.$confirm({ content: '确定清除全部历史吗?' }, (res) => {
|