diff --git a/src/components/UploadForm.vue b/src/components/UploadForm.vue index d045998..7498e2c 100644 --- a/src/components/UploadForm.vue +++ b/src/components/UploadForm.vue @@ -18,7 +18,7 @@
拖拽 点击Ctrl + V 粘贴上传
diff --git a/src/views/AdminDashBoard.vue b/src/views/AdminDashBoard.vue index 686c470..c667f48 100644 --- a/src/views/AdminDashBoard.vue +++ b/src/views/AdminDashBoard.vue @@ -267,7 +267,10 @@ computed: { watch: { tableData: { handler(newData) { - this.selectedFiles = newData.filter(file => file.selected); + // selectedFiles 增加 newData中新选中,不包含在 selectedFiles 中的文件 + this.selectedFiles = this.selectedFiles.concat(newData.filter(file => file.selected && !this.selectedFiles.includes(file))); + // selectedFiles 删掉 newData 中已取消选中的文件 + this.selectedFiles = this.selectedFiles.filter(file => file.selected); }, deep: true }, diff --git a/src/views/CustomerConfig.vue b/src/views/CustomerConfig.vue index cdba4b4..39d5a91 100644 --- a/src/views/CustomerConfig.vue +++ b/src/views/CustomerConfig.vue @@ -46,6 +46,19 @@ + + + @@ -60,6 +73,7 @@ export default { return { tableData: [], dealedData: [], // 根据IP地址处理后的数据,格式为 {ip, count, [data]} + blockipList: [], // 禁止上传的IP列表 } }, computed: { @@ -104,7 +118,8 @@ export default { ipSet.forEach(ip => { let ipData = data.filter(item => item.metadata?.UploadIP === ip); let count = ipData.length; - dealedData.push({ip, count, data: ipData}); + let enable = !this.blockipList.includes(ip); + dealedData.push({ip, count, data: ipData, enable}); }); return dealedData; }, @@ -123,6 +138,27 @@ export default { }, sortByTimestamp(a, b) { return new Date(a.metadata.TimeStamp) - new Date(b.metadata.TimeStamp); + }, + async handleSwitchEnable(row) { + const ip = row.ip; + const enable = row.enable; + if (enable) { + // 从 blockipList 中移除 + this.blockipList = this.blockipList.filter(item => item !== ip); + // 更新 blockipList + await this.fetchWithAuth("/api/manage/cusConfig/whiteip", { + method: 'POST', + body: ip + }); + } else { + // 添加到 blockipList 中 + this.blockipList.push(ip); + // 更新 blockipList + await this.fetchWithAuth("/api/manage/cusConfig/blockip", { + method: 'POST', + body: ip + }); + } } }, mounted() { @@ -140,7 +176,10 @@ export default { } }) .then(response => response.json()) - .then(result => { + .then(async result => { + // 读取blockipList, 接口返回格式为 'ip1,ip2,ip3',需要转换为数组 + const blockipList = await this.fetchWithAuth("/api/manage/cusConfig/blockipList", { method: 'GET' }); + this.blockipList = (await blockipList.text()).split(','); this.tableData = result; this.dealedData = this.dealByIP(result); // 根据IP地址处理数据 }) @@ -156,6 +195,8 @@ export default {