index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索区域 -->
  4. <div class="filter-container">
  5. <div class="filter-control">
  6. <span>图片标题:</span>
  7. <el-input v-model="listQuery.imageTitle" placeholder="图片标题" @keyup.enter.native="getList" />
  8. </div>
  9. <div class="filter-control">
  10. <span>审核状态:</span>
  11. <el-select v-model="listQuery.auditStatus" placeholder="审核状态" clearable @change="getList">
  12. <el-option label="全部" value="" />
  13. <el-option label="待审核" :value="2" />
  14. <el-option label="审核通过" :value="1" />
  15. <el-option label="审核未通过" :value="0" />
  16. </el-select>
  17. </div>
  18. <div class="filter-control">
  19. <span>上线状态:</span>
  20. <el-select v-model="listQuery.status" placeholder="上线状态" clearable @change="getList">
  21. <el-option label="全部" value="" />
  22. <el-option label="已上线" :value="1" />
  23. <el-option label="待上线" :value="2" />
  24. <el-option label="未上线" :value="0" />
  25. </el-select>
  26. </div>
  27. <div class="filter-control">
  28. <permission-button type="primary" @click="getList">查询</permission-button>
  29. <permission-button type="primary" @click="$_navigationTo(`image-edit?type=add`)">添加图片</permission-button>
  30. </div>
  31. </div>
  32. <!-- 搜索区域END -->
  33. <!-- 表格区域 -->
  34. <el-table
  35. v-loading="listLoading"
  36. :data="list"
  37. style="width: 100%"
  38. border
  39. fit
  40. highlight-current-row
  41. cell-class-name="table-cell"
  42. header-row-class-name="tableHeader"
  43. >
  44. <el-table-column label="序号" :index="indexMethod" type="index" width="80" align="center" />
  45. <el-table-column label="图片标题" prop="imageTitle" align="center" />
  46. <el-table-column label="审核状态" width="180px" align="center">
  47. <template slot-scope="{ row }">
  48. <el-tag v-if="row.auditStatus === 2" size="small" type="warning">待审核</el-tag>
  49. <el-tag v-if="row.auditStatus === 1" size="small" type="success">审核通过</el-tag>
  50. <!-- 未通过原因展示 -->
  51. <template v-if="row.auditStatus === 0">
  52. <!-- <span class="status danger">审核未通过&nbsp;</span> -->
  53. <el-popover placement="top-start" title="审核说明" width="400" trigger="hover" :content="row.invalidReason">
  54. <el-tag slot="reference" size="small" type="danger" class="reason">
  55. <span>审核未通过</span>
  56. <span class="el-icon-question status danger" />
  57. </el-tag>
  58. </el-popover>
  59. <!-- 未通过原因展示END -->
  60. </template>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="上线状态" width="160px" align="center">
  64. <template slot-scope="{ row }">
  65. <!-- 只有审核通过了才能操作上下线 auditStatus :审核状态 -->
  66. <template v-if="row.auditStatus === 1">
  67. <template v-if="row.status === 0">
  68. <span style="margin-right: 10px" class="status danger">已下线</span>
  69. <permission-button type="primary" size="mini" @click="handleChangeStatus(row)">上线</permission-button>
  70. </template>
  71. <template v-else>
  72. <span style="margin-right: 10px" class="status success">已上线</span>
  73. <permission-button type="info" size="mini" plain @click="handleChangeStatus(row)">下线</permission-button>
  74. </template>
  75. </template>
  76. <template v-else>
  77. <!-- <el-tag type="warning">待上线</el-tag> -->
  78. <span style="margin-right: 10px" class="status warning">待上线</span>
  79. </template>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="创建时间" width="160px" align="center">
  83. <template slot-scope="{ row }">
  84. {{ row.createTime | formatTime }}
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="操作" width="180px" align="center">
  88. <template slot-scope="{ row }">
  89. <permission-button
  90. type="primary"
  91. size="mini"
  92. style="margin-right: 5px"
  93. @click="$_navigationTo(`image-edit?type=edit&imageId=${row.imageId}`)"
  94. >编辑</permission-button>
  95. <permission-button
  96. type="danger"
  97. size="mini"
  98. style="margin-right: 5px"
  99. @click="handleRemoveImage(row)"
  100. >删除</permission-button>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <pagination
  105. v-show="total > 0"
  106. :total="total"
  107. :page.sync="listQuery.pageNum"
  108. :limit.sync="listQuery.pageSize"
  109. @pagination="getList(listQuery)"
  110. />
  111. <!-- 表格区域END -->
  112. </div>
  113. </template>
  114. <script>
  115. import PermissionButton from '@/views/components/PermissionButton'
  116. import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  117. import { mapGetters } from 'vuex'
  118. import { changeImageStatus, getImageList, removeImage } from '@/api/doc'
  119. export default {
  120. components: { Pagination, PermissionButton },
  121. data() {
  122. return {
  123. listLoading: false,
  124. total: 0,
  125. listQuery: {
  126. authUserId: '', // 机构id
  127. auditStatus: '', // 审核状态
  128. imageTitle: '', // 文章标题
  129. listType: 1, // 列表类型:1文章列表,2文章审核列表
  130. pageNum: 1, // 页码
  131. pageSize: 10, // 分页大小
  132. status: '' // 文章状态:0已下线,1已上线,2待上线
  133. },
  134. list: []
  135. }
  136. },
  137. computed: {
  138. ...mapGetters(['authUserId', 'userIdentity'])
  139. },
  140. created() {
  141. this.getList()
  142. },
  143. methods: {
  144. // 获取列表数据
  145. getList() {
  146. this.listLoading = true
  147. this.listQuery.authUserId = this.authUserId
  148. getImageList(this.listQuery)
  149. .then((res) => {
  150. console.log(res)
  151. if (res.code !== 0) return
  152. this.list = res.data.list
  153. this.total = res.data.total
  154. })
  155. .finally(() => {
  156. this.listLoading = false
  157. })
  158. },
  159. // 删除图片
  160. async handleRemoveImage(row) {
  161. const text = await this.$confirm('确认删除该图片吗?', '提示', {
  162. confirmButtonText: '确定',
  163. cancelButtonText: '取消',
  164. type: 'warning'
  165. }).catch(() => {
  166. this.$message.info('已取消操作')
  167. })
  168. if (text !== 'confirm') return
  169. removeImage({ imageId: row.imageId }).then((res) => {
  170. if (res.code !== 0) return
  171. this.$message.success(res.data)
  172. this.getList(this.listQuery)
  173. })
  174. },
  175. // 状态改变
  176. handleChangeStatus(item) {
  177. this.listLoading = true
  178. // const params = {
  179. // authId: item.authId,
  180. // status: item.status ? 1 : 0
  181. // }
  182. console.log(item)
  183. const params = {
  184. imageId: item.imageId,
  185. status: item.status === 1 ? 0 : 1
  186. }
  187. changeImageStatus(params)
  188. .then((res) => {
  189. // this.$message.success(res.data)
  190. this.$message({
  191. message: res.data,
  192. duration: 500,
  193. type: 'success'
  194. })
  195. this.getList()
  196. })
  197. .catch((err) => {
  198. console.log(err)
  199. })
  200. .finally(() => {
  201. this.listLoading = false
  202. })
  203. },
  204. indexMethod(index) {
  205. return index + this.listQuery.pageSize * (this.listQuery.pageNum - 1) + 1
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. .el-table .cell {
  212. overflow: visible;
  213. }
  214. .el-badge {
  215. margin: 0 6px;
  216. }
  217. </style>