代码优化

This commit is contained in:
BianLzhaoMin 2024-11-11 17:06:52 +08:00
parent 9645d6160c
commit 8835cb8906
1 changed files with 171 additions and 25 deletions

View File

@ -191,7 +191,8 @@ export default {
currentIndex: 0,
fixedPersonList: [],
tempPersonList: [],
returnPersonList: []
returnPersonList: [],
isSearch: false
}
},
methods: {
@ -232,13 +233,46 @@ export default {
//
if (this.subUserListTemp.length > 0) {
// this.subUserList = this.subUserListTemp.filter(e => e.isAllChecked == true)
this.subUserListAll.forEach(e => {
this.subUserListTemp.forEach(j => {
if (e.idNumber == j.idNumber) {
this.subUserList.push(JSON.parse(JSON.stringify(j)))
}
// this.subUserListAll.forEach(e => {
// this.subUserListTemp.forEach(j => {
// if (e.idNumber == j.idNumber) {
// this.subUserList.push(JSON.parse(JSON.stringify(j)))
// }
// })
// })
let tempArray = this.personList.filter((e, index) => index != this.currentIndex)
let tempPersonList = []
if (tempArray.length > 0) {
this.subUserList = []
// this.subUserListTemp
tempArray.forEach(e => {
this.subUserListAll.forEach(j => {
if (!e.includes(j.idNumber)) {
// this.subUserList.push(j)
tempPersonList.push(JSON.parse(JSON.stringify(j)))
// this.subUserListTemp.push(JSON.parse(JSON.stringify(j)))
}
})
})
})
// this.subUserList = this.subUserListTemp.filter(e => e.isAllChecked == true)
tempPersonList.forEach(e => {
this.subUserListTemp.forEach(j => {
if (e.idNumber == j.idNumber) {
this.subUserList.push(JSON.parse(JSON.stringify(j)))
}
})
})
// this.subUserList = tempPersonList
} else {
this.subUserListAll.forEach(e => {
this.subUserListTemp.forEach(j => {
if (e.idNumber == j.idNumber) {
this.subUserList.push(JSON.parse(JSON.stringify(j)))
}
})
})
}
} else {
this.subUserList = []
}
@ -250,15 +284,67 @@ export default {
// this.subUserList = this.subUserListTemp.filter(e => e.isAllChecked == false)
// }
if (this.subUserListTemp.length > 0) {
this.subUserListAll.forEach(e => {
this.subUserListTemp.forEach(j => {
if (e.idNumber != j.idNumber) {
this.subUserList.push(JSON.parse(JSON.stringify(e)))
}
// this.subUserListAll.forEach(e => {
// if (!this.subUserListTemp.includes(e)) {
// this.subUserList.push(JSON.parse(JSON.stringify(e)))
// }
// // console.log('', e)
// // this.subUserListTemp.forEach(j => {
// // console.log('', j)
// // if (e.idNumber == j.idNumber) {
// // this.subUserList.push(JSON.parse(JSON.stringify(e)))
// // }
// // })
// })
// this.subUserListTemp.forEach((e)=>{
// this.subUserListAll.forEach((j)=>{
// if(e.idNumber )
// })
// })
let tempArray = this.personList.filter((e, index) => index != this.currentIndex)
let tempPersonList = []
if (tempArray.length > 0) {
this.subUserList = []
// this.subUserListTemp
tempArray.forEach(e => {
this.subUserListAll.forEach(j => {
if (!e.includes(j.idNumber)) {
// this.subUserList.push(j)
tempPersonList.push(JSON.parse(JSON.stringify(j)))
// this.subUserListTemp.push(JSON.parse(JSON.stringify(j)))
}
})
})
})
this.subUserList = this.tempPersonList.filter(
itemA => !this.subUserListTemp.some(itemB => itemB.idNumber == itemA.idNumber)
)
} else {
this.subUserList = this.subUserListAll.filter(
itemA => !this.subUserListTemp.some(itemB => itemB.idNumber == itemA.idNumber)
)
}
} else {
this.subUserList = JSON.parse(JSON.stringify(this.subUserListAll))
let tempArray = this.personList.filter((e, index) => index != this.currentIndex)
let tempPersonList = []
if (tempArray.length > 0) {
this.subUserList = []
// this.subUserListTemp
tempArray.forEach(e => {
this.subUserListAll.forEach(j => {
if (!e.includes(j.idNumber)) {
// this.subUserList.push(j)
tempPersonList.push(JSON.parse(JSON.stringify(j)))
// this.subUserListTemp.push(JSON.parse(JSON.stringify(j)))
}
})
})
this.subUserList = tempPersonList
} else {
this.subUserList = JSON.parse(JSON.stringify(this.subUserListAll))
}
}
}
} else {
@ -272,7 +358,7 @@ export default {
// }
console.log('全部状态---', this.personList)
if (this.subUserListTemp.length == 0) {
if (this.subUserListTemp.length == 0 && !this.isSearch) {
if (this.personList.length > 0) {
this.subUserListAll.forEach(e => {
if (this.personList[this.currentIndex].includes(e.idNumber)) {
@ -300,16 +386,69 @@ export default {
} else {
this.subUserList = JSON.parse(JSON.stringify(this.subUserListAll))
}
} else {
this.subUserListAll.forEach(e => {
this.subUserListTemp.forEach(j => {
if (e.idNumber == j.idNumber) {
this.subUserList.push(JSON.parse(JSON.stringify(j)))
} else {
this.subUserList.push(JSON.parse(JSON.stringify(e)))
}
} else if (this.subUserListTemp.length > 0 && this.isSearch) {
let tempArray = this.personList.filter((e, index) => index != this.currentIndex)
let tempPersonList = []
if (tempArray.length > 0) {
this.subUserList = []
// this.subUserListTemp
tempArray.forEach(e => {
this.subUserListAll.forEach(j => {
if (!e.includes(j.idNumber)) {
// this.subUserList.push(j)
tempPersonList.push(JSON.parse(JSON.stringify(j)))
// this.subUserListTemp.push(JSON.parse(JSON.stringify(j)))
}
})
})
})
// this.subUserList = tempPersonList
tempPersonList.forEach(e => {
this.subUserListTemp.forEach(j => {
if (e.idNumber == j.idNumber) {
// this.subUserList.push(JSON.parse(JSON.stringify(j)))
e.isChecked = true
} else {
// this.subUserList.push(JSON.parse(JSON.stringify(e)))
}
})
})
this.subUserList = tempPersonList
} else {
this.subUserListAll.forEach(e => {
this.subUserListTemp.forEach(j => {
if (e.idNumber == j.idNumber) {
// this.subUserList.push(JSON.parse(JSON.stringify(j)))
e.isChecked = true
} else {
// this.subUserList.push(JSON.parse(JSON.stringify(e)))
}
})
})
this.subUserList = this.subUserListAll
}
} else if (this.subUserListTemp.length == 0 && this.isSearch) {
let tempArray = this.personList.filter((e, index) => index != this.currentIndex)
let tempPersonList = []
if (tempArray.length > 0) {
this.subUserList = []
// this.subUserListTemp
tempArray.forEach(e => {
this.subUserListAll.forEach(j => {
if (!e.includes(j.idNumber)) {
// this.subUserList.push(j)
tempPersonList.push(JSON.parse(JSON.stringify(j)))
// this.subUserListTemp.push(JSON.parse(JSON.stringify(j)))
}
})
})
this.subUserList = tempPersonList
} else {
this.subUserList = this.subUserListAll
}
} else {
}
}
this.totalAmount = this.subUserList.length
@ -327,7 +466,7 @@ export default {
// try {
// this.subUserListAll.forEach(e => {
// if (e.idNumber == item.idNumber) {
// e.isChecked = !eisChecked
// e.isChecked = !e.isChecked
// throw new Error()
// }
// })
@ -397,6 +536,7 @@ export default {
this.$refs.popup.close()
},
onSubmit() {
this.isSearch = true
if (this.reamList.length > 0) {
this.subQueryParams.teamName = this.reamList.join(',')
}
@ -460,6 +600,12 @@ export default {
console.log(isAllChecked, 'isAllChecked')
this.subUserList.forEach(e => {
e.isChecked = !isAllChecked
// this.subUserListAll.forEach(j => {
// if (e.idNumber == j.idNumber) {
// j.isChecked = !j.isChecked
// }
// })
})
if (this.subUserList.every(e => e.isChecked == true)) {