Commit d2f1cc40 by Chao Sun

多选记住上一步答案

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