上传记录页面支持删除历史记录
This commit is contained in:
parent
e0e87c09b9
commit
56ef11de57
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "渠道应用开发部知识库",
|
"name": "渠道应用开发部知识库",
|
||||||
"version": "2.0.8",
|
"version": "2.0.9",
|
||||||
"description": "通过关键词快速搜索内部文档",
|
"description": "通过关键词快速搜索内部文档",
|
||||||
"permissions": ["storage"],
|
"permissions": ["storage"],
|
||||||
"host_permissions": [
|
"host_permissions": [
|
||||||
|
|||||||
@ -65,12 +65,30 @@
|
|||||||
.pagination button:hover:not(.active) {
|
.pagination button:hover:not(.active) {
|
||||||
background: #dce4f7;
|
background: #dce4f7;
|
||||||
}
|
}
|
||||||
.page-size {
|
|
||||||
|
/* 新增:底部操作栏 */
|
||||||
|
.bottom-bar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
text-align: right;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
.page-size select {
|
|
||||||
|
.bottom-bar .left-actions button {
|
||||||
|
padding: 6px 12px;
|
||||||
|
background-color: #3662f4;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom-bar .left-actions button:hover {
|
||||||
|
background-color: #d32f2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom-bar .right-select select {
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
@ -79,10 +97,12 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="history-wrapper">
|
<div class="history-wrapper">
|
||||||
<h2>上传记录</h2>
|
<h2>上传记录</h2>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 60%;">文件名</th>
|
<th style="width: 5%;"><input type="checkbox" id="selectAll" /></th>
|
||||||
|
<th style="width: 55%;">文件名</th>
|
||||||
<th style="width: 20%;">上传时间</th>
|
<th style="width: 20%;">上传时间</th>
|
||||||
<th style="width: 20%;">有效期</th>
|
<th style="width: 20%;">有效期</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -94,7 +114,11 @@
|
|||||||
|
|
||||||
<div class="pagination" id="pagination"></div>
|
<div class="pagination" id="pagination"></div>
|
||||||
|
|
||||||
<div class="page-size">
|
<div class="bottom-bar">
|
||||||
|
<div class="left-actions">
|
||||||
|
<button id="deleteSelectedBtn" title="选中记录后点击删除">删除选中</button>
|
||||||
|
</div>
|
||||||
|
<div class="right-select">
|
||||||
每页显示
|
每页显示
|
||||||
<select id="pageSizeSelect">
|
<select id="pageSizeSelect">
|
||||||
<option value="10">10</option>
|
<option value="10">10</option>
|
||||||
@ -103,6 +127,7 @@
|
|||||||
</select> 条记录
|
</select> 条记录
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script src="../scripts/upload-history.js"></script>
|
<script src="../scripts/upload-history.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## 修订记录
|
## 修订记录
|
||||||
| 时间 | 版本 | 修订人 | 说明 |
|
| 时间 | 版本 | 修订人 | 说明 |
|
||||||
|------------|--------|---------|---------------------|
|
|------------|--------|---------|------------------------------|
|
||||||
| 2025.06.02 | V2.0.0 | Luke.Ye | 完成插件配置化改造 |
|
| 2025.06.02 | V2.0.0 | Luke.Ye | 完成插件配置化改造 |
|
||||||
| 2025.06.03 | V2.0.1 | Luke.Ye | 完成llm token过期时间的配置化 |
|
| 2025.06.03 | V2.0.1 | Luke.Ye | 完成llm token过期时间的配置化 |
|
||||||
| 2025.06.03 | V2.0.2 | Luke.Ye | 支持LLM工作区配置化 |
|
| 2025.06.03 | V2.0.2 | Luke.Ye | 支持LLM工作区配置化 |
|
||||||
@ -12,4 +12,5 @@
|
|||||||
| 2025.06.16 | V2.0.6 | Luke.Ye | 添加上传文件到对象存储功能 |
|
| 2025.06.16 | V2.0.6 | Luke.Ye | 添加上传文件到对象存储功能 |
|
||||||
| 2025.06.17 | V2.0.7 | Luke.Ye | 完成上传记录展示 |
|
| 2025.06.17 | V2.0.7 | Luke.Ye | 完成上传记录展示 |
|
||||||
| 2025.06.19 | V2.0.8 | Luke.Ye | 对象存储上传优化,适配后端新接口 |
|
| 2025.06.19 | V2.0.8 | Luke.Ye | 对象存储上传优化,适配后端新接口 |
|
||||||
|
| 2025.06.20 | V2.0.8 | Luke.Ye | 上传记录页面支持删除历史记录(会同时清空对象存储和ES) |
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
const API_HISTORY = "http://app.wisdompulse.cn/api/v1/doc/fetch-os-upload-history";
|
const API_HISTORY = "http://app.wisdompulse.cn/api/v1/doc/fetch-os-upload-history";
|
||||||
|
const API_DELETE = "http://app.wisdompulse.cn/api/v1/doc/batch-delete-os-upload"; // 假设后端支持 recordId 数组删除
|
||||||
|
|
||||||
const tableBody = document.getElementById("historyTableBody");
|
const tableBody = document.getElementById("historyTableBody");
|
||||||
const pagination = document.getElementById("pagination");
|
const pagination = document.getElementById("pagination");
|
||||||
const pageSizeSelect = document.getElementById("pageSizeSelect");
|
const pageSizeSelect = document.getElementById("pageSizeSelect");
|
||||||
|
const deleteBtn = document.getElementById("deleteSelectedBtn");
|
||||||
|
const selectAllCheckbox = document.getElementById("selectAll");
|
||||||
|
|
||||||
let currentPage = 1;
|
let currentPage = 1;
|
||||||
let total = 0;
|
let total = 0;
|
||||||
@ -25,20 +28,28 @@ function renderTable(records) {
|
|||||||
tableBody.innerHTML = "";
|
tableBody.innerHTML = "";
|
||||||
if (!records.length) {
|
if (!records.length) {
|
||||||
const tr = document.createElement("tr");
|
const tr = document.createElement("tr");
|
||||||
tr.innerHTML = `<td colspan="3">暂无记录</td>`;
|
tr.innerHTML = `<td colspan="4">暂无记录</td>`;
|
||||||
tableBody.appendChild(tr);
|
tableBody.appendChild(tr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
records.forEach(rec => {
|
records.forEach((rec) => {
|
||||||
const tr = document.createElement("tr");
|
const tr = document.createElement("tr");
|
||||||
tr.innerHTML = `
|
tr.innerHTML = `
|
||||||
|
<td><input type="checkbox" class="recordCheckbox" data-id="${rec.recordId}" /></td>
|
||||||
<td><a href="${rec.url}" target="_blank">${rec.fileName}</a></td>
|
<td><a href="${rec.url}" target="_blank">${rec.fileName}</a></td>
|
||||||
<td>${rec.uploadTime}</td>
|
<td>${rec.uploadTime}</td>
|
||||||
<td>${rec.daysRemaining}</td>
|
<td>${rec.daysRemaining}</td>
|
||||||
`;
|
`;
|
||||||
tableBody.appendChild(tr);
|
tableBody.appendChild(tr);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 全选功能
|
||||||
|
selectAllCheckbox.checked = false;
|
||||||
|
selectAllCheckbox.onclick = () => {
|
||||||
|
const checkboxes = document.querySelectorAll(".recordCheckbox");
|
||||||
|
checkboxes.forEach(cb => cb.checked = selectAllCheckbox.checked);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderPagination(totalCount, current, size) {
|
function renderPagination(totalCount, current, size) {
|
||||||
@ -59,6 +70,38 @@ function renderPagination(totalCount, current, size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteBtn.onclick = () => {
|
||||||
|
const selected = Array.from(document.querySelectorAll(".recordCheckbox:checked"));
|
||||||
|
if (!selected.length) {
|
||||||
|
alert("请选择要删除的记录");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const recordIds = selected.map(cb => parseInt(cb.getAttribute("data-id")));
|
||||||
|
|
||||||
|
if (!confirm("删除后文件将无法访问或检索,是否确认删除?")) return;
|
||||||
|
|
||||||
|
fetch(API_DELETE, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ recordIds })
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (!res.ok) throw new Error("删除失败");
|
||||||
|
return res.json();
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
alert("删除成功");
|
||||||
|
loadUploadHistory(currentPage, pageSize);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error("删除出错:", err);
|
||||||
|
alert("删除失败,请稍后重试");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
pageSizeSelect.addEventListener("change", () => {
|
pageSizeSelect.addEventListener("change", () => {
|
||||||
pageSize = parseInt(pageSizeSelect.value);
|
pageSize = parseInt(pageSizeSelect.value);
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user