| | |
| | | // pages/mLedger/ledgerhome/ledgerhome.js |
| | | const ledgerservice = require("../../../service/ledgerservice") |
| | | const moment = require('../../../utils/moment.min') |
| | | const app = getApp() |
| | | const ledgerservice = require('../../../service/ledgerservice'); |
| | | const moment = require('../../../utils/moment.min'); |
| | | const app = getApp(); |
| | | |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | |
| | | //超时情况 |
| | | overtime: '', |
| | | //建议 |
| | | suggestion: '' |
| | | suggestion: '', |
| | | }, |
| | | //上月汇总 |
| | | lastMonthInfo: { |
| | |
| | | finishedSelect: 0, |
| | | status: '', |
| | | overtime: '', |
| | | suggestion: '' |
| | | suggestion: '', |
| | | }, |
| | | |
| | | //选项卡相关 |
| | |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | let now = moment() |
| | | let limitTime = moment().date(this.DEADLINEDAY) |
| | | let now = moment(); |
| | | let limitTime = moment().date(this.DEADLINEDAY); |
| | | //如果是新注册用户不到一个月,则不提醒本月情况,直接提醒下个月的情况 |
| | | if (app.globalData.newUser) { |
| | | limitTime.add(1, 'M') |
| | | limitTime.add(1, 'M'); |
| | | } |
| | | let deadline = limitTime.format(`MM-${this.DEADLINEDAY}`) |
| | | let leftday = limitTime.diff(now, 'days') |
| | | let thisMonth = now.format('YYYY-MM') |
| | | let lastMonth = now.add(-1, 'M').format('YYYY-MM') |
| | | let deadline = limitTime.format(`MM-${this.DEADLINEDAY}`); |
| | | let leftday = limitTime.diff(now, 'days'); |
| | | let thisMonth = now.format('YYYY-MM'); |
| | | let lastMonth = now.add(-1, 'M').format('YYYY-MM'); |
| | | this.setData({ |
| | | deadline, |
| | | leftday, |
| | | thisMonth, |
| | | lastMonth |
| | | }) |
| | | lastMonth, |
| | | }); |
| | | |
| | | now = moment() |
| | | now = moment(); |
| | | this.getLedgerType(now.format('YYYY-MM-DD'), r => { |
| | | this.setData({ |
| | | tabList: r[0], |
| | | pageList: r[1], |
| | | thisMonthInfo: r[2] |
| | | }) |
| | | this.tabsHeight('.page0') |
| | | }) //本月 |
| | | this.getLedgerType(now.add(-1, 'M').format('YYYY-MM-DD'), r => { |
| | | thisMonthInfo: r[2], |
| | | }); |
| | | this.tabsHeight('.page0'); |
| | | }); //本月 |
| | | this.getLedgerType( |
| | | now.add(-1, 'M').format('YYYY-MM-DD'), |
| | | r => { |
| | | this.setData({ |
| | | lastMonthInfo: r[2] |
| | | }) |
| | | }, true) //上月 |
| | | lastMonthInfo: r[2], |
| | | }); |
| | | }, |
| | | true, |
| | | ); //上月 |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | | onReady() {}, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | }, |
| | | onShow() {}, |
| | | |
| | | getLedgerType(time, success, lastMonth) { |
| | | var that = this |
| | | var that = this; |
| | | // var time = moment().format('YYYY-MM-DD') |
| | | ledgerservice.getLedgerSummary(app.globalData.accessToken.userId, app.globalData.userInfo.extension2, time, { |
| | | ledgerservice.getLedgerSummary( |
| | | app.globalData.accessToken.userId, |
| | | app.globalData.userInfo.extension2, |
| | | time, |
| | | { |
| | | success(res) { |
| | | let r = that.parseLedgerType(res, lastMonth) |
| | | success(r) |
| | | } |
| | | }) |
| | | let r = that.parseLedgerType(res, lastMonth); |
| | | success(r); |
| | | }, |
| | | }, |
| | | ); |
| | | }, |
| | | |
| | | parseLedgerType(subtypes, lastMonth) { |
| | |
| | | finishedSelect: 0, |
| | | status: '', |
| | | overtime: '', |
| | | suggestion: '' |
| | | } |
| | | let map = new Map() |
| | | suggestion: '', |
| | | }; |
| | | let map = new Map(); |
| | | subtypes.forEach(s => { |
| | | //月度统计 |
| | | if (s.needUpdate) { |
| | | monthInfo.totalMust++ |
| | | if (s.ledgerTypeId != -1 && s.needUpdate) { |
| | | monthInfo.totalMust++; |
| | | if (s.upLoad) { |
| | | monthInfo.finishedMust++ |
| | | monthInfo.finishedMust++; |
| | | } |
| | | } else { |
| | | monthInfo.totalSelect++ |
| | | monthInfo.totalSelect++; |
| | | if (s.upLoad) { |
| | | monthInfo.finishedSelect++ |
| | | monthInfo.finishedSelect++; |
| | | } |
| | | } |
| | | |
| | | //选项卡 |
| | | if (s.upLoad) { |
| | | s.tag = '/res/icons/round_check_fill.png' |
| | | s.opacity = 0.7 |
| | | s.tag = '/res/icons/round_check_fill.png'; |
| | | s.opacity = 0.7; |
| | | } else if (s.ledgerFinished) { |
| | | s.tag = '/res/icons/warning_yellow.png' |
| | | s.opacity = 1 |
| | | s.tag = '/res/icons/warning_yellow.png'; |
| | | s.opacity = 1; |
| | | } else if (!s.needUpdate) { |
| | | s.tag = '/res/icons/warning_selected.png' |
| | | s.opacity = 0.8 |
| | | s.tag = '/res/icons/warning_selected.png'; |
| | | s.opacity = 0.8; |
| | | } else { |
| | | s.tag = '/res/icons/warning_red.png' |
| | | s.opacity = 1 |
| | | s.tag = '/res/icons/warning_red.png'; |
| | | s.opacity = 1; |
| | | } |
| | | if (!map.has(s.ledgerType)) { |
| | | map.set(s.ledgerType, []) |
| | | map.set(s.ledgerType, []); |
| | | } |
| | | map.get(s.ledgerType).push(s) |
| | | map.get(s.ledgerType).push(s); |
| | | }); |
| | | |
| | | // |
| | | if (monthInfo.finishedMust == 0) { |
| | | monthInfo.status = '未提交' |
| | | monthInfo.status = '未提交'; |
| | | if (lastMonth) { |
| | | monthInfo.suggestion = '建议:当期台账完全未提交,严重影响评估结果,后续请注意' |
| | | monthInfo.suggestion = |
| | | '建议:当期台账完全未提交,严重影响评估结果,后续请注意'; |
| | | } else { |
| | | monthInfo.suggestion = '建议:请尽快提交台账' |
| | | monthInfo.suggestion = '建议:请尽快提交台账'; |
| | | } |
| | | } else if (monthInfo.finishedMust < monthInfo.totalMust) { |
| | | monthInfo.status = '部分提交' |
| | | monthInfo.status = '部分提交'; |
| | | if (lastMonth) { |
| | | monthInfo.suggestion = '建议:当期台账部分未提交,会影响评估结果,后续请尽量提交所有台账' |
| | | monthInfo.suggestion = |
| | | '建议:当期台账部分未提交,会影响评估结果,后续请尽量提交所有台账'; |
| | | } else { |
| | | monthInfo.suggestion = '建议:当前已提交部分台账,请补全剩余台账' |
| | | monthInfo.suggestion = '建议:当前已提交部分台账,请补全剩余台账'; |
| | | } |
| | | } else { |
| | | monthInfo.status = '已提交' |
| | | monthInfo.status = '已提交'; |
| | | if (lastMonth) { |
| | | monthInfo.suggestion = '当期台账已全部提交,请保持' |
| | | monthInfo.suggestion = '当期台账已全部提交,请保持'; |
| | | } else { |
| | | monthInfo.suggestion = '本期台账已全部提交' |
| | | monthInfo.suggestion = '本期台账已全部提交'; |
| | | } |
| | | } |
| | | monthInfo.overtime = moment().date() - this.DEADLINEDAY |
| | | monthInfo.percent = Math.round(monthInfo.finishedMust / monthInfo.totalMust * 100) |
| | | monthInfo.overtime = moment().date() - this.DEADLINEDAY; |
| | | monthInfo.percent = Math.round( |
| | | (monthInfo.finishedMust / monthInfo.totalMust) * 100, |
| | | ); |
| | | |
| | | //选项卡 |
| | | var t = [] |
| | | var p = [] |
| | | var t = []; |
| | | var p = []; |
| | | for (let item of map) { |
| | | let notUpload = 0 |
| | | if (item[1][0].ledgerTypeId == -1) { |
| | | continue; |
| | | } |
| | | let notUpload = 0; |
| | | item[1].forEach(l => { |
| | | if (l.needUpdate && !l.upLoad) { |
| | | notUpload++ |
| | | notUpload++; |
| | | } |
| | | }); |
| | | t.push({ |
| | | name: item[0], |
| | | tag: notUpload, |
| | | total: item[1].length |
| | | }) |
| | | p.push(item[1]) |
| | | total: item[1].length, |
| | | }); |
| | | p.push(item[1]); |
| | | } |
| | | |
| | | return [t, p, monthInfo] |
| | | return [t, p, monthInfo]; |
| | | }, |
| | | |
| | | gotoLedgerDetail(e) { |
| | | var i = e.currentTarget.dataset.index.split(',') |
| | | var indexGroup = [parseInt(i[0]), parseInt(i[1])] |
| | | var ledger = this.data.pageList[indexGroup[0]][indexGroup[1]] |
| | | var i = e.currentTarget.dataset.index.split(','); |
| | | var indexGroup = [parseInt(i[0]), parseInt(i[1])]; |
| | | var ledger = this.data.pageList[indexGroup[0]][indexGroup[1]]; |
| | | |
| | | var that = this |
| | | var that = this; |
| | | wx.navigateTo({ |
| | | url: '/pages/mLedger/ledgerupload/ledgerupload', |
| | | events: { |
| | | uploadOver: function (data) { |
| | | let i = data.indexGroup |
| | | let pageList = that.data.pageList |
| | | pageList[i[0]][i[1]].upLoad = true |
| | | pageList[i[0]][i[1]].tag = '/res/icons/round_check_fill.png' |
| | | pageList[i[0]][i[1]].opacity = 0.7 |
| | | let i = data.indexGroup; |
| | | let { pageList, tabList } = that.data; |
| | | tabList[i[0]].tag--; |
| | | pageList[i[0]][i[1]].upLoad = true; |
| | | pageList[i[0]][i[1]].tag = '/res/icons/round_check_fill.png'; |
| | | pageList[i[0]][i[1]].opacity = 0.7; |
| | | that.setData({ |
| | | pageList |
| | | }) |
| | | } |
| | | pageList, |
| | | tabList, |
| | | }); |
| | | }, |
| | | success: (res) => { |
| | | }, |
| | | success: res => { |
| | | // 通过 eventChannel 向被打开页面传送数据 |
| | | res.eventChannel.emit('acceptDataFromOpenerPage', { |
| | | ledger: ledger, |
| | | indexGroup: indexGroup |
| | | }) |
| | | indexGroup: indexGroup, |
| | | type: 0, |
| | | }); |
| | | }, |
| | | }) |
| | | }); |
| | | }, |
| | | |
| | | gotoHistory(){ |
| | | let tabList = this.data.tabList |
| | | let tabList = this.data.tabList; |
| | | wx.navigateTo({ |
| | | url: '/pages/mLedger/ledgerhistory/ledgerhistory', |
| | | success: (res) => { |
| | | success: res => { |
| | | // 通过 eventChannel 向被打开页面传送数据 |
| | | res.eventChannel.emit('acceptDataFromOpenerPage', { |
| | | tabList: tabList, |
| | | }) |
| | | }); |
| | | }, |
| | | }) |
| | | }); |
| | | }, |
| | | |
| | | |
| | | //计算swiper高度方法(在切换的时候调用) |
| | | tabsHeight(element) { |
| | | let that = this; |
| | | let query = wx.createSelectorQuery(); //必须要先创建一个查询 |
| | | query.select(element).boundingClientRect(function (rect) { |
| | | let pageheight = that.data.pageheight.split('px')[0] |
| | | pageheight = parseInt(pageheight) |
| | | query |
| | | .select(element) |
| | | .boundingClientRect(function (rect) { |
| | | let pageheight = that.data.pageheight.split('px')[0]; |
| | | pageheight = parseInt(pageheight); |
| | | if (rect.height > pageheight) { |
| | | that.setData({ |
| | | pageheight: rect.height + 'px' |
| | | pageheight: rect.height + 'px', |
| | | }); |
| | | } |
| | | }).exec(); |
| | | }) |
| | | .exec(); |
| | | }, |
| | | swichNav: function (e) { |
| | | var that = this; |
| | |
| | | } else { |
| | | that.setData({ |
| | | currentTab: e.target.dataset.current, |
| | | navScrollLeft: e.target.dataset.current >= 3 ? ((e.target.dataset.current) * 60) : 0 //判断当前选中的个数是否是第5个 |
| | | }) |
| | | navScrollLeft: |
| | | e.target.dataset.current >= 3 ? e.target.dataset.current * 60 : 0, //判断当前选中的个数是否是第5个 |
| | | }); |
| | | // that.tabsHeight('.page' + e.target.dataset.current); //查询哪一个元素 |
| | | } |
| | | }, |
| | |
| | | var that = this; |
| | | that.setData({ |
| | | currentTab: e.detail.current, |
| | | navScrollLeft: e.detail.current >= 3 ? ((e.detail.current) * 60) : 0 //判断当前选中的个数是否是第5个 |
| | | navScrollLeft: e.detail.current >= 3 ? e.detail.current * 60 : 0, //判断当前选中的个数是否是第5个 |
| | | }); |
| | | that.tabsHeight('.page' + e.detail.current); //查询哪一个元素 |
| | | }, |
| | | |
| | | changeMonth(){ |
| | | let showThisMonth = !this.data.showThisMonth |
| | | this.setData({showThisMonth}) |
| | | } |
| | | }) |
| | | let showThisMonth = !this.data.showThisMonth; |
| | | this.setData({ showThisMonth }); |
| | | }, |
| | | }); |