Commit 869fa4ce by Sweet Zhang

健康

parent fa4d8075
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
<li <li
class="selected" class="selected"
*ngFor="let options of this.curPageData?.questions[0]['options']" *ngFor="let options of this.curPageData?.questions[0]['options']"
[ngClass]="{ selected: options['selected'] == true }" (click)="selectedHealth(options)"> [ngClass]="{ selected: options['selected'] == true }" (click)="selectedHealth(options,false)">
{{ options.optionName }} {{ options.optionName }}
</li> </li>
</ul> </ul>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;" (click)="before()">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步 </div> <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -23,6 +23,7 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -23,6 +23,7 @@ export class ChildrenHealthComponent implements OnInit {
// 暂存多个孩子的答案 // 暂存多个孩子的答案
childTotalQuestions: Array<any> = []; childTotalQuestions: Array<any> = [];
nextBtn: boolean = false; nextBtn: boolean = false;
lastQuestions: Array<any>;
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
...@@ -51,9 +52,12 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -51,9 +52,12 @@ export class ChildrenHealthComponent implements OnInit {
} }
// 选择健康情况(多选) // 选择健康情况(多选)
selectedHealth(option) { selectedHealth(option, lastFlag) {
// debugger;
if (lastFlag === false) {
option['selected'] = !option['selected'];
}
this.id = this.route.snapshot.params['childId']; this.id = this.route.snapshot.params['childId'];
option['selected'] = !option['selected'];
this.questions = []; this.questions = [];
this.getOptions(99, option); this.getOptions(99, option);
const questions = { const questions = {
...@@ -106,7 +110,36 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -106,7 +110,36 @@ export class ChildrenHealthComponent implements OnInit {
surveyInfo() { surveyInfo() {
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
this.curPageData = res['data']['survey'].pages['12'] this.curPageData = res['data']['survey'].pages['12'];
// debugger;
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 13).pop();
console.log(this.lastQuestions)
if (this.lastQuestions) {
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)
if (this.lastQuestions['questions'][i].questionSubId == this.curPageData['questions'][j].questionSubId) {
this.lastQuestions['questions'][i]['options'].forEach(option => {
if (Object.keys(option).indexOf('optionId') > -1) {
const targetObj = option;
this.curPageData['questions'][j]['options'].forEach(option => {
if (targetObj['optionId'] == option['optionId']) {
this.curPageData['questions'][j]['options'][this.curPageData['questions'][j]['options'].indexOf(option)] = targetObj;
}
});
this.selectedHealth(targetObj, true);
// console.log(this.targetObj);
}
});
}
}
}
}
}
console.log(this.curPageData) console.log(this.curPageData)
} }
}) })
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<ul class="jobContent"> <ul class="jobContent">
<li *ngFor="let options of this.curPageData?.questions[0]['options']" <li *ngFor="let options of this.curPageData?.questions[0]['options']"
[ngClass]="{ selected: options['selected'] == true}" [ngClass]="{ selected: options['selected'] == true}"
(click)="selectedHealth(options)"> (click)="selectedHealth(options,false)">
{{ options.optionName }} {{ options.optionName }}
</li> </li>
</ul> </ul>
......
...@@ -20,7 +20,7 @@ export class HealthComponent implements OnInit { ...@@ -20,7 +20,7 @@ export class HealthComponent implements OnInit {
questions: Array<any> = []; questions: Array<any> = [];
nextBtn: boolean = false; nextBtn: boolean = false;
lastQuestions: Array<any>; 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) {
...@@ -44,12 +44,12 @@ export class HealthComponent implements OnInit { ...@@ -44,12 +44,12 @@ export class HealthComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
if(this.id == 1){ if (this.id == 1) {
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 11).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 11).pop();
}else{ } else {
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 12).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 12).pop();
} }
this.surveyInfo(); this.surveyInfo();
} }
...@@ -58,36 +58,65 @@ export class HealthComponent implements OnInit { ...@@ -58,36 +58,65 @@ 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'];
if (this.lastQuestions) {
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { // console.log(this.lastQuestions)
console.log(this.lastQuestions) // console.log(this.curPageData)
console.log(this.curPageData) this.lastQuestions['questions'][i]['options'].forEach(option => {
this.lastQuestions['questions'][i]['options'].forEach(option => { if (Object.keys(option).indexOf('optionId') > -1) {
if(Object.keys(option).indexOf('optionId')>-1){ const targetObj = option;
this.targetObj = option this.curPageData['questions'][j]['options'].forEach(option => {
console.log(this.targetObj) if (targetObj['optionId'] == option['optionId']) {
} this.curPageData['questions'][j]['options'][this.curPageData['questions'][j]['options'].indexOf(option)] = targetObj;
// this.selectedHealth(this.targetObj); }
});
}); this.selectedHealth(targetObj, true);
// console.log(this.targetObj);
}
});
}
} }
} }
} }
} else { } else {
this.curPageData = res['data'].survey.pages['11']; this.curPageData = res['data'].survey.pages['11'];
if (this.lastQuestions) {
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) {
const targetObj = option;
this.curPageData['questions'][j]['options'].forEach(option => {
if (targetObj['optionId'] == option['optionId']) {
this.curPageData['questions'][j]['options'][this.curPageData['questions'][j]['options'].indexOf(option)] = targetObj;
}
});
this.selectedHealth(targetObj, true);
// console.log(this.targetObj);
}
});
}
}
}
}
} }
} }
}) })
} }
// 选择健康情况(多选) // 选择健康情况(多选)
selectedHealth(option) { selectedHealth(option, lastFlag) {
option['selected'] = !option['selected']; if (lastFlag === false) {
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) {
...@@ -101,6 +130,7 @@ export class HealthComponent implements OnInit { ...@@ -101,6 +130,7 @@ export class HealthComponent implements OnInit {
options: this.questions options: this.questions
}], }],
}; };
console.log(this.pageAnswers)
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
if (this.curPageData['questions'].length == this.pageAnswers.questions.length) { if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
if (this.pageAnswers.questions.every(item => item.options.length > 0)) { if (this.pageAnswers.questions.every(item => item.options.length > 0)) {
......
...@@ -14,7 +14,8 @@ export class LoanComponent implements OnInit { ...@@ -14,7 +14,8 @@ export class LoanComponent implements OnInit {
pageAnswers: any; pageAnswers: any;
nextBtn: boolean; nextBtn: boolean;
lastQuestions: Array<any>; lastQuestions: Array<any>;
targetObj:Object = {} targetObj: Object = {}
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
...@@ -34,7 +35,7 @@ export class LoanComponent implements OnInit { ...@@ -34,7 +35,7 @@ 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.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 8).pop();
this.surveyInfo(); this.surveyInfo();
} }
...@@ -43,22 +44,24 @@ export class LoanComponent implements OnInit { ...@@ -43,22 +44,24 @@ 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'];
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { if (this.lastQuestions) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
this.lastQuestions['questions'][i]['options'].forEach(option => { if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
if(Object.keys(option).indexOf('optionId')>-1){ this.lastQuestions['questions'][i]['options'].forEach(option => {
this.targetObj = option if (Object.keys(option).indexOf('optionId') > -1) {
} this.targetObj = option
this.selectedLoan(this.curPageData['questions'][j],this.targetObj); }
this.selectedLoan(this.curPageData['questions'][j], this.targetObj);
});
});
}
} }
} }
} }
} }
console.log(this.pageAnswers) // console.log(this.pageAnswers)
console.log(this.commonService.todos) // 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