123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <template>
- <div class="app-container">
- <!-- 搜索区域 -->
- <div class="filter-container">
- <span>文章标题:</span>
- <el-input
- v-model="listQuery.articleTitle"
- placeholder="文章标题"
- style="width: 200px"
- class="filter-item"
- @keyup.enter.native="getList"
- />
- <span>审核状态:</span>
- <el-select
- v-model="listQuery.lowerAuditStatus"
- placeholder="审核状态"
- clearable
- style="width: 200px"
- class="filter-item"
- @change="getList"
- >
- <el-option label="全部" value="" />
- <el-option label="待审核" :value="2" />
- <el-option label="审核通过" :value="0" />
- <el-option label="审核未通过" :value="1" />
- </el-select>
- <span>上线状态:</span>
- <el-select
- v-model="listQuery.status"
- placeholder="上线状态"
- clearable
- style="width: 200px"
- class="filter-item"
- @change="getList"
- >
- <el-option label="全部" value="" />
- <el-option label="已上线" :value="1" />
- <el-option label="待上线" :value="2" />
- <el-option label="未上线" :value="0" />
- </el-select>
- <el-button type="primary" icon="el-icon-search" @click="getList">查询</el-button>
- <el-button v-if="userIdentity === 2 || proxyInfo!==null" icon="el-icon-edit" type="primary">添加文章</el-button>
- </div>
- <!-- 搜索区域END -->
- <!-- 表格区域 -->
- <el-table
- v-loading="listLoading"
- :data="list"
- style="width: 100%"
- border
- fit
- highlight-current-row
- cell-class-name="table-cell"
- >
- <el-table-column label="序号" type="index" width="80" align="center" />
- <el-table-column label="文章标题" prop="articleTitle" align="center" />
- <el-table-column label="文章头图" width="200" align="center">
- <template slot-scope="{ row }">
- <el-image
- style="width: 50px; height: 50px"
- :src="row.articleCover"
- :preview-src-list="srcList"
- /></template>
- </el-table-column>
- <el-table-column label="审核状态" width="180px" align="center">
- <template slot-scope="{ row }">
- <el-tag v-if="row.auditStatus === 0" size="small" type="danger">审核未通过</el-tag>
- <el-tag v-if="row.auditStatus === 1" size="small" type="success">审核通过</el-tag>
- <el-tag v-if="row.auditStatus === 2" size="small" type="warning">待审核</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="上线状态" width="180px" align="center">
- <template slot-scope="{row}">
- <!-- 只有审核通过了才能操作上下线 auditStatus :审核状态 -->
- <template v-if="row.auditStatus === 1">
- <template v-if="row.status === 0">
- <span style="margin-right:10px;" class="status danger">已下线</span>
- <el-button v-if="userIdentity===2 || proxyInfo!==null" type="primary" size="mini" @click="handleChangeStatus(row)">上线</el-button>
- </template>
- <template v-else>
- <span style="margin-right:10px;" class="status success ">已上线</span>
- <el-button v-if="userIdentity===2 || proxyInfo!==null" type="info" size="mini" plain @click="handleChangeStatus(row)">下线</el-button>
- </template>
- </template>
- <template v-else>
- <!-- <el-tag type="warning">待上线</el-tag> -->
- <span style="margin-right:10px;" class="status warning">待上线</span>
- </template>
- </template>
- </el-table-column>
- <el-table-column label="审核时间" width="240px" align="center">
- <template slot-scope="{row}">
- <span v-if="row.auditStatus!==2">{{ row.auditTime | formatTime }}</span>
- <span v-else>—</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="240px" align="center">
- <template>
- <el-button type="primary" size="mini" style="margin-right:5px" icon="el-icon-edit" @click="$_navigationTo(`/doc/article-edit`)">编辑</el-button>
- <el-button type="danger" size="mini" style="margin-right:5px" icon="el-icon-s-check">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <!-- 表格区域END -->
- </div>
- </template>
- <script>
- import Mock from 'mockjs'
- import { formatDate } from '@/utils'
- import { mapGetters } from 'vuex'
- export default {
- filters: {
- formatTime(time) {
- if (!time) {
- return ''
- }
- return formatDate(time, 'yyyy-MM-DD HH:mm:ss')
- }
- },
- data() {
- return {
- listLoading: false,
- listQuery: {
- pageNum: 0, // 页码
- pageSize: 20, // 分页大小
- articleTitle: '', // 供应商类型
- lowerAuditStatus: '', // 审核状态
- status: ''
- },
- list: [],
- srcList: []
- }
- },
- computed: {
- ...mapGetters(['authUserId', 'userIdentity', 'proxyInfo'])
- },
- created() {
- this.getList()
- },
- methods: {
- // 获取列表数据
- getList() {
- const count = 10
- const list = []
- for (let i = 0; i < count; i++) {
- list.push(Mock.mock({
- articleId: '@natural',
- articleTitle: '@ctitle(20,30)',
- articleCover: '@image("100x100")',
- auditStatus: '@natural(0,2)',
- auditTime: '@date("yy-MM-dd hh:mm:ss")',
- auditBy: '@cname(2,6)',
- status: '@natural(0,1)'
- }))
- }
- this.list = list
- this.initPreviewList(list)
- },
- // 初始化预览图片列表
- initPreviewList(list) {
- list.forEach(item => this.srcList.push(item.articleCover))
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .filter-container {
- span {
- display: inline-block;
- margin-bottom: 10px;
- vertical-align: middle;
- font-size: 14px;
- }
- .el-button {
- display: inline-block;
- margin-bottom: 10px;
- vertical-align: middle;
- }
- .el-input,
- .el-select {
- margin-right: 10px;
- margin-left: 10px;
- }
- }
- .el-table .cell {
- overflow: visible;
- }
- .el-badge{
- margin: 0 6px;
- }
- </style>
|