更新
This commit is contained in:
@@ -58,3 +58,15 @@ export const handleReport = data => {
|
|||||||
data
|
data
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
export const queryAndroidList = params => {
|
||||||
|
return http.request<Result>(
|
||||||
|
"get",
|
||||||
|
"/adminapi/Inform/android_log_list",
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export const DeteleAndroidLog = data => {
|
||||||
|
return http.request<Result>("post", "/adminapi/Inform/android_log_delete", {
|
||||||
|
data
|
||||||
|
});
|
||||||
|
};
|
||||||
104
src/views/Inform/androidlog/hook.tsx
Normal file
104
src/views/Inform/androidlog/hook.tsx
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import { ref } from "vue";
|
||||||
|
import { message } from "@/utils/message";
|
||||||
|
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) => {
|
||||||
|
console.log(rowData)
|
||||||
|
// 创建Blob对象的临时URL
|
||||||
|
const blobUrl = window.URL.createObjectURL(new Blob([rowData.log_url]));
|
||||||
|
|
||||||
|
// 创建a标签并触发下载
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = blobUrl;
|
||||||
|
link.setAttribute('download', rowData.log_name); // 设置下载的文件名
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
// 清理和释放URL对象
|
||||||
|
link.remove();
|
||||||
|
window.URL.revokeObjectURL(blobUrl);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
onSearch,
|
||||||
|
isShow,
|
||||||
|
tableList,
|
||||||
|
tableLabel,
|
||||||
|
pagination,
|
||||||
|
handleSizeChange,
|
||||||
|
handleCurrentChange,
|
||||||
|
handleDelete,
|
||||||
|
downloadData,
|
||||||
|
loading
|
||||||
|
};
|
||||||
|
}
|
||||||
54
src/views/Inform/androidlog/index.vue
Normal file
54
src/views/Inform/androidlog/index.vue
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted } from "vue";
|
||||||
|
import { useData } from "./hook";
|
||||||
|
import { PureTableBar } from "@/components/RePureTableBar";
|
||||||
|
import { deviceDetection } from "@pureadmin/utils";
|
||||||
|
const {
|
||||||
|
onSearch,
|
||||||
|
isShow,
|
||||||
|
tableList,
|
||||||
|
pagination,
|
||||||
|
tableLabel,
|
||||||
|
handleSizeChange,
|
||||||
|
handleCurrentChange,
|
||||||
|
handleDelete,
|
||||||
|
downloadData,
|
||||||
|
loading
|
||||||
|
} = useData();
|
||||||
|
onMounted(() => {
|
||||||
|
onSearch();
|
||||||
|
});
|
||||||
|
defineOptions({
|
||||||
|
name: "giftRecord"
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="main">
|
||||||
|
<div ref="contentRef" :class="['flex', deviceDetection() ? 'flex-wrap' : '']">
|
||||||
|
<PureTableBar title="安卓日志记录表" :class="[isShow && !deviceDetection() ? '!w-[60vw]' : 'w-full']"
|
||||||
|
:columns="tableLabel" @refresh="onSearch">
|
||||||
|
<template v-slot="{ size, dynamicColumns }">
|
||||||
|
<pure-table ref="tableRef" align-whole="center" showOverflowTooltip table-layout="auto" default-expand-all
|
||||||
|
:loading="loading" :size="size" row-key="id" adaptive :adaptiveConfig="{ offsetBottom: 108 }"
|
||||||
|
:data="tableList" :columns="dynamicColumns" :pagination="{ ...pagination, size }" :header-cell-style="{
|
||||||
|
background: 'var(--el-fill-color-light)',
|
||||||
|
color: 'var(--el-text-color-primary)'
|
||||||
|
}" @page-current-change="handleCurrentChange" @page-size-change="handleSizeChange">
|
||||||
|
<template #operation="{ row }">
|
||||||
|
<el-button link type="primary" :size="size" @click="downloadData(row)">
|
||||||
|
下载
|
||||||
|
</el-button>
|
||||||
|
<el-popconfirm :title="`是否确认删除这条数据`" @confirm="handleDelete(row)">
|
||||||
|
<template #reference>
|
||||||
|
<el-button link type="primary" :size="size"> 删除 </el-button>
|
||||||
|
</template>
|
||||||
|
</el-popconfirm>
|
||||||
|
</template>
|
||||||
|
</pure-table>
|
||||||
|
</template>
|
||||||
|
</PureTableBar>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<style scoped lang="scss"></style>
|
||||||
Reference in New Issue
Block a user