PostList.vue 13 KB

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