VideoPost.vue 11 KB

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