index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 直播课管理
  7. </h2>
  8. <div class="m-core">
  9. <auth auths="imLiveBroadcastRoom/add">
  10. <el-button
  11. @click="newLiveClass"
  12. type="primary"
  13. style="margin-bottom: 20px"
  14. >新建直播课</el-button
  15. >
  16. </auth>
  17. <save-form
  18. :inline="true"
  19. :model="searchForm"
  20. @submit="search"
  21. @reset="onReSet"
  22. ref="searchForm"
  23. >
  24. <el-form-item prop="search">
  25. <el-input
  26. v-model.trim="searchForm.search"
  27. clearable
  28. @keyup.enter.native="search"
  29. placeholder="直播间编号/标题"
  30. ></el-input>
  31. </el-form-item>
  32. <el-form-item prop="popularize">
  33. <el-select
  34. placeholder="是否推广"
  35. v-model="searchForm.popularize"
  36. clearable
  37. >
  38. <el-option label="否" value="0"></el-option>
  39. <el-option label="是" value="1"></el-option>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item prop="liveState">
  43. <el-select
  44. placeholder="直播状态"
  45. v-model="searchForm.liveState"
  46. clearable
  47. >
  48. <el-option label="未开始" value="0"></el-option>
  49. <el-option label="直播中" value="1"></el-option>
  50. <el-option label="已结束" value="2"></el-option>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item prop="timer">
  54. <el-date-picker
  55. v-model.trim="searchForm.timer"
  56. type="daterange"
  57. value-format="yyyy-MM-dd"
  58. range-separator="至"
  59. start-placeholder="直播开始日期"
  60. end-placeholder="直播结束日期"
  61. :picker-options="{
  62. firstDayOfWeek: 1,
  63. }"
  64. >
  65. </el-date-picker>
  66. </el-form-item>
  67. <el-form-item>
  68. <el-button native-type="submit" type="primary">搜索</el-button>
  69. <el-button native-type="reset" type="danger">重置</el-button>
  70. </el-form-item>
  71. </save-form>
  72. <div class="tableWrap">
  73. <el-table
  74. style="width: 100%"
  75. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  76. :data="tableList"
  77. >
  78. <el-table-column
  79. align="center"
  80. prop="id"
  81. label="直播间编号"
  82. ></el-table-column>
  83. <el-table-column
  84. align="center"
  85. prop="roomTitle"
  86. label="直播课标题"
  87. ></el-table-column>
  88. <el-table-column
  89. align="center"
  90. prop="speakerName"
  91. label="主讲人"
  92. ></el-table-column>
  93. <el-table-column
  94. align="center"
  95. prop="liveStartTime"
  96. label="直播开始时间"
  97. >
  98. <template slot-scope="scope">
  99. <div>
  100. {{ scope.row.liveStartTime | dateForMinFormat }}
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column align="center" prop="popularize" label="是否推广">
  105. <template slot-scope="scope">
  106. <div>
  107. {{ scope.row.popularize == 1 ? "是" : "否" }}
  108. </div>
  109. </template>
  110. </el-table-column>
  111. <el-table-column align="center" prop="liveState" label="直播状态">
  112. <template slot-scope="scope">
  113. <div>
  114. {{ scope.row.liveState | liveState }}
  115. </div>
  116. </template>
  117. </el-table-column>
  118. <el-table-column
  119. align="center"
  120. prop="createdByName"
  121. label="创建人"
  122. ></el-table-column>
  123. <el-table-column align="center" prop="studentId" label="操作">
  124. <template slot-scope="scope">
  125. <div>
  126. <auth auths="imLiveBroadcastRoom/opsPopularize" v-if="scope.row.liveState != 2">
  127. <el-button type="text" @click="popularizeRoom(scope.row)">{{
  128. scope.row.popularize == 1 ? "取消推广" : "首页推广"
  129. }}</el-button>
  130. </auth>
  131. <auth auths="imLiveBroadcastRoom/roomDestroy">
  132. <el-button
  133. type="text"
  134. v-if="scope.row.liveState == 1"
  135. @click="closeRoom(scope.row)"
  136. >关闭直播</el-button
  137. >
  138. </auth>
  139. <el-button
  140. type="text"
  141. v-if="scope.row.liveState == 2"
  142. @click="gotoDetail(scope.row)"
  143. >直播详情</el-button
  144. >
  145. <auth auths="imLiveBroadcastRoom/shareGroup">
  146. <el-button type="text" @click="shareLive(scope.row)"
  147. >分享</el-button
  148. >
  149. </auth>
  150. <auth auths="imLiveBroadcastRoom/update">
  151. <el-button
  152. type="text"
  153. v-if="scope.row.liveState == 0"
  154. @click="resetLive(scope.row)"
  155. >修改</el-button
  156. >
  157. </auth>
  158. <auth auths="imLiveBroadcastRoom/delete">
  159. <el-button
  160. type="text"
  161. v-if="scope.row.liveState == 0"
  162. @click="deteleLive(scope.row)"
  163. >删除</el-button
  164. >
  165. </auth>
  166. </div>
  167. </template>
  168. </el-table-column>
  169. </el-table>
  170. <pagination
  171. sync
  172. :total.sync="rules.total"
  173. :page.sync="rules.page"
  174. :limit.sync="rules.limit"
  175. :page-sizes="rules.page_size"
  176. @pagination="getList"
  177. />
  178. </div>
  179. </div>
  180. <el-dialog
  181. title="分享"
  182. width="510px"
  183. append-to-body
  184. :visible.sync="shareVisible"
  185. v-if="shareVisible"
  186. >
  187. <shareDetail @close="shareVisible = false" :row="activeRow" />
  188. </el-dialog>
  189. </div>
  190. </template>
  191. <script>
  192. import axios from "axios";
  193. import { getToken } from "@/utils/auth";
  194. import { getTimes } from "@/utils";
  195. import pagination from "@/components/Pagination/index";
  196. import shareDetail from "./modals/shareDetail.vue";
  197. import load from "@/utils/loading";
  198. import {
  199. getLiveBroadcastList,
  200. delLiveBroadcast,
  201. closeBroadcastRoomList,
  202. opsPopularize,
  203. } from "./api";
  204. export default {
  205. components: { pagination, shareDetail },
  206. data() {
  207. return {
  208. searchForm: {
  209. search: null,
  210. timer: [],
  211. liveState: null,
  212. popularize: null,
  213. },
  214. tableList: [],
  215. organList: [],
  216. rules: {
  217. // 分页规则
  218. limit: 10, // 限制显示条数
  219. page: 1, // 当前页
  220. total: 0, // 总条数
  221. page_size: [10, 20, 40, 50], // 选择限制显示条数
  222. },
  223. shareVisible: false,
  224. activeRow: null,
  225. };
  226. },
  227. //生命周期 - 创建完成(可以访问当前this实例)
  228. created() {},
  229. //生命周期 - 挂载完成(可以访问DOM元素)
  230. mounted() {
  231. // 获取分部
  232. this.init();
  233. },
  234. methods: {
  235. init() {
  236. this.getList();
  237. },
  238. async getList() {
  239. const { timer, ...rest } = this.searchForm;
  240. try {
  241. const res = await getLiveBroadcastList({
  242. ...rest,
  243. ...getTimes(timer, ["startTime", "endTime"]),
  244. rows: this.rules.limit,
  245. page: this.rules.page,
  246. });
  247. this.tableList = res.data.rows;
  248. this.rules.total = res.data.total;
  249. } catch (e) {
  250. console.log(e);
  251. }
  252. },
  253. search() {
  254. this.rules.page = 1;
  255. this.getList();
  256. },
  257. onReSet() {
  258. this.$refs.searchForm.resetFields();
  259. this.search();
  260. },
  261. newLiveClass() {
  262. let params = {
  263. path: "/business/createLiveClass",
  264. };
  265. this.$router.push(params, (route) => {
  266. route.meta.title = "新建直播课";
  267. });
  268. this.$router.push("/business/createLiveClass");
  269. //liveClassDetail
  270. },
  271. gotoDetail(row) {
  272. this.$router.push({
  273. path: "/business/liveClassDetail",
  274. query: { roomUid: row.roomUid },
  275. });
  276. },
  277. shareLive(row) {
  278. this.activeRow = row;
  279. this.shareVisible = true;
  280. },
  281. resetLive(row) {
  282. let params = {
  283. path: "/business/createLiveClass",
  284. query: { ...row },
  285. };
  286. this.$router.push(params, (route) => {
  287. route.meta.title = "修改直播课";
  288. });
  289. },
  290. deteleLive(row) {
  291. this.$confirm("您确定删除该直播间", "提示", {
  292. confirmButtonText: "确定",
  293. cancelButtonText: "取消",
  294. type: "warning",
  295. })
  296. .then(async () => {
  297. try {
  298. const res = await delLiveBroadcast({ id: row.id });
  299. this.$message.success("删除成功");
  300. this.getList();
  301. } catch (e) {
  302. console.log(e);
  303. }
  304. })
  305. .catch(() => {});
  306. },
  307. closeRoom(row) {
  308. this.$confirm("您确定关闭直播间", "提示", {
  309. confirmButtonText: "确定",
  310. type: "warning",
  311. }).then(async (res) => {
  312. try {
  313. const res = await closeBroadcastRoomList(row.id);
  314. this.$message.success("关闭成功");
  315. this.getList();
  316. } catch (e) {}
  317. });
  318. },
  319. async popularizeRoom(row) {
  320. let popularize,str;
  321. if (row.popularize) {
  322. popularize = 0;
  323. str='取消推广'
  324. } else {
  325. popularize = 1;
  326. str='推广'
  327. }
  328. this.$confirm(`您是否${str}直播间"${row.roomTitle}"`, "提示", {
  329. confirmButtonText: "确定",
  330. cancelButtonText: "取消",
  331. type: "warning",
  332. })
  333. .then(async () => {
  334. try {
  335. const res = await opsPopularize({
  336. popularize,
  337. id: row.id,
  338. });
  339. this.$message.success(`${str}成功`);
  340. this.getList();
  341. } catch (e) {
  342. console.log(e);
  343. }
  344. })
  345. .catch(() => {});
  346. },
  347. },
  348. };
  349. </script>
  350. <style lang='scss' scoped>
  351. </style>