Complete core mini program flows
This commit is contained in:
@@ -2,6 +2,7 @@ Component({
|
||||
properties: {
|
||||
pets: { type: Array, value: [] },
|
||||
selected: { type: Array, value: [] },
|
||||
disabled: { type: Boolean, value: false },
|
||||
},
|
||||
data: { viewPets: [] },
|
||||
observers: {
|
||||
@@ -16,11 +17,18 @@ Component({
|
||||
},
|
||||
methods: {
|
||||
toggle(e) {
|
||||
if (this.data.disabled) return;
|
||||
const id = e.currentTarget.dataset.id;
|
||||
const selected = this.data.selected.includes(id)
|
||||
? this.data.selected.filter((x) => x !== id)
|
||||
: [...this.data.selected, id];
|
||||
this.triggerEvent("change", { selected });
|
||||
},
|
||||
selectAll() {
|
||||
if (this.data.disabled) return;
|
||||
const ids = this.data.pets.map((pet) => pet.id);
|
||||
const allSelected = ids.every((id) => this.data.selected.includes(id));
|
||||
this.triggerEvent("change", { selected: allSelected ? [] : ids });
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user