|
|
@@ -63,7 +63,6 @@ const props = defineProps({
|
|
|
isShowTip: propTypes.bool.def(true),
|
|
|
tipText: propTypes.string.def(''),
|
|
|
span: propTypes.number.def(24),
|
|
|
- isObject: propTypes.bool.def(false),
|
|
|
multiple: propTypes.bool.def(true),
|
|
|
white: propTypes.bool.def(false),
|
|
|
// 上传数据格式
|
|
|
@@ -89,15 +88,21 @@ const fileUploadRef = ref<ElUploadInstance>();
|
|
|
const progressList = ref<any>([]);
|
|
|
watch(
|
|
|
() => props.modelValue,
|
|
|
- async (val) => {
|
|
|
+ async (val: any) => {
|
|
|
if (val) {
|
|
|
let temp = 1;
|
|
|
// 首先将值转为数组
|
|
|
let list = [];
|
|
|
if (props.format === 'array' && Array.isArray(val)) {
|
|
|
list = val;
|
|
|
- } else if (props.format === 'object' || props.isObject) {
|
|
|
- list = [val];
|
|
|
+ } else if (props.format === 'object') {
|
|
|
+ list = [{
|
|
|
+ name: val.fileName,
|
|
|
+ url: val.url,
|
|
|
+ fileSize: val.fileSize,
|
|
|
+ fileType: val.fileType,
|
|
|
+ ossId: val.ossId
|
|
|
+ }];
|
|
|
} else {
|
|
|
const res = await listByIds(val as string);
|
|
|
list = res.data.map((oss) => {
|
|
|
@@ -187,7 +192,7 @@ const uploadedSuccessfully = () => {
|
|
|
if (props.format === 'id') {
|
|
|
emit('change', listToString(valuef));
|
|
|
emit('update:modelValue', listToString(valuef));
|
|
|
- } else if (props.isObject || props.format === 'object') {
|
|
|
+ } else if (props.format === 'object') {
|
|
|
emit('change', valuef[0])
|
|
|
emit('update:modelValue', valuef[0]);
|
|
|
} else {
|
|
|
@@ -205,7 +210,7 @@ const handleDelete = (index: number) => {
|
|
|
fileUploadRef.value?.abort(fileList.value[index]);
|
|
|
fileList.value.splice(index, 1);
|
|
|
const valuef = fileList.value.map(({ name, url, fileType, fileSize }) => ({ fileName: name, url, fileSize, fileType }));
|
|
|
- if (props.isObject) {
|
|
|
+ if (props.format === 'object') {
|
|
|
emit('change', null)
|
|
|
emit('update:modelValue', null);
|
|
|
} else {
|