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 }) }, onAvatarError(event) { const index = Number(event.currentTarget.dataset.index) if (!Number.isInteger(index) || !this.data.items[index]) return this.setData({ [`items[${index}].avatar`]: '' }) }, retry() { this.triggerEvent('retry') }, action() { this.triggerEvent('action') }, changeView(event) { this.triggerEvent('changeview', { mode: event.currentTarget.dataset.mode }) }, sort() { this.triggerEvent('sort') } } })