VideoPost.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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 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="true"
  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. @click="handleScope(scope.$index, scope.row)"
  113. >本人可见</el-button>
  114. <el-button
  115. v-else-if="scope.row.scope === 2"
  116. size="mini"
  117. type="success"
  118. @click="handleScope(scope.$index, scope.row)"
  119. >所有人可见</el-button>
  120. <el-button
  121. v-else-if="scope.row.scope === 3"
  122. size="mini"
  123. type="warning"
  124. @click="handleScope(scope.$index, scope.row)"
  125. >VIP 可见</el-button>
  126. <el-button
  127. v-else
  128. size="mini"
  129. type="danger"
  130. @click="handleScope(scope.$index, scope.row)"
  131. >验证码可见</el-button>
  132. </el-tooltip>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. prop="scope"
  137. label="审核状态"
  138. width="120"
  139. >
  140. <template slot-scope="scope">
  141. <el-tag v-if="scope.row.status === 1" :type="'warning'" disable-transitions>
  142. 审核中
  143. </el-tag>
  144. <el-tag v-else-if="scope.row.status === 2" :type="'success'" disable-transitions>
  145. 审核通过
  146. </el-tag>
  147. <el-tag v-else-if="scope.row.status === 3" :type="'danger'" disable-transitions>
  148. 审核未通过
  149. </el-tag>
  150. <el-tag v-else-if="scope.row.status === 4" :type="'danger'" disable-transitions>
  151. 下架
  152. </el-tag>
  153. <el-tag v-else :type="'danger'" disable-transitions>
  154. 状态值: {{ scope.row.status }}
  155. </el-tag>
  156. </template>
  157. </el-table-column>
  158. <el-table-column
  159. fixed="right"
  160. label="操作"
  161. width="280"
  162. >
  163. <template slot-scope="scope">
  164. <el-button
  165. size="mini"
  166. @click="handlePreview(scope.$index, scope.row)"
  167. >预览</el-button>
  168. <el-button
  169. size="mini"
  170. @click="handleEdit(scope.$index, scope.row)"
  171. >编辑</el-button>
  172. <el-button
  173. size="mini"
  174. type="danger"
  175. @click="handleDelete(scope.$index, scope.row)"
  176. >删除</el-button>
  177. </template>
  178. </el-table-column>
  179. </el-table>
  180. <el-pagination
  181. background
  182. :small="screenWidth <= 768"
  183. layout="prev, pager, next"
  184. :page-size="pageSize"
  185. :current-page="currentPage"
  186. :total="totalSize"
  187. @current-change="handleCurrentChange"
  188. @prev-click="handleCurrentChange"
  189. @next-click="handleCurrentChange"
  190. />
  191. </el-main>
  192. <!-- 发布视频稿件对话框 -->
  193. <el-dialog
  194. :visible.sync="publishVideoDiaglog"
  195. :before-close="handleClose"
  196. width="70%"
  197. center
  198. >
  199. <video-post-publish />
  200. <span slot="footer" class="dialog-footer">
  201. <el-button @click="publishVideoDiaglog = false">取 消</el-button>
  202. <el-button type="primary" @click="publishVideoDiaglog = false">关 闭</el-button>
  203. </span>
  204. </el-dialog>
  205. <!-- 修改视频可见范围对话框 -->
  206. <el-dialog
  207. append-to-body
  208. :visible.sync="showEditScopeDialog"
  209. width="30%"
  210. center
  211. >
  212. <el-card class="box-card">
  213. <div slot="header" class="clearfix">
  214. <span>修改视频可见范围</span>
  215. <el-button style="float: right; padding: 3px 0" type="text" @click="onUpdateScope">更新</el-button>
  216. </div>
  217. <div class="text item">
  218. <el-select v-model="form.scope" placeholder="选择可见范围">
  219. <el-option label="本人可见" value="1" />
  220. <el-option label="所有人可见" value="2" />
  221. <el-option label="VIP 可见" value="3" />
  222. <el-option label="验证码可见" value="4" />
  223. </el-select>
  224. </div>
  225. </el-card>
  226. </el-dialog>
  227. <!-- 视频预览对话框 -->
  228. <el-dialog
  229. title="预览视频"
  230. append-to-body
  231. :visible.sync="showPreviewDialog"
  232. :before-close="handleDialogClose"
  233. width="70%"
  234. center
  235. >
  236. <template>
  237. <video-preview-player :video-prop.sync="videoProp" />
  238. </template>
  239. </el-dialog>
  240. </el-container>
  241. </template>
  242. <script>
  243. import VideoPreviewPlayer from 'components/VideoPreviewPlayer'
  244. import VideoPostPublish from '@/views/post/VideoPostPublish'
  245. import { updateVideoScope, videoInfo, deleteVideoPost, getVideoPosts } from '@/api/video'
  246. export default {
  247. name: 'VideoPost',
  248. components: { VideoPreviewPlayer, VideoPostPublish },
  249. data() {
  250. return {
  251. queryInfo: {
  252. scope: null,
  253. pn: 1
  254. },
  255. // 屏幕宽度, 为了控制分页条的大小
  256. screenWidth: document.body.clientWidth,
  257. currentPage: 1,
  258. pageSize: 12,
  259. totalSize: 0,
  260. dataList: [],
  261. // **********************************************************************
  262. videoProp: null,
  263. showVideoResourceDialog: false,
  264. showEditScopeDialog: false,
  265. showPreviewDialog: false,
  266. form: {
  267. videoId: null,
  268. scope: 1
  269. },
  270. videoResources: [],
  271. publishVideoDiaglog: false
  272. }
  273. },
  274. created() {
  275. document.title = '视频稿件'
  276. this.getData()
  277. },
  278. methods: {
  279. handleCurrentChange(pageNumber) {
  280. this.currentPage = pageNumber
  281. this.getData()
  282. // 回到顶部
  283. scrollTo(0, 0)
  284. },
  285. getData() {
  286. this.dataList = []
  287. getVideoPosts(this.currentPage).then(resp => {
  288. if (resp.code === 0) {
  289. this.dataList = resp.data.list
  290. this.totalSize = resp.data.totalSize
  291. } else {
  292. this.$notify({
  293. title: '提示',
  294. message: resp.msg,
  295. type: 'warning',
  296. duration: 3000
  297. })
  298. }
  299. }).catch(error => {
  300. this.$notify({
  301. title: '提示',
  302. message: error.message,
  303. type: 'error',
  304. duration: 3000
  305. })
  306. })
  307. },
  308. handleScope(index, row) {
  309. this.form.videoId = row.videoId
  310. this.form.scope = '' + row.scope
  311. this.showEditScopeDialog = true
  312. },
  313. handleDialogClose(done) {
  314. this.showPreviewDialog = false
  315. this.videoProp = {
  316. videoId: null,
  317. play: false
  318. }
  319. done()
  320. },
  321. handlePreview(index, row) {
  322. videoInfo(row.videoId).then(res => {
  323. if (res.code === 0) {
  324. this.showPreviewDialog = true
  325. this.videoProp = {
  326. videoId: res.data.videoId,
  327. play: true
  328. }
  329. }
  330. })
  331. },
  332. handleEdit(index, row) {
  333. const path = '/post/video/edit/' + row.videoId
  334. this.$router.push(path)
  335. },
  336. handleDelete(index, row) {
  337. this.$confirm('确定要删除 ' + row.title + '?', '提示', {
  338. confirmButtonText: '确定',
  339. cancelButtonText: '取消',
  340. type: 'warning'
  341. }).then(() => {
  342. deleteVideoPost(row.videoId).then(res => {
  343. if (res.code === 0) {
  344. this.$notify({
  345. title: '提示',
  346. message: '稿件已删除',
  347. type: 'warning',
  348. duration: 3000
  349. })
  350. this.$router.go(0)
  351. }
  352. })
  353. }).catch(() => {
  354. this.$message({
  355. type: 'info',
  356. message: '已取消'
  357. })
  358. })
  359. },
  360. onUpdateScope() {
  361. this.showEditScopeDialog = false
  362. updateVideoScope(this.form).then(res => {
  363. if (res.code === 0) {
  364. this.$notify({
  365. title: '提示',
  366. message: '视频可见范围已更新',
  367. type: 'warning',
  368. duration: 3000
  369. })
  370. }
  371. }).catch(error => {
  372. this.$notify({
  373. title: '提示',
  374. message: error.message,
  375. type: 'warning',
  376. duration: 3000
  377. })
  378. })
  379. },
  380. onSelectChange() {
  381. this.$message.info(this.queryInfo)
  382. },
  383. handleClose() {
  384. }
  385. }
  386. }
  387. </script>
  388. <style>
  389. </style>