Newer
Older
import {Component, ViewChild} from '@angular/core';
import {InfiniteScrollContent, IonicPage, NavController, NavParams} from 'ionic-angular';
import {AppGlobal} from "../../../../service/http.service";
import {ServeService} from "../../serve.service";
import {CommonService} from "../../../../provide/common.service";
import {timer} from "rxjs/observable/timer";
@ViewChild(InfiniteScrollContent) infiniteScrollContent: InfiniteScrollContent;
pageNum = 1;
pageSize = 10;
changeType = 1;
footerView = false;
checkAll = false;
chooseObj = [];
totalNum;
apply = {
list: [],
isLoad: false,
loadMore:false
};
constructor(public navCtrl: NavController, public navParams: NavParams,
private serveSer: ServeService, private commonSer: CommonService) {
}
ionViewDidLoad() {
this.footerView = true;
this.getList();
}
getList() {
const data = {
P_pageNumber: 1,
P_pageSize: this.pageSize,
status: this.changeType
};
this.serveSer.searchCheckList(data).subscribe(
(res) => {
this.apply.list = res.data.list;
}
)
}
change(type) {
this.changeType = type;
this.getList();
}
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
changeCheck(item){
const index = this.chooseObj.indexOf(item.id);
if (index > -1) {
this.chooseObj.splice(index, 1);
} else {
this.chooseObj.push(item.id);
}
this.checkAll = this.chooseObj.length === this.apply.list.length;
}
//下拉刷新
doRefresh(e) {
this.apply.loadMore = true;
this.infiniteScrollContent.inf.enable(true);
const data = {
P_pageNumber: 1,
P_pageSize: this.pageSize,
status: this.changeType
};
this.serveSer.myOrder(data).subscribe(
(res) => {
this.apply.list = res.data.list;
this.totalNum = res.data.total;
timer(800).subscribe(() => {
this.commonSer.toast('刷新成功');
e.complete()
});
}
)
}
//加载更多
doInfinite(e) {
if (this.totalNum == this.apply.list.length) {
console.log("没有更多了");
this.apply.loadMore = false;
e.enable(false);
return false;
}
this.pageNum++;
const data = {
P_pageNumber: this.pageNum,
P_pageSize: this.pageSize,
status: this.changeType
};
this.serveSer.myOrder(data).subscribe(
(res) => {
this.totalNum = res.data.total;
res.list.forEach(e => {
this.apply.list.push(e);
});
timer(800).subscribe(() => e.complete());
}
)
}
//全选
selectAll(e) {
this.chooseObj = [];
if (e == false) {
this.apply.list.forEach(e => {
e.checkbox = false;
})
} else {
this.apply.list.forEach(e => {
e.checkbox = true;
this.chooseObj.push(e.id);
})
}
}
submit(status){
if(this.chooseObj.length == 0){
this.commonSer.toast('请选择申请');
return false;
}
const data = {
ids: this.chooseObj.join(','),
status: status,
};
this.commonSer.alert(msg, () => {
this.serveSer.meetOperate(data).subscribe(
(res) => {
this.getList();
}
)
})
}