Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import {Component} from '@angular/core';
import {IonicPage, ModalController, NavController, NavParams, ToastController} from 'ionic-angular';
import {EditPage} from "../edit/edit";
import {PersonPage} from "../../modal/person/person";
import {AppService} from "../../../../../service/http.service";
import {message} from "../../../../../app/main";
@IonicPage()
@Component({
selector: 'page-desicr',
templateUrl: 'desicr.html',
})
export class DesicrPage {
id;
isans = null; //匿名
isopen; //公开
desrc = {
title: '', //问卷标题
explai: '', //问卷说明
usergroup: null, //用户组id
isopen: 1, //是否公开
isans: 1, //是否匿名
state: 1 //状态
};
groupName = '全体用户';
constructor(public navCtrl: NavController, public navParams: NavParams,
public modalCtrl: ModalController, public appService: AppService,
public toastCtrl: ToastController) {
}
ionViewDidLoad() {
if (this.navParams.get('id')) {
this.id = this.navParams.get('id');
this.getDetail();
}
}
//新建
submitOrder() {
const toast = this.toastCtrl.create(message);
if (!this.desrc.title) {
toast.setMessage('请填写标题');
toast.present();
return false
}
if (this.desrc.usergroup == null) {
this.desrc.usergroup = 'all';
}
if (this.desrc.isopen) {
this.desrc.isopen = 1;
} else {
this.desrc.isopen = 0;
}
this.appService.ObserverHttpPost('/wisdomgroup/modules/question/create', this.desrc)
.subscribe(
(res) => {
if (res) {
toast.setMessage('创建成功');
toast.present();
this.navCtrl.push('EditPage', {temp: res.json()});
}
}
)
}
//编辑
submitEdit() {
//是否匿名
if (this.isans == true || this.isans == 1) {
this.desrc.isans = 1;
} else {
this.desrc.isans = 2;
}
//是否公开问卷结果
if (this.isopen == true || this.isopen == 1) {
this.desrc.isopen = 1;
} else {
this.desrc.isopen = 0;
}
const data = {
id: this.id,
title: this.desrc.title, //问卷标题
explai: this.desrc.explai, //问卷说明
usergroup: this.desrc.usergroup, //用户组id
isopen: this.desrc.isopen, //是否公开
isans: this.desrc.isans, //是否匿名
state: this.desrc.state //状态
};
this.appService.ObserverHttpPost('/wisdomgroup/modules/question/updateOnApp', data)
.subscribe((res) => {
if (res) {
this.navCtrl.pop();
}
})
}
selectPerson() {
let modal = this.modalCtrl.create(PersonPage);
modal.onDidDismiss(data => {
if (data) {
this.desrc.usergroup = data.id;
this.groupName = data.groupName;
} else {
this.desrc.usergroup = 'all';
this.groupName = '全体用户';
}
});
modal.present();
}
getDetail() {
this.appService.ObserverHttpPostAdd('/wisdomgroup/modules/question/edit/', this.id).subscribe((res) => {
this.desrc = res.json().data;
if (this.desrc.isans == 1) {
this.isans = true;
} else {
this.isans = false;
}
if (this.desrc.isopen == 1) {
this.isopen = true;
} else {
this.isopen = false;
}
});
}
}