42 lines
1019 B
JavaScript
42 lines
1019 B
JavaScript
Component({
|
|
properties: {
|
|
visible: { type: Boolean, value: false },
|
|
title: { type: String, value: '请选择' },
|
|
keyword: { type: String, value: '' },
|
|
placeholder: { type: String, value: '搜索' },
|
|
items: { type: Array, value: [] },
|
|
selectedId: { type: null, value: '' },
|
|
loading: { type: Boolean, value: false },
|
|
errorText: { type: String, value: '' },
|
|
emptyText: { type: String, value: '暂无可选内容' },
|
|
actionText: { type: String, value: '' },
|
|
showSearch: { type: Boolean, value: true }
|
|
},
|
|
|
|
methods: {
|
|
close() {
|
|
this.triggerEvent('close')
|
|
},
|
|
|
|
stopEvent() {
|
|
},
|
|
|
|
onSearch(event) {
|
|
this.triggerEvent('search', { value: event.detail.value })
|
|
},
|
|
|
|
selectItem(event) {
|
|
const item = this.data.items[Number(event.currentTarget.dataset.index)]
|
|
if (item) this.triggerEvent('select', { item })
|
|
},
|
|
|
|
retry() {
|
|
this.triggerEvent('retry')
|
|
},
|
|
|
|
action() {
|
|
this.triggerEvent('action')
|
|
}
|
|
}
|
|
})
|