v1.2.1 — 修复合并时误删 renderProposals/fileGroup/fileItem
This commit is contained in:
@@ -220,6 +220,50 @@ function renderProjects() {
|
|||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderProposals() {
|
||||||
|
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">
|
||||||
|
${card(formHtml([
|
||||||
|
{ label: "客户/项目", input: `<input name="customer_or_project_name" required placeholder="如:信达生物">` },
|
||||||
|
{ label: "版本号", input: `<input name="version" required placeholder="v1.0">` },
|
||||||
|
{ label: "状态", input: `<select name="status"><option>草稿</option><option>内部评审</option><option selected>已提交客户</option><option>客户反馈中</option><option>已确认</option><option>已归档</option></select>` },
|
||||||
|
], { handler: "createProposal", text: "新增版本" }), "p-4")}
|
||||||
|
${renderTable(["客户/项目", "版本号", "状态", "文件数"], proposalRows, proposalClicks)}
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fileGroup(module, ownerId, version, category, files) {
|
||||||
|
return `<div class="rounded-md border border-slate-200 px-3 py-2">
|
||||||
|
<div class="flex items-center justify-between gap-3"><p class="text-[13px] font-semibold text-slate-800">${category}</p><label class="inline-flex cursor-pointer items-center gap-1 rounded-md border border-slate-200 px-2 py-1 text-[12px] font-medium text-slate-600 hover:bg-slate-50"><i data-lucide="upload"></i>上传<input class="hidden" type="file" onchange="uploadFile(event,'${module}',${ownerId},'${version}','${category}')"></label></div>
|
||||||
|
<div class="mt-2 grid gap-1.5">${files.length ? files.map(fileItem).join("") : `<p class="text-[12px] text-slate-400">暂无文件</p>`}</div>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fileItem(file) {
|
||||||
|
return `<div class="flex items-center justify-between gap-2 rounded-md bg-slate-50 px-2 py-1.5 text-[13px]"><div class="min-w-0 flex-1"><p class="truncate font-medium text-slate-800">${file.file_name}</p><div class="mt-0.5 flex gap-3"><a class="file-link inline-flex items-center gap-1" target="_blank" href="/api/files/${file.id}/content?inline=true"><i data-lucide="eye"></i>预览</a><a class="file-link inline-flex items-center gap-1 text-slate-600" href="/api/files/${file.id}/content?inline=false"><i data-lucide="download"></i>下载</a></div></div><button class="btn btn-ghost btn-sm text-red-600" onclick="deleteFile(${file.id})" title="删除"><i data-lucide="trash-2"></i></button></div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.deleteFile = async (fileId) => {
|
||||||
|
if (!confirm("确认删除此文件?")) return;
|
||||||
|
await api(`/api/files/${fileId}`, { method: "DELETE" });
|
||||||
|
await load();
|
||||||
|
closeDrawer();
|
||||||
|
};
|
||||||
|
|
||||||
|
window.uploadFile = async (event, module, ownerId, version, category) => {
|
||||||
|
const file = event.target.files[0];
|
||||||
|
if (!file) return;
|
||||||
|
const form = new FormData();
|
||||||
|
form.append("module", module);
|
||||||
|
form.append("owner_id", ownerId);
|
||||||
|
form.append("owner_version", version);
|
||||||
|
form.append("file_category", category);
|
||||||
|
form.append("file", file);
|
||||||
|
await api("/api/files/upload", { method: "POST", body: form });
|
||||||
|
await load();
|
||||||
|
};
|
||||||
|
|
||||||
function renderProducts() {
|
function renderProducts() {
|
||||||
const items = state.productPlatform === "all" ? state.data.products : state.data.products.filter((x) => (x.platform || "") === state.productPlatform);
|
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">
|
document.querySelector("#products").innerHTML = `<div class="grid gap-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user