Files
tangguo_admin/src/views/videoManagement/goldCoinVideoConfig/index.vue
T
rootandClaude Opus 5 e282bd23e8 Switch to dart-sass and make deploy script fail-safe
node-sass 4.x cannot build on arm64/Node 16. Use sass with ::v-deep
instead of /deep/, and only replace the server dist after the upload
is unpacked and verified.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 19:18:37 +08:00

704 lines
19 KiB
Vue

<template>
<div class="tag-box">
<!--操作栏-->
<div class="action-bar">
<el-select
v-model="params.status"
placeholder="订单状态"
size="small"
@change="getList('status')"
clearable
>
<el-option
v-for="item in statuses"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
<el-button
type="primary"
size="small"
icon="el-icon-search"
@click="getList('status')"
style="margin-right: 20px"
>搜索</el-button
>
<el-button
type="primary"
size="small"
@click="addAndEdit('add')"
style="margin-right: 20px"
>新增</el-button
>
<!-- <el-button
type="danger"
size="small"
icon="el-icon-menu"
:disabled="isBatch"
plain
@click="openBatch"
>批量操作</el-button
> -->
</div>
<!--数据表格-->
<el-table
:data="tableData"
style="width: 100%"
border
v-loading="loading"
element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading"
ref="multipleTable"
height="600"
@selection-change="handleSelectionChange"
>
<el-table-column
type="selection"
v-if="isBatch"
width="55"
fixed="left"
align="center"
></el-table-column>
<el-table-column prop="id" label="ID" align="center" min-width="210">
<template slot-scope="scope">
<span>{{ scope.row.id || "-" }}</span>
</template>
</el-table-column>
<el-table-column
prop="vidId"
label="帖子id"
align="center"
min-width="210"
>
<template slot-scope="scope">
<span>{{ scope.row.vidId || "-" }}</span>
</template>
</el-table-column>
<el-table-column
prop="vidTitle"
label="视频标题"
align="center"
min-width="180"
>
<template slot-scope="scope">
<span>{{ scope.row.vidTitle || "-" }}</span>
</template>
</el-table-column>
<el-table-column
prop="vidType"
label="帖子类型"
align="center"
width="120"
>
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.vidType == 'SP'"
>长视频</el-tag
>
<el-tag type="warning" v-if="scope.row.vidType == 'SHORT'"
>短视频</el-tag
>
<el-tag v-if="scope.row.vidType == 'COVER'">图集</el-tag>
</template>
</el-table-column>
<el-table-column prop="coins" label="定价" align="center" min-width="120">
<template slot-scope="scope">
<span>{{ scope.row.coins }}</span>
</template>
</el-table-column>
<el-table-column
label="封面图"
align="center"
min-width="120"
prop="cover"
>
<template slot-scope="scope">
<img-load
:width="'80px'"
:height="'60px'"
:src="imgUrl + scope.row.cover"
>
</img-load>
</template>
</el-table-column>
<el-table-column
prop="seriesCover"
label="图集预览"
align="center"
width="110"
>
<template slot-scope="scope">
<div
class="picturePreview"
>
<decrypt-img
style="width: 40px; height: 40px"
:src="imgUrl + item"
fit="fill"
v-for="(item, i) in scope.row.seriesCover"
:key="i"
></decrypt-img>
</div>
</template>
</el-table-column>
<el-table-column
prop="sourceURL"
label="查看视频"
align="center"
width="80"
>
<template slot-scope="scope" v-if="scope.row.sourceURL">
<i
class="el-icon-video-play views"
title="点击播放"
@click="checkMedia(scope.row.sourceURL, 'video')"
></i>
</template>
</el-table-column>
<el-table-column
prop="name"
label="作者姓名"
align="center"
min-width="120"
>
<template slot-scope="scope">
<span>{{ scope.row.name || "-" }}</span>
</template>
</el-table-column>
<el-table-column
prop="operateAccount"
label="操作者"
align="center"
min-width="120"
>
<template slot-scope="scope">
<span>{{ scope.row.operateAccount || "-" }}</span>
</template>
</el-table-column>
<el-table-column
label="作者头像"
align="center"
min-width="120"
prop="portrait"
>
<template slot-scope="scope">
<img-load
:width="'80px'"
:height="'80px'"
:src="imgUrl + scope.row.portrait"
>
</img-load>
</template>
</el-table-column>
<el-table-column
prop="publisherID"
label="作者ID"
align="center"
min-width="120"
>
<template slot-scope="scope">
<span>{{ scope.row.publisherID || "-" }}</span>
</template>
</el-table-column>
<el-table-column
prop="reason"
label="下架理由"
align="center"
min-width="180"
>
<template slot-scope="scope">
<span>{{ scope.row.reason || "-" }}</span>
</template>
</el-table-column>
<el-table-column
prop="sortCode"
label="排序号"
align="center"
min-width="80"
>
<template slot-scope="scope">
<span>{{ scope.row.sortCode }}</span>
</template>
</el-table-column>
<el-table-column label="状态" align="center" width="120">
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.status === 1">上架</el-tag>
<el-tag v-if="scope.row.status === 2">下架</el-tag>
</template>
</el-table-column>
<el-table-column
prop="createdAt"
label="创建时间"
align="center"
min-width="180"
>
<template slot-scope="scope">
<span>{{ changeTime(scope.row.createdAt) }}</span>
</template>
</el-table-column>
<el-table-column
prop="updatedAt"
label="修改时间"
align="center"
min-width="180"
>
<template slot-scope="scope">
<span>{{ changeTime(scope.row.updatedAt) }}</span>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
min-width="180"
fixed="right"
>
<template slot-scope="scope">
<el-button
size="mini"
type="success"
icon="el-icon-edit"
@click="addAndEdit(scope.row)"
>编辑</el-button
>
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="del(scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<div style="margin: 10px 0" v-if="isBatch">
<el-button @click="giveUpBatch" type="danger" size="mini"
>取消批量操作</el-button
>
<el-button @click="openBatchDelete" type="primary" size="mini"
>批量删除</el-button
>
</div>
<!--分页组件-->
<el-pagination
:page-sizes="[10, 15, 20, 30]"
:current-page="params.pageNumber"
:page-size="params.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
background
@size-change="changeSize"
@current-change="changeCurrent"
></el-pagination>
<!-- 新增、修改 -->
<el-dialog
:title="dialogTitle"
:visible.sync="dialogVisible"
width="500px"
@before-close="handleClose"
@close="handleClose"
>
<el-form :model="form" label-width="100px" :rules="rules" ref="form">
<el-form-item
label="视频id"
prop="videoId"
v-if="dialogTitle == '新增'"
>
<el-input type="textarea" rows="5" v-model="form.videoId"></el-input>
</el-form-item>
<el-form-item label="状态:" prop="status" v-if="dialogTitle == '编辑'">
<el-select
v-model="form.status"
size="small"
placeholder="请选择状态"
>
<el-option label="上架" :value="1"></el-option>
<el-option label="下架" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item
label="排序号"
prop="sortCode"
v-if="dialogTitle == '编辑'"
>
<el-input type="text" v-model.number="form.sortCode"></el-input>
</el-form-item>
<el-form-item
label="理由"
prop="reason"
v-if="dialogTitle == '编辑' && form.status == 2"
>
<el-input type="textarea" rows="3" v-model="form.reason"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="handleClose">取 消</el-button>
<el-button type="primary" @click="onSubmit()">确 定</el-button>
</div>
</el-dialog>
<!--封面图、视频弹窗组件-->
<media-popup ref="mediaPopup"></media-popup>
<!-- 图集预览窗口 -->
<preview-picture ref="previewPicture"></preview-picture>
</div>
</template>
<script>
import API from "@/api";
import { uniteDate } from "@/utils/validator.js";
import baseConfig from "@/utils/serverUrlConfig";
import MediaPopup from "@/components/media-popup";
import PreviewPicture from "./components/previewPicture";
export default {
components: {
MediaPopup,
PreviewPicture,
},
data() {
return {
// 表格数据加载动画
loading: false,
// 列表数据
tableData: [],
total: 0,
params: {
pageNumber: 1,
pageSize: 10,
status: undefined,
},
statuses: [
{
label: "上架",
value: 1,
},
{
label: "下架",
value: 2,
},
],
imgUrl: baseConfig.imgUrl,
rules: {
videoId: [{ required: true, message: "请输入视频id", trigger: "blur" }],
},
dialogTitle: "",
dialogVisible: false,
form: {
id: undefined,
videoId: "",
status: undefined,
sortCode: 0,
reason: undefined,
},
isBatch: false,
dataIds: [],
batchUpdateDialog: false,
batchStatus: 0,
};
},
created() {
this.getList();
},
methods: {
getList(type) {
if (type === "status") {
this.params.pageNumber = 1;
}
API.getVideoGoldCoin(this.params)
.then((res) => {
if (res.code === 200 && res.data) {
this.tableData = res.data.list;
this.total = res.data.total;
} else {
this.tableData = [];
}
if (this.isBatch) {
this.restoreCheckedState();
}
this.loading = false;
})
.catch(() => {
this.loading = false;
});
},
// 新增标签配置
addAndEdit(param) {
if (param === "add") {
this.dialogTitle = "新增";
this.dialogVisible = true; // 打开新增、编辑对话框
} else {
this.dialogTitle = "编辑";
// 把数据回显给表单
this.form.id = param.id;
this.form.status = param.status;
this.form.sortCode = param.sortCode;
this.form.reason = param.reason;
this.dialogVisible = true; // 打开新增、编辑对话框
}
},
// 新增、修改提交
onSubmit() {
if (this.dialogTitle === "新增") {
this.add();
} else {
this.edit();
}
},
// 新增方法
add() {
this.$refs["form"].validate((valid) => {
if (valid) {
var videoId = this.form.videoId.toString();
//去掉空格
videoId = videoId.replace(/\s+/g, "");
//去掉换行符
videoId = videoId.replace(/[\r\n]/g, "");
//去掉两头逗号
videoId = videoId.replace(/^,+/, "").replace(/,+$/, "");
let req = {
videoId: videoId,
};
API.addVideoGoldCoin(req).then((res) => {
if (res.code === 200) {
this.$message({
type: "success",
message: "新增成功",
});
this.dialogVisible = false;
this.getList();
} else {
this.$message({
type: "error",
message: "新增失败",
});
}
});
} else {
return false;
}
});
},
// 修改方法
edit() {
this.$refs["form"].validate((valid) => {
if (valid) {
let req = {
id: this.form.id,
status: this.form.status,
sortCode: this.form.sortCode,
reason: this.form.reason,
};
API.editVideoGoldCoin(req).then((res) => {
if (res.code === 200) {
this.$message({
type: "success",
message: "编辑成功",
});
this.dialogVisible = false;
this.getList();
} else {
this.$message({
type: "error",
message: "编辑失败",
});
}
});
} else {
return false;
}
});
},
del(param) {
this.$confirm(
`确认是否删除<span style='color:blue'>${param.vidTitle}</span>, 是否继续?`,
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
dangerouslyUseHTMLString: true,
}
)
.then(() => {
let delData = {
id: param.id,
};
API.deleteVideoGoldCoin(delData).then((res) => {
if (res.code === 200) {
this.$message({
type: "success",
message: "删除成功!",
});
} else {
this.$message({
type: "success",
message: "删除失败!",
});
}
this.getList();
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
// 关闭窗口清除数据
handleClose() {
this.form.id = undefined;
this.form.videoId = "";
this.form.status = undefined;
this.form.sortCode = 0;
this.form.reason = undefined;
this.isBatch = false;
this.dataIds = [];
this.batchStatus = 0;
this.batchUpdateDialog = false;
this.$refs.multipleTable.clearSelection();
this.dialogVisible = false;
},
// 查看媒体
checkMedia(url, type) {
this.$refs.mediaPopup.open(url, type);
},
// 图集预览
previewPicture(pictureArr) {
let Arr = JSON.parse(JSON.stringify(pictureArr));
this.$refs.previewPicture.open(Arr);
},
// 分页条数改变回调
changeSize(size) {
this.params.pageSize = size;
this.getList();
},
// 分页页码改变回调
changeCurrent(pageNumber) {
this.params.pageNumber = pageNumber;
this.getList();
},
// 更换时间格式
changeTime(time) {
return uniteDate(time);
},
// *******************批量操作*********************
// 翻页时的勾选回显
restoreCheckedState() {
/**
* ①获取到当前数据表格中已经被选中的数据
*/
const indexs = this.tableData
.map((item) => {
let flag = false;
this.dataIds.forEach((value) => {
value.id === item.id ? (flag = true) : "";
});
if (flag) {
return item;
}
})
.filter((item) => item);
/**
* ②回显当前数据表格中已经被勾选过的数据
*/
this.$nextTick(() => {
indexs.forEach((rows) => {
this.$refs.multipleTable.toggleRowSelection(rows);
});
});
},
// 批量操作窗口
openBatch() {
this.isBatch = true;
},
// 取消批量操作
giveUpBatch() {
this.isBatch = false;
this.dataIds = [];
this.$refs.multipleTable.clearSelection();
},
// 打开批量删除窗口
openBatchDelete() {
if (this.dataIds.length === 0)
return this.$message.error("请至少选择一条数据");
const ids = this.dataIds.map((item) => item.id);
// 确认删除提示
this.$confirm("确定删除吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
const req = {
id: ids,
};
API.deleteUserFavorOption(req).then((res) => {
if (res.code === 200) {
this.getList();
this.handleClose();
this.$message.success("批量删除成功");
} else {
this.$message.error(res.msg);
}
});
})
.catch(() => {
this.$message.success("取消成功");
});
},
// 处理勾选时的数据
handleSelectionChange(objArr) {
/**
* 1.取消勾选时,将添加的数据从this.dataIds这个数据表里去除;
* ① 获取到当前数据列表中未勾选的数据;
* ② 从this.dataIds这个数据表中移除未勾选的数据;
*/
// ①获取到当前数据列表中未勾选的数据;
const tempTableData = JSON.parse(JSON.stringify(this.tableData));
objArr.forEach((item) => {
this.tableData.forEach((value, index) => {
if (item === value) {
tempTableData.splice(index, 1);
}
});
});
// ②从this.dataIds这个数据表中移除未勾选的数据;
tempTableData.forEach((item) => {
this.dataIds.forEach((value, index) => {
if (item.id === value.id) {
this.dataIds.splice(index, 1);
}
});
});
// 2.添加数组数据,需要去重
this.dataIds = this.dataIds.concat(objArr);
const tempDatas = new Set(this.dataIds);
this.dataIds = Array.from(tempDatas);
},
},
};
</script>
<style lang="scss" scoped>
.dialog-footer {
position: relative;
left: 50%;
-webkit-transform: translate(-50%);
transform: translate(-50%);
}
::v-deep .el-form-item__content {
display: flex;
}
::v-deep .el-select {
width: 100%;
}
.form-flex-box {
display: flex;
.el-form-item {
flex: 1;
}
}
.picturePreview {
max-width: 300px;
display: flex;
}
</style>