123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <template>
- <div class="app-container">
- <div class="filter-container">
- <el-input v-model="listQuery.name" placeholder="直播间名称" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
- <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
- 搜索
- </el-button>
- </div>
- <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%">
- <el-table-column align="center" label="ID" width="80">
- <template slot-scope="scope">
- <span>{{ scope.row.id }}</span>
- </template>
- </el-table-column>
- <el-table-column width="180px" align="center" label="创建日期">
- <template slot-scope="scope">
- <span>{{ scope.row.create_time }}</span>
- </template>
- </el-table-column>
- <el-table-column class-name="status-col" align="center" label="直播间id">
- <template slot-scope="scope">
- <span>{{ scope.row.room_id }}</span>
- </template>
- </el-table-column>
- <el-table-column class-name="status-col" label="直播间名称" align="center" >
- <template slot-scope="scope">
- <span>{{ scope.row.name }}</span>
- </template>
- </el-table-column>
- <el-table-column class-name="status-col" label="开始时间" width="180px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.start_time }}</span>
- </template>
- </el-table-column>
- <el-table-column class-name="status-col" align="center" label="结束时间" width="180px">
- <template slot-scope="scope">
- <span>{{ scope.row.end_time }}</span>
- </template>
- </el-table-column>
- <!--<el-table-column class-name="status-col" label="主播昵称" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.anchor_name }}</span>
- </template>
- </el-table-column>-->
- <!--<el-table-column class-name="status-col" label="直播类型" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.type | typeFilter }}</span>
- </template>
- </el-table-column>-->
- <el-table-column class-name="status-col" label="状态" align="center">
- <template slot-scope="{row}">
- <el-tag type="success">
- {{ row | statusFilter }}
- </el-tag>
- </template>
- </el-table-column>
- <el-table-column align="center" label="Actions" width="300" class-name="small-padding fixed-width">
- <template slot-scope="scope">
- <el-row>
- <router-link :to="'/live/edit/'+scope.row.id">
- <el-button type="primary" size="mini" icon="el-icon-edit" style="margin-right: 10px;">
- 查看
- </el-button>
- </router-link>
- <router-link :to="'/live/chatList/'+scope.row.id">
- <el-button type="primary" size="mini" icon="el-icon-edit" style="margin-right: 10px;">
- 查看聊天记录
- </el-button>
- </router-link>
- <!-- <el-button type="primary" size="mini" icon="el-icon-s-check" :disabled="(scope.row.status === 1 || scope.row.status === 3)" @click="handleUpdate(scope)">-->
- <!-- {{ scope.row.status === 1 || scope.row.status === 3 ? '已处理' : '处理' }}-->
- <!-- </el-button>-->
- <!--<el-button type="danger" size="mini" icon="el-icon-delete" style="margin-left: 10px;" @click="handleDelete(scope)">
- 删除
- </el-button>-->
- </el-row>
- </template>
- </el-table-column>
- </el-table>
- <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize" @pagination="getList" />
- </div>
- </template>
- <script>
- import { fetchList } from '@/api/live'
- import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
- import waves from '@/directive/waves'
- export default {
- name: 'ArticleList',
- components: { Pagination },
- directives: { waves },
- filters: {
- statusFilter(row) {
- const startTimeData = new Date(row.start_time)
- const endTimeData = new Date(row.end_time)
- const now = new Date()
- if (now.getTime() > startTimeData.getTime() && now.getTime() < endTimeData.getTime()) {
- return '直播中'
- }
- if (now.getTime() > endTimeData.getTime()) {
- return '已结束'
- }
- if (now.getTime() < startTimeData.getTime()) {
- return '未开始'
- }
- },
- typeFilter(type) {
- const statusMap = {
- 1: '推流',
- 0: '手机直播'
- }
- return statusMap[type]
- }
- },
- data() {
- return {
- list: null,
- total: 0,
- listLoading: true,
- listQuery: {
- page: 1,
- pageSize: 10
- },
- temp: {
- id: undefined,
- mark: '',
- status: ''
- },
- dialogFormVisible: false
- }
- },
- created() {
- this.getList()
- },
- methods: {
- getList() {
- this.listLoading = true
- fetchList(this.listQuery).then(response => {
- this.list = response.data.list
- this.total = response.data.count
- this.listLoading = false
- })
- },
- handleFilter() {
- this.listLoading = true
- fetchList(this.listQuery).then(response => {
- this.list = response.data.list
- this.total = response.data.count
- this.listLoading = false
- })
- },
- async handleUpdate({ $index, row }) {
- this.temp = Object.assign({}, row) // copy obj
- this.dialogFormVisible = true
- this.$nextTick(() => {
- this.$refs['dataForm'].clearValidate()
- })
- }
- }
- }
- </script>
- <style scoped>
- .edit-input {
- padding-right: 100px;
- }
- .cancel-btn {
- position: absolute;
- right: 15px;
- top: 10px;
- }
- .filter-container{
- margin-bottom: 20px;
- }
- .filter-item {
- margin-right: 10px;
- }
- </style>
|