articleList.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索区域 -->
  4. <div class="filter-container">
  5. <span>文章标题:</span>
  6. <el-input
  7. v-model="listQuery.articleTitle"
  8. placeholder="文章标题"
  9. style="width: 200px"
  10. class="filter-item"
  11. @keyup.enter.native="getList"
  12. />
  13. <span>审核状态:</span>
  14. <el-select
  15. v-model="listQuery.lowerAuditStatus"
  16. placeholder="审核状态"
  17. clearable
  18. style="width: 200px"
  19. class="filter-item"
  20. @change="getList"
  21. >
  22. <el-option label="全部" value="" />
  23. <el-option label="待审核" :value="2" />
  24. <el-option label="审核通过" :value="0" />
  25. <el-option label="审核未通过" :value="1" />
  26. </el-select>
  27. <span>上线状态:</span>
  28. <el-select
  29. v-model="listQuery.status"
  30. placeholder="上线状态"
  31. clearable
  32. style="width: 200px"
  33. class="filter-item"
  34. @change="getList"
  35. >
  36. <el-option label="全部" value="" />
  37. <el-option label="已上线" :value="1" />
  38. <el-option label="待上线" :value="2" />
  39. <el-option label="未上线" :value="0" />
  40. </el-select>
  41. <el-button type="primary" icon="el-icon-search" @click="getList">查询</el-button>
  42. <el-button v-if="userIdentity === 2 || proxyInfo!==null" icon="el-icon-edit" type="primary">添加文章</el-button>
  43. </div>
  44. <!-- 搜索区域END -->
  45. <!-- 表格区域 -->
  46. <el-table
  47. v-loading="listLoading"
  48. :data="list"
  49. style="width: 100%"
  50. border
  51. fit
  52. highlight-current-row
  53. cell-class-name="table-cell"
  54. >
  55. <el-table-column label="序号" type="index" width="80" align="center" />
  56. <el-table-column label="文章标题" prop="articleTitle" align="center" />
  57. <el-table-column label="文章头图" width="200" align="center">
  58. <template slot-scope="{ row }">
  59. <el-image
  60. style="width: 50px; height: 50px"
  61. :src="row.articleCover"
  62. :preview-src-list="srcList"
  63. /></template>
  64. </el-table-column>
  65. <el-table-column label="审核状态" width="180px" align="center">
  66. <template slot-scope="{ row }">
  67. <el-tag v-if="row.auditStatus === 0" size="small" type="danger">审核未通过</el-tag>
  68. <el-tag v-if="row.auditStatus === 1" size="small" type="success">审核通过</el-tag>
  69. <el-tag v-if="row.auditStatus === 2" size="small" type="warning">待审核</el-tag>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="上线状态" width="180px" align="center">
  73. <template slot-scope="{row}">
  74. <!-- 只有审核通过了才能操作上下线 auditStatus :审核状态 -->
  75. <template v-if="row.auditStatus === 1">
  76. <template v-if="row.status === 0">
  77. <span style="margin-right:10px;" class="status danger">已下线</span>
  78. <el-button v-if="userIdentity===2 || proxyInfo!==null" type="primary" size="mini" @click="handleChangeStatus(row)">上线</el-button>
  79. </template>
  80. <template v-else>
  81. <span style="margin-right:10px;" class="status success ">已上线</span>
  82. <el-button v-if="userIdentity===2 || proxyInfo!==null" type="info" size="mini" plain @click="handleChangeStatus(row)">下线</el-button>
  83. </template>
  84. </template>
  85. <template v-else>
  86. <!-- <el-tag type="warning">待上线</el-tag> -->
  87. <span style="margin-right:10px;" class="status warning">待上线</span>
  88. </template>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="审核时间" width="240px" align="center">
  92. <template slot-scope="{row}">
  93. <span v-if="row.auditStatus!==2">{{ row.auditTime | formatTime }}</span>
  94. <span v-else>—</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="操作" width="240px" align="center">
  98. <template>
  99. <el-button type="primary" size="mini" style="margin-right:5px" icon="el-icon-edit" @click="$_navigationTo(`/doc/article-edit`)">编辑</el-button>
  100. <el-button type="danger" size="mini" style="margin-right:5px" icon="el-icon-s-check">删除</el-button>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <!-- 表格区域END -->
  105. </div>
  106. </template>
  107. <script>
  108. import Mock from 'mockjs'
  109. import { formatDate } from '@/utils'
  110. import { mapGetters } from 'vuex'
  111. export default {
  112. filters: {
  113. formatTime(time) {
  114. if (!time) {
  115. return ''
  116. }
  117. return formatDate(time, 'yyyy-MM-DD HH:mm:ss')
  118. }
  119. },
  120. data() {
  121. return {
  122. listLoading: false,
  123. listQuery: {
  124. pageNum: 0, // 页码
  125. pageSize: 20, // 分页大小
  126. articleTitle: '', // 供应商类型
  127. lowerAuditStatus: '', // 审核状态
  128. status: ''
  129. },
  130. list: [],
  131. srcList: []
  132. }
  133. },
  134. computed: {
  135. ...mapGetters(['authUserId', 'userIdentity', 'proxyInfo'])
  136. },
  137. created() {
  138. this.getList()
  139. },
  140. methods: {
  141. // 获取列表数据
  142. getList() {
  143. const count = 10
  144. const list = []
  145. for (let i = 0; i < count; i++) {
  146. list.push(Mock.mock({
  147. articleId: '@natural',
  148. articleTitle: '@ctitle(20,30)',
  149. articleCover: '@image("100x100")',
  150. auditStatus: '@natural(0,2)',
  151. auditTime: '@date("yy-MM-dd hh:mm:ss")',
  152. auditBy: '@cname(2,6)',
  153. status: '@natural(0,1)'
  154. }))
  155. }
  156. this.list = list
  157. this.initPreviewList(list)
  158. },
  159. // 初始化预览图片列表
  160. initPreviewList(list) {
  161. list.forEach(item => this.srcList.push(item.articleCover))
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. .filter-container {
  168. span {
  169. display: inline-block;
  170. margin-bottom: 10px;
  171. vertical-align: middle;
  172. font-size: 14px;
  173. }
  174. .el-button {
  175. display: inline-block;
  176. margin-bottom: 10px;
  177. vertical-align: middle;
  178. }
  179. .el-input,
  180. .el-select {
  181. margin-right: 10px;
  182. margin-left: 10px;
  183. }
  184. }
  185. .el-table .cell {
  186. overflow: visible;
  187. }
  188. .el-badge{
  189. margin: 0 6px;
  190. }
  191. </style>