|
|
|
|
@@ -2,6 +2,7 @@ const state = {
|
|
|
|
|
active: "home",
|
|
|
|
|
data: null,
|
|
|
|
|
opFilter: "all",
|
|
|
|
|
projectView: null,
|
|
|
|
|
chart: null,
|
|
|
|
|
chart2: null,
|
|
|
|
|
productPlatform: "all",
|
|
|
|
|
@@ -216,8 +217,6 @@ window.submitTaskForm = async (event, projectId) => {
|
|
|
|
|
await api("/api/tasks", { method: "POST", body: JSON.stringify({ data }) });
|
|
|
|
|
}
|
|
|
|
|
await load();
|
|
|
|
|
closeTaskDrawer(projectId);
|
|
|
|
|
showTaskModal(Number(projectId));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
alert("保存失败:" + error.message);
|
|
|
|
|
}
|
|
|
|
|
@@ -226,6 +225,10 @@ window.createFinance = (event) => createResource(event, "finance");
|
|
|
|
|
window.switchTab = switchTab;
|
|
|
|
|
|
|
|
|
|
function renderProjects() {
|
|
|
|
|
// 二级页面:项目任务详情
|
|
|
|
|
if (state.projectView) {
|
|
|
|
|
return renderProjectTasks(state.projectView);
|
|
|
|
|
}
|
|
|
|
|
const items = state.data.operations;
|
|
|
|
|
const rows = items.map((x) => [
|
|
|
|
|
`<strong>${x.project_name}</strong>`,
|
|
|
|
|
@@ -233,13 +236,10 @@ function renderProjects() {
|
|
|
|
|
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(); showTaskModal(${x.id})"><i data-lucide="eye"></i>查看</button>`
|
|
|
|
|
`<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-between">
|
|
|
|
|
<div class="flex gap-2">
|
|
|
|
|
${[["all","全部"],["商务洽谈","洽谈"],["系统上线","系统"],["团队分工","团队"],["项目交付","交付"],["上线推广","推广"],["结项验收","验收"]].map(([k,v]) => `<button class="btn ${state.opFilter === k ? "btn-primary" : "btn-ghost"} btn-sm" onclick="state.opFilter='${k}'; renderProjects()">${v}</button>`).join("")}
|
|
|
|
|
</div>
|
|
|
|
|
<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>
|
|
|
|
|
@@ -256,6 +256,48 @@ function renderProjects() {
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|