|
|
@@ -13,7 +13,7 @@
|
|
|
<el-input v-model="searchForm.keyword" placeholder="搜索帖子标题" clearable @keyup.enter="handleSearch" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="状态">
|
|
|
- <el-select v-model="searchForm.status" clearable placeholder="全部">
|
|
|
+ <el-select v-model="searchForm.status" clearable placeholder="全部" style="width: 130px">
|
|
|
<el-option label="全部" value="all" />
|
|
|
<el-option label="在售" value="on_sale" />
|
|
|
<el-option label="公开" value="public" />
|
|
|
@@ -39,14 +39,17 @@
|
|
|
<el-tag v-else type="warning" size="small">待确认</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="查看人数" width="90">
|
|
|
+ <el-table-column label="查看人数" width="110">
|
|
|
<template #default="{ row }">
|
|
|
- <el-input-number v-model="row._viewCount" :min="0" size="small" controls-position="right"
|
|
|
- @change="saveViewCount(row)" style="width: 100px" />
|
|
|
+ <el-button size="small" @click="openViewCountEditor(row)">{{ row._viewCount ?? 0 }}</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="publishTime" label="发布时间" width="160" />
|
|
|
- <el-table-column prop="expireTime" label="过期时间" width="160" />
|
|
|
+ <el-table-column label="发布时间" width="150">
|
|
|
+ <template #default="{ row }">{{ formatDateTime(row.publishTime) }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="过期时间" width="150">
|
|
|
+ <template #default="{ row }">{{ formatDateTime(row.expireTime) }}</template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column label="操作" width="280" fixed="right">
|
|
|
<template #default="{ row }">
|
|
|
<el-button v-if="canEdit(row)" size="small" @click="router.push('/admin/posts/' + row.id + '/edit')">编辑</el-button>
|
|
|
@@ -67,6 +70,14 @@
|
|
|
</div>
|
|
|
</el-card>
|
|
|
|
|
|
+ <el-dialog v-model="vcDialog.visible" title="修改查看人数" width="360px">
|
|
|
+ <el-input-number v-model="vcDialog.value" :min="0" />
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="vcDialog.visible = false">取消</el-button>
|
|
|
+ <el-button type="primary" :loading="vcDialog.loading" @click="confirmViewCount">确认</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
<el-dialog v-model="hitDialog.visible" title="设置命中状态" width="400px">
|
|
|
<el-radio-group v-model="hitDialog.value">
|
|
|
<el-radio value="pending">待确认</el-radio>
|
|
|
@@ -87,6 +98,7 @@ import { useRouter } from 'vue-router'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import { getPostController } from '../api/post-controller'
|
|
|
import { useLoginUserStore } from '../store'
|
|
|
+import { formatDateTime } from '../util/format'
|
|
|
import type { PostVo, ListPostsParams } from '../api/models'
|
|
|
|
|
|
const router = useRouter()
|
|
|
@@ -106,6 +118,13 @@ const searchForm = reactive({ keyword: '', status: 'all' })
|
|
|
|
|
|
const pagination = reactive({ pageNum: 1, pageSize: 10, total: 0 })
|
|
|
|
|
|
+const vcDialog = reactive({
|
|
|
+ visible: false,
|
|
|
+ postId: 0,
|
|
|
+ value: 0,
|
|
|
+ loading: false,
|
|
|
+})
|
|
|
+
|
|
|
const hitDialog = reactive({
|
|
|
visible: false,
|
|
|
postId: 0,
|
|
|
@@ -147,11 +166,23 @@ function handleReset() {
|
|
|
handleSearch()
|
|
|
}
|
|
|
|
|
|
-async function saveViewCount(row: PostVo & { _viewCount?: number }) {
|
|
|
+function openViewCountEditor(row: PostVo & { _viewCount?: number }) {
|
|
|
+ vcDialog.postId = Number(row.id)
|
|
|
+ vcDialog.value = row._viewCount ?? row.viewCount ?? 0
|
|
|
+ vcDialog.visible = true
|
|
|
+}
|
|
|
+
|
|
|
+async function confirmViewCount() {
|
|
|
+ vcDialog.loading = true
|
|
|
try {
|
|
|
- await api.updateViewCount(Number(row.id), { viewCount: row._viewCount ?? 0 })
|
|
|
+ await api.updateViewCount(vcDialog.postId, { viewCount: vcDialog.value })
|
|
|
+ ElMessage.success('查看人数已更新')
|
|
|
+ vcDialog.visible = false
|
|
|
+ await fetchData()
|
|
|
} catch {
|
|
|
ElMessage.error('更新查看人数失败')
|
|
|
+ } finally {
|
|
|
+ vcDialog.loading = false
|
|
|
}
|
|
|
}
|
|
|
|