// pages/handle/expenditureAudit/expenditureAudit.js import * as UTIL from '../../../utils/util.js'; import * as API from '../../../utils/API.js'; let EVN_CONFIG = require('../../../env/env'); const DISTRIBUTE_ENVIROMENT = 'IMGURL'; let { URL_PREFIX, } = EVN_CONFIG[DISTRIBUTE_ENVIROMENT]; const app = getApp(); Page({ /** * 页面的初始数据 */ data: { isIPX: app.globalData.isIPX, active:0, spsxOptions:[], nickName:app.globalData.user, comment:'' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; console.log(options); that.setData({ taskId:options.taskId, pageType:options.type }) UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, { success: (res) => { if (res.code == API.SUCCESS_CODE) { that.setData({ ["form.approvalItemTemplate.submitCompany"]:res.user.bookName, ["form.approvalItemTemplate.submitDate"]:UTIL.js_date_time(new Date()), ["form.approvalItemTemplate.submitter"]:res.user.nickName, ["form.approvalItemTemplate.telephone"]:res.user.phonenumber, nickName:res.user.nickName }) } } }) //所属银行 UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, { success: (res) => { this.setData({ bankTypeOptions:res.data }); } }) // 资金支出类别字典查询 UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'capital_expenditure_type', {method:'GET'}, { success: (res) => { that.setData({ capitalExpenditureTypeOptions:res.data, }) } }) // 付款方式类型字典查询 UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'transfer_type', {method:'GET'}, { success: (res) => { that.setData({ transferTypeOptions:res.data, }) } }) // 项目工程列表 UTIL.httpRequest(API.URL_GET_GETPROJECTLIST , {method:'GET'}, { success: (res) => { that.setData({ projectOptions:res.rows, }) } }) // 工程款类型字典查询 UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'project_fund_type', {method:'GET'}, { success: (res) => { that.setData({ projectFundTypeOptions:res.data, }) } }) // 获取合同信息列表 UTIL.httpRequest(API.URL_GET_CONTRACTIONLIST , {method:'GET'}, { success: (res) => { that.setData({ contractionOptions:res.rows, }) } }) UTIL.httpRequest(API.URL_GET_APPROVALITEMS+options.id, {method:'GET'}, { success: (res) => { if (res.code == API.SUCCESS_CODE) { console.log(that.data.capitalExpenditureTypeOptions); if(res.data.approvalItemTemplate == null){return;} res.data.transfers.forEach( (item,index) => { res.data.transfers[index].capitalExpenditureTypeText = UTIL.getTransform(item.capitalExpenditureType,that.data.capitalExpenditureTypeOptions); res.data.transfers[index].transferTypeText = UTIL.getTransform(item.transferType,that.data.transferTypeOptions); res.data.transfers[index].bankTypeText = UTIL.getTransform(item.bankType,that.data.bankTypeOptions); res.data.transfers[index].payeeList.forEach( (response,i) => { res.data.transfers[index].payeeList[i].bankTypeText = UTIL.getTransform(response.bankType,that.data.bankTypeOptions); }) UTIL.httpRequest( API.URL_GET_FINDLIST, { method:'GET', tableName:'t_yinnong_transfer', tableId:item.id, fileType:1 }, { success: (res) => { let list = []; res.data.forEach((item2,index2)=>{ wx.downloadFile({ url: URL_PREFIX+item2.fileUrl, //仅为示例,并非真实的资源 success (response) { if (response.statusCode === 200) { let fileForm = item.fileForm?item.fileForm:[]; fileForm.push({ file: response.tempFilePath, fileType:'1', bizPath:'transfer', tableName:'t_yinnong_transfer', tableId:'' }) console.log("--------------fileForm2 start----------------"); console.log(fileForm); console.log("--------------fileForm2 end----------------"); list.push({ tempFilePath:response.tempFilePath }) that.setData({ ["form.transfers["+index+"].SJimage"]:list, ["form.transfers["+index+"].fileForm"]:fileForm }); } } }) }) } }) //发票 UTIL.httpRequest( API.URL_GET_FINDLIST, { method:'GET', tableName:'t_yinnong_transfer', tableId:item.id, fileType:2 }, { success: (res) => { let list = []; res.data.forEach((item2,index2)=>{ wx.downloadFile({ url: URL_PREFIX+item2.fileUrl, //仅为示例,并非真实的资源 success (response) { if (response.statusCode === 200) { let fileForm = item.fileForm?item.fileForm:[]; fileForm.push({ file: response.tempFilePath, fileType:'2', bizPath:'transfer', tableName:'t_yinnong_transfer', tableId:item.id }) list.push({ tempFilePath:response.tempFilePath }) that.setData({ ["form.transfers["+index+"].FPimage"]:list, ["form.transfers["+index+"].fileForm"]:fileForm }); } } }) }) } }) //其他 UTIL.httpRequest( API.URL_GET_FINDLIST, { method:'GET', tableName:'t_yinnong_transfer', tableId:item.id, fileType:3 }, { success: (res) => { let list = []; let fileForm = item.fileForm?item.fileForm:[]; res.data.forEach((item2,index2)=>{ wx.downloadFile({ url: URL_PREFIX+item2.fileUrl, //仅为示例,并非真实的资源 success (response) { if (response.statusCode === 200) { let fileForm = item.fileForm?item.fileForm:[]; fileForm.push({ file: response.tempFilePath, fileType:'3', bizPath:'transfer', tableName:'t_yinnong_transfer', tableId:item.id }) list.push({ tempFilePath:response.tempFilePath }) that.setData({ ["form.transfers["+index+"].QTimage"]:list, ["form.transfers["+index+"].fileForm"]:fileForm }); } } }) }) } }) }) that.setData({ form:res.data }) } } }) // 查询审批事项流转进度 UTIL.httpRequest(API.URL_GET_GETPROCESS+options.id , {method:'GET'}, { success: (res) => { console.log(res); that.setData({ spsxOptions:res.data.processSchedule.spsx, instanceId:res.data.instanceId }) } }) }, goDis(){ var that = this ; console.log() let data = { taskId:that.data.taskId, instanceId:that.data.instanceId, variables:JSON.stringify({ comment:that.data.comment == '' ? '驳回':that.data.comment, pass:false, }), method:'POST' }; UTIL.httpRequest(API.URL_GET_PROCESSCOMPLETE , data, { success: (res) => { console.log(res); if (res.code == API.SUCCESS_CODE) { wx.showToast({ title: '审批成功', icon: 'success', duration: 2000, complete(){ setTimeout(function(){ that.back(); },2000) } }) }else{ wx.showToast({ title: '操作失败', icon: 'error', duration: 2000 }) } } }) }, goAgree(){ var that = this ; let data = { taskId:that.data.taskId, instanceId:that.data.instanceId, variables:JSON.stringify({ "comment":that.data.comment == '' ? '同意':that.data.comment, "pass":true, }), method:'POST' }; UTIL.httpRequest(API.URL_GET_PROCESSCOMPLETE ,data, { success: (res) => { console.log(res); if (res.code == API.SUCCESS_CODE) { wx.showToast({ title: '审批成功', icon: 'success', duration: 2000, complete(){ setTimeout(function(){ that.back(); },2000) } }) }else{ wx.showToast({ title: '操作失败', icon: 'error', duration: 2000 }) } } }) }, commentInput(e){ console.log(e); var that = this; that.setData({ comment:e.detail.value }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, back:function(){ wx.navigateBack({ delta: 1 }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })