Commit ca5ad94d authored by wangqinghua's avatar wangqinghua

color

parent c5004ead
......@@ -27,10 +27,8 @@
</p>
<div class="padding-0-16">
<ng-container *ngIf="item.quesType == 1">
<!--<p class="input-radio"><label for="{{item.id}}0"><input name="{{item.id}}" id="{{item.id}}0" value="0" type="radio">是</label></p>-->
<p class="input-radio"><input [(ngModel)]="item.answerdesc" name="{{item.questionQueId}}" value="0" type="radio"></p>
<p class="input-radio"><input [(ngModel)]="item.answerdesc" name="{{item.questionQueId}}" value="1" type="radio"></p>
<!--<p class="input-radio"><label for="{{item.id}}1"><input name="{{item.id}}" id="{{item.id}}1" value="1" type="radio">否</label></p>-->
</ng-container>
<!--单选题-->
<ng-container *ngIf="item.quesType == 2">
......
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { AppService } from "../../../../service/appHttpService";
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {AppService} from "../../../../service/appHttpService";
@IonicPage()
@Component({
selector: 'page-survey-write',
templateUrl: 'survey-write.html',
selector: 'page-survey-write',
templateUrl: 'survey-write.html',
})
export class SurveyWritePage {
item;
temp;
ansArr = [];
constructor(public navCtrl: NavController, public navParams: NavParams,
public appService:AppService) {
}
item;
temp;
ansArr = [];
ionViewDidLoad() {
this.item = this.navParams.get('item');
this.getDetail();
}
constructor(public navCtrl: NavController, public navParams: NavParams,
public appService: AppService) {
}
ionViewDidLoad() {
this.item = this.navParams.get('item');
this.getDetail();
}
getDetail(){
const id = '';
this.appService.ObserverHttpGetAdd('/wisdomgroup/modules/question/findQuesByQuestionId/',this.item.id)
.subscribe((res)=>{
this.temp = res.json().datalist;
for(let i = 0;i < this.temp.length;i++){
const data = {
'questionId':this.temp[i].questionId,
'questionQueId':this.temp[i].id,
'answerdesc':'',
'quesType':this.temp[i].quesType,
'title':this.temp[i].title,
'quesDesc':JSON.parse(this.temp[i].quesDesc),
'isans':'1'
};
this.ansArr.push(data);
}
})
}
getDetail() {
const id = '';
this.appService.ObserverHttpGetAdd('/wisdomgroup/modules/question/findQuesByQuestionId/', this.item.id)
.subscribe((res) => {
this.temp = res.json().datalist;
for (let i = 0; i < this.temp.length; i++) {
const data = {
'questionId': this.temp[i].questionId,
'questionQueId': this.temp[i].id,
'answerdesc': '',
'quesType': this.temp[i].quesType,
'title': this.temp[i].title,
'quesDesc': JSON.parse(this.temp[i].quesDesc),
'isAns': this.temp[i].isAns
};
this.ansArr.push(data);
}
console.log(this.ansArr);
})
}
//多选
mutiSelect(i,index){
this.ansArr[i].answerdesc += ","+ index;
console.log(this.ansArr);
//多选
mutiSelect(i, index) {
if (this.ansArr[i].answerdesc.indexOf(index) != -1) {
this.ansArr[i].answerdesc = this.ansArr[i].answerdesc.replace(',' + index, '');
} else {
this.ansArr[i].answerdesc += "," + index;
}
console.log(this.ansArr[i]);
}
submit(){
let arrData = [];
for(let i = 0;i < this.ansArr.length;i++){
if(this.ansArr[i].quesType == 3){
let length = this.ansArr[i].answerdesc.length;
this.ansArr[i].answerdesc = this.ansArr[i].answerdesc.substr(1,length-1);
}
const data = {
'questionId':this.ansArr[i].questionId,
'questionQueId':this.ansArr[i].questionQueId,
'answerdesc':this.ansArr[i].answerdesc,
'isans':this.ansArr[i].isans
};
arrData.push(data);
}
console.log(arrData);
const qData = {
'array':JSON.stringify(arrData)
}
this.appService.ObserverHttpPost('/wisdomgroup/modules/question/create/quesuser',qData)
.subscribe((res)=>{
submit() {
if (!this.check()) {
return false;
}
let arrData = [];
for (let i = 0; i < this.ansArr.length; i++) {
if (this.ansArr[i].quesType == 3) {
let length = this.ansArr[i].answerdesc.length;
this.ansArr[i].answerdesc = this.ansArr[i].answerdesc.substr(1, length - 1);
}
const data = {
'questionId': this.ansArr[i].questionId,
'questionQueId': this.ansArr[i].questionQueId,
'answerdesc': this.ansArr[i].answerdesc,
'isans': this.ansArr[i].isans
};
arrData.push(data);
}
console.log(arrData);
const qData = {
'array': JSON.stringify(arrData)
}
this.appService.ObserverHttpPost('/wisdomgroup/modules/question/create/quesuser', qData)
.subscribe((res) => {
this.navCtrl.pop();
})
}
check() {
let count = 0;
for (let i = 0; i < this.ansArr.length; i++) {
if (this.ansArr[i].isAns == 1) {
if (this.ansArr[i].answerdesc == "") {
this.appService.popToastView('有必答题未答', 'middle', 1500);
count++;
break;
}
}
}
if (count > 0) {
return false;
}
return true;
}
}
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