Commit f16774c7 by Chao Sun

合并冲突

parents 373a640a 869fa4ce
......@@ -8,14 +8,14 @@
<li
class="selected"
*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 }}
</li>
</ul>
</div>
<div class="content_footer">
<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>
......@@ -23,6 +23,7 @@ export class ChildrenHealthComponent implements OnInit {
// 暂存多个孩子的答案
childTotalQuestions: Array<any> = [];
nextBtn: boolean = false;
lastQuestions: Array<any>;
constructor(private commonService: CommonService,
private router: Router,
......@@ -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'];
option['selected'] = !option['selected'];
this.questions = [];
this.getOptions(99, option);
const questions = {
......@@ -106,7 +110,36 @@ export class ChildrenHealthComponent implements OnInit {
surveyInfo() {
this.commonService.surveyInfo().then(res => {
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)
}
})
......
......@@ -7,7 +7,7 @@
<ul class="jobContent">
<li *ngFor="let options of this.curPageData?.questions[0]['options']"
[ngClass]="{ selected: options['selected'] == true}"
(click)="selectedHealth(options)">
(click)="selectedHealth(options,false)">
{{ options.optionName }}
</li>
</ul>
......
......@@ -20,7 +20,7 @@ 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) {
......@@ -44,12 +44,12 @@ export class HealthComponent implements OnInit {
}
ngOnInit() {
if(this.id == 1){
if (this.id == 1) {
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.surveyInfo();
}
......@@ -58,36 +58,65 @@ 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);
});
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);
}
});
}
}
}
}
} else {
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) {
option['selected'] = !option['selected'];
selectedHealth(option, lastFlag) {
if (lastFlag === false) {
option['selected'] = !option['selected'];
}
this.questions = [];
console.log(option)
if (this.id == 1) {
this.getOptions(67, option);
} else if (this.id == 2) {
......@@ -101,6 +130,7 @@ export class HealthComponent implements OnInit {
options: this.questions
}],
};
console.log(this.pageAnswers)
this.commonService.addAnswer(this.pageAnswers);
if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
if (this.pageAnswers.questions.every(item => item.options.length > 0)) {
......
......@@ -14,7 +14,8 @@ export class LoanComponent implements OnInit {
pageAnswers: any;
nextBtn: boolean;
lastQuestions: Array<any>;
targetObj:Object = {}
targetObj: Object = {}
constructor(private commonService: CommonService,
private router: Router,
private route: ActivatedRoute) {
......@@ -34,7 +35,7 @@ export class LoanComponent implements OnInit {
ngOnInit() {
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();
}
......@@ -43,17 +44,17 @@ export class LoanComponent implements OnInit {
if (res['success']) {
this.curPageData = res['data']['survey'].pages['7'];
this.pageAnswers.pageId = this.curPageData['pageId'];
if(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) {
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);
});
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);
});
}
}
}
......@@ -61,8 +62,8 @@ export class LoanComponent implements OnInit {
return;
}
}
console.log(this.pageAnswers)
console.log(this.commonService.todos)
// 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