index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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
  8. placeholder="SKU"
  9. class="filter-item"
  10. style="width: 200px;"
  11. clearable
  12. v-model="listQuery.sku"
  13. /> -->
  14. <el-button v-waves class="filter-btn" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
  15. </div>
  16. <!-- <div class="filter-container-rt">
  17. <excel-import :upload-url="'/api/upload-excel'" :headers="{ token: 'your-token' }"
  18. :upload-data="{ type: 'import' }" @on-success="handleImportSuccess">
  19. <template slot="upload-text">
  20. 导入话题
  21. </template>
  22. </excel-import>
  23. </div> -->
  24. </div>
  25. <div class="table-container">
  26. <el-table style="width: 100%" v-loading="listLoading" :key="tableKey" :data="list" row-key="id"
  27. stripe border fit highlight-current-row>
  28. <el-table-column label="序号" type="index" width="60" align="center" />
  29. <el-table-column label="视频ID" min-width="100" align="center" prop="id" />
  30. <el-table-column label="视频标题" min-width="150" align="center" prop="videoTitle" />
  31. <el-table-column label="原图片/视频" min-width="130" align="center" prop="videoUrl">
  32. <template slot-scope="scope" v-if="scope.row.rawVideoUrl">
  33. <div v-if="isVideoFormat(scope.row.rawVideoUrl)" class="video"
  34. @click="handlePlay(scope.row.rawVideoUrl)">
  35. <video :src="scope.row.rawVideoUrl" class="video-img" />
  36. <i class="el-icon-video-play" />
  37. </div>
  38. <div class="video" v-else>
  39. <el-image class="video-last-img video" :src="scope.row.rawVideoUrl"
  40. :preview-src-list="[scope.row.rawVideoUrl]" :lazy="true"/>
  41. <i class="el-icon-zoom-in" />
  42. </div>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="处理后图片/视频" min-width="130" align="center" prop="videoUrl">
  46. <template slot-scope="scope">
  47. <div v-if="isVideoFormat(scope.row.videoUrl)" class="video"
  48. @click="handlePlay(scope.row.videoUrl)">
  49. <!-- <img :src="scope.row.videoCoverImageUrl" class="video-img" /> -->
  50. <video :src="scope.row.videoUrl" class="video-img" />
  51. <i class="el-icon-video-play" />
  52. </div>
  53. <div class="video" v-else>
  54. <el-image class="video-last-img video" :src="scope.row.videoUrl"
  55. :preview-src-list="[scope.row.videoUrl]" :lazy="true"/>
  56. <i class="el-icon-zoom-in" />
  57. </div>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="换脸所用模特" min-width="130" align="center" prop="swapModelUrl">
  61. <template slot-scope="scope">
  62. <div class="video">
  63. <el-image class="video-last-img video" :src="scope.row.swapModelUrl"
  64. :preview-src-list="[scope.row.swapModelUrl]" :lazy="true"/>
  65. <i class="el-icon-zoom-in" />
  66. </div>
  67. </template>
  68. </el-table-column>
  69. <!-- <el-table-column label="操作人" min-width="100" align="center" prop="creator" /> -->
  70. <el-table-column label="创建时间" min-width="100" align="center" prop="createTime" />
  71. <el-table-column label="下载次数" min-width="100" align="center">
  72. <template slot-scope="scope">
  73. {{ scope.row.downlaodCount ? scope.row.downlaodCount : '-' }}
  74. </template>
  75. </el-table-column>
  76. <!-- <el-table-column label="优化建议" min-width="100" align="center" prop="remark">
  77. <template slot-scope="scope">
  78. <p v-if="roles.includes('superAdmin')">
  79. <span class="desc">{{remark}}</span>
  80. <a class="look-more" href="javascript:void(0);" @click="handleViewSuggestions(scope.row)">更多&nbsp;>></a>
  81. </p>
  82. <p v-else>
  83. <a class="edit" href="javascript:void(0);" @click="handleEditSuggestions(scope.row)"><i
  84. class="el-icon-edit" /></a>
  85. </p>
  86. </template>
  87. </el-table-column> -->
  88. <!-- <el-table-column v-permission="['superAdmin']" label="使用账号" width="100" align="center" prop="createTime">
  89. <template slot-scope="scope">
  90. <el-popover placement="top-start" width="200" trigger="hover" :content="scope.row.videoDesc">
  91. <span class="desc" slot="reference"></span>
  92. </el-popover>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="生成账号" min-width="100" align="center" prop="createTime" /> -->
  96. <el-table-column label="操作" align="center" width="160" v-bind="device !== 'mobile' ? { fixed: 'right' } : {}">
  97. <template slot-scope="scope">
  98. <el-tooltip class="item" effect="dark" content="下载" placement="top">
  99. <el-button type="primary" :loading="scope.row && scope.row.id
  100. ? downloadingRows[scope.row.id]
  101. : false
  102. " size="mini" icon="el-icon-download" circle @click="handleDownload(scope.row)" />
  103. </el-tooltip>
  104. <el-tooltip class="item" effect="dark" content="播放" placement="top">
  105. <el-button type="success" size="mini" icon="el-icon-caret-right" circle
  106. @click="handlePlay(scope.row.videoUrl)" />
  107. </el-tooltip>
  108. <el-tooltip class="more" effect="dark" content="删除" placement="top">
  109. <el-button type="danger" size="mini" icon="el-icon-delete-solid" circle
  110. @click="handleDelete(scope.row)" />
  111. </el-tooltip>
  112. <el-tooltip class="more" style="margin: 10px 0 0 0;" effect="dark" content="更多操作" placement="top">
  113. <el-dropdown trigger="click" @command="command => handleAdvise(command, scope.row)">
  114. <el-button size="mini" type="info" icon="el-icon-more" circle title="更多操作" />
  115. <el-dropdown-menu class="dropdown-menu" slot="dropdown">
  116. <el-dropdown-item command="addAdvise">优化建议</el-dropdown-item>
  117. <el-dropdown-item command="editAdvise">查看建议</el-dropdown-item>
  118. </el-dropdown-menu>
  119. </el-dropdown>
  120. </el-tooltip>
  121. <!-- <el-tooltip class="more" effect="dark" content="更多" placement="top">
  122. <el-dropdown trigger="click" @command="command => handleMore(command, scope.row)">
  123. <el-button size="mini" type="primary" icon="el-icon-more" circle title="更多" />
  124. <el-dropdown-menu class="dropdown-menu" slot="dropdown">
  125. <el-dropdown-item command="changeTopic">修改话题</el-dropdown-item>
  126. <el-dropdown-item command="delete">删除</el-dropdown-item>
  127. </el-dropdown-menu>
  128. </el-dropdown>
  129. </el-tooltip> -->
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. </div>
  134. <!-- 分页 -->
  135. <swPage v-if="total > 0" key="2" :listQuery="listQuery" :total="total" pos="btmRight" @retPage="retPage" />
  136. <!-- 视频播放 -->
  137. <video-player ref="videoPlayer" :video-url="currentVideoUrl" :video-title="currentVideoTitle"
  138. @close="handlePlayerClose" />
  139. <!-- 优化建议 -->
  140. <suggestion-table ref="suggestionTable" />
  141. <!-- 编辑优化建议 -->
  142. <edit-suggestion ref="editSuggestion" />
  143. <el-image ref="elImage" style="width: 0; height: 0;" :src="imageUrl" :preview-src-list="[imageUrl]">
  144. </el-image>
  145. </div>
  146. </template>
  147. <script>
  148. import waves from "@/directive/waves";
  149. import swPage from "@/views/common/swPage";
  150. import { auditStatus } from "@/constants/index";
  151. import { getValueByKey } from "@/utils/index";
  152. // import ExcelImport from "@/components/ExcelImport";
  153. import EditSuggestion from "@/components/Suggestion/editSuggestion";
  154. import SuggestionTable from "@/components/Suggestion/suggestionTable";
  155. import { fetchOralVideoList, deleteOralVideoList } from "@/api/video";
  156. import downloadUtil from "@/utils/downloadUtil";
  157. import VideoPlayer from "@/components/VideoPlayer";
  158. import { mapGetters } from "vuex";
  159. export default {
  160. name: "faceswapVideoIndex",
  161. directives: {
  162. waves
  163. },
  164. components: {
  165. swPage,
  166. VideoPlayer,
  167. SuggestionTable,
  168. EditSuggestion
  169. // ExcelImport,
  170. // changeTopic
  171. },
  172. computed: {
  173. ...mapGetters(["device", "roles"]) // 从 vuex 中获取设备类型
  174. },
  175. data() {
  176. return {
  177. auditStatus,
  178. tableKey: 0,
  179. list: [],
  180. total: 0,
  181. listLoading: false,
  182. downloadingRows: {},
  183. listQuery: {
  184. currentPage: 1,
  185. pageSize: 10,
  186. videoTitle: null,
  187. type: 3
  188. // sku: null,
  189. },
  190. currentVideoUrl: null,
  191. currentVideoTitle: null,
  192. currentVideo: {},
  193. imageUrl: null
  194. };
  195. },
  196. //页面创建的时候执行
  197. created() {
  198. this.getList();
  199. },
  200. methods: {
  201. getValueByKey,
  202. isVideoFormat(url) {
  203. if (!url) return false;
  204. const extension = url
  205. .toLowerCase()
  206. .split(".")
  207. .pop();
  208. return["mp4", "mov",].includes(extension);
  209. },
  210. // 新增图片格式检测方法
  211. isImageFormat(url) {
  212. if (!url) return false;
  213. const extension = url
  214. .toLowerCase()
  215. .split(".")
  216. .pop();
  217. return ["jpg", "jpeg", "png", "gif", "webp"].includes(extension);
  218. },
  219. getList() {
  220. this.listLoading = true;
  221. fetchOralVideoList(this.listQuery).then(res => {
  222. if (200 == res.code) {
  223. this.total = res.data.total;
  224. this.list = res.data.rows;
  225. }
  226. this.listLoading = false;
  227. });
  228. },
  229. retPage() {
  230. //分页
  231. this.getList();
  232. },
  233. handleFilter() {
  234. this.listQuery.page = 1;
  235. this.getList();
  236. },
  237. // 视频下载
  238. async handleDownload(row) {
  239. const { videoUrl, videoTitle, id, sku } = row;
  240. this.$set(this.downloadingRows, id, true);
  241. try {
  242. const title = sku ? videoTitle + "_" + sku : videoTitle;
  243. const res = await downloadUtil.fileDownload(videoUrl, title);
  244. if (res) {
  245. this.$message.success("下载成功");
  246. }
  247. } catch (error) {
  248. this.$message.error(error.message);
  249. } finally {
  250. this.$set(this.downloadingRows, id, false);
  251. }
  252. },
  253. handlePlay(url) {
  254. if (!url) {
  255. this.$message.error("媒体地址不存在");
  256. return;
  257. }
  258. if (this.isVideoFormat(url)) {
  259. // 视频播放逻辑
  260. this.currentVideoUrl = url;
  261. this.currentVideoTitle = url.split("/").pop();
  262. this.$refs.videoPlayer.show();
  263. } else if (this.isImageFormat(url)) {
  264. // 新增图片格式判断
  265. this.$nextTick(() => {
  266. this.imageUrl = url;
  267. this.$refs.elImage.clickHandler();
  268. });
  269. } else {
  270. this.$message.error("不支持的文件格式");
  271. }
  272. },
  273. handlePlayerClose() {
  274. this.currentVideoUrl = "";
  275. this.currentVideoTitle = "";
  276. },
  277. handleDelete(row) {
  278. //删除
  279. this.$confirm("是否删除该图片/视频?", "提示", {
  280. confirmButtonText: "确定",
  281. cancelButtonText: "取消",
  282. type: "warning"
  283. }).then(() => {
  284. const { id } = row;
  285. deleteOralVideoList([id]).then(() => {
  286. this.$notify({
  287. title: "成功",
  288. message: "删除成功",
  289. type: "success",
  290. duration: 3000
  291. });
  292. const index = this.list.indexOf(row);
  293. this.list.splice(index, 1);
  294. });
  295. });
  296. },
  297. //更多
  298. handleMore(command, row) {
  299. if (command === "delete") {
  300. this.handleDelete(row); // 删除
  301. } else if (command === "changeTopic") {
  302. this.changeTopic(row); // 修改话题
  303. }
  304. },
  305. handleAdvise(command, row) {
  306. if (command == 'addAdvise') {
  307. this.handleEditSuggestions(row)
  308. }
  309. if (command == 'editAdvise') {
  310. this.handleViewSuggestions(row)
  311. }
  312. },
  313. handleViewSuggestions(row) {
  314. this.$refs.suggestionTable.show(row);
  315. },
  316. handleEditSuggestions(row) {
  317. this.$refs.editSuggestion.show(row);
  318. },
  319. handleCofirmSuggestion() {
  320. this.retPage();
  321. }
  322. }
  323. };
  324. </script>
  325. <style rel="stylesheet/scss" lang="scss" scoped>
  326. @import "@/styles/layout.scss";
  327. .button {
  328. .el-button {
  329. margin-bottom: 10px;
  330. &:last-child {
  331. margin-bottom: 0;
  332. }
  333. }
  334. }
  335. .video-last-img {
  336. display: flex;
  337. align-items: center;
  338. justify-content: center;
  339. margin-top: 5px;
  340. /deep/.el-image__preview {
  341. width: 80px;
  342. height: 80px;
  343. border: 1px solid #eee;
  344. object-fit: cover;
  345. object-position: top;
  346. cursor: pointer;
  347. }
  348. }
  349. .video {
  350. position: relative;
  351. display: flex;
  352. align-content: center;
  353. justify-content: center;
  354. &:hover {
  355. i {
  356. opacity: 1;
  357. pointer-events: none;
  358. }
  359. .video-img {
  360. opacity: 0.6;
  361. }
  362. }
  363. &-img {
  364. width: 80px;
  365. height: 80px;
  366. border: 1px solid #eee;
  367. vertical-align: top;
  368. object-fit: cover;
  369. object-position: top;
  370. cursor: pointer;
  371. }
  372. i {
  373. width: 80px;
  374. height: 80px;
  375. position: absolute;
  376. top: 85%;
  377. left: 50%;
  378. transform: translate(-50%, -50%);
  379. font-size: 20px;
  380. font-weight: bold;
  381. color: #fff;
  382. opacity: 0;
  383. cursor: pointer;
  384. }
  385. }
  386. .status-tag {
  387. display: inline-block;
  388. width: 8px;
  389. height: 8px;
  390. border-radius: 50%;
  391. margin-right: 6px;
  392. }
  393. .status-pending {
  394. background-color: #e6a23c;
  395. }
  396. .status-success {
  397. background-color: #67c23a;
  398. }
  399. .status-error {
  400. background-color: #f56c6c;
  401. }
  402. .filter-btn {
  403. height: 40px;
  404. }
  405. .desc {
  406. overflow: hidden;
  407. text-overflow: ellipsis;
  408. display: -webkit-box;
  409. -webkit-line-clamp: 2;
  410. -webkit-box-orient: vertical;
  411. line-height: 1.5;
  412. max-height: 3em;
  413. }
  414. .more {
  415. margin-left: 10px;
  416. }
  417. .look-more {
  418. font-size: 12px;
  419. color: #ae8877;
  420. text-decoration: underline;
  421. }
  422. .edit {
  423. font-size: 16px;
  424. color: #ae8877;
  425. }
  426. </style>