index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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.downloadCount ? scope.row.downloadCount : '-' }}
  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, addSuggestion } 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. const params = {
  246. "videoId": id,
  247. "operationType": 2
  248. }
  249. addSuggestion(params).then(res =>{
  250. if(res.code == 200){}
  251. })
  252. this.$message.success("下载成功");
  253. }
  254. } catch (error) {
  255. this.$message.error(error.message);
  256. } finally {
  257. this.$set(this.downloadingRows, id, false);
  258. }
  259. },
  260. handlePlay(url) {
  261. if (!url) {
  262. this.$message.error("媒体地址不存在");
  263. return;
  264. }
  265. if (this.isVideoFormat(url)) {
  266. // 视频播放逻辑
  267. this.currentVideoUrl = url;
  268. this.currentVideoTitle = url.split("/").pop();
  269. this.$refs.videoPlayer.show();
  270. } else if (this.isImageFormat(url)) {
  271. // 新增图片格式判断
  272. this.$nextTick(() => {
  273. this.imageUrl = url;
  274. this.$refs.elImage.clickHandler();
  275. });
  276. } else {
  277. this.$message.error("不支持的文件格式");
  278. }
  279. },
  280. handlePlayerClose() {
  281. this.currentVideoUrl = "";
  282. this.currentVideoTitle = "";
  283. },
  284. handleDelete(row) {
  285. //删除
  286. this.$confirm("是否删除该图片/视频?", "提示", {
  287. confirmButtonText: "确定",
  288. cancelButtonText: "取消",
  289. type: "warning"
  290. }).then(() => {
  291. const { id } = row;
  292. deleteOralVideoList([id]).then(() => {
  293. this.$notify({
  294. title: "成功",
  295. message: "删除成功",
  296. type: "success",
  297. duration: 3000
  298. });
  299. const index = this.list.indexOf(row);
  300. this.list.splice(index, 1);
  301. });
  302. });
  303. },
  304. //更多
  305. handleMore(command, row) {
  306. if (command === "delete") {
  307. this.handleDelete(row); // 删除
  308. } else if (command === "changeTopic") {
  309. this.changeTopic(row); // 修改话题
  310. }
  311. },
  312. handleAdvise(command, row) {
  313. if (command == 'addAdvise') {
  314. this.handleEditSuggestions(row)
  315. }
  316. if (command == 'editAdvise') {
  317. this.handleViewSuggestions(row)
  318. }
  319. },
  320. handleViewSuggestions(row) {
  321. this.$refs.suggestionTable.show(row);
  322. },
  323. handleEditSuggestions(row) {
  324. this.$refs.editSuggestion.show(row);
  325. },
  326. handleCofirmSuggestion() {
  327. this.retPage();
  328. }
  329. }
  330. };
  331. </script>
  332. <style rel="stylesheet/scss" lang="scss" scoped>
  333. @import "@/styles/layout.scss";
  334. .button {
  335. .el-button {
  336. margin-bottom: 10px;
  337. &:last-child {
  338. margin-bottom: 0;
  339. }
  340. }
  341. }
  342. .video-last-img {
  343. display: flex;
  344. align-items: center;
  345. justify-content: center;
  346. margin-top: 5px;
  347. /deep/.el-image__preview {
  348. width: 80px;
  349. height: 80px;
  350. border: 1px solid #eee;
  351. object-fit: cover;
  352. object-position: top;
  353. cursor: pointer;
  354. }
  355. }
  356. .video {
  357. position: relative;
  358. display: flex;
  359. align-content: center;
  360. justify-content: center;
  361. &:hover {
  362. i {
  363. opacity: 1;
  364. pointer-events: none;
  365. }
  366. .video-img {
  367. opacity: 0.6;
  368. }
  369. }
  370. &-img {
  371. width: 80px;
  372. height: 80px;
  373. border: 1px solid #eee;
  374. vertical-align: top;
  375. object-fit: cover;
  376. object-position: top;
  377. cursor: pointer;
  378. }
  379. i {
  380. width: 80px;
  381. height: 80px;
  382. position: absolute;
  383. top: 85%;
  384. left: 50%;
  385. transform: translate(-50%, -50%);
  386. font-size: 20px;
  387. font-weight: bold;
  388. color: #fff;
  389. opacity: 0;
  390. cursor: pointer;
  391. }
  392. }
  393. .status-tag {
  394. display: inline-block;
  395. width: 8px;
  396. height: 8px;
  397. border-radius: 50%;
  398. margin-right: 6px;
  399. }
  400. .status-pending {
  401. background-color: #e6a23c;
  402. }
  403. .status-success {
  404. background-color: #67c23a;
  405. }
  406. .status-error {
  407. background-color: #f56c6c;
  408. }
  409. .filter-btn {
  410. height: 40px;
  411. }
  412. .desc {
  413. overflow: hidden;
  414. text-overflow: ellipsis;
  415. display: -webkit-box;
  416. -webkit-line-clamp: 2;
  417. -webkit-box-orient: vertical;
  418. line-height: 1.5;
  419. max-height: 3em;
  420. }
  421. .more {
  422. margin-left: 10px;
  423. }
  424. .look-more {
  425. font-size: 12px;
  426. color: #ae8877;
  427. text-decoration: underline;
  428. }
  429. .edit {
  430. font-size: 16px;
  431. color: #ae8877;
  432. }
  433. </style>