index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <div class="filter-container-lt">
  5. <el-input placeholder="视频标题" class="filter-item" style="width: 200px;" clearable
  6. v-model="listQuery.videoTitle" />
  7. <!-- <el-input placeholder="SKU" class="filter-item" style="width: 200px;" clearable v-model="listQuery.sku" /> -->
  8. <el-button v-waves class="filter-btn" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
  9. </div>
  10. <!-- <div class="filter-container-rt">
  11. <excel-import :upload-url="'/api/upload-excel'" :headers="{ token: 'your-token' }"
  12. :upload-data="{ type: 'import' }" @on-success="handleImportSuccess">
  13. <template slot="upload-text">
  14. 导入话题
  15. </template>
  16. </excel-import>
  17. </div> -->
  18. </div>
  19. <div class="table-container">
  20. <el-table height="80vh" style="width: 100%" v-loading="listLoading" :key="tableKey" :data="list" row-key="id" stripe border fit
  21. highlight-current-row>
  22. <el-table-column label="序号" type="index" width="60" align="center" />
  23. <el-table-column label="视频ID" min-width="100" align="center" prop="id" />
  24. <el-table-column label="视频标题" min-width="150" align="center" prop="videoTitle" />
  25. <el-table-column label="视频封面" min-width="110" align="center" prop="videoCoverImageUrl">
  26. <template slot-scope="scope">
  27. <div v-if="scope.row.videoCoverImageUrl" class="video" @click="handlePlay(scope.row)">
  28. <img :src="scope.row.videoCoverImageUrl" class="video-img" />
  29. <i class="el-icon-video-play" />
  30. </div>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="视频描述" min-width="150" align="center" prop="videoDesc">
  34. <template slot-scope="scope">
  35. <el-popover placement="top-start" width="200" trigger="hover" :content="scope.row.videoDesc">
  36. <span class="desc"
  37. slot="reference">{{ scope.row.videoDesc }}</span>
  38. </el-popover>
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="SKU" min-width="100" align="center" prop="sku" />
  42. <el-table-column label="SKUID" min-width="100" align="center" prop="skuId" />
  43. <el-table-column label="审核状态" min-width="100" align="center" prop="reviewStatus">
  44. <template slot-scope="scope">
  45. <span class="status-tag" :class="{
  46. 'status-pending': scope.row.reviewStatus === 0,
  47. 'status-success': scope.row.reviewStatus === 1,
  48. 'status-error': scope.row.reviewStatus === 2
  49. }"></span>
  50. {{ getValueByKey(scope.row.reviewStatus, auditStatus) }}
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="审核时间" min-width="100" align="center" prop="reviewTime" />
  54. <el-table-column label="审核人" min-width="100" align="center" prop="reviewer" />
  55. <el-table-column label="发布状态" min-width="100" align="center" prop="publishStatus">
  56. <template slot-scope="scope">
  57. <span class="status-tag" :class="{
  58. 'status-pending': scope.row.publishStatus === 0,
  59. 'status-success': scope.row.publishStatus === 1,
  60. 'status-error': scope.row.publishStatus === 2
  61. }"></span>
  62. {{ getValueByKey(scope.row.publishStatus, auditStatus) }}
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="发布时间" min-width="100" align="center" prop="publishTime" />
  66. <el-table-column label="发布人" min-width="100" align="center" prop="publisher" />
  67. <el-table-column label="关联话题" min-width="100" align="center" prop="hotWords" />
  68. <el-table-column label="直播时间" min-width="100" align="center" prop="liveTime" />
  69. <!-- <el-table-column
  70. label="直播场次"
  71. min-width="100"
  72. align="center"
  73. prop="liveSession"
  74. /> -->
  75. <el-table-column label="直播中控" min-width="120" align="center" prop="liveController">
  76. </el-table-column>
  77. <el-table-column label="直播间号" min-width="100" align="center" prop="liveRoomId" />
  78. <el-table-column label="操作人" min-width="100" align="center" prop="creator" />
  79. <el-table-column label="创建时间" min-width="100" align="center" prop="createTime" />
  80. <el-table-column label="操作" align="center" min-width="160"
  81. v-bind="device !== 'mobile' ? { fixed: 'right' } : {}">
  82. <template slot-scope="scope">
  83. <el-tooltip class="item" effect="dark" content="下载" placement="top">
  84. <el-button type="primary" :loading="scope.row && scope.row.id
  85. ? downloadingRows[scope.row.id]
  86. : false
  87. " size="mini" icon="el-icon-download" circle @click="handleDownload(scope.row)" />
  88. </el-tooltip>
  89. <el-tooltip class="item" effect="dark" content="播放" placement="top">
  90. <el-button type="success" size="mini" icon="el-icon-caret-right" circle @click="handlePlay(scope.row)" />
  91. </el-tooltip>
  92. <el-tooltip
  93. class="more"
  94. effect="dark"
  95. content="删除"
  96. placement="top"
  97. >
  98. <el-button
  99. type="danger"
  100. size="mini"
  101. icon="el-icon-delete-solid"
  102. circle
  103. @click="handleDelete(scope.row)"
  104. />
  105. </el-tooltip>
  106. <!-- <el-tooltip class="more" effect="dark" content="更多" placement="top">
  107. <el-dropdown trigger="click" @command="command => handleMore(command, scope.row)">
  108. <el-button size="mini" type="primary" icon="el-icon-more" circle title="更多" />
  109. <el-dropdown-menu class="dropdown-menu" slot="dropdown">
  110. <el-dropdown-item command="changeTopic">修改话题</el-dropdown-item>
  111. <el-dropdown-item command="delete">删除</el-dropdown-item>
  112. </el-dropdown-menu>
  113. </el-dropdown>
  114. </el-tooltip> -->
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. </div>
  119. <!-- 分页 -->
  120. <swPage v-if="total > 0" key="2" :listQuery="listQuery" :total="total" pos="btmRight" @retPage="retPage" />
  121. <!-- 视频播放 -->
  122. <video-player ref="videoPlayer" :video-url="currentVideoUrl" :video-title="currentVideoTitle"
  123. @close="handlePlayerClose" />
  124. <!-- 修改话题-->
  125. <change-topic ref="changeTopicRef" :rows="currentVideo" @confirm="handleTopicChange" />
  126. </div>
  127. </template>
  128. <script>
  129. import waves from "@/directive/waves";
  130. import swPage from "@/views/common/swPage";
  131. import { auditStatus } from "@/constants/index";
  132. import { getValueByKey } from "@/utils/index";
  133. import ExcelImport from "@/components/ExcelImport";
  134. import changeTopic from "@/views/oral-video/component/changeTopic";
  135. import { fetchOralVideoList, deleteOralVideoList } from "@/api/video";
  136. import downloadUtil from "@/utils/downloadUtil";
  137. import VideoPlayer from "@/components/VideoPlayer";
  138. import { mapGetters } from "vuex";
  139. export default {
  140. name: "oralVideoIndex",
  141. directives: {
  142. waves
  143. },
  144. components: {
  145. swPage,
  146. VideoPlayer,
  147. ExcelImport,
  148. changeTopic
  149. },
  150. computed: {
  151. ...mapGetters(["device"]) // 从 vuex 中获取设备类型
  152. },
  153. data() {
  154. return {
  155. auditStatus,
  156. tableKey: 0,
  157. list: [],
  158. total: 0,
  159. listLoading: false,
  160. downloadingRows: {},
  161. listQuery: {
  162. currentPage: 1,
  163. pageSize: 10,
  164. videoTitle: null,
  165. // sku: null,
  166. },
  167. currentVideoUrl: null,
  168. currentVideoTitle: null,
  169. currentVideo:{},
  170. };
  171. },
  172. //页面创建的时候执行
  173. created() {
  174. this.getList();
  175. },
  176. methods: {
  177. getValueByKey,
  178. getList() {
  179. this.listLoading = true;
  180. fetchOralVideoList(this.listQuery).then(res => {
  181. if (200 == res.code) {
  182. this.total = res.data.total;
  183. this.list = res.data.rows;
  184. }
  185. this.listLoading = false;
  186. });
  187. },
  188. retPage() {
  189. //分页
  190. this.getList();
  191. },
  192. handleFilter() {
  193. this.listQuery.page = 1;
  194. this.getList();
  195. },
  196. // 视频下载
  197. async handleDownload(row) {
  198. const { videoUrl, videoTitle, id, sku } = row;
  199. this.$set(this.downloadingRows, id, true);
  200. try {
  201. const title = sku ? videoTitle + "_" + sku : videoTitle;
  202. const res = await downloadUtil.videoDownload(videoUrl, title);
  203. if (res) {
  204. this.$message.success("下载成功");
  205. }
  206. } catch (error) {
  207. this.$message.error(error.message);
  208. } finally {
  209. this.$set(this.downloadingRows, id, false);
  210. }
  211. },
  212. // 视频播放
  213. handlePlay(row) {
  214. const { videoUrl, videoTitle } = row;
  215. ``;
  216. if (!videoUrl) {
  217. this.$message.error("视频地址不存在");
  218. return;
  219. }
  220. this.currentVideoUrl = videoUrl;
  221. this.currentVideoTitle = videoTitle;
  222. this.$refs.videoPlayer.show();
  223. },
  224. handlePlayerClose() {
  225. this.currentVideoUrl = "";
  226. this.currentVideoTitle = "";
  227. },
  228. handleDelete(row) {
  229. //删除
  230. this.$confirm("是否删除该视频?", "提示", {
  231. confirmButtonText: "确定",
  232. cancelButtonText: "取消",
  233. type: "warning"
  234. }).then(() => {
  235. const { id } = row;
  236. deleteOralVideoList([id]).then(() => {
  237. this.$notify({
  238. title: "成功",
  239. message: "删除成功",
  240. type: "success",
  241. duration: 3000
  242. });
  243. const index = this.list.indexOf(row);
  244. this.list.splice(index, 1);
  245. });
  246. });
  247. },
  248. // 导入话题回调
  249. handleImportSuccess({ data, header, file }) {
  250. console.log("导入的数据:", data);
  251. console.log("表头:", header);
  252. console.log("原始文件:", file);
  253. // 处理导入的数据
  254. },
  255. //更多
  256. handleMore(command, row) {
  257. if (command === "delete") {
  258. this.handleDelete(row); // 删除
  259. } else if (command === "changeTopic") {
  260. this.changeTopic(row); // 修改话题
  261. }
  262. },
  263. // 修改话题
  264. changeTopic(row) {
  265. this.currentVideo = row;
  266. this.$refs.changeTopicRef.show();
  267. },
  268. handleTopicChange() {
  269. this.$refs.changeTopicRef.show();
  270. this.retPage()
  271. }
  272. }
  273. };
  274. </script>
  275. <style rel="stylesheet/scss" lang="scss" scoped>
  276. @import "@/styles/layout.scss";
  277. .button {
  278. .el-button {
  279. margin-bottom: 10px;
  280. &:last-child {
  281. margin-bottom: 0;
  282. }
  283. }
  284. }
  285. .video {
  286. position: relative;
  287. display: flex;
  288. align-content: center;
  289. justify-content: center;
  290. &:hover {
  291. i {
  292. opacity: 1;
  293. }
  294. .video-img {
  295. opacity: 0.6;
  296. }
  297. }
  298. &-img {
  299. width: 60px;
  300. height: 60px;
  301. border: 1px solid #eee;
  302. object-fit: cover;
  303. cursor: pointer;
  304. }
  305. i {
  306. width: 60px;
  307. height: 60px;
  308. position: absolute;
  309. top: 85%;
  310. left: 50%;
  311. transform: translate(-50%, -50%);
  312. font-size: 20px;
  313. font-weight: bold;
  314. color: #fff;
  315. opacity: 0;
  316. cursor: pointer;
  317. }
  318. }
  319. .status-tag {
  320. display: inline-block;
  321. width: 8px;
  322. height: 8px;
  323. border-radius: 50%;
  324. margin-right: 6px;
  325. }
  326. .status-pending {
  327. background-color: #e6a23c;
  328. }
  329. .status-success {
  330. background-color: #67c23a;
  331. }
  332. .status-error {
  333. background-color: #f56c6c;
  334. }
  335. .filter-btn {
  336. height: 40px;
  337. }
  338. .desc {
  339. overflow: hidden;
  340. text-overflow: ellipsis;
  341. display: -webkit-box;
  342. -webkit-line-clamp: 2;
  343. -webkit-box-orient: vertical;
  344. line-height: 1.5;
  345. max-height: 3em;
  346. }
  347. .more {
  348. margin-left: 10px;
  349. }
  350. </style>