|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="header">
|
|
<div class="header">
|
|
|
<a-upload
|
|
<a-upload
|
|
|
- accept="image/*"
|
|
|
|
|
|
|
+ :accept="acceptType"
|
|
|
multiple
|
|
multiple
|
|
|
:beforeUpload="beforeUpload"
|
|
:beforeUpload="beforeUpload"
|
|
|
:showUploadList="false"
|
|
:showUploadList="false"
|
|
@@ -14,7 +14,7 @@
|
|
|
type="primary"
|
|
type="primary"
|
|
|
size="samll"
|
|
size="samll"
|
|
|
class="mr-10"
|
|
class="mr-10"
|
|
|
- >{{ butText }}</a-button
|
|
|
|
|
|
|
+ >{{ buttonText }}</a-button
|
|
|
>
|
|
>
|
|
|
</a-upload>
|
|
</a-upload>
|
|
|
<div style="width: 300px" v-if="list.length">
|
|
<div style="width: 300px" v-if="list.length">
|
|
@@ -114,7 +114,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, reactive, defineProps, watch } from "vue";
|
|
|
|
|
|
|
+import { ref, reactive, defineProps, watch, computed } from "vue";
|
|
|
import Api from "@/api/api";
|
|
import Api from "@/api/api";
|
|
|
import Up from "@/api/upload";
|
|
import Up from "@/api/upload";
|
|
|
import utils from "@/utils/utils";
|
|
import utils from "@/utils/utils";
|
|
@@ -165,6 +165,32 @@ const props = defineProps({
|
|
|
type: Boolean,
|
|
type: Boolean,
|
|
|
default: true,
|
|
default: true,
|
|
|
},
|
|
},
|
|
|
|
|
+ fileType: {
|
|
|
|
|
+ type: [String, Number],
|
|
|
|
|
+ default: 1, // 1:图片, 2:视频, 3:文档
|
|
|
|
|
+ },
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+// 根据文件类型返回 accept 属性
|
|
|
|
|
+const acceptType = computed(() => {
|
|
|
|
|
+ const type = Number(props.fileType);
|
|
|
|
|
+ if (type === 2) {
|
|
|
|
|
+ return 'video/*'; // 视频类型
|
|
|
|
|
+ } else if (type === 3) {
|
|
|
|
|
+ return '*'; // 文档类型不限制
|
|
|
|
|
+ }
|
|
|
|
|
+ return 'image/*'; // 默认图片类型
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+// 根据文件类型返回按钮文字
|
|
|
|
|
+const buttonText = computed(() => {
|
|
|
|
|
+ const type = Number(props.fileType);
|
|
|
|
|
+ if (type === 2) {
|
|
|
|
|
+ return '添加视频';
|
|
|
|
|
+ } else if (type === 3) {
|
|
|
|
|
+ return '添加文档';
|
|
|
|
|
+ }
|
|
|
|
|
+ return '添加图片';
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
let baseSize = ref("140"),
|
|
let baseSize = ref("140"),
|