TabPane.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <el-table :data="list" border fit highlight-current-row style="width: 100%">
  3. <el-table-column
  4. v-loading="loading"
  5. align="center"
  6. label="ID"
  7. width="65"
  8. element-loading-text="请给我点时间!"
  9. >
  10. <template slot-scope="scope">
  11. <span>{{ scope.row.id }}</span>
  12. </template>
  13. </el-table-column>
  14. <el-table-column width="180px" align="center" label="Date">
  15. <template slot-scope="scope">
  16. <span>{{ scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
  17. </template>
  18. </el-table-column>
  19. <el-table-column min-width="300px" label="Title">
  20. <template slot-scope="{row}">
  21. <span>{{ row.title }}</span>
  22. <el-tag>{{ row.type }}</el-tag>
  23. </template>
  24. </el-table-column>
  25. <el-table-column width="110px" align="center" label="Author">
  26. <template slot-scope="scope">
  27. <span>{{ scope.row.author }}</span>
  28. </template>
  29. </el-table-column>
  30. <el-table-column width="120px" label="Importance">
  31. <template slot-scope="scope">
  32. <svg-icon v-for="n in +scope.row.importance" :key="n" icon-class="star" />
  33. </template>
  34. </el-table-column>
  35. <el-table-column align="center" label="Readings" width="95">
  36. <template slot-scope="scope">
  37. <span>{{ scope.row.pageviews }}</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column class-name="status-col" label="Status" width="110">
  41. <template slot-scope="{row}">
  42. <el-tag :type="row.status | statusFilter">
  43. {{ row.status }}
  44. </el-tag>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. </template>
  49. <script>
  50. import { fetchList } from '@/api/article'
  51. export default {
  52. filters: {
  53. statusFilter(status) {
  54. const statusMap = {
  55. published: 'success',
  56. draft: 'info',
  57. deleted: 'danger'
  58. }
  59. return statusMap[status]
  60. }
  61. },
  62. props: {
  63. type: {
  64. type: String,
  65. default: 'CN'
  66. }
  67. },
  68. data() {
  69. return {
  70. list: null,
  71. listQuery: {
  72. page: 1,
  73. limit: 5,
  74. type: this.type,
  75. sort: '+id'
  76. },
  77. loading: false
  78. }
  79. },
  80. created() {
  81. this.getList()
  82. },
  83. methods: {
  84. getList() {
  85. this.loading = true
  86. this.$emit('create') // for test
  87. fetchList(this.listQuery).then(response => {
  88. this.list = response.data.items
  89. this.loading = false
  90. })
  91. }
  92. }
  93. }
  94. </script>