Commit fb3f4c19 by Chao Sun

修复多选问题

parent f93ab19e
......@@ -39,7 +39,7 @@ export class AskComponent implements OnInit {
this.curPageData = this.allQues[this.curPage]
}
})
this.commonService.provinceqry({ insurerId: 11 }).subscribe(res => {
this.commonService.provinceqry({ insurerId: 11 }).then(res => {
if (res['success']) {
this.provinceList = res['data'].provinceList
}
......@@ -92,7 +92,6 @@ export class AskComponent implements OnInit {
if(this.nextBtn===false){
return;
}
console.log(this.questionInfo)
this.allAnswers[this.curPage] = this.questionInfo;
if (this.curPage < 16) {
//判断当前页是否有答案
......@@ -124,35 +123,21 @@ export class AskComponent implements OnInit {
}
}
getAllAnswer(e) {
let result=false;
this.questionInfo = e;
console.log(e)
const questions = e.questions;
if(questions.length>0){
for(let i=0;i<questions.length;i++){
let options = questions[i].options;
if(options.length>0){
result = true;
}
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){
this.nextBtn = true
}
}
}
if (this.curPage < 16) {
//判断当前页是否有答案
if (
this.curPage == 0 ||
result ||
this.curPage == 5 ||
this.curPage == 9
) {
this.nextBtn = true;
}else{
this.nextBtn = false;
}
if(this.curPageData['questions'].length == e['questions'].length){
this.nextBtn = true
}
}
setCurPageData() {
// console.log(this.allAnswers)
const thePateData = this.allQues[this.curPage]
this.curPageData = thePateData
......
......@@ -40,12 +40,6 @@ export class CommonService {
return response;
});
}
// async getAllInfo(){
// const res = await this.surveyInfo()
// if(res['success']){
// this.questionList = res['data']['survey'].pages
// }
// }
/**
* 获取TOKEN
......@@ -62,7 +56,7 @@ export class CommonService {
const url = this.USER_API_URL + '/partner/provinceqry';
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).pipe(res => {
return this.http.post(url,JSON.stringify(objParam),this.httpOptions).toPromise().then(res => {
return res;
})
}
......@@ -73,7 +67,7 @@ export class CommonService {
this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']);
return this.http
.post(url,JSON.stringify(objParam),this.httpOptions)
.pipe(res => {
.toPromise().then(res => {
return res;
})
}
......
......@@ -10,6 +10,5 @@ export class Page10Component implements OnInit {
constructor() {}
ngOnInit() {
console.log(this.curPageData)
}
}
......@@ -19,7 +19,6 @@ export class Page11Component implements OnInit {
this.getAlloptions()
}
getAnswer(options) {
console.log(options)
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push
......@@ -47,39 +46,6 @@ export class Page11Component implements OnInit {
}
}
}
// 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']] = {}
// }
// console.log(this.allOption)
// this.allOption[options['optionId']] = {
// selected: !this.allOption[options['optionId']]['selected'],
// options
// }
// const options_ret = Object.keys(this.allOption)
// .filter(item => {
// return this.allOption[item]['selected']
// })
// .map(questionId => {
// return {
// options: this.allOption[questionId]
// }
// })
// const result = this.allOptions.filter(item=>{
// item.selected==true
// })
// console.log(result)
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
......@@ -101,18 +67,14 @@ export class Page11Component implements OnInit {
}
getAlloptions(){
// const questions = this.curPageData['questions']
// if(!questions){
// return
// }
// questions[0]['options'].forEach(option => {
// if(option['selected']){
// console.log(questions)
// this.allOptions = questions[0]['options']
// // console.log(questions[0]['options'])
// // console.log(this.allOptions[question])
// }
// });
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option)
}
});
}
}
......@@ -13,6 +13,7 @@ export class Page12Component implements OnInit {
ngOnInit() {
this.allOptions = []
this.getAlloptions()
}
getAnswer(options) {
options['selected'] = !options['selected']
......@@ -61,4 +62,16 @@ export class Page12Component implements OnInit {
return item['selected']==true;
})
}
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option)
}
});
}
}
......@@ -12,6 +12,7 @@ export class Page13Component implements OnInit {
ngOnInit() {
this.allOptions = []
this.getAlloptions()
}
getAnswer(options) {
options['selected'] = !options['selected']
......@@ -59,4 +60,15 @@ export class Page13Component implements OnInit {
return item['selected']==true;
})
}
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option)
}
});
}
}
......@@ -24,6 +24,7 @@ export class Page14Component implements OnInit {
}
if(this.optionType==2){
this.allOptions = []
this.getAlloptions()
}
}
......@@ -121,5 +122,15 @@ export class Page14Component implements OnInit {
this.getManyAnswer(options)
}
}
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option)
}
});
}
}
......@@ -26,6 +26,7 @@ export class Page15Component implements OnInit {
}
if(this.optionType==2){
this.allOptions = []
this.getAlloptions()
}
}
......@@ -124,5 +125,17 @@ export class Page15Component implements OnInit {
this.getManyAnswer(options)
}
}
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option)
}
});
}
}
......@@ -59,7 +59,7 @@ export class Page16Component implements OnInit {
insurerId: 11,
provinceId: this.provinceId
}
this.commonService.getCityqry(param).subscribe(res => {
this.commonService.getCityqry(param).then(res => {
if (res['success']) {
this.cityList = res['data'].cityList
// console.log(this.cityList)
......
......@@ -12,26 +12,26 @@
</li>
</ul>
</div>
<div class="addChild" *ngIf="isShowChildAgeBtn" (click)="addChild()">
<!-- <div class="addChild" *ngIf="isShowChildAgeBtn" (click)="addChild()">
<div class="icon">+</div>
<div data-toggle="modal">增加孩子年龄</div>
</div> -->
<div class="toastWrapper toast" *ngIf="isShow" (click)="closeToast()">
</div>
<div>{{result}}</div>
<div class="toastWrapper toast" *ngIf="isShow">
<div class="toastContent">
<ul>
<li
[ngClass]="{ selected: this.selectedNum === options.optionId }"
*ngFor="let options of curQues.options"
(click)="
closeToast();
getAnswer(options);
changeStyle(options, options.optionId)
"
>
{{ options.optionName }}
</li>
</ul>
</div>
</div>
</div>
<div class="toastContent" *ngIf="isShow">
<ul>
<li
[ngClass]="{ selected: this.curQuestionSelecte === options.optionName}"
*ngFor="let options of curQues.options"
(click)="
closeToast();
getAnswer(options);
changeStyle(options, options.optionId)
"
>
{{ options.optionName }}
</li>
</ul>
</div>
......@@ -20,6 +20,7 @@ export class Page3Component implements OnInit {
curQuesLen: number
//增加孩子点击次数
addChildCount: number
curQuestionSelecte:string;
constructor() {}
ngOnInit() {
......@@ -33,6 +34,8 @@ export class Page3Component implements OnInit {
this.isShow = true
this.curQues = question
this.curQuesIndex = idx
// console.log(question)
this.curQuestionSelecte = question.name
}
closeToast() {
this.isShow = false
......@@ -55,23 +58,6 @@ export class Page3Component implements OnInit {
this.curPageData['questions'][this.curQuesIndex]['name'] =
options.optionName
this.selectedNum = optionId
// 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() {
......
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