|
|
|
|
@@ -254,6 +254,7 @@ function renderProjects() {
|
|
|
|
|
</div>
|
|
|
|
|
${renderTable(["项目", "项目说明", "当前阶段", "项目金额", "负责人", "进展"], rows, items.map((x) => ({ resource: "operations", id: x.id })))}
|
|
|
|
|
</div>`;
|
|
|
|
|
if (window.lucide) window.lucide.createIcons();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderProjectTasks(projectId) {
|
|
|
|
|
@@ -262,7 +263,7 @@ function renderProjectTasks(projectId) {
|
|
|
|
|
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">
|
|
|
|
|
<div class="flex items-center justify-between px-5">
|
|
|
|
|
<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>
|
|
|
|
|
@@ -429,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>
|
|
|
|
|
@@ -447,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",
|
|
|
|
|
@@ -466,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>
|
|
|
|
|
@@ -533,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;
|
|
|
|
|
@@ -553,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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|