list.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div class="app-container">
  3. <!-- <div class="filter-container">-->
  4. <!-- <el-input v-model="listQuery.name" placeholder="直播间名称" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />-->
  5. <!-- <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">-->
  6. <!-- 搜索-->
  7. <!-- </el-button>-->
  8. <!-- </div>-->
  9. <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%">
  10. <el-table-column align="center" label="ID" width="80">
  11. <template slot-scope="scope">
  12. <span>{{ scope.row.id }}</span>
  13. </template>
  14. </el-table-column>
  15. <el-table-column width="180px" align="center" label="创建日期">
  16. <template slot-scope="scope">
  17. <span>{{ scope.row.create_time }}</span>
  18. </template>
  19. </el-table-column>
  20. <el-table-column class-name="status-col" align="center" label="简介">
  21. <template slot-scope="scope">
  22. <span>{{ scope.row.desc }}</span>
  23. </template>
  24. </el-table-column>
  25. <el-table-column align="center" label="Actions" width="350" class-name="small-padding fixed-width">
  26. <template slot-scope="scope">
  27. <el-row>
  28. <router-link :to="'/live/edit/'+scope.row.id">
  29. <el-button type="primary" size="mini" icon="el-icon-edit" style="margin-right: 10px;">
  30. 查看
  31. </el-button>
  32. </router-link>
  33. <!--<el-button type="primary" size="mini" icon="el-icon-s-check" :disabled="(scope.row.status === 1 || scope.row.status === 3)" @click="handleUpdate(scope)">
  34. {{ scope.row.status === 1 || scope.row.status === 3 ? '已处理' : '处理' }}
  35. </el-button>-->
  36. <!-- <el-button type="danger" size="mini" icon="el-icon-delete" style="" @click="handleDelete(scope)">-->
  37. <!-- 删除-->
  38. <!-- </el-button>-->
  39. </el-row>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize" @pagination="getList" />
  44. </div>
  45. </template>
  46. <script>
  47. import { fetchList, deleteLive } from '@/api/live'
  48. import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
  49. import waves from '@/directive/waves'
  50. export default {
  51. name: 'ArticleList',
  52. components: { Pagination },
  53. directives: { waves },
  54. filters: {
  55. statusFilter(row) {
  56. const startTimeData = new Date(row.start_time)
  57. const endTimeData = new Date(row.end_time)
  58. const now = new Date()
  59. if (now.getTime() > startTimeData.getTime() && now.getTime() < endTimeData.getTime()) {
  60. return '直播中'
  61. }
  62. if (now.getTime() > endTimeData.getTime()) {
  63. return '已结束'
  64. }
  65. if (now.getTime() < startTimeData.getTime()) {
  66. return '未开始'
  67. }
  68. },
  69. typeFilter(type) {
  70. const statusMap = {
  71. 1: '推流',
  72. 0: '手机直播'
  73. }
  74. return statusMap[type]
  75. }
  76. },
  77. data() {
  78. return {
  79. list: null,
  80. total: 0,
  81. listLoading: true,
  82. listQuery: {
  83. page: 1,
  84. pageSize: 10
  85. },
  86. temp: {
  87. id: undefined,
  88. mark: '',
  89. status: ''
  90. },
  91. dialogFormVisible: false
  92. }
  93. },
  94. created() {
  95. this.getList()
  96. },
  97. methods: {
  98. getList() {
  99. this.listLoading = true
  100. fetchList(this.listQuery).then(response => {
  101. this.list = response.data.list
  102. this.total = response.data.count
  103. this.listLoading = false
  104. })
  105. },
  106. handleFilter() {
  107. this.listLoading = true
  108. fetchList(this.listQuery).then(response => {
  109. this.list = response.data.list
  110. this.total = response.data.count
  111. this.listLoading = false
  112. })
  113. },
  114. async handleUpdate({ $index, row }) {
  115. this.temp = Object.assign({}, row) // copy obj
  116. this.dialogFormVisible = true
  117. this.$nextTick(() => {
  118. this.$refs['dataForm'].clearValidate()
  119. })
  120. },
  121. handleDelete({ $index, row }) {
  122. console.log(row.id)
  123. this.$confirm('您确定要删除吗', '警告', {
  124. confirmButtonText: '是的',
  125. cancelButtonText: '取消',
  126. type: 'warning'
  127. })
  128. .then(async() => {
  129. await deleteLive(row.id)
  130. this.list.splice($index, 1)
  131. this.$message({
  132. type: 'success',
  133. message: '删除成功'
  134. })
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style scoped>
  141. .edit-input {
  142. padding-right: 100px;
  143. }
  144. .cancel-btn {
  145. position: absolute;
  146. right: 15px;
  147. top: 10px;
  148. }
  149. .filter-container{
  150. margin-bottom: 20px;
  151. }
  152. .filter-item {
  153. margin-right: 10px;
  154. }
  155. </style>