Commit d2f1cc40 by Chao Sun

多选记住上一步答案

parent de9334f1
......@@ -19,7 +19,8 @@ export class HealthComponent implements OnInit {
// 暂存健康状况
questions: Array<any> = [];
nextBtn: boolean = false;
lastQuestions: Array<any>;
targetObj:Object = {}
constructor(private commonService: CommonService,
private router: Router,
private route: ActivatedRoute) {
......@@ -43,6 +44,12 @@ export class HealthComponent implements OnInit {
}
ngOnInit() {
if(this.id == 1){
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 11).pop();
}else{
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 12).pop();
}
this.surveyInfo();
}
......@@ -51,10 +58,27 @@ export class HealthComponent implements OnInit {
if (res['success']) {
if (this.id == 1) {
this.curPageData = res['data'].survey.pages['10'];
for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
console.log(this.lastQuestions)
console.log(this.curPageData)
this.lastQuestions['questions'][i]['options'].forEach(option => {
if(Object.keys(option).indexOf('optionId')>-1){
this.targetObj = option
console.log(this.targetObj)
}
// this.selectedHealth(this.targetObj);
});
}
}
}
} else {
this.curPageData = res['data'].survey.pages['11'];
}
// console.log(this.curPageData)
}
})
}
......@@ -63,6 +87,7 @@ export class HealthComponent implements OnInit {
selectedHealth(option) {
option['selected'] = !option['selected'];
this.questions = [];
console.log(option)
if (this.id == 1) {
this.getOptions(67, option);
} else if (this.id == 2) {
......
......@@ -13,7 +13,8 @@ export class LoanComponent implements OnInit {
type: any;
pageAnswers: any;
nextBtn: boolean;
lastQuestions: Array<any>;
targetObj:Object = {}
constructor(private commonService: CommonService,
private router: Router,
private route: ActivatedRoute) {
......@@ -33,8 +34,8 @@ export class LoanComponent implements OnInit {
ngOnInit() {
this.nextBtn = false;
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 8).pop();
this.surveyInfo();
}
surveyInfo() {
......@@ -42,8 +43,22 @@ export class LoanComponent implements OnInit {
if (res['success']) {
this.curPageData = res['data']['survey'].pages['7'];
this.pageAnswers.pageId = this.curPageData['pageId'];
// console.log(this.curPageData);
for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
this.lastQuestions['questions'][i]['options'].forEach(option => {
if(Object.keys(option).indexOf('optionId')>-1){
this.targetObj = option
}
this.selectedLoan(this.curPageData['questions'][j],this.targetObj);
});
}
}
}
}
console.log(this.pageAnswers)
console.log(this.commonService.todos)
})
}
......
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