|
@@ -147,6 +147,8 @@ const props = defineProps({
|
|
|
type: [String, Object, Array],
|
|
type: [String, Object, Array],
|
|
|
default: () => []
|
|
default: () => []
|
|
|
},
|
|
},
|
|
|
|
|
+ // 返回值类型:ossId - 返回 OSS 表 ID,url - 返回图片绝对路径 URL
|
|
|
|
|
+ valueType: propTypes.string.def('ossId'),
|
|
|
// 图片数量限制
|
|
// 图片数量限制
|
|
|
limit: propTypes.number.def(5),
|
|
limit: propTypes.number.def(5),
|
|
|
// 大小限制(MB)
|
|
// 大小限制(MB)
|
|
@@ -256,8 +258,8 @@ watch(
|
|
|
} else {
|
|
} else {
|
|
|
// 判断是否为URL路径(包含http/https协议或相对路径)
|
|
// 判断是否为URL路径(包含http/https协议或相对路径)
|
|
|
if (typeof val === 'string' && (val.startsWith('http') || val.startsWith('/'))) {
|
|
if (typeof val === 'string' && (val.startsWith('http') || val.startsWith('/'))) {
|
|
|
- // 直接使用URL路径作为图片显示
|
|
|
|
|
- list = [{ url: val } as OssVO];
|
|
|
|
|
|
|
+ // 如果是以逗号分隔的URL列表,进行拆分
|
|
|
|
|
+ list = val.split(',').map((url) => ({ url } as OssVO));
|
|
|
} else {
|
|
} else {
|
|
|
// 原有逻辑,调用API获取信息
|
|
// 原有逻辑,调用API获取信息
|
|
|
const res = await listByIds(val);
|
|
const res = await listByIds(val);
|
|
@@ -394,8 +396,14 @@ const listToString = (list: any[], separator?: string) => {
|
|
|
let strs = '';
|
|
let strs = '';
|
|
|
separator = separator || ',';
|
|
separator = separator || ',';
|
|
|
for (const i in list) {
|
|
for (const i in list) {
|
|
|
- if (undefined !== list[i].ossId && list[i].url.indexOf('blob:') !== 0) {
|
|
|
|
|
- strs += list[i].ossId + separator;
|
|
|
|
|
|
|
+ if (props.valueType === 'url') {
|
|
|
|
|
+ if (list[i].url && list[i].url.indexOf('blob:') !== 0) {
|
|
|
|
|
+ strs += list[i].url + separator;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (undefined !== list[i].ossId && list[i].url.indexOf('blob:') !== 0) {
|
|
|
|
|
+ strs += list[i].ossId + separator;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return strs != '' ? strs.substring(0, strs.length - 1) : '';
|
|
return strs != '' ? strs.substring(0, strs.length - 1) : '';
|