VideoPost.vue 9.2 KB

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