fix: 文件列表添加预览功能

This commit is contained in:
kun 2024-06-21 17:22:58 +08:00
parent 5e9d8ec143
commit 5cb2a8fc5e
3 changed files with 28 additions and 2 deletions

View File

@ -987,6 +987,7 @@
<el-table-column label="操作" width="200"> <el-table-column label="操作" width="200">
<template #default="{ row }"> <template #default="{ row }">
<el-button type="primary" link size="small" @click="onDowmload(row)">下载</el-button> <el-button type="primary" link size="small" @click="onDowmload(row)">下载</el-button>
<el-button type="primary" link size="small" @click="onPreview(row)">预览</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -1002,6 +1003,10 @@ import { ElMessage, ElMessageBox } from "element-plus";
import { useDownload } from "@/hooks/useDownload"; import { useDownload } from "@/hooks/useDownload";
import AreaSelected from "@/components/ChinaAreaData/index.vue"; import AreaSelected from "@/components/ChinaAreaData/index.vue";
import divDialogComponent from "@/components/divDialogComponent/index.vue"; import divDialogComponent from "@/components/divDialogComponent/index.vue";
import { Base64 } from "js-base64";
const uplUrl = import.meta.env.VITE_ULD_API_URL;
const baseUrl = window.location.protocol + "//" + window.location.host;
// const baseUrl = import.meta.env.VITE_API_URL;
const emits = defineEmits(["update:ennMEssageVisible"]); const emits = defineEmits(["update:ennMEssageVisible"]);
const props = defineProps(["relativeId", "ennMEssageVisible"]); const props = defineProps(["relativeId", "ennMEssageVisible"]);
const current = ref([]); const current = ref([]);
@ -1197,6 +1202,14 @@ const onDowmload = row => {
useDownload(exportApp, `${row.name}`, { fileUrl: row.response.fileUrl }) useDownload(exportApp, `${row.name}`, { fileUrl: row.response.fileUrl })
); );
}; };
const onPreview = (row: any) => {
const fileExtension = row.fileUrl.slice(row.fileUrl.lastIndexOf(".") + 1);
const url = Base64.encode(baseUrl + "/xmgl/file/preview?fileUrl=" + row.fileUrl + "&fullfilename=123." + fileExtension);
//
// const url1 = "http://182.90.224.147:8012/onlinePreview?url=";
// const url1 = "http://192.168.34.155:8012/onlinePreview?url=";
window.open(uplUrl + url);
};
// //
const onAppendix = row => { const onAppendix = row => {
console.log(row); console.log(row);

View File

@ -115,6 +115,7 @@ import { jxj_User } from "@/api/types";
import { useHandleData } from "@/hooks/useHandleData"; import { useHandleData } from "@/hooks/useHandleData";
import divDialogComponent from "@/components/divDialogComponent/index.vue"; import divDialogComponent from "@/components/divDialogComponent/index.vue";
import { Base64 } from "js-base64"; import { Base64 } from "js-base64";
const uplUrl = import.meta.env.VITE_ULD_API_URL;
const emits = defineEmits(["update:fileListVisible"]); const emits = defineEmits(["update:fileListVisible"]);
const props = defineProps(["relativeId", "engineeringSn", "fileListVisible"]); const props = defineProps(["relativeId", "engineeringSn", "fileListVisible"]);
const selectedAnnex = ref(); // const selectedAnnex = ref(); //
@ -149,7 +150,6 @@ const addDialogVisible = ref(false);
const dialogVisible = ref(false); const dialogVisible = ref(false);
const annexFiles = ref([]); const annexFiles = ref([]);
const visible1 = ref(false); const visible1 = ref(false);
const uplUrl = import.meta.env.VITE_ULD_API_URL;
// //
const saveAnnexFile = async () => { const saveAnnexFile = async () => {
let requestData = { let requestData = {

View File

@ -290,6 +290,7 @@
<el-table-column label="操作" width="200"> <el-table-column label="操作" width="200">
<template #default="{ row }"> <template #default="{ row }">
<el-button type="primary" link size="small" @click="onDowmload(row)">下载</el-button> <el-button type="primary" link size="small" @click="onDowmload(row)">下载</el-button>
<el-button type="primary" link size="small" @click="onPreview(row)">预览</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -305,6 +306,10 @@ import { ElMessage, ElMessageBox } from "element-plus";
import { useDownload } from "@/hooks/useDownload"; import { useDownload } from "@/hooks/useDownload";
import AreaSelected from "@/components/ChinaAreaData/index.vue"; import AreaSelected from "@/components/ChinaAreaData/index.vue";
import divDialogComponent from "@/components/divDialogComponent/index.vue"; import divDialogComponent from "@/components/divDialogComponent/index.vue";
import { Base64 } from "js-base64";
const uplUrl = import.meta.env.VITE_ULD_API_URL;
const baseUrl = window.location.protocol + "//" + window.location.host;
// const baseUrl = import.meta.env.VITE_API_URL;
const emits = defineEmits(["update:ennMEssageVisible"]); const emits = defineEmits(["update:ennMEssageVisible"]);
const props = defineProps(["relativeId", "ennMEssageVisible"]); const props = defineProps(["relativeId", "ennMEssageVisible"]);
const current = ref([]); const current = ref([]);
@ -320,6 +325,14 @@ const onDowmload = row => {
useDownload(exportApp, `${row.fileName}`, { fileUrl: row.fileUrl }) useDownload(exportApp, `${row.fileName}`, { fileUrl: row.fileUrl })
); );
}; };
const onPreview = (row: any) => {
const fileExtension = row.fileUrl.slice(row.fileUrl.lastIndexOf(".") + 1);
const url = Base64.encode(baseUrl + "/xmgl/file/preview?fileUrl=" + row.fileUrl + "&fullfilename=123." + fileExtension);
//
// const url1 = "http://182.90.224.147:8012/onlinePreview?url=";
// const url1 = "http://192.168.34.155:8012/onlinePreview?url=";
window.open(uplUrl + url);
};
// //
const onAppendix = row => { const onAppendix = row => {
dialogVisible.value = true; dialogVisible.value = true;
@ -521,7 +534,7 @@ onMounted(async () => {
border-left: 2px solid #0f81ff; border-left: 2px solid #0f81ff;
font-size: 24px; font-size: 24px;
color: #333333; color: #333333;
width: 90%; width: 97%;
margin: 20px auto; margin: 20px auto;
> img { > img {
width: 16px; width: 16px;