jhwxapp/miniprogram/pageage/voucherManagement/index.js

167 lines
3.6 KiB
JavaScript

// pages/voucherManagement/index.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
DeviceGroupData: [],
DocumentList:[],
show: false,
loadShow:false,
loginName:'',
userName:'',
deptId:'',
projectName:'',
projectId:'',
monthCount:0,
weekCount:0,
initData:{}
},
//项目切换 返回值
onProjectSelect(e){
this.onClickShow();
let projectId = e.detail.id;
let projectName = e.detail.text;
app.globalData.projectId = projectId;
app.globalData.projectName = projectName;
this.setData({
projectId:projectId,
projectName:projectName
})
this.onLoad();
},
//筛选条件
screenCondition(e){
console.log(e.detail)
this.getDocumentList(e.detail.typeId,e.detail.startDate,e.detail.endTime)
},
showPopup() {
this.setData({ show: true });
},
onClose() {
this.setData({ show: false });
},
onClickShow() {
this.setData({ loadShow: true });
},
onClickHide() {
this.setData({ loadShow: false });
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
var that = this;
//加载蒙版
that.onClickShow();
//获取缓存数据
wx.getStorage({
key: 'userinfo',
success:function(res){
console.log(res.data);
that.setData({
loginName:res.data.loginName,
userName:res.data.userName,
deptId:res.data.deptId,
projectName: app.globalData.projectName,
projectId:app.globalData.projectId,
initData:{text:app.globalData.projectName,id:app.globalData.projectId}
})
that.getDocumentType();
that.getDocumentList('','','');
}
})
},
/**
* 凭证类型
*/
getDocumentType:function(){
wx.request({
url: app.globalData.reqUrl+'/weixin/security/getDocumentType',
method: 'get',
data: {
deptId:this.data.deptId,
projectId:this.data.projectId,
},
success: resData => {
this.onClickHide();
if(resData.data.code == 200){
let DeviceGroupData = resData.data.data;
let list = [];
for(let i = 0;i<DeviceGroupData.length;i++){
list.push({"id":DeviceGroupData[i].id,"text":DeviceGroupData[i].name});
}
this.setData({
DeviceGroupData:list
})
}
}
})
},
/**
* 凭证列表
*/
getDocumentList:function(type,beginTime,endTime){
wx.request({
url: app.globalData.reqUrl+'/weixin/security/getDocumentList',
method: 'get',
data: {
deptId:this.data.deptId,
projectId:this.data.projectId,
type:type,
beginTime:beginTime,
endTime:endTime
},
success: resData => {
this.onClickHide();
console.log(resData.data);
if(resData.data.code == 200){
this.setData({
DocumentList:resData.data.data,
weekCount:resData.data.weekCount,
monthCount:resData.data.monthCount
})
}else{
this.setData({
DocumentList:[],
weekCount:0,
monthCount:0
})
}
}
})
},
/**
* 返回到更多功能页面
*/
goGCLB:function(){
wx.redirectTo({
url: '../../pages/gengduogongneng/gengduogongneng'
})
},
/**
* 跳转到add页面
*/
add:function(){
wx.navigateTo({
url: '../voucherManagementAddto/index?projectName='+this.data.projectName+"&projectId="+this.data.projectId,
})
}
})