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

65 lines
1.1 KiB
TypeScript
Raw Normal View History

Component({
options: { multipleSlots: true },
/**
*
*/
properties: {
mode: {
type: String,
value: "single",
},
title: {
type: String,
value: "请选择",
},
options: {
type: Array,
value: [],
},
value: {
type: null,
value: [],
},
},
observers: {
"value,mode": function (v, m) {
if (m == "multiple") {
this.setData({ val: Array.isArray(v) ? [...v] : [] });
} else {
this.setData({ val: v });
}
},
},
/**
*
*/
data: {
visible: false,
val: [] as any[] | string | number,
},
/**
*
*/
methods: {
click() {
this.setData({ visible: true });
},
close() {
this.setData({ visible: false });
},
radioChange(e: any) {
this.setData({ val: e.detail.value });
},
checkboxChange(e: any) {
this.setData({ val: e.detail.value });
},
ok() {
this.setData({ visible: false });
this.triggerEvent("change", { value: this.data.val });
},
},
});