diff --git a/static/modules/home.js b/static/modules/home.js
index 5f484ae..80e925c 100644
--- a/static/modules/home.js
+++ b/static/modules/home.js
@@ -6,58 +6,65 @@ function renderHome() {
const moneyInt = (v) => `${Math.round(Number(v || 0)).toLocaleString("zh-CN")} 元`;
const rows1 = [
["年度累计", moneyInt(m.signed_annual || m.signed_amount)],
- ["季度累计", moneyInt(m.signed_q2 || 0)],
- ["本月新增", moneyInt(m.signed_month || 0)],
- ["上季度累计", moneyInt(m.signed_prev_q || 0)],
+ ["本季度累计", moneyInt(m.signed_q2 || 0)],
+ ["本月累计", moneyInt(m.signed_month || 0)],
+ ["上本季度累计", moneyInt(m.signed_prev_q || 0)],
["上月累计", moneyInt(m.signed_prev_month || 0)],
];
const rows2 = [
["年度累计", moneyInt(m.revenue_annual)],
- ["季度累计", moneyInt(m.revenue_q2)],
- ["本月新增", moneyInt(m.monthly_revenue)],
- ["上季度累计", moneyInt(m.revenue_prev_q || 0)],
+ ["本季度累计", moneyInt(m.revenue_q2)],
+ ["本月累计", moneyInt(m.monthly_revenue)],
+ ["上本季度累计", moneyInt(m.revenue_prev_q || 0)],
["上月累计", moneyInt(m.revenue_prev_month || 0)],
];
const rows3 = [
["年度累计", moneyInt(m.gross_annual)],
- ["季度累计", moneyInt(m.gross_q2)],
- ["本月新增", moneyInt(m.monthly_net_profit)],
- ["上季度累计", moneyInt(m.gross_prev_q || 0)],
+ ["本季度累计", moneyInt(m.gross_q2)],
+ ["本月累计", moneyInt(m.monthly_net_profit)],
+ ["上本季度累计", moneyInt(m.gross_prev_q || 0)],
["上月累计", moneyInt(m.gross_prev_month || 0)],
];
const rows4 = [
["年度累计", moneyInt(m.payment_annual || 0)],
- ["季度累计", moneyInt(m.payment_q2 || 0)],
- ["本月新增", moneyInt(m.payment_month || 0)],
- ["上季度累计", moneyInt(m.payment_prev_q || 0)],
+ ["本季度累计", moneyInt(m.payment_q2 || 0)],
+ ["本月累计", moneyInt(m.payment_month || 0)],
+ ["上本季度累计", moneyInt(m.payment_prev_q || 0)],
["上月累计", moneyInt(m.payment_prev_month || 0)],
];
const rows5 = [
["年度累计", moneyInt(m.cost_annual || 0)],
- ["季度累计", moneyInt(m.cost_q2 || 0)],
- ["本月新增", moneyInt(m.cost_month || 0)],
- ["上季度累计", moneyInt(m.cost_prev_q || 0)],
+ ["本季度累计", moneyInt(m.cost_q2 || 0)],
+ ["本月累计", moneyInt(m.cost_month || 0)],
+ ["上本季度累计", moneyInt(m.cost_prev_q || 0)],
["上月累计", moneyInt(m.cost_prev_month || 0)],
];
const rows7 = [
["年度累计", moneyInt(m.paid_annual || 0)],
- ["季度累计", moneyInt(m.paid_q2 || 0)],
- ["本月新增", moneyInt(m.paid_month || 0)],
- ["上季度累计", moneyInt(m.paid_prev_q || 0)],
+ ["本季度累计", moneyInt(m.paid_q2 || 0)],
+ ["本月累计", moneyInt(m.paid_month || 0)],
+ ["上本季度累计", moneyInt(m.paid_prev_q || 0)],
["上月累计", moneyInt(m.paid_prev_month || 0)],
];
+ const rowsProjExpense = [
+ ["年度累计", moneyInt(m.proj_expense_annual || 0)],
+ ["本季度累计", moneyInt(m.proj_expense_q2 || 0)],
+ ["本月累计", moneyInt(m.proj_expense_month || 0)],
+ ["上本季度累计", moneyInt(m.proj_expense_prev_q || 0)],
+ ["上月累计", moneyInt(m.proj_expense_prev_month || 0)],
+ ];
const rows8 = [
["年度累计", moneyInt(m.cashflow_annual || 0)],
- ["季度累计", moneyInt(m.cashflow_q2 || 0)],
- ["本月新增", moneyInt(m.cashflow_month || 0)],
- ["上季度累计", moneyInt(m.cashflow_prev_q || 0)],
+ ["本季度累计", moneyInt(m.cashflow_q2 || 0)],
+ ["本月累计", moneyInt(m.cashflow_month || 0)],
+ ["上本季度累计", moneyInt(m.cashflow_prev_q || 0)],
["上月累计", moneyInt(m.cashflow_prev_month || 0)],
];
const rows9 = [
["年度累计", moneyInt(m.profit_annual || 0)],
- ["季度累计", moneyInt(m.profit_q2 || 0)],
- ["本月新增", moneyInt(m.profit_month || 0)],
- ["上季度累计", moneyInt(m.profit_prev_q || 0)],
+ ["本季度累计", moneyInt(m.profit_q2 || 0)],
+ ["本月累计", moneyInt(m.profit_month || 0)],
+ ["上本季度累计", moneyInt(m.profit_prev_q || 0)],
["上月累计", moneyInt(m.profit_prev_month || 0)],
];
const qoq = (cur, prev) => {
@@ -67,25 +74,34 @@ function renderHome() {
const sign = pct >= 0 ? '+' : '';
return '' + sign + pct + '%';
};
- const COLORS = ['text-slate-700','text-blue-600','text-green-600','text-amber-600','text-rose-600','text-purple-600','text-cyan-600','text-indigo-600'];
- const LABELS = ['合同金额','确收金额','确收毛利','回款金额','应付金额','已付','现金流','项目利润'];
- const Q_FIELDS = [m.signed_q2||0, m.revenue_q2, m.gross_q2, m.payment_q2||0, m.cost_q2||0, m.paid_q2||0, m.cashflow_q2||0, m.profit_q2||0];
- const Q_PREV = [m.signed_prev_q||0, m.revenue_prev_q||0, m.gross_prev_q||0, m.payment_prev_q||0, m.cost_prev_q||0, m.paid_prev_q||0, m.cashflow_prev_q||0, m.profit_prev_q||0];
- const M_FIELDS = [m.signed_month||0, m.monthly_revenue, m.monthly_net_profit, m.payment_month||0, m.cost_month||0, m.paid_month||0, m.cashflow_month||0, m.profit_month||0];
- const M_PREV = [m.signed_prev_month||0, m.revenue_prev_month||0, m.gross_prev_month||0, m.payment_prev_month||0, m.cost_prev_month||0, m.paid_prev_month||0, m.cashflow_prev_month||0, m.profit_prev_month||0];
- const ROWS = [rows1, rows2, rows3, rows4, rows5, rows7, rows8, rows9];
- var thead = '
| 指标 | 年度累计 | 季度累计 | 季环比 | 本月新增 | 月环比 | 上季度累计 | 上月累计 |
';
+ const COLORS = ['text-slate-700','text-blue-600','text-green-600','text-amber-600','text-rose-600','text-purple-600','text-orange-600','text-cyan-600','text-indigo-600'];
+ const LABELS = ['合同金额','确收金额','确收毛利','回款金额','应付金额','已付','项目费用','现金流','项目利润'];
+ const Q_FIELDS = [m.signed_q2||0, m.revenue_q2, m.gross_q2, m.payment_q2||0, m.cost_q2||0, m.paid_q2||0, m.proj_expense_q2||0, m.cashflow_q2||0, m.profit_q2||0];
+ const Q_PREV = [m.signed_prev_q||0, m.revenue_prev_q||0, m.gross_prev_q||0, m.payment_prev_q||0, m.cost_prev_q||0, m.paid_prev_q||0, m.proj_expense_prev_q||0, m.cashflow_prev_q||0, m.profit_prev_q||0];
+ const M_FIELDS = [m.signed_month||0, m.monthly_revenue, m.monthly_net_profit, m.payment_month||0, m.cost_month||0, m.paid_month||0, m.proj_expense_month||0, m.cashflow_month||0, m.profit_month||0];
+ const M_PREV = [m.signed_prev_month||0, m.revenue_prev_month||0, m.gross_prev_month||0, m.payment_prev_month||0, m.cost_prev_month||0, m.paid_prev_month||0, m.proj_expense_prev_month||0, m.cashflow_prev_month||0, m.profit_prev_month||0];
+ const ROWS = [rows1, rows2, rows3, rows4, rows5, rows7, rowsProjExpense, rows8, rows9];
+ // 现金流和项目利润的原始值数组,用于正负着色
+ const CF_RAW = [m.cashflow_annual||0, m.cashflow_q2||0, m.cashflow_month||0, m.cashflow_prev_q||0, m.cashflow_prev_month||0];
+ const PF_RAW = [m.profit_annual||0, m.profit_q2||0, m.profit_month||0, m.profit_prev_q||0, m.profit_prev_month||0];
+ var valCls = function(ri) { return (ri === 7 || ri === 8) ? '' : 'text-slate-800'; };
+ var tdVal = function(ri, col, val) {
+ if (ri === 7) return '' + val + ' | ';
+ if (ri === 8) return '' + val + ' | ';
+ return '' + val + ' | ';
+ };
+ var thead = '| 指标 | 年度累计 | 上本季度累计 | 上月累计 | 本季度累计 | 季环比 | 本月累计 | 月环比 |
';
var tbody = '';
- for (var ri = 0; ri < 8; ri++) {
+ for (var ri = 0; ri < 9; ri++) {
var vals = ROWS[ri];
tbody += '| ' + LABELS[ri] + ' | ' +
- '' + vals[0][1] + ' | ' +
- '' + vals[1][1] + ' | ' +
+ tdVal(ri, 0, vals[0][1]) +
+ tdVal(ri, 3, vals[3][1]) +
+ tdVal(ri, 4, vals[4][1]) +
+ tdVal(ri, 1, vals[1][1]) +
'' + qoq(Q_FIELDS[ri], Q_PREV[ri]) + ' | ' +
- '' + vals[2][1] + ' | ' +
- '' + qoq(M_FIELDS[ri], M_PREV[ri]) + ' | ' +
- '' + vals[3][1] + ' | ' +
- '' + vals[4][1] + ' |
';
+ tdVal(ri, 2, vals[2][1]) +
+ '' + qoq(M_FIELDS[ri], M_PREV[ri]) + ' | ';
}
document.querySelector("#home").innerHTML = `
@@ -97,10 +113,10 @@ function renderHome() {
["产品迭代", m.upcoming_products, "products"],
].map(([label, value, tab]) => ``).join("")}
`}
- ${card(`部门经营情况
| 指标 | 年度累计 | 季度累计 | 季环比 | 本月新增 | 月环比 | 上季度累计 | 上月累计 |
+ ${card(`部门经营情况
| 指标 | 年度累计 | 上本季度累计 | 上月累计 | 本季度累计 | 季环比 | 本月累计 | 月环比 |
${(() => {
var d = [
- ['部门利润', [m.profit_annual||0, m.profit_q2||0, m.profit_month||0, m.profit_prev_q||0, m.profit_prev_month||0],
+ ['部门毛利', [m.profit_annual||0, m.profit_q2||0, m.profit_month||0, m.profit_prev_q||0, m.profit_prev_month||0],
[m.profit_q2||0,m.profit_prev_q||0], [m.profit_month||0,m.profit_prev_month||0]],
['部门费用', [m.expense_annual||0, m.expense_q2||0, (m.expense_month||0), m.expense_prev_q||0, m.expense_prev_month||0],
[m.expense_q2||0,m.expense_prev_q||0], [(m.expense_month||0),m.expense_prev_month||0]],
@@ -114,16 +130,17 @@ function renderHome() {
]]
];
var h = '';
+ var netCls = function(di, raw) { return di === 2 ? (raw >= 0 ? 'text-green-600' : 'text-red-600') : 'text-slate-800'; };
for (var di = 0; di < 3; di++) {
var r = d[di];
h += '| ' + r[0] + ' | ' +
- '' + moneyInt(r[1][0]) + ' | ' +
- '' + moneyInt(r[1][1]) + ' | ' +
+ '' + moneyInt(r[1][0]) + ' | ' +
+ '' + moneyInt(r[1][3]) + ' | ' +
+ '' + moneyInt(r[1][4]) + ' | ' +
+ '' + moneyInt(r[1][1]) + ' | ' +
'' + qoq(r[2][0], r[2][1]) + ' | ' +
- '' + moneyInt(r[1][2]) + ' | ' +
- '' + qoq(r[3][0], r[3][1]) + ' | ' +
- '' + moneyInt(r[1][3]) + ' | ' +
- '' + moneyInt(r[1][4]) + ' |
';
+ '' + moneyInt(r[1][2]) + ' | ' +
+ '' + qoq(r[3][0], r[3][1]) + ' | ';
}
return h;
})()}