文件预览不能使用

main
王家东 4 months ago
parent 514f53c606
commit fa735ebd3c
  1. 2
      jeecgboot-vue3-master/src/views/UpfilePersion/UpfilePersionList.vue
  2. 18
      jeecgboot-vue3-master/src/views/expscore/ExpScoreList.vue

@ -349,7 +349,7 @@
} }
function handlePreview(record) { function handlePreview(record) {
const previewServerUrl = 'http://127.0.0.1:8012/onlinePreview?url='; const previewServerUrl = 'http://10.20.15.171:8012/onlinePreview?url=';
const fileUrl = `${globalSetting.domainUrl}${getDownWork}?id=${record.id}`; const fileUrl = `${globalSetting.domainUrl}${getDownWork}?id=${record.id}`;
const extName = record.url.substring(record.url.lastIndexOf('.')); const extName = record.url.substring(record.url.lastIndexOf('.'));
const previewUrl = `${fileUrl}&fullfilename=${new Date().getTime()}${extName}`; const previewUrl = `${fileUrl}&fullfilename=${new Date().getTime()}${extName}`;

@ -43,6 +43,8 @@
<template #fileSlot="{text}"> <template #fileSlot="{text}">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span> <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button> <a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button>
<a-button v-if="text" type="primary" preIcon="ant-design:download-outlined" size="small" @click="handlePreview(text)">预览</a-button>
</template> </template>
</BasicTable> </BasicTable>
<!-- 表单区域 --> <!-- 表单区域 -->
@ -62,6 +64,7 @@
import JSelectUserByDept from '/@/components/Form/src/jeecg/components/JSelectUserByDept.vue'; import JSelectUserByDept from '/@/components/Form/src/jeecg/components/JSelectUserByDept.vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import {useMessage} from "../../hooks/web/useMessage"; import {useMessage} from "../../hooks/web/useMessage";
import {getDownWork} from "/@/views/UpfilePersion/UpfilePersion.api";
const { createMessage } = useMessage(); const { createMessage } = useMessage();
const route = useRoute(); const route = useRoute();
@ -105,6 +108,21 @@
sm: { span: 16 }, sm: { span: 16 },
}); });
function handlePreview(record) {
console.log("===========================================================");
console.log(record);
console.log("===========================================================");
const previewServerUrl = 'http://10.20.15.171:8012/onlinePreview?url=';
let url = 'http://10.20.15.171/jeecg-boot/sys/common/static/' + record;
window.open(previewServerUrl + encodeURIComponent(base64Encode(url)));
}
function base64Encode(str: string): string {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
/** /**
* 新增事件 * 新增事件
*/ */

Loading…
Cancel
Save