186 lines
4.3 KiB
JavaScript
186 lines
4.3 KiB
JavaScript
// pages/approvalWarning/approvalWarning.js
|
|
const {API: $api} = require("../../utils/api");
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
//所有数据
|
|
list: [],
|
|
isRefreshing:false,//下拉刷新
|
|
isFinish:false,//下拉加载,
|
|
searchForm:{
|
|
reviewed:''
|
|
},
|
|
reviewedOpt:[],
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
|
|
},
|
|
|
|
//人员查询
|
|
handleSearchReviewed(e){
|
|
this.setData({
|
|
"searchForm.reviewed":e.detail,
|
|
})
|
|
this.loadListData();
|
|
},
|
|
|
|
//跳转页面
|
|
handleSwitchItem(e){
|
|
let _data = e.currentTarget.dataset.item;
|
|
wx.navigateTo({
|
|
url:'./approvalForm/approvalForm?data='+JSON.stringify(_data)
|
|
})
|
|
},
|
|
|
|
//上拉加载
|
|
onLoadMore(){
|
|
let _num = this.data.pageNum+1;
|
|
this.setData({
|
|
pageNum:_num
|
|
});
|
|
this.loadListData();
|
|
},
|
|
//下拉刷新
|
|
onRefresh(){
|
|
this.setData({
|
|
list:[],
|
|
pageNum:1,
|
|
isFinish:false
|
|
});
|
|
this.loadListData();
|
|
},
|
|
/**
|
|
* 列表接口
|
|
*/
|
|
loadListData() {
|
|
var that = this; // //防止this指向问题
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
});
|
|
let _param = {
|
|
pageSize:that.data.pageSize,
|
|
pageNum:that.data.pageNum,
|
|
reviewed:that.data.searchForm.reviewed
|
|
}
|
|
$api.approveList(_param).then(res => {
|
|
if(res.code === 0){
|
|
wx.hideLoading();
|
|
let _data = res.rows;
|
|
_data.forEach(item => {
|
|
item.statusName = that.statusFn(item.status)
|
|
})
|
|
if(that.data.pageNum > 1){ //上拉加载的逻辑
|
|
if(_data.length == 0){
|
|
that.setData({
|
|
isFinish:true
|
|
})
|
|
}
|
|
_data = that.data.list.concat(_data); //数据合并
|
|
that.setData({
|
|
list:_data
|
|
})
|
|
}else{
|
|
if(_data.length < that.data.pageSize){
|
|
that.setData({
|
|
list:_data,
|
|
isRefreshing:false,
|
|
isFinish:true
|
|
})
|
|
}else{
|
|
that.setData({
|
|
list:_data,
|
|
isRefreshing:false,
|
|
})
|
|
}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
//加载人员
|
|
loadPersonData(){
|
|
let _this = this;
|
|
$api.personList({}).then(res => {
|
|
if(res.code === 0){
|
|
let _newData = [{text:'请选择人员',value:''}];
|
|
res.data.forEach(item => {
|
|
_newData.push({
|
|
text:item.name,
|
|
value:item.id
|
|
})
|
|
})
|
|
_this.setData({
|
|
reviewedOpt:_newData
|
|
})
|
|
}
|
|
})
|
|
},
|
|
//状态值
|
|
statusFn(_num){
|
|
let statusArr = ['待提交','待审批','已驳回','已审批'];
|
|
return statusArr[Number(_num)-1];
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
if (wx.getStorageSync('userInfo').loginName !== 'admin'){
|
|
this.setData({
|
|
"searchForm.reviewed":wx.getStorageSync('perInfo').id
|
|
})
|
|
}
|
|
this.loadListData();
|
|
this.loadPersonData();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |