465effae3be596b55e4533f9fcdee3dfc16ed5e2.svn-base 2.1 KB

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