Newer
Older
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams, ToastController} from 'ionic-angular';
set = { //设置
lastchange: '1',
morechange: '1',
isAns: '',
more: '100'
};
constructor(public navCtrl: NavController, public navParams: NavParams,
public appService: AppService, public toastCtrl: ToastController) {
}
this.qType = this.editTemp[this.editIndex].quesType;
this.title = this.editTemp[this.editIndex].title;
addOption() {
const option = {
option_title: '', //选项文字
canFill: 2, // 1是 2否
isNeed: 1, // 1是 2否
return false;
}
let newArr = [];
this.editTemp[this.editIndex].title = this.title;
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
for (let i = 0; i < this.editTemp.length; i++) {
const arr = {
questionId: this.temp.id,
isAns: this.editTemp[i].isAns,
quesType: this.editTemp[i].quesType,
title: this.editTemp[i].title,
limit: this.editTemp[i].limit, //问答的字数限制
quesDesc: this.editTemp[i].quesDesc,
minOps: this.editTemp[i].minOps,
maxOps: this.editTemp[i].maxOps,
index: this.editTemp[i].index //序号
};
newArr.push(arr);
}
const data = {
array: JSON.stringify(newArr),
id: this.temp.id
};
console.log(newArr);
const toast = this.toastCtrl.create(message);
this.appService.ObserverHttpPost('/wisdomgroup/modules/question/saveQuestion', data)
.subscribe(
(res) => {
toast.setMessage('编辑成功');
toast.present();
setTimeout((res) => {
this.navCtrl.push('EditPage', {
temp: this.temp
});
}, 1000)
}
)
}
//提交问卷
const option1 = {
option_title: '是', //选项文字
canFill: 2, // 1是 2否
isNeed: 1, // 1是 2否
index: 0
}; //序号
const option2 = {
option_title: '否', //选项文字
canFill: 2, // 1是 2否
isNeed: 1, // 1是 2否
}; //序号
this.quesDescList.push(option1);
this.quesDescList.push(option2);
}
limit: 1000, //问答的字数限制
quesDesc: this.quesDescList,
minOps: 0,
maxOps: 0,
index: 0 //序号
console.log(this.temp);
const toast = this.toastCtrl.create(message);
this.appService.ObserverHttpPost('/wisdomgroup/modules/question/saveQuestion', data)
(res) => {
toast.setMessage('添加成功');
toast.present();
setTimeout((res) => {
this.navCtrl.push('EditPage', {
temp: this.temp
});
}, 2000)
check() {
if (!this.title) {
this.appService.popToastView('请输入标题', 'middle', 1000);
if (this.qType == 2 || this.qType == 3) {
if (this.quesDescList.length == 0) {
this.appService.popToastView('请输入选项', 'middle', 1000);
this.quesDescList.forEach((res) => {
if (res.option_title.length == '') {
index++;
if (index > 0) {
this.appService.popToastView('请输入选项', 'middle', 1000);