FileList.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <el-container>
  3. <el-header height="220">
  4. <h3>我的文件</h3>
  5. </el-header>
  6. <el-main>
  7. <el-table
  8. :data="dataList"
  9. border
  10. height="480"
  11. style="width: 100%"
  12. >
  13. <el-table-column
  14. fixed="left"
  15. label="No"
  16. type="index"
  17. />
  18. <el-table-column
  19. prop="pubDate"
  20. label="文件名"
  21. width="150"
  22. />
  23. <el-table-column
  24. prop="videoId"
  25. label="修改时间"
  26. width="120"
  27. >
  28. <template slot-scope="scope">
  29. <router-link target="_blank" :to="`/video/${scope.row.videoId}`">
  30. <span>{{ scope.row.videoId }}</span>
  31. </router-link>
  32. </template>
  33. </el-table-column>
  34. <el-table-column
  35. prop="description"
  36. label="大小"
  37. :show-overflow-tooltip="true"
  38. >
  39. <template slot-scope="scope">
  40. <el-tooltip
  41. v-if="scope.row.description"
  42. :content="scope.row.description"
  43. raw-content
  44. placement="top-start"
  45. >
  46. <span v-if="scope.row.description && scope.row.description.length <= 15">
  47. {{ scope.row.description }}
  48. </span>
  49. <span v-if="scope.row.description && scope.row.description.length > 15">
  50. {{ scope.row.description.substr(0, 15) + "..." }}
  51. </span>
  52. </el-tooltip>
  53. <span v-else-if="scope.row.description === null">-</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column
  57. prop="duration"
  58. label="文件类型"
  59. />
  60. <el-table-column
  61. fixed="right"
  62. label="操作"
  63. width="280"
  64. >
  65. <template slot-scope="scope">
  66. <el-button
  67. size="mini"
  68. @click="handlePreview(scope.$index, scope.row)"
  69. >预览</el-button>
  70. <el-button
  71. size="mini"
  72. @click="handleEdit(scope.$index, scope.row)"
  73. >编辑</el-button>
  74. </template>
  75. </el-table-column>
  76. </el-table>
  77. <el-pagination
  78. background
  79. :small="screenWidth <= 768"
  80. layout="prev, pager, next"
  81. :page-size="pageSize"
  82. :current-page="currentPage"
  83. :total="totalSize"
  84. @current-change="handleCurrentChange"
  85. @prev-click="handleCurrentChange"
  86. @next-click="handleCurrentChange"
  87. />
  88. </el-main>
  89. <!-- 修改视频可见范围对话框 -->
  90. <el-dialog
  91. append-to-body
  92. :visible.sync="showEditScopeDialog"
  93. width="30%"
  94. center
  95. >
  96. <el-card class="box-card">
  97. <div slot="header" class="clearfix">
  98. <span>修改视频可见范围</span>
  99. <el-button style="float: right; padding: 3px 0" type="text" @click="onUpdateScope">更新</el-button>
  100. </div>
  101. <div class="text item">
  102. <el-select v-model="form.scope" placeholder="选择可见范围">
  103. <el-option label="本人可见" value="1" />
  104. <el-option label="所有人可见" value="2" />
  105. <el-option label="VIP 可见" value="3" />
  106. </el-select>
  107. </div>
  108. </el-card>
  109. </el-dialog>
  110. <!-- 视频预览对话框 -->
  111. <el-dialog
  112. title="预览视频"
  113. append-to-body
  114. :visible.sync="showPreviewDialog"
  115. :before-close="handleDialogClose"
  116. width="70%"
  117. center
  118. >
  119. <template>
  120. <video-preview-player :video-prop.sync="videoProp" />
  121. </template>
  122. </el-dialog>
  123. </el-container>
  124. </template>
  125. <script>
  126. import VideoPreviewPlayer from 'components/VideoPreviewPlayer'
  127. import { updateVideoScope, videoInfo } from '@/api/video'
  128. import { getVideoList } from '@/api/admin'
  129. export default {
  130. name: 'VideoPost',
  131. components: { VideoPreviewPlayer },
  132. data() {
  133. return {
  134. queryInfo: {
  135. scope: null,
  136. pn: 1
  137. },
  138. // 屏幕宽度, 为了控制分页条的大小
  139. screenWidth: document.body.clientWidth,
  140. currentPage: 1,
  141. pageSize: 10,
  142. totalSize: 0,
  143. dataList: [],
  144. nextId: 0,
  145. // **********************************************************************
  146. videoProp: null,
  147. showVideoResourceDialog: false,
  148. showEditScopeDialog: false,
  149. showPreviewDialog: false,
  150. form: {
  151. videoId: null,
  152. scope: 1
  153. },
  154. videoResources: [],
  155. publishVideoDiaglog: false
  156. }
  157. },
  158. created() {
  159. document.title = 'AdminVideoList'
  160. this.getData()
  161. },
  162. methods: {
  163. handleCurrentChange(pageNumber) {
  164. this.currentPage = pageNumber
  165. this.getData()
  166. // 回到顶部
  167. scrollTo(0, 0)
  168. },
  169. getData() {
  170. this.dataList = []
  171. getVideoList(0).then(resp => {
  172. if (resp.code === 0) {
  173. const respData = resp.data
  174. this.dataList = respData.list
  175. this.totalSize = respData.totalSize
  176. } else {
  177. this.$message.error(resp.msg)
  178. }
  179. })
  180. },
  181. onRefresh() {
  182. this.getData()
  183. },
  184. handleScope(index, row) {
  185. this.form.videoId = row.videoId
  186. this.form.scope = '' + row.scope
  187. this.showEditScopeDialog = true
  188. },
  189. handleDialogClose(done) {
  190. this.showPreviewDialog = false
  191. this.videoProp = {
  192. videoId: null,
  193. play: false
  194. }
  195. done()
  196. },
  197. handlePreview(index, row) {
  198. videoInfo(row.videoId).then(res => {
  199. if (res.code === 0) {
  200. this.showPreviewDialog = true
  201. this.videoProp = {
  202. videoId: res.data.videoId,
  203. play: true
  204. }
  205. }
  206. })
  207. },
  208. handleEdit(index, row) {
  209. const path = '/post/video/edit/' + row.videoId
  210. this.$router.push(path)
  211. },
  212. onUpdateScope() {
  213. this.showEditScopeDialog = false
  214. updateVideoScope(this.form).then(res => {
  215. if (res.code === 0) {
  216. this.$notify({
  217. title: '提示',
  218. message: '视频可见范围已更新',
  219. type: 'warning',
  220. duration: 3000
  221. })
  222. }
  223. }).catch(error => {
  224. this.$notify({
  225. title: '提示',
  226. message: error.message,
  227. type: 'warning',
  228. duration: 3000
  229. })
  230. })
  231. },
  232. onSelectChange() {
  233. this.$message.info(this.queryInfo)
  234. },
  235. handleClose() {
  236. }
  237. }
  238. }
  239. </script>
  240. <style>
  241. </style>