mirror of
https://gitee.com/JavaLionLi/plus-ui.git
synced 2026-09-13 07:43:43 +08:00
add 新增 附件上传附件支持保存扩展信息
This commit is contained in:
parent
84cbada026
commit
382c37e896
@ -26,3 +26,17 @@ export interface OssQuery extends PageQuery {
|
|||||||
export interface OssForm {
|
export interface OssForm {
|
||||||
file: undefined | string;
|
file: undefined | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SysOssExt {
|
||||||
|
bizType?: string;
|
||||||
|
fileSize?: number;
|
||||||
|
contentType?: string;
|
||||||
|
source?: string;
|
||||||
|
uploadIp?: string;
|
||||||
|
remark?: string;
|
||||||
|
tags?: string[];
|
||||||
|
refId?: string;
|
||||||
|
refType?: string;
|
||||||
|
isTemp?: boolean;
|
||||||
|
md5?: string;
|
||||||
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
multiple
|
multiple
|
||||||
:action="uploadFileUrl"
|
:action="uploadFileUrl"
|
||||||
:before-upload="handleBeforeUpload"
|
:before-upload="handleBeforeUpload"
|
||||||
|
:data="uploadData"
|
||||||
:file-list="fileList"
|
:file-list="fileList"
|
||||||
:limit="limit"
|
:limit="limit"
|
||||||
:accept="fileAccept"
|
:accept="fileAccept"
|
||||||
@ -48,6 +49,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { delOss, listByIds } from '@/api/system/oss';
|
import { delOss, listByIds } from '@/api/system/oss';
|
||||||
|
import type { SysOssExt } from '@/api/system/oss/types';
|
||||||
import modal from '@/plugins/modal';
|
import modal from '@/plugins/modal';
|
||||||
import { propTypes } from '@/utils/propTypes';
|
import { propTypes } from '@/utils/propTypes';
|
||||||
import { globalHeaders } from '@/utils/request';
|
import { globalHeaders } from '@/utils/request';
|
||||||
@ -66,7 +68,12 @@ const props = defineProps({
|
|||||||
// 是否显示提示
|
// 是否显示提示
|
||||||
isShowTip: propTypes.bool.def(true),
|
isShowTip: propTypes.bool.def(true),
|
||||||
// 禁用组件(仅查看文件)
|
// 禁用组件(仅查看文件)
|
||||||
disabled: propTypes.bool.def(false)
|
disabled: propTypes.bool.def(false),
|
||||||
|
// 上传扩展属性
|
||||||
|
ossExt: {
|
||||||
|
type: Object as PropType<SysOssExt>,
|
||||||
|
default: undefined
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue']);
|
const emit = defineEmits(['update:modelValue']);
|
||||||
@ -82,6 +89,14 @@ const showTip = computed(() => props.isShowTip && (props.fileType || props.fileS
|
|||||||
|
|
||||||
const fileUploadRef = ref<ElUploadInstance>();
|
const fileUploadRef = ref<ElUploadInstance>();
|
||||||
|
|
||||||
|
// 上传附加数据(ossExt 扩展属性)
|
||||||
|
const uploadData = computed(() => {
|
||||||
|
if (!props.ossExt) return {};
|
||||||
|
return {
|
||||||
|
ossExt: JSON.stringify(props.ossExt)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 监听 fileType 变化,更新 fileAccept
|
// 监听 fileType 变化,更新 fileAccept
|
||||||
const fileAccept = computed(() => props.fileType.map(type => `.${type}`).join(','));
|
const fileAccept = computed(() => props.fileType.map(type => `.${type}`).join(','));
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
list-type="picture-card"
|
list-type="picture-card"
|
||||||
:on-success="handleUploadSuccess"
|
:on-success="handleUploadSuccess"
|
||||||
:before-upload="handleBeforeUpload"
|
:before-upload="handleBeforeUpload"
|
||||||
|
:data="uploadData"
|
||||||
:limit="limit"
|
:limit="limit"
|
||||||
:accept="fileAccept"
|
:accept="fileAccept"
|
||||||
:on-error="handleUploadError"
|
:on-error="handleUploadError"
|
||||||
@ -45,7 +46,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { compressAccurately } from 'image-conversion';
|
import { compressAccurately } from 'image-conversion';
|
||||||
import { listByIds, delOss } from '@/api/system/oss';
|
import { listByIds, delOss } from '@/api/system/oss';
|
||||||
import { OssVO } from '@/api/system/oss/types';
|
import type { OssVO, SysOssExt } from '@/api/system/oss/types';
|
||||||
import modal from '@/plugins/modal';
|
import modal from '@/plugins/modal';
|
||||||
import { propTypes } from '@/utils/propTypes';
|
import { propTypes } from '@/utils/propTypes';
|
||||||
import { globalHeaders } from '@/utils/request';
|
import { globalHeaders } from '@/utils/request';
|
||||||
@ -72,7 +73,12 @@ const props = defineProps({
|
|||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
// 压缩目标大小,单位KB。默认300KB以上文件才压缩,并压缩至300KB以内
|
// 压缩目标大小,单位KB。默认300KB以上文件才压缩,并压缩至300KB以内
|
||||||
compressTargetSize: propTypes.number.def(300)
|
compressTargetSize: propTypes.number.def(300),
|
||||||
|
// 上传扩展属性
|
||||||
|
ossExt: {
|
||||||
|
type: Object as PropType<SysOssExt>,
|
||||||
|
default: undefined
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue']);
|
const emit = defineEmits(['update:modelValue']);
|
||||||
@ -90,6 +96,14 @@ const showTip = computed(() => props.isShowTip && (props.fileType || props.fileS
|
|||||||
|
|
||||||
const imageUploadRef = ref<ElUploadInstance>();
|
const imageUploadRef = ref<ElUploadInstance>();
|
||||||
|
|
||||||
|
// 上传附加数据(ossExt 扩展属性)
|
||||||
|
const uploadData = computed(() => {
|
||||||
|
if (!props.ossExt) return {};
|
||||||
|
return {
|
||||||
|
ossExt: JSON.stringify(props.ossExt)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 监听 fileType 变化,更新 fileAccept
|
// 监听 fileType 变化,更新 fileAccept
|
||||||
const fileAccept = computed(() => props.fileType.map(type => `.${type}`).join(','));
|
const fileAccept = computed(() => props.fileType.map(type => `.${type}`).join(','));
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user