Commit 8270fee1 authored by 罗林杰's avatar 罗林杰

修改活动发布

parent 62be76e8
......@@ -74,3 +74,11 @@ export function deleteComment(businessId) {
method: 'delete'
})
}
// oss查询图片路径
export function getOssUrl(id) {
return request({
url: '/common/getOssUrl?businessId=' + id,
method: 'GET'
})
}
......@@ -16,7 +16,7 @@
</el-form-item>
<el-form-item label="置顶:" prop="isTop">
<el-select v-model="queryParams.isTop" placeholder="请选择置顶状态" style="width: 150px" clearable>
<el-option v-for="item in yesOrNo" :key="item.value" :label="item.label" :value="item.value"/>
<el-option v-for="item in yesOrNo" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="推荐:" prop="isRecommended">
......@@ -162,6 +162,7 @@
@click="handleView(scope.row)"
>查看</el-button>
<el-button
v-if="scope.row.publishStatus!='1'"
v-has-permi="hasUpdatePerm"
:class="commonField.updateClass"
:type="commonField.typeParent"
......@@ -169,6 +170,7 @@
@click="handleUpdate(scope.row)"
>编辑</el-button>
<el-button
v-if="scope.row.publishStatus!='1'"
:class="commonField.resetPasClass"
:type="commonField.typeParent"
:size="commonField.size"
......@@ -309,7 +311,7 @@
import commonField from '@/utils/commonField'
import {
delCmsActivity,
listCmsActivity, updatePushStatus, updateStatus
listCmsActivity, updatePushStatus
} from '@/api/contentManagement/activity'
import { parseTime } from '@/utils'
import { getDataCache, setDataCache } from '@/assets/js/filterData'
......
......@@ -136,20 +136,41 @@
</div>
<!-- 详情弹窗 -->
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="deviceFormRef" :model="form" label-position="right" label-width="auto">
<el-row :gutter="20">
<el-col :span="24">
<span style="font-size: 20px;font-weight: bold;padding-left: 20px">内容:</span>
<div style="font-size: 15px;padding-left: 20px;padding-bottom: 20px;padding-top: 10px" class="content">{{ form.content }}</div>
</el-col>
<el-row :gutter="20">
<el-col v-for="(imagePath, index) in form.url" :key="index" :span="7">
<div style="padding-left: 20px;padding-bottom: 20px">
<img :src="imagePath" alt="Avatar" class="avatar">
<div>
<!-- 当没有图片时 -->
<div v-if="!form.url || form.url.length === 0" style="text-align: center; color: #999;">
没有图片
</div>
<!-- 当图片数量为1时 -->
<div v-else-if="form.url.length === 1" style="text-align: center;">
<img :src="form.url[0]" alt="Avatar" class="avatar1">
</div>
<!-- 当图片数量为4或6时,上下两排展示 -->
<div v-else-if="form.url.length === 4 || form.url.length === 2">
<el-row v-for="(row, rowIndex) in Math.ceil(form.url.length / 2)" :key="rowIndex" :gutter="20">
<el-col v-for="(imagePath, index) in form.url.slice(rowIndex * 2, rowIndex * 2 + 2)" :key="index" :span="12">
<div style="padding: 10px;">
<img :src="imagePath" alt="Avatar" class="avatar3">
</div>
</el-col>
</el-row>
</div>
<!-- 当图片数量为5, 7, 8或9时,按九宫格显示 -->
<el-row v-else :gutter="20">
<el-col v-for="(imagePath, index) in form.url" :key="index" :span="8">
<div style="padding: 10px;">
<img :src="imagePath" alt="Avatar" class="avatar2">
</div>
</el-col>
</el-row>
</div>
<el-col :span="12">
<span style="font-size: 15px;padding-left: 20px">评论数:{{ form.commentCount }}</span>
</el-col>
......@@ -226,7 +247,7 @@ import { getDataCache, setDataCache } from '@/assets/js/filterData'
import {
deleteComment,
delOpmArticle,
getOpmArticle,
getOpmArticle, getOssUrl,
listOpmArticle,
updateOpmArticle
} from '@/api/contentManagement/opmArticle'
......@@ -386,8 +407,15 @@ export default {
getOpmArticle(id).then(response => {
this.form = response.data
// 处理图片url 将url按逗号分隔成数组
if (this.form.url != null && this.form.url !== '') {
this.form.url = this.form.url.split(',')
if (response.data.pictureId !== '' && response.data.pictureId !== null) {
const urlArray = JSON.parse(response.data.pictureId)
const url = []
urlArray.id.forEach(item => {
getOssUrl(item).then(imgRes => {
url.push(imgRes.data)
})
})
this.form.url = url
}
this.title = this.form.memCode
this.open = true
......@@ -401,14 +429,23 @@ export default {
const id = row.businessId
getOpmArticle(id).then(response => {
this.form = response.data
// 处理图片url 将url按逗号分隔成数组
if (this.form.url != null && this.form.url !== '') {
this.form.url = this.form.url.split(',')
// 处理图片url
if (response.data.pictureId !== '' && response.data.pictureId !== null) {
const urlArray = JSON.parse(response.data.pictureId)
const url = []
urlArray.id.forEach(item => {
getOssUrl(item).then(imgRes => {
url.push(imgRes.data)
})
})
this.form.url = url
}
this.title = this.form.memCode
this.open = true
this.isEdit = true
if (this.form.articleCommentVOList !== null && this.form.articleCommentVOList.length > 0) {
this.getComment()
}
})
},
getComment() {
......@@ -418,13 +455,13 @@ export default {
const rootComments = []
// 首先填充映射表
this.form.articleCommentDTOList.forEach(comment => {
this.form.articleCommentVOList.forEach(comment => {
comment.children = [] // 为每个评论添加 children 属性
commentMap.set(comment.businessId, comment)
})
// 再次遍历评论列表,这次是为了设置父子关系
this.form.articleCommentDTOList.forEach(comment => {
this.form.articleCommentVOList.forEach(comment => {
if (comment.parentId === null) {
// 如果是顶级评论,直接添加到 rootComments
rootComments.push(comment)
......@@ -487,7 +524,7 @@ export default {
return deleteComment(row.businessId)
}).then(() => {
// 使用 filter 创建一个新的数组,并重新赋值给 this.form.comments
this.form.comments = this.form.comments.filter(comment => comment.businessId !== row.businessId)
this.form.articleCommentVOList = this.form.articleCommentVOList.filter(comment => comment.businessId !== row.businessId)
this.$forceUpdate()
// 触发视图更新
this.$nextTick(() => {
......@@ -507,7 +544,7 @@ export default {
return deleteComment(row.businessId)
}).then(() => {
// 遍历找到对应的父评论,并更新其子评论
this.form.comments.forEach(comment => {
this.form.articleCommentVOList.forEach(comment => {
if (comment.businessId === row.parentId) {
comment.children = comment.children.filter(reply => reply.businessId !== row.businessId)
}
......@@ -597,4 +634,25 @@ export default {
}
}
}
.avatar1 {
width: 280px;
height: 240px;
display: block;
margin: 0 auto;
}
.avatar2 {
width: 120px;
height: 100px;
display: block;
}
.avatar3 {
width: 200px;
height: 178px;
display: block;
}
.avatar4 {
width: 200px;
height: 178px;
display: block;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment