fix: topic pinned
This commit is contained in:
@@ -66,3 +66,17 @@ export function toggleEnable(id, isEnabled) {
|
||||
data: { isEnabled },
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 置顶话题置顶状态
|
||||
* @param {id: string} id 话题 id
|
||||
* @param {isPinned: boolean} 是否置顶话题
|
||||
* @returns
|
||||
*/
|
||||
export function pinnedTopic(id, isPinned) {
|
||||
return request({
|
||||
url: `/management/api/rating/topic/pinned/${id}`,
|
||||
method: 'patch',
|
||||
data: { isPinned },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
<template>
|
||||
<div class="rating-topic-container">
|
||||
<el-alert
|
||||
v-if="!queryForm.categoryId"
|
||||
:closable="false"
|
||||
show-icon
|
||||
style="margin-bottom: 20px"
|
||||
title="选择类别后可以置顶话题"
|
||||
type="info"
|
||||
/>
|
||||
|
||||
<vab-query-form>
|
||||
<vab-query-form-left-panel>
|
||||
<el-button icon="el-icon-plus" type="primary" @click="handleAdd">创建话题</el-button>
|
||||
@@ -109,9 +118,15 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="操作" width="150">
|
||||
<el-table-column align="center" label="操作" width="200">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleViewItems(row)">查看评分项</el-button>
|
||||
|
||||
<template v-if="queryForm.categoryId">
|
||||
<el-button v-if="!row.isPinned" style="color: #e6a23c" type="text" @click="handleTogglePin(row, true)">置顶</el-button>
|
||||
<el-button v-else style="color: #909399" type="text" @click="handleTogglePin(row, false)">取消置顶</el-button>
|
||||
</template>
|
||||
|
||||
<el-button v-if="row.status !== 4" style="color: #f56c6c" type="text" @click="handleDisable(row)">禁用</el-button>
|
||||
<el-button v-if="row.status === 4" style="color: #67c23a" type="text" @click="handleEnable(row)">启用</el-button>
|
||||
</template>
|
||||
@@ -133,7 +148,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getList } from '@/api/rating/topic'
|
||||
import { getList, pinnedTopic } from '@/api/rating/topic'
|
||||
import { getList as getCategoryList } from '@/api/rating/topicCategory'
|
||||
import { reviewTopic } from '@/api/rating/topicOperate'
|
||||
import { formatTime } from '@/utils'
|
||||
@@ -244,6 +259,15 @@
|
||||
query: { topicId: row.id },
|
||||
})
|
||||
},
|
||||
async handleTogglePin(row, isPinned) {
|
||||
try {
|
||||
const { msg } = await pinnedTopic(row.id, isPinned)
|
||||
this.$baseMessage(msg || (isPinned ? '置顶成功' : '已取消置顶'), 'success')
|
||||
this.fetchData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
},
|
||||
handleDisable(row) {
|
||||
this.$confirm('确定要禁用该话题吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
|
||||
Reference in New Issue
Block a user