list.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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="直播间id">
  21. <template slot-scope="scope">
  22. <span>{{ scope.row.room_id }}</span>
  23. </template>
  24. </el-table-column>
  25. <el-table-column class-name="status-col" label="直播间名称" align="center" >
  26. <template slot-scope="scope">
  27. <span>{{ scope.row.name }}</span>
  28. </template>
  29. </el-table-column>
  30. <el-table-column class-name="status-col" label="开始时间" width="180px" align="center">
  31. <template slot-scope="scope">
  32. <span>{{ scope.row.start_time }}</span>
  33. </template>
  34. </el-table-column>
  35. <el-table-column class-name="status-col" align="center" label="结束时间" width="180px">
  36. <template slot-scope="scope">
  37. <span>{{ scope.row.end_time }}</span>
  38. </template>
  39. </el-table-column>
  40. <!--<el-table-column class-name="status-col" label="主播昵称" align="center">
  41. <template slot-scope="scope">
  42. <span>{{ scope.row.anchor_name }}</span>
  43. </template>
  44. </el-table-column>-->
  45. <!--<el-table-column class-name="status-col" label="直播类型" align="center">
  46. <template slot-scope="scope">
  47. <span>{{ scope.row.type | typeFilter }}</span>
  48. </template>
  49. </el-table-column>-->
  50. <el-table-column class-name="status-col" label="状态" align="center">
  51. <template slot-scope="{row}">
  52. <el-tag type="success">
  53. {{ row | statusFilter }}
  54. </el-tag>
  55. </template>
  56. </el-table-column>
  57. <el-table-column align="center" label="Actions" width="300" class-name="small-padding fixed-width">
  58. <template slot-scope="scope">
  59. <el-row>
  60. <router-link :to="'/live/edit/'+scope.row.id">
  61. <el-button type="primary" size="mini" icon="el-icon-edit" style="margin-right: 10px;">
  62. 查看
  63. </el-button>
  64. </router-link>
  65. <router-link :to="'/live/chatList/'+scope.row.id">
  66. <el-button type="primary" size="mini" icon="el-icon-edit" style="margin-right: 10px;">
  67. 查看聊天记录
  68. </el-button>
  69. </router-link>
  70. <!-- <el-button type="primary" size="mini" icon="el-icon-s-check" :disabled="(scope.row.status === 1 || scope.row.status === 3)" @click="handleUpdate(scope)">-->
  71. <!-- {{ scope.row.status === 1 || scope.row.status === 3 ? '已处理' : '处理' }}-->
  72. <!-- </el-button>-->
  73. <!--<el-button type="danger" size="mini" icon="el-icon-delete" style="margin-left: 10px;" @click="handleDelete(scope)">
  74. 删除
  75. </el-button>-->
  76. </el-row>
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize" @pagination="getList" />
  81. </div>
  82. </template>
  83. <script>
  84. import { fetchList } from '@/api/live'
  85. import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
  86. import waves from '@/directive/waves'
  87. export default {
  88. name: 'ArticleList',
  89. components: { Pagination },
  90. directives: { waves },
  91. filters: {
  92. statusFilter(row) {
  93. const startTimeData = new Date(row.start_time)
  94. const endTimeData = new Date(row.end_time)
  95. const now = new Date()
  96. if (now.getTime() > startTimeData.getTime() && now.getTime() < endTimeData.getTime()) {
  97. return '直播中'
  98. }
  99. if (now.getTime() > endTimeData.getTime()) {
  100. return '已结束'
  101. }
  102. if (now.getTime() < startTimeData.getTime()) {
  103. return '未开始'
  104. }
  105. },
  106. typeFilter(type) {
  107. const statusMap = {
  108. 1: '推流',
  109. 0: '手机直播'
  110. }
  111. return statusMap[type]
  112. }
  113. },
  114. data() {
  115. return {
  116. list: null,
  117. total: 0,
  118. listLoading: true,
  119. listQuery: {
  120. page: 1,
  121. pageSize: 10
  122. },
  123. temp: {
  124. id: undefined,
  125. mark: '',
  126. status: ''
  127. },
  128. dialogFormVisible: false
  129. }
  130. },
  131. created() {
  132. this.getList()
  133. },
  134. methods: {
  135. getList() {
  136. this.listLoading = true
  137. fetchList(this.listQuery).then(response => {
  138. this.list = response.data.list
  139. this.total = response.data.count
  140. this.listLoading = false
  141. })
  142. },
  143. handleFilter() {
  144. this.listLoading = true
  145. fetchList(this.listQuery).then(response => {
  146. this.list = response.data.list
  147. this.total = response.data.count
  148. this.listLoading = false
  149. })
  150. },
  151. async handleUpdate({ $index, row }) {
  152. this.temp = Object.assign({}, row) // copy obj
  153. this.dialogFormVisible = true
  154. this.$nextTick(() => {
  155. this.$refs['dataForm'].clearValidate()
  156. })
  157. }
  158. }
  159. }
  160. </script>
  161. <style scoped>
  162. .edit-input {
  163. padding-right: 100px;
  164. }
  165. .cancel-btn {
  166. position: absolute;
  167. right: 15px;
  168. top: 10px;
  169. }
  170. .filter-container{
  171. margin-bottom: 20px;
  172. }
  173. .filter-item {
  174. margin-right: 10px;
  175. }
  176. </style>