index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="app-container">
  3. <el-card shadow="never" class="mb16 filter-card">
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="small">
  5. <el-form-item label="租户名称" prop="tenantId">
  6. <inline-tenant-selector :key="tenantSelectorKey" @change="handleTenantChange" />
  7. </el-form-item>
  8. <el-form-item label="直播标题" prop="liveTitle">
  9. <el-input
  10. v-model="queryParams.liveTitle"
  11. placeholder="请输入直播标题"
  12. clearable
  13. size="small"
  14. @keyup.enter.native="handleQuery"
  15. />
  16. </el-form-item>
  17. <el-form-item label="直播状态" prop="status">
  18. <el-select v-model="queryParams.status" placeholder="请选择直播状态" clearable size="small">
  19. <el-option
  20. v-for="item in statusOptions"
  21. :key="item.value"
  22. :label="item.label"
  23. :value="item.value">
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  29. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  30. </el-form-item>
  31. </el-form>
  32. </el-card>
  33. <el-row :gutter="10" class="mb8">
  34. <el-col :span="1.5">
  35. <el-button
  36. type="warning"
  37. plain
  38. icon="el-icon-download"
  39. size="mini"
  40. :loading="exportLoading"
  41. @click="handleExport"
  42. v-hasPermi="['admin:live:list']"
  43. >导出</el-button>
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-button
  47. type="info"
  48. plain
  49. icon="el-icon-bar-chart"
  50. size="mini"
  51. @click="showStatistics = true"
  52. >直播统计</el-button>
  53. </el-col>
  54. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  55. </el-row>
  56. <el-table border size="small" style="width:100%" v-loading="loading" :data="liveList">
  57. <el-table-column type="selection" width="55" align="center" />
  58. <el-table-column label="租户名称" align="center" prop="companyName" min-width="120" />
  59. <el-table-column label="直播标题" align="center" prop="liveTitle" min-width="150" show-overflow-tooltip />
  60. <el-table-column label="直播封面" align="center" prop="coverUrl" min-width="100">
  61. <template slot-scope="scope">
  62. <el-image
  63. v-if="scope.row.coverUrl"
  64. style="width: 80px; height: 60px"
  65. :src="scope.row.coverUrl"
  66. fit="contain" />
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="主播名称" align="center" prop="anchorName" min-width="90" />
  70. <el-table-column label="观看人数" align="center" prop="viewerCount" min-width="80" />
  71. <el-table-column label="开始时间" align="center" prop="startTime" min-width="150" />
  72. <el-table-column label="直播时长" align="center" prop="duration" min-width="90" />
  73. <el-table-column label="直播状态" align="center" prop="status" min-width="90">
  74. <template slot-scope="scope">
  75. <el-tag v-if="scope.row.status == 2" type="success">直播中</el-tag>
  76. <el-tag v-else-if="scope.row.status == 1" type="warning">待支付</el-tag>
  77. <el-tag v-else type="info">已结束</el-tag>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  81. <template slot-scope="scope">
  82. <el-button
  83. size="mini"
  84. type="text"
  85. icon="el-icon-search"
  86. plain
  87. @click="handleView(scope.row)"
  88. >详情</el-button>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <pagination
  93. v-show="total>0"
  94. :total="total"
  95. :page.sync="queryParams.pageNum"
  96. :limit.sync="queryParams.pageSize"
  97. @pagination="getList"
  98. />
  99. <!-- 详情弹窗 -->
  100. <el-dialog title="直播详情" :visible.sync="viewOpen" width="600px" append-to-body>
  101. <el-form :model="viewForm" label-width="100px">
  102. <el-form-item label="租户名称">
  103. <span>{{ viewForm.companyName }}</span>
  104. </el-form-item>
  105. <el-form-item label="直播标题">
  106. <span>{{ viewForm.liveTitle }}</span>
  107. </el-form-item>
  108. <el-form-item label="直播封面">
  109. <el-image v-if="viewForm.coverUrl" style="width: 120px; height: 90px" :src="viewForm.coverUrl" fit="contain" />
  110. </el-form-item>
  111. <el-form-item label="主播名称">
  112. <span>{{ viewForm.anchorName }}</span>
  113. </el-form-item>
  114. <el-form-item label="观看人数">
  115. <span>{{ viewForm.viewerCount }}</span>
  116. </el-form-item>
  117. <el-form-item label="开始时间">
  118. <span>{{ viewForm.startTime }}</span>
  119. </el-form-item>
  120. <el-form-item label="直播时长">
  121. <span>{{ viewForm.duration }}</span>
  122. </el-form-item>
  123. <el-form-item label="直播状态">
  124. <el-tag v-if="viewForm.status == 2" type="success">直播中</el-tag>
  125. <el-tag v-else-if="viewForm.status == 1" type="warning">待支付</el-tag>
  126. <el-tag v-else type="info">已结束</el-tag>
  127. </el-form-item>
  128. </el-form>
  129. </el-dialog>
  130. <!-- 统计弹窗 -->
  131. <el-dialog title="直播统计" :visible.sync="showStatistics" width="600px" append-to-body>
  132. <el-card>
  133. <el-row :gutter="20">
  134. <el-col :span="12">
  135. <div class="stat-item">
  136. <span class="stat-value">{{ statistics.totalCount }}</span>
  137. <span class="stat-label">直播总数</span>
  138. </div>
  139. </el-col>
  140. <el-col :span="12">
  141. <div class="stat-item">
  142. <span class="stat-value">{{ statistics.totalViewerCount }}</span>
  143. <span class="stat-label">总观看人数</span>
  144. </div>
  145. </el-col>
  146. <el-col :span="12">
  147. <div class="stat-item">
  148. <span class="stat-value">{{ statistics.livingCount }}</span>
  149. <span class="stat-label">直播中</span>
  150. </div>
  151. </el-col>
  152. <el-col :span="12">
  153. <div class="stat-item">
  154. <span class="stat-value">{{ statistics.endedCount }}</span>
  155. <span class="stat-label">已结束</span>
  156. </div>
  157. </el-col>
  158. </el-row>
  159. </el-card>
  160. </el-dialog>
  161. </div>
  162. </template>
  163. <script>
  164. import { listAllLives, getLiveInfo, getLiveStatistics, exportAllLives } from '@/api/admin/live'
  165. import InlineTenantSelector from '@/components/InlineTenantSelector'
  166. export default {
  167. name: 'LiveAdmin',
  168. components: { InlineTenantSelector },
  169. data() {
  170. return {
  171. loading: false,
  172. exportLoading: false,
  173. showSearch: true,
  174. total: 0,
  175. liveList: [],
  176. statistics: {
  177. totalCount: 0,
  178. totalViewerCount: 0,
  179. livingCount: 0,
  180. endedCount: 0
  181. },
  182. statusOptions: [
  183. { value: 1, label: '待支付' },
  184. { value: 2, label: '直播中' },
  185. { value: 3, label: '已结束' }
  186. ],
  187. queryParams: {
  188. pageNum: 1,
  189. pageSize: 10,
  190. tenantId: null,
  191. liveTitle: null,
  192. status: null
  193. },
  194. viewOpen: false,
  195. viewForm: {},
  196. showStatistics: false,
  197. tenantSelectorKey: 0
  198. }
  199. },
  200. methods: {
  201. getList() {
  202. if (!this.queryParams.tenantId) {
  203. this.liveList = []
  204. this.total = 0
  205. this.loading = false
  206. return
  207. }
  208. this.loading = true
  209. listAllLives(this.queryParams).then(response => {
  210. this.liveList = response.rows
  211. this.total = response.total
  212. this.loading = false
  213. })
  214. },
  215. handleTenantChange(val) {
  216. this.queryParams.tenantId = val || null
  217. if (val) {
  218. this.handleQuery()
  219. }
  220. },
  221. handleQuery() {
  222. if (!this.queryParams.tenantId) {
  223. this.$message.warning('请先选择租户')
  224. return
  225. }
  226. this.queryParams.pageNum = 1
  227. this.getList()
  228. },
  229. resetQuery() {
  230. this.$store.dispatch('tenant/setTenantId', null)
  231. this.resetForm('queryForm')
  232. this.queryParams.tenantId = null
  233. this.liveList = []
  234. this.total = 0
  235. this.tenantSelectorKey++
  236. },
  237. handleView(row) {
  238. getLiveInfo(row.liveId).then(response => {
  239. this.viewForm = response.data
  240. this.viewOpen = true
  241. })
  242. },
  243. showStatisticsDialog() {
  244. getLiveStatistics().then(response => {
  245. this.statistics = response.data
  246. this.showStatistics = true
  247. })
  248. },
  249. handleExport() {
  250. this.exportLoading = true
  251. exportAllLives(this.queryParams).then(response => {
  252. this.download(response.msg)
  253. this.exportLoading = false
  254. }).catch(() => { this.exportLoading = false })
  255. }
  256. }
  257. }
  258. </script>
  259. <style scoped>
  260. .stat-item {
  261. text-align: center;
  262. padding: 20px;
  263. background: #f5f7fa;
  264. border-radius: 8px;
  265. }
  266. .stat-value {
  267. font-size: 24px;
  268. font-weight: bold;
  269. color: #1890ff;
  270. }
  271. .stat-label {
  272. display: block;
  273. margin-top: 5px;
  274. font-size: 14px;
  275. color: #666;
  276. }
  277. .mb16 { margin-bottom: 16px; }
  278. .filter-card { padding-bottom: 0; }
  279. </style>