VideoPost.vue 12 KB

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