|
|
@@ -3,7 +3,7 @@
|
|
|
<el-header height="auto" class="post-header">
|
|
|
<div class="header-wrapper">
|
|
|
<h3 class="page-title">
|
|
|
- <i class="el-icon-collection"></i> 稿件管理
|
|
|
+ <i class="el-icon-collection" /> 稿件管理
|
|
|
</h3>
|
|
|
<div class="filter-controls">
|
|
|
<el-select
|
|
|
@@ -24,7 +24,7 @@
|
|
|
icon="el-icon-plus"
|
|
|
size="small"
|
|
|
class="publish-btn"
|
|
|
- @click="publishVideoDiaglog = true"
|
|
|
+ @click="handlePost"
|
|
|
>发布稿件</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -33,10 +33,10 @@
|
|
|
<el-main class="post-main">
|
|
|
<div class="table-card">
|
|
|
<el-table
|
|
|
+ v-loading="loading"
|
|
|
:data="dataList"
|
|
|
style="width: 100%"
|
|
|
header-cell-class-name="table-header-cell"
|
|
|
- v-loading="loading"
|
|
|
>
|
|
|
<el-table-column label="No" type="index" width="60" align="center" />
|
|
|
|
|
|
@@ -49,7 +49,7 @@
|
|
|
:preview-src-list="[scope.row.coverUrl]"
|
|
|
>
|
|
|
<div slot="error" class="image-slot">
|
|
|
- <i class="el-icon-picture-outline"></i>
|
|
|
+ <i class="el-icon-picture-outline" />
|
|
|
</div>
|
|
|
</el-image>
|
|
|
</template>
|
|
|
@@ -63,7 +63,7 @@
|
|
|
</router-link>
|
|
|
<div class="video-meta">
|
|
|
<span class="vid-tag">ID: {{ scope.row.videoId }}</span>
|
|
|
- <span class="duration-tag"><i class="el-icon-time"></i> {{ scope.row.duration }}</span>
|
|
|
+ <span class="duration-tag"><i class="el-icon-time" /> {{ scope.row.duration }}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -74,7 +74,7 @@
|
|
|
<el-table-column label="可见范围" width="130" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
<el-tooltip content="点击修改可见范围" placement="top">
|
|
|
- <div @click="handleScope(scope.$index, scope.row)" class="scope-pointer">
|
|
|
+ <div class="scope-pointer" @click="handleScope(scope.$index, scope.row)">
|
|
|
<el-tag v-if="scope.row.scope === 1" size="medium" type="info" effect="plain">本人可见</el-tag>
|
|
|
<el-tag v-else-if="scope.row.scope === 2" size="medium" type="success" effect="plain">所有人可见</el-tag>
|
|
|
<el-tag v-else-if="scope.row.scope === 3" size="medium" type="warning" effect="plain">VIP 可见</el-tag>
|
|
|
@@ -94,7 +94,7 @@
|
|
|
<el-table-column label="操作" width="220" fixed="right" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button type="text" size="small" icon="el-icon-view" @click="handlePreview(scope.$index, scope.row)">预览</el-button>
|
|
|
- <el-button type="text" size="small" icon="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
|
|
|
+ <el-button type="text" size="small" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
|
|
|
<el-button type="text" size="small" icon="el-icon-delete" class="danger-text" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
@@ -114,16 +114,28 @@
|
|
|
</div>
|
|
|
</el-main>
|
|
|
|
|
|
- <el-dialog :visible.sync="publishVideoDiaglog" width="70%" custom-class="custom-glass-dialog" append-to-body destroy-on-close>
|
|
|
+ <el-dialog
|
|
|
+ :visible.sync="publishVideoDiaglog"
|
|
|
+ width="70%"
|
|
|
+ custom-class="custom-glass-dialog"
|
|
|
+ append-to-body
|
|
|
+ destroy-on-close
|
|
|
+ @close="editingVideo = null"
|
|
|
+ >
|
|
|
<div slot="title" class="dialog-header-custom">
|
|
|
- <i class="el-icon-circle-plus-outline"></i><span>发布新视频稿件</span>
|
|
|
+ <i :class="editingVideo ? 'el-icon-edit' : 'el-icon-circle-plus-outline'" />
|
|
|
+ <span>{{ editingVideo ? '编辑视频稿件' : '发布新视频稿件' }}</span>
|
|
|
</div>
|
|
|
- <video-post-publish @video-publish="onVideoPublish" />
|
|
|
+
|
|
|
+ <video-post-publish
|
|
|
+ :video-info="editingVideo"
|
|
|
+ @video-publish="onVideoPublish"
|
|
|
+ />
|
|
|
</el-dialog>
|
|
|
|
|
|
<el-dialog :visible.sync="showEditScopeDialog" width="400px" custom-class="custom-glass-dialog compact-dialog" append-to-body center>
|
|
|
<div slot="title" class="dialog-header-custom">
|
|
|
- <i class="el-icon-lock"></i><span>权限设置</span>
|
|
|
+ <i class="el-icon-lock" /><span>权限设置</span>
|
|
|
</div>
|
|
|
<div class="dialog-body-padding">
|
|
|
<p class="input-label-tip">请选择该视频的可见范围:</p>
|
|
|
@@ -141,7 +153,7 @@
|
|
|
|
|
|
<el-dialog :visible.sync="showPreviewDialog" width="900px" top="8vh" custom-class="custom-glass-dialog preview-dialog" append-to-body @close="handleDialogClose(()=> { showPreviewDialog = false })">
|
|
|
<div slot="title" class="dialog-header-custom">
|
|
|
- <i class="el-icon-video-play"></i><span>内容预览</span>
|
|
|
+ <i class="el-icon-video-play" /><span>内容预览</span>
|
|
|
</div>
|
|
|
<div class="preview-wrapper">
|
|
|
<video-preview-player :video-prop.sync="videoProp" />
|
|
|
@@ -153,7 +165,7 @@
|
|
|
<script>
|
|
|
import VideoPreviewPlayer from 'components/VideoPreviewPlayer'
|
|
|
import VideoPostPublish from '@/views/post/VideoPostPublish'
|
|
|
-import { updateVideoScope, videoInfo, deleteVideoPost, getVideoPosts, addVideoPost } from '@/api/video'
|
|
|
+import {updateVideoScope, videoInfo, deleteVideoPost, getVideoPosts, addVideoPost, updateVideoInfo} from '@/api/video'
|
|
|
|
|
|
export default {
|
|
|
name: 'VideoPost',
|
|
|
@@ -163,7 +175,7 @@ export default {
|
|
|
loading: false,
|
|
|
queryInfo: {
|
|
|
scope: null, // 从 URL 获取
|
|
|
- pn: 1 // 从 URL 获取
|
|
|
+ pn: 1 // 从 URL 获取
|
|
|
},
|
|
|
screenWidth: document.body.clientWidth,
|
|
|
pageSize: 12,
|
|
|
@@ -173,13 +185,14 @@ export default {
|
|
|
showEditScopeDialog: false,
|
|
|
showPreviewDialog: false,
|
|
|
form: { videoId: null, scope: 1 },
|
|
|
- publishVideoDiaglog: false
|
|
|
+ publishVideoDiaglog: false,
|
|
|
+ editingVideo: null
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
// 映射当前页码给 el-pagination 使用
|
|
|
currentPage() {
|
|
|
- return parseInt(this.queryInfo.pn) || 1;
|
|
|
+ return parseInt(this.queryInfo.pn) || 1
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
@@ -192,10 +205,10 @@ export default {
|
|
|
methods: {
|
|
|
// 1. 同步 URL 参数到 data,并执行请求
|
|
|
syncParamsAndLoad() {
|
|
|
- const { pn, scope } = this.$route.query;
|
|
|
- this.queryInfo.pn = pn ? parseInt(pn) : 1;
|
|
|
- this.queryInfo.scope = scope ? (isNaN(scope) ? scope : parseInt(scope)) : null;
|
|
|
- this.getData();
|
|
|
+ const { pn, scope } = this.$route.query
|
|
|
+ this.queryInfo.pn = pn ? parseInt(pn) : 1
|
|
|
+ this.queryInfo.scope = scope ? (isNaN(scope) ? scope : parseInt(scope)) : null
|
|
|
+ this.getData()
|
|
|
},
|
|
|
|
|
|
// 2. 更新 URL 的通用方法
|
|
|
@@ -208,64 +221,69 @@ export default {
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
// 捕获冗余导航错误(点击同一页时)
|
|
|
- if (err.name !== 'NavigationDuplicated') throw err;
|
|
|
- });
|
|
|
+ if (err.name !== 'NavigationDuplicated') throw err
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
// 3. 交互触发:切换分页
|
|
|
handlePageChange(pageNumber) {
|
|
|
- this.queryInfo.pn = pageNumber;
|
|
|
- this.updateRouter();
|
|
|
- window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
|
+ this.queryInfo.pn = pageNumber
|
|
|
+ this.updateRouter()
|
|
|
+ window.scrollTo({ top: 0, behavior: 'smooth' })
|
|
|
},
|
|
|
|
|
|
// 4. 交互触发:切换筛选
|
|
|
handleFilterChange() {
|
|
|
- this.queryInfo.pn = 1; // 筛选条件变了,重置回第一页
|
|
|
- this.updateRouter();
|
|
|
+ this.queryInfo.pn = 1 // 筛选条件变了,重置回第一页
|
|
|
+ this.updateRouter()
|
|
|
},
|
|
|
|
|
|
getData() {
|
|
|
- this.loading = true;
|
|
|
+ this.loading = true
|
|
|
// 注意:这里建议给后端接口也加上 scope 参数,此处假设你原有接口支持
|
|
|
getVideoPosts(this.queryInfo.pn, this.queryInfo.scope).then(resp => {
|
|
|
if (resp.code === 0) {
|
|
|
- this.dataList = resp.data.list;
|
|
|
- this.totalSize = resp.data.totalSize;
|
|
|
+ this.dataList = resp.data.list
|
|
|
+ this.totalSize = resp.data.totalSize
|
|
|
}
|
|
|
}).finally(() => {
|
|
|
- this.loading = false;
|
|
|
- });
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/* --- 其余 UI 逻辑保持不变 --- */
|
|
|
getStatusClass(status) {
|
|
|
- const map = { 1: 'warning', 2: 'success', 3: 'danger', 4: 'info' };
|
|
|
- return map[status] || 'info';
|
|
|
+ const map = { 1: 'warning', 2: 'success', 3: 'danger', 4: 'info' }
|
|
|
+ return map[status] || 'info'
|
|
|
},
|
|
|
getStatusText(status) {
|
|
|
- const map = { 1: '审核中', 2: '已发布', 3: '审核失败', 4: '已下架' };
|
|
|
- return map[status] || `未知(${status})`;
|
|
|
+ const map = { 1: '审核中', 2: '已发布', 3: '审核失败', 4: '已下架' }
|
|
|
+ return map[status] || `未知(${status})`
|
|
|
},
|
|
|
handleScope(index, row) {
|
|
|
- this.form.videoId = row.videoId;
|
|
|
- this.form.scope = '' + row.scope;
|
|
|
- this.showEditScopeDialog = true;
|
|
|
+ this.form.videoId = row.videoId
|
|
|
+ this.form.scope = '' + row.scope
|
|
|
+ this.showEditScopeDialog = true
|
|
|
},
|
|
|
handleDialogClose(done) {
|
|
|
- this.videoProp = { videoId: null, play: false };
|
|
|
- if(typeof done === 'function') done();
|
|
|
+ this.videoProp = { videoId: null, play: false }
|
|
|
+ if (typeof done === 'function') done()
|
|
|
},
|
|
|
handlePreview(index, row) {
|
|
|
videoInfo(row.videoId).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
- this.showPreviewDialog = true;
|
|
|
- this.videoProp = { videoId: res.data.videoId, play: true };
|
|
|
+ this.showPreviewDialog = true
|
|
|
+ this.videoProp = { videoId: res.data.videoId, play: true }
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
- handleEdit(index, row) {
|
|
|
- this.$router.push('/bg/post/video/edit/' + row.videoId);
|
|
|
+ handleEdit(row) {
|
|
|
+ this.editingVideo = row
|
|
|
+ this.publishVideoDiaglog = true
|
|
|
+ },
|
|
|
+ handlePost() {
|
|
|
+ this.editingVideo = null
|
|
|
+ this.publishVideoDiaglog = true
|
|
|
},
|
|
|
handleDelete(index, row) {
|
|
|
this.$confirm(`确定要删除《${row.title}》?`, '警告', {
|
|
|
@@ -274,29 +292,44 @@ export default {
|
|
|
}).then(() => {
|
|
|
deleteVideoPost(row.videoId).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
- this.$message.success('稿件已删除');
|
|
|
- this.getData();
|
|
|
+ this.$message.info('稿件已删除')
|
|
|
+ this.getData()
|
|
|
}
|
|
|
- });
|
|
|
- }).catch(() => {});
|
|
|
+ })
|
|
|
+ }).catch(() => {})
|
|
|
},
|
|
|
onUpdateScope() {
|
|
|
updateVideoScope(this.form).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
- this.showEditScopeDialog = false;
|
|
|
- this.getData();
|
|
|
- this.$message.success('可见范围已更新');
|
|
|
+ this.showEditScopeDialog = false
|
|
|
+ this.getData()
|
|
|
+ this.$message.info('可见范围已更新')
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
- onVideoPublish(videoForm) {
|
|
|
- addVideoPost(videoForm).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.publishVideoDiaglog = false;
|
|
|
- this.$message.success('投稿成功,请等待审核');
|
|
|
- this.getData();
|
|
|
- }
|
|
|
- });
|
|
|
+ onVideoPublish({ data, mode }) {
|
|
|
+ const videoForm = data
|
|
|
+ if (mode === 'edit') {
|
|
|
+ updateVideoInfo(videoForm).then(res => {
|
|
|
+ this.$message.info(res.msg)
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message.error(error.message)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ addVideoPost(videoForm).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.publishVideoDiaglog = false
|
|
|
+ this.$message.info('投稿成功,请等待审核')
|
|
|
+ this.getData()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.finishPublish()
|
|
|
+ },
|
|
|
+ finishPublish() {
|
|
|
+ this.publishVideoDiaglog = false
|
|
|
+ this.editingVideo = null
|
|
|
+ this.getData()
|
|
|
}
|
|
|
}
|
|
|
}
|