| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <template>
- <div>
- <el-row class="movie-list">
- <el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">全选</el-checkbox>
- <el-button style="float: right; padding: 3px 0" type="text" @click="onSubmit">发布</el-button>
- </el-row>
- <!--电影列表,与推荐列表-->
- <el-row class="movie-list">
- <!--电影列表-->
- <el-col>
- <el-checkbox-group v-model="checkedVideos" @change="handleCheckedChange">
- <el-checkbox v-for="video in dataList" :key="video.videoId" :label="video.videoId">
- <div style="cursor: pointer" :title="video.title">
- <el-image
- lazy
- fit="cover"
- class="coverImg"
- :src="video.coverUrl"
- />
- <span style="position: absolute; top: 0; left: 60%; color:red"> {{ video.duration }} </span>
- <div style="padding: 14px">
- <router-link style="text-decoration-line: none" target="_blank" :to="`/video/${video.videoId}`">
- <span style="left: 0;margin-bottom: 0px;color: black;">
- {{ video.title | ellipsis }}
- </span>
- </router-link>
- </div>
- </div>
- </el-checkbox>
- </el-checkbox-group>
- <el-col :span="24" class="pagination">
- <el-pagination
- :small="screenWidth <= 768"
- layout="prev, pager, next"
- :page-size="pageSize"
- :current-page="currentPage"
- :total="totalSize"
- @current-change="handleCurrentChange"
- />
- </el-col>
- </el-col>
- </el-row>
- <el-dialog :visible.sync="showDialog" width="30%" center>
- <el-card class="box-card" style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
- <div slot="header" class="clearfix">
- <span>修改视频所有者</span>
- <el-button style="float: right; padding: 10px" type="text" @click="onUpdate">保存修改</el-button>
- </div>
- <div class="text item">
- <el-input
- v-model="jsonData.newUserId"
- placeholder="新用户 ID"
- style="margin-left: 5px;width: 220px"
- prefix-icon="el-icon-search"
- />
- </div>
- </el-card>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getUserVideos } from '@/api/video'
- import { updateVideoOwner } from '@/api/video_edit'
- import { getUserInfo } from '@/api/user'
- export default {
- name: 'VideoList',
- filters: {
- ellipsis(value) {
- if (!value) return ''
- const max = 20
- if (value.length > max) {
- return value.slice(0, max) + '...'
- }
- return value
- }
- },
- data() {
- return {
- // 屏幕宽度, 为了控制分页条的大小
- screenWidth: document.body.clientWidth,
- currentPage: 1,
- pageSize: 120,
- totalSize: 0,
- dataList: [],
- checkAll: false,
- checkedVideos: [],
- cityOptions: [],
- isIndeterminate: true,
- showDialog: false,
- jsonData: {
- oldUserId: null,
- newUserId: null,
- videoIds: null
- }
- }
- },
- created() {
- document.title = 'VideoList'
- this.userId = this.$route.params.userId
- var pnStr = this.$route.query.pn
- if (pnStr === null || pnStr === undefined) {
- pnStr = 1
- }
- getUserInfo(this.userId).then(resp => {
- if (resp.code === 0) {
- this.user = resp.data
- document.title = this.user.screenName + '的视频'
- }
- })
- this.currentPage = parseInt(pnStr)
- this.userVideoListWrapper(this.currentPage, this.userId)
- },
- mounted() {
- // 当窗口宽度改变时获取屏幕宽度
- window.onresize = () => {
- return () => {
- window.screenWidth = document.body.clientWidth
- this.screenWidth = window.screenWidth
- }
- }
- },
- methods: {
- handleCurrentChange(currentPage) {
- this.currentPage = currentPage
- this.$router.push({
- path: '/edit/videolist/' + this.userId,
- query: {
- pn: this.currentPage
- }
- })
- this.$router.go(0)
- },
- userVideoListWrapper(pageNumber, userId) {
- this.dataList = []
- this.totalSize = 0
- getUserVideos(userId, pageNumber).then(resp => {
- if (resp.code === 0) {
- const respData = resp.data
- this.dataList = respData.list
- this.totalSize = respData.totalSize
- this.showEmpty = this.dataList.length === 0
- for (const item of this.dataList) {
- // 使用 videoId 作为 checked 的值
- this.cityOptions.push(item.videoId)
- }
- }
- })
- },
- handleCheckAllChange(val) {
- this.checkedVideos = val ? this.cityOptions : []
- this.isIndeterminate = false
- },
- handleCheckedChange(value) {
- const checkedCount = value.length
- this.checkAll = checkedCount === this.cityOptions.length
- this.isIndeterminate = checkedCount > 0 && checkedCount < this.cityOptions.length
- // console.log(value)
- },
- onSubmit() {
- this.jsonData.oldUserIdStr = this.userId
- // this.jsonData.newUserId = 10196
- this.jsonData.videoIds = this.checkedVideos
- this.showDialog = true
- },
- onUpdate() {
- updateVideoOwner(this.jsonData).then(resp => {
- if (resp.code !== 0) {
- this.$message.error(resp.msg)
- } else {
- this.checkedVideos = []
- this.checkAll = false
- this.$router.go(0)
- }
- }).finally(e => {
- this.showDialog = false
- this.jsonData.oldUserIdStr = this.userId
- this.jsonData.newUserId = null
- this.jsonData.videoIds = []
- })
- }
- }
- }
- </script>
- <style scoped>
- .movie-list {
- padding-top: 5px;
- padding-left: 1%;
- padding-right: 1%;
- }
- .pagination {
- text-align: center;
- padding: 10px;
- }
- .imgs {
- position: relative;
- }
- .coverImg {
- width: 100%;
- height: 175px;
- display: block;
- }
- </style>
|