fix: comment
Some checks failed
continuous-integration/drone/tag Build encountered an error

This commit is contained in:
zzc
2026-06-25 00:16:49 +08:00
parent a263e8a7e0
commit a34ed84a29
4 changed files with 45 additions and 10 deletions

View File

@@ -33,7 +33,7 @@
<el-table-column align="center" label="状态切换" width="80">
<template #default="{ row }">
<el-switch v-model="row.enable" :active-value="true" :inactive-value="false" @change="handleToggleStatus(row)" />
<el-switch v-model="row.status" :active-value="2" :inactive-value="4" @change="handleToggleStatus(row)" />
</template>
</el-table-column>
@@ -57,7 +57,7 @@
</template>
<script>
import { getCommentList, toggleEnable } from '@/api/rating/pk'
import { getCommentList, commentStatus } from '@/api/rating/pk'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
import UserInfo from '@/components/UserInfo'
@@ -126,11 +126,12 @@
},
async handleToggleStatus(row) {
try {
const { msg } = await toggleEnable({ id: row.id, enable: row.enable })
const enable = row.status === 2
const { msg } = await commentStatus({ id: row.id, enable })
this.$baseMessage(msg || '状态切换成功', 'success')
} catch (error) {
console.error(error)
row.enable = !row.enable
row.status = row.status === 2 ? 4 : 2
}
},
},

View File

@@ -85,7 +85,7 @@
<el-table-column align="center" label="状态切换" width="100">
<template #default="{ row }">
<el-switch v-model="row.enable" :active-value="true" :inactive-value="false" @change="handleToggleStatus(row)" />
<el-switch v-model="row.status" :active-value="2" :inactive-value="4" @change="handleToggleStatus(row)" />
</template>
</el-table-column>
@@ -113,7 +113,7 @@
</template>
<script>
import { getCommentList, toggleEnable, getList as getPkList } from '@/api/rating/pk'
import { getCommentList, commentStatus, getList as getPkList } from '@/api/rating/pk'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
import UserInfo from '@/components/UserInfo'
@@ -242,11 +242,13 @@
},
async handleToggleStatus(row) {
try {
const { msg } = await toggleEnable({ id: row.id, enable: row.enable })
// status: 2为启用4为禁用
const enable = row.status === 2
const { msg } = await commentStatus({ id: row.id, enable })
this.$baseMessage(msg || '状态切换成功', 'success')
} catch (error) {
console.error(error)
row.enable = !row.enable
row.status = row.status === 2 ? 4 : 2
}
},

View File

@@ -31,6 +31,12 @@
</template>
</el-table-column>
<el-table-column align="center" label="状态切换" width="80">
<template #default="{ row }">
<el-switch v-model="row.status" :active-value="2" :inactive-value="4" @change="handleToggleStatus(row)" />
</template>
</el-table-column>
<el-table-column align="center" label="时间" prop="createdAt" width="160">
<template #default="{ row }">
{{ formatTime(row.createdAt) }}
@@ -51,7 +57,7 @@
</template>
<script>
import { userCommentList } from '@/api/rating/topicOperate'
import { userCommentList, commentStatus } from '@/api/rating/topicOperate'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
import UserInfo from '@/components/UserInfo'
@@ -118,6 +124,16 @@
// 传递当前行作为被回复对象同时传递根评论ID
this.$emit('reply', row, this.queryForm.rootCommentId)
},
async handleToggleStatus(row) {
try {
const enable = row.status === 2
const { msg } = await commentStatus({ id: row.id, enable })
this.$baseMessage(msg || '状态切换成功', 'success')
} catch (error) {
console.error(error)
row.status = row.status === 2 ? 4 : 2
}
},
},
}
</script>

View File

@@ -136,6 +136,12 @@
</template>
</el-table-column>
<el-table-column align="center" label="状态切换" width="100">
<template #default="{ row }">
<el-switch v-model="row.status" :active-value="2" :inactive-value="4" @change="handleToggleStatus(row)" />
</template>
</el-table-column>
<el-table-column align="center" label="评论时间" prop="createdAt" width="160">
<template #default="{ row }">
{{ formatTime(row.createdAt) }}
@@ -160,7 +166,7 @@
</template>
<script>
import { userCommentList } from '@/api/rating/topicOperate'
import { userCommentList, commentStatus } from '@/api/rating/topicOperate'
import { getList as getUserList } from '@/api/system/user'
import { getList as getTopicList } from '@/api/rating/topic'
import { getList as getItemList } from '@/api/rating/topicItem'
@@ -346,6 +352,16 @@
handleCommentNow() {
this.$refs['commentEdit'].showEdit()
},
async handleToggleStatus(row) {
try {
const enable = row.status === 2
const { msg } = await commentStatus({ id: row.id, enable })
this.$baseMessage(msg || '状态切换成功', 'success')
} catch (error) {
console.error(error)
row.status = row.status === 2 ? 4 : 2
}
},
// 子组件触发的方法
handleReplyFromList(row, parentCommentId) {
this.$refs['commentEdit'].showEdit(row, parentCommentId)