if.else的写法
if(this.searchForm.listType == 1 && this.searchForm.status == "WAIT_ALLOC"){
if (this.isClueBelongPeople(item) || this.isClueInterventionPeople(item))
item.buttonList.push("分配线索")
}
if(this.searchForm.listType == 1 && this.searchForm.status == "WAIT_GET"){
if (this.isClueBelongPeople(item) || this.isClueInterventionPeople(item))
item.buttonList.push("回收线索")
}
if(this.searchForm.listType == 1 && this.searchForm.status == "WAIT_INVITE"){
if (this.isClueBelongPeople(item) || this.isClueInterventionPeople(item))
item.buttonList.push("回收线索")
}if(this.searchForm.listType == 1 && this.searchForm.status == "INVITING"){
if (this.isClueBelongPeople(item) || this.isClueInterventionPeople(item))
item.buttonList.push("催促邀约")
}
映射对象的写法
const { listType, status } = this.searchForm;
// 定义按钮操作的映射对象
const buttonActions = {
1: {
"WAIT_ALLOC": () => {
if (this.isClueBelongPeople(item) || this.isClueInterventionPeople(item)) {
item.buttonList.push("分配线索");
}
},
"WAIT_GET": () => {
if (this.isClueBelongPeople(item)) {
item.buttonList.push("回收线索");
}
},
"WAIT_INVITE": () => {
if (this.isClueBelongPeople(item)) {
item.buttonList.push("回收线索");
}
},
"INVITING": () => {
if (this.isClueBelongPeople(item)) {
item.buttonList.push("催促邀约");
}
}
},
};
// 执行对应的操作
if (buttonActions[listType]?.[status]) {
buttonActions[listType][status]();
}