index.vue 17 KB

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