From 48145f787eda81815f653ad21161a60e89b6a303 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 13 十一月 2024 16:41:32 +0800
Subject: [PATCH] 2024.11.13
---
pages/mLedger/ledgerhome/ledgerhome.js | 248 ++++++++++++++++++++++++++-----------------------
1 files changed, 132 insertions(+), 116 deletions(-)
diff --git a/pages/mLedger/ledgerhome/ledgerhome.js b/pages/mLedger/ledgerhome/ledgerhome.js
index 2348115..d4156e9 100644
--- a/pages/mLedger/ledgerhome/ledgerhome.js
+++ b/pages/mLedger/ledgerhome/ledgerhome.js
@@ -1,10 +1,8 @@
-// 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({
-
/**
* 椤甸潰鐨勫垵濮嬫暟鎹�
*/
@@ -32,7 +30,7 @@
//瓒呮椂鎯呭喌
overtime: '',
//寤鸿
- suggestion: ''
+ suggestion: '',
},
//涓婃湀姹囨��
lastMonthInfo: {
@@ -42,7 +40,7 @@
finishedSelect: 0,
status: '',
overtime: '',
- suggestion: ''
+ suggestion: '',
},
//閫夐」鍗$浉鍏�
@@ -62,62 +60,67 @@
* 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
*/
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 => {
- this.setData({
- lastMonthInfo: r[2]
- })
- }, true) //涓婃湀
+ thisMonthInfo: r[2],
+ });
+ this.tabsHeight('.page0');
+ }); //鏈湀
+ this.getLedgerType(
+ now.add(-1, 'M').format('YYYY-MM-DD'),
+ r => {
+ this.setData({
+ 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, {
- success(res) {
- let r = that.parseLedgerType(res, lastMonth)
- success(r)
- }
- })
+ ledgerservice.getLedgerSummary(
+ app.globalData.accessToken.userId,
+ app.globalData.userInfo.extension2,
+ time,
+ {
+ success(res) {
+ let r = that.parseLedgerType(res, lastMonth);
+ success(r);
+ },
+ },
+ );
},
parseLedgerType(subtypes, lastMonth) {
@@ -128,147 +131,159 @@
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
+ gotoHistory() {
+ 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)
- if (rect.height > pageheight) {
- that.setData({
- pageheight: rect.height + 'px'
- });
- }
- }).exec();
+ 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',
+ });
+ }
+ })
+ .exec();
},
swichNav: function (e) {
var that = this;
@@ -277,8 +292,9 @@
} 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); //鏌ヨ鍝竴涓厓绱�
}
},
@@ -286,13 +302,13 @@
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); //鏌ヨ鍝竴涓厓绱�
+ that.tabsHeight('.page' + e.detail.current); //鏌ヨ鍝竴涓厓绱�
},
- changeMonth(){
- let showThisMonth = !this.data.showThisMonth
- this.setData({showThisMonth})
- }
-})
\ No newline at end of file
+ changeMonth() {
+ let showThisMonth = !this.data.showThisMonth;
+ this.setData({ showThisMonth });
+ },
+});
--
Gitblit v1.9.3