// pages/billUse/flowAdd/flowAdd.js import * as UTIL from '../../../utils/util.js'; import * as API from '../../../utils/API.js'; let EVN_CONFIG = require('../../../env/env'); const app = getApp(); Page({ /** * 页面的初始数据 */ data: { isIPX: app.globalData.isIPX, formData:{ accountDate:'',//日期 accountId:'',//账户id accountName:'',//账户名称 accountSummary:'',//摘要 accountType:'',//账户类型101=现金,102=银行存款 billNum:'',//单据编号 checkedStatus:'',//审核状态:1未提交、2待审核、3已审核、4已挂起 contractionId:'',//关联合同选择发包收入的时候必填 incomeType:'',//收入类型 1经营收入、2发包收入(这个关联合同)、3补助收入、4其他收入、5投资收益 incomeDate:'',//收入时间 incomeExpensesType:'',//收支类别1收入2支出 isBill:'',//是否来源票据0:否  1:是 jieAmount:'',//收入金额 subjectId:'',//对方科目编码 subjectNameAll:'',//对方科目名称 }, //收入时间弹窗显隐 srShow:false, minDate:new Date().getTime() - 180* 24 * 60 * 60 * 1000, maxDate:new Date().getTime() + 180* 24 * 60 * 60 * 1000, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var that = this ; this.setData({ formData:JSON.parse(options.options), ["formData.accountDate"]:this.getNewDate(new Date()) }) UTIL.httpRequest(API.URL_GET_SUBJECTLIST , {method:'GET'}, { success: (res2) => { if(res2.rows.length>0){ that.setData({ subjectOptions:res2.rows, }) } } }) UTIL.httpRequest(API.URL_GET_GETQMYE+JSON.parse(options.options).accountId , {method:'POST'}, { success: (res2) => { that.setData({ ["formData.yue"]:res2.data, }) } }) }, back:function(){ wx.navigateBack({ delta: 1 }) }, onsrDate(){ this.setData({srShow:true}) }, onClose(){ this.setData({srShow:false}) }, onConfirm(e){ console.log(e); let data = this.getNewDate(new Date(e.detail)); console.log(data); this.setData({'formData.accountDate':data}) this.setData({srShow:false}) }, getNewDate(date){ //date是传过来的时间戳,注意需为13位,10位需*1000 //也可以不传,获取的就是当前时间 var time = new Date(date); var year= time.getFullYear() //年 var month = ("0" + (time.getMonth() + 1)).slice(-2); //月 var day = ("0" + time.getDate()).slice(-2); //日 var mydate = year + "-" + month + "-" + day; return mydate }, oncrlxShow(){ this.setData({crlxShow:true}) }, onCancelcrzh(){ this.setData({crzhShow:false}) }, onCancelcrlx(){ this.setData({crlxShow:false,}) }, bindPickerChange (e) { console.log(e); let obj = e.detail.value; this.setData({ crlxShow:false, ["formData.subjectNameAll"]:obj.subjectNameAll, ["formData.subjectId"]:obj.subjectId }) }, swichAccounting:function(e){ var that = this; let data = this.data.formData; console.log(data); if (data.subjectNameAll == '' || data.subjectNameAll == undefined) { UTIL.showToastNoneIcon("请选择对方科目!"); return; } if (data.accountDate == '') { UTIL.showToastNoneIcon("请选择日期!"); return; } data.method = "POST"; UTIL.httpRequest(API.URL_GET_GETFLOWADD, data, { success: (res) => { if (res.code == API.SUCCESS_CODE) { wx.showToast({ title: '生成成功', icon: 'success', duration: 2000, }) setTimeout(function(){ that.back(); },2000) }else{ UTIL.showToastNoneIcon(res.msg); } } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })