// pages/Bookkeeping/Bookkeeping.js import * as UTIL from '../../utils/util.js'; import * as API from '../../utils/API.js'; const app = getApp(); Page({ /** * 页面的初始数据 */ data: { isIPX: app.globalData.isIPX, result:[], result2:[], showGroup:true, flowList:[], showProjectFundType:false, checkedStatusText:'未提交', checkedStatus:'1' }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var that = this; UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'checked_status', {method:'GET'}, { success: (res) => { that.setData({ capitalExpenditureTypeOptions:res.data, }) } }) UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'income_type', {method:'GET'}, { success: (res) => { that.setData({ incomeTypeOptions:res.data, }) } }) UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'capital_expenditure_type', {method:'GET'}, { success: (res) => { that.setData({ expenditureTypeOptions:res.data, }) } }) //收入事项 let data = { pageNum:'1', pageSize:'999', accountType:'', checkedStatus:'1', incomeExpensesType:'1', } UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{ success: (res) => { if (res.code == API.SUCCESS_CODE) { let list = res.rows; for (let i = 0; i < list.length; i++) { const element = list[i]; list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions); list[i].incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions); } this.setData({ flowListSR:list, flowListSRNum:res.total }); } } }) //支出事项 let data2 = { pageNum:'1', pageSize:'999', accountType:'', checkedStatus:'1', incomeExpensesType:'2', } UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{ success: (res) => { if (res.code == API.SUCCESS_CODE) { let list = res.rows; this.setData({ flowListZCNum:res.total }); } } }) }, onChange(event) { this.setData({result:event.detail}) }, onChange2(event) { this.setData({result2:event.detail}) }, switchTab(e){ var that = this; this.setData({showGroup:e.currentTarget.dataset.gid}) if(e.currentTarget.dataset.gid){ //收入事项 let data = { pageNum:'1', pageSize:'999', accountType:'', checkedStatus:this.data.checkedStatus, incomeExpensesType:'1', } UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{ success: (res) => { if (res.code == API.SUCCESS_CODE) { let list = res.rows; for (let i = 0; i < list.length; i++) { const element = list[i]; list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions); list[i].incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions); } this.setData({ flowListSR:list, flowListSRNum:res.total }); } } }) }else{ let data2 = { pageNum:'1', pageSize:'999', accountType:'', checkedStatus:this.data.checkedStatus, incomeExpensesType:'2', } UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{ success: (res) => { if (res.code == API.SUCCESS_CODE) { let list = res.rows; for (let i = 0; i < list.length; i++) { const element = list[i]; list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions); list[i].expenditureTypeText = UTIL.getTransform(element.expenditureType,that.data.expenditureTypeOptions); } this.setData({ flowListZC:list, flowListZCNum:res.total }); } } }) } }, back:function(){ wx.navigateBack({ delta: 1 }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, openPopup(even){ this.setData({ showProjectFundType:true }) }, onConfirmPick(event){ var that = this; this.setData({ [event.currentTarget.dataset.name]: false, checkedStatus: event.detail.value.dictValue, checkedStatusText: event.detail.value.dictLabel, }); let data = { pageNum:'1', pageSize:'999', accountType:'', checkedStatus:event.detail.value.dictValue, incomeExpensesType:'1', } UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{ success: (res) => { if (res.code == API.SUCCESS_CODE) { let list = res.rows; for (let i = 0; i < list.length; i++) { const element = list[i]; element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions); element.incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions); } this.setData({ flowListSR:list, flowListSRNum:res.total }); } } }) let data2 = { pageNum:'1', pageSize:'999', accountType:'', checkedStatus:event.detail.value.dictValue, incomeExpensesType:'2', } UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{ success: (res) => { if (res.code == API.SUCCESS_CODE) { let list = res.rows; for (let i = 0; i < list.length; i++) { const element = list[i]; element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions); } this.setData({ flowListZC:list, flowListZCNum:res.total }); } } }) }, closeBox(even){ console.log(even.currentTarget.dataset.name); this.setData({ [even.currentTarget.dataset.name]:false }) }, goSubmit(){ var that = this ; let url = API.URL_GET_GETBOOKKEEP wx.request({ url, method:"POST", timeout: 60000, data:that.data.result, header: { 'Authorization':'Bearer '+getApp().globalData.userInfo.token }, success: function (response) { wx.showToast({ title: "提交成功!", duration: 2000, icon:"success" }) setTimeout(function(){ wx.reLaunch({ url: '/pages/index/index' }) },2000) } }) }, goUpdate(event){ wx.navigateTo({ url: '/pages/Bookkeeping/update/update?id='+event.currentTarget.dataset.id, }) }, goUpdateZC(event){ wx.navigateTo({ url: '/pages/Bookkeeping/updateZC/update?id='+event.currentTarget.dataset.id, }) }, delete(e){ console.log(e); var that = this; UTIL.httpRequest(API.URL_GET_FLOWREMOVE + e.currentTarget.dataset.id, {method:'GET'},{ success: (res) => { if (res.code == API.SUCCESS_CODE) { that.data.flowListSR.splice(e.currentTarget.dataset.index, 1); wx.showToast({ title: '删除成功!', icon: 'success', duration: 2000 }) that.setData({ flowListSR : that.data.flowListSR, flowListSRNum:that.data.flowListSRNum-1 }) } } }) }, delete2(e){ console.log(e); var that = this; UTIL.httpRequest(API.URL_GET_FLOWREMOVE + e.currentTarget.dataset.id, {method:'GET'},{ success: (res) => { if (res.code == API.SUCCESS_CODE) { that.data.flowListZC.splice(e.currentTarget.dataset.index, 1); wx.showToast({ title: '删除成功!', icon: 'success', duration: 2000 }) that.setData({ flowListZC : that.data.flowListZC, flowListZCNum:that.data.flowListZCNum-1 }) } } }) }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })