Commit da61eba1 by caoyanzhi

update: 选择成员组件

parent 51a0f0e9
......@@ -188,25 +188,47 @@ export default {
// 全选所有导购
onSelectAll() {
// 只能全选本页,或者取消本页的全选
this.storeClerkList.forEach(el => {
if (!el.disabled && this.selected.length < this.max) {
el.selected = this.selectAll.selected;
this.onSelectStore(el, true);
const storeClerkList = this.storeClerkList.filter(el => !el.disabled);
if (storeClerkList.length > 0) {
const isSelectedAll = storeClerkList.every(el => el.selected) || this.selected.length >= this.max;
if (isSelectedAll) {
storeClerkList.forEach(el => {
el.selected = false;
el.indeterminate = false;
});
this.selected.forEach(el => (el.selected = false));
this.selected = [];
} else {
storeClerkList.forEach(el => {
if (this.selected.length < this.max && !el.selected) {
el.selected = true;
this.onSelectStore(el, true);
}
});
}
});
}
this.updateAllState();
},
// 全选门店下的导购
onSelectStore(store, isAll) {
store.clerkList.forEach(el => {
if (!el.disabled && this.selected.length < this.max) {
el.selected = store.selected;
this.onSelectClerk(el, store, true);
const clerkList = store.clerkList.filter(el => !el.disabled);
if (clerkList.length > 0) {
let isSelectedAll = clerkList.every(el => el.selected) || this.selected.length >= this.max;
clerkList.forEach(el => {
if (isSelectedAll) {
el.selected = false;
this.onSelectClerk(el, store, true);
} else {
if (this.selected.length < this.max && !el.selected) {
el.selected = true;
this.onSelectClerk(el, store, true);
}
}
});
this.updateStoreState(store);
if (!isAll) {
this.updateAllState();
}
});
this.updateStoreState(store);
if (!isAll) {
this.updateAllState();
}
},
// 选择单个导购
......@@ -227,11 +249,14 @@ export default {
if (this.selected.length < this.max) {
this.selected.push(clerk);
} else {
clerk.selected = false;
this.$message.warning(`最多只能选择 ${this.max} 个导购`);
}
} else {
const index = this.selected.findIndex(el => el.clerkId == clerk.clerkId);
this.selected.splice(index, 1);
if (index >= 0) {
this.selected.splice(index, 1);
}
}
if (!isAll) {
this.updateStoreState(store);
......@@ -239,9 +264,10 @@ export default {
}
},
onDelAll() {
this.selectAll.selected = false;
this.selectAll.indeterminate = false;
this.onSelectAll();
if (this.selected.length > 0) {
this.selectAll.selected = false;
this.onSelectAll();
}
},
onDel(index) {
const clerk = this.selected[index];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment