增加长图,方图分类上传功能

This commit is contained in:
liuyuan
2025-03-12 16:44:12 +08:00
parent cc744ec5fb
commit eadd2a83be
7 changed files with 105 additions and 16 deletions

View File

@@ -23,7 +23,7 @@ module.exports = {
}, },
// Various Dev Server settings // Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST host: '192.168.110.160', // can be overwritten by process.env.HOST
port: 8001, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined port: 8001, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: true, autoOpenBrowser: true,
errorOverlay: true, errorOverlay: true,

View File

@@ -32,7 +32,7 @@
</el-switch> </el-switch>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label="课程图" label="课程图"
prop="image" prop="image"
:class="fileList.length > 0 ? 'isUpload' : ''" :class="fileList.length > 0 ? 'isUpload' : ''"
> >
@@ -45,7 +45,6 @@
}" }"
:action="baseUrl + '/oss/fileoss'" :action="baseUrl + '/oss/fileoss'"
list-type="picture-card" list-type="picture-card"
:on-preview="handlePictureCardPreview"
:file-list="fileList" :file-list="fileList"
:on-success="handlePicSuccess" :on-success="handlePicSuccess"
accept=".jpeg,.jpg,.gif,.png" accept=".jpeg,.jpg,.gif,.png"
@@ -54,7 +53,32 @@
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
</el-upload> </el-upload>
<el-dialog :visible.sync="dialogVisible" :append-to-body="true"> <el-dialog :visible.sync="dialogVisible" :append-to-body="true">
<img width="100%" :src="dataForm.image" alt="" /> <img width="100%" height="40px" :src="dataForm.image" alt="" />
</el-dialog>
</el-form-item>
<el-form-item
label="课程方图"
prop="squareImage"
:class="fileList2.length > 0 ? 'isUpload2' : ''"
>
<el-upload
:limit="1"
class="el-uploadfeng2"
:class="{
uoloadSty: dataForm.showBtnDealImg2,
disUoloadSty: dataForm.noneBtnImg2
}"
:action="baseUrl + '/oss/fileoss'"
list-type="picture-card"
:file-list="fileList2"
:on-success="handlePicSuccess2"
accept=".jpeg,.jpg,.gif,.png"
:on-remove="handleRemove2"
>
<i class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="dialogVisible" :append-to-body="true">
<img width="100%" :src="dataForm.squareImage" alt="" />
</el-dialog> </el-dialog>
</el-form-item> </el-form-item>
<div v-if="relationProducts && relationProducts.length > 0" style="margin-bottom:20px"> <div v-if="relationProducts && relationProducts.length > 0" style="margin-bottom:20px">
@@ -242,6 +266,7 @@ export default {
author: "", author: "",
publisherList: [], publisherList: [],
fileList: [], fileList: [],
fileList2: [],
fileListNovel: [], fileListNovel: [],
dialogImageUrl: "", dialogImageUrl: "",
dialogVisible: false, dialogVisible: false,
@@ -419,6 +444,7 @@ export default {
}else{ }else{
this.relationProducts = [] this.relationProducts = []
} }
//长图
if (data.image != "" && data.image != null) { if (data.image != "" && data.image != null) {
var img = { var img = {
name: "", name: "",
@@ -428,6 +454,17 @@ export default {
attr.push(img); attr.push(img);
this.fileList = attr; this.fileList = attr;
} }
//方图
if (data.squareImage != "" && data.squareImage != null) {
var img = {
name: "",
url: data.squareImage
};
var attr = [];
attr.push(img);
this.fileList2 = attr;
}
data.canzk = data.canzk == '1' ? true : false data.canzk = data.canzk == '1' ? true : false
this.dataForm = { ...data }; this.dataForm = { ...data };
} }
@@ -473,6 +510,7 @@ export default {
canzk: this.dataForm.canzk ? '1' : '0', // 是否可以自考 0/ 1 0 否 1 是 canzk: this.dataForm.canzk ? '1' : '0', // 是否可以自考 0/ 1 0 否 1 是
sort: this.dataForm.sort, sort: this.dataForm.sort,
image: this.dataForm.image, image: this.dataForm.image,
squareImage: this.dataForm.squareImage,
content: this.dataForm.content, content: this.dataForm.content,
etitle: this.dataForm.etitle, etitle: this.dataForm.etitle,
titleAbbr: this.dataForm.titleAbbr, titleAbbr: this.dataForm.titleAbbr,
@@ -503,6 +541,7 @@ export default {
} }
}); });
}, },
//长图
handlePicSuccess(res, file) { handlePicSuccess(res, file) {
// console.log(res,'res') // console.log(res,'res')
if (res.msg == "success") { if (res.msg == "success") {
@@ -517,20 +556,46 @@ export default {
this.$message.error("上传失败"); this.$message.error("上传失败");
} }
}, },
//方图
handlePicSuccess2(res, file){
if (res.msg == "success") {
this.dataForm.squareImage = res.url;
this.fileList2.push({
name: file.name,
url: res.url
});
this.$message.success("上传成功");
} else {
this.$message.error("上传失败");
}
},
//删除长图
handleRemove(file, fileList) { handleRemove(file, fileList) {
this.dataForm.image = ""; this.dataForm.image = "";
this.fileList = []; this.fileList = [];
this.dataForm.noneBtnImg = fileList.length >= this.dataForm.limitCountImg; this.dataForm.noneBtnImg = fileList.length >= this.dataForm.limitCountImg;
}, },
//删除方图
handleRemove2(file, fileList) {
this.dataForm.squareImage = "";
this.fileList2 = [];
this.dataForm.noneBtnImg2 = fileList.length >= this.dataForm.limitCountImg2;
},
//放大长图
handlePictureCardPreview(file) { handlePictureCardPreview(file) {
this.dataForm.image = file.url; this.dataForm.image = file.url;
this.dialogVisible = true; this.dialogVisible = true;
}, },
//放大方图
handlePictureCardPreview2(file) {
this.dataForm.squareImage = file.url;
this.dialogVisible = true;
},
handleDownload(file) { handleDownload(file) {
console.log(file); console.log(file);
}, },
handlereset() { handlereset() {
(this.fileList = []), (this.fileListNovel = []), (this.visible = false); (this.fileList = []), (this.fileList2 = []), (this.fileListNovel = []), (this.visible = false);
this.$emit('pclose') this.$emit('pclose')
this.relationProducts = [] this.relationProducts = []
this.courseId = undefined this.courseId = undefined
@@ -583,3 +648,16 @@ export default {
} }
} }
</style> </style>
<style>
.isUpload .el-uploadfeng {
display: flex;
}
.isUpload .el-upload-list--picture-card .is-success{
display: flex;
align-items: center;
}
.isUpload .el-upload-list--picture-card .el-upload-list__item-thumbnail{
height:58px;
}
</style>

View File

@@ -80,7 +80,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="课程图" label="课程图"
header-align="center" header-align="center"
align="center" align="center"
width="100" width="100"
@@ -91,7 +91,23 @@
style="width:100%;display: flex; style="width:100%;display: flex;
align-items: center;justify-content: center;" align-items: center;justify-content: center;"
> >
<img :src="scope.row.image" alt="" width="40px" height="40px" /> <img :src="scope.row.image" alt="" width="60px" height="30px" />
</div>
</template>
</el-table-column>
<el-table-column
label="课程方图"
header-align="center"
align="center"
width="100"
>
<template slot-scope="scope">
<div
v-if="scope.row.image"
style="width:100%;display: flex;
align-items: center;justify-content: center;"
>
<img :src="scope.row.squareImage" alt="" width="40px" height="40px" />
</div> </div>
</template> </template>
</el-table-column> </el-table-column>

View File

@@ -457,7 +457,7 @@ this.$emit('delete',[row])
console.log("🚀 ~ getAssociatedGoodsList ~ form:", form) console.log("🚀 ~ getAssociatedGoodsList ~ form:", form)
} }
else if (this.currentType == "bookMarketId") { else if (this.currentType == "bookMarketId") {
form.medicineMarketId = this.currentId; form.psycheMarketId = this.currentId;
console.log("🚀 ~ getAssociatedGoodsList ~ form:", form) console.log("🚀 ~ getAssociatedGoodsList ~ form:", form)
} }

View File

@@ -188,7 +188,7 @@ export default {
form.medicineLabelId = this.currentId; form.medicineLabelId = this.currentId;
console.log("🚀 ~ getAssociatedGoodsList ~ form:", form); console.log("🚀 ~ getAssociatedGoodsList ~ form:", form);
} else if (this.currentType == "bookMarketId") { } else if (this.currentType == "bookMarketId") {
form.medicineMarketId = this.currentId; form.psycheMarketId = this.currentId;
console.log("🚀 ~ getAssociatedGoodsList ~ form:", form); console.log("🚀 ~ getAssociatedGoodsList ~ form:", form);
} }
this.dataListLoading = true; this.dataListLoading = true;

View File

@@ -5,8 +5,8 @@
window.SITE_CONFIG = {}; window.SITE_CONFIG = {};
// api接口请求地址 // api接口请求地址
// window.SITE_CONFIG['baseUrl'] = 'http://59.110.212.44:9100/pb';
window.SITE_CONFIG['baseUrl'] = 'https://api.nuttyreading.com'; window.SITE_CONFIG['baseUrl'] = 'https://api.nuttyreading.com';
//window.SITE_CONFIG['baseUrl'] = 'http://192.168.110.100:9200/pb';
// cdn地址 = 域名 + 版本号 // cdn地址 = 域名 + 版本号
window.SITE_CONFIG['domain'] = './'; // 域名 window.SITE_CONFIG['domain'] = './'; // 域名

View File

@@ -5,13 +5,8 @@
window.SITE_CONFIG = {}; window.SITE_CONFIG = {};
// api接口请求地址 // api接口请求地址
// window.SITE_CONFIG['baseUrl'] = 'http://192.168.110.100:9200/pb';//张川川
// window.SITE_CONFIG['baseUrl'] = 'http://59.110.212.44:9200/pb';
// window.SITE_CONFIG['baseUrl'] = 'https://testapi.nuttyreading.com'; // 线上测试环境11
window.SITE_CONFIG['baseUrl'] = 'https://api.nuttyreading.com'; // 线上正式环境 window.SITE_CONFIG['baseUrl'] = 'https://api.nuttyreading.com'; // 线上正式环境
// window.SITE_CONFIG['baseUrl'] = 'http://192.168.110.110:9200/pb';//磊哥 //window.SITE_CONFIG['baseUrl'] = 'http://192.168.110.100:9200/pb'; //本地
// window.SITE_CONFIG['baseUrl'] = 'http://59.110.212.44:9200/pb';
// window.SITE_CONFIG['baseUrl'] = 'http://192.168.110.100:9200/pb';
// cdn地址 = 域名 + 版本号 // cdn地址 = 域名 + 版本号
window.SITE_CONFIG['domain'] = './'; // 域名 window.SITE_CONFIG['domain'] = './'; // 域名