😎调整文件管理页面
This commit is contained in:
parent
abda065883
commit
267b62ed64
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="sys-file-container">
|
<div class="sys-file-container">
|
||||||
<el-dialog v-model="state.isShowDialog" draggable :close-on-click-modal="false" width="500px">
|
<el-dialog v-model="state.isShowDialog" draggable overflow destroy-on-close width="500px">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div style="color: #fff">
|
<div style="color: #fff">
|
||||||
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>
|
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>
|
||||||
|
|||||||
@ -1,89 +1,90 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="sys-file-container">
|
<div class="sys-file-container" v-loading="options.loading">
|
||||||
<el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
|
<el-card shadow="hover" :body-style="{ padding: '5px 5px 0 5px', display: 'flex', width: '100%', height: '100%', alignItems: 'start' }">
|
||||||
<el-form :model="state.queryParams" ref="queryForm" :inline="true">
|
<el-form :model="state.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true" :label-width="'60px'" style="flex: 1 1 0%">
|
||||||
|
<el-row :gutter="10">
|
||||||
|
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||||
<el-form-item label="文件名称" prop="fileName">
|
<el-form-item label="文件名称" prop="fileName">
|
||||||
<el-input v-model="state.queryParams.fileName" placeholder="文件名称" clearable />
|
<el-input v-model="state.queryParams.fileName" placeholder="文件名称" clearable @keyup.enter.native="handleQuery(true)" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||||
<el-form-item label="开始时间" prop="name">
|
<el-form-item label="开始时间" prop="name">
|
||||||
<el-date-picker v-model="state.queryParams.startTime" type="datetime" placeholder="开始时间" value-format="YYYY-MM-DD HH:mm:ss" />
|
<el-date-picker v-model="state.queryParams.startTime" type="datetime" placeholder="开始时间" value-format="YYYY-MM-DD HH:mm:ss" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||||
<el-form-item label="结束时间" prop="code">
|
<el-form-item label="结束时间" prop="code">
|
||||||
<el-date-picker v-model="state.queryParams.endTime" type="datetime" placeholder="结束时间" value-format="YYYY-MM-DD HH:mm:ss" />
|
<el-date-picker v-model="state.queryParams.endTime" type="datetime" placeholder="结束时间" value-format="YYYY-MM-DD HH:mm:ss" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
</el-col>
|
||||||
<el-button-group>
|
</el-row>
|
||||||
<el-button type="primary" icon="ele-Search" @click="handleQuery" v-auth="'sysFile:page'"> 查询 </el-button>
|
|
||||||
<el-button icon="ele-Refresh" @click="resetQuery"> 重置 </el-button>
|
|
||||||
</el-button-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" icon="ele-Plus" @click="openUploadDialog" v-auth="'sysFile:uploadFile'"> 上传 </el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
|
<el-divider style="height: calc(100% - 5px); margin: 0 10px" direction="vertical" />
|
||||||
|
|
||||||
|
<el-row>
|
||||||
|
<el-col>
|
||||||
|
<el-button-group>
|
||||||
|
<el-button type="primary" icon="ele-Search" @click="handleQuery(true)" v-auth="'sysFile:page'" :loading="options.loading"> 查询 </el-button>
|
||||||
|
<el-button icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> 重置 </el-button>
|
||||||
|
</el-button-group>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
|
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
|
||||||
<el-table :data="state.fileData" style="width: 100%" v-loading="state.loading" border>
|
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" @sort-change="sortChange">
|
||||||
<el-table-column type="index" label="序号" width="55" align="center" />
|
<template #toolbar_buttons>
|
||||||
<el-table-column prop="fileName" label="名称" min-width="150" header-align="center" show-overflow-tooltip />
|
<el-button type="primary" icon="ele-Plus" @click="showUpload" v-auth="'sysFile:uploadFile'"> 上传 </el-button>
|
||||||
<el-table-column prop="suffix" label="后缀" align="center" show-overflow-tooltip>
|
|
||||||
<template #default="scope">
|
|
||||||
<el-tag round>{{ scope.row.suffix }}</el-tag>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
<template #toolbar_tools> </template>
|
||||||
<el-table-column prop="sizeKb" label="大小kb" align="center" show-overflow-tooltip />
|
<template #empty>
|
||||||
<el-table-column prop="url" label="预览" align="center">
|
<el-empty :image-size="200" />
|
||||||
<template #default="scope">
|
</template>
|
||||||
|
<template #row_suffix="{ row }">
|
||||||
|
<el-tag round>{{ row.suffix }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #row_url="{ row }">
|
||||||
<el-image
|
<el-image
|
||||||
style="width: 60px; height: 60px"
|
style="width: 60px; height: 60px"
|
||||||
:src="getFileUrl(scope.row)"
|
:src="fetchFileUrl(row)"
|
||||||
alt="无法预览"
|
alt="无法预览"
|
||||||
:lazy="true"
|
lazy
|
||||||
:hide-on-click-modal="true"
|
hide-on-click-modal
|
||||||
:preview-src-list="[getFileUrl(scope.row)]"
|
:preview-src-list="[fetchFileUrl(row)]"
|
||||||
:initial-index="0"
|
:initial-index="0"
|
||||||
fit="scale-down"
|
fit="scale-down"
|
||||||
preview-teleported
|
preview-teleported
|
||||||
>
|
></el-image>
|
||||||
<template #error> </template>
|
|
||||||
</el-image>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
<template #row_buttons="{ row }">
|
||||||
<el-table-column prop="bucketName" label="存储位置" align="center" show-overflow-tooltip />
|
<el-tooltip content="编辑" placement="top">
|
||||||
<el-table-column prop="id" label="存储标识" align="center" show-overflow-tooltip />
|
<el-button icon="ele-Edit" size="small" text type="primary" @click="handleEdit(row)" v-auth="'sysFile:update'" />
|
||||||
<el-table-column prop="fileType" label="文件类型" min-width="100" header-align="center" show-overflow-tooltip />
|
</el-tooltip>
|
||||||
<el-table-column type="relationName" label="关联对象名称" min-width="150" align="center" />
|
<el-tooltip content="删除" placement="top">
|
||||||
<el-table-column type="relationId" label="关联对象Id" align="center" />
|
<el-button icon="ele-Delete" size="small" text type="danger" @click="handleDelete(row)" v-auth="'sysFile:delete'" />
|
||||||
<el-table-column type="belongId" label="所属Id" align="center" />
|
</el-tooltip>
|
||||||
<el-table-column label="修改记录" width="100" align="center" show-overflow-tooltip>
|
<el-tooltip content="预览" placement="top">
|
||||||
<template #default="scope">
|
<el-button icon="ele-View" size="small" text type="primary" @click="showPreviewDialog(row)" v-auth="'sysFile:delete'" />
|
||||||
<ModifyRecord :data="scope.row" />
|
</el-tooltip>
|
||||||
|
<el-tooltip content="下载" placement="top">
|
||||||
|
<el-button icon="ele-Download" size="small" text type="primary" @click="handleDownload(row)" v-auth="'sysFile:downloadFile'" />
|
||||||
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
<template #pager>
|
||||||
<el-table-column label="操作" width="260" fixed="right" align="center" show-overflow-tooltip>
|
<vxe-pager
|
||||||
<template #default="scope">
|
:loading="options.loading"
|
||||||
<el-button icon="ele-View" size="small" text type="primary" @click="openFilePreviewDialog(scope.row)" v-auth="'sysFile:delete'"> 预览 </el-button>
|
v-model:current-page="state.tableParams.page"
|
||||||
<el-button icon="ele-Download" size="small" text type="primary" @click="downloadFile(scope.row)" v-auth="'sysFile:downloadFile'"> 下载 </el-button>
|
|
||||||
<el-button icon="ele-Delete" size="small" text type="danger" @click="delFile(scope.row)" v-auth="'sysFile:delete'"> 删除 </el-button>
|
|
||||||
<el-button icon="ele-Edit" size="small" text type="primary" @click="openEditSysFile(scope.row)" v-auth="'sysFile:update'"> 编辑 </el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<el-pagination
|
|
||||||
v-model:currentPage="state.tableParams.page"
|
|
||||||
v-model:page-size="state.tableParams.pageSize"
|
v-model:page-size="state.tableParams.pageSize"
|
||||||
:total="state.tableParams.total"
|
:total="state.tableParams.total"
|
||||||
:page-sizes="[10, 20, 50, 100]"
|
@page-change="pageChange"
|
||||||
small
|
|
||||||
background
|
|
||||||
@size-change="handleSizeChange"
|
|
||||||
@current-change="handleCurrentChange"
|
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
|
||||||
/>
|
/>
|
||||||
|
</template>
|
||||||
|
</vxe-grid>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-dialog v-model="state.dialogUploadVisible" :lock-scroll="false" draggable width="400px">
|
<el-dialog v-model="state.visible" :lock-scroll="false" draggable overflow destroy-on-close width="400px">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div style="color: #fff">
|
<div style="color: #fff">
|
||||||
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-UploadFilled /> </el-icon>
|
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-UploadFilled /> </el-icon>
|
||||||
@ -108,49 +109,50 @@
|
|||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<span class="dialog-footer">
|
||||||
<el-button @click="state.dialogUploadVisible = false">取消</el-button>
|
<el-button @click="state.visible = false">取消</el-button>
|
||||||
<el-button type="primary" @click="uploadFile">确定</el-button>
|
<el-button type="primary" @click="handleUpload">确定</el-button>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<el-drawer :title="state.fileName" v-model="state.dialogDocxVisible" size="50%" destroy-on-close>
|
<el-drawer :title="state.fileName" v-model="state.docxVisible" size="70%" destroy-on-close>
|
||||||
<vue-office-docx :src="state.docxUrl" style="height: 100vh" @rendered="renderedHandler" @error="errorHandler" />
|
<vue-office-docx :src="state.docxUrl" style="height: calc(100vh - 37px)" @rendered="handleRendered" @error="handleError" />
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
<el-drawer :title="state.fileName" v-model="state.dialogXlsxVisible" size="50%" destroy-on-close>
|
<el-drawer :title="state.fileName" v-model="state.xlsxVisible" size="70%" destroy-on-close>
|
||||||
<vue-office-excel :src="state.excelUrl" style="height: 100vh" @rendered="renderedHandler" @error="errorHandler" />
|
<vue-office-excel :src="state.excelUrl" style="height: calc(100vh - 37px)" @rendered="handleRendered" @error="handleError" />
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
<el-drawer :title="state.fileName" v-model="state.dialogPdfVisible" size="50%" destroy-on-close>
|
<el-drawer :title="state.fileName" v-model="state.pdfVisible" size="70%" destroy-on-close>
|
||||||
<vue-office-pdf :src="state.pdfUrl" style="height: 100vh" @rendered="renderedHandler" @error="errorHandler" />
|
<vue-office-pdf :src="state.pdfUrl" style="height: calc(100vh - 37px)" @rendered="handleRendered" @error="handleError" />
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
<el-image-viewer v-if="state.showViewer" :url-list="state.previewList" :hideOnClickModal="true" @close="state.showViewer = false"></el-image-viewer>
|
<el-image-viewer v-if="state.showViewer" :url-list="state.previewList" :hideOnClickModal="true" @close="state.showViewer = false"></el-image-viewer>
|
||||||
<EditSysFile ref="editSysFileRef" title="编辑文件" @handleQuery="handleQuery" />
|
<EditFile ref="editRef" title="编辑文件" @handleQuery="handleQuery" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup name="sysFile">
|
<script lang="ts" setup name="sysFile">
|
||||||
import { onMounted, reactive, ref } from 'vue';
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
import { ElMessageBox, ElMessage, UploadInstance } from 'element-plus';
|
import { ElMessageBox, ElMessage, UploadInstance } from 'element-plus';
|
||||||
|
import { auth } from '/@/utils/authFunction';
|
||||||
|
import { VxeGridInstance, VxePagerEvents, VxePagerDefines } from 'vxe-table';
|
||||||
|
import { useVxeTable } from '/@/hooks/vxeTableOptionsHook';
|
||||||
|
import { downloadByUrl } from '/@/utils/download';
|
||||||
import VueOfficeDocx from '@vue-office/docx';
|
import VueOfficeDocx from '@vue-office/docx';
|
||||||
import VueOfficeExcel from '@vue-office/excel';
|
import VueOfficeExcel from '@vue-office/excel';
|
||||||
import VueOfficePdf from '@vue-office/pdf';
|
import VueOfficePdf from '@vue-office/pdf';
|
||||||
import '@vue-office/docx/lib/index.css';
|
import '@vue-office/docx/lib/index.css';
|
||||||
import '@vue-office/excel/lib/index.css';
|
import '@vue-office/excel/lib/index.css';
|
||||||
|
|
||||||
import EditSysFile from '/@/views/system/file/component/editSysfile.vue';
|
import EditFile from '/@/views/system/file/component/editSysfile.vue';
|
||||||
import ModifyRecord from '/@/components/table/modifyRecord.vue';
|
|
||||||
|
|
||||||
import { downloadByUrl } from '/@/utils/download';
|
|
||||||
import { getAPI } from '/@/utils/axios-utils';
|
import { getAPI } from '/@/utils/axios-utils';
|
||||||
import { SysFileApi } from '/@/api-services/api';
|
import { SysFileApi } from '/@/api-services/api';
|
||||||
import { SysFile } from '/@/api-services/models';
|
import { SysFile } from '/@/api-services/models';
|
||||||
|
|
||||||
|
const xGrid = ref<VxeGridInstance>();
|
||||||
// const baseUrl = window.__env__.VITE_API_URL;
|
// const baseUrl = window.__env__.VITE_API_URL;
|
||||||
const uploadRef = ref<UploadInstance>();
|
const uploadRef = ref<UploadInstance>();
|
||||||
const editSysFileRef = ref<InstanceType<typeof EditSysFile>>();
|
const editRef = ref<InstanceType<typeof EditFile>>();
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
loading: false,
|
|
||||||
fileData: [] as Array<SysFile>,
|
|
||||||
queryParams: {
|
queryParams: {
|
||||||
fileName: undefined,
|
fileName: undefined,
|
||||||
startTime: undefined,
|
startTime: undefined,
|
||||||
@ -158,15 +160,18 @@ const state = reactive({
|
|||||||
},
|
},
|
||||||
tableParams: {
|
tableParams: {
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 10,
|
pageSize: 50,
|
||||||
|
field: 'id', // 默认的排序字段
|
||||||
|
order: 'aes', // 排序方向
|
||||||
|
descStr: 'desc', // 降序排序的关键字符
|
||||||
total: 0 as any,
|
total: 0 as any,
|
||||||
},
|
},
|
||||||
dialogUploadVisible: false,
|
visible: false,
|
||||||
diaglogEditFile: false,
|
diaglogEditFile: false,
|
||||||
fileList: [] as any,
|
fileList: [] as any,
|
||||||
dialogDocxVisible: false,
|
docxVisible: false,
|
||||||
dialogXlsxVisible: false,
|
xlsxVisible: false,
|
||||||
dialogPdfVisible: false,
|
pdfVisible: false,
|
||||||
showViewer: false,
|
showViewer: false,
|
||||||
docxUrl: '',
|
docxUrl: '',
|
||||||
excelUrl: '',
|
excelUrl: '',
|
||||||
@ -176,21 +181,55 @@ const state = reactive({
|
|||||||
previewList: [] as string[],
|
previewList: [] as string[],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 表格参数配置
|
||||||
|
const options = useVxeTable<SysFile>(
|
||||||
|
{
|
||||||
|
id: 'sysFile',
|
||||||
|
name: '文件信息',
|
||||||
|
columns: [
|
||||||
|
// { type: 'checkbox', width: 40, fixed: 'left' },
|
||||||
|
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
|
||||||
|
{ field: 'fileName', title: '名称', minWidth: 200, showOverflow: 'tooltip' },
|
||||||
|
{ field: 'suffix', title: '后缀', minWidth: 80, showOverflow: 'tooltip', slots: { default: 'row_suffix' } },
|
||||||
|
{ field: 'sizeKb', title: '大小(KB)', minWidth: 100, showOverflow: 'tooltip' },
|
||||||
|
{ field: 'url', title: '预览', minWidth: 100, slots: { default: 'row_url' } },
|
||||||
|
{ field: 'bucketName', title: '存储位置', minWidth: 180, showOverflow: 'tooltip' },
|
||||||
|
{ field: 'id', title: '存储标识', minWidth: 120, showOverflow: 'tooltip' },
|
||||||
|
{ field: 'fileType', title: '文件类型', minWidth: 140, showOverflow: 'tooltip' },
|
||||||
|
{ field: 'relationName', title: '关联对象名称', minWidth: 150, showOverflow: 'tooltip' },
|
||||||
|
{ field: 'relationId', title: '关联对象ID', minWidth: 150, showOverflow: 'tooltip' },
|
||||||
|
{ field: 'belongId', title: '所属ID', minWidth: 120, showOverflow: 'tooltip' },
|
||||||
|
// { field: 'userName', title: '上传者', minWidth: 150, showOverflow: 'tooltip', sortable: true },
|
||||||
|
{ field: 'createTime', title: '创建时间', minWidth: 150, showOverflow: 'tooltip' },
|
||||||
|
{ field: 'remark', title: '备注', minWidth: 200, showOverflow: 'tooltip' },
|
||||||
|
{ title: '操作', fixed: 'right', width: 150, showOverflow: true, slots: { default: 'row_buttons' } },
|
||||||
|
],
|
||||||
|
enableExport: auth('sysFile:export'),
|
||||||
|
searchCallback: () => handleQuery(),
|
||||||
|
queryAllCallback: () => fetchData({ pageSize: 99999 }),
|
||||||
|
},
|
||||||
|
{ rowConfig: { height: 80 } }
|
||||||
|
);
|
||||||
|
|
||||||
|
// 页面初始化
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
handleQuery();
|
await handleQuery();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 查询操作
|
// 查询操作
|
||||||
const handleQuery = async () => {
|
const handleQuery = async (reset = false) => {
|
||||||
if (state.queryParams.startTime == null) state.queryParams.startTime = undefined;
|
options.loading = true;
|
||||||
if (state.queryParams.endTime == null) state.queryParams.endTime = undefined;
|
if (reset) state.tableParams.page = 1;
|
||||||
|
var res = await fetchData(null);
|
||||||
state.loading = true;
|
xGrid.value?.loadData(res.data.result?.items ?? []);
|
||||||
let params = Object.assign(state.queryParams, state.tableParams);
|
|
||||||
var res = await getAPI(SysFileApi).apiSysFilePagePost(params);
|
|
||||||
state.fileData = res.data.result?.items ?? [];
|
|
||||||
state.tableParams.total = res.data.result?.total;
|
state.tableParams.total = res.data.result?.total;
|
||||||
state.loading = false;
|
options.loading = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
|
const fetchData = async (tableParams: any) => {
|
||||||
|
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
|
||||||
|
return getAPI(SysFileApi).apiSysFilePagePost(params);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 重置操作
|
// 重置操作
|
||||||
@ -198,13 +237,27 @@ const resetQuery = () => {
|
|||||||
state.queryParams.fileName = undefined;
|
state.queryParams.fileName = undefined;
|
||||||
state.queryParams.startTime = undefined;
|
state.queryParams.startTime = undefined;
|
||||||
state.queryParams.endTime = undefined;
|
state.queryParams.endTime = undefined;
|
||||||
|
handleQuery(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 改变页码序号或页面容量
|
||||||
|
const pageChange: VxePagerEvents.PageChange = ({ currentPage, pageSize }: VxePagerDefines.PageChangeEventParams) => {
|
||||||
|
state.tableParams.page = currentPage;
|
||||||
|
state.tableParams.pageSize = pageSize;
|
||||||
|
handleQuery();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 列排序
|
||||||
|
const sortChange = (options: any) => {
|
||||||
|
state.tableParams.field = options.field;
|
||||||
|
state.tableParams.order = options.order;
|
||||||
handleQuery();
|
handleQuery();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 打开上传页面
|
// 打开上传页面
|
||||||
const openUploadDialog = () => {
|
const showUpload = () => {
|
||||||
state.fileList = [];
|
state.fileList = [];
|
||||||
state.dialogUploadVisible = true;
|
state.visible = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 通过onChanne方法获得文件列表
|
// 通过onChanne方法获得文件列表
|
||||||
@ -213,23 +266,23 @@ const handleChange = (file: any, fileList: []) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 上传
|
// 上传
|
||||||
const uploadFile = async () => {
|
const handleUpload = async () => {
|
||||||
if (state.fileList.length < 1) return;
|
if (state.fileList.length < 1) return;
|
||||||
await getAPI(SysFileApi).apiSysFileUploadFilePostForm(state.fileList[0].raw, state.fileType, undefined);
|
await getAPI(SysFileApi).apiSysFileUploadFilePostForm(state.fileList[0].raw, state.fileType, undefined);
|
||||||
handleQuery();
|
handleQuery();
|
||||||
ElMessage.success('上传成功');
|
ElMessage.success('上传成功');
|
||||||
state.dialogUploadVisible = false;
|
state.visible = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 下载
|
// 下载
|
||||||
const downloadFile = async (row: any) => {
|
const handleDownload = async (row: any) => {
|
||||||
// var res = await getAPI(SysFileApi).sysFileDownloadPost({ id: row.id });
|
// var res = await getAPI(SysFileApi).sysFileDownloadPost({ id: row.id });
|
||||||
var fileUrl = getFileUrl(row);
|
var fileUrl = fetchFileUrl(row);
|
||||||
downloadByUrl({ url: fileUrl });
|
downloadByUrl({ url: fileUrl });
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const delFile = (row: any) => {
|
const handleDelete = (row: any) => {
|
||||||
ElMessageBox.confirm(`确定删除文件:【${row.fileName}】?`, '提示', {
|
ElMessageBox.confirm(`确定删除文件:【${row.fileName}】?`, '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
@ -243,42 +296,30 @@ const delFile = (row: any) => {
|
|||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 打开文件预览页面
|
// 打开Pdf预览页面
|
||||||
const openFilePreviewDialog = async (row: any) => {
|
const showPreviewDialog = async (row: any) => {
|
||||||
if (row.suffix == '.pdf') {
|
if (row.suffix == '.pdf') {
|
||||||
state.fileName = `【${row.fileName}${row.suffix}】`;
|
state.fileName = `【${row.fileName}${row.suffix}】`;
|
||||||
state.pdfUrl = getFileUrl(row);
|
state.pdfUrl = fetchFileUrl(row);
|
||||||
state.dialogPdfVisible = true;
|
state.pdfVisible = true;
|
||||||
} else if (row.suffix == '.docx') {
|
} else if (row.suffix == '.docx') {
|
||||||
state.fileName = `【${row.fileName}${row.suffix}】`;
|
state.fileName = `【${row.fileName}${row.suffix}】`;
|
||||||
state.docxUrl = getFileUrl(row);
|
state.docxUrl = fetchFileUrl(row);
|
||||||
state.dialogDocxVisible = true;
|
state.docxVisible = true;
|
||||||
} else if (row.suffix == '.xlsx') {
|
} else if (row.suffix == '.xlsx') {
|
||||||
state.fileName = `【${row.fileName}${row.suffix}】`;
|
state.fileName = `【${row.fileName}${row.suffix}】`;
|
||||||
state.excelUrl = getFileUrl(row);
|
state.excelUrl = fetchFileUrl(row);
|
||||||
state.dialogXlsxVisible = true;
|
state.xlsxVisible = true;
|
||||||
} else if (['.jpg', '.png', '.jpeg', '.bmp'].findIndex((e) => e == row.suffix) > -1) {
|
} else if (['.jpg', '.png', '.jpeg', '.bmp'].findIndex((e) => e == row.suffix) > -1) {
|
||||||
state.previewList = [getFileUrl(row)];
|
state.previewList = [fetchFileUrl(row)];
|
||||||
state.showViewer = true;
|
state.showViewer = true;
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error('此文件格式不支持预览');
|
ElMessage.error('此文件格式不支持预览');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 改变页面容量
|
|
||||||
const handleSizeChange = (val: number) => {
|
|
||||||
state.tableParams.pageSize = val;
|
|
||||||
handleQuery();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 改变页码序号
|
|
||||||
const handleCurrentChange = (val: number) => {
|
|
||||||
state.tableParams.page = val;
|
|
||||||
handleQuery();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取文件地址
|
// 获取文件地址
|
||||||
const getFileUrl = (row: SysFile): string => {
|
const fetchFileUrl = (row: SysFile): string => {
|
||||||
if (row.bucketName == 'Local') {
|
if (row.bucketName == 'Local') {
|
||||||
return `/${row.filePath}/${row.id}${row.suffix}`;
|
return `/${row.filePath}/${row.id}${row.suffix}`;
|
||||||
} else {
|
} else {
|
||||||
@ -287,12 +328,13 @@ const getFileUrl = (row: SysFile): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 打开编辑页面
|
// 打开编辑页面
|
||||||
const openEditSysFile = (row: any) => {
|
const handleEdit = (row: any) => {
|
||||||
editSysFileRef.value?.openDialog(row);
|
editRef.value?.openDialog(row);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 文件渲染完成
|
// 文件渲染完成
|
||||||
const renderedHandler = () => {};
|
const handleRendered = () => {};
|
||||||
|
|
||||||
// 文件渲染失败
|
// 文件渲染失败
|
||||||
const errorHandler = () => {};
|
const handleError = () => {};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user