| | |
| | | function editArticle(row: NewsArticle | PolicyArticle) { router.push(isPolicy.value ? `/talent-policy-categories/${row.id}` : `/talent-news-categories/${row.id}`) } |
| | | async function toggleStatus(row: NewsArticle | PolicyArticle) { |
| | | const next = Number(row.status) === 1 ? 2 : 1 |
| | | const action = isPolicy.value ? (next === 1 ? '启用' : '禁用') : (next === 1 ? '发布' : '下架') |
| | | const action = next === 1 ? '启用' : '禁用' |
| | | await ElMessageBox.confirm(`确认${action}该${isPolicy.value ? '政策' : '资讯'}吗?`, '操作确认', { type: 'warning' }) |
| | | if (isPolicy.value) await updateAdminPolicyStatus(row.id, next) |
| | | else await updateAdminNewsStatus(row.id, next) |
| | | ElMessage.success(isPolicy.value ? `政策已${action}` : (next === 1 ? '资讯已发布' : '资讯已下架')) |
| | | ElMessage.success(`${isPolicy.value ? '政策' : '资讯'}已${action}`) |
| | | await load() |
| | | } |
| | | onMounted(() => void load()) |
| | |
| | | <el-table-column label="发布时间" width="170" align="center"><template #default="{ row }">{{ formatTime(row.publishTime) }}</template></el-table-column> |
| | | <el-table-column prop="viewCount" label="观看数" width="100" align="center" /> |
| | | <el-table-column label="状态" width="100" align="center"><template #default="{ row }">{{ statusText(row.status) }}</template></el-table-column> |
| | | <el-table-column label="操作" width="180" align="center"><template #default="{ row }"><el-button link type="primary" @click="toggleStatus(row)">{{ isPolicy ? (Number(row.status) === 1 ? '禁用' : '启用') : (Number(row.status) === 1 ? '下架' : '发布') }}</el-button><el-button link type="primary" @click="editArticle(row)">编辑</el-button></template></el-table-column> |
| | | <el-table-column label="操作" width="180" align="center"><template #default="{ row }"><el-button link type="primary" @click="toggleStatus(row)">{{ Number(row.status) === 1 ? '禁用' : '启用' }}</el-button><el-button link type="primary" @click="editArticle(row)">编辑</el-button></template></el-table-column> |
| | | </el-table> |
| | | <div class="article-management-pagination"><el-pagination v-model:current-page="pagination.page" v-model:page-size="pagination.size" background layout="total, sizes, prev, pager, next" :page-sizes="[10, 20, 50]" :total="pagination.total" @change="load" /></div> |
| | | </section> |