index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <div class="app-container">
  3. <el-card shadow="never" class="mb16 filter-card">
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="small">
  5. <el-form-item label="租户名称" prop="tenantId">
  6. <inline-tenant-selector @change="handleTenantChange" />
  7. </el-form-item>
  8. <el-form-item label="文章标题" prop="articleTitle">
  9. <el-input
  10. v-model="queryParams.articleTitle"
  11. placeholder="请输入文章标题"
  12. clearable
  13. size="small"
  14. @keyup.enter.native="handleQuery"
  15. />
  16. </el-form-item>
  17. <el-form-item label="文章状态" prop="status">
  18. <el-select v-model="queryParams.status" placeholder="请选择文章状态" clearable size="small">
  19. <el-option
  20. v-for="item in statusOptions"
  21. :key="item.value"
  22. :label="item.label"
  23. :value="item.value">
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  29. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  30. </el-form-item>
  31. </el-form>
  32. </el-card>
  33. <el-row :gutter="10" class="mb8">
  34. <el-col :span="1.5">
  35. <el-button
  36. type="warning"
  37. plain
  38. icon="el-icon-download"
  39. size="mini"
  40. :loading="exportLoading"
  41. @click="handleExport"
  42. v-hasPermi="['admin:article:list']"
  43. >导出</el-button>
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-button
  47. type="info"
  48. plain
  49. icon="el-icon-document"
  50. size="mini"
  51. @click="handlePending"
  52. >待审计</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button
  56. type="info"
  57. plain
  58. icon="el-icon-bar-chart"
  59. size="mini"
  60. @click="showStatistics = true"
  61. >文章统计</el-button>
  62. </el-col>
  63. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  64. </el-row>
  65. <el-table border size="small" style="width:100%" v-loading="loading" :data="articleList">
  66. <el-table-column type="selection" width="55" align="center" />
  67. <el-table-column label="租户名称" align="center" prop="companyName" min-width="120" />
  68. <el-table-column label="文章标题" align="center" prop="articleTitle" min-width="160" show-overflow-tooltip />
  69. <el-table-column label="文章分类" align="center" prop="categoryName" min-width="100" />
  70. <el-table-column label="作者" align="center" prop="author" min-width="90" />
  71. <el-table-column label="创建时间" align="center" prop="createTime" min-width="150" />
  72. <el-table-column label="文章状态" align="center" prop="status" min-width="90">
  73. <template slot-scope="scope">
  74. <el-tag v-if="scope.row.status == 0" type="warning">待审计</el-tag>
  75. <el-tag v-else-if="scope.row.status == 1" type="success">已通过</el-tag>
  76. <el-tag v-else type="error">已拒绝</el-tag>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  80. <template slot-scope="scope">
  81. <el-button
  82. size="mini"
  83. type="text"
  84. icon="el-icon-search"
  85. plain
  86. @click="handleView(scope.row)"
  87. >详情</el-button>
  88. <template v-if="scope.row.status == 0">
  89. <el-button
  90. size="mini"
  91. type="text"
  92. icon="el-icon-check"
  93. plain
  94. @click="handleAudit(scope.row, 1)"
  95. v-hasPermi="['admin:article:audit']"
  96. >通过</el-button>
  97. <el-button
  98. size="mini"
  99. type="text"
  100. icon="el-icon-close"
  101. plain
  102. @click="handleAudit(scope.row, 2)"
  103. v-hasPermi="['admin:article:audit']"
  104. >拒绝</el-button>
  105. </template>
  106. <el-button
  107. size="mini"
  108. type="text"
  109. icon="el-icon-delete"
  110. plain
  111. @click="handleDelete(scope.row)"
  112. v-hasPermi="['admin:article:remove']"
  113. >删除</el-button>
  114. </template>
  115. </el-table-column>
  116. </el-table>
  117. <pagination
  118. v-show="total>0"
  119. :total="total"
  120. :page.sync="queryParams.pageNum"
  121. :limit.sync="queryParams.pageSize"
  122. @pagination="getList"
  123. />
  124. <!-- 详情弹窗 -->
  125. <el-dialog title="文章详情" :visible.sync="viewOpen" width="800px" append-to-body>
  126. <el-form :model="viewForm" label-width="100px">
  127. <el-form-item label="租户名称">
  128. <span>{{ viewForm.companyName }}</span>
  129. </el-form-item>
  130. <el-form-item label="文章标题">
  131. <span>{{ viewForm.articleTitle }}</span>
  132. </el-form-item>
  133. <el-form-item label="文章分类">
  134. <span>{{ viewForm.categoryName }}</span>
  135. </el-form-item>
  136. <el-form-item label="作者">
  137. <span>{{ viewForm.author }}</span>
  138. </el-form-item>
  139. <el-form-item label="文章内容">
  140. <div v-html="viewForm.content"></div>
  141. </el-form-item>
  142. <el-form-item label="创建时间">
  143. <span>{{ viewForm.createTime }}</span>
  144. </el-form-item>
  145. <el-form-item label="文章状态">
  146. <el-tag v-if="viewForm.status == 0" type="warning">待审计</el-tag>
  147. <el-tag v-else-if="viewForm.status == 1" type="success">已通过</el-tag>
  148. <el-tag v-else type="error">已拒绝</el-tag>
  149. </el-form-item>
  150. </el-form>
  151. </el-dialog>
  152. <!-- 审计弹窗 -->
  153. <el-dialog :title="auditTitle" :visible.sync="auditOpen" width="400px" append-to-body>
  154. <el-form ref="auditForm" :model="auditForm" label-width="80px">
  155. <el-form-item label="审计备注">
  156. <el-textarea v-model="auditForm.auditRemark" placeholder="请输入审计备注" :rows="3" />
  157. </el-form-item>
  158. </el-form>
  159. <div slot="footer" class="dialog-footer">
  160. <el-button type="primary" @click="submitAudit">确 定</el-button>
  161. </div>
  162. </el-dialog>
  163. <!-- 统计弹窗 -->
  164. <el-dialog title="文章统计" :visible.sync="showStatistics" width="600px" append-to-body>
  165. <el-card>
  166. <el-row :gutter="20">
  167. <el-col :span="12">
  168. <div class="stat-item">
  169. <span class="stat-value">{{ statistics.totalCount }}</span>
  170. <span class="stat-label">文章总数</span>
  171. </div>
  172. </el-col>
  173. <el-col :span="12">
  174. <div class="stat-item">
  175. <span class="stat-value">{{ statistics.pendingCount }}</span>
  176. <span class="stat-label">待审计</span>
  177. </div>
  178. </el-col>
  179. <el-col :span="12">
  180. <div class="stat-item">
  181. <span class="stat-value">{{ statistics.approvedCount }}</span>
  182. <span class="stat-label">已通过</span>
  183. </div>
  184. </el-col>
  185. <el-col :span="12">
  186. <div class="stat-item">
  187. <span class="stat-value">{{ statistics.rejectedCount }}</span>
  188. <span class="stat-label">已拒绝</span>
  189. </div>
  190. </el-col>
  191. </el-row>
  192. </el-card>
  193. </el-dialog>
  194. </div>
  195. </template>
  196. <script>
  197. import { listAllArticles, listPendingArticles, getArticleInfo, auditArticle, deleteArticle, getArticleStatistics, exportAllArticles } from '@/api/admin/article'
  198. import InlineTenantSelector from '@/components/InlineTenantSelector'
  199. export default {
  200. name: 'ArticleAdmin',
  201. components: { InlineTenantSelector },
  202. data() {
  203. return {
  204. loading: true,
  205. exportLoading: false,
  206. showSearch: true,
  207. total: 0,
  208. articleList: [],
  209. statistics: {
  210. totalCount: 0,
  211. pendingCount: 0,
  212. approvedCount: 0,
  213. rejectedCount: 0
  214. },
  215. // 状态选项
  216. statusOptions: [
  217. { value: 0, label: '待审计' },
  218. { value: 1, label: '已通过' },
  219. { value: 2, label: '已拒绝' }
  220. ],
  221. // 查询参数
  222. queryParams: {
  223. pageNum: 1,
  224. pageSize: 10,
  225. tenantId: null,
  226. articleTitle: null,
  227. status: null
  228. },
  229. // 详情弹窗
  230. viewOpen: false,
  231. viewForm: {},
  232. // 审计弹窗
  233. auditOpen: false,
  234. auditTitle: '',
  235. auditForm: {
  236. articleId: null,
  237. status: null,
  238. auditRemark: ''
  239. },
  240. // 统计弹窗
  241. showStatistics: false
  242. }
  243. },
  244. created() {
  245. this.getList()
  246. },
  247. methods: {
  248. getList() {
  249. if (!this.queryParams.tenantId) {
  250. this.articleList = []
  251. this.total = 0
  252. this.loading = false
  253. return
  254. }
  255. this.loading = true
  256. listAllArticles(this.queryParams).then(response => {
  257. this.articleList = response.rows
  258. this.total = response.total
  259. this.loading = false
  260. })
  261. },
  262. /** 查询待审计列表 */
  263. handlePending() {
  264. this.loading = true
  265. listPendingArticles().then(response => {
  266. this.articleList = response.rows
  267. this.total = response.total
  268. this.loading = false
  269. })
  270. },
  271. /** 搜索按钮操作 */
  272. handleQuery() {
  273. if (!this.queryParams.tenantId) {
  274. this.$message.warning('请先选择租户')
  275. return
  276. }
  277. this.queryParams.pageNum = 1
  278. this.getList()
  279. },
  280. handleTenantChange(val) {
  281. this.queryParams.tenantId = val || null
  282. this.handleQuery()
  283. },
  284. resetQuery() {
  285. this.resetForm('queryForm')
  286. this.queryParams.tenantId = null
  287. this.handleQuery()
  288. },
  289. /** 查看详情 */
  290. handleView(row) {
  291. getArticleInfo(row.articleId).then(response => {
  292. this.viewForm = response.data
  293. this.viewOpen = true
  294. })
  295. },
  296. /** 审计文章 */
  297. handleAudit(row, status) {
  298. this.auditTitle = status === 1 ? '通过文章' : '拒绝文章'
  299. this.auditForm = {
  300. articleId: row.articleId,
  301. status: status,
  302. auditRemark: ''
  303. }
  304. this.auditOpen = true
  305. },
  306. /** 提交审计 */
  307. submitAudit() {
  308. auditArticle(this.auditForm.articleId, this.auditForm.status, this.auditForm.auditRemark).then(response => {
  309. this.$message.success(this.auditForm.status === 1 ? '通过成功' : '拒绝成功')
  310. this.auditOpen = false
  311. this.getList()
  312. })
  313. },
  314. /** 删除文章 */
  315. handleDelete(row) {
  316. this.$confirm('确定删除文章 [' + row.articleTitle + '] 吗?', '提示', {
  317. confirmButtonText: '确定',
  318. cancelButtonText: '取消',
  319. type: 'warning'
  320. }).then(() => {
  321. deleteArticle(row.articleId).then(response => {
  322. this.$message.success('删除成功')
  323. this.getList()
  324. })
  325. })
  326. },
  327. /** 查看统计 */
  328. showStatisticsDialog() {
  329. getArticleStatistics().then(response => {
  330. this.statistics = response.data
  331. this.showStatistics = true
  332. })
  333. },
  334. /** 导出按钒操作 */
  335. handleExport() {
  336. this.exportLoading = true
  337. exportAllArticles(this.queryParams).then(response => {
  338. this.download(response.msg)
  339. this.exportLoading = false
  340. }).catch(() => { this.exportLoading = false })
  341. }
  342. }
  343. }
  344. </script>
  345. <style scoped>
  346. .stat-item {
  347. text-align: center;
  348. padding: 20px;
  349. background: #f5f7fa;
  350. border-radius: 8px;
  351. }
  352. .stat-value {
  353. font-size: 24px;
  354. font-weight: bold;
  355. color: #1890ff;
  356. }
  357. .stat-label {
  358. display: block;
  359. margin-top: 5px;
  360. font-size: 14px;
  361. color: #666;
  362. }
  363. .mb16 { margin-bottom: 16px; }
  364. .filter-card { padding-bottom: 0; }
  365. </style>