|
|
|
|
@@ -2,6 +2,7 @@ const state = {
|
|
|
|
|
active: "home",
|
|
|
|
|
data: null,
|
|
|
|
|
opFilter: "all",
|
|
|
|
|
projectView: null,
|
|
|
|
|
chart: null,
|
|
|
|
|
chart2: null,
|
|
|
|
|
productPlatform: "all",
|
|
|
|
|
@@ -61,9 +62,8 @@ function switchTab(tab) {
|
|
|
|
|
function render() {
|
|
|
|
|
if (!state.data) return;
|
|
|
|
|
renderHome();
|
|
|
|
|
renderSales();
|
|
|
|
|
renderProjects();
|
|
|
|
|
renderProposals();
|
|
|
|
|
renderOperations();
|
|
|
|
|
renderProducts();
|
|
|
|
|
renderFinance();
|
|
|
|
|
if (window.lucide) window.lucide.createIcons();
|
|
|
|
|
@@ -98,10 +98,10 @@ function renderHome() {
|
|
|
|
|
<div class="grid gap-5">
|
|
|
|
|
<div class="grid grid-cols-4 gap-3">
|
|
|
|
|
${[
|
|
|
|
|
["P0 客户数", m.p0_customers, "sales"],
|
|
|
|
|
["跟进中销售机会", m.active_sales, "sales"],
|
|
|
|
|
["已签约执行项目", m.execution_projects, "operations"],
|
|
|
|
|
["有风险项目", m.risk_projects, "operations"],
|
|
|
|
|
["P0 客户数", m.p0_customers, "projects"],
|
|
|
|
|
["跟进中销售机会", m.active_sales, "projects"],
|
|
|
|
|
["已签约执行项目", m.execution_projects, "projects"],
|
|
|
|
|
["有风险项目", m.risk_projects, "projects"],
|
|
|
|
|
["本月收入", money(m.monthly_revenue), "finance"],
|
|
|
|
|
["本月净利", money(m.monthly_net_profit), "finance"],
|
|
|
|
|
["即将上线版本", m.upcoming_products, "products"],
|
|
|
|
|
@@ -110,8 +110,8 @@ function renderHome() {
|
|
|
|
|
</div>
|
|
|
|
|
<div class="grid grid-cols-4 gap-3">
|
|
|
|
|
${[
|
|
|
|
|
["已签约合同总额", money(m.signed_amount), "operations"],
|
|
|
|
|
["合同流程中", money(m.pipeline_amount), "operations"],
|
|
|
|
|
["已签约合同总额", money(m.signed_amount), "projects"],
|
|
|
|
|
["合同流程中", money(m.pipeline_amount), "projects"],
|
|
|
|
|
["年度累计确收", money(m.revenue_annual), "finance"],
|
|
|
|
|
["Q2 累计确收", money(m.revenue_q2), "finance"],
|
|
|
|
|
["年度累计毛利", money(m.gross_annual), "finance"],
|
|
|
|
|
@@ -171,24 +171,172 @@ window.createSales = (event) => createResource(event, "sales");
|
|
|
|
|
window.createProposal = (event) => createResource(event, "proposals");
|
|
|
|
|
window.createOperation = (event) => createResource(event, "operations");
|
|
|
|
|
window.createProduct = (event) => createResource(event, "products");
|
|
|
|
|
|
|
|
|
|
window.openTaskForm = (projectId, taskId) => {
|
|
|
|
|
const drawer = document.querySelector(`#task-drawer-${projectId}`);
|
|
|
|
|
const titleEl = drawer.querySelector(".task-drawer-title");
|
|
|
|
|
if (taskId === null) {
|
|
|
|
|
document.querySelector(`#task-id-${projectId}`).value = "";
|
|
|
|
|
document.querySelector(`#task-name-${projectId}`).value = "";
|
|
|
|
|
document.querySelector(`#task-phase-${projectId}`).value = "商务洽谈";
|
|
|
|
|
document.querySelector(`#task-owner-${projectId}`).value = "";
|
|
|
|
|
document.querySelector(`#task-due-${projectId}`).value = "";
|
|
|
|
|
document.querySelector(`#task-notes-${projectId}`).value = "";
|
|
|
|
|
document.querySelector(`#task-blockers-${projectId}`).value = "";
|
|
|
|
|
document.querySelector(`#task-submit-btn-${projectId}`).textContent = "确认新增";
|
|
|
|
|
if (titleEl) titleEl.textContent = "新增任务";
|
|
|
|
|
} else {
|
|
|
|
|
const task = (state.data.tasks || []).find((t) => t.id === taskId);
|
|
|
|
|
if (!task) return;
|
|
|
|
|
document.querySelector(`#task-id-${projectId}`).value = task.id;
|
|
|
|
|
document.querySelector(`#task-name-${projectId}`).value = task.task || "";
|
|
|
|
|
document.querySelector(`#task-phase-${projectId}`).value = task.phase || "商务洽谈";
|
|
|
|
|
document.querySelector(`#task-owner-${projectId}`).value = task.owner || "";
|
|
|
|
|
document.querySelector(`#task-due-${projectId}`).value = task.due_date || "";
|
|
|
|
|
document.querySelector(`#task-notes-${projectId}`).value = task.notes || "";
|
|
|
|
|
document.querySelector(`#task-blockers-${projectId}`).value = task.blockers || "";
|
|
|
|
|
document.querySelector(`#task-submit-btn-${projectId}`).textContent = "保存修改";
|
|
|
|
|
if (titleEl) titleEl.textContent = "编辑任务";
|
|
|
|
|
}
|
|
|
|
|
drawer.classList.add("open");
|
|
|
|
|
};
|
|
|
|
|
window.closeTaskDrawer = (projectId) => {
|
|
|
|
|
document.querySelector(`#task-drawer-${projectId}`).classList.remove("open");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.submitTaskForm = async (event, projectId) => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
const data = Object.fromEntries(new FormData(event.currentTarget).entries());
|
|
|
|
|
data.project_id = Number(projectId);
|
|
|
|
|
const taskId = data.task_id;
|
|
|
|
|
delete data.task_id;
|
|
|
|
|
try {
|
|
|
|
|
if (taskId) {
|
|
|
|
|
await api(`/api/tasks/${taskId}`, { method: "PUT", body: JSON.stringify({ data }) });
|
|
|
|
|
} else {
|
|
|
|
|
await api("/api/tasks", { method: "POST", body: JSON.stringify({ data }) });
|
|
|
|
|
}
|
|
|
|
|
await load();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
alert("保存失败:" + error.message);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
window.createFinance = (event) => createResource(event, "finance");
|
|
|
|
|
window.switchTab = switchTab;
|
|
|
|
|
|
|
|
|
|
function renderSales() {
|
|
|
|
|
const rows = state.data.sales.map((x) => [x.target_customer, badge(x.priority), badge(x.status), text(x.latest_follow_up_record)]);
|
|
|
|
|
const salesClicks = state.data.sales.map((x) => ({ resource: "sales", id: x.id }));
|
|
|
|
|
document.querySelector("#sales").innerHTML = `<div class="grid gap-4">
|
|
|
|
|
${card(formHtml([
|
|
|
|
|
{ label: "业务机会", input: `<input name="target_customer" required placeholder="客户名称">` },
|
|
|
|
|
{ label: "优先级", input: `<select name="priority"><option>P0</option><option selected>P1</option><option>P2</option><option>P3</option></select>` },
|
|
|
|
|
{ label: "状态", input: `<select name="status"><option>待跟进</option><option>跟进中</option><option>方案中</option><option>商务谈判</option><option>已签约</option><option>暂缓</option><option>已丢单</option></select>` },
|
|
|
|
|
], { handler: "createSales", text: `<i data-lucide="plus"></i>新增业务机会` }), "p-4")}
|
|
|
|
|
${renderTable(["业务机会", "优先级", "状态", "最新跟进记录"], rows, salesClicks)}
|
|
|
|
|
function renderProjects() {
|
|
|
|
|
// 二级页面:项目任务详情
|
|
|
|
|
if (state.projectView) {
|
|
|
|
|
return renderProjectTasks(state.projectView);
|
|
|
|
|
}
|
|
|
|
|
const items = state.data.operations;
|
|
|
|
|
const rows = items.map((x) => [
|
|
|
|
|
`<strong>${x.project_name}</strong>`,
|
|
|
|
|
text(x.customer_need || x.notes),
|
|
|
|
|
badge(x.current_stage || x.project_status),
|
|
|
|
|
x.expected_contract_amount ? money(x.expected_contract_amount) : "—",
|
|
|
|
|
text(x.owner || "—"),
|
|
|
|
|
`<button class="btn btn-ghost btn-sm text-blue-600" onclick="event.stopPropagation(); state.projectView=${x.id}; renderProjects()"><i data-lucide="eye"></i>查看</button>`
|
|
|
|
|
]);
|
|
|
|
|
document.querySelector("#projects").innerHTML = `<div class="grid gap-4">
|
|
|
|
|
<div class="flex items-center justify-end">
|
|
|
|
|
<button class="btn btn-primary" onclick="document.querySelector('#project-form').classList.toggle('hidden')">
|
|
|
|
|
<i data-lucide="plus"></i>新增项目
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="project-form" class="hidden">
|
|
|
|
|
${card(formHtml([
|
|
|
|
|
{ label: "项目名称", input: `<input name="project_name" required>` },
|
|
|
|
|
{ label: "当前阶段", input: `<select name="current_stage"><option>商务洽谈</option><option>系统上线</option><option>团队分工</option><option>项目交付</option><option>上线推广</option><option>结项验收</option></select>` },
|
|
|
|
|
{ label: "项目金额", input: `<input name="expected_contract_amount" type="number" step="0.01" placeholder="万元">` },
|
|
|
|
|
{ label: "负责人", input: `<input name="owner">` },
|
|
|
|
|
], { handler: "createOperation", text: "确认新增" }), "p-4")}
|
|
|
|
|
</div>
|
|
|
|
|
${renderTable(["项目", "项目说明", "当前阶段", "项目金额", "负责人", "进展"], rows, items.map((x) => ({ resource: "operations", id: x.id })))}
|
|
|
|
|
</div>`;
|
|
|
|
|
if (window.lucide) window.lucide.createIcons();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderProjectTasks(projectId) {
|
|
|
|
|
const project = state.data.operations.find((x) => x.id === projectId);
|
|
|
|
|
if (!project) { state.projectView = null; renderProjects(); return; }
|
|
|
|
|
const tasks = (state.data.tasks || []).filter((t) => t.project_id === projectId);
|
|
|
|
|
const phases = ["商务洽谈", "系统上线", "团队分工", "项目交付", "上线推广", "结项验收"];
|
|
|
|
|
document.querySelector("#projects").innerHTML = `<div class="grid gap-4">
|
|
|
|
|
<div class="flex items-center justify-between">
|
|
|
|
|
<button class="btn btn-ghost btn-sm" onclick="state.projectView=null;renderProjects()"><i data-lucide="arrow-left"></i>返回项目列表</button>
|
|
|
|
|
<div class="flex items-center gap-3">
|
|
|
|
|
<span class="text-sm font-semibold text-slate-700">${project.project_name}</span>
|
|
|
|
|
<button class="btn btn-primary btn-sm" onclick="openTaskForm(${projectId}, null)"><i data-lucide="plus"></i>新增任务</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="task-page-wrap">
|
|
|
|
|
<div class="task-body">
|
|
|
|
|
${phases.map((phase) => {
|
|
|
|
|
const pt = tasks.filter((t) => t.phase === phase);
|
|
|
|
|
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">${pt.map((t) => `<div class="task-row" data-id="${t.id}" onclick="openTaskForm(${projectId}, ${t.id})"><span class="task-dot"><i data-lucide="${t.status === 'done' ? 'check-circle' : 'circle'}"></i></span><div class="task-main"><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("")}
|
|
|
|
|
</div>
|
|
|
|
|
<div id="task-drawer-${projectId}" class="task-drawer">
|
|
|
|
|
<div class="task-drawer-hd"><span class="task-drawer-title">编辑任务</span><button class="task-close" onclick="closeTaskDrawer(${projectId})"><i data-lucide="x"></i></button></div>
|
|
|
|
|
<form class="task-drawer-form" onsubmit="submitTaskForm(event, ${projectId})">
|
|
|
|
|
<input type="hidden" name="task_id" id="task-id-${projectId}" value="">
|
|
|
|
|
<label class="task-field"><span>任务名称</span><input name="task" required id="task-name-${projectId}"></label>
|
|
|
|
|
<label class="task-field"><span>任务阶段</span><select name="phase" id="task-phase-${projectId}">${phases.map((p) => `<option>${p}</option>`).join("")}</select></label>
|
|
|
|
|
<label class="task-field"><span>负责人</span><input name="owner" id="task-owner-${projectId}"></label>
|
|
|
|
|
<label class="task-field"><span>截止时间</span><input name="due_date" type="date" id="task-due-${projectId}"></label>
|
|
|
|
|
<label class="task-field"><span>任务说明</span><textarea name="notes" rows="3" id="task-notes-${projectId}"></textarea></label>
|
|
|
|
|
<label class="task-field"><span>卡点&备注</span><textarea name="blockers" rows="2" id="task-blockers-${projectId}" placeholder="风险卡点、依赖项等"></textarea></label>
|
|
|
|
|
<div class="flex justify-end gap-2 mt-4 pt-3 border-t border-slate-100">
|
|
|
|
|
<button type="button" class="btn btn-ghost btn-sm" onclick="closeTaskDrawer(${projectId})">取消</button>
|
|
|
|
|
<button type="submit" class="btn btn-primary btn-sm" id="task-submit-btn-${projectId}">确认新增</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>`;
|
|
|
|
|
if (window.lucide) window.lucide.createIcons();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showTaskModal(projectId) {
|
|
|
|
|
const project = state.data.operations.find((x) => x.id === projectId);
|
|
|
|
|
const tasks = (state.data.tasks || []).filter((t) => t.project_id === projectId);
|
|
|
|
|
const phases = ["商务洽谈", "系统上线", "团队分工", "项目交付", "上线推广", "结项验收"];
|
|
|
|
|
document.querySelector("#taskModal").innerHTML = `<div class="task-overlay" onclick="closeTaskModal()"><div class="task-panel" onclick="event.stopPropagation()"><div class="task-header"><h2 class="task-title">${project.project_name} · 任务清单</h2><div class="flex items-center gap-3"><button class="btn btn-primary btn-sm" onclick="event.stopPropagation(); openTaskForm(${projectId}, null)"><i data-lucide="plus"></i>新增任务</button><button class="task-close" onclick="closeTaskModal()"><i data-lucide="x"></i></button></div></div><div class="task-body-wrap">
|
|
|
|
|
<div class="task-body">
|
|
|
|
|
${phases.map((phase) => {
|
|
|
|
|
const pt = tasks.filter((t) => t.phase === phase);
|
|
|
|
|
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">${pt.map((t) => `<div class="task-row" data-id="${t.id}" onclick="event.stopPropagation(); openTaskForm(${projectId}, ${t.id})"><span class="task-dot"><i data-lucide="${t.status === 'done' ? 'check-circle' : 'circle'}"></i></span><div class="task-main"><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("")}
|
|
|
|
|
</div>
|
|
|
|
|
<div id="task-drawer-${projectId}" class="task-drawer">
|
|
|
|
|
<div class="task-drawer-hd"><span class="task-drawer-title">编辑任务</span><button class="task-close" onclick="closeTaskDrawer(${projectId})"><i data-lucide="x"></i></button></div>
|
|
|
|
|
<form class="task-drawer-form" onsubmit="submitTaskForm(event, ${projectId})">
|
|
|
|
|
<input type="hidden" name="task_id" id="task-id-${projectId}" value="">
|
|
|
|
|
<label class="task-field"><span>任务名称</span><input name="task" required id="task-name-${projectId}"></label>
|
|
|
|
|
<label class="task-field"><span>任务阶段</span><select name="phase" id="task-phase-${projectId}">${phases.map((p) => `<option>${p}</option>`).join("")}</select></label>
|
|
|
|
|
<label class="task-field"><span>负责人</span><input name="owner" id="task-owner-${projectId}"></label>
|
|
|
|
|
<label class="task-field"><span>截止时间</span><input name="due_date" type="date" id="task-due-${projectId}"></label>
|
|
|
|
|
<label class="task-field"><span>任务说明</span><textarea name="notes" rows="3" id="task-notes-${projectId}"></textarea></label>
|
|
|
|
|
<label class="task-field"><span>卡点&备注</span><textarea name="blockers" rows="2" id="task-blockers-${projectId}" placeholder="风险卡点、依赖项等"></textarea></label>
|
|
|
|
|
<div class="flex justify-end gap-2 mt-4 pt-3 border-t border-slate-100">
|
|
|
|
|
<button type="button" class="btn btn-ghost btn-sm" onclick="closeTaskDrawer(${projectId})">取消</button>
|
|
|
|
|
<button type="submit" class="btn btn-primary btn-sm" id="task-submit-btn-${projectId}">确认新增</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div></div></div>`;
|
|
|
|
|
document.querySelector("#taskModal").classList.add("active");
|
|
|
|
|
if (window.lucide) window.lucide.createIcons();
|
|
|
|
|
}
|
|
|
|
|
window.closeTaskModal = () => {
|
|
|
|
|
document.querySelector("#taskModal").classList.remove("active");
|
|
|
|
|
document.querySelector("#taskModal").innerHTML = "";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function renderProposals() {
|
|
|
|
|
const categories = ["方案", "成本", "SOP", "财务流程"];
|
|
|
|
|
const proposalRows = state.data.proposals.map((p) => [p.customer_or_project_name, p.version, badge(p.status), p.files.length + " 个"]);
|
|
|
|
|
const proposalClicks = state.data.proposals.map((p) => ({ resource: "proposals", id: p.id }));
|
|
|
|
|
document.querySelector("#proposals").innerHTML = `<div class="grid gap-4">
|
|
|
|
|
@@ -232,22 +380,6 @@ window.uploadFile = async (event, module, ownerId, version, category) => {
|
|
|
|
|
await load();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function renderOperations() {
|
|
|
|
|
const items = state.opFilter === "all" ? state.data.operations : state.data.operations.filter((x) => x.project_type === state.opFilter);
|
|
|
|
|
const opRows = items.map((x) => [`<strong>${x.project_name}</strong><p class="text-xs text-slate-500">${x.project_version}</p>`, badge(x.project_type), badge(x.project_status), x.expected_contract_amount ? money(x.expected_contract_amount) : "—", text(x.current_stage || x.sop_stage), `${x.files.length} 个`, text(x.latest_follow_up_record)]);
|
|
|
|
|
const opClicks = items.map((x) => ({ resource: "operations", id: x.id }));
|
|
|
|
|
document.querySelector("#operations").innerHTML = `<div class="grid gap-4">
|
|
|
|
|
${card(formHtml([
|
|
|
|
|
{ label: "项目名称", input: `<input name="project_name" required>` },
|
|
|
|
|
{ label: "项目版本", input: `<input name="project_version" value="v1.0">` },
|
|
|
|
|
{ label: "项目类型", input: `<select name="project_type"><option value="opportunity">业务机会项目</option><option value="execution">已签约执行项目</option></select>` },
|
|
|
|
|
{ label: "状态", input: `<input name="project_status" value="线索发现">` },
|
|
|
|
|
], { handler: "createOperation", text: "新增项目" }), "p-4")}
|
|
|
|
|
<div class="flex gap-2">${[["all","全部项目"],["opportunity","业务机会项目"],["execution","已签约执行项目"]].map(([k,v]) => `<button class="btn ${state.opFilter === k ? "btn-primary" : "btn-ghost"}" onclick="state.opFilter='${k}'; renderOperations()">${v}</button>`).join("")}</div>
|
|
|
|
|
${renderTable(["项目名称", "类型", "状态", "金额", "当前阶段", "交付文件", "最新跟进"], opRows, opClicks)}
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderProducts() {
|
|
|
|
|
const items = state.productPlatform === "all" ? state.data.products : state.data.products.filter((x) => (x.platform || "") === state.productPlatform);
|
|
|
|
|
document.querySelector("#products").innerHTML = `<div class="grid gap-4">
|
|
|
|
|
@@ -298,11 +430,13 @@ function renderChartOn(id, data) {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function drawerField(icon, label, name, value, multiline = false) {
|
|
|
|
|
function drawerField(icon, label, name, value, multiline = false, customControl = null) {
|
|
|
|
|
const initialValue = text(value);
|
|
|
|
|
const control = multiline
|
|
|
|
|
? `<textarea name="${name}" rows="2" class="drawer-value drawer-textarea" data-original="${initialValue}">${initialValue}</textarea>`
|
|
|
|
|
: `<input name="${name}" value="${initialValue}" class="drawer-value" data-original="${initialValue}">`;
|
|
|
|
|
const control = customControl
|
|
|
|
|
? customControl
|
|
|
|
|
: multiline
|
|
|
|
|
? `<textarea name="${name}" rows="2" class="drawer-value drawer-textarea" data-original="${initialValue}">${initialValue}</textarea>`
|
|
|
|
|
: `<input name="${name}" value="${initialValue}" class="drawer-value" data-original="${initialValue}">`;
|
|
|
|
|
return `<div class="drawer-field">
|
|
|
|
|
<div class="drawer-field-label"><i data-lucide="${icon}"></i><span>${label}</span></div>
|
|
|
|
|
<div class="drawer-field-control">${control}</div>
|
|
|
|
|
@@ -316,14 +450,14 @@ function openDrawer(resource, id) {
|
|
|
|
|
const fields = resource === "sales"
|
|
|
|
|
? [["target_customer","业务机会"],["priority","优先级"],["status","状态"]]
|
|
|
|
|
: resource === "operations"
|
|
|
|
|
? [["project_name","项目名称"],["project_version","项目版本"],["project_status","项目状态"],["current_stage","当前阶段"],["target_customer","业务机会"],["customer_need","客户需求"],["expected_contract_amount","预计签约金额"],["expected_sign_date","预计签约时间"],["sign_probability","签约概率"],["sop_stage","SOP 阶段"],["execution_progress","执行进度"],["current_deliverable","当前交付物"],["risks","风险与阻塞"],["next_action","下一步动作"]]
|
|
|
|
|
? [["project_name","项目名称"],["owner","负责人"],["expected_sign_date","截止时间"],["expected_contract_amount","金额"],["notes","项目说明"]]
|
|
|
|
|
: resource === "proposals"
|
|
|
|
|
? [["customer_or_project_name","客户/项目"],["version","版本号"],["description","版本说明"],["created_date","创建日期"],["status","状态"]]
|
|
|
|
|
: [["product_name","产品名称"],["version","版本号"],["version_goal","版本目标"],["feature_list","核心功能清单"],["platform","平台"],["launch_date","上线日期"],["status","当前状态"],["notes","备注"]];
|
|
|
|
|
const fieldIcons = {
|
|
|
|
|
target_customer: "user", priority: "flag", status: "circle-dot",
|
|
|
|
|
project_name: "briefcase-business", project_version: "git-branch", project_status: "circle-dot", current_stage: "map-pin",
|
|
|
|
|
customer_need: "file-text", expected_contract_amount: "banknote", expected_sign_date: "calendar",
|
|
|
|
|
owner: "user", customer_need: "file-text", expected_contract_amount: "banknote", expected_sign_date: "calendar",
|
|
|
|
|
sign_probability: "percent", sop_stage: "list-checks", execution_progress: "activity",
|
|
|
|
|
current_deliverable: "package", risks: "alert-triangle", next_action: "arrow-right",
|
|
|
|
|
product_name: "box", version: "tag", version_goal: "target", feature_list: "list", platform: "layers",
|
|
|
|
|
@@ -335,7 +469,10 @@ function openDrawer(resource, id) {
|
|
|
|
|
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><button class="btn btn-ghost btn-sm" onclick="closeDrawer()">关闭</button></div><div class="grid gap-5 p-5">
|
|
|
|
|
<section>
|
|
|
|
|
<h3 class="drawer-section-title">属性</h3>
|
|
|
|
|
<form id="drawerForm" class="drawer-fields">${fields.map(([key,label]) => drawerField(fieldIcons[key] || "circle", label, key, item[key], multilineFields.includes(key))).join("")}</form>
|
|
|
|
|
<form id="drawerForm" class="drawer-fields">
|
|
|
|
|
${drawerField("map-pin", "当前阶段", "current_stage", "", false, `<select name="current_stage" class="drawer-value" onchange="saveDrawerField(this,'${resource}',${id})">${["商务洽谈","系统上线","团队分工","项目交付","上线推广","结项验收"].map((s) => `<option ${s === item.current_stage ? "selected" : ""}>${s}</option>`).join("")}</select>`)}
|
|
|
|
|
${fields.map(([key,label]) => drawerField(fieldIcons[key] || "circle", label, key, item[key], multilineFields.includes(key))).join("")}
|
|
|
|
|
</form>
|
|
|
|
|
</section>
|
|
|
|
|
${resource === "proposals" ? `<section><h3 class="drawer-section-title">方案文件</h3><div class="grid gap-2">${["方案","成本","SOP","财务流程"].map((cat) => fileGroup("proposal", item.id, item.version, cat, item.files.filter((f) => f.file_category === cat))).join("")}</div></section>` : ""}
|
|
|
|
|
${followupTarget ? `<section>
|
|
|
|
|
@@ -402,7 +539,7 @@ function bindDrawerAutosave(resource, id, item) {
|
|
|
|
|
field.addEventListener("keydown", (event) => {
|
|
|
|
|
if (event.key === "Enter" && field.tagName !== "TEXTAREA") field.blur();
|
|
|
|
|
});
|
|
|
|
|
field.addEventListener("blur", async () => {
|
|
|
|
|
const doSave = async () => {
|
|
|
|
|
const value = field.value;
|
|
|
|
|
if (value === field.dataset.original) return;
|
|
|
|
|
const previous = field.dataset.original;
|
|
|
|
|
@@ -422,7 +559,9 @@ function bindDrawerAutosave(resource, id, item) {
|
|
|
|
|
setDrawerSaveStatus("保存失败", "danger");
|
|
|
|
|
alert(`自动保存失败:${error.message}`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
field.addEventListener("blur", doSave);
|
|
|
|
|
if (field.tagName === "SELECT") field.addEventListener("change", doSave);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|