@@ -191,6 +191,7 @@
v-if="canUploadImages"
ref="upRef"
:action="managerApiUrl + '/manager/common/upload/file'"
+ :accept="uploadAccept"
:data="uploadData"
:headers="accessToken"
:before-upload="beforeUpload"
@@ -930,13 +931,16 @@ const canShowGroups = computed(() => {
return activeRoleTab.value === "MANAGER";
});
const canUploadImages = computed(() => {
- return activeRoleTab.value === "MANAGER";
+ return activeRoleTab.value === "MANAGER" && activeCategoryTab.value !== "FILE";
+});
+const uploadAccept = computed(() => {
+ if (activeCategoryTab.value === "VIDEO") return "video/*";
+ return "image/*";
});
const uploadButtonText = computed(() => {
const textMap = {
IMAGE: "上传图片",
VIDEO: "上传视频",
- FILE: "上传文件",
};
return textMap[activeCategoryTab.value] || "上传图片";
});
@@ -954,9 +958,22 @@ const uploadData = computed(() => {
function beforeUpload(file) {
if (!canUploadImages.value) {
- ElMessage.warning("仅管理员模块支持上传图片");
+ ElMessage.warning("当前模块不支持上传");
return false;
}
+ if (activeCategoryTab.value === "IMAGE") {
+ const isImg = (file?.type && file.type.startsWith("image/")) || /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i.test(file?.name || "");
+ if (!isImg) {
+ ElMessage.warning("请上传图片格式文件");
+ return false;
+ }
+ } else if (activeCategoryTab.value === "VIDEO") {
+ const isVid = (file?.type && file.type.startsWith("video/")) || /\.(mp4|webm|ogg|mov|avi|mkv)$/i.test(file?.name || "");
+ if (!isVid) {
+ ElMessage.warning("请上传视频格式文件");
+ return false;
+ }
+ }
const maxSize = 20480 * 1024;
if (file && file.size > maxSize) {
handleMaxSize(file);
@@ -1388,7 +1405,7 @@ function changeFileType() {
const categoryMap = {
pic: "IMAGE",
video: "VIDEO",
- file: "FILE",
+ file: props.isComponent ? "IMAGE" : "FILE",
all: "IMAGE",
};
const category = categoryMap[fileType.value] || "IMAGE";
diff --git a/seller/src/views/sys/oss-manage/ossManage.vue b/seller/src/views/sys/oss-manage/ossManage.vue
index 943ad7299..3262d1e7c 100644
--- a/seller/src/views/sys/oss-manage/ossManage.vue
+++ b/seller/src/views/sys/oss-manage/ossManage.vue
@@ -122,6 +122,7 @@
@click="handleCategoryTabChange('VIDEO')"
>视频
{
return activeRoleTab.value === "STORE";
});
-// 商家端允许上传图片/视频/文件
+// 商家端允许上传图片/视频(文件仅在发票上传业务中使用)
const canUploadImages = computed(() => {
- return activeRoleTab.value === "STORE";
+ return activeRoleTab.value === "STORE" && activeCategoryTab.value !== "FILE";
+});
+const uploadAccept = computed(() => {
+ if (activeCategoryTab.value === "VIDEO") return "video/*";
+ return "image/*";
});
const uploadButtonText = computed(() => {
const textMap = {
IMAGE: "上传图片",
VIDEO: "上传视频",
- FILE: "上传文件",
};
return textMap[activeCategoryTab.value] || "上传图片";
});
@@ -563,6 +568,19 @@ function beforeUpload(file) {
ElMessage.warning("当前模块不支持上传");
return false;
}
+ if (activeCategoryTab.value === "IMAGE") {
+ const isImg = (file?.type && file.type.startsWith("image/")) || /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i.test(file?.name || "");
+ if (!isImg) {
+ ElMessage.warning("请上传图片格式文件");
+ return false;
+ }
+ } else if (activeCategoryTab.value === "VIDEO") {
+ const isVid = (file?.type && file.type.startsWith("video/")) || /\.(mp4|webm|ogg|mov|avi|mkv)$/i.test(file?.name || "");
+ if (!isVid) {
+ ElMessage.warning("请上传视频格式文件");
+ return false;
+ }
+ }
const maxSize = 20480 * 1024;
if (file && file.size > maxSize) {
handleMaxSize(file);