Commit f4c962bf by Chao Sun

部分逻辑

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