修复
This commit is contained in:
@@ -130,8 +130,10 @@ export default {
|
|||||||
// 然后将数组转为对象数组
|
// 然后将数组转为对象数组
|
||||||
this.fileList = list.map(item => {
|
this.fileList = list.map(item => {
|
||||||
if (typeof item === "string") {
|
if (typeof item === "string") {
|
||||||
if (item.indexOf(this.baseUrl) === -1 && !isExternal(item)) {
|
// 如果不是完整URL且不包含baseUrl,则添加baseUrl前缀用于显示
|
||||||
item = { name: this.baseUrl + item, url: this.baseUrl + item }
|
if (!isExternal(item) && item.indexOf(this.baseUrl) === -1) {
|
||||||
|
const displayUrl = this.baseUrl + (item.startsWith('/') ? item : '/' + item);
|
||||||
|
item = { name: displayUrl, url: displayUrl }
|
||||||
} else {
|
} else {
|
||||||
item = { name: item, url: item }
|
item = { name: item, url: item }
|
||||||
}
|
}
|
||||||
@@ -196,13 +198,14 @@ export default {
|
|||||||
// 上传成功回调
|
// 上传成功回调
|
||||||
handleUploadSuccess(res, file) {
|
handleUploadSuccess(res, file) {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
// 根据新的接口返回格式,data字段包含图片路径
|
// 直接使用接口返回的路径,不做任何修改
|
||||||
let imagePath = res.data || res.fileName;
|
let imagePath = res.data || res.fileName;
|
||||||
// 如果路径不是以http开头,则拼接域名前缀
|
// 为了显示需要,临时添加baseUrl前缀
|
||||||
|
let displayUrl = imagePath;
|
||||||
if (imagePath && !imagePath.startsWith('http://') && !imagePath.startsWith('https://')) {
|
if (imagePath && !imagePath.startsWith('http://') && !imagePath.startsWith('https://')) {
|
||||||
imagePath = this.baseUrl + imagePath;
|
displayUrl = this.baseUrl + imagePath;
|
||||||
}
|
}
|
||||||
this.uploadList.push({ name: imagePath, url: imagePath })
|
this.uploadList.push({ name: displayUrl, url: displayUrl })
|
||||||
this.uploadedSuccessfully()
|
this.uploadedSuccessfully()
|
||||||
} else {
|
} else {
|
||||||
this.number--
|
this.number--
|
||||||
|
|||||||
@@ -37,8 +37,8 @@
|
|||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-image
|
<el-image
|
||||||
style="width: 60px; height: 60px"
|
style="width: 60px; height: 60px"
|
||||||
:src="baseUrl + scope.row.img"
|
:src="getImageDisplayUrl(scope.row.img)"
|
||||||
:preview-src-list="[baseUrl + scope.row.img]"
|
:preview-src-list="[getImageDisplayUrl(scope.row.img)]"
|
||||||
fit="cover"
|
fit="cover"
|
||||||
v-if="scope.row.img"
|
v-if="scope.row.img"
|
||||||
>
|
>
|
||||||
@@ -385,22 +385,8 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确保图片URL正确处理,用于回显
|
// 图片路径处理:编辑时直接使用数据库中的路径,上传组件会自动处理显示
|
||||||
if (this.form.img) {
|
// 不需要额外的路径处理,保持数据库中存储的原始路径
|
||||||
// 如果img不是完整URL,则处理为相对路径
|
|
||||||
if (this.form.img.startsWith('http://') || this.form.img.startsWith('https://')) {
|
|
||||||
// 完整URL保持不变
|
|
||||||
} else {
|
|
||||||
// 确保路径格式正确,移除baseUrl前缀(如果有)
|
|
||||||
if (this.form.img.startsWith(baseUrl)) {
|
|
||||||
this.form.img = this.form.img.substring(baseUrl.length);
|
|
||||||
}
|
|
||||||
// 确保路径不以/开头(因为上传组件期望的是相对路径)
|
|
||||||
if (this.form.img.startsWith('/')) {
|
|
||||||
this.form.img = this.form.img.substring(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('修改活动数据处理后:', this.form);
|
console.log('修改活动数据处理后:', this.form);
|
||||||
this.open = true;
|
this.open = true;
|
||||||
@@ -466,8 +452,8 @@ export default {
|
|||||||
this.$modal.msgSuccess("删除成功");
|
this.$modal.msgSuccess("删除成功");
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
},
|
},
|
||||||
// 获取图片完整URL的方法
|
// 获取图片显示URL的方法
|
||||||
getImageUrlMethod(imagePath) {
|
getImageDisplayUrl(imagePath) {
|
||||||
if (!imagePath) {
|
if (!imagePath) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -477,13 +463,8 @@ export default {
|
|||||||
return imagePath;
|
return imagePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确保路径以/开头
|
// 添加后台请求路径前缀
|
||||||
if (!imagePath.startsWith('/')) {
|
return this.baseUrl + (imagePath.startsWith('/') ? imagePath : '/' + imagePath);
|
||||||
imagePath = '/' + imagePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回完整URL
|
|
||||||
return baseUrl + imagePath;
|
|
||||||
},
|
},
|
||||||
// 验证活动内容只能输入数字
|
// 验证活动内容只能输入数字
|
||||||
validateNumberInput() {
|
validateNumberInput() {
|
||||||
|
|||||||
@@ -473,7 +473,8 @@ export default {
|
|||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const ids = row.id || this.ids;
|
const ids = row.id || this.ids;
|
||||||
this.$modal.confirm('是否确认删除普通歌曲编号为"' + ids + '"的数据项?').then(function() {
|
const musicName = row.name || '选中的音乐';
|
||||||
|
this.$modal.confirm('是否确认删除音乐"' + musicName + '"?').then(function() {
|
||||||
return delNormalSong(ids);
|
return delNormalSong(ids);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.getList();
|
this.getList();
|
||||||
|
|||||||
Reference in New Issue
Block a user