| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- <template>
- <div class="app-container">
- <el-card shadow="never" class="mb16 filter-card">
- <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="small">
- <el-form-item label="租户名称" prop="tenantId">
- <inline-tenant-selector @change="handleTenantChange" />
- </el-form-item>
- <el-form-item label="文章标题" prop="articleTitle">
- <el-input
- v-model="queryParams.articleTitle"
- placeholder="请输入文章标题"
- clearable
- size="small"
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="文章状态" prop="status">
- <el-select v-model="queryParams.status" placeholder="请选择文章状态" clearable size="small">
- <el-option
- v-for="item in statusOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
- </el-form-item>
- </el-form>
- </el-card>
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button
- type="warning"
- plain
- icon="el-icon-download"
- size="mini"
- :loading="exportLoading"
- @click="handleExport"
- v-hasPermi="['admin:article:list']"
- >导出</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="info"
- plain
- icon="el-icon-document"
- size="mini"
- @click="handlePending"
- >待审计</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="info"
- plain
- icon="el-icon-bar-chart"
- size="mini"
- @click="showStatistics = true"
- >文章统计</el-button>
- </el-col>
- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
- </el-row>
- <el-table border size="small" style="width:100%" v-loading="loading" :data="articleList">
- <el-table-column type="selection" width="55" align="center" />
- <el-table-column label="租户名称" align="center" prop="companyName" min-width="120" />
- <el-table-column label="文章标题" align="center" prop="articleTitle" min-width="160" show-overflow-tooltip />
- <el-table-column label="文章分类" align="center" prop="categoryName" min-width="100" />
- <el-table-column label="作者" align="center" prop="author" min-width="90" />
- <el-table-column label="创建时间" align="center" prop="createTime" min-width="150" />
- <el-table-column label="文章状态" align="center" prop="status" min-width="90">
- <template slot-scope="scope">
- <el-tag v-if="scope.row.status == 0" type="warning">待审计</el-tag>
- <el-tag v-else-if="scope.row.status == 1" type="success">已通过</el-tag>
- <el-tag v-else type="error">已拒绝</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
- <template slot-scope="scope">
- <el-button
- size="mini"
- type="text"
- icon="el-icon-search"
- plain
- @click="handleView(scope.row)"
- >详情</el-button>
- <template v-if="scope.row.status == 0">
- <el-button
- size="mini"
- type="text"
- icon="el-icon-check"
- plain
- @click="handleAudit(scope.row, 1)"
- v-hasPermi="['admin:article:audit']"
- >通过</el-button>
- <el-button
- size="mini"
- type="text"
- icon="el-icon-close"
- plain
- @click="handleAudit(scope.row, 2)"
- v-hasPermi="['admin:article:audit']"
- >拒绝</el-button>
- </template>
- <el-button
- size="mini"
- type="text"
- icon="el-icon-delete"
- plain
- @click="handleDelete(scope.row)"
- v-hasPermi="['admin:article:remove']"
- >删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total>0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- <!-- 详情弹窗 -->
- <el-dialog title="文章详情" :visible.sync="viewOpen" width="800px" append-to-body>
- <el-form :model="viewForm" label-width="100px">
- <el-form-item label="租户名称">
- <span>{{ viewForm.companyName }}</span>
- </el-form-item>
- <el-form-item label="文章标题">
- <span>{{ viewForm.articleTitle }}</span>
- </el-form-item>
- <el-form-item label="文章分类">
- <span>{{ viewForm.categoryName }}</span>
- </el-form-item>
- <el-form-item label="作者">
- <span>{{ viewForm.author }}</span>
- </el-form-item>
- <el-form-item label="文章内容">
- <div v-html="viewForm.content"></div>
- </el-form-item>
- <el-form-item label="创建时间">
- <span>{{ viewForm.createTime }}</span>
- </el-form-item>
- <el-form-item label="文章状态">
- <el-tag v-if="viewForm.status == 0" type="warning">待审计</el-tag>
- <el-tag v-else-if="viewForm.status == 1" type="success">已通过</el-tag>
- <el-tag v-else type="error">已拒绝</el-tag>
- </el-form-item>
- </el-form>
- </el-dialog>
- <!-- 审计弹窗 -->
- <el-dialog :title="auditTitle" :visible.sync="auditOpen" width="400px" append-to-body>
- <el-form ref="auditForm" :model="auditForm" label-width="80px">
- <el-form-item label="审计备注">
- <el-textarea v-model="auditForm.auditRemark" placeholder="请输入审计备注" :rows="3" />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="submitAudit">确 定</el-button>
- </div>
- </el-dialog>
- <!-- 统计弹窗 -->
- <el-dialog title="文章统计" :visible.sync="showStatistics" width="600px" append-to-body>
- <el-card>
- <el-row :gutter="20">
- <el-col :span="12">
- <div class="stat-item">
- <span class="stat-value">{{ statistics.totalCount }}</span>
- <span class="stat-label">文章总数</span>
- </div>
- </el-col>
- <el-col :span="12">
- <div class="stat-item">
- <span class="stat-value">{{ statistics.pendingCount }}</span>
- <span class="stat-label">待审计</span>
- </div>
- </el-col>
- <el-col :span="12">
- <div class="stat-item">
- <span class="stat-value">{{ statistics.approvedCount }}</span>
- <span class="stat-label">已通过</span>
- </div>
- </el-col>
- <el-col :span="12">
- <div class="stat-item">
- <span class="stat-value">{{ statistics.rejectedCount }}</span>
- <span class="stat-label">已拒绝</span>
- </div>
- </el-col>
- </el-row>
- </el-card>
- </el-dialog>
- </div>
- </template>
- <script>
- import { listAllArticles, listPendingArticles, getArticleInfo, auditArticle, deleteArticle, getArticleStatistics, exportAllArticles } from '@/api/admin/article'
- import InlineTenantSelector from '@/components/InlineTenantSelector'
- export default {
- name: 'ArticleAdmin',
- components: { InlineTenantSelector },
- data() {
- return {
- loading: true,
- exportLoading: false,
- showSearch: true,
- total: 0,
- articleList: [],
- statistics: {
- totalCount: 0,
- pendingCount: 0,
- approvedCount: 0,
- rejectedCount: 0
- },
- // 状态选项
- statusOptions: [
- { value: 0, label: '待审计' },
- { value: 1, label: '已通过' },
- { value: 2, label: '已拒绝' }
- ],
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- tenantId: null,
- articleTitle: null,
- status: null
- },
- // 详情弹窗
- viewOpen: false,
- viewForm: {},
- // 审计弹窗
- auditOpen: false,
- auditTitle: '',
- auditForm: {
- articleId: null,
- status: null,
- auditRemark: ''
- },
- // 统计弹窗
- showStatistics: false
- }
- },
- created() {
- this.getList()
- },
- methods: {
- getList() {
- if (!this.queryParams.tenantId) {
- this.articleList = []
- this.total = 0
- this.loading = false
- return
- }
- this.loading = true
- listAllArticles(this.queryParams).then(response => {
- this.articleList = response.rows
- this.total = response.total
- this.loading = false
- })
- },
- /** 查询待审计列表 */
- handlePending() {
- this.loading = true
- listPendingArticles().then(response => {
- this.articleList = response.rows
- this.total = response.total
- this.loading = false
- })
- },
- /** 搜索按钮操作 */
- handleQuery() {
- if (!this.queryParams.tenantId) {
- this.$message.warning('请先选择租户')
- return
- }
- this.queryParams.pageNum = 1
- this.getList()
- },
- handleTenantChange(val) {
- this.queryParams.tenantId = val || null
- this.handleQuery()
- },
- resetQuery() {
- this.resetForm('queryForm')
- this.queryParams.tenantId = null
- this.handleQuery()
- },
- /** 查看详情 */
- handleView(row) {
- getArticleInfo(row.articleId).then(response => {
- this.viewForm = response.data
- this.viewOpen = true
- })
- },
- /** 审计文章 */
- handleAudit(row, status) {
- this.auditTitle = status === 1 ? '通过文章' : '拒绝文章'
- this.auditForm = {
- articleId: row.articleId,
- status: status,
- auditRemark: ''
- }
- this.auditOpen = true
- },
- /** 提交审计 */
- submitAudit() {
- auditArticle(this.auditForm.articleId, this.auditForm.status, this.auditForm.auditRemark).then(response => {
- this.$message.success(this.auditForm.status === 1 ? '通过成功' : '拒绝成功')
- this.auditOpen = false
- this.getList()
- })
- },
- /** 删除文章 */
- handleDelete(row) {
- this.$confirm('确定删除文章 [' + row.articleTitle + '] 吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- deleteArticle(row.articleId).then(response => {
- this.$message.success('删除成功')
- this.getList()
- })
- })
- },
- /** 查看统计 */
- showStatisticsDialog() {
- getArticleStatistics().then(response => {
- this.statistics = response.data
- this.showStatistics = true
- })
- },
- /** 导出按钒操作 */
- handleExport() {
- this.exportLoading = true
- exportAllArticles(this.queryParams).then(response => {
- this.download(response.msg)
- this.exportLoading = false
- }).catch(() => { this.exportLoading = false })
- }
- }
- }
- </script>
- <style scoped>
- .stat-item {
- text-align: center;
- padding: 20px;
- background: #f5f7fa;
- border-radius: 8px;
- }
- .stat-value {
- font-size: 24px;
- font-weight: bold;
- color: #1890ff;
- }
- .stat-label {
- display: block;
- margin-top: 5px;
- font-size: 14px;
- color: #666;
- }
- .mb16 { margin-bottom: 16px; }
- .filter-card { padding-bottom: 0; }
- </style>
|