Commit 9391fe3e by Chao Sun

fix: many bug

parent 3fba7ea1
import { Component, OnInit } from '@angular/core'
import { CommonService } from '../common.service'
import { Options } from 'selenium-webdriver/chrome'
@Component({
selector: 'app-ask',
templateUrl: './ask.component.html',
......@@ -17,7 +18,7 @@ export class AskComponent implements OnInit {
constructor(private commonService: CommonService) {}
ngOnInit() {
this.curPage = 10
this.curPage = 0
this.totalPage = 17
this.curPageData = []
this.allAnswers = []
......@@ -67,8 +68,8 @@ export class AskComponent implements OnInit {
setCurPageData() {
const thePateData = this.allQues[this.curPage]
console.log('thePateData------', this.curPage, thePateData)
this.curPageData = thePateData
const page2Answer = this.allAnswers[1]
this.curPageData = thePateData
const page2Answer = this.allAnswers[1]
if (this.curPage == 2) {
this.filterPage2(
page2Answer.questions[0].options[0].optionId,
......@@ -81,22 +82,24 @@ export class AskComponent implements OnInit {
thePateData
)
}
if(this.curPage == 11){
if (this.curPage == 11) {
this.filterPage12(
page2Answer.questions[0].options[0].optionId,
thePateData
)
}
if(this.curPage == 12){
if (this.curPage == 12) {
this.filterPage13(
page2Answer.questions[0].options[0].optionId,
thePateData
)
}
if(this.curPage ==14){
this.filterPage15(
console.log('page start', this.curPage)
if (this.curPage == 13) {
console.log('page end', this.curPage)
this.filterPage14(
page2Answer.questions[0].options[0].optionId,
thePateData
this.allQues[this.curPage]
)
}
}
......@@ -156,41 +159,87 @@ export class AskComponent implements OnInit {
}
//pege12判断是否显示配偶健康
filterPage12(optionId, thePateData){
filterPage12(optionId, thePateData) {
if (optionId == 1 || optionId == 3) {
this.curPage++
console.log('page12', this.curPage, this.curPageData)
this.curPageData = this.allQues[this.curPage]
}
}
//page13判断是否显示孩子健康
filterPage13(optionId, thePateData){
filterPage13(optionId, thePateData) {
//单身或二人世界
if (optionId == 1 || optionId ==2) {
if (optionId == 1 || optionId == 2) {
this.curPage++
console.log('page13', this.curPage, this.curPageData)
this.curPageData = this.allQues[this.curPage]
}
}
//page15判断option内容
filterPage15(optionId,thePateData){
//page14判断option内容
filterPage14(optionId, thePateData) {
//如果单身或者单亲选择相中没有配偶选项
if(optionId == 1 || optionId == 3){
if (optionId == 1) {
this.curPageData = {
...thePateData,
questions:thePateData.questions[0]['options'].filter(option=>{
return option.optionId == 108 || option.optionId==109
})
questions: [
{
...thePateData.questions[0],
options: thePateData.questions[0]['options'].filter(option => {
return option.optionId == 106 || option.optionId == 107
})
}
]
}
}
if(optionId==2 || optionId==4){
if (optionId == 2) {
this.curPageData = {
...thePateData,
questions:thePateData.questions[0]['options'].filter(option=>{
return option.optionId == 110 || option.optionId == 111 || option.optionId == 112
})
questions: [
{
...thePateData.questions[0],
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
option.optionId == 109 ||
option.optionId == 111
)
})
}
]
}
}
if (optionId == 3) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
option.optionId == 110 ||
option.optionId == 111
)
})
}
]
}
}
if (optionId == 4) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
option.optionId == 109 ||
option.optionId == 110 ||
option.optionId == 111
)
})
}
]
}
}
}
......
......@@ -7,8 +7,9 @@
<ul class="jobContent">
<li
*ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{'selected':options['selected']==true}"
(click)="getAnswer(options);changeStyle(options.optionId)">
[ngClass]="{ selected: options['selected'] == true }"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
</ul>
......
......@@ -8,36 +8,35 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page11Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
allOption: object
selectedNum:number;
allOptions:Array<any>;
// allOption: object
allOptions: Array<any>
constructor() {}
ngOnInit() {
this.allOption = {};
this.allOptions = [];
// this.allOption = {}
this.allOptions = []
console.log(this.curPageData)
}
getAnswer(options) {
options['selected'] = !options['selected'];
for(let i=0;i<this.allOptions.length;i++){
if(options['optionId'] == this.allOptions[i]['optionId']){
let index = this.allOptions.indexOf(this.allOptions[i]);
if(index>-1){
this.allOptions.splice(index,1)
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
this.allOptions.push(options);
for(let i=0;i<this.allOptions.length;i++){
if(!this.allOptions[i]['selected']){
let index = this.allOptions.indexOf(this.allOptions[i]);
if(index>-1){
this.allOptions.splice(index,1)
this.allOptions.push(options)
for (let i = 0; i < this.allOptions.length; i++) {
if (!this.allOptions[i]['selected']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
console.log(this.allOptions)
// if (!this.allOption[options['optionId']]) {
......@@ -57,19 +56,15 @@ export class Page11Component implements OnInit {
// options: this.allOption[questionId]
// }
// })
// const ret = {
// pageId: this.curPageData['pageId'],
// questions: [
// {
// questionId: this.curPageData['questions'][0].questionId,
// options: options_ret
// }
// ]
// }
// this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
this.selectedNum = optionId
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
options: this.allOptions
}
]
}
this.getAllAnswer.emit(ret)
}
}
......@@ -4,14 +4,16 @@
<div class="questionTitle">
{{ this.curPageData['questions'][0]['questionName'].substring(0, 1) }}
<span>
{{ this.curPageData['questions'][0]['questionName'].substring(1, 3) }}</span
{{
this.curPageData['questions'][0]['questionName'].substring(1, 3)
}}</span
>
{{ this.curPageData['questions'][0]['questionName'].substring(3, 8) }}
</div>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
(click)="getAnswer(options)"
>
{{ options.optionName }}
......
import { Component, OnInit, Input , Output, EventEmitter} from '@angular/core'
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({
selector: 'app-page12',
......@@ -8,18 +8,39 @@ import { Component, OnInit, Input , Output, EventEmitter} from '@angular/core'
export class Page12Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
allOptions: Array<any>
constructor() {}
ngOnInit() {
this.allOptions = []
console.log(this.curPageData)
}
getAnswer(option) {
getAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
this.allOptions.push(options)
for (let i = 0; i < this.allOptions.length; i++) {
if (!this.allOptions[i]['selected']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
console.log(this.allOptions)
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
option: [option]
options: this.allOptions
}
]
}
......
......@@ -8,6 +8,7 @@
<li
class="selected"
*ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
(click)="getAnswer(options)"
>
{{ options.optionName }}
......
import { Component, OnInit, Input, Output, EventEmitter} from '@angular/core'
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({
selector: 'app-page13',
templateUrl: './page13.component.html',
......@@ -7,18 +7,39 @@ import { Component, OnInit, Input, Output, EventEmitter} from '@angular/core'
export class Page13Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
allOptions: Array<any>
constructor() {}
ngOnInit() {
this.allOptions = []
console.log(this.curPageData)
}
getAnswer(option) {
getAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
this.allOptions.push(options)
for (let i = 0; i < this.allOptions.length; i++) {
if (!this.allOptions[i]['selected']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
console.log(this.allOptions)
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
option: [option]
options: this.allOptions
}
]
}
......
......@@ -2,10 +2,11 @@
<div class="content">
<div class="questionTitle">{{ this.curPageData['pageName'] }}</div>
<ul class="ageContent">
<li *ngFor="let optionsList of this.curPageData['questions'];index as i">
<li *ngFor="let optionsList of this.curPageData['questions']; index as i">
<div>{{ optionsList.questionName }}</div>
<b (click)="showToast(optionsList)">
<span>{{optionsList.name}}</span>&gt;
<b (click)="showToast(optionsList, i)">
<span>{{ optionsList.name }}</span
>&gt;
</b>
</li>
</ul>
......@@ -18,10 +19,14 @@
<div class="toastContent">
<ul>
<li
[ngClass]="{'selected':this.selectedNum === options.optionId}"
[ngClass]="{ selected: this.selectedNum === options.optionId }"
*ngFor="let options of curQues.options"
(click)="closeToast(); getAnswer(options);changeStyle(options,options.optionId)"
>
(click)="
closeToast();
getAnswer(options);
changeStyle(options, options.optionId)
"
>
{{ options.optionName }}
</li>
</ul>
......
......@@ -13,19 +13,27 @@ export class Page3Component implements OnInit {
isShow: boolean
curQues: Object
curAllQues: Object
selectedNum:number;
options:Array<any>;
curQuesLen:number;
selectedNum: number
options: Array<any>
curQuesIndex: number
//当前问题长度
curQuesLen: number
//增加孩子点击次数
addChildCount: number
constructor() {}
ngOnInit() {
this.curQues = {}
this.curAllQues = {}
this.curQuesLen = this.curPageData['questions'].length;
this.curQuesLen = this.curPageData['questions'].length
//初始化增加孩子按钮可以点2次
this.addChildCount = 2
}
showToast(question) {
showToast(question, idx) {
this.isShow = true
this.curQues = question
this.curQuesIndex = idx
}
closeToast() {
this.isShow = false
......@@ -42,37 +50,88 @@ export class Page3Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(options,optionId){
changeStyle(options, optionId) {
//当前选中项
this.curPageData['questions'][this.curQuesIndex]['name'] =
options.optionName
this.selectedNum = optionId
for(let i=0;i<this.curPageData['questions'].length;i++){
for(let j=0;j<this.curPageData['questions'][i]['options'].length;j++){
if(options.optionId==this.curPageData['questions'][i].options[j].optionId){
this.curPageData['questions'].optionName = options.optionName;
this.curPageData['questions'][i]['name'] = this.curPageData['questions'][i].options[j].optionName
}
}
}
// for (let i = 0; i < this.curQuesLen; i++) {
// for (
// let j = 0;
// j < this.curPageData['questions'][i]['options'].length;
// j++
// ) {
// if (
// options.optionId ==
// this.curPageData['questions'][i].options[j].optionId
// ) {
// this.curPageData['questions'][i]['name'] = this.curPageData[
// 'questions'
// ][i].options[j].optionName
// }
// }
// }
}
addChild(){
this.curQuesLen++;
if(this.curQuesLen<5){
this.curPageData['questions'][this.curQuesLen-1] = {
questionId: 4,
questionName: "孩子"+(this.curQuesLen-1)+"年龄",
optionType: 1,
questionOrder: 4,
addChild() {
this.addChildCount--
if (this.addChildCount >= 0) {
this.curPageData['questions'][this.curQuesLen++] = {
questionId: 4,
questionName: `孩子${this.addChildCount == 1 ? '1' : '2'}年龄`,
optionType: 1,
questionOrder: 4,
options: [
{optionId: 22, optionName: "95后", optionOrder: 1, customerInput: null},
{optionId: 23, optionName: "90后", optionOrder: 2, customerInput: null},
{optionId: 24, optionName: "85后", optionOrder: 3, customerInput: null},
{optionId: 25, optionName: "80后", optionOrder: 4, customerInput: null},
{optionId: 26, optionName: "75后", optionOrder: 5, customerInput: null},
{optionId: 27, optionName: "70后", optionOrder: 6, customerInput: null},
{optionId: 28, optionName: "65后", optionOrder: 7, customerInput: null},
{optionId: 29, optionName: "60后", optionOrder: 8, customerInput: null}
{
optionId: 22,
optionName: '95后',
optionOrder: 1,
customerInput: null
},
{
optionId: 23,
optionName: '90后',
optionOrder: 2,
customerInput: null
},
{
optionId: 24,
optionName: '85后',
optionOrder: 3,
customerInput: null
},
{
optionId: 25,
optionName: '80后',
optionOrder: 4,
customerInput: null
},
{
optionId: 26,
optionName: '75后',
optionOrder: 5,
customerInput: null
},
{
optionId: 27,
optionName: '70后',
optionOrder: 6,
customerInput: null
},
{
optionId: 28,
optionName: '65后',
optionOrder: 7,
customerInput: null
},
{
optionId: 29,
optionName: '60后',
optionOrder: 8,
customerInput: null
}
]
}
}
......
......@@ -6,10 +6,9 @@
</div>
<ul class="jobContent">
<li
[ngClass]="{'selected':this.selectedNum === options.optionId}"
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(this.curPageData['questions'][0], options);
changeStyle(options.optionId)"
(click)="getAnswer(this.curPageData['questions'][0], options)"
>
{{ options.optionName }}
</li>
......@@ -19,10 +18,9 @@
</div>
<ul class="jobContent" *ngIf="hasMate">
<li
[ngClass]="{'selected':this.selectedTwo === options.optionId}"
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][1]['options']"
(click)="getAnswer(this.curPageData['questions'][1], options);
changeStyle2(options.optionId)"
(click)="getAnswer(this.curPageData['questions'][1], options)"
>
{{ options.optionName }}
</li>
......
......@@ -10,17 +10,27 @@ export class Page9Component implements OnInit {
@Input() hasMate: boolean
@Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object
selectedNum:number;
selectedTwo:number;
selectedObj: Object
constructor() {}
ngOnInit() {
this.curAllQues = {}
console.log(this.curPageData)
this.selectedObj = {}
this.setOptionSelected()
}
getAnswer(question, options) {
console.log('page9', question, options)
const questionId = question['questionId']
console.log('select', this.selectedObj, options)
if (!this.selectedObj[questionId]) {
this.selectedObj[questionId] = options
options['selected'] = true
} else {
if (this.selectedObj[questionId].optionId != options.optionId) {
this.selectedObj[questionId]['selected'] = false
options['selected'] = true
this.selectedObj[questionId] = options
}
}
this.curAllQues[questionId] = options
const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: this.curAllQues[questionId] }
......@@ -31,10 +41,17 @@ export class Page9Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
this.selectedNum = optionId
}
changeStyle2(optionId){
this.selectedTwo = optionId
setOptionSelected() {
const questions = this.curPageData['questions']
if (!questions) {
return
}
questions.map(question => {
question['options'].forEach(option => {
if (option['selected']) {
this.selectedObj[question['questionId']] = option
}
})
})
}
}
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