Commit f4c962bf by Chao Sun

部分逻辑

parent 9391fe3e
......@@ -63,8 +63,17 @@
*ngIf="curPage == 13"
(getAllAnswer)="getAllAnswer($event)"
></app-page14>
<app-page15 [curPageData]="curPageData" *ngIf="curPage == 14"></app-page15>
<app-page16 [curPageData]="curPageData" *ngIf="curPage == 15"></app-page16>
<app-page15
[curPageData]="curPageData"
*ngIf="curPage == 14"
(getAllAnswer)="getAllAnswer($event)"
></app-page15>
<app-page16
[curPageData]="curPageData"
*ngIf="curPage == 15"
(getAllAnswer)="getAllAnswer($event)"
[provinceList] = "provinceList"
></app-page16>
<app-page17 [curPageData]="curPageData" *ngIf="curPage == 16"></app-page17>
<div class="footer" *ngIf="curPage == 0" (click)="addPage()">
<div>获取家庭分析报告</div>
......
......@@ -15,6 +15,8 @@ export class AskComponent implements OnInit {
allAnswers: Array<any>
isShowChildAgeBtn: boolean
hasMate: boolean
//获取省份
provinceList: Array<any>
constructor(private commonService: CommonService) {}
ngOnInit() {
......@@ -34,6 +36,11 @@ export class AskComponent implements OnInit {
this.curPageData = this.allQues[this.curPage]
}
})
this.commonService.provinceqry({ insurerId: 11 }).subscribe(res => {
if (res['success']) {
this.provinceList = res['data'].provinceList
}
})
}
reducePage() {
if (this.curPage > 0) {
......@@ -43,7 +50,11 @@ export class AskComponent implements OnInit {
return
}
}
filterItems() {
return this.allAnswers.filter(item=> {
return item !=null
})
}
addPage() {
if (this.curPage < 16) {
if (
......@@ -59,6 +70,19 @@ export class AskComponent implements OnInit {
this.curPage = 0
return
}
const answerParam = {
"survey":{
"customerId": 20,
"orderId":9999996,
"pages":this.filterItems()
}
}
console.log(answerParam)
if(this.curPage==16){
this.commonService.saveCustomerAnwers(answerParam).then(res => {
console.log(res)
})
}
console.log(this.curPage)
}
getAllAnswer(e) {
......@@ -94,14 +118,18 @@ export class AskComponent implements OnInit {
thePateData
)
}
console.log('page start', this.curPage)
if (this.curPage == 13) {
console.log('page end', this.curPage)
this.filterPage14(
page2Answer.questions[0].options[0].optionId,
this.allQues[this.curPage]
)
}
if(this.curPage == 14){
this.filterPage15(
page2Answer.questions[0].options[0].optionId,
this.allQues[this.curPage]
)
}
}
filterPage2(optionId, thePateData) {
......@@ -174,15 +202,17 @@ export class AskComponent implements OnInit {
}
}
//page14判断option内容
//page14判断是否住院option内容
filterPage14(optionId, thePateData) {
//如果单身或者单亲选择相中没有配偶选项
//传一个optionType告诉子页面是单选还是多选1表示单选2表示多选
if (optionId == 1) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType:1,
options: thePateData.questions[0]['options'].filter(option => {
return option.optionId == 106 || option.optionId == 107
})
......@@ -196,6 +226,7 @@ export class AskComponent implements OnInit {
questions: [
{
...thePateData.questions[0],
optionType:2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
......@@ -213,6 +244,7 @@ export class AskComponent implements OnInit {
questions: [
{
...thePateData.questions[0],
optionType:2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
......@@ -230,6 +262,7 @@ export class AskComponent implements OnInit {
questions: [
{
...thePateData.questions[0],
optionType:2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
......@@ -243,4 +276,80 @@ export class AskComponent implements OnInit {
}
}
}
//判断是否吸烟option内容
filterPage15(optionId,thePateData){
//如果单身或者单亲选择相中没有配偶选项
//传一个optionType告诉子页面是单选还是多选1表示单选2表示多选
if (optionId == 1) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType:1,
options: thePateData.questions[0]['options'].filter(option => {
return option.optionId == 112 || option.optionId == 113
})
}
]
}
}
if (optionId == 2) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType:2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 114 ||
option.optionId == 115 ||
option.optionId == 117
)
})
}
]
}
}
if (optionId == 3) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType:2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 114 ||
option.optionId == 116 ||
option.optionId == 117
)
})
}
]
}
}
if (optionId == 4) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType:2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 114 ||
option.optionId == 115 ||
option.optionId == 116 ||
option.optionId == 117
)
})
}
]
}
}
}
}
......@@ -31,6 +31,15 @@ export class CommonService {
});
}
async saveCustomerAnwers(objParam){
const url = this.USER_API_URL + '/survey/saveCustomerAnwers';
const res = await this.obtainToken();
this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']);
return this.http
.post(url, JSON.stringify(objParam),this.httpOptions).toPromise().then(response => {
return response;
});
}
// async getAllInfo(){
// const res = await this.surveyInfo()
// if(res['success']){
......
......@@ -20,25 +20,42 @@ export class Page11Component implements OnInit {
getAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
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)
}
}
let index;
// 当选中无疾病时
if(options['optionId']==67 && options['selected']==true){
index = this.allOptions.indexOf(options);
this.allOptions[i]['selected'] = false;
if(index > -1){
this.allOptions[index]['selected'] = true;
}
}else{
// 选中其他疾病时,无疾病状态改为false
if(this.allOptions[i]['optionId']==67){
this.allOptions[i]['selected'] = false;
}
}
}
console.log(this.allOptions)
// 删掉未选中的疾病
// 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)
// }
// }
// }
// if (!this.allOption[options['optionId']]) {
// this.allOption[options['optionId']] = {}
// }
......@@ -56,15 +73,28 @@ export class Page11Component implements OnInit {
// options: this.allOption[questionId]
// }
// })
// const result = this.allOptions.filter(item=>{
// item.selected==true
// })
// console.log(result)
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.allOptions
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
filterItems() {
return this.allOptions.filter(item=> {
return item['selected']==true;
})
}
}
......@@ -13,37 +13,52 @@ export class Page12Component implements OnInit {
ngOnInit() {
this.allOptions = []
console.log(this.curPageData)
}
getAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
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)
}
}
let index;
// 当选中无疾病时
if(options['optionId']==83 && options['selected']==true){
index = this.allOptions.indexOf(options);
this.allOptions[i]['selected'] = false;
if(index > -1){
this.allOptions[index]['selected'] = true;
}
}else{
// 选中其他疾病时,无疾病状态改为false
if(this.allOptions[i]['optionId']==83){
this.allOptions[i]['selected'] = false;
}
}
}
console.log(this.allOptions)
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.allOptions
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
filterItems() {
return this.allOptions.filter(item=> {
return item['selected']==true;
})
}
}
......@@ -12,37 +12,51 @@ export class Page13Component implements OnInit {
ngOnInit() {
this.allOptions = []
console.log(this.curPageData)
}
getAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
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)
}
}
let index;
// 当选中无疾病时
if(options['optionId']==99 && options['selected']==true){
index = this.allOptions.indexOf(options);
this.allOptions[i]['selected'] = false;
if(index > -1){
this.allOptions[index]['selected'] = true;
}
}else{
// 选中其他疾病时,无疾病状态改为false
if(this.allOptions[i]['optionId']==99){
this.allOptions[i]['selected'] = false;
}
}
}
console.log(this.allOptions)
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.allOptions
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
filterItems() {
return this.allOptions.filter(item=> {
return item['selected']==true;
})
}
}
......@@ -6,9 +6,9 @@
</div>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(options)"
[ngClass]="{ selected: options['selected'] == true }"
(click)="checkFun(options)"
>
{{ options.optionName }}
</li>
......
......@@ -8,22 +8,118 @@ import { Component, OnInit ,Input, Output, EventEmitter} from '@angular/core';
export class Page14Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
selectedObj:Object;
allOptions: Array<any>
optionType:number
constructor() { }
ngOnInit() {
console.log(this.curPageData)
//拿到数据中是多选还是单选2表示多选1表示单选
this.optionType = this.curPageData['questions'][0].optionType
console.log(this.optionType)
if(this.optionType==1){
this.selectedObj = {}
this.setOptionSelected()
}
if(this.optionType==2){
this.allOptions = []
}
}
getAnswer(option) {
getManyAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push
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++) {
let index;
// 当选中无疾病时
if(options['optionId']==111 && options['selected']==true){
index = this.allOptions.indexOf(options);
this.allOptions[i]['selected'] = false;
if(index > -1){
this.allOptions[index]['selected'] = true;
}
}else{
// 选中其他疾病时,无疾病状态改为false
if(this.allOptions[i]['optionId']==111){
this.allOptions[i]['selected'] = false;
}
}
}
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
option: [option]
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
filterItems() {
return this.allOptions.filter(item=> {
return item['selected']==true;
})
}
//单选调用的方法
getAnswer(options) {
if(!this.selectedObj['selected']){
this.selectedObj = options
options['selected'] = true;
}else{
if(this.selectedObj['optionId']!=options.optionId){
this.selectedObj['selected'] = false;
options['selected'] = true;
this.selectedObj = options
}
}
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
options: [options]
}
]
}
this.getAllAnswer.emit(ret)
}
setOptionSelected() {
const options = this.curPageData['questions'][0].options
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedObj = option
}
})
}
//判断用哪个方法
checkFun(options){
if(this.optionType==1){
this.getAnswer(options)
}
if(this.optionType==2){
this.getManyAnswer(options)
}
}
}
......@@ -2,13 +2,13 @@
<div class="layout">
<div class="content">
<div class="questionTitle smokeTitle">
{{ this.curPageData['questions'][0]['questionName'] }}
{{ this.curPageData['pageName'] }}
</div>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(options)"
[ngClass]="{ selected: options['selected'] == true }"
(click)="checkFun(options)"
>
{{ options.optionName }}
</li>
......
......@@ -10,22 +10,119 @@ export class Page15Component implements OnInit {
@Output() getAllAnswer = new EventEmitter<any>()
curQues: Object
curAllQues: Object
optionType:number
selectedObj:Object;
allOptions: Array<any>
constructor() { }
ngOnInit() {
console.log(this.curPageData)
//拿到数据中是多选还是单选2表示多选1表示单选
this.optionType = this.curPageData['questions'][0].optionType
console.log(this.optionType)
if(this.optionType==1){
this.selectedObj = {}
this.setOptionSelected()
}
if(this.optionType==2){
this.allOptions = []
}
}
getManyAnswer(options) {
console.log(options)
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push
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++) {
let index;
// 当选中无疾病时
if(options['optionId']==117 && options['selected']==true){
index = this.allOptions.indexOf(options);
this.allOptions[i]['selected'] = false;
if(index > -1){
this.allOptions[index]['selected'] = true;
}
}else{
// 选中其他疾病时,无疾病状态改为false
if(this.allOptions[i]['optionId']==117){
this.allOptions[i]['selected'] = false;
}
}
}
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
getAnswer(option){
const questionId = this.curQues['questionId']
this.curAllQues[questionId] = option
const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: this.curAllQues[questionId] }
filterItems() {
return this.allOptions.filter(item=> {
return item['selected']==true;
})
}
//单选调用的方法
getAnswer(options) {
if(!this.selectedObj['selected']){
this.selectedObj = options
options['selected'] = true;
}else{
if(this.selectedObj['optionId']!=options.optionId){
this.selectedObj['selected'] = false;
options['selected'] = true;
this.selectedObj = options
}
}
const ret = {
pageId: 15,
questions
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
options: [options]
}
]
}
this.getAllAnswer.emit(ret)
}
setOptionSelected() {
const options = this.curPageData['questions'][0].options
console.log(this.curPageData['questions'][0])
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedObj = option
}
})
}
//判断用哪个方法
checkFun(options){
if(this.optionType==1){
this.getAnswer(options)
}
if(this.optionType==2){
this.getManyAnswer(options)
}
}
}
......@@ -5,24 +5,31 @@
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="cityContent">
<li *ngFor="let provinces of this.provinceList" (click)="showToast()">
<li
*ngFor="let provinces of this.provinceList"
[ngClass]="{ selected: provinces['selected'] == true }"
(click)="showToast();selectProvince(provinces)">
{{ provinces.provinceAbbr }}
</li>
</ul>
<div class="address" *ngIf="this.showAddress">
{{this.strAddress}}
</div>
</div>
</div>
<div class="toastWrapper toast" *ngIf="isShow">
<div class="toastContent">
<div class="toastContent city">
<div class="live">所在地区</div>
<div class="province">
<span>{{this.provinceName}}</span>
</div>
<ul class="city">
<li class="selected" (click)="closeToast()">舟山市</li>
<li>台州市</li>
<li>宁波市</li>
<li>杭州市</li>
<li>温州市</li>
<li>嘉兴市</li>
<li>湖州市</li>
<li>绍兴市</li>
<li
*ngFor="let city of this.cityList"
(click)="closeToast();selectCity(city);getAnswer(city)"
>
{{city.cityName}}
</li>
</ul>
</div>
</div>
......
import { Component, OnInit, Input } from '@angular/core'
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
import { CommonService } from '../common.service'
@Component({
......@@ -8,42 +8,108 @@ import { CommonService } from '../common.service'
})
export class Page16Component implements OnInit {
@Input() curPageData: Array<any>
//获取省份
@Input() provinceList: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
isShow: boolean
provinceList: Array<any>
cityList: Array<any>
provinceId: number
provinceName:string;
//具体地址显示
showAddress:boolean;
address:Object;
selectedProvinceObj:Object;
selectedCityObj:Object;
strAddress:string;
constructor(private commonService: CommonService) {}
ngOnInit() {
this.selectedProvinceObj = {}
this.selectedCityObj = {}
console.log(this.curPageData)
this.provinceqry()
this.showAddress = false;
this.setOptionSelected()
}
showToast() {
this.isShow = true
}
selectProvince(option){
if(!this.selectedProvinceObj['selected']){
this.selectedProvinceObj = option
option['selected'] = true;
}else{
if(this.selectedProvinceObj['provinceId']!=option.provinceId){
this.selectedProvinceObj['selected'] = false;
option['selected'] = true;
this.selectedProvinceObj = option
}
}
console.log(this.selectedProvinceObj)
this.provinceName = option.provinceName
this.provinceId = option.provinceId
this.getCityqry()
}
closeToast() {
this.isShow = false
}
provinceqry() {
this.commonService.provinceqry({ insurerId: 14 }).subscribe(res => {
if (res['success']) {
this.provinceList = res['data'].provinceList
console.log(this.provinceList)
}
})
}
getCityqry() {
const param = {
insurerId: 14,
insurerId: 11,
provinceId: this.provinceId
}
this.commonService.provinceqry(param).subscribe(res => {
this.commonService.getCityqry(param).subscribe(res => {
if (res['success']) {
console.log(res)
this.cityList = res['data'].cityList
console.log(this.cityList)
}
})
}
selectCity(e){
this.showAddress = true;
this.strAddress = this.provinceName + e.cityName
this.address = {
'customerInput': this.provinceName +',' + e.cityName
}
}
getAnswer(option) {
if(!this.selectedCityObj['selected']){
this.selectedCityObj = option
option['selected'] = true;
}else{
if(this.selectedCityObj['optionId']!=option.optionId){
this.selectedCityObj['selected'] = false;
option['selected'] = true;
this.selectedCityObj = option
}
}
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: [this.address]
}
]
}
this.getAllAnswer.emit(ret)
}
setOptionSelected() {
const options = this.provinceList
console.log(options)
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedProvinceObj = option
}
})
}
}
......@@ -3,12 +3,11 @@
<div class="questionTitle">{{ this.curPageData['pageName'] }}</div>
<ul class="option_item">
<li
*ngFor="let options of this.curPageData['questions'][0].options"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(options)"
>
<img
[ngClass]="{'selected':this.selectedNum === options.optionId}"
(click)="changeStyle(options.optionId)"
[ngClass]="{ selected: options['selected'] == true }"
src="assets/images/icon{{ options.optionId }}.png"
alt="{{ options.optionName }}"
/>
......
......@@ -8,13 +8,24 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page2Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
selectedNum:number;
selectedObj:Object;
constructor() {}
ngOnInit() {
console.log(this.curPageData)
this.selectedObj = {}
this.setOptionSelected()
}
getAnswer(option) {
if(!this.selectedObj['selected']){
this.selectedObj = option
option['selected'] = true;
}else{
if(this.selectedObj['optionId']!=option.optionId){
this.selectedObj['selected'] = false;
option['selected'] = true;
this.selectedObj = option
}
}
const ret = {
pageId: this.curPageData['pageId'],
questions: [
......@@ -27,8 +38,15 @@ export class Page2Component implements OnInit {
this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
//当前选中项
this.selectedNum = optionId
setOptionSelected() {
const options = this.curPageData['questions'][0].options
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedObj = option
}
})
}
}
......@@ -4,9 +4,9 @@
<div class="questionTitle">{{ this.curPageData['pageName'] }}</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(options);changeStyle(options.optionId)"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
......
......@@ -8,13 +8,24 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page4Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
selectedNum:number;
selectedObj:Object;
constructor() {}
ngOnInit() {
console.log(this.curPageData)
this.selectedObj = {}
this.setOptionSelected()
}
getAnswer(option) {
if(!this.selectedObj['selected']){
this.selectedObj = option
option['selected'] = true;
}else{
if(this.selectedObj['optionId']!=option.optionId){
this.selectedObj['selected'] = false;
option['selected'] = true;
this.selectedObj = option
}
}
const ret = {
pageId: this.curPageData['pageId'],
questions: [
......@@ -26,8 +37,16 @@ export class Page4Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
//当前选中项
this.selectedNum = optionId
setOptionSelected() {
const options = this.curPageData['questions'][0].options
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedObj = option
}
})
}
}
......@@ -8,9 +8,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(options);changeStyle(options.optionId)"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
......
......@@ -8,13 +8,24 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page5Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
selectedNum:number;
selectedObj:Object;
constructor() {}
ngOnInit() {
console.log(this.curPageData)
this.selectedObj = {}
this.setOptionSelected()
}
getAnswer(option) {
if(!this.selectedObj['selected']){
this.selectedObj = option
option['selected'] = true;
}else{
if(this.selectedObj['optionId']!=option.optionId){
this.selectedObj['selected'] = false;
option['selected'] = true;
this.selectedObj = option
}
}
const ret = {
pageId: this.curPageData['pageId'],
questions: [
......@@ -26,8 +37,15 @@ export class Page5Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
//当前选中项
this.selectedNum = optionId
setOptionSelected() {
const options = this.curPageData['questions'][0].options
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedObj = option
}
})
}
}
......@@ -6,10 +6,9 @@
</div>
<ul class="income">
<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="income" *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,19 +10,27 @@ export class Page7Component 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)
console.log(this.hasMate)
this.selectedObj = {}
this.setOptionSelected()
}
getAnswer(question, options) {
console.log('page7', question, options)
//获取当前页面问题id
const questionId = question['questionId']
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] }
......@@ -33,10 +41,21 @@ export class Page7Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
this.selectedNum = optionId
}
changeStyle2(optionId){
this.selectedTwo = optionId
setOptionSelected() {
const questions = this.curPageData['questions']
console.log(questions)
if (!questions) {
return
}
questions.map(question => {
question['options'].forEach(option => {
if (option['selected']) {
console.log(this.selectedObj)
this.selectedObj[question['questionId']] = option
}
})
})
}
}
......@@ -6,10 +6,9 @@
</div>
<ul class="income">
<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="income">
<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>
......
......@@ -11,15 +11,27 @@ export class Page8Component implements OnInit {
curAllQues: Object
selectedNum:number;
selectedTwo:number;
selectedObj: Object
constructor() {}
ngOnInit() {
this.curAllQues = {}
this.selectedObj = {}
this.setOptionSelected()
console.log(this.curPageData)
}
getAnswer(question, options) {
console.log('page8', question, options)
const questionId = question['questionId']
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] }
......@@ -30,11 +42,17 @@ export class Page8Component 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
}
})
})
}
}
......@@ -185,6 +185,9 @@ ul li,ol li{
background-color: #fff;
z-index: 20;
}
.toastContent.city{
margin: 0;
}
.toastContent .live{
display: flex;
height: 40px;
......@@ -194,9 +197,21 @@ ul li,ol li{
border-bottom: 1px rgb(220, 220, 220) solid;
font-size: 16px;
}
.toastContent ul{
.toastContent .province{
display: flex;
flex-wrap: wrap;
height: 40px;
line-height:40px;
}
.toastContent .province span{
width: 45%;
font-size:16px;
text-align: center;
}
/* .toastContent .province span.selected{
border-bottom:2px solid #ff0000;
} */
.toastContent ul{
width: 100%;
margin: 5% 0%;
}
.toastContent ul li{
......@@ -215,6 +230,8 @@ ul li,ol li{
}
.toastContent ul.city {
margin: 0;
overflow: auto;
max-height: 240px;
}
.toastContent ul.city li{
width: 100%;
......@@ -224,4 +241,9 @@ ul li,ol li{
margin: 0;
height:35px;
line-height:35px;
}
.address{
width: 80%;
margin:15% auto;
text-align: center;
}
\ No newline at end of file
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