2025-11-13 14:12:01 +08:00
|
|
|
import { ref } from "vue";
|
|
|
|
|
import { message } from "@/utils/message";
|
2025-11-13 16:02:50 +08:00
|
|
|
import axios from 'axios';
|
2025-11-13 14:12:01 +08:00
|
|
|
import {
|
|
|
|
|
queryAndroidList,
|
|
|
|
|
DeteleAndroidLog
|
|
|
|
|
} from "@/api/modules/Inform";
|
|
|
|
|
export function useData() {
|
|
|
|
|
const loading = ref(true);
|
|
|
|
|
const tableList = ref([]);
|
|
|
|
|
const isShow = ref(false);
|
|
|
|
|
const pagination = ref({
|
|
|
|
|
total: 0,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
pageSizes: [10, 20, 50, 100],
|
|
|
|
|
currentPage: 1,
|
|
|
|
|
background: true
|
|
|
|
|
});
|
|
|
|
|
const tableLabel = ref([
|
|
|
|
|
{
|
|
|
|
|
label: "id",
|
|
|
|
|
prop: "id"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "用户名",
|
|
|
|
|
prop: "nickname"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "文件名",
|
|
|
|
|
prop: "log_name"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "上传时间",
|
|
|
|
|
prop: "createtime"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "操作",
|
|
|
|
|
fixed: "right",
|
|
|
|
|
slot: "operation"
|
|
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
const onSearch = async () => {
|
|
|
|
|
loading.value = true;
|
|
|
|
|
const { data, code } = await queryAndroidList({
|
|
|
|
|
page: pagination.value.currentPage,
|
|
|
|
|
page_limit: pagination.value.pageSize,
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
if (code) {
|
|
|
|
|
tableList.value = data.lists.map(ele => {
|
|
|
|
|
return {
|
|
|
|
|
...ele, ...data.total
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
pagination.value.total = data.count;
|
|
|
|
|
pagination.value.currentPage = data.page;
|
|
|
|
|
}
|
|
|
|
|
loading.value = false;
|
|
|
|
|
};
|
|
|
|
|
const handleSizeChange = (val: number) => {
|
|
|
|
|
pagination.value.pageSize = val;
|
|
|
|
|
onSearch();
|
|
|
|
|
};
|
|
|
|
|
const handleCurrentChange = (val: number) => {
|
|
|
|
|
pagination.value.currentPage = val;
|
|
|
|
|
onSearch();
|
|
|
|
|
};
|
|
|
|
|
const handleDelete = async rowData => {
|
|
|
|
|
const { code } = await DeteleAndroidLog({ id: rowData.id });
|
|
|
|
|
if (code) {
|
|
|
|
|
message(`删除成功`, {
|
|
|
|
|
type: "success"
|
|
|
|
|
});
|
|
|
|
|
onSearch();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const downloadData = (rowData) => {
|
2025-11-13 16:02:50 +08:00
|
|
|
downloadZip(rowData.log_url, rowData.log_name)
|
|
|
|
|
}
|
|
|
|
|
const downloadZip = (fileUrl, fileName) => {
|
|
|
|
|
// 创建一个隐藏的a标签
|
2025-11-13 14:12:01 +08:00
|
|
|
const link = document.createElement('a');
|
2025-11-13 16:02:50 +08:00
|
|
|
link.href = fileUrl;
|
|
|
|
|
link.download = fileName; // 设置下载的文件名
|
2025-11-13 14:12:01 +08:00
|
|
|
document.body.appendChild(link);
|
|
|
|
|
link.click();
|
2025-11-13 16:02:50 +08:00
|
|
|
document.body.removeChild(link);
|
|
|
|
|
};
|
2025-11-13 14:12:01 +08:00
|
|
|
return {
|
|
|
|
|
onSearch,
|
|
|
|
|
isShow,
|
|
|
|
|
tableList,
|
|
|
|
|
tableLabel,
|
|
|
|
|
pagination,
|
|
|
|
|
handleSizeChange,
|
|
|
|
|
handleCurrentChange,
|
|
|
|
|
handleDelete,
|
|
|
|
|
downloadData,
|
|
|
|
|
loading
|
|
|
|
|
};
|
|
|
|
|
}
|