Commit c5004ead authored by wangqinghua's avatar wangqinghua

color

parent d16ab6c0
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
<ion-item> <ion-item>
<ion-label class="set-font" color="primary">必须回答</ion-label> <ion-label class="set-font" color="primary">必须回答</ion-label>
<ion-toggle checked="false"></ion-toggle> <ion-toggle *ngIf="isAns == 2" [checked]="false" (ionChange)="isAnsChange(1)"></ion-toggle>
<ion-toggle *ngIf="isAns == 1" [checked]="true" (ionChange)="isAnsChange(2)"></ion-toggle>
</ion-item> </ion-item>
<!--多选题--> <!--多选题-->
......
...@@ -20,6 +20,7 @@ export class CreatePage { ...@@ -20,6 +20,7 @@ export class CreatePage {
temp; //问卷信息 temp; //问卷信息
title; //标题 title; //标题
index = 0; //序号 index = 0; //序号
isAns = 2; //是否必答
quesDescList = []; quesDescList = [];
set = { //设置 set = { //设置
lastchange: '1', lastchange: '1',
...@@ -34,13 +35,15 @@ export class CreatePage { ...@@ -34,13 +35,15 @@ export class CreatePage {
ionViewDidLoad() { ionViewDidLoad() {
this.temp = this.navParams.get('temp'); //问卷信息 this.temp = this.navParams.get('temp'); //问卷信息
if(this.navParams.get('edit')){ //编辑 if (this.navParams.get('edit')) { //编辑
this.editTemp = this.navParams.get('edit'); this.editTemp = this.navParams.get('edit');
this.editIndex = this.navParams.get('index'); this.editIndex = this.navParams.get('index');
this.qType = this.editTemp[this.editIndex].quesType; this.qType = this.editTemp[this.editIndex].quesType;
this.title = this.editTemp[this.editIndex].title; this.title = this.editTemp[this.editIndex].title;
this.isAns = this.editTemp[this.editIndex].isAns;
this.quesDescList = this.editTemp[this.editIndex].quesDesc; this.quesDescList = this.editTemp[this.editIndex].quesDesc;
}else{ //新增 console.log(this.editTemp[this.editIndex]);
} else { //新增
this.qType = this.navParams.get('type'); //题目类型 this.qType = this.navParams.get('type'); //题目类型
} }
} }
...@@ -52,7 +55,7 @@ export class CreatePage { ...@@ -52,7 +55,7 @@ export class CreatePage {
isNeed: 1, // 1是 2否 isNeed: 1, // 1是 2否
index: this.index index: this.index
}; //序号 }; //序号
this.index ++; this.index++;
this.quesDescList.push(option); this.quesDescList.push(option);
} }
...@@ -60,13 +63,19 @@ export class CreatePage { ...@@ -60,13 +63,19 @@ export class CreatePage {
this.quesDescList.splice(i, 1); this.quesDescList.splice(i, 1);
} }
//是否必答
isAnsChange(type){
this.isAns = type;
}
//提交编辑问卷 //提交编辑问卷
submitEdit(){ submitEdit() {
if( !this.check() ){ if (!this.check()) {
return false; return false;
} }
let newArr = []; let newArr = [];
this.editTemp[this.editIndex].title = this.title; this.editTemp[this.editIndex].title = this.title;
this.editTemp[this.editIndex].isAns = this.isAns;
for (let i = 0; i < this.editTemp.length; i++) { for (let i = 0; i < this.editTemp.length; i++) {
const arr = { const arr = {
questionId: this.temp.id, questionId: this.temp.id,
...@@ -104,11 +113,11 @@ export class CreatePage { ...@@ -104,11 +113,11 @@ export class CreatePage {
//提交问卷 //提交问卷
submit() { submit() {
if( !this.check() ){ if (!this.check()) {
return false; return false;
} }
if( this.qType == 1 ){ if (this.qType == 1) {
const option1 = { const option1 = {
option_title: '是', //选项文字 option_title: '是', //选项文字
canFill: 2, // 1是 2否 canFill: 2, // 1是 2否
...@@ -157,24 +166,24 @@ export class CreatePage { ...@@ -157,24 +166,24 @@ export class CreatePage {
} }
//校验 //校验
check(){ check() {
if(!this.title){ if (!this.title) {
this.appService.popToastView('请输入标题','middle',1000); this.appService.popToastView('请输入标题', 'middle', 1000);
return false; return false;
} }
if(this.qType == 2 || this.qType ==3){ if (this.qType == 2 || this.qType == 3) {
if(this.quesDescList.length == 0){ if (this.quesDescList.length == 0) {
this.appService.popToastView('请输入选项','middle',1000); this.appService.popToastView('请输入选项', 'middle', 1000);
return false; return false;
}else{ } else {
let index = 0; let index = 0;
this.quesDescList.forEach((res)=>{ this.quesDescList.forEach((res) => {
if(res.option_title.length == ''){ if (res.option_title.length == '') {
index ++; index++;
} }
}); });
if(index > 0){ if (index > 0) {
this.appService.popToastView('请输入选项','middle',1000); this.appService.popToastView('请输入选项', 'middle', 1000);
return false; return false;
} }
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
<p class="survey-title">{{temp?.title}}</p> <p class="survey-title">{{temp?.title}}</p>
<div class="footter-opr"> <div class="footter-opr">
<div *ngIf="swiperIndex == 0" (click)="edit()"><span>编辑</span></div> <div *ngIf="swiperIndex == 0" (click)="edit()"><span>编辑</span></div>
<div *ngIf="swiperIndex == 1" (click)="look()"><span>查看</span></div> <div *ngIf="swiperIndex == 1" (click)="edit()"><span>查看</span></div>
<div *ngIf="swiperIndex == 1" (click)="overDue()"><span>设为过期</span></div> <div *ngIf="swiperIndex == 1" (click)="overDue()"><span>设为过期</span></div>
<div *ngIf="swiperIndex == 0" (click)="release()"><span>发布</span></div> <div *ngIf="swiperIndex == 0" (click)="release()"><span>发布</span></div>
<div *ngIf="swiperIndex == 1 || swiperIndex == 2" (click)="result()"><span>结果</span></div> <div *ngIf="swiperIndex == 1 || swiperIndex == 2" (click)="result()"><span>结果</span></div>
......
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