VideoPost.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <el-row>
  3. <el-table
  4. :data="dataList"
  5. border
  6. style="width: 100%"
  7. >
  8. <el-table-column
  9. fixed="left"
  10. label="No"
  11. type="index"
  12. />
  13. <el-table-column
  14. prop="pubDate"
  15. label="发布时间"
  16. width="150"
  17. />
  18. <el-table-column
  19. prop="coverUrl"
  20. label="封面"
  21. width="90"
  22. >
  23. <template slot-scope="scope">
  24. <el-image :src="scope.row.coverUrl" min-width="30" height="20" />
  25. </template>
  26. </el-table-column>
  27. <el-table-column
  28. prop="videoId"
  29. label="视频 ID"
  30. width="120"
  31. >
  32. <template slot-scope="scope">
  33. <router-link target="_blank" :to="`/video/${scope.row.videoId}`">
  34. <span>{{ scope.row.videoId }}</span>
  35. </router-link>
  36. </template>
  37. </el-table-column>
  38. <el-table-column
  39. prop="title"
  40. label="标题"
  41. width="150"
  42. />
  43. <el-table-column
  44. prop="description"
  45. label="描述"
  46. >
  47. <template slot-scope="scope">
  48. <span v-if="scope.row.description !== null">-</span>
  49. <span v-else>{{ scope.row.description }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column
  53. prop="duration"
  54. label="时长"
  55. />
  56. <el-table-column
  57. prop="direction"
  58. label="方向"
  59. />
  60. <el-table-column
  61. label="视频资源"
  62. >
  63. <template slot-scope="scope">
  64. <el-button
  65. size="mini"
  66. @click="handleVideoResource(scope.$index, scope.row)"
  67. >查看</el-button>
  68. </template>
  69. </el-table-column>
  70. <el-table-column
  71. prop="scope"
  72. label="可见范围"
  73. width="120"
  74. >
  75. <template slot-scope="scope">
  76. <el-tooltip class="item" effect="dark" content="点击修改可见范围" placement="top-end">
  77. <el-button
  78. v-if="scope.row.scope === 1"
  79. size="mini"
  80. @click="handleScope(scope.$index, scope.row)"
  81. >本人可见</el-button>
  82. <el-button
  83. v-else-if="scope.row.scope === 2"
  84. size="mini"
  85. type="success"
  86. @click="handleScope(scope.$index, scope.row)"
  87. >所有人可见</el-button>
  88. <el-button
  89. v-else-if="scope.row.scope === 3"
  90. size="mini"
  91. type="warning"
  92. @click="handleScope(scope.$index, scope.row)"
  93. >VIP 可见</el-button>
  94. <el-button
  95. v-else
  96. size="mini"
  97. type="danger"
  98. @click="handleScope(scope.$index, scope.row)"
  99. >验证码可见</el-button>
  100. </el-tooltip>
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. prop="scope"
  105. label="审核状态"
  106. width="120"
  107. >
  108. <template slot-scope="scope">
  109. <el-tag v-if="scope.row.status === 1" :type="'warning'" disable-transitions>
  110. 审核中
  111. </el-tag>
  112. <el-tag v-else-if="scope.row.status === 2" :type="'success'" disable-transitions>
  113. 审核通过
  114. </el-tag>
  115. <el-tag v-else-if="scope.row.status === 3" :type="'danger'" disable-transitions>
  116. 审核未通过
  117. </el-tag>
  118. <el-tag v-else-if="scope.row.status === 4" :type="'danger'" disable-transitions>
  119. 下架
  120. </el-tag>
  121. <el-tag v-else-if="scope.row.status === 5" :type="'danger'" disable-transitions>
  122. 待缓存
  123. </el-tag>
  124. <el-tag v-else-if="scope.row.status === 6" :type="'danger'" disable-transitions>
  125. 缓存中
  126. </el-tag>
  127. <el-tag v-else-if="scope.row.status === 7" :type="'danger'" disable-transitions>
  128. 缓存失败
  129. </el-tag>
  130. <el-tag v-else-if="scope.row.status === 8" :type="'danger'" disable-transitions>
  131. 封面不存在
  132. </el-tag>
  133. <el-tag v-else :type="'danger'" disable-transitions>
  134. 视频不存在
  135. </el-tag>
  136. </template>
  137. </el-table-column>
  138. <el-table-column
  139. fixed="right"
  140. label="操作"
  141. width="280"
  142. >
  143. <template slot-scope="scope">
  144. <el-button
  145. size="mini"
  146. @click="handlePreview(scope.$index, scope.row)"
  147. >预览</el-button>
  148. <el-button
  149. size="mini"
  150. @click="handleEdit(scope.$index, scope.row)"
  151. >编辑</el-button>
  152. <el-button
  153. size="mini"
  154. type="danger"
  155. @click="handleDelete(scope.$index, scope.row)"
  156. >删除</el-button>
  157. </template>
  158. </el-table-column>
  159. </el-table>
  160. <!-- 视频资源对话框 -->
  161. <el-dialog
  162. append-to-body
  163. :visible.sync="showVideoResourceDialog"
  164. width="70%"
  165. center
  166. >
  167. <el-table
  168. :data="videoResources"
  169. border
  170. style="width: 100%"
  171. >
  172. <el-table-column
  173. label="No"
  174. type="index"
  175. />
  176. <el-table-column
  177. prop="videoCodec"
  178. label="原始视频"
  179. />
  180. <el-table-column
  181. prop="videoCodec"
  182. label="视频编码"
  183. />
  184. <el-table-column
  185. prop="audioCodec"
  186. label="音频编码"
  187. />
  188. <el-table-column
  189. prop="quality"
  190. label="画质"
  191. />
  192. <el-table-column
  193. prop="urlType"
  194. label="URL 类型"
  195. />
  196. <el-table-column
  197. prop="url"
  198. label="URL"
  199. />
  200. <el-table-column
  201. fixed="right"
  202. label="操作"
  203. width="280"
  204. >
  205. <template slot-scope="scope">
  206. <el-button
  207. size="mini"
  208. @click="handleConvert(scope.$index, scope.row)"
  209. >转码</el-button>
  210. </template>
  211. </el-table-column>
  212. </el-table>
  213. </el-dialog>
  214. <!-- 修改视频可见范围对话框 -->
  215. <el-dialog
  216. append-to-body
  217. :visible.sync="showEditScopeDialog"
  218. width="30%"
  219. center
  220. >
  221. <el-card class="box-card">
  222. <div slot="header" class="clearfix">
  223. <span>修改视频可见范围</span>
  224. <el-button style="float: right; padding: 3px 0" type="text" @click="onUpdateScope">更新</el-button>
  225. </div>
  226. <div class="text item">
  227. <el-select v-model="form.scope" placeholder="选择可见范围">
  228. <el-option label="本人可见" value="1" />
  229. <el-option label="所有人可见" value="2" />
  230. <el-option label="VIP 可见" value="3" />
  231. <el-option label="验证码可见" value="4" />
  232. </el-select>
  233. </div>
  234. </el-card>
  235. </el-dialog>
  236. <!-- 视频预览对话框 -->
  237. <el-dialog
  238. title="预览视频"
  239. append-to-body
  240. :visible.sync="showPreviewDialog"
  241. :before-close="handleDialogClose"
  242. width="70%"
  243. center
  244. >
  245. <template>
  246. <video-preview-player :video-prop.sync="this.videoProp" />
  247. </template>
  248. </el-dialog>
  249. </el-row>
  250. </template>
  251. <script>
  252. import VideoPreviewPlayer from 'components/VideoPreviewPlayer'
  253. import { updateVideoScope, videoInfo, deleteVideoPost, getVideoResource, convertVideo, getVideoPosts } from '@/api/video'
  254. export default {
  255. name: 'VideoPost',
  256. components: { VideoPreviewPlayer },
  257. data() {
  258. return {
  259. // 屏幕宽度, 为了控制分页条的大小
  260. screenWidth: document.body.clientWidth,
  261. currentPage: 1,
  262. pageSize: 12,
  263. totalSize: 0,
  264. dataList: [],
  265. // **********************************************************************
  266. videoProp: null,
  267. showVideoResourceDialog: false,
  268. showEditScopeDialog: false,
  269. showPreviewDialog: false,
  270. form: {
  271. videoId: null,
  272. scope: 1
  273. },
  274. videoResources: []
  275. }
  276. },
  277. created() {
  278. document.title = '视频稿件'
  279. this.getData()
  280. },
  281. methods: {
  282. handleCurrentChange(pageNumber) {
  283. this.currentPage = pageNumber
  284. this.getData()
  285. // 回到顶部
  286. scrollTo(0, 0)
  287. },
  288. getData() {
  289. this.dataList = []
  290. getVideoPosts(this.currentPage).then(resp => {
  291. if (resp.code === 0) {
  292. this.dataList = resp.data.list
  293. this.totalSize = resp.data.totalSize
  294. } else {
  295. this.$notify({
  296. title: '提示',
  297. message: resp.msg,
  298. type: 'warning',
  299. duration: 3000
  300. })
  301. }
  302. }).catch(error => {
  303. this.$notify({
  304. title: '提示',
  305. message: error.message,
  306. type: 'error',
  307. duration: 3000
  308. })
  309. })
  310. },
  311. handleVideoResource(index, row) {
  312. const videoId = row.videoId
  313. this.showVideoResourceDialog = true
  314. getVideoResource(videoId).then(resp => {
  315. if (resp.code === 0) {
  316. this.videoResources = resp.data
  317. }
  318. })
  319. },
  320. handleScope(index, row) {
  321. this.form.videoId = row.videoId
  322. this.form.scope = '' + row.scope
  323. this.showEditScopeDialog = true
  324. },
  325. handleDialogClose(done) {
  326. this.showPreviewDialog = false
  327. this.videoProp = {
  328. videoId: null,
  329. play: false
  330. }
  331. done()
  332. },
  333. handleConvert(index, row) {
  334. convertVideo(row.videoId).then(res => {
  335. if (res.code === 0) {
  336. this.$notify({
  337. title: '提示',
  338. message: '视频转码请求已提交',
  339. type: 'warning',
  340. duration: 3000
  341. })
  342. }
  343. })
  344. },
  345. handlePreview(index, row) {
  346. videoInfo(row.videoId).then(res => {
  347. if (res.code === 0) {
  348. this.showPreviewDialog = true
  349. this.videoProp = {
  350. videoId: res.data.videoId,
  351. play: true
  352. }
  353. }
  354. })
  355. },
  356. handleEdit(index, row) {
  357. const path = '/post/edit/video/' + row.videoId
  358. this.$router.push(path)
  359. },
  360. handleDelete(index, row) {
  361. this.$confirm('确定要删除 ' + row.title + '?', '提示', {
  362. confirmButtonText: '确定',
  363. cancelButtonText: '取消',
  364. type: 'warning'
  365. }).then(() => {
  366. deleteVideoPost(row.videoId).then(res => {
  367. if (res.code === 0) {
  368. this.$notify({
  369. title: '提示',
  370. message: '稿件已删除',
  371. type: 'warning',
  372. duration: 3000
  373. })
  374. this.$router.go(0)
  375. }
  376. })
  377. }).catch(() => {
  378. this.$message({
  379. type: 'info',
  380. message: '已取消'
  381. })
  382. })
  383. },
  384. onUpdateScope() {
  385. this.showEditScopeDialog = false
  386. updateVideoScope(this.form).then(res => {
  387. if (res.code === 0) {
  388. this.$notify({
  389. title: '提示',
  390. message: '视频可见范围已更新',
  391. type: 'warning',
  392. duration: 3000
  393. })
  394. }
  395. }).catch(error => {
  396. this.$notify({
  397. title: '提示',
  398. message: error.message,
  399. type: 'warning',
  400. duration: 3000
  401. })
  402. })
  403. }
  404. }
  405. }
  406. </script>
  407. <style>
  408. </style>