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>
585 lines
16 KiB
Vue
585 lines
16 KiB
Vue
<template>
|
|
<div class="tag-box">
|
|
<!--操作栏-->
|
|
<div class="action-bar">
|
|
<el-select
|
|
placeholder="请选择折扣专区"
|
|
clearable
|
|
size="small"
|
|
v-model="params.discountAreaId"
|
|
@change="getList('status')"
|
|
style="width: 220px;"
|
|
>
|
|
<el-option
|
|
:label="item.title"
|
|
:value="item.id"
|
|
v-for="item in discountAreas"
|
|
:key="item.id"
|
|
></el-option>
|
|
</el-select>
|
|
<el-input
|
|
v-model="params.vid"
|
|
placeholder="请输入视频ID"
|
|
clearable
|
|
size="small"
|
|
class="param-input"
|
|
style="width: 220px"
|
|
></el-input>
|
|
<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="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="title" label="标题" align="center" min-width="250">
|
|
<template slot-scope="scope">
|
|
<span>{{ scope.row.title || "-" }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="videoID" label="视频ID" align="center" min-width="250">
|
|
<template slot-scope="scope">
|
|
<span>{{ scope.row.videoID || "-" }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="cover" label="封面图" align="center" min-width="250">
|
|
<template slot-scope="scope">
|
|
<span v-if="!scope.row.cover">暂无封面图</span>
|
|
<div
|
|
v-else
|
|
class="picturePreview"
|
|
>
|
|
<decrypt-img
|
|
style="width: 80px; height: 80px"
|
|
:src="imgUrl + scope.row.cover"
|
|
fit="fill"
|
|
></decrypt-img>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="discountAreaId" label="折扣专区ID" align="center" min-width="250">
|
|
<template slot-scope="scope">
|
|
<span>{{ scope.row.discountAreaId || "-" }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="discountAreaTitle" label="折扣专区标题" align="center" min-width="250">
|
|
<template slot-scope="scope">
|
|
<span>{{ scope.row.discountAreaTitle || "-" }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="discountedPrice" label="折扣价" align="center" min-width="250">
|
|
<template slot-scope="scope">
|
|
<span>{{ scope.row.discountedPrice || 0 }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="originalPrice" label="原价" align="center" min-width="250">
|
|
<template slot-scope="scope">
|
|
<span>{{ scope.row.originalPrice || 0 }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="publisherID" label="发布者ID" align="center" min-width="250">
|
|
<template slot-scope="scope">
|
|
<span>{{ scope.row.publisherID || '-' }}</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="600px"
|
|
@before-close="handleClose"
|
|
@close="handleClose"
|
|
>
|
|
<el-form :model="form" label-width="100px" :rules="rules" ref="form">
|
|
<el-form-item label="折扣专区" prop="discountAreaId" style="width: 480px">
|
|
<el-select
|
|
placeholder="请选择折扣专区"
|
|
clearable
|
|
size="small"
|
|
v-model="form.discountAreaId"
|
|
>
|
|
<el-option
|
|
:label="item.title"
|
|
:value="item.id"
|
|
v-for="item in discountAreas"
|
|
:key="item.id"
|
|
></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item
|
|
label="视频ID:"
|
|
size="small"
|
|
prop="videoIDs"
|
|
style="width: 480px"
|
|
>
|
|
<el-input
|
|
type="textarea"
|
|
rows="5"
|
|
v-model="form.videoIDs"
|
|
placeholder="请输入播单ID,多个播单ID请用空格隔开"
|
|
></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>
|
|
<el-dialog :visible.sync="dialogVisiblePreview">
|
|
<img width="100%" :src="dialogImageUrl" alt="" />
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import API from "@/api";
|
|
import { uniteDate } from "@/utils/validator.js";
|
|
import baseConfig from "@/utils/serverUrlConfig";
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
// 表格数据加载动画
|
|
loading: false,
|
|
// 列表数据
|
|
tableData: [],
|
|
total: 0,
|
|
params: {
|
|
pageNumber: 1,
|
|
pageSize: 10,
|
|
vid: undefined,
|
|
discountAreaId: undefined,
|
|
},
|
|
discountAreas: [], // 折扣专区
|
|
dialogImageUrl: undefined, // 放大图地址
|
|
dialogVisiblePreview: false, // 放大图
|
|
imgUrl: baseConfig.imgUrl,
|
|
rules: {
|
|
discountAreaId: [{ required: true, message: "请输入折扣专区ID", trigger: "blur" }],
|
|
videoIDs: [{ required: true, message: "请输入视频ID", trigger: "blur" }],
|
|
},
|
|
dialogTitle: "",
|
|
dialogVisible: false,
|
|
form: {
|
|
id: undefined,
|
|
discountAreaId: undefined, // 折扣专区id
|
|
videoIDs: undefined, // 视频ID
|
|
vids: "", // 视频ID
|
|
},
|
|
isBatch: false,
|
|
dataIds: [],
|
|
batchUpdateDialog: false,
|
|
batchStatus: 0,
|
|
};
|
|
},
|
|
created() {
|
|
this.getList();
|
|
this.getDiscountAreasList();
|
|
},
|
|
methods: {
|
|
handlePictureCardPreview(file) {
|
|
this.dialogImageUrl = file.url;
|
|
this.dialogVisiblePreview = true;
|
|
},
|
|
getDiscountAreasList() {
|
|
API.getDiscountAreaList()
|
|
.then((res) => {
|
|
if (res.code === 200 && res.data) {
|
|
this.discountAreas = res.data.list || [];
|
|
} else {
|
|
this.discountAreas = [];
|
|
}
|
|
});
|
|
},
|
|
getList(type) {
|
|
if (type === "status") {
|
|
this.params.pageNumber = 1;
|
|
}
|
|
API.getDiscountAreaVideoList(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) {
|
|
this.dialogVisible = true; // 打开新增、编辑对话框
|
|
if (param === "add") {
|
|
this.dialogTitle = "新增";
|
|
} else {
|
|
this.dialogTitle = "编辑";
|
|
// 把数据回显给表单
|
|
this.form.id = param.id;
|
|
this.form.discountAreaId = param.discountAreaId;
|
|
this.form.videoIDs = param.videoIDs;
|
|
this.form.vids = param.vids;
|
|
}
|
|
},
|
|
// 新增、修改提交
|
|
onSubmit() {
|
|
if (this.dialogTitle === "新增") {
|
|
this.add();
|
|
} else {
|
|
this.edit();
|
|
}
|
|
},
|
|
// 新增方法
|
|
add() {
|
|
this.$refs["form"].validate((valid) => {
|
|
if (valid) {
|
|
var videoIDs = this.form.videoIDs
|
|
.toString()
|
|
.replace(/\s+/g, "\n");
|
|
this.form.vids = videoIDs.split("\n");
|
|
this.form.videoIDs = "";
|
|
API.addDiscountAreaVideo(this.form).then((res) => {
|
|
if (res.code === 200) {
|
|
this.$message({
|
|
type: "success",
|
|
message: "新增成功",
|
|
});
|
|
this.dialogVisible = false;
|
|
this.getList();
|
|
} else {
|
|
this.$message({
|
|
type: "error",
|
|
message: res.msg || res.data || "新增失败",
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
return false;
|
|
}
|
|
});
|
|
},
|
|
// 修改方法
|
|
edit() {
|
|
this.$refs["form"].validate((valid) => {
|
|
if (valid) {
|
|
API.updateDiscountAreaVideo(this.form).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.title}</span>, 是否继续?`,
|
|
"提示",
|
|
{
|
|
confirmButtonText: "确定",
|
|
cancelButtonText: "取消",
|
|
type: "warning",
|
|
dangerouslyUseHTMLString: true,
|
|
}
|
|
)
|
|
.then(() => {
|
|
let delData = {
|
|
ids: [param.id],
|
|
};
|
|
API.deleteDiscountAreaVideo(delData).then((res) => {
|
|
if (res.code === 200) {
|
|
this.$message({
|
|
type: "success",
|
|
message: "删除成功!",
|
|
});
|
|
} else {
|
|
this.$message({
|
|
type: "success",
|
|
message: res.msg || res.tip || res.data || "删除失败!",
|
|
});
|
|
}
|
|
this.getList();
|
|
});
|
|
})
|
|
.catch(() => {
|
|
this.$message({
|
|
type: "info",
|
|
message: "已取消删除",
|
|
});
|
|
});
|
|
},
|
|
// 关闭窗口清除数据
|
|
handleClose() {
|
|
this.form.id = undefined;
|
|
this.form.discountAreaId = undefined;
|
|
this.form.videoIDs = undefined;
|
|
this.form.vids = undefined;
|
|
this.isBatch = false;
|
|
this.dataIds = [];
|
|
this.batchStatus = 0;
|
|
this.batchUpdateDialog = false;
|
|
this.$refs.multipleTable.clearSelection();
|
|
this.dialogVisible = false;
|
|
},
|
|
// 分页条数改变回调
|
|
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 = {
|
|
ids: ids,
|
|
};
|
|
API.deleteDiscountAreaVideo(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;
|
|
}
|
|
}
|
|
.itemBox {
|
|
position: relative;
|
|
.itemTip {
|
|
font-size: 14px;
|
|
color: red;
|
|
position: absolute;
|
|
left: 100px;
|
|
bottom: -20px;
|
|
}
|
|
}
|
|
</style>
|