Commit 2ce358eb by Chao Sun

返回问题

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