Files
FreeERP.Applet/miniprogram/pages/components/select-plugin/select-plugin.ts

48 lines
895 B
TypeScript
Raw Normal View History

2026-02-04 17:07:30 +08:00
import { toArray } from '@/utils/util';
Component({
options: { multipleSlots: true },
/**
*
*/
properties: {
2026-02-04 17:07:30 +08:00
title: null,
options: null,
value: null,
},
observers: {
2026-02-04 17:07:30 +08:00
value: function (value) {
const data = toArray(this.data.options).find((el) => el.value == value);
this.setData({ note: data?.label || '' });
},
},
/**
*
*/
data: {
2026-02-04 17:07:30 +08:00
show: false,
note: '',
},
/**
*
*/
methods: {
2026-02-04 17:07:30 +08:00
onOpenPicker() {
this.setData({ show: true });
},
2026-02-04 17:07:30 +08:00
onPickerCancel() {
this.setData({ show: false });
},
2026-02-04 17:07:30 +08:00
onConfirm(e: any) {
this.triggerEvent('change', { value: e.detail.value?.[0] });
this.onPickerCancel();
},
2026-02-04 17:07:30 +08:00
onClear() {
this.triggerEvent('change', { value: '' });
this.onPickerCancel();
},
},
});