Brak opisu

index.vue 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <div class="app-container">
  3. <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row>
  4. <el-table-column align="center" label='ID' width="95">
  5. <template slot-scope="scope">
  6. {{scope.$index}}
  7. </template>
  8. </el-table-column>
  9. <el-table-column label="Title">
  10. <template slot-scope="scope">
  11. {{scope.row.title}}
  12. </template>
  13. </el-table-column>
  14. <el-table-column label="Author" width="110" align="center">
  15. <template slot-scope="scope">
  16. <span>{{scope.row.author}}</span>
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="Pageviews" width="110" align="center">
  20. <template slot-scope="scope">
  21. {{scope.row.pageviews}}
  22. </template>
  23. </el-table-column>
  24. <el-table-column class-name="status-col" label="Status" width="110" align="center">
  25. <template slot-scope="scope">
  26. <el-tag :type="scope.row.status | statusFilter">{{scope.row.status}}</el-tag>
  27. </template>
  28. </el-table-column>
  29. <el-table-column align="center" prop="created_at" label="Display_time" width="200">
  30. <template slot-scope="scope">
  31. <i class="el-icon-time"></i>
  32. <span>{{scope.row.display_time}}</span>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. </div>
  37. </template>
  38. <script>
  39. import { getList } from '@/api/table'
  40. export default {
  41. data() {
  42. return {
  43. list: null,
  44. listLoading: true
  45. }
  46. },
  47. filters: {
  48. statusFilter(status) {
  49. const statusMap = {
  50. published: 'success',
  51. draft: 'gray',
  52. deleted: 'danger'
  53. }
  54. return statusMap[status]
  55. }
  56. },
  57. created() {
  58. this.fetchData()
  59. },
  60. methods: {
  61. fetchData() {
  62. this.listLoading = true
  63. getList(this.listQuery).then(response => {
  64. this.list = response.data.items
  65. this.listLoading = false
  66. })
  67. }
  68. }
  69. }
  70. </script>