| | |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | deadline: '', |
| | | leftday:0 , |
| | | thisMonth: '', |
| | | lastMonth: '', |
| | | |
| | | //提交期限 |
| | | deadline: '', |
| | | //剩余提交天数 |
| | | leftday: 0, |
| | | |
| | | //本月汇总 |
| | | thisMonthInfo: { |
| | | //必填项总数 |
| | | totalMust: 0, |
| | | //必填项提交数 |
| | | finishedMust: 0, |
| | | //选填项总数 |
| | | totalSelect: 0, |
| | | //选填项提交数 |
| | | finishedSelect: 0, |
| | | //提交情况 |
| | | status: '', |
| | | //超时情况 |
| | | overtime: '', |
| | | //建议 |
| | | suggestion: '' |
| | | }, |
| | | //上月汇总 |
| | | lastMonthInfo: { |
| | | totalMust: 0, |
| | | finishedMust: 0, |
| | | totalSelect: 0, |
| | | finishedSelect: 0, |
| | | status: '', |
| | | overtime: '', |
| | | suggestion: '' |
| | | }, |
| | | |
| | | //选项卡相关 |
| | | currentTab: 0, |
| | | tabList: [], |
| | | pageList: [], |
| | | pageheight: '300px', |
| | | |
| | | pageheight: '300px' |
| | | //当前显示月份 |
| | | showThisMonth: true, |
| | | }, |
| | | |
| | | //每月台账提交期限日 |
| | |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | this.getLedgerType() |
| | | |
| | | var deadline = moment().format(`MM-${this.DEADLINEDAY}`) |
| | | var leftday = this.DEADLINEDAY + 1 - moment().date() |
| | | let now = moment() |
| | | let deadline = now.format(`MM-${this.DEADLINEDAY}`) |
| | | let leftday = this.DEADLINEDAY + 1 - now.date() |
| | | let thisMonth = now.format('YYYY-MM') |
| | | let lastMonth = now.add(-1, 'M').format('YYYY-MM') |
| | | this.setData({ |
| | | deadline: deadline, |
| | | leftday: leftday |
| | | deadline, |
| | | leftday, |
| | | thisMonth, |
| | | lastMonth |
| | | }) |
| | | |
| | | now = moment() |
| | | this.getLedgerType(now.format('YYYY-MM-DD'), r => { |
| | | this.setData({ |
| | | tabList: r[0], |
| | | pageList: r[1], |
| | | thisMonthInfo: r[2] |
| | | }) |
| | | }) //本月 |
| | | this.getLedgerType(now.add(-1, 'M').format('YYYY-MM-DD'), r => { |
| | | this.setData({ |
| | | lastMonthInfo: r[2] |
| | | }) |
| | | }, true) //上月 |
| | | }, |
| | | |
| | | /** |
| | |
| | | |
| | | }, |
| | | |
| | | getLedgerType () { |
| | | getLedgerType(time, success, lastMonth) { |
| | | var that = this |
| | | var time = moment().format('YYYY-MM-DD') |
| | | // var time = moment().format('YYYY-MM-DD') |
| | | ledgerservice.getLedgerSummary(app.globalData.accessToken.userId, app.globalData.userInfo.extension2, time, { |
| | | success (res) { |
| | | // console.log(res); |
| | | let r = that.parseLedgerType(res) |
| | | that.setData({ |
| | | tabList: r[0], |
| | | pageList: r[1] |
| | | }) |
| | | success(res) { |
| | | let r = that.parseLedgerType(res, lastMonth) |
| | | success(r) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | parseLedgerType (subtypes) { |
| | | var map = new Map() |
| | | parseLedgerType(subtypes, lastMonth) { |
| | | let monthInfo = { |
| | | totalMust: 0, |
| | | finishedMust: 0, |
| | | totalSelect: 0, |
| | | finishedSelect: 0, |
| | | status: '', |
| | | overtime: '', |
| | | suggestion: '' |
| | | } |
| | | let map = new Map() |
| | | subtypes.forEach(s => { |
| | | //月度统计 |
| | | if (s.needUpdate) { |
| | | monthInfo.totalMust++ |
| | | if (s.upLoad) { |
| | | monthInfo.finishedMust++ |
| | | } |
| | | } else { |
| | | monthInfo.totalSelect++ |
| | | if (s.upLoad) { |
| | | monthInfo.finishedSelect++ |
| | | } |
| | | } |
| | | |
| | | //选项卡 |
| | | if (s.upLoad) { |
| | | s.tag = '/res/icons/round_check_fill.png' |
| | | } else if (s.ledgerFinished) { |
| | |
| | | } |
| | | map.get(s.ledgerType).push(s) |
| | | }); |
| | | |
| | | // |
| | | if (monthInfo.finishedMust == 0) { |
| | | monthInfo.status = '未提交' |
| | | if (lastMonth) { |
| | | monthInfo.suggestion = '当期台账完全未提交,严重影响评估结果,后续请注意' |
| | | } else { |
| | | monthInfo.suggestion = '请尽快提交台账' |
| | | } |
| | | } else if (monthInfo.finishedMust < monthInfo.totalMust) { |
| | | monthInfo.status = '部分提交' |
| | | if (lastMonth) { |
| | | monthInfo.suggestion = '当期台账部分未提交,会影响评估结果,后续请尽量提交所有台账' |
| | | } else { |
| | | monthInfo.suggestion = '当前已提交部分台账,请补全剩余台账' |
| | | } |
| | | } else { |
| | | monthInfo.status = '已提交' |
| | | if (lastMonth) { |
| | | monthInfo.suggestion = '当期台账已全部提交,请保持' |
| | | } else { |
| | | monthInfo.suggestion = '本期台账已全部提交' |
| | | } |
| | | } |
| | | monthInfo.overtime = moment().date() - this.DEADLINEDAY |
| | | monthInfo.percent = Math.round(monthInfo.finishedMust / monthInfo.totalMust * 100) |
| | | |
| | | console.log(lastMonth); |
| | | console.log(monthInfo); |
| | | |
| | | //选项卡 |
| | | var t = [] |
| | | var p = [] |
| | | for(let item of map){ |
| | | for (let item of map) { |
| | | console.log(item); |
| | | t.push(item[0]) |
| | | let notUpload = 0 |
| | | item[1].forEach(l => { |
| | | if (l.needUpdate && !l.upLoad) { |
| | | notUpload++ |
| | | } |
| | | }); |
| | | t.push({ |
| | | name: item[0], |
| | | tag: notUpload, |
| | | total: item[1].length |
| | | }) |
| | | p.push(item[1]) |
| | | } |
| | | |
| | | return [t, p] |
| | | return [t, p, monthInfo] |
| | | }, |
| | | |
| | | gotoLedgerDetail (e) { |
| | | 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]] |
| | | console.log(indexGroup); |
| | | console.log(ledger); |
| | | |
| | | var that = this |
| | | wx.navigateTo({ |
| | |
| | | }) |
| | | }, |
| | | |
| | | gotoHistory(){ |
| | | let tabList = this.data.tabList |
| | | wx.navigateTo({ |
| | | url: '/pages/module_ledger/ledgerhistory/ledgerhistory', |
| | | 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) { |
| | | that.setData({ |
| | | pageheight: rect.height + 'px' |
| | | }); |
| | | console.log(rect.height); |
| | | let pageheight = that.data.pageheight.split('px')[0] |
| | | pageheight = parseInt(pageheight) |
| | | if (rect.height > pageheight) { |
| | | that.setData({ |
| | | pageheight: rect.height + 'px' |
| | | }); |
| | | } |
| | | }).exec(); |
| | | }, |
| | | swichNav: function (e) { |
| | |
| | | currentTab: e.target.dataset.current, |
| | | navScrollLeft: e.target.dataset.current >= 3 ? ((e.target.dataset.current) * 60) : 0 //判断当前选中的个数是否是第5个 |
| | | }) |
| | | that.tabsHeight('.page'+e.target.dataset.current); //查询哪一个元素 |
| | | // that.tabsHeight('.page' + e.target.dataset.current); //查询哪一个元素 |
| | | } |
| | | }, |
| | | bindChange: function (e) { |
| | |
| | | currentTab: e.detail.current, |
| | | navScrollLeft: e.detail.current >= 3 ? ((e.detail.current) * 60) : 0 //判断当前选中的个数是否是第5个 |
| | | }); |
| | | // that.tabsHeight('.page'+e.target.dataset.current); //查询哪一个元素 |
| | | that.tabsHeight('.page' + e.detail.current); //查询哪一个元素 |
| | | }, |
| | | |
| | | changeMonth(){ |
| | | let showThisMonth = !this.data.showThisMonth |
| | | this.setData({showThisMonth}) |
| | | } |
| | | }) |