feat: feishu alert

This commit is contained in:
zzc
2026-06-25 00:03:30 +08:00
parent bb819d07a1
commit a263e8a7e0
5 changed files with 245 additions and 10 deletions

View File

@@ -97,3 +97,18 @@ export function toggleEnable(data) {
data, data,
}) })
} }
/**
* 修改评论状态
* @param {*} { id, enable: boolean }
* @param { enable: boolean } data 是否启用
* @param { id: string } data 评论id
* @returns
*/
export function commentStatus(data) {
return request({
url: 'management/api/rating/pk/comment/toggle',
method: 'post',
data,
})
}

View File

@@ -29,7 +29,7 @@ export function scoreRecordList(data) {
/** /**
* 评论记录 * 评论记录
* @param {*} { pageNo, pageSize, userId?, topicId?, itemId?, trueUser? } * @param {*} { pageNo, pageSize, userId?, topicId?, itemId?, trueUser?, rootCommentId? }
* @returns * @returns
*/ */
export function userCommentList(data) { export function userCommentList(data) {
@@ -42,7 +42,9 @@ export function userCommentList(data) {
/** /**
* 评论 * 评论
* @param {*} { topicId, itemId, comment, userId } * @param {*} { topicId, itemId, comment, userId,parentCommentId, replyToCommentId, }
* @param { parentCommentId: string } data 评论回复必传
* @param { replyToCommentId: string } data 回复必传
* @returns * @returns
*/ */
export function comment(data) { export function comment(data) {
@@ -53,6 +55,21 @@ export function comment(data) {
}) })
} }
/**
* 修改评论状态
* @param {*} { id, enable: boolean }
* @param { enable: boolean } data 是否启用
* @param { id: string } data 评论id
* @returns
*/
export function commentStatus(data) {
return request({
url: 'management/api/rating/topicItemOperate/comment/toggle',
method: 'post',
data,
})
}
/** /**
* 评论点赞 * 评论点赞
* @param {*} { commentId, userId } * @param {*} { commentId, userId }

View File

@@ -18,7 +18,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="评价主题" prop="topicId"> <el-form-item v-if="!isReply" label="评价主题" prop="topicId">
<el-select <el-select
v-model="form.topicId" v-model="form.topicId"
v-loadmore="loadMoreTopics" v-loadmore="loadMoreTopics"
@@ -31,7 +31,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="评价项" prop="itemId"> <el-form-item v-if="!isReply" label="评价项" prop="itemId">
<el-select <el-select
v-model="form.itemId" v-model="form.itemId"
v-loadmore="loadMoreItems" v-loadmore="loadMoreItems"
@@ -54,7 +54,7 @@
</el-form-item> </el-form-item>
<el-form-item label="评论内容" prop="content"> <el-form-item label="评论内容" prop="content">
<el-input v-model="form.content" maxlength="500" placeholder="请输入您的评论文字" :rows="4" show-word-limit type="textarea" /> <el-input v-model="form.content" maxlength="500" :placeholder="contentPlaceholder" :rows="4" show-word-limit type="textarea" />
</el-form-item> </el-form-item>
</el-form> </el-form>
@@ -96,11 +96,15 @@
title: '立即评论', title: '立即评论',
dialogFormVisible: false, dialogFormVisible: false,
saving: false, saving: false,
isReply: false,
contentPlaceholder: '请输入您的评论文字',
form: { form: {
userId: '', userId: '',
topicId: '', topicId: '',
itemId: '', itemId: '',
content: '', content: '',
parentCommentId: '',
replyToCommentId: '',
}, },
rules: { rules: {
userId: [{ required: true, trigger: 'change', message: '请选择用户' }], userId: [{ required: true, trigger: 'change', message: '请选择用户' }],
@@ -130,11 +134,31 @@
}, },
methods: { methods: {
getThumbUrl, getThumbUrl,
showEdit() { showEdit(row = null, parentCommentId = null) {
this.title = '立即评论'
this.dialogFormVisible = true this.dialogFormVisible = true
this.form = this.$options.data().form this.form = this.$options.data().form
if (row) {
this.isReply = true
this.title = '回复评论'
this.contentPlaceholder = `回复 @${row.user ? row.user.nickname : '未知用户'}:`
this.form.parentCommentId = parentCommentId || row.id
this.form.replyToCommentId = row.id
if (row.rating) {
this.form.topicId = row.rating.topicId || row.rating.topic?.id || row.topicId
this.form.itemId = row.rating.itemId || row.rating.item?.id || row.itemId
} else {
this.form.topicId = row.topicId
this.form.itemId = row.itemId
}
} else {
this.isReply = false
this.title = '立即评论'
this.contentPlaceholder = '请输入您的评论文字'
}
// 重置列表数据 // 重置列表数据
this.userList = [] this.userList = []
this.userQuery.pageNo = 1 this.userQuery.pageNo = 1
@@ -151,7 +175,9 @@
// 初始化加载第一页数据 // 初始化加载第一页数据
this.fetchUserList() this.fetchUserList()
this.fetchTopicList() if (!this.isReply) {
this.fetchTopicList()
}
}, },
close() { close() {
this.$refs['form'].resetFields() this.$refs['form'].resetFields()

View File

@@ -0,0 +1,160 @@
<template>
<el-dialog :title="title" :visible.sync="dialogVisible" width="900px" @close="close">
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
<el-table-column align="center" fixed="left" label="操作" width="120">
<template #default="{ row }">
<el-button type="text" @click="handleLike(row)">点赞</el-button>
<el-button type="text" @click="handleReply(row)">回复</el-button>
</template>
</el-table-column>
<el-table-column align="left" label="回复内容" min-width="250">
<template #default="{ row }">
<div class="comment-content-cell">
<div v-if="row.replyToUser" class="reply-target">回复 @{{ row.replyToUser.nickname || '未知用户' }}:</div>
<div class="content-text">{{ row.content }}</div>
<div class="comment-meta">
<span class="meta-item">
<i class="el-icon-thumb" />
{{ row.likeCount || 0 }}
</span>
<el-tag v-if="row.status === 2" size="mini" style="margin-left: 8px" type="success">已展示</el-tag>
<el-tag v-else size="mini" style="margin-left: 8px" type="info">隐藏/待审</el-tag>
</div>
</div>
</template>
</el-table-column>
<el-table-column align="left" label="用户信息" min-width="180">
<template #default="{ row }">
<user-info :user="row.user" :user-id="row.userId" />
</template>
</el-table-column>
<el-table-column align="center" label="时间" prop="createdAt" width="160">
<template #default="{ row }">
{{ formatTime(row.createdAt) }}
</template>
</el-table-column>
</el-table>
<el-pagination
background
:current-page="queryForm.pageNo"
:layout="layout"
:page-size="queryForm.pageSize"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
/>
</el-dialog>
</template>
<script>
import { userCommentList } from '@/api/rating/topicOperate'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
import UserInfo from '@/components/UserInfo'
export default {
name: 'RecordCommentReplyList',
components: { UserInfo },
data() {
return {
title: '回复列表',
dialogVisible: false,
list: [],
listLoading: false,
layout: 'total, prev, pager, next',
total: 0,
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
rootCommentId: '',
},
parentRow: null,
}
},
methods: {
formatTime,
getThumbUrl,
show(row) {
this.parentRow = row
this.title = `回复列表`
this.dialogVisible = true
this.queryForm.rootCommentId = row.id
this.queryForm.pageNo = 1
this.fetchData()
},
close() {
this.dialogVisible = false
this.list = []
},
handleSizeChange(val) {
this.queryForm.pageSize = val
this.fetchData()
},
handleCurrentChange(val) {
this.queryForm.pageNo = val
this.fetchData()
},
async fetchData() {
this.listLoading = true
try {
const { data } = await userCommentList(this.queryForm)
this.list = data.list || []
this.total = data.totalCount || 0
} catch (error) {
console.error(error)
} finally {
this.listLoading = false
}
},
handleLike(row) {
this.$emit('like', row)
},
handleReply(row) {
// 传递当前行作为被回复对象同时传递根评论ID
this.$emit('reply', row, this.queryForm.rootCommentId)
},
},
}
</script>
<style scoped>
.comment-content-cell {
display: flex;
flex-direction: column;
}
.reply-target {
font-size: 12px;
color: #409eff;
margin-bottom: 4px;
}
.content-text {
font-size: 14px;
color: #303133;
margin-bottom: 8px;
word-break: break-all;
}
.comment-meta {
display: flex;
align-items: center;
font-size: 12px;
color: #909399;
}
.meta-item {
display: flex;
align-items: center;
margin-right: 12px;
}
.meta-item i {
margin-right: 4px;
}
</style>

View File

@@ -83,9 +83,11 @@
</vab-query-form> </vab-query-form>
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText"> <el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
<el-table-column align="center" fixed="left" label="操作" width="100"> <el-table-column align="center" fixed="left" label="操作" width="160">
<template #default="{ row }"> <template #default="{ row }">
<el-button type="text" @click="handleLike(row)">点赞</el-button> <el-button type="text" @click="handleLike(row)">点赞</el-button>
<el-button type="text" @click="handleReply(row)">回复</el-button>
<el-button v-if="row.replyCount > 0" type="text" @click="handleViewReplies(row)">查看回复</el-button>
</template> </template>
</el-table-column> </el-table-column>
@@ -153,6 +155,7 @@
<record-comment-edit ref="commentEdit" @fetch-data="fetchData" /> <record-comment-edit ref="commentEdit" @fetch-data="fetchData" />
<record-comment-like-edit ref="likeEdit" @fetch-data="fetchData" /> <record-comment-like-edit ref="likeEdit" @fetch-data="fetchData" />
<record-comment-reply-list ref="replyList" @like="handleLikeFromList" @reply="handleReplyFromList" />
</div> </div>
</template> </template>
@@ -166,10 +169,11 @@
import UserInfo from '@/components/UserInfo' import UserInfo from '@/components/UserInfo'
import RecordCommentEdit from './components/RecordCommentEdit' import RecordCommentEdit from './components/RecordCommentEdit'
import RecordCommentLikeEdit from './components/RecordCommentLikeEdit' import RecordCommentLikeEdit from './components/RecordCommentLikeEdit'
import RecordCommentReplyList from './components/RecordCommentReplyList'
export default { export default {
name: 'RatingTopicCommentIndex', name: 'RatingTopicCommentIndex',
components: { RecordCommentEdit, RecordCommentLikeEdit, UserInfo }, components: { RecordCommentEdit, RecordCommentLikeEdit, RecordCommentReplyList, UserInfo },
directives: { directives: {
loadmore: { loadmore: {
bind(el, binding) { bind(el, binding) {
@@ -333,9 +337,22 @@
handleLike(row) { handleLike(row) {
this.$refs['likeEdit'].showEdit(row) this.$refs['likeEdit'].showEdit(row)
}, },
handleReply(row) {
this.$refs['commentEdit'].showEdit(row)
},
handleViewReplies(row) {
this.$refs['replyList'].show(row)
},
handleCommentNow() { handleCommentNow() {
this.$refs['commentEdit'].showEdit() this.$refs['commentEdit'].showEdit()
}, },
// 子组件触发的方法
handleReplyFromList(row, parentCommentId) {
this.$refs['commentEdit'].showEdit(row, parentCommentId)
},
handleLikeFromList(row) {
this.$refs['likeEdit'].showEdit(row)
},
handleSizeChange(val) { handleSizeChange(val) {
this.queryForm.pageSize = val this.queryForm.pageSize = val
this.fetchData() this.fetchData()