2025-04-01 18:02:41 +08:00
|
|
|
|
<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
|
2025-04-04 18:22:41 +08:00
|
|
|
|
@input="handleQuery"
|
2025-04-01 18:02:41 +08:00
|
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
2025-04-03 19:55:58 +08:00
|
|
|
|
|
|
|
|
|
<el-form-item label="广告类型" prop="type">
|
|
|
|
|
<el-select v-model="queryParams.type" placeholder="请选择广告类型" @change="handleQuery">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in dict.type.ad_type"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
2025-04-01 18:02:41 +08:00
|
|
|
|
</el-form-item>
|
2025-04-03 19:55:58 +08:00
|
|
|
|
|
2025-04-01 18:02:41 +08:00
|
|
|
|
<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">
|
2025-04-03 19:55:58 +08:00
|
|
|
|
<!-- <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-button-->
|
|
|
|
|
<!-- type="danger"-->
|
|
|
|
|
<!-- plain-->
|
|
|
|
|
<!-- icon="el-icon-delete"-->
|
|
|
|
|
<!-- size="mini"-->
|
|
|
|
|
<!-- :disabled="multiple"-->
|
|
|
|
|
<!-- @click="handleDelete"-->
|
|
|
|
|
<!-- v-has-permi="['bst:ad:remove']"-->
|
|
|
|
|
<!-- >删除</el-button>-->
|
|
|
|
|
<!-- </el-col>-->
|
2025-04-01 18:02:41 +08:00
|
|
|
|
<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" />
|
2025-04-03 19:55:58 +08:00
|
|
|
|
<el-table-column label="广告类型" align="center" prop="type">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<dict-tag :options="dict.type.ad_type" :value="scope.row.type"/>
|
|
|
|
|
</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="url" />
|
|
|
|
|
<el-table-column label="备注" align="center" prop="remark" />
|
2025-04-01 18:02:41 +08:00
|
|
|
|
<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-edit"
|
|
|
|
|
@click="handleUpdate(scope.row)"
|
|
|
|
|
v-has-permi="['bst:ad:edit']"
|
|
|
|
|
>修改</el-button>
|
2025-04-03 19:55:58 +08:00
|
|
|
|
<!-- <el-button-->
|
|
|
|
|
<!-- size="mini"-->
|
|
|
|
|
<!-- type="text"-->
|
|
|
|
|
<!-- icon="el-icon-delete"-->
|
|
|
|
|
<!-- @click="handleDelete(scope.row)"-->
|
|
|
|
|
<!-- v-has-permi="['bst:ad:remove']"-->
|
|
|
|
|
<!-- >删除</el-button>-->
|
2025-04-01 18:02:41 +08:00
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
<pagination
|
|
|
|
|
v-show="total>0"
|
|
|
|
|
:total="total"
|
|
|
|
|
:page.sync="queryParams.pageNum"
|
|
|
|
|
:limit.sync="queryParams.pageSize"
|
|
|
|
|
@pagination="getList"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<!-- 添加或修改广告对话框 -->
|
2025-04-03 19:55:58 +08:00
|
|
|
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
2025-04-01 18:02:41 +08:00
|
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
2025-04-03 19:55:58 +08:00
|
|
|
|
<el-form-item label="广告类型" prop="type">
|
|
|
|
|
<el-select v-model="form.type" placeholder="请选择广告类型">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in dict.type.ad_type"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value"
|
|
|
|
|
></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="广告图片" prop="picture">
|
|
|
|
|
<image-upload v-model="form.picture" :limit="1"/>
|
|
|
|
|
</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>
|
2025-04-01 18:02:41 +08:00
|
|
|
|
</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";
|
|
|
|
|
|
|
|
|
|
// 默认排序字段
|
|
|
|
|
const defaultSort = {
|
|
|
|
|
prop: "createTime",
|
|
|
|
|
order: "descending"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "Ad",
|
2025-04-03 19:55:58 +08:00
|
|
|
|
dicts:['ad_type','ad_url_type'],
|
2025-04-01 18:02:41 +08:00
|
|
|
|
mixins: [$showColumns],
|
|
|
|
|
components: {FormCol},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
span: 24,
|
|
|
|
|
// 字段列表
|
|
|
|
|
columns: [
|
2025-04-03 19:55:58 +08:00
|
|
|
|
{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},
|
2025-04-01 18:02:41 +08:00
|
|
|
|
{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},
|
2025-04-03 19:55:58 +08:00
|
|
|
|
//{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},
|
2025-04-01 18:02:41 +08:00
|
|
|
|
],
|
|
|
|
|
// 排序方式
|
|
|
|
|
orderSorts: ['ascending', 'descending', null],
|
|
|
|
|
// 遮罩层
|
|
|
|
|
loading: true,
|
|
|
|
|
// 选中数组
|
|
|
|
|
ids: [],
|
|
|
|
|
// 非单个禁用
|
|
|
|
|
single: true,
|
|
|
|
|
// 非多个禁用
|
|
|
|
|
multiple: true,
|
|
|
|
|
// 显示搜索条件
|
|
|
|
|
showSearch: true,
|
|
|
|
|
// 总条数
|
|
|
|
|
total: 0,
|
|
|
|
|
// 广告表格数据
|
|
|
|
|
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
|
|
|
|
|
},
|
|
|
|
|
// 表单参数
|
|
|
|
|
form: {},
|
|
|
|
|
// 表单校验
|
2025-04-03 19:55:58 +08:00
|
|
|
|
// rules: {
|
|
|
|
|
// createTime: [
|
|
|
|
|
// { required: true, message: "创建时间不能为空", trigger: "blur" }
|
|
|
|
|
// ],
|
|
|
|
|
// deleted: [
|
|
|
|
|
// { required: true, message: "逻辑删除标志,0否,1是不能为空", trigger: "blur" }
|
|
|
|
|
// ],
|
|
|
|
|
// urlType: [
|
|
|
|
|
// { required: true, message: "跳转类型,1外链跳转,2站内跳转不能为空", trigger: "change" }
|
|
|
|
|
// ]
|
|
|
|
|
// }
|
2025-04-01 18:02:41 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.getList();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
/** 当排序按钮被点击时触发 **/
|
|
|
|
|
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,
|
|
|
|
|
type: null,
|
|
|
|
|
picture: null,
|
|
|
|
|
url: null,
|
|
|
|
|
createBy: null,
|
|
|
|
|
createTime: null,
|
|
|
|
|
updateBy: null,
|
|
|
|
|
updateTime: null,
|
|
|
|
|
remark: null,
|
|
|
|
|
deleted: null,
|
|
|
|
|
urlType: null
|
|
|
|
|
};
|
|
|
|
|
this.resetForm("form");
|
|
|
|
|
},
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
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
|
|
|
|
|
getAd(adId).then(response => {
|
|
|
|
|
this.form = response.data;
|
|
|
|
|
this.open = true;
|
|
|
|
|
this.title = "修改广告";
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/** 提交按钮 */
|
|
|
|
|
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>
|