electripper-v2-ui/src/views/bst/ad/index.vue
2025-04-25 11:20:01 +08:00

480 lines
17 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="跳转链接" prop="url">
<el-input
v-model="queryParams.url"
placeholder="请输入跳转链接"
clearable
@input="handleQuery"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-has-permi="['bst:ad:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-has-permi="['bst:ad:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="adList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="onSortChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="广告所属" align="center" prop="belong">
<template slot-scope="scope">
<dict-tag :options="dict.type.ad_belong" :value="scope.row.belong"/>
</template>
</el-table-column>
<el-table-column label="所属运营区" align="center" prop="areaName">
<template slot-scope="scope">
<span>{{ scope.row.areaName || '-' }}</span>
</template>
</el-table-column>
<el-table-column label="广告图片" align="center" prop="picture" width="100">
<template slot-scope="scope">
<image-preview :src="scope.row.picture" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="跳转类型" align="center" prop="urlType">
<template slot-scope="scope">
<dict-tag :options="dict.type.ad_url_type" :value="scope.row.urlType"/>
</template>
</el-table-column>
<el-table-column label="审核状态" align="center" prop="auditStatus">
<template slot-scope="scope">
<dict-tag :options="dict.type.ad_audit_status" :value="scope.row.auditStatus"/>
</template>
</el-table-column>
<el-table-column label="跳转链接" align="center" prop="url" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-view"
@click="handleView(scope.row)"
v-hasPermi="['bst:ad:edit']">
{{ scope.row.auditStatus === '1' ? '审核' : '查看详情' }}
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-has-permi="['bst:ad:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-has-permi="['bst:ad:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 在index.vue的template中添加弹窗结构 -->
<el-dialog
:title="`广告详情`"
:visible.sync="detailVisible"
width="800px"
append-to-body>
<!-- 申请信息区块 -->
<div class="info-section">
<el-descriptions title="申报信息" :column="2" border>
<el-descriptions-item label="广告所属">
<dict-tag :options="dict.type.ad_belong" :value="detailForm.belong"/>
</el-descriptions-item>
<el-descriptions-item label="所属运营区">{{ detailForm.areaName }}</el-descriptions-item>
<el-descriptions-item label="广告图片" :span="2">
<image-preview :src="detailForm.picture" :width="200" />
</el-descriptions-item>
<el-descriptions-item label="跳转链接" :span="24">{{ detailForm.url }}</el-descriptions-item>
<el-descriptions-item label="跳转类型" :span="2">
<dict-tag :options="dict.type.ad_url_type" :value="detailForm.urlType"/>
</el-descriptions-item>
<el-descriptions-item label="审核状态">
<dict-tag :value="detailForm.auditStatus" :options="dict.type.ad_audit_status"/>
</el-descriptions-item>
</el-descriptions>
</div>
<!-- 审核区块 -->
<template v-if="detailForm.auditStatus === '1'">
<el-divider />
<div class="verify-area">
<el-input
v-model="verifyRemark"
type="textarea"
:rows="4"
placeholder="请输入审核意见"
style="margin:20px 0"
/>
<div class="dialog-footer" style="display: flex; justify-content: flex-end; gap: 10px;">
<el-button type="danger" @click="reject" v-hasPermi="['bst:ad:edit']">驳 回</el-button>
<el-button type="success" @click="audit" v-hasPermi="['bst:ad:edit']">通 过</el-button>
</div>
</div>
</template>
<template v-if="['0','2'].includes(detailForm.auditStatus)">
<el-divider />
<el-descriptions title="审核信息" :column="1" border>
<el-descriptions-item label="审核人">{{ detailForm.verifyName || '-' }}</el-descriptions-item>
<el-descriptions-item label="审核时间">{{ detailForm.verifyEndTime || '-' }}</el-descriptions-item>
<el-descriptions-item label="审核意见">
<pre style="white-space: pre-wrap;">{{ detailForm.verifyRemark || '无' }}</pre>
</el-descriptions-item>
</el-descriptions>
</template>
</el-dialog>
<!-- 添加或修改广告对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :rules="rules" :model="form" label-width="80px" v-loading="detailLoading">
<el-form-item label="运营区" prop="areaId" >
<area-remote-select
v-model="form.areaId"
:init-options="initAreaOptions"
v-if="!detailLoading"
placeholder="请选择运营区"
style="width: 58%"
/>
</el-form-item>
<el-form-item label="广告所属" prop="belong" v-if="isSysAdmin()">
<el-select v-model="form.belong" placeholder="请选择广告所属">
<el-option
v-for="dict in dict.type.ad_belong"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="广告图片" prop="picture">
<div class="upload-wrapper">
<image-upload v-model="form.picture" :limit="1"/>
</div>
</el-form-item>
<el-form-item label="跳转类型" prop="urlType">
<el-select v-model="form.urlType" placeholder="请选择跳转类型">
<el-option
v-for="dict in dict.type.ad_url_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="跳转链接" prop="url">
<el-input v-model="form.url" placeholder="请输入跳转链接" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listAd, getAd, delAd, addAd, updateAd } from "@/api/bst/ad";
import { $showColumns } from '@/utils/mixins';
import FormCol from "@/components/FormCol/index.vue";
import AreaRemoteSelect from "@/components/Business/Area/AreaRemoteSelect.vue";
import {isSysAdmin} from "@/utils/permission";
import {handleAudit} from "@/api/bst/ad";
// 默认排序字段
const defaultSort = {
prop: "createTime",
order: "descending"
}
export default {
name: "Ad",
dicts:['ad_type','ad_url_type','ad_belong','ad_audit_status'],
props:{
id: {
type: [String, Number],
default: null
},
},
mixins: [$showColumns],
components: {AreaRemoteSelect, FormCol},
data() {
return {
span: 24,
// 字段列表
columns: [
{key: 'adId', visible: true, label: 'ID', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'type', visible: true, label: '广告类型', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'areaName', visible: true, label: '所属运营区', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'picture', visible: true, label: '广告图片', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'url', visible: true, label: '跳转链接', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'remark', visible: true, label: '备注', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'auditStatus', visible: true, label: '审核状态', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
//{key: 'deleted', visible: true, label: '逻辑删除标志0否1是', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
//{key: 'urlType', visible: true, label: '跳转类型1外链跳转2站内跳转', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
],
rules: {
areaId: [
{ required: true, message: '运营区不能为空', trigger: 'change' }
],
picture: [
{ required: true, message: '广告图片不能为空', trigger: 'change' }
],
urlType: [
{ required: true, message: '跳转类型不能为空', trigger: 'change' }
],
url: [
{ required: true, message: '跳转链接不能为空', trigger: 'blur' },
]
},
// 排序方式
orderSorts: ['ascending', 'descending', null],
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
detailVisible: false, // 控制详情弹窗显示
detailForm: {}, // 详情数据存储
verifyRemark: '',
// 广告表格数据
adList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
defaultSort,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
orderByColumn: defaultSort.prop,
isAsc: defaultSort.order,
type: null,
picture: null,
url: null,
deleted: null,
urlType: null,
belong: null
},
// 表单参数
form: {},
detailLoading: false,
};
},
computed:{
initAreaOptions() {
return [{id: this.form.areaId, name: this.form.areaName}]
},
},
created() {
this.getList();
},
methods: {
// 审核驳回
reject() {
this.handleVerify(false);
},
// 审核通过
audit() {
this.handleVerify(true);
},
// 处理审核
handleVerify(Pass) {
if (!this.verifyRemark) {
this.$message.warning('请填写审核意见');
return;
}
const action = Pass ? '通过' : '驳回';
this.$modal.confirm(`确认${action}该申请吗?`).then(() => {
handleAudit({
id: this.detailForm.adId,
pass: Pass, // true表示通过false表示驳回
verifyRemark: this.verifyRemark
}).then(() => {
this.$modal.msgSuccess(`${action}成功`);
this.detailVisible = false;
this.getList();
});
});
},
isSysAdmin,
/** 当排序按钮被点击时触发 **/
onSortChange(column) {
if (column.order == null) {
this.queryParams.orderByColumn = defaultSort.prop;
this.queryParams.isAsc = defaultSort.order;
} else {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
}
this.getList();
},
/** 查询广告列表 */
getList() {
this.loading = true;
listAd(this.queryParams).then(response => {
this.adList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
adId: null,
areaId: null,
type: null,
picture: null,
url: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null,
deleted: null,
urlType: null
};
this.resetForm("form");
},
/** 查看详情 */
handleView(row) {
this.loading = true;
getAd(row.adId).then(response => {
this.detailForm = response.data;
this.detailVisible = true;
this.verifyRemark = '';
}).finally(() => {
this.loading = false;
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.adId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加广告";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const adId = row.adId || this.ids
this.detailLoading = true;
getAd(adId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改广告";
}).finally(() => {
this.detailLoading = false;
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.adId != null) {
updateAd(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addAd(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const adIds = row.adId || this.ids;
this.$modal.confirm('是否确认删除广告编号为"' + adIds + '"的数据项?').then(function() {
return delAd(adIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('bst/ad/export', {
...this.queryParams
}, `ad_${new Date().getTime()}.xlsx`)
}
}
};
</script>