diff --git a/pages/workPlan/dayPlan/sub-user/index.vue b/pages/workPlan/dayPlan/sub-user/index.vue index 5f4d625..7c4f360 100644 --- a/pages/workPlan/dayPlan/sub-user/index.vue +++ b/pages/workPlan/dayPlan/sub-user/index.vue @@ -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)) {