Files
JayuCloud/JC-Salon-WeChat/components/entity-selector-sheet/index.js
T

53 lines
1.3 KiB
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: '' },
showViewSwitch: { type: Boolean, value: false },
viewMode: { type: String, value: 'list' },
sortLabel: { 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')
},
changeView(event) {
this.triggerEvent('changeview', { mode: event.currentTarget.dataset.mode })
},
sort() {
this.triggerEvent('sort')
}
}
})