添加组件及页面

This commit is contained in:
zhengw
2026-02-04 17:07:30 +08:00
parent e10c7bc537
commit 62039e3684
20 changed files with 756 additions and 55 deletions

View File

@@ -1,21 +1,19 @@
import { toArray } from '@/utils/util';
Component({
options: { multipleSlots: true },
/**
* 组件的属性列表
*/
properties: {
mode: { type: String, value: "single" },
title: { type: String, value: "请选择" },
options: { type: Array, value: [] },
value: { type: null, value: [] },
title: null,
options: null,
value: null,
},
observers: {
"value,mode": function (v, m) {
if (m == "multiple") {
this.setData({ val: Array.isArray(v) ? [...v] : [] });
} else {
this.setData({ val: v });
}
value: function (value) {
const data = toArray(this.data.options).find((el) => el.value == value);
this.setData({ note: data?.label || '' });
},
},
@@ -23,31 +21,27 @@ Component({
* 组件的初始数据
*/
data: {
visible: false,
val: [] as any[] | string | number,
show: false,
note: '',
},
/**
* 组件的方法列表
*/
methods: {
click() {
this.setData({ visible: true });
onOpenPicker() {
this.setData({ show: true });
},
close() {
this.setData({ visible: false });
onPickerCancel() {
this.setData({ show: false });
},
radioChange(e: any) {
this.triggerEvent("change", { value: e.detail.value });
this.setData({ val: e.detail.value, visible: false });
onConfirm(e: any) {
this.triggerEvent('change', { value: e.detail.value?.[0] });
this.onPickerCancel();
},
checkboxChange(e: any) {
this.setData({ val: e.detail.value });
},
ok() {
this.setData({ visible: false });
this.triggerEvent("change", { value: this.data.val });
onClear() {
this.triggerEvent('change', { value: '' });
this.onPickerCancel();
},
},
});