This commit is contained in:
linfeng 2023-06-25 10:12:07 +08:00
commit f55c71889c

View File

@ -1,103 +1,41 @@
<template> <template>
<div class="mod-config"> <div class="mod-config">
<el-form <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
:inline="true"
:model="dataForm"
@keyup.enter.native="getDataList()"
>
<el-form-item> <el-form-item>
<el-input <el-input v-model="dataForm.key" placeholder="帖子内容或标题搜索" clearable></el-input>
v-model="dataForm.key"
placeholder="帖子内容或标题搜索"
clearable
></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<!-- 选择框 --> <!-- 选择框 -->
<el-select v-model="dataForm.status" clearable placeholder="请选择状态"> <el-select v-model="dataForm.status" clearable placeholder="请选择状态">
<el-option <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option> </el-option>
</el-select> </el-select>
<el-button @click="getDataList()">查询</el-button> <el-button @click="getDataList()">查询</el-button>
<el-button @click="refresh()">重置</el-button> <el-button @click="refresh()">重置</el-button>
<el-button <el-button v-if="isAuth('admin:post:delete')" type="danger" @click="deleteHandle()"
v-if="isAuth('admin:post:delete')" :disabled="dataListSelections.length <= 0">批量删除</el-button>
type="danger"
@click="deleteHandle()"
:disabled="dataListSelections.length <= 0"
>批量删除</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table <el-table :data="dataList" border v-loading="dataListLoading" @selection-change="selectionChangeHandle"
:data="dataList" style="width: 100%">
border <el-table-column type="selection" header-align="center" align="center" width="50">
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
style="width: 100%"
>
<el-table-column
type="selection"
header-align="center"
align="center"
width="50"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="id" header-align="center" align="center" label="id">
prop="id"
header-align="center"
align="center"
label="id"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="userInfo.username" header-align="center" align="center" label="用户名">
prop="userInfo.username"
header-align="center"
align="center"
label="用户名"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="userInfo.avatar" header-align="center" align="center" label="头像">
prop="userInfo.avatar"
header-align="center"
align="center"
label="头像"
>
<template slot-scope="scope"> <template slot-scope="scope">
<img <img style="width: 40px; height: 40px" :src="scope.row.userInfo.avatar" />
style="width: 40px; height: 40px"
:src="scope.row.userInfo.avatar"
/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="title" header-align="center" align="center" label="标题">
prop="title"
header-align="center"
align="center"
label="标题"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="content" header-align="center" align="center" width="200" label="内容">
prop="content"
header-align="center"
align="center"
width="200"
label="内容"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="type" header-align="center" align="center" label="帖子类型">
prop="type"
header-align="center"
align="center"
label="帖子类型"
>
<template slot-scope="scope"> <template slot-scope="scope">
<div> <div>
<el-tag v-if="scope.row.type == 1" type="success">图文</el-tag> <el-tag v-if="scope.row.type == 1" type="success">图文</el-tag>
@ -105,54 +43,20 @@
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="media" header-align="center" align="center" label="文件">
prop="media"
header-align="center"
align="center"
label="文件"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button v-if="scope.row.type == 2" type="text" @click="openVideo(scope.row.media[0])">点击预览</el-button>
v-if="scope.row.type == 2" <el-button v-if="scope.row.type == 1 && scope.row.media[0]" type="text"
type="text" @click="openPic(scope.row.media)">点击查看</el-button>
@click="openVideo(scope.row.media[0])"
>点击预览</el-button
>
<el-button
v-if="scope.row.type == 1 && scope.row.media[0]"
type="text"
@click="openPic(scope.row.media)"
>点击查看</el-button
>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="readCount" header-align="center" align="center" label="浏览量">
prop="readCount"
header-align="center"
align="center"
label="浏览量"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="commentCount" header-align="center" align="center" label="评论数">
prop="commentCount"
header-align="center"
align="center"
label="评论数"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="collectionCount" header-align="center" align="center" label="点赞数">
prop="collectionCount"
header-align="center"
align="center"
label="点赞数"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="postTop" header-align="center" align="center" label="置顶">
prop="postTop"
header-align="center"
align="center"
label="置顶"
>
<template slot-scope="scope"> <template slot-scope="scope">
<div> <div>
<el-tag v-if="scope.row.postTop == 1" type="success"></el-tag> <el-tag v-if="scope.row.postTop == 1" type="success"></el-tag>
@ -161,110 +65,42 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="address" header-align="center" align="center" label="发帖地址">
prop="address"
header-align="center"
align="center"
label="发帖地址"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="createTime" header-align="center" align="center" label="创建时间">
prop="createTime"
header-align="center"
align="center"
label="创建时间"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
fixed="right"
header-align="center"
align="center"
width="150"
label="操作"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button v-if="scope.row.status == 1 || scope.row.status == 2" type="text" size="small"
v-if="scope.row.status == 1 || scope.row.status == 2" @click="statusHandle(scope.row.id)">上架</el-button>
type="text" <el-button v-if="scope.row.status == 0" type="text" size="small"
size="small" @click="statusDownHandle(scope.row.id)">下架</el-button>
@click="statusHandle(scope.row.id)"
>上架</el-button
>
<el-button
v-if="scope.row.status == 0"
type="text"
size="small"
@click="statusDownHandle(scope.row.id)"
>下架</el-button
>
<el-button <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
type="text" <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
size="small"
@click="addOrUpdateHandle(scope.row.id)"
>修改</el-button
>
<el-button
type="text"
size="small"
@click="deleteHandle(scope.row.id)"
>删除</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-pagination <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
@size-change="sizeChangeHandle" :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
@current-change="currentChangeHandle" layout="total, sizes, prev, pager, next, jumper">
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
>
</el-pagination> </el-pagination>
<!-- 弹窗, 新增 / 修改 --> <!-- 弹窗, 新增 / 修改 -->
<add-or-update <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
v-if="addOrUpdateVisible"
ref="addOrUpdate"
@refreshDataList="getDataList"
></add-or-update>
<el-dialog <el-dialog title="视频预览" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
title="视频预览" <video class="video" :src="this.videoUrl" enable-danmu danmu-btn controls></video>
:visible.sync="dialogVisible"
width="30%"
:before-close="handleClose"
>
<video
class="video"
:src="this.videoUrl"
enable-danmu
danmu-btn
controls
></video>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button> <el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="dialogVisible = false" <el-button type="primary" @click="dialogVisible = false"> </el-button>
> </el-button
>
</span> </span>
</el-dialog> </el-dialog>
<el-dialog <el-dialog title="图片预览(点击查看)" :visible.sync="dialogVisible2" width="60%" :before-close="handleClose">
title="图片预览(点击查看)"
:visible.sync="dialogVisible2"
width="60%"
:before-close="handleClose"
>
<div class="images"> <div class="images">
<div v-for="(item, index) in media" :key="index" class="image-middle"> <div v-for="(item, index) in media" :key="index" class="image-middle">
<el-card shadow="hover" :body-style="{ padding: '10px' }"> <el-card shadow="hover" :body-style="{ padding: '10px' }">
<img <img :src="media[index]" class="image" @click="goPic(media[index])" />
:src="media[index]"
class="image"
@click="goPic(media[index])"
/>
<div style="text-align: center; padding-top: 12px"> <div style="text-align: center; padding-top: 12px">
<span>{{ index + 1 }}</span> <span>{{ index + 1 }}</span>
</div> </div>
@ -274,9 +110,7 @@
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible2 = false"> </el-button> <el-button @click="dialogVisible2 = false"> </el-button>
<el-button type="primary" @click="dialogVisible2 = false" <el-button type="primary" @click="dialogVisible2 = false"> </el-button>
> </el-button
>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
@ -316,7 +150,6 @@ export default {
label: "已下架", label: "已下架",
}, },
], ],
// value: ''
}; };
}, },
components: { components: {
@ -383,8 +216,8 @@ export default {
var ids = id var ids = id
? [id] ? [id]
: this.dataListSelections.map((item) => { : this.dataListSelections.map((item) => {
return item.id; return item.id;
}); });
this.$confirm( this.$confirm(
`确定对[id=${ids.join(",")}]进行[${id ? "删除" : "批量删除"}]操作?`, `确定对[id=${ids.join(",")}]进行[${id ? "删除" : "批量删除"}]操作?`,
"提示", "提示",
@ -418,8 +251,8 @@ export default {
var ids = id var ids = id
? [id] ? [id]
: this.dataListSelections.map((item) => { : this.dataListSelections.map((item) => {
return item.id; return item.id;
}); });
this.$confirm( this.$confirm(
`确定对[id=${ids.join(",")}]进行[${id ? "下架" : "批量下架"}]操作?`, `确定对[id=${ids.join(",")}]进行[${id ? "下架" : "批量下架"}]操作?`,
"提示", "提示",
@ -454,8 +287,8 @@ export default {
var ids = id var ids = id
? [id] ? [id]
: this.dataListSelections.map((item) => { : this.dataListSelections.map((item) => {
return item.id; return item.id;
}); });
this.$confirm( this.$confirm(
`确定对[id=${ids.join(",")}]进行[${id ? "上架" : "批量上架"}]操作?`, `确定对[id=${ids.join(",")}]进行[${id ? "上架" : "批量上架"}]操作?`,
"提示", "提示",
@ -490,7 +323,7 @@ export default {
.then((_) => { .then((_) => {
done(); done();
}) })
.catch((_) => {}); .catch((_) => { });
}, },
openVideo(url) { openVideo(url) {
this.dialogVisible = true; this.dialogVisible = true;
@ -512,11 +345,13 @@ export default {
width: 100%; width: 100%;
margin-bottom: 10px; margin-bottom: 10px;
} }
.position { .position {
margin-left: 15px; margin-left: 15px;
font-size: 30px; font-size: 30px;
font-weight: 600; font-weight: 600;
} }
/* 图片总布局,样式 */ /* 图片总布局,样式 */
.images { .images {
display: flex; display: flex;
@ -525,11 +360,13 @@ export default {
margin-right: 20px; margin-right: 20px;
flex-wrap: wrap; flex-wrap: wrap;
} }
/* 图片之间 */ /* 图片之间 */
.image-middle { .image-middle {
margin-right: 15px; margin-right: 15px;
margin-bottom: 15px; margin-bottom: 15px;
} }
/* 单张图片样式 */ /* 单张图片样式 */
.image { .image {
width: 110px; width: 110px;