日志文件下载功能,支持多实例
This commit is contained in:
@@ -3,41 +3,47 @@ import { useMessage } from '/@/hooks/web/useMessage';
|
|||||||
|
|
||||||
const { createConfirm } = useMessage();
|
const { createConfirm } = useMessage();
|
||||||
enum Api {
|
enum Api {
|
||||||
logFilesList = '/health-system/service/log/files',
|
logFilesList = '/service/log/files',
|
||||||
logFilesDelete = '/health-system/service/log/file/delete',
|
logFilesDelete = '/service/log/file/delete',
|
||||||
logFilesLDown = '/health-system/service/log/file/down',
|
logFilesLDown = '/service/log/file/down',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const logFilesListApi = (params: any) => defHttp.get({ url: Api.logFilesList, params: params });
|
export const logFilesListApi = (params: any) => defHttp.get({ url: '/' + params.service + Api.logFilesList, params: params });
|
||||||
|
|
||||||
//文档删除
|
//文档删除
|
||||||
export const logFilesDeleteApi = (params: any, handleSuccess: Function) => {
|
export const logFilesDeleteApi = (params: any, handleSuccess: Function) => {
|
||||||
createConfirm({
|
createConfirm({
|
||||||
iconType: 'warning',
|
iconType: 'warning',
|
||||||
title: '确认删除',
|
title: '确认删除',
|
||||||
content: '是否删除数据',
|
content: '是否删除数据',
|
||||||
okText: '确认',
|
okText: '确认',
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
return defHttp
|
const { service } = params;
|
||||||
.get(
|
const url = '/' + service + Api.logFilesDelete;
|
||||||
{
|
return defHttp
|
||||||
url: Api.logFilesDelete,
|
.get(
|
||||||
params,
|
{
|
||||||
},
|
url: url,
|
||||||
{ joinParamsToUrl: true }
|
params,
|
||||||
)
|
},
|
||||||
.then(() => {
|
{ joinParamsToUrl: true }
|
||||||
handleSuccess();
|
)
|
||||||
});
|
.then(() => {
|
||||||
},
|
handleSuccess();
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const logFilesLDownApi = (params: any) => {
|
||||||
|
const { service } = params;
|
||||||
|
const url = '/' + service + Api.logFilesLDown;
|
||||||
|
return defHttp.get(
|
||||||
|
{
|
||||||
|
url: url,
|
||||||
|
params: params,
|
||||||
|
responseType: 'blob',
|
||||||
|
},
|
||||||
|
{ isTransformResponse: false }
|
||||||
|
);
|
||||||
};
|
};
|
||||||
export const logFilesLDownApi = (params: any) =>
|
|
||||||
defHttp.get(
|
|
||||||
{
|
|
||||||
url: Api.logFilesLDown,
|
|
||||||
params: params,
|
|
||||||
responseType: 'blob',
|
|
||||||
},
|
|
||||||
{ isTransformResponse: false }
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -1,12 +1,30 @@
|
|||||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||||
|
|
||||||
export const columns: BasicColumn[] = [
|
export const columns: BasicColumn[] = [
|
||||||
{
|
{
|
||||||
title: '文件名',
|
title: '文件名',
|
||||||
dataIndex: 'fileName',
|
dataIndex: 'fileName',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 100,
|
width: 100,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '最新修改时间',
|
||||||
|
dataIndex: 'lastModified',
|
||||||
|
align: 'center',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '文件大小',
|
||||||
|
dataIndex: 'fileSize',
|
||||||
|
align: 'center',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '实例地址',
|
||||||
|
dataIndex: 'instance',
|
||||||
|
align: 'center',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
export const searchFormSchema: FormSchema[] = [
|
export const searchFormSchema: FormSchema[] = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,79 +1,74 @@
|
|||||||
<template>
|
<template>
|
||||||
<BasicTable @register="registerTable">
|
<BasicTable @register="registerTable">
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<TableAction :actions="getTableAction(record)" />
|
<TableAction :actions="getTableAction(record)" />
|
||||||
</template>
|
</template>
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts" name="sys-log">
|
||||||
import BasicTable from '/@/components/Table/src/BasicTable.vue';
|
import BasicTable from '/@/components/Table/src/BasicTable.vue';
|
||||||
import { logFilesDeleteApi, logFilesLDownApi, logFilesListApi } from '/@/views/monitor/filelog/filelog.api';
|
import { logFilesDeleteApi, logFilesLDownApi, logFilesListApi } from '/@/views/monitor/filelog/filelog.api';
|
||||||
import { columns, searchFormSchema } from '/@/views/monitor/filelog/filelog.data';
|
import { columns, searchFormSchema } from '/@/views/monitor/filelog/filelog.data';
|
||||||
import { useListPage } from '/@/hooks/system/useListPage';
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
import { TableAction } from '/@/components/Table';
|
import { TableAction } from '/@/components/Table';
|
||||||
import { ref } from 'vue';
|
|
||||||
|
|
||||||
const data = ref(['a.txt']);
|
const { tableContext } = useListPage({
|
||||||
const { tableContext } = useListPage({
|
tableProps: {
|
||||||
tableProps: {
|
api: logFilesListApi,
|
||||||
api: logFilesListApi,
|
canResize: false,
|
||||||
canResize: false,
|
columns,
|
||||||
columns,
|
beforeFetch: (params) => {
|
||||||
afterFetch: (v) => {
|
params.service = getForm().getFieldsValue().service;
|
||||||
return v.map((item) => {
|
return params;
|
||||||
return {
|
},
|
||||||
fileName: item,
|
formConfig: {
|
||||||
};
|
labelWidth: 120,
|
||||||
});
|
schemas: searchFormSchema,
|
||||||
},
|
},
|
||||||
formConfig: {
|
actionColumn: {
|
||||||
labelWidth: 120,
|
fixed: 'right',
|
||||||
schemas: searchFormSchema,
|
},
|
||||||
},
|
},
|
||||||
|
});
|
||||||
actionColumn: {
|
const [registerTable, { reload, getForm }] = tableContext;
|
||||||
fixed: 'right',
|
function getTableAction(record: Recordable) {
|
||||||
},
|
return [
|
||||||
},
|
{
|
||||||
});
|
label: '删除',
|
||||||
const [registerTable, { reload, getForm }] = tableContext;
|
onClick: hanldeDelete.bind(null, record),
|
||||||
function getTableAction(record: Recordable) {
|
},
|
||||||
return [
|
{
|
||||||
{
|
label: '下载',
|
||||||
label: '删除',
|
onClick: hanldeDownload.bind(null, record),
|
||||||
onClick: hanldeDelete.bind(null, record),
|
},
|
||||||
},
|
];
|
||||||
{
|
}
|
||||||
label: '下载',
|
function hanldeDelete(record) {
|
||||||
onClick: hanldeDownload.bind(null, record),
|
const params = {
|
||||||
},
|
filename: record.fileName,
|
||||||
];
|
service: getForm().getFieldsValue().service,
|
||||||
}
|
};
|
||||||
function hanldeDelete(record) {
|
logFilesDeleteApi(params, reload);
|
||||||
const params = {
|
}
|
||||||
filename: record.fileName,
|
async function hanldeDownload(record) {
|
||||||
service: getForm().getFieldsValue().service,
|
const params = {
|
||||||
};
|
filename: record.fileName,
|
||||||
logFilesDeleteApi(params, reload);
|
service: getForm().getFieldsValue().service,
|
||||||
}
|
instance: record.instance,
|
||||||
async function hanldeDownload(record) {
|
};
|
||||||
const params = {
|
try {
|
||||||
filename: record.fileName,
|
const v = await logFilesLDownApi(params);
|
||||||
service: getForm().getFieldsValue().service,
|
const url = window.URL.createObjectURL(v);
|
||||||
};
|
const link = document.createElement('a');
|
||||||
try {
|
link.style.display = 'none';
|
||||||
const v = await logFilesLDownApi(params);
|
link.href = url;
|
||||||
const url = window.URL.createObjectURL(v);
|
link.download = record.fileName;
|
||||||
const link = document.createElement('a');
|
document.body.appendChild(link);
|
||||||
link.style.display = 'none';
|
link.click();
|
||||||
link.href = url;
|
document.body.removeChild(link);
|
||||||
link.download = record.fileName;
|
window.URL.revokeObjectURL(url);
|
||||||
document.body.appendChild(link);
|
} catch (e) {
|
||||||
link.click();
|
console.log(e);
|
||||||
document.body.removeChild(link);
|
|
||||||
window.URL.revokeObjectURL(url);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user