|
|
@@ -106,7 +106,7 @@
|
|
|
style="display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; cursor: pointer;"
|
|
|
@click="downloadFile(item)"
|
|
|
>
|
|
|
- <FileOutlined :style="{ fontSize: (baseSize > 100 ? '48px' : '36px'), color: '#1890ff' }" />
|
|
|
+ <component :is="getFileIcon(item)" :style="{ fontSize: (baseSize > 100 ? '48px' : '36px'), color: '#1890ff' }" />
|
|
|
<div style="font-size: 12px; color: #666; margin-top: 8px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 90%;">
|
|
|
{{ item.document || '文件' }}
|
|
|
</div>
|
|
|
@@ -125,7 +125,7 @@ import { ref, reactive, defineProps, watch, computed } from "vue";
|
|
|
import Api from "@/api/api";
|
|
|
import Up from "@/api/upload";
|
|
|
import utils from "@/utils/utils";
|
|
|
-import { DeleteOutlined, FileOutlined } from "@ant-design/icons-vue";
|
|
|
+import { DeleteOutlined, FileOutlined, FileTextOutlined, PlayCircleOutlined } from "@ant-design/icons-vue";
|
|
|
import { Empty } from "ant-design-vue";
|
|
|
|
|
|
const simpleImage = Empty.PRESENTED_IMAGE_SIMPLE;
|
|
|
@@ -219,6 +219,24 @@ function isImageFile(item) {
|
|
|
return item.fileType.toLowerCase() === 'image';
|
|
|
}
|
|
|
|
|
|
+// 根据文件类型返回对应图标组件
|
|
|
+function getFileIcon(item) {
|
|
|
+ if (!item) return FileTextOutlined;
|
|
|
+ const type = (item.fileType || '').toLowerCase();
|
|
|
+ if (type === 'image') return FileOutlined;
|
|
|
+ if (type === 'video') return PlayCircleOutlined;
|
|
|
+ // 根据文件扩展名判断文档类型
|
|
|
+ const filename = item.document || item.filename || '';
|
|
|
+ if (filename) {
|
|
|
+ const ext = filename.toLowerCase().split('.').pop();
|
|
|
+ const videoExts = ['mp4', 'webm', 'ogg', 'mov', 'avi'];
|
|
|
+ const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
|
|
|
+ if (videoExts.includes(ext)) return PlayCircleOutlined;
|
|
|
+ if (imageExts.includes(ext)) return FileOutlined;
|
|
|
+ }
|
|
|
+ return FileTextOutlined;
|
|
|
+}
|
|
|
+
|
|
|
// 格式化文件大小
|
|
|
function getFileSize(size) {
|
|
|
if (!size) return '未知大小';
|
|
|
@@ -319,12 +337,12 @@ function beforeUpload(file) {
|
|
|
list.value[file.sequence] = getList.data
|
|
|
.filter((v) => v.attachmentid == attachmentid)
|
|
|
.map((v) => {
|
|
|
- v = Object.assign(v, v.attinfos[0]);
|
|
|
- delete v.attinfos;
|
|
|
- v.cover = props.coverType
|
|
|
- ? v.subfiles.find((s) => s.type == props.coverType).url ||
|
|
|
- v.url
|
|
|
- : v.url;
|
|
|
+ if (v.attinfos && v.attinfos.length) {
|
|
|
+ v = Object.assign(v, v.attinfos[0]);
|
|
|
+ delete v.attinfos;
|
|
|
+ }
|
|
|
+ const subfile = v.subfiles && v.subfiles.length ? v.subfiles.find((s) => s.type == props.coverType) : null;
|
|
|
+ v.cover = props.coverType && subfile ? subfile.url : v.url;
|
|
|
return v;
|
|
|
})[0];
|
|
|
});
|
|
|
@@ -342,15 +360,23 @@ watch(
|
|
|
);
|
|
|
function init(attinfos, pic = props.pic) {
|
|
|
if(!attinfos.length) return;
|
|
|
- list.value = pic ? attinfos : attinfos.filter((v) => v.fileType == "image");
|
|
|
+ const fileType = Number(props.fileType);
|
|
|
+ if (pic) {
|
|
|
+ list.value = attinfos;
|
|
|
+ } else if (fileType === 1) {
|
|
|
+ list.value = attinfos.filter((v) => v.fileType == "image");
|
|
|
+ } else if (fileType === 2) {
|
|
|
+ list.value = attinfos.filter((v) => v.fileType == "video");
|
|
|
+ } else {
|
|
|
+ list.value = attinfos;
|
|
|
+ }
|
|
|
list.value = list.value.map((v) => {
|
|
|
- if (pic) {
|
|
|
+ if (pic && v.attinfos && v.attinfos.length) {
|
|
|
v = Object.assign(v, v.attinfos[0]);
|
|
|
delete v.attinfos;
|
|
|
}
|
|
|
- v.cover = props.coverType
|
|
|
- ? v.subfiles.find((s) => s.type == props.coverType).url || v.url
|
|
|
- : v.url;
|
|
|
+ const subfile = v.subfiles && v.subfiles.length ? v.subfiles.find((s) => s.type == props.coverType) : null;
|
|
|
+ v.cover = props.coverType && subfile ? subfile.url : v.url;
|
|
|
return v;
|
|
|
});
|
|
|
if (
|