Commit 2ce358eb by Chao Sun

返回问题

parent 80387efb
...@@ -121,7 +121,6 @@ export class AskComponent implements OnInit { ...@@ -121,7 +121,6 @@ export class AskComponent implements OnInit {
pages: this.filterItems() pages: this.filterItems()
} }
} }
console.log(answerParam)
if (this.curPage == 16) { if (this.curPage == 16) {
this.commonService.saveCustomerAnwers(answerParam).then(res => { this.commonService.saveCustomerAnwers(answerParam).then(res => {
...@@ -130,8 +129,9 @@ export class AskComponent implements OnInit { ...@@ -130,8 +129,9 @@ export class AskComponent implements OnInit {
} }
getAllAnswer(e) { getAllAnswer(e) {
this.questionInfo = e; this.questionInfo = e;
console.log(e)
const page2Answer = this.allAnswers[1]
if(this.curPage == 6 || this.curPage == 8){ if(this.curPage == 6 || this.curPage == 8){
const page2Answer = this.allAnswers[1]
const optionId = page2Answer.questions[0].options[0].optionId const optionId = page2Answer.questions[0].options[0].optionId
if(optionId==1 || optionId==3){ if(optionId==1 || optionId==3){
if(e['questions'].length>0){ if(e['questions'].length>0){
...@@ -140,7 +140,19 @@ export class AskComponent implements OnInit { ...@@ -140,7 +140,19 @@ export class AskComponent implements OnInit {
} }
} }
if(this.curPageData['questions'].length == e['questions'].length){ if(this.curPageData['questions'].length == e['questions'].length){
this.nextBtn = true for(let i=0;i<e['questions'].length;i++){
if(e['questions'][i]['options'].length>0){
for(let j=0;j<e['questions'][i]['options'].length;j++){
if(!e['questions'][i]['options'][j]['optionId']){
this.nextBtn = false
}else{
this.nextBtn = true
}
}
}
}
}else{
this.nextBtn = false
} }
} }
setCurPageData() { setCurPageData() {
......
...@@ -8,7 +8,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core' ...@@ -8,7 +8,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page2Component implements OnInit { export class Page2Component implements OnInit {
@Input() curPageData: Array<any> @Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
@Output() controlNext = new EventEmitter<any>()
selectedObj:Object; selectedObj:Object;
constructor() {} constructor() {}
...@@ -39,7 +39,6 @@ export class Page2Component implements OnInit { ...@@ -39,7 +39,6 @@ export class Page2Component implements OnInit {
// console.log(this.curPageData['questions']); // console.log(this.curPageData['questions']);
// console.log(ret.questions) // console.log(ret.questions)
this.getAllAnswer.emit(ret); this.getAllAnswer.emit(ret);
this.controlNext.emit();
// console.log(ret) // console.log(ret)
} }
......
...@@ -56,12 +56,13 @@ export class Page3Component implements OnInit { ...@@ -56,12 +56,13 @@ export class Page3Component implements OnInit {
const questions = Object.keys(this.curAllQues).map(questionId => { const questions = Object.keys(this.curAllQues).map(questionId => {
return {questionId, options: [this.curAllQues[questionId]]} return {questionId, options: [this.curAllQues[questionId]]}
}); });
for (let i = 0; i < questions.length; i++) {
for (let j = 0; j < this.questions.length; j++) { for (let j = 0; j < this.questions.length; j++) {
for (let i = 0; i < questions.length; i++) {
if (questions[i]['questionId'] != this.questions[j]['questionId']) { if (questions[i]['questionId'] != this.questions[j]['questionId']) {
questions.push(this.questions[j]); questions.push(this.questions[j]);
break; break;
} }
break;
} }
} }
const ret = { const ret = {
...@@ -86,7 +87,7 @@ export class Page3Component implements OnInit { ...@@ -86,7 +87,7 @@ export class Page3Component implements OnInit {
if (this.curPageData['questions'].length > 0) { if (this.curPageData['questions'].length > 0) {
for (let i = 0; i < this.curPageData['questions'].length; i++) { for (let i = 0; i < this.curPageData['questions'].length; i++) {
if (!this.curPageData['questions'][i]['name']) { if (!this.curPageData['questions'][i]['name']) {
return; break
} }
let option = {}; let option = {};
let question = { let question = {
......
...@@ -11,17 +11,16 @@ export class Page7Component implements OnInit { ...@@ -11,17 +11,16 @@ export class Page7Component implements OnInit {
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object curAllQues: Object
selectedObj: Object selectedObj: Object
selectedObj1:Object questions: Array<any>;
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
this.curAllQues = {} this.curAllQues = {}
this.selectedObj = {} this.selectedObj = {}
this.selectedObj1 = {} this.questions = []
this.setOptionSelected() this.setOptionSelected()
} }
getAnswer(question, options) { getAnswer(question, options) {
console.log(question,options)
//获取当前页面问题id //获取当前页面问题id
const questionId = question['questionId'] const questionId = question['questionId']
if (!this.selectedObj[questionId]) { if (!this.selectedObj[questionId]) {
...@@ -38,6 +37,16 @@ export class Page7Component implements OnInit { ...@@ -38,6 +37,16 @@ export class Page7Component implements OnInit {
const questions = Object.keys(this.curAllQues).map(questionId => { const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: [this.curAllQues[questionId]] } return { questionId, options: [this.curAllQues[questionId]] }
}) })
for (let j = 0; j < this.questions.length; j++) {
for (let i = 0; i < questions.length; i++) {
if (questions[i]['questionId'] != this.questions[j]['questionId']) {
questions.push(this.questions[j]);
break;
}
break;
}
}
const ret = { const ret = {
pageId: 7, pageId: 7,
questions questions
...@@ -46,18 +55,27 @@ export class Page7Component implements OnInit { ...@@ -46,18 +55,27 @@ export class Page7Component implements OnInit {
} }
setOptionSelected() { setOptionSelected() {
const questions = this.curPageData['questions'] const questions2 = this.curPageData['questions']
// console.log(questions) // console.log(questions)
if (!questions) { if (!questions2) {
return return
} }
questions.map(question => { questions2.map(question => {
question['options'].forEach(option => { question['options'].forEach(option => {
if (option['selected']) { if (option['selected']) {
// console.log(this.selectedObj)
this.selectedObj[question['questionId']] = option this.selectedObj[question['questionId']] = option
} }
}) })
}) })
const questions = Object.keys(this.selectedObj).map(questionId => {
return { questionId, options: [this.selectedObj[questionId]] }
})
this.questions = questions
const ret = {
pageId: 7,
questions
}
this.getAllAnswer.emit(ret)
} }
} }
...@@ -9,12 +9,13 @@ export class Page8Component implements OnInit { ...@@ -9,12 +9,13 @@ export class Page8Component implements OnInit {
@Input() curPageData: Array<any> @Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object curAllQues: Object
selectedNum: number
selectedTwo: number
selectedObj: Object selectedObj: Object
questions: Array<any>;
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
this.questions = [];
this.curAllQues = {} this.curAllQues = {}
this.selectedObj = {} this.selectedObj = {}
this.setOptionSelected() this.setOptionSelected()
...@@ -36,25 +37,43 @@ export class Page8Component implements OnInit { ...@@ -36,25 +37,43 @@ export class Page8Component implements OnInit {
const questions = Object.keys(this.curAllQues).map(questionId => { const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: [this.curAllQues[questionId]] } return { questionId, options: [this.curAllQues[questionId]] }
}) })
for (let j = 0; j < this.questions.length; j++) {
for (let i = 0; i < questions.length; i++) {
if (questions[i]['questionId'] != this.questions[j]['questionId']) {
questions.push(this.questions[j]);
break;
}
break;
}
}
const ret = { const ret = {
pageId: 8, pageId: 8,
questions questions
} }
// console.log(this.curPageData['questions']); // console.log(this.curPageData['questions']);
// console.log(ret.questions)
this.getAllAnswer.emit(ret) this.getAllAnswer.emit(ret)
} }
setOptionSelected() { setOptionSelected() {
const questions = this.curPageData['questions'] const questions2 = this.curPageData['questions']
if (!questions) { if (!questions2) {
return return
} }
questions.map(question => { questions2.map(question => {
question['options'].forEach(option => { question['options'].forEach(option => {
if (option['selected']) { if (option['selected']) {
this.selectedObj[question['questionId']] = option this.selectedObj[question['questionId']] = option
} }
}) })
}) })
const questions = Object.keys(this.selectedObj).map(questionId => {
return { questionId, options: [this.selectedObj[questionId]] }
})
this.questions = questions
const ret = {
pageId: 8,
questions
}
this.getAllAnswer.emit(ret)
} }
} }
...@@ -11,12 +11,15 @@ export class Page9Component implements OnInit { ...@@ -11,12 +11,15 @@ export class Page9Component implements OnInit {
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object curAllQues: Object
selectedObj: Object selectedObj: Object
questions: Array<any>;
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
this.curAllQues = {} this.curAllQues = {}
this.selectedObj = {} this.selectedObj = {}
this.questions = [];
this.setOptionSelected() this.setOptionSelected()
} }
getAnswer(question, options) { getAnswer(question, options) {
const questionId = question['questionId'] const questionId = question['questionId']
...@@ -35,6 +38,15 @@ export class Page9Component implements OnInit { ...@@ -35,6 +38,15 @@ export class Page9Component implements OnInit {
const questions = Object.keys(this.curAllQues).map(questionId => { const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: [this.curAllQues[questionId]] } return { questionId, options: [this.curAllQues[questionId]] }
}) })
for (let j = 0; j < this.questions.length; j++) {
for (let i = 0; i < questions.length; i++) {
if (questions[i]['questionId'] != this.questions[j]['questionId']) {
questions.push(this.questions[j]);
break;
}
break;
}
}
const ret = { const ret = {
pageId: 9, pageId: 9,
questions questions
...@@ -42,16 +54,26 @@ export class Page9Component implements OnInit { ...@@ -42,16 +54,26 @@ export class Page9Component implements OnInit {
this.getAllAnswer.emit(ret) this.getAllAnswer.emit(ret)
} }
setOptionSelected() { setOptionSelected() {
const questions = this.curPageData['questions'] const questions2 = this.curPageData['questions']
if (!questions) { if (!questions2) {
return return
} }
questions.map(question => { questions2.map(question => {
question['options'].forEach(option => { question['options'].forEach(option => {
if (option['selected']) { if (option['selected']) {
this.selectedObj[question['questionId']] = option this.selectedObj[question['questionId']] = option
} }
}) })
}) })
const questions = Object.keys(this.selectedObj).map(questionId => {
return { questionId, options: [this.selectedObj[questionId]] }
})
this.questions = questions
const ret = {
pageId: 9,
questions
}
this.getAllAnswer.emit(ret)
} }
} }
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