Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4eacfafe2 | ||
|
|
f8c816dc38 | ||
|
|
e2d9049e45 | ||
|
|
1b0049e342 | ||
|
|
87a5d4f81d | ||
|
|
d6ec7b24ec | ||
|
|
194c91cf25 | ||
|
|
68797e4fb5 | ||
|
|
af4ae1cbc3 | ||
|
|
c42abb05da |
@@ -316,13 +316,30 @@ def attach_common(conn, resource, items):
|
|||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
def monthly_finance(conn):
|
def monthly_finance(conn, tenant="科普·无界"):
|
||||||
|
from datetime import date
|
||||||
|
today = date.today()
|
||||||
|
# 12 months: 9 before + current + 2 after
|
||||||
|
from dateutil.relativedelta import relativedelta
|
||||||
|
start = today + relativedelta(months=-9)
|
||||||
|
months = []
|
||||||
|
for i in range(12):
|
||||||
|
m = start + relativedelta(months=i)
|
||||||
|
months.append(m.strftime("%Y-%m"))
|
||||||
data = []
|
data = []
|
||||||
for item in rows(conn, "SELECT DISTINCT month FROM finance_records ORDER BY month"):
|
for month in months:
|
||||||
month = item["month"]
|
def s(cat):
|
||||||
revenue = one(conn, "SELECT COALESCE(SUM(amount),0) AS v FROM finance_records WHERE month=? AND record_type='revenue'", (month,))["v"]
|
return one(conn, "SELECT COALESCE(SUM(amount),0) AS v FROM finance_records WHERE month=? AND category=? AND tenant=?", (month, cat, tenant))["v"]
|
||||||
cost = one(conn, "SELECT COALESCE(SUM(amount),0) AS v FROM finance_records WHERE month=? AND record_type='cost_expense'", (month,))["v"]
|
revenue = s("确认收入") + s("签单")
|
||||||
data.append({"month": month, "revenue": revenue, "gross_profit": revenue - cost, "cost_expense": cost, "net_profit": revenue - cost})
|
labor = s("人力成本")
|
||||||
|
expense = s("费用")
|
||||||
|
purchase = s("外部采购")
|
||||||
|
net = revenue - labor - expense - purchase
|
||||||
|
data.append({
|
||||||
|
"month": month, "revenue": revenue,
|
||||||
|
"labor": labor, "expense": expense, "purchase": purchase,
|
||||||
|
"net_profit": net,
|
||||||
|
})
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
@@ -333,25 +350,35 @@ def index():
|
|||||||
|
|
||||||
@app.route("/api/bootstrap")
|
@app.route("/api/bootstrap")
|
||||||
def bootstrap():
|
def bootstrap():
|
||||||
|
tenant = request.args.get("tenant", "科普·无界")
|
||||||
conn = db()
|
conn = db()
|
||||||
try:
|
try:
|
||||||
sales = attach_common(conn, "sales", rows(conn, "SELECT * FROM sales_leads ORDER BY id DESC"))
|
def q(sql, *args):
|
||||||
proposals = attach_common(conn, "proposals", rows(conn, "SELECT * FROM business_proposals ORDER BY id DESC"))
|
return rows(conn, sql, args)
|
||||||
operations = attach_common(conn, "operations", rows(conn, "SELECT * FROM operation_projects ORDER BY id DESC"))
|
sales = attach_common(conn, "sales", q("SELECT * FROM sales_leads WHERE tenant=? ORDER BY id DESC", tenant))
|
||||||
products = attach_common(conn, "products", rows(conn, "SELECT * FROM product_versions ORDER BY id DESC"))
|
proposals = attach_common(conn, "proposals", q("SELECT * FROM business_proposals WHERE tenant=? ORDER BY id DESC", tenant))
|
||||||
finance = rows(conn, "SELECT * FROM finance_records ORDER BY month DESC, id DESC")
|
operations = attach_common(conn, "operations", q("SELECT * FROM operation_projects WHERE tenant=? ORDER BY id DESC", tenant))
|
||||||
|
products = attach_common(conn, "products", q("SELECT * FROM product_versions WHERE tenant=? ORDER BY id DESC", tenant))
|
||||||
|
finance = q("SELECT * FROM finance_records WHERE tenant=? ORDER BY month DESC, id DESC", tenant)
|
||||||
|
tasks = q("SELECT * FROM project_tasks WHERE tenant=? ORDER BY phase, sort_order, id", tenant)
|
||||||
current_month = "2026-06"
|
current_month = "2026-06"
|
||||||
# Finance aggregates
|
# Finance aggregates
|
||||||
def sum_finance(months, rtype):
|
def sum_cat(months, cat):
|
||||||
return sum(x["amount"] for x in finance if x["month"] in months and x["record_type"] == rtype)
|
return sum(x["amount"] for x in finance if x["month"] in months and x.get("category") == cat)
|
||||||
months_2026 = [f"2026-{m:02d}" for m in range(1,7)]
|
months_2026 = [f"2026-{m:02d}" for m in range(1,7)]
|
||||||
months_q2 = ["2026-04","2026-05","2026-06"]
|
months_q2 = ["2026-04","2026-05","2026-06"]
|
||||||
revenue_annual = sum_finance(months_2026, "revenue")
|
rev_annual = sum_cat(months_2026, "确认收入") + sum_cat(months_2026, "签单")
|
||||||
cost_annual = sum_finance(months_2026, "cost_expense")
|
labor_annual = sum_cat(months_2026, "人力成本")
|
||||||
revenue_q2 = sum_finance(months_q2, "revenue")
|
expense_annual = sum_cat(months_2026, "费用")
|
||||||
cost_q2 = sum_finance(months_q2, "cost_expense")
|
purchase_annual = sum_cat(months_2026, "外部采购")
|
||||||
revenue_month = sum_finance([current_month], "revenue")
|
rev_q2 = sum_cat(months_q2, "确认收入") + sum_cat(months_q2, "签单")
|
||||||
cost_month = sum_finance([current_month], "cost_expense")
|
labor_q2 = sum_cat(months_q2, "人力成本")
|
||||||
|
expense_q2 = sum_cat(months_q2, "费用")
|
||||||
|
purchase_q2 = sum_cat(months_q2, "外部采购")
|
||||||
|
rev_month = sum_cat([current_month], "确认收入") + sum_cat([current_month], "签单")
|
||||||
|
labor_month = sum_cat([current_month], "人力成本")
|
||||||
|
expense_month = sum_cat([current_month], "费用")
|
||||||
|
purchase_month = sum_cat([current_month], "外部采购")
|
||||||
# Contract aggregates — time-based
|
# Contract aggregates — time-based
|
||||||
signed_amount = sum(x["expected_contract_amount"] or 0 for x in operations if x["project_status"] == "已签约")
|
signed_amount = sum(x["expected_contract_amount"] or 0 for x in operations if x["project_status"] == "已签约")
|
||||||
from datetime import date
|
from datetime import date
|
||||||
@@ -374,8 +401,9 @@ def bootstrap():
|
|||||||
"active_sales": len([x for x in sales if x["status"] in ["待跟进", "跟进中", "方案中", "商务谈判"]]),
|
"active_sales": len([x for x in sales if x["status"] in ["待跟进", "跟进中", "方案中", "商务谈判"]]),
|
||||||
"execution_projects": len([x for x in operations if x["project_type"] == "execution"]),
|
"execution_projects": len([x for x in operations if x["project_type"] == "execution"]),
|
||||||
"risk_projects": len([x for x in operations if x["project_status"] == "有风险" or x["risks"]]),
|
"risk_projects": len([x for x in operations if x["project_status"] == "有风险" or x["risks"]]),
|
||||||
"monthly_revenue": revenue_month,
|
"monthly_revenue": rev_month,
|
||||||
"monthly_net_profit": revenue_month - cost_month,
|
"monthly_net_profit": rev_month - labor_month - expense_month - purchase_month,
|
||||||
|
"monthly_gross": rev_month - labor_month - expense_month - purchase_month,
|
||||||
"upcoming_products": len([x for x in products if x["status"] in ["规划中", "设计中", "开发中", "测试中"]]),
|
"upcoming_products": len([x for x in products if x["status"] in ["规划中", "设计中", "开发中", "测试中"]]),
|
||||||
"total_projects": len(operations),
|
"total_projects": len(operations),
|
||||||
"total_proposals": len(proposals),
|
"total_proposals": len(proposals),
|
||||||
@@ -386,27 +414,27 @@ def bootstrap():
|
|||||||
"signed_q2": signed_q2,
|
"signed_q2": signed_q2,
|
||||||
"signed_month": signed_month,
|
"signed_month": signed_month,
|
||||||
"pipeline_amount": pipeline_amount,
|
"pipeline_amount": pipeline_amount,
|
||||||
"revenue_annual": revenue_annual,
|
"revenue_annual": rev_annual,
|
||||||
"revenue_q2": revenue_q2,
|
"revenue_q2": rev_q2,
|
||||||
"gross_annual": revenue_annual - cost_annual,
|
"gross_annual": rev_annual - labor_annual - expense_annual - purchase_annual,
|
||||||
"gross_q2": revenue_q2 - cost_q2,
|
"gross_q2": rev_q2 - labor_q2 - expense_q2 - purchase_q2,
|
||||||
"signed_not_executed": signed_not_executed,
|
"signed_not_executed": signed_not_executed,
|
||||||
},
|
},
|
||||||
"recent": rows(conn, "SELECT * FROM follow_up_records ORDER BY id DESC LIMIT 8"),
|
"recent": q("SELECT * FROM follow_up_records WHERE tenant=? ORDER BY id DESC LIMIT 8", tenant),
|
||||||
"risks": [{"title": "执行提醒", "content": x["next_action"]} for x in operations if x["next_action"]][:5],
|
"risks": [{"title": "执行提醒", "content": x["next_action"]} for x in operations if x["next_action"]][:5],
|
||||||
}
|
}
|
||||||
return jsonify({"summary": summary, "sales": sales, "proposals": proposals, "operations": operations, "products": products, "finance": finance, "financeMonthly": monthly_finance(conn), "tasks": rows(conn, "SELECT * FROM project_tasks ORDER BY phase, sort_order, id")})
|
return jsonify({"summary": summary, "sales": sales, "proposals": proposals, "operations": operations, "products": products, "finance": finance, "financeMonthly": monthly_finance(conn, tenant), "tasks": tasks, "tenant": tenant, "tenants": ["科普·无界","科研·无界","医患·无界"]})
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
TABLES = {
|
TABLES = {
|
||||||
"sales": ("sales_leads", ["target_customer", "priority", "status"]),
|
"sales": ("sales_leads", ["target_customer", "priority", "status", "tenant"]),
|
||||||
"proposals": ("business_proposals", ["customer_or_project_name", "version", "description", "status", "created_date"]),
|
"proposals": ("business_proposals", ["customer_or_project_name", "version", "description", "status", "created_date", "tenant"]),
|
||||||
"operations": ("operation_projects", ["project_name", "project_version", "project_type", "project_status", "current_stage", "owner", "target_customer", "customer_need", "expected_contract_amount", "expected_sign_date", "sign_probability", "next_action", "sop_stage", "execution_progress", "current_deliverable", "risks", "notes"]),
|
"operations": ("operation_projects", ["project_name", "project_version", "project_type", "project_status", "current_stage", "owner", "target_customer", "customer_need", "expected_contract_amount", "expected_sign_date", "sign_probability", "next_action", "sop_stage", "execution_progress", "current_deliverable", "risks", "notes", "tenant"]),
|
||||||
"products": ("product_versions", ["product_name", "version", "version_goal", "feature_list", "launch_date", "status", "platform", "notes"]),
|
"products": ("product_versions", ["product_name", "version", "version_goal", "feature_list", "launch_date", "status", "platform", "notes", "tenant"]),
|
||||||
"finance": ("finance_records", ["month", "project_name", "record_type", "category", "amount", "occurred_date", "notes"]),
|
"finance": ("finance_records", ["month", "project_name", "record_type", "category", "amount", "occurred_date", "notes", "tenant"]),
|
||||||
"tasks": ("project_tasks", ["project_id", "phase", "milestone", "task", "owner", "due_date", "blockers", "notes", "status", "sort_order"]),
|
"tasks": ("project_tasks", ["project_id", "phase", "milestone", "task", "owner", "due_date", "blockers", "notes", "status", "sort_order", "tenant"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
Flask==3.0.3
|
Flask==3.0.3
|
||||||
|
python-dateutil==2.9.0
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const state = {
|
const state = {
|
||||||
active: "home",
|
active: "home",
|
||||||
data: null,
|
data: null,
|
||||||
|
tenant: "科普·无界",
|
||||||
opFilter: "all",
|
opFilter: "all",
|
||||||
projectView: null,
|
projectView: null,
|
||||||
chart: null,
|
chart: null,
|
||||||
@@ -48,7 +49,7 @@ function renderTable(headers, rows, rowClicks) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
state.data = await api("/api/bootstrap");
|
state.data = await api(`/api/bootstrap?tenant=${encodeURIComponent(state.tenant)}`);
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,8 +230,29 @@ window.submitTaskForm = async (event, projectId) => {
|
|||||||
alert("保存失败:" + error.message);
|
alert("保存失败:" + error.message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.createFinance = (event) => createResource(event, "finance");
|
window.createFinance = async (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const data = Object.fromEntries(new FormData(event.currentTarget).entries());
|
||||||
|
// Map form: month(date)→month(YYYY-MM), category→category, amount, tenant
|
||||||
|
data.month = data.month.substring(0, 7);
|
||||||
|
data.project_name = state.tenant;
|
||||||
|
data.tenant = state.tenant;
|
||||||
|
data.record_type = "revenue"; // default, will be adjusted by category
|
||||||
|
try {
|
||||||
|
await api("/api/finance", { method: "POST", body: JSON.stringify({ data }) });
|
||||||
|
await load();
|
||||||
|
} catch (error) {
|
||||||
|
alert("新增失败:" + error.message);
|
||||||
|
}
|
||||||
|
};
|
||||||
window.switchTab = switchTab;
|
window.switchTab = switchTab;
|
||||||
|
window.switchTenant = (tenant) => {
|
||||||
|
state.tenant = tenant;
|
||||||
|
state.projectView = null;
|
||||||
|
const label = tenant.replace("·无界", "");
|
||||||
|
document.querySelector("#workspaceTitle").textContent = label + " OPC 工作台";
|
||||||
|
load();
|
||||||
|
};
|
||||||
|
|
||||||
function renderProjects() {
|
function renderProjects() {
|
||||||
// 二级页面:项目任务详情
|
// 二级页面:项目任务详情
|
||||||
@@ -278,7 +300,7 @@ function renderProjectTasks(projectId) {
|
|||||||
${phases.map((phase) => {
|
${phases.map((phase) => {
|
||||||
const pt = tasks.filter((t) => t.phase === phase);
|
const pt = tasks.filter((t) => t.phase === phase);
|
||||||
if (!pt.length) return "";
|
if (!pt.length) return "";
|
||||||
return `<div class="task-group"><div class="task-group-hd"><span class="task-group-icon"><i data-lucide="layers"></i></span><span class="task-group-label">${phase}</span><span class="task-group-n">${pt.length}</span></div><div class="task-group-list" data-phase="${phase}" ondrop="handleTaskDrop(event, ${projectId}, '${phase}')" ondragover="event.preventDefault(); event.currentTarget.classList.add('drag-over')" ondragleave="event.currentTarget.classList.remove('drag-over')">${pt.map((t) => `<div class="task-row ${t.status === 'done' ? 'task-done' : ''}" data-id="${t.id}" draggable="true" ondragstart="handleTaskDragStart(event, ${t.id})" ondragend="event.currentTarget.classList.remove('dragging')"><span class="task-dot" onclick="event.stopPropagation(); toggleTaskDone(${t.id}, ${projectId})"><i data-lucide="${t.status === 'done' ? 'check-circle' : 'circle'}"></i></span><div class="task-main" onclick="openTaskForm(${projectId}, ${t.id})"><span class="task-name">${t.task}</span>${t.notes ? `<span class="task-desc">${t.notes}</span>` : ""}${t.blockers ? `<span class="task-blocker">⚠ ${t.blockers}</span>` : ""}</div><span class="task-col">${t.owner || ""}</span><span class="task-col-badge">${t.due_date || ""}</span></div>`).join("")}</div></div>`;
|
return `<div class="task-group"><div class="task-group-hd"><span class="task-group-icon"><i data-lucide="layers"></i></span><span class="task-group-label">${phase}</span><span class="task-group-n">${pt.length}</span></div><div class="task-group-list" data-phase="${phase}" ondrop="handleTaskDrop(event, ${projectId}, '${phase}')" ondragover="event.preventDefault(); event.currentTarget.classList.add('drag-over')" ondragleave="event.currentTarget.classList.remove('drag-over')">${pt.map((t) => `<div class="task-row ${t.status === 'done' ? 'task-done' : ''}" data-id="${t.id}" draggable="true" ondragstart="handleTaskDragStart(event, ${t.id})" ondragend="event.currentTarget.classList.remove('dragging')"><span class="task-dot" onclick="event.stopPropagation(); toggleTaskDone(${t.id}, ${projectId})"><i data-lucide="${t.status === 'done' ? 'check-circle' : 'circle'}"></i></span><span class="task-grip"><i data-lucide="grip-vertical"></i></span><div class="task-main" onclick="openTaskForm(${projectId}, ${t.id})"><span class="task-name">${t.task}</span>${t.notes ? `<span class="task-desc">${t.notes}</span>` : ""}${t.blockers ? `<span class="task-blocker">⚠ ${t.blockers}</span>` : ""}</div><span class="task-col">${t.owner || ""}</span><span class="task-col-badge">${t.due_date || ""}</span></div>`).join("")}</div></div>`;
|
||||||
}).join("")}
|
}).join("")}
|
||||||
</div>
|
</div>
|
||||||
<div id="task-drawer-${projectId}" class="task-drawer">
|
<div id="task-drawer-${projectId}" class="task-drawer">
|
||||||
@@ -399,19 +421,46 @@ function renderProducts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderFinance() {
|
function renderFinance() {
|
||||||
const rows = state.data.finance.map((x) => [x.month, badge(x.record_type === "revenue" ? "收入" : "成本/费用"), x.category, money(x.amount), x.occurred_date, text(x.notes)]);
|
const rows = state.data.finance.map((x) => [x.month, x.category, money(x.amount), text(x.notes)]);
|
||||||
document.querySelector("#finance").innerHTML = `<div class="grid gap-4">
|
document.querySelector("#finance").innerHTML = `<div class="grid gap-4">
|
||||||
${card(`<h2 class="mb-4 text-lg font-bold">收入、毛利、成本/费用、净利月度曲线</h2><div style="position:relative;height:300px"><canvas id="financeChart2"></canvas></div>`, "p-5")}
|
${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")}
|
||||||
${card(formHtml([
|
${card(formHtml([
|
||||||
{ label: "月份", input: `<input name="month" required placeholder="YYYY-MM" pattern="\\d{4}-\\d{2}">` },
|
{ label: "日期", input: `<input name="month" type="date" required>` },
|
||||||
{ label: "类型", input: `<select name="record_type"><option value="revenue">收入</option><option value="cost_expense">成本/费用</option></select>` },
|
{ label: "类型", input: `<select name="category"><option>签单</option><option>确认收入</option><option>人力成本</option><option>费用</option><option>外部采购</option></select>` },
|
||||||
{ label: "分类", input: `<input name="category" required>` },
|
|
||||||
{ label: "金额/万", input: `<input name="amount" type="number" step="0.01" required>` },
|
{ label: "金额/万", input: `<input name="amount" type="number" step="0.01" required>` },
|
||||||
{ label: "发生日期", input: `<input name="occurred_date" type="date">` },
|
{ label: "费用说明", input: `<input name="notes" placeholder="摘要说明">` },
|
||||||
], { handler: "createFinance", text: "新增明细" }), "p-4")}
|
], { handler: "createFinance", text: "新增明细" }), "p-4")}
|
||||||
${renderTable(["月份", "类型", "分类", "金额", "发生日期", "备注"], rows)}
|
${card(`<h3 class="font-bold text-slate-700 mb-3">明细列表 <span class="text-slate-400 font-normal">(${state.data.finance.length})</span></h3>${renderTable(["日期", "类型", "金额", "备注"], rows)}`, "p-4")}
|
||||||
</div>`;
|
</div>`;
|
||||||
renderChartOn("financeChart2", state.data.financeMonthly);
|
if (window.lucide) window.lucide.createIcons();
|
||||||
|
}
|
||||||
|
window.toggleFinanceChart = () => {
|
||||||
|
const wrap = document.querySelector("#financeChartWrap");
|
||||||
|
const icon = document.querySelector("#financeChartIcon");
|
||||||
|
if (!wrap) return;
|
||||||
|
wrap.classList.toggle("hidden");
|
||||||
|
icon.classList.toggle("rotate-90");
|
||||||
|
if (!wrap.classList.contains("hidden") && !state.chart2) renderFinanceChart();
|
||||||
|
};
|
||||||
|
function renderFinanceChart() {
|
||||||
|
const { financeMonthly } = state.data;
|
||||||
|
const canvas = document.querySelector("#financeChart2");
|
||||||
|
if (!canvas || !window.Chart) return;
|
||||||
|
if (state.chart2) state.chart2.destroy();
|
||||||
|
state.chart2 = new Chart(canvas, {
|
||||||
|
type: "line",
|
||||||
|
data: {
|
||||||
|
labels: financeMonthly.map((x) => x.month),
|
||||||
|
datasets: [
|
||||||
|
{ label: "确认收入", data: financeMonthly.map((x) => x.revenue), borderColor: "#2563eb", tension: 0.3 },
|
||||||
|
{ label: "人力成本", data: financeMonthly.map((x) => x.labor), borderColor: "#ef4444", tension: 0.3 },
|
||||||
|
{ label: "费用", data: financeMonthly.map((x) => x.expense), borderColor: "#d97706", tension: 0.3 },
|
||||||
|
{ label: "外部采购", data: financeMonthly.map((x) => x.purchase), borderColor: "#8b5cf6", tension: 0.3 },
|
||||||
|
{ label: "月度净利", data: financeMonthly.map((x) => x.net_profit), borderColor: "#059669", tension: 0.3, borderDash: [5,3] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { position: "bottom", labels: { boxWidth: 12, font: { size: 11 } } } }, scales: { x: { ticks: { font: { size: 11 } }, grid: { display: false } }, y: { ticks: { font: { size: 11 }, callback: (v) => v + "万" } } } },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderChartOn(id, data) {
|
function renderChartOn(id, data) {
|
||||||
@@ -469,7 +518,7 @@ function openDrawer(resource, id) {
|
|||||||
const multilineFields = ["customer_need", "current_deliverable", "risks", "next_action", "version_goal", "feature_list", "notes"];
|
const multilineFields = ["customer_need", "current_deliverable", "risks", "next_action", "version_goal", "feature_list", "notes"];
|
||||||
const followupTarget = resource === "sales" ? "sales" : resource === "proposals" ? "proposal" : resource === "operations" ? "operation" : resource === "products" ? "product" : "";
|
const followupTarget = resource === "sales" ? "sales" : resource === "proposals" ? "proposal" : resource === "operations" ? "operation" : resource === "products" ? "product" : "";
|
||||||
const title = item.target_customer || item.project_name || item.customer_or_project_name || item.product_name;
|
const title = item.target_customer || item.project_name || item.customer_or_project_name || item.product_name;
|
||||||
drawer.innerHTML = `<div class="drawer-panel"><div class="sticky top-0 z-10 flex items-center justify-between border-b border-slate-200 bg-white/95 px-5 py-3 backdrop-blur"><div><p class="text-[10px] font-semibold uppercase tracking-[0.18em] text-slate-400">Detail Drawer</p><div class="flex items-center gap-2"><h2 class="drawer-title text-[17px] font-semibold leading-6 text-slate-900">${title}</h2><span id="drawerSaveStatus" class="save-status"></span></div></div><div class="flex items-center gap-2"><button class="btn btn-ghost btn-sm text-red-600 hover:bg-red-50" onclick="deleteOperation(${id})"><i data-lucide="trash-2"></i>删除</button><button class="btn btn-ghost btn-sm" onclick="closeDrawer()">关闭</button></div></div><div class="grid gap-5 p-5">
|
drawer.innerHTML = `<div class="drawer-panel"><div class="sticky top-0 z-10 flex items-center justify-between border-b border-slate-200 bg-white/95 px-5 py-3 backdrop-blur"><div><p class="text-[10px] font-semibold uppercase tracking-[0.18em] text-slate-400">Detail Drawer</p><div class="flex items-center gap-2"><h2 class="drawer-title text-[17px] font-semibold leading-6 text-slate-900">${title}</h2><span id="drawerSaveStatus" class="save-status"></span></div></div><div class="flex items-center gap-2"><button class="btn btn-ghost btn-sm text-red-600 hover:bg-red-50" onclick="deleteDrawerItem('${resource}', ${id})"><i data-lucide="trash-2"></i>删除</button><button class="btn btn-ghost btn-sm" onclick="closeDrawer()">关闭</button></div></div><div class="grid gap-5 p-5">
|
||||||
<section>
|
<section>
|
||||||
<h3 class="drawer-section-title">属性</h3>
|
<h3 class="drawer-section-title">属性</h3>
|
||||||
<form id="drawerForm" class="drawer-fields">
|
<form id="drawerForm" class="drawer-fields">
|
||||||
@@ -571,10 +620,10 @@ function bindDrawerAutosave(resource, id, item) {
|
|||||||
|
|
||||||
|
|
||||||
window.openDrawer = openDrawer;
|
window.openDrawer = openDrawer;
|
||||||
window.deleteOperation = async (id) => {
|
window.deleteDrawerItem = async (resource, id) => {
|
||||||
if (!confirm("确认删除该项目?此操作不可撤销。")) return;
|
if (!confirm("确认删除?此操作不可撤销。")) return;
|
||||||
try {
|
try {
|
||||||
await api(`/api/operations/${id}`, { method: "DELETE" });
|
await api(`/api/${resource}/${id}`, { method: "DELETE" });
|
||||||
closeDrawer();
|
closeDrawer();
|
||||||
await load();
|
await load();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -554,6 +554,9 @@ td {
|
|||||||
.task-row:hover { background: #f8fafc; }
|
.task-row:hover { background: #f8fafc; }
|
||||||
.task-dot { display: flex; color: #cbd5e1; flex-shrink: 0; cursor: pointer; }
|
.task-dot { display: flex; color: #cbd5e1; flex-shrink: 0; cursor: pointer; }
|
||||||
.task-dot:hover { color: #6366f1; }
|
.task-dot:hover { color: #6366f1; }
|
||||||
|
.task-grip { display: flex; color: #cbd5e1; flex-shrink: 0; cursor: grab; }
|
||||||
|
.task-grip:hover { color: #94a3b8; }
|
||||||
|
.task-grip:active { cursor: grabbing; }
|
||||||
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
||||||
.task-name { color: #1e293b; font-size: 13px; }
|
.task-name { color: #1e293b; font-size: 13px; }
|
||||||
.task-desc { color: #94a3b8; font-size: 12px; word-wrap: break-word; overflow-wrap: break-word; }
|
.task-desc { color: #94a3b8; font-size: 12px; word-wrap: break-word; overflow-wrap: break-word; }
|
||||||
|
|||||||
@@ -27,9 +27,18 @@
|
|||||||
</head>
|
</head>
|
||||||
<body class="min-h-screen bg-slate-50 text-slate-950">
|
<body class="min-h-screen bg-slate-50 text-slate-950">
|
||||||
<header class="topbar border-b border-slate-200 bg-white px-8 py-5">
|
<header class="topbar border-b border-slate-200 bg-white px-8 py-5">
|
||||||
<div>
|
<div class="flex items-center gap-3">
|
||||||
<p class="eyebrow text-xs font-semibold uppercase tracking-[0.18em] text-blue-700">OPC Manager · 单用户 · 单项目</p>
|
<div>
|
||||||
<h1 class="mt-1 text-2xl font-semibold">科普(慰心斋)OPC 工作台</h1>
|
<p class="eyebrow text-xs font-semibold uppercase tracking-[0.18em] text-blue-700">OPC Manager</p>
|
||||||
|
<div class="flex items-center gap-3 mt-1">
|
||||||
|
<h1 class="text-2xl font-semibold" id="workspaceTitle">科普 OPC 工作台</h1>
|
||||||
|
<select id="tenantSelect" class="rounded-md border border-slate-200 bg-white px-3 py-1.5 text-sm font-medium text-slate-700 outline-none focus:border-blue-500" onchange="switchTenant(this.value)">
|
||||||
|
<option value="科普·无界">科普·无界</option>
|
||||||
|
<option value="科研·无界">科研·无界</option>
|
||||||
|
<option value="医患·无界">医患·无界</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button id="refreshBtn" class="rounded-md border border-slate-200 bg-white px-3 py-2 text-sm font-medium hover:bg-slate-50" type="button"><i data-lucide="refresh-cw"></i>刷新</button>
|
<button id="refreshBtn" class="rounded-md border border-slate-200 bg-white px-3 py-2 text-sm font-medium hover:bg-slate-50" type="button"><i data-lucide="refresh-cw"></i>刷新</button>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
Reference in New Issue
Block a user