// pages/voucherManagementAddto/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { projectNameList:[], voucherTypeList:[], loadShow:false, loginName:'', userName:'', deptId:'', projectName:'', projectId:'', fileList:[], //参数 voucherType:'', happenTime:'', uploadTime:'', remarks:'', }, //选择项目名称 onSelectProjectName(e){ console.log(e.detail) this.setData({ projectId:e.detail.id, projectName:e.detail.text }) }, //选择凭证类型 onSelectVoucherType(e){ console.log(e.detail) this.setData({ voucherType:e.detail.id }) }, //发生时间 onOccurrenceTime(e){ console.log(e.detail) this.setData({ happenTime:e.detail }) }, //上传时间 onUploadTime(e){ console.log(e.detail) this.setData({ uploadTime:e.detail }) }, //备注 remarks(e){ console.log(e.detail.value); this.setData({ remarks:e.detail.value }) }, onClickShow() { this.setData({ loadShow: true }); }, onClickHide() { this.setData({ loadShow: false }); }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(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, projectNameList:[{text:options.projectName,id:options.projectId}] }) that.getDocumentType(); } }) }, /** * 凭证类型 */ 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 { let data = JSON.parse(res.data); // 上传完成需要更新 fileList let fileList = this.data.fileList fileList.push(data); this.setData({ fileList:fileList}); }, }); }, add:function(){ //判断值是否为空 if(this.data.projectId == '' || this.data.projectId == undefined){ app.toast("请选择项目"); return; }else if(this.data.voucherType == '' || this.data.voucherType == undefined){ app.toast("请选择凭证类型"); return; }else if(this.data.happenTime == '' || this.data.happenTime == undefined){ app.toast("请选择发生时间"); return; }else if(this.data.uploadTime == '' || this.data.uploadTime == undefined){ app.toast("请选择上传时间"); return; }else if(this.data.fileList.length == 0){ app.toast("请上传文件"); return; } console.log(this.data.fileList); wx.request({ header: { 'content-type': 'application/x-www-form-urlencoded' }, url:app.globalData.reqUrl+'/weixin/security/addDocumentData', data:{ deptId:this.data.deptId, projectId:this.data.projectId, projectName:this.data.projectName, type:this.data.voucherType, createTime:this.data.happenTime, time:this.data.uploadTime, createUser:this.data.loginName, userName:this.data.userName, remarks:this.data.remarks, djCertificatesonList:JSON.stringify(this.data.fileList) }, method:"POST", success:function(res){ console.log(res.data); if(res.data.code == 200){ wx.redirectTo({ url: '../voucherManagement/index', }) }else{ app.toast("添加失败"); return; } } }) }, /** * 返回凭证管理 */ goGCLB:function(){ wx.redirectTo({ url: '../voucherManagement/index' }) }, })