index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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.popularizeType=='ALL'? "全员" : "部分" }}
  108. </div>
  109. </template>
  110. </el-table-column>
  111. <el-table-column align="center" prop="popularize" label="是否推广">
  112. <template slot-scope="scope">
  113. <div>
  114. {{ scope.row.popularize == 1 ? "是" : "否" }}
  115. </div>
  116. </template>
  117. </el-table-column>
  118. <el-table-column align="center" prop="liveState" label="直播状态">
  119. <template slot-scope="scope">
  120. <div>
  121. {{ scope.row.liveState | liveState }}
  122. </div>
  123. </template>
  124. </el-table-column>
  125. <el-table-column
  126. align="center"
  127. prop="createdByName"
  128. label="创建人"
  129. ></el-table-column>
  130. <el-table-column align="center" prop="createdByName" label="预约人数">
  131. <template slot-scope="scope">
  132. <div>
  133. <auth auths="imLiveBroadcastRoom/query/roomUser">
  134. <el-button
  135. type="text"
  136. @click="lookReservationDetail(scope.row)"
  137. >
  138. {{ scope.row.roomReservationNum }}</el-button
  139. >
  140. </auth>
  141. </div>
  142. </template>
  143. </el-table-column>
  144. <el-table-column align="center" prop="studentId" label="操作">
  145. <template slot-scope="scope">
  146. <div>
  147. <el-dropdown trigger="click" placement="bottom" :hide-on-click="false">
  148. <span class="el-dropdown-link">
  149. 操作<i class="el-icon-arrow-down el-icon--right"></i>
  150. </span>
  151. <el-dropdown-menu slot="dropdown">
  152. <el-dropdown-item
  153. v-if="permission('/liveStudentList')&&scope.row.popularizeType!=='ALL'"
  154. @click.native="lookStudentDetail(scope.row)"
  155. >
  156. <el-button
  157. type="text"
  158. >观看学员</el-button
  159. >
  160. </el-dropdown-item>
  161. <el-dropdown-item
  162. v-if="
  163. permission('imLiveBroadcastRoom/opsPopularize') &&
  164. scope.row.liveState != 2
  165. "
  166. @click.native="popularizeRoom(scope.row)"
  167. >
  168. <el-button
  169. type="text"
  170. >{{
  171. scope.row.popularize == 1 ? "取消推广" : "首页推广"
  172. }}</el-button
  173. >
  174. </el-dropdown-item>
  175. <el-dropdown-item
  176. v-if="
  177. permission('imLiveBroadcastRoom/roomDestroy') &&
  178. scope.row.liveState == 1
  179. "
  180. @click.native="closeRoom(scope.row)"
  181. >
  182. <el-button type="text"
  183. >关闭直播</el-button
  184. >
  185. </el-dropdown-item>
  186. <el-dropdown-item v-if="scope.row.liveState == 2" @click.native="gotoDetail(scope.row)">
  187. <el-button type="text"
  188. >直播详情</el-button
  189. >
  190. </el-dropdown-item>
  191. <auth auths="/liveBlackList">
  192. <el-dropdown-item @click.native="gotoBuylist(scope.row)">
  193. <el-button type="text"
  194. >订单详情</el-button
  195. >
  196. </el-dropdown-item>
  197. </auth>
  198. <el-dropdown-item v-if="permission('liveGoodsMapper/page')" @click.native="setShop(scope.row)">
  199. <el-button type="text"
  200. >商品设置</el-button
  201. >
  202. </el-dropdown-item>
  203. <auth
  204. auths="imLiveBroadcastRoom/queryLiveRoomGoodsOrderList"
  205. >
  206. <el-dropdown-item @click.native="gotoBlacklist(scope.row)">
  207. <el-button type="text"
  208. >黑名单</el-button
  209. >
  210. </el-dropdown-item>
  211. </auth>
  212. <el-dropdown-item
  213. v-if="permission('imLiveBroadcastRoom/shareGroup')"
  214. @click.native="shareLive(scope.row)"
  215. >
  216. <el-button type="text"
  217. >分享</el-button
  218. >
  219. </el-dropdown-item>
  220. <el-dropdown-item
  221. v-if="
  222. permission('imLiveBroadcastRoom/update') &&
  223. scope.row.liveState == 0
  224. "
  225. >
  226. <el-button type="text" @click.native="resetLive(scope.row)"
  227. >修改</el-button
  228. >
  229. </el-dropdown-item>
  230. <auth
  231. auths="imLiveBroadcastRoom/delete"
  232. v-if="scope.row.liveState == 0"
  233. >
  234. <el-dropdown-item>
  235. <el-button type="text" @click.native="deteleLive(scope.row)"
  236. >删除</el-button
  237. >
  238. </el-dropdown-item>
  239. </auth>
  240. </el-dropdown-menu>
  241. </el-dropdown>
  242. <!-- <auth
  243. auths="imLiveBroadcastRoom/opsPopularize"
  244. v-if="scope.row.liveState != 2"
  245. >
  246. <el-button type="text" @click="popularizeRoom(scope.row)">{{
  247. scope.row.popularize == 1 ? "取消推广" : "首页推广"
  248. }}</el-button>
  249. </auth>
  250. <auth auths="imLiveBroadcastRoom/roomDestroy">
  251. <el-button
  252. type="text"
  253. v-if="scope.row.liveState == 1"
  254. @click="closeRoom(scope.row)"
  255. >关闭直播</el-button
  256. >
  257. </auth>
  258. <el-button
  259. type="text"
  260. v-if="scope.row.liveState == 2"
  261. @click="gotoDetail(scope.row)"
  262. >直播详情</el-button
  263. >
  264. <auth auths="liveGoodsMapper/page">
  265. <el-button type="text" @click="setShop(scope.row)"
  266. >商品设置</el-button
  267. >
  268. </auth>
  269. <auth auths="imLiveBroadcastRoom/shareGroup">
  270. <el-button type="text" @click="shareLive(scope.row)"
  271. >分享</el-button
  272. >
  273. </auth>
  274. <auth auths="imLiveBroadcastRoom/update">
  275. <el-button
  276. type="text"
  277. v-if="scope.row.liveState == 0"
  278. @click="resetLive(scope.row)"
  279. >修改</el-button
  280. >
  281. </auth>
  282. <auth auths="imLiveBroadcastRoom/delete">
  283. <el-button
  284. type="text"
  285. v-if="scope.row.liveState == 0"
  286. @click="deteleLive(scope.row)"
  287. >删除</el-button
  288. >
  289. </auth>
  290. <auth auths="imLiveBroadcastRoom/queryLiveRoomGoodsOrderList">
  291. <el-button type="text" @click="gotoBlacklist(scope.row)"
  292. >黑名单</el-button
  293. >
  294. </auth>
  295. <auth auths="/liveBlackList">
  296. <el-button type="text" @click="gotoBuylist(scope.row)"
  297. >订单详情</el-button
  298. >
  299. </auth> -->
  300. </div>
  301. </template>
  302. </el-table-column>
  303. </el-table>
  304. <pagination
  305. sync
  306. :total.sync="rules.total"
  307. :page.sync="rules.page"
  308. :limit.sync="rules.limit"
  309. :page-sizes="rules.page_size"
  310. @pagination="getList"
  311. />
  312. </div>
  313. </div>
  314. <el-dialog
  315. title="分享"
  316. width="510px"
  317. append-to-body
  318. :visible.sync="shareVisible"
  319. v-if="shareVisible"
  320. >
  321. <shareDetail @close="shareVisible = false" :row="activeRow" />
  322. </el-dialog>
  323. <popularizeRoom @getList="getList" ref="popularizeRoom" />
  324. <reservationDetail ref="reservationDetail" />
  325. <sellShopList ref="sellShopList" />
  326. </div>
  327. </template>
  328. <script>
  329. import axios from "axios";
  330. import { getToken } from "@/utils/auth";
  331. import { getTimes } from "@/utils";
  332. import pagination from "@/components/Pagination/index";
  333. import shareDetail from "./modals/shareDetail.vue";
  334. import load from "@/utils/loading";
  335. import popularizeRoom from "./modals/popularizeRoom.vue";
  336. import reservationDetail from "./modals/reservationDetail.vue";
  337. import sellShopList from "./modals/sellShopList";
  338. import { permission } from "@/utils/directivePage";
  339. import {
  340. getLiveBroadcastList,
  341. delLiveBroadcast,
  342. closeBroadcastRoomList,
  343. opsPopularize,
  344. } from "./api";
  345. export default {
  346. components: {
  347. pagination,
  348. shareDetail,
  349. popularizeRoom,
  350. reservationDetail,
  351. sellShopList,
  352. },
  353. data() {
  354. return {
  355. searchForm: {
  356. search: null,
  357. timer: [],
  358. liveState: null,
  359. popularize: null,
  360. },
  361. tableList: [],
  362. organList: [],
  363. rules: {
  364. // 分页规则
  365. limit: 10, // 限制显示条数
  366. page: 1, // 当前页
  367. total: 0, // 总条数
  368. page_size: [10, 20, 40, 50], // 选择限制显示条数
  369. },
  370. shareVisible: false,
  371. activeRow: null,
  372. };
  373. },
  374. //生命周期 - 创建完成(可以访问当前this实例)
  375. created() {},
  376. //生命周期 - 挂载完成(可以访问DOM元素)
  377. mounted() {
  378. // 获取分部
  379. this.init();
  380. },
  381. methods: {
  382. permission,
  383. init() {
  384. this.getList();
  385. },
  386. async getList() {
  387. const { timer, ...rest } = this.searchForm;
  388. try {
  389. const res = await getLiveBroadcastList({
  390. ...rest,
  391. ...getTimes(timer, ["startTime", "endTime"]),
  392. rows: this.rules.limit,
  393. page: this.rules.page,
  394. });
  395. this.tableList = res.data.rows;
  396. this.rules.total = res.data.total;
  397. } catch (e) {
  398. console.log(e);
  399. }
  400. },
  401. search() {
  402. this.rules.page = 1;
  403. this.getList();
  404. },
  405. onReSet() {
  406. this.$refs.searchForm.resetFields();
  407. this.search();
  408. },
  409. newLiveClass() {
  410. let params = {
  411. path: "/business/createLiveClass",
  412. };
  413. this.$router.push(params, (route) => {
  414. route.meta.title = "新建直播课";
  415. });
  416. this.$router.push("/business/createLiveClass");
  417. //liveClassDetail
  418. },
  419. gotoDetail(row) {
  420. this.$router.push({
  421. path: "/business/liveClassDetail",
  422. query: { roomUid: row.roomUid },
  423. });
  424. //
  425. },
  426. shareLive(row) {
  427. console.log('触发')
  428. this.activeRow = row;
  429. this.shareVisible = true;
  430. },
  431. resetLive(row) {
  432. let params = {
  433. path: "/business/createLiveClass",
  434. query: { ...row },
  435. };
  436. // query: { id:row.id,roomUid:row.roomUid},
  437. this.$router.push(params, (route) => {
  438. route.meta.title = "修改直播课";
  439. });
  440. },
  441. deteleLive(row) {
  442. this.$confirm("您确定删除该直播间", "提示", {
  443. confirmButtonText: "确定",
  444. cancelButtonText: "取消",
  445. type: "warning",
  446. })
  447. .then(async () => {
  448. try {
  449. const res = await delLiveBroadcast({ id: row.id });
  450. this.$message.success("删除成功");
  451. this.getList();
  452. } catch (e) {
  453. console.log(e);
  454. }
  455. })
  456. .catch(() => {});
  457. },
  458. closeRoom(row) {
  459. this.$confirm("您确定关闭直播间", "提示", {
  460. confirmButtonText: "确定",
  461. type: "warning",
  462. }).then(async (res) => {
  463. try {
  464. const res = await closeBroadcastRoomList(row.id);
  465. this.$message.success("关闭成功");
  466. this.getList();
  467. } catch (e) {}
  468. });
  469. },
  470. async popularizeRoom(row) {
  471. let popularize, str;
  472. if (row.popularize) {
  473. popularize = 0;
  474. str = "取消推广";
  475. } else {
  476. popularize = 1;
  477. str = "推广";
  478. // this.$refs.popularizeRoom.openDioag(row);
  479. }
  480. this.$confirm(`您是否${str}直播间"${row.roomTitle}"`, "提示", {
  481. confirmButtonText: "确定",
  482. cancelButtonText: "取消",
  483. type: "warning",
  484. })
  485. .then(async () => {
  486. try {
  487. const res = await opsPopularize({
  488. popularize,
  489. id: row.id,
  490. });
  491. this.$message.success(`${str}成功`);
  492. this.getList();
  493. } catch (e) {
  494. console.log(e);
  495. }
  496. })
  497. .catch(() => {});
  498. },
  499. setShop(row) {
  500. this.$router.push({
  501. path: "/business/liveShopControl",
  502. query: { roomUid: row.roomUid },
  503. });
  504. //
  505. },
  506. lookReservationDetail(row) {
  507. this.$refs.reservationDetail.openDioag(row);
  508. },
  509. gotoBlacklist(row) {
  510. this.$router.push({
  511. path: "/business/liveBlackList",
  512. query: { roomUid: row.roomUid, name: row.roomTitle },
  513. });
  514. },
  515. gotoBuylist(row) {
  516. this.$refs.sellShopList.openDioag(row);
  517. },
  518. lookStudentDetail(row) {
  519. this.$router.push({
  520. path: "/business/liveStudentList",
  521. query: { roomUid: row.roomUid,name:row.roomTitle },
  522. });
  523. },
  524. },
  525. };
  526. </script>
  527. <style lang='scss' scoped>
  528. /deep/.el-dropdown-link {
  529. cursor: pointer;
  530. color: var(--color-primary);
  531. }
  532. /deep/.el-icon-arrow-down {
  533. font-size: 12px;
  534. }
  535. </style>