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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import {Component, ViewChild} from '@angular/core';
import {AlertController, IonicPage, NavController, NavParams, Slides} from 'ionic-angular';
import {DesicrPage} from "../item/desicr/desicr";
import {EditPage} from "../item/edit/edit";
import {DetailPage} from "../item/detail/detail";
import {AppService} from "../../../../service/http.service";
import {SurveyResultPage} from "../../mySurvey/survey-result/survey-result";
declare var Swiper;
@IonicPage()
@Component({
selector: 'page-list',
templateUrl: 'list.html',
})
export class ListPage {
@ViewChild('contentSlides') contentSlides: Slides;
contentList = <any>[
{
datalist: []
}
];
menuList = [
{name: '草稿箱'},
{name: '已发布'},
{name: '已过期'}
];
showOp = false;
swiperIndex;
swiper;
temp; //选中的item
constructor(public navCtrl: NavController, public navParams: NavParams,
public appService: AppService,public alertCtrl:AlertController) {
}
ionViewDidEnter() {
this.initSwiper();
this.selectPageMenu(0);
this.swiperIndex = 0;
}
initSwiper() {
this.swiper = new Swiper('.pageMenuSlides .swiper-container', {
//设置slider容器能够同时显示的slides数量(
slidesPreView: 3,
//slide之间的距离(单位px)
spaceBetween: 0,
//断点设定:根据屏幕宽度设置某参数为不同的值
breakpoints: {
1024: {
slidesPerView: 3,
spaceBetween: 0
},
768: {
slidesPerView: 3,
spaceBetween: 0
},
640: {
slidesPerView: 3,
spaceBetween: 0
},
320: {
slidesPerView: 3,
spaceBetween: 0
}
}
});
}
selectPageMenu(index) {
const data = {
state: index + 1
};
this.appService.ObserverHttpGet('/wisdomgroup/modules/question/findByState', data)
.subscribe(
(res: Response) => {
this.contentList = res.json();
}
);
this.swiperIndex = index;
this.showOp = false;
//切换页面
// this.contentSlides.slideTo(index);
}
//显示问卷操作
showOpra(item) {
this.temp = item;
this.showOp = true;
}
//创建
create() {
this.navCtrl.push('DesicrPage');
}
//编辑
edit() {
this.showOp = false;
this.navCtrl.push('EditPage', {temp: this.temp});
}
//查看
look(){
this.showOp = false;
this.navCtrl.push('DetailPage',{temp:this.temp});
}
//设为过期
overDue() {
this.appService.alert('确定将该问卷设为过期吗',(res)=>{
this.appService.ObserverHttpGetAdd('/wisdomgroup/modules/question/outdate/', this.temp.id)
.subscribe((res) => {
this.appService.popToastView('问卷状态已更新','middle',1000);
this.selectPageMenu(this.swiperIndex);
})
})
}
//发布
release() {
this.appService.alert('确定发布该问卷吗',
(res) => {
this.appService.ObserverHttpGetAdd('/wisdomgroup/modules/question/submit/', this.temp.id)
.subscribe((res) => {
this.appService.popToastView('发布成功','middle',1000);
this.selectPageMenu(this.swiperIndex);
})
}
)
}
//取消发布
cancel(){
// 0 清除 1 不清除
let alert = this.alertCtrl.create();
alert.setTitle('确定取消发布该问卷吗?');
alert.addInput({
type: 'checkbox',
label: '清空该问卷答题数据',
value: '0',
checked: false
});
alert.addButton('取消');
alert.addButton({
text: '确定',
handler: res => {
let data = {isdelete:''};
if(res.length == 0 ){
data.isdelete = '1';
}else{
data.isdelete = '0';
}
this.appService.ObserverHttpForm('/wisdomgroup/modules/question/cancel/', this.temp.id,data)
.subscribe((res) => {
this.appService.popToastView('取消发布成功','middle',1000);
this.selectPageMenu(this.swiperIndex);
})
}
});
alert.present();
}
//结果
result() {
this.showOp = false;
const data = {
id:this.temp.id
}
this.navCtrl.push('SurveyResultPage',{item:data});
}
//复制
copy() {
this.appService.ObserverHttpGetOption('/wisdomgroup/modules/question/copyQuestion', {id: this.temp.id})
.subscribe((res) => {
this.selectPageMenu(this.swiperIndex);
})
}
//删除
delete() {
this.appService.alert('确定删除该问卷吗',(res)=>{
this.appService.ObserverHttpGet('/wisdomgroup/modules/question/delete', {id: this.temp.id})
.subscribe((res) => {
this.appService.popToastView('删除成功','middle',1000);
this.selectPageMenu(0);
this.showOp = false;
})
})
}
cancle() {
this.showOp = false;
}
}