Commit 5a751580 by Sweet Zhang

下一步的问题

parent e2da9242
...@@ -97,7 +97,7 @@ export class AgeComponent implements OnInit { ...@@ -97,7 +97,7 @@ export class AgeComponent implements OnInit {
// console.log(this.curPageData); // console.log(this.curPageData);
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
this.closeToast(); this.closeToast();
console.log(this.pageAnswers); // console.log(this.pageAnswers);
if (this.curPageData['questions'].length == this.pageAnswers.questions.length) { if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
this.nextBtn = true; this.nextBtn = true;
} else { } else {
......
...@@ -22,6 +22,7 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -22,6 +22,7 @@ export class ChildrenHealthComponent implements OnInit {
childTotalCount: any; childTotalCount: any;
// 暂存多个孩子的答案 // 暂存多个孩子的答案
childTotalQuestions: Array<any> = []; childTotalQuestions: Array<any> = [];
nextBtn: boolean = false;
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
...@@ -35,7 +36,6 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -35,7 +36,6 @@ export class ChildrenHealthComponent implements OnInit {
*/ */
this.type = this.route.snapshot.queryParams['type']; this.type = this.route.snapshot.queryParams['type'];
this.id = this.route.snapshot.params['childId']; this.id = this.route.snapshot.params['childId'];
this.childTotalCount = this.route.snapshot.queryParams['childTotalCount'];
this.pageAnswers = { this.pageAnswers = {
pageId: '', pageId: '',
questions: [{ questions: [{
...@@ -73,6 +73,17 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -73,6 +73,17 @@ export class ChildrenHealthComponent implements OnInit {
pageId: this.curPageData['pageId'], pageId: this.curPageData['pageId'],
questions: this.childTotalQuestions, questions: this.childTotalQuestions,
}; };
// console.log(this.pageAnswers);
// console.log(this.curPageData)
if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
if (this.pageAnswers.questions.every(item => item.options.length > 0)) {
this.nextBtn = true;
} else {
this.nextBtn = false;
}
} else {
this.nextBtn = false;
}
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
} }
...@@ -107,16 +118,15 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -107,16 +118,15 @@ export class ChildrenHealthComponent implements OnInit {
// 下一步 // 下一步
next() { next() {
if (this.pageAnswers.questions[0].options.every((item) => { const age = this.commonService.todosCopy.filter(item => item.pageId == 3).pop();
return item.selected; this.childTotalCount = age['questions'].filter(item => item.questionId == 4).length;
})) { if (this.nextBtn) {
this.id = this.route.snapshot.params['childId']; this.id = this.route.snapshot.params['childId'];
// 查看有几个孩子,一个直接跳到疾病页,多个跳多个孩子页 // 查看有几个孩子,一个直接跳到疾病页,多个跳多个孩子页
if (this.id < this.childTotalCount) { if (this.id < parseInt(this.childTotalCount, 0)) {
this.router.navigate(['/children_health', parseInt(this.id, 0) + 1], { this.router.navigate(['/children_health', parseInt(this.id, 0) + 1], {
queryParams: { queryParams: {
type: this.type, type: this.type
childTotalCount: this.childTotalCount
} }
}); });
this.surveyInfo(); this.surveyInfo();
......
...@@ -92,10 +92,14 @@ export class DiseaseComponent implements OnInit { ...@@ -92,10 +92,14 @@ export class DiseaseComponent implements OnInit {
} }
this.commonService.addAnswer(this.pageAnswers) this.commonService.addAnswer(this.pageAnswers)
// console.log(this.pageAnswers) // console.log(this.pageAnswers)
if (this.pageAnswers['questions'].length > 0) { if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
this.nextBtn = true if (this.pageAnswers.questions.every(item => item.options.length > 0)) {
this.nextBtn = true;
} else {
this.nextBtn = false;
}
} else { } else {
this.nextBtn = false this.nextBtn = false;
} }
} }
...@@ -126,10 +130,14 @@ export class DiseaseComponent implements OnInit { ...@@ -126,10 +130,14 @@ export class DiseaseComponent implements OnInit {
options: this.questions options: this.questions
}], }],
}; };
if (this.pageAnswers['questions'].length > 0) { if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
this.nextBtn = true if (this.pageAnswers.questions.every(item => item.options.length > 0)) {
this.nextBtn = true;
} else {
this.nextBtn = false;
}
} else { } else {
this.nextBtn = false this.nextBtn = false;
} }
// console.log(this.pageAnswers) // console.log(this.pageAnswers)
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
......
...@@ -77,10 +77,12 @@ export class HealthComponent implements OnInit { ...@@ -77,10 +77,12 @@ export class HealthComponent implements OnInit {
}], }],
}; };
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
if (this.pageAnswers.questions[0].options.every((item) => { if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
return item.selected; if (this.pageAnswers.questions.every(item => item.options.length > 0)) {
})) { this.nextBtn = true;
this.nextBtn = true; } else {
this.nextBtn = false;
}
} else { } else {
this.nextBtn = false; this.nextBtn = false;
} }
...@@ -115,7 +117,11 @@ export class HealthComponent implements OnInit { ...@@ -115,7 +117,11 @@ export class HealthComponent implements OnInit {
if (this.type == 2 || this.type == 4) { if (this.type == 2 || this.type == 4) {
this.router.navigate(['/spouse_health'], {queryParams: {type: this.type}}); this.router.navigate(['/spouse_health'], {queryParams: {type: this.type}});
} else if (this.type == 3) { } else if (this.type == 3) {
this.router.navigate(['/children_health', 1], {queryParams: {type: this.type}}); this.router.navigate(['/children_health', 1], {
queryParams: {
type: this.type
}
});
} else if (this.type == 1) { } else if (this.type == 1) {
this.router.navigate(['/disease'], {queryParams: {type: this.type}}); this.router.navigate(['/disease'], {queryParams: {type: this.type}});
} }
...@@ -123,7 +129,11 @@ export class HealthComponent implements OnInit { ...@@ -123,7 +129,11 @@ export class HealthComponent implements OnInit {
if (this.type == 1 || this.type == 2) { if (this.type == 1 || this.type == 2) {
this.router.navigate(['/disease'], {queryParams: {type: this.type}}); this.router.navigate(['/disease'], {queryParams: {type: this.type}});
} else if (this.type == 3 || this.type == 4) { } else if (this.type == 3 || this.type == 4) {
this.router.navigate(['/children_health', 1], {queryParams: {type: this.type}}); this.router.navigate(['/children_health', 1], {
queryParams: {
type: this.type
}
});
} else { } else {
this.router.navigate(['/disease'], {queryParams: {type: this.type}}); this.router.navigate(['/disease'], {queryParams: {type: this.type}});
} }
......
...@@ -92,8 +92,12 @@ export class SmokingComponent implements OnInit { ...@@ -92,8 +92,12 @@ export class SmokingComponent implements OnInit {
} }
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
// console.log(this.pageAnswers); // console.log(this.pageAnswers);
if (this.pageAnswers['questions'].length > 0) { if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
this.nextBtn = true; if (this.pageAnswers.questions.every(item => item.options.length > 0)) {
this.nextBtn = true;
} else {
this.nextBtn = false;
}
} else { } else {
this.nextBtn = false; this.nextBtn = false;
} }
...@@ -126,8 +130,12 @@ export class SmokingComponent implements OnInit { ...@@ -126,8 +130,12 @@ export class SmokingComponent implements OnInit {
options: this.questions options: this.questions
}], }],
}; };
if (this.pageAnswers['questions'].length > 0) { if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
this.nextBtn = true; if (this.pageAnswers.questions.every(item => item.options.length > 0)) {
this.nextBtn = true;
} else {
this.nextBtn = false;
}
} else { } else {
this.nextBtn = false; this.nextBtn = false;
} }
......
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