| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <template>
- <div class="app-container">
- <el-card shadow="never" class="mb16 filter-card">
- <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="small">
- <el-form-item label="租户名称" prop="tenantId">
- <inline-tenant-selector :key="tenantSelectorKey" @change="handleTenantChange" />
- </el-form-item>
- <el-form-item label="直播标题" prop="liveTitle">
- <el-input
- v-model="queryParams.liveTitle"
- placeholder="请输入直播标题"
- clearable
- size="small"
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="直播状态" prop="status">
- <el-select v-model="queryParams.status" placeholder="请选择直播状态" clearable size="small">
- <el-option
- v-for="item in statusOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
- </el-form-item>
- </el-form>
- </el-card>
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button
- type="warning"
- plain
- icon="el-icon-download"
- size="mini"
- :loading="exportLoading"
- @click="handleExport"
- v-hasPermi="['admin:live:list']"
- >导出</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="info"
- plain
- icon="el-icon-bar-chart"
- size="mini"
- @click="showStatistics = true"
- >直播统计</el-button>
- </el-col>
- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
- </el-row>
- <el-table border size="small" style="width:100%" v-loading="loading" :data="liveList">
- <el-table-column type="selection" width="55" align="center" />
- <el-table-column label="租户名称" align="center" prop="companyName" min-width="120" />
- <el-table-column label="直播标题" align="center" prop="liveTitle" min-width="150" show-overflow-tooltip />
- <el-table-column label="直播封面" align="center" prop="coverUrl" min-width="100">
- <template slot-scope="scope">
- <el-image
- v-if="scope.row.coverUrl"
- style="width: 80px; height: 60px"
- :src="scope.row.coverUrl"
- fit="contain" />
- </template>
- </el-table-column>
- <el-table-column label="主播名称" align="center" prop="anchorName" min-width="90" />
- <el-table-column label="观看人数" align="center" prop="viewerCount" min-width="80" />
- <el-table-column label="开始时间" align="center" prop="startTime" min-width="150" />
- <el-table-column label="直播时长" align="center" prop="duration" min-width="90" />
- <el-table-column label="直播状态" align="center" prop="status" min-width="90">
- <template slot-scope="scope">
- <el-tag v-if="scope.row.status == 2" type="success">直播中</el-tag>
- <el-tag v-else-if="scope.row.status == 1" type="warning">待支付</el-tag>
- <el-tag v-else type="info">已结束</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
- <template slot-scope="scope">
- <el-button
- size="mini"
- type="text"
- icon="el-icon-search"
- plain
- @click="handleView(scope.row)"
- >详情</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total>0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- <!-- 详情弹窗 -->
- <el-dialog title="直播详情" :visible.sync="viewOpen" width="600px" append-to-body>
- <el-form :model="viewForm" label-width="100px">
- <el-form-item label="租户名称">
- <span>{{ viewForm.companyName }}</span>
- </el-form-item>
- <el-form-item label="直播标题">
- <span>{{ viewForm.liveTitle }}</span>
- </el-form-item>
- <el-form-item label="直播封面">
- <el-image v-if="viewForm.coverUrl" style="width: 120px; height: 90px" :src="viewForm.coverUrl" fit="contain" />
- </el-form-item>
- <el-form-item label="主播名称">
- <span>{{ viewForm.anchorName }}</span>
- </el-form-item>
- <el-form-item label="观看人数">
- <span>{{ viewForm.viewerCount }}</span>
- </el-form-item>
- <el-form-item label="开始时间">
- <span>{{ viewForm.startTime }}</span>
- </el-form-item>
- <el-form-item label="直播时长">
- <span>{{ viewForm.duration }}</span>
- </el-form-item>
- <el-form-item label="直播状态">
- <el-tag v-if="viewForm.status == 2" type="success">直播中</el-tag>
- <el-tag v-else-if="viewForm.status == 1" type="warning">待支付</el-tag>
- <el-tag v-else type="info">已结束</el-tag>
- </el-form-item>
- </el-form>
- </el-dialog>
- <!-- 统计弹窗 -->
- <el-dialog title="直播统计" :visible.sync="showStatistics" width="600px" append-to-body>
- <el-card>
- <el-row :gutter="20">
- <el-col :span="12">
- <div class="stat-item">
- <span class="stat-value">{{ statistics.totalCount }}</span>
- <span class="stat-label">直播总数</span>
- </div>
- </el-col>
- <el-col :span="12">
- <div class="stat-item">
- <span class="stat-value">{{ statistics.totalViewerCount }}</span>
- <span class="stat-label">总观看人数</span>
- </div>
- </el-col>
- <el-col :span="12">
- <div class="stat-item">
- <span class="stat-value">{{ statistics.livingCount }}</span>
- <span class="stat-label">直播中</span>
- </div>
- </el-col>
- <el-col :span="12">
- <div class="stat-item">
- <span class="stat-value">{{ statistics.endedCount }}</span>
- <span class="stat-label">已结束</span>
- </div>
- </el-col>
- </el-row>
- </el-card>
- </el-dialog>
- </div>
- </template>
- <script>
- import { listAllLives, getLiveInfo, getLiveStatistics, exportAllLives } from '@/api/admin/live'
- import InlineTenantSelector from '@/components/InlineTenantSelector'
- export default {
- name: 'LiveAdmin',
- components: { InlineTenantSelector },
- data() {
- return {
- loading: false,
- exportLoading: false,
- showSearch: true,
- total: 0,
- liveList: [],
- statistics: {
- totalCount: 0,
- totalViewerCount: 0,
- livingCount: 0,
- endedCount: 0
- },
- statusOptions: [
- { value: 1, label: '待支付' },
- { value: 2, label: '直播中' },
- { value: 3, label: '已结束' }
- ],
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- tenantId: null,
- liveTitle: null,
- status: null
- },
- viewOpen: false,
- viewForm: {},
- showStatistics: false,
- tenantSelectorKey: 0
- }
- },
- methods: {
- getList() {
- if (!this.queryParams.tenantId) {
- this.liveList = []
- this.total = 0
- this.loading = false
- return
- }
- this.loading = true
- listAllLives(this.queryParams).then(response => {
- this.liveList = response.rows
- this.total = response.total
- this.loading = false
- })
- },
- handleTenantChange(val) {
- this.queryParams.tenantId = val || null
- if (val) {
- this.handleQuery()
- }
- },
- handleQuery() {
- if (!this.queryParams.tenantId) {
- this.$message.warning('请先选择租户')
- return
- }
- this.queryParams.pageNum = 1
- this.getList()
- },
- resetQuery() {
- this.$store.dispatch('tenant/setTenantId', null)
- this.resetForm('queryForm')
- this.queryParams.tenantId = null
- this.liveList = []
- this.total = 0
- this.tenantSelectorKey++
- },
- handleView(row) {
- getLiveInfo(row.liveId).then(response => {
- this.viewForm = response.data
- this.viewOpen = true
- })
- },
- showStatisticsDialog() {
- getLiveStatistics().then(response => {
- this.statistics = response.data
- this.showStatistics = true
- })
- },
- handleExport() {
- this.exportLoading = true
- exportAllLives(this.queryParams).then(response => {
- this.download(response.msg)
- this.exportLoading = false
- }).catch(() => { this.exportLoading = false })
- }
- }
- }
- </script>
- <style scoped>
- .stat-item {
- text-align: center;
- padding: 20px;
- background: #f5f7fa;
- border-radius: 8px;
- }
- .stat-value {
- font-size: 24px;
- font-weight: bold;
- color: #1890ff;
- }
- .stat-label {
- display: block;
- margin-top: 5px;
- font-size: 14px;
- color: #666;
- }
- .mb16 { margin-bottom: 16px; }
- .filter-card { padding-bottom: 0; }
- </style>
|