From 068be2757aa2d51e3f6604dae54287683160ad0e Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 19 一月 2026 17:29:48 +0800
Subject: [PATCH] 2026.1.19
---
model/ledger.js | 141 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 119 insertions(+), 22 deletions(-)
diff --git a/model/ledger.js b/model/ledger.js
index a4cb035..4d3a254 100644
--- a/model/ledger.js
+++ b/model/ledger.js
@@ -1,8 +1,8 @@
const moment = require('../utils/moment.min');
+const app = getApp();
-// 缁熻鍙拌处涓婁紶鎯呭喌
-function parseLedgerStat(subtypes, lastMonth) {
- const DEADLINEDAY = 10;
+function name(params) {
+ const DEADLINEDAY = app.globalData.userSetting.ledgerDeadline;
let monthInfo = {
totalMust: 0,
finishedMust: 0,
@@ -85,6 +85,8 @@
//閫夐」鍗�
var t = [];
var p = [];
+ var tSelf = [];
+ var pSelf = [];
for (let item of map) {
let notUpload = 0;
item[1].forEach(l => {
@@ -100,35 +102,130 @@
p.push(item[1]);
}
- return [t, p, monthInfo];
+ return { types: t, items: p, monthInfo };
+}
+
+/**
+ * 瀵瑰彴璐︽垨鑷贰鏌ヨ繘琛岀粺璁★紝绫诲瀷ledgerTypeId涓�-1鐨勬槸鑷贰鏌ワ紝鍏朵綑涓哄彴璐�
+ * @param {Array} subtypes 鍙拌处璁板綍
+ * @param {Boolean} isSelfPatrol 鏄惁缁熻鑷贰鏌ョ被鍨�
+ */
+function _parse(subtypes, isSelfPatrol) {
+ const DEADLINEDAY = 10;
+ // 鏈堝害缁熻
+ let monthInfo = {
+ // 鍏ㄩ儴蹇呭~鏁�
+ totalMust: 0,
+ // 瀹屾垚蹇呭~鏁�
+ finishedMust: 0,
+ // 蹇呭~瀹屾垚鐧惧垎姣�
+ percent: 0,
+ // 鍏ㄩ儴閫夊~鏁�
+ totalSelect: 0,
+ // 瀹屾垚閫夊~鏁�
+ finishedSelect: 0,
+ // 鎻愪氦鐘舵�侊細鏈彁浜� | 閮ㄥ垎鎻愪氦 | 宸叉彁浜�
+ status: '',
+ // 閫炬湡澶╂暟
+ overtime: '',
+ // 寤鸿
+ suggestion: '',
+ };
+ let map = new Map();
+ for (let i = 0; i < subtypes.length; i++) {
+ const s = subtypes[i];
+ // 缁熻鑷贰鏌ユ椂锛岃繃婊ゆ櫘閫氬彴璐�
+ if (isSelfPatrol && s.ledgerTypeId != -1) continue;
+ // 缁熻鍙拌处鏃讹紝杩囨护鑷贰鏌�
+ if (!isSelfPatrol && s.ledgerTypeId == -1) continue;
+ // 鍒嗗埆缁熻蹇呭~鍜岄�夊~鐨勫畬鎴愭儏鍐�
+ if (s.needUpdate) {
+ monthInfo.totalMust++;
+ if (s.upLoad) monthInfo.finishedMust++;
+ } else {
+ monthInfo.totalSelect++;
+ if (s.upLoad) monthInfo.finishedSelect++;
+ }
+ refreshLedgerStatus(s);
+ if (!map.has(s.ledgerType)) map.set(s.ledgerType, []);
+ map.get(s.ledgerType).push(s);
+ }
+
+ //
+ if (monthInfo.finishedMust + monthInfo.finishedSelf == 0) {
+ monthInfo.status = '鏈彁浜�';
+ monthInfo.suggestion = '鍙拌处瀹屽叏鏈彁浜わ紝灏嗕弗閲嶅奖鍝嶈瘎浼扮粨鏋�';
+ } else if (monthInfo.finishedMust < monthInfo.totalMust) {
+ monthInfo.status = '閮ㄥ垎鎻愪氦';
+ monthInfo.suggestion = '鍙拌处閮ㄥ垎鏈彁浜わ紝浼氬奖鍝嶈瘎浼扮粨鏋�';
+ } else {
+ monthInfo.status = '宸叉彁浜�';
+ monthInfo.suggestion = '鍙拌处宸插叏閮ㄦ彁浜�';
+ }
+ monthInfo.overtime = moment().date() - DEADLINEDAY;
+ monthInfo.percent =
+ monthInfo.totalMust == 0
+ ? 0
+ : Math.round((monthInfo.finishedMust / monthInfo.totalMust) * 100);
+
+ //閫夐」鍗�
+ var t = [];
+ var p = [];
+ for (let item of map) {
+ 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 { types: t, items: p, monthInfo };
+}
+// 缁熻鍙拌处涓婁紶鎯呭喌
+function parseLedgerStat(subtypes) {
+ return _parse(subtypes);
+}
+
+// 缁熻鑷贰鏌ヤ笂浼犳儏鍐�
+function parseSelfPatrol(subtypes) {
+ return _parse(subtypes, true);
}
function refreshLedgerStatus(s) {
- if (s.upLoad) {
+ // if (s.ledgerFinished) {
+ // s.badge = {
+ // color: 'yellow',
+ // count: '!',
+ // };
+ // s.opacity = 1;
+ // }
+ if (!s.needUpdate) {
s.badge = {
- color: 'green',
- count: '鉁�',
- };
- s.opacity = 0.7;
- } else if (s.ledgerFinished) {
- s.badge = {
- color: 'yellow',
- count: '!',
+ color: '#00500079',
+ count: '閫夊~',
+ shape: 'bubble',
};
s.opacity = 1;
- } else if (!s.needUpdate) {
- s.badge = {
- color: 'green',
- count: '閫夊~',
- };
- s.opacity = 0.8;
} else {
s.badge = {
- color: 'red',
- count: '!',
+ color: 'ff00005d',
+ count: '蹇呭~',
+ shape: 'bubble',
};
s.opacity = 1;
}
+ if (s.upLoad) {
+ s.badge.color = 'gray';
+ // s.badge.count += '鉁�';
+ s.opacity = 0.4;
+ }
}
-export { parseLedgerStat, refreshLedgerStatus };
+export { parseLedgerStat, parseSelfPatrol, refreshLedgerStatus };
--
Gitblit v1.9.3