代码优化
This commit is contained in:
parent
9645d6160c
commit
8835cb8906
|
|
@ -191,7 +191,8 @@ export default {
|
||||||
currentIndex: 0,
|
currentIndex: 0,
|
||||||
fixedPersonList: [],
|
fixedPersonList: [],
|
||||||
tempPersonList: [],
|
tempPersonList: [],
|
||||||
returnPersonList: []
|
returnPersonList: [],
|
||||||
|
isSearch: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -232,13 +233,46 @@ export default {
|
||||||
// 过滤已选择的数据
|
// 过滤已选择的数据
|
||||||
if (this.subUserListTemp.length > 0) {
|
if (this.subUserListTemp.length > 0) {
|
||||||
// this.subUserList = this.subUserListTemp.filter(e => e.isAllChecked == true)
|
// this.subUserList = this.subUserListTemp.filter(e => e.isAllChecked == true)
|
||||||
this.subUserListAll.forEach(e => {
|
// this.subUserListAll.forEach(e => {
|
||||||
this.subUserListTemp.forEach(j => {
|
// this.subUserListTemp.forEach(j => {
|
||||||
if (e.idNumber == j.idNumber) {
|
// if (e.idNumber == j.idNumber) {
|
||||||
this.subUserList.push(JSON.parse(JSON.stringify(j)))
|
// 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 {
|
} else {
|
||||||
this.subUserList = []
|
this.subUserList = []
|
||||||
}
|
}
|
||||||
|
|
@ -250,15 +284,67 @@ export default {
|
||||||
// this.subUserList = this.subUserListTemp.filter(e => e.isAllChecked == false)
|
// this.subUserList = this.subUserListTemp.filter(e => e.isAllChecked == false)
|
||||||
// }
|
// }
|
||||||
if (this.subUserListTemp.length > 0) {
|
if (this.subUserListTemp.length > 0) {
|
||||||
this.subUserListAll.forEach(e => {
|
// this.subUserListAll.forEach(e => {
|
||||||
this.subUserListTemp.forEach(j => {
|
// if (!this.subUserListTemp.includes(e)) {
|
||||||
if (e.idNumber != j.idNumber) {
|
// this.subUserList.push(JSON.parse(JSON.stringify(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 {
|
} 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 {
|
} else {
|
||||||
|
|
@ -272,7 +358,7 @@ export default {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
console.log('全部状态---', this.personList)
|
console.log('全部状态---', this.personList)
|
||||||
if (this.subUserListTemp.length == 0) {
|
if (this.subUserListTemp.length == 0 && !this.isSearch) {
|
||||||
if (this.personList.length > 0) {
|
if (this.personList.length > 0) {
|
||||||
this.subUserListAll.forEach(e => {
|
this.subUserListAll.forEach(e => {
|
||||||
if (this.personList[this.currentIndex].includes(e.idNumber)) {
|
if (this.personList[this.currentIndex].includes(e.idNumber)) {
|
||||||
|
|
@ -300,16 +386,69 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
this.subUserList = JSON.parse(JSON.stringify(this.subUserListAll))
|
this.subUserList = JSON.parse(JSON.stringify(this.subUserListAll))
|
||||||
}
|
}
|
||||||
} else {
|
} else if (this.subUserListTemp.length > 0 && this.isSearch) {
|
||||||
this.subUserListAll.forEach(e => {
|
let tempArray = this.personList.filter((e, index) => index != this.currentIndex)
|
||||||
this.subUserListTemp.forEach(j => {
|
let tempPersonList = []
|
||||||
if (e.idNumber == j.idNumber) {
|
if (tempArray.length > 0) {
|
||||||
this.subUserList.push(JSON.parse(JSON.stringify(j)))
|
this.subUserList = []
|
||||||
} else {
|
// this.subUserListTemp
|
||||||
this.subUserList.push(JSON.parse(JSON.stringify(e)))
|
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
|
this.totalAmount = this.subUserList.length
|
||||||
|
|
@ -327,7 +466,7 @@ export default {
|
||||||
// try {
|
// try {
|
||||||
// this.subUserListAll.forEach(e => {
|
// this.subUserListAll.forEach(e => {
|
||||||
// if (e.idNumber == item.idNumber) {
|
// if (e.idNumber == item.idNumber) {
|
||||||
// e.isChecked = !eisChecked
|
// e.isChecked = !e.isChecked
|
||||||
// throw new Error()
|
// throw new Error()
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
|
|
@ -397,6 +536,7 @@ export default {
|
||||||
this.$refs.popup.close()
|
this.$refs.popup.close()
|
||||||
},
|
},
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
|
this.isSearch = true
|
||||||
if (this.reamList.length > 0) {
|
if (this.reamList.length > 0) {
|
||||||
this.subQueryParams.teamName = this.reamList.join(',')
|
this.subQueryParams.teamName = this.reamList.join(',')
|
||||||
}
|
}
|
||||||
|
|
@ -460,6 +600,12 @@ export default {
|
||||||
console.log(isAllChecked, 'isAllChecked')
|
console.log(isAllChecked, 'isAllChecked')
|
||||||
this.subUserList.forEach(e => {
|
this.subUserList.forEach(e => {
|
||||||
e.isChecked = !isAllChecked
|
e.isChecked = !isAllChecked
|
||||||
|
|
||||||
|
// this.subUserListAll.forEach(j => {
|
||||||
|
// if (e.idNumber == j.idNumber) {
|
||||||
|
// j.isChecked = !j.isChecked
|
||||||
|
// }
|
||||||
|
// })
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this.subUserList.every(e => e.isChecked == true)) {
|
if (this.subUserList.every(e => e.isChecked == true)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue