Commit 5a751580 by Sweet Zhang

下一步的问题

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