v3.1.2 — 财务弹窗按工作台显示项目和业务类型

This commit is contained in:
mac
2026-06-17 13:11:06 +08:00
parent 29dc7e040e
commit 0a7f70757d

View File

@@ -435,8 +435,13 @@ function renderProducts() {
}
function renderFinance() {
const pfs = state.data.projectFinances || [];
const ops = state.data.operations || [];
const fmTypesByTenant = {
"科普·无界": ["科普音频","科普视频","科普文章","全品类科普"],
"科研·无界": ["真实世界研究","调研问卷","病例征集","患者招募"],
"医患·无界": ["医患运营","患者管理","患教会","创新支付","电商","其他"],
};
const fmTypes = fmTypesByTenant[state.tenant] || fmTypesByTenant["科普·无界"];
const tenantOps = (state.data.operations || []).filter(o => (o.project_name || "").includes(state.tenant.replace("·无界","")) || o.tenant === state.tenant);
const months = ["2026-06","2026-07","2026-08","2026-09"];
const monthLabels = ["6月","7月","8月","9月"];
@@ -464,7 +469,7 @@ function renderFinance() {
${card(`<div class="flex items-center justify-between cursor-pointer" onclick="toggleFinanceChart()"><h2 class="text-lg font-bold text-slate-700">月度趋势</h2><i data-lucide="chevron-down" class="transition-transform rotate-90" id="financeChartIcon"></i></div><div id="financeChartWrap" class="hidden mt-4"><div style="position:relative;height:300px"><canvas id="financeChart2"></canvas></div></div>`, "p-5")}
<div class="flex justify-end"><button class="btn btn-primary btn-sm" onclick="openFinanceModal()"><i data-lucide="plus"></i>新增财务项目</button></div>
<div id="financeModal" class="hidden fixed inset-0 z-50 flex items-center justify-center bg-black/30" onclick="closeFinanceModal()"><div class="bg-white rounded-xl shadow-xl w-full max-w-3xl mx-4 max-h-[90vh] overflow-y-auto" onclick="event.stopPropagation()"><div class="sticky top-0 bg-white border-b px-6 py-4 flex items-center justify-between"><h3 class="font-bold text-lg" id="financeModalTitle">新增项目财务</h3><button class="btn btn-ghost btn-sm" onclick="closeFinanceModal()"><i data-lucide="x"></i></button></div><form onsubmit="createFinance(event)" class="p-6 grid gap-3"><input type="hidden" name="pf_id" id="pf-id-input" value=""><div class="grid grid-cols-3 gap-3"><label class="text-xs">项目<select name="project_id" class="rounded border px-2 py-1.5 text-sm w-full">${ops.map(o => `<option value="${o.id}">${o.project_name}</option>`).join("")}</select></label><label class="text-xs">业务类型<select name="business_type" class="rounded border px-2 py-1.5 text-sm w-full">${["科普音频","科普视频","科普文章","全品类科普","真实世界研究","调研问卷","病例征集","患者招募","医患运营","患者管理","患教会","创新支付","电商","其他"].map(t => `<option>${t}</option>`).join("")}</select></label><label class="text-xs">客户名称<input name="customer_name" class="rounded border px-2 py-1.5 text-sm w-full"></label><label class="text-xs">签约金额/万<input name="sign_amount" type="number" step="0.01" class="rounded border px-2 py-1.5 text-sm w-full"></label><label class="text-xs">签约月份<input name="sign_month" class="rounded border px-2 py-1.5 text-sm w-full"></label><label class="text-xs">状态<select name="status" class="rounded border px-2 py-1.5 text-sm w-full"><option>已签单</option><option>待签</option></select></label></div><div class="grid grid-cols-4 gap-2">${["06","07","08","09"].map(m => `<div class="border rounded p-2"><p class="text-xs text-slate-400 mb-1">${m}月</p><label class="text-xs text-slate-500">确收<br><input name="rev_2026_${m}" type="number" step="0.01" class="w-full rounded border px-1 py-1 text-sm" placeholder="万"></label><label class="text-xs text-slate-500 mt-1">毛利<br><input name="gross_2026_${m}" type="number" step="0.01" class="w-full rounded border px-1 py-1 text-sm" placeholder="万"></label></div>`).join("")}</div><div class="flex justify-end gap-2 pt-3 border-t"><button type="button" class="btn btn-ghost btn-sm" onclick="closeFinanceModal()">取消</button><button type="submit" class="btn btn-primary btn-sm">确认新增</button></div></form></div></div>
<div id="financeModal" class="hidden fixed inset-0 z-50 flex items-center justify-center bg-black/30" onclick="closeFinanceModal()"><div class="bg-white rounded-xl shadow-xl w-full max-w-3xl mx-4 max-h-[90vh] overflow-y-auto" onclick="event.stopPropagation()"><div class="sticky top-0 bg-white border-b px-6 py-4 flex items-center justify-between"><h3 class="font-bold text-lg" id="financeModalTitle">新增项目财务</h3><button class="btn btn-ghost btn-sm" onclick="closeFinanceModal()"><i data-lucide="x"></i></button></div><form onsubmit="createFinance(event)" class="p-6 grid gap-3"><input type="hidden" name="pf_id" id="pf-id-input" value=""><div class="grid grid-cols-3 gap-3"><label class="text-xs">项目<select name="project_id" class="rounded border px-2 py-1.5 text-sm w-full">${tenantOps.map(o => `<option value="${o.id}">${o.project_name}</option>`).join("")}</select></label><label class="text-xs">业务类型<select name="business_type" class="rounded border px-2 py-1.5 text-sm w-full">${fmTypes.map(t => `<option>${t}</option>`).join("")}</select></label><label class="text-xs">客户名称<input name="customer_name" class="rounded border px-2 py-1.5 text-sm w-full"></label><label class="text-xs">签约金额/万<input name="sign_amount" type="number" step="0.01" class="rounded border px-2 py-1.5 text-sm w-full"></label><label class="text-xs">签约月份<input name="sign_month" class="rounded border px-2 py-1.5 text-sm w-full"></label><label class="text-xs">状态<select name="status" class="rounded border px-2 py-1.5 text-sm w-full"><option>已签单</option><option>待签</option></select></label></div><div class="grid grid-cols-4 gap-2">${["06","07","08","09"].map(m => `<div class="border rounded p-2"><p class="text-xs text-slate-400 mb-1">${m}月</p><label class="text-xs text-slate-500">确收<br><input name="rev_2026_${m}" type="number" step="0.01" class="w-full rounded border px-1 py-1 text-sm" placeholder="万"></label><label class="text-xs text-slate-500 mt-1">毛利<br><input name="gross_2026_${m}" type="number" step="0.01" class="w-full rounded border px-1 py-1 text-sm" placeholder="万"></label></div>`).join("")}</div><div class="flex justify-end gap-2 pt-3 border-t"><button type="button" class="btn btn-ghost btn-sm" onclick="closeFinanceModal()">取消</button><button type="submit" class="btn btn-primary btn-sm">确认新增</button></div></form></div></div>
${card(`<h3 class="font-bold text-slate-700 mb-3">项目明细 <span class="text-slate-400 font-normal">(${pfs.length})</span></h3><div class="flex gap-2 mb-3">${[["已签单","已签"],["待签","待签"]].map(([k,v]) => `<button class="btn btn-sm ${state.finFilter === k ? 'btn-primary' : 'btn-ghost'}" onclick="state.finFilter='${k}';renderFinance()">${v} (${pfs.filter(x=>x.status===k).length})</button>`).join("")}</div><div class="overflow-x-auto"><table class="w-full text-sm"><thead><tr class="bg-slate-50 border-b border-slate-200"><th class="p-2 text-left font-semibold">客户</th><th class="p-2 text-left font-semibold">类型</th><th class="p-2 text-left font-semibold">状态</th><th class="p-2 text-right font-semibold">签约金额</th>${monthLabels.map(l => `<th class="p-2 text-center font-semibold">${l}<br><span class="text-xs text-slate-400">确收/毛利</span></th>`).join("")}<th class="p-2 text-left font-semibold">销售</th></tr></thead><tbody>${pfs.filter(x => x.status === state.finFilter).map(renderPfRow).join("")}</tbody></table></div>`, "p-4")}
</div>`;