123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- <template>
- <div class="bannerManage app-container">
- <div class="search">
- <div>
- <el-input
- v-model="query.bannerName"
- size="small"
- placeholder="请输入名称"
- class="item-width-200 "
- ></el-input>
- <el-select
- v-model="query.menuId"
- size="small"
- clearable
- class="item-width-200 ml10"
- placeholder="请选择栏目"
- >
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- <el-select
- v-model="platformType"
- multiple
- size="small"
- clearable
- class="item-width-200 ml10"
- placeholder="请选择所属平台"
- >
- <el-option
- v-for="item in masterShopOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- <el-button
- class="ml10"
- type="primary"
- size="small"
- icon="el-icon-search"
- @click="handleSearch"
- >
- 搜索
- </el-button>
- </div>
- <el-button class="add-btn" type="primary" size="small" @click="handleAdd"
- >添加</el-button
- >
- </div>
- <el-table
- :data="tableData"
- tooltip-effect="dark"
- border
- v-loading="loading"
- style="width: 100%"
- >
-
- <el-table-column
- prop="bannerName"
- align="center"
- label="名称"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column
- prop="createTime"
- align="center"
- label="banner图"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <img class="icon" :src="scope.row.bannerImg" alt="">
- </template>
- </el-table-column>
- <el-table-column
- prop="menuId"
- align="center"
- label="栏目"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <span>{{scope.row.menuId |filterMenu(that)}}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="accountChildType"
- align="center"
- label="所属平台"
- fit
- >
- <template slot-scope="scope">
- {{filterMasterName(scope.row.platformType )}}
- </template>
- </el-table-column>
- <el-table-column
- prop="jumpUrl"
- align="center"
- label="跳转链接"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <span>{{scope.row.jumpUrl || '-'}}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="sort"
- align="center"
- label="权重"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column prop="address" align="center" label="操作">
- <template slot-scope="scope">
- <el-button type="text" size="small" @click="handleEdit(scope.row)">编辑</el-button>
- <el-button type="text" size="small" @click="handleDel(scope.row.id)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div class="page-box">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- background
- :current-page="query.currentPage"
- :page-sizes="[10, 20, 30, 40]"
- :page-size="query.pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- >
- </el-pagination>
- </div>
- </div>
- </template>
-
- <script>
- import { debounce } from "@/utils/index";
- import {bannerList,delBanner,getMenuName } from '@/api/appConfig'
- export default {
- name: "bannerManage",
- data() {
- return {
- that:this,
- tableData: [],
- options: [],
- loading: false,
- platformType:"",
- query: {
- platformType:null,
- menuId: "",
- bannerName: "",
- currentPage: 1,
- pageSize: 10,
- },
- title: "",
- total: 0,
- };
- },
- watch: {
- platformType(val) {
- if(val.length){
- this.query.platformType = val.join(',')
- }else{
- this.query.platformType = null
- }
- }
- },
- filters: {
- filterMenu: function(value,that) {
- let msg
- that.options.map(item=>{
- if(item.value == value){
- msg = item.label
- }
- })
- return msg;
- }
- },
- methods: {
- handleSearch(){
- this.query.currentPage = 1
- this.bannerList();
- },
- handleEdit(row){
- sessionStorage.setItem('bannerItem',JSON.stringify(row))
- // this.$router.push('/operationManage/bannerManage/editBanner')
- this.$router.push({
- path:'/operationManage/bannerManage/addBanner',
- query:{
- title:'编辑banner',
- }
- })
- },
- handleAdd(){
- this.$router.push({
- path:'/operationManage/bannerManage/addBanner',
- })
- },
- // 删除
- handleDel(id) {
- this.$confirm(`此操作将删除该数据, 是否继续?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- delBanner({bannerId:id}).then(res=>{
- if(res.state == 'Success'){
- this.$notify({
- title: '成功',
- message: '操作成功',
- type: 'success'
- });
- this.bannerList()
- }
- })
- })
- },
- handleSizeChange(val) {
- this.query.currentPage = 1;
- this.query.pageSize = val;
- this.bannerList()
- },
- handleCurrentChange(val) {
- this.query.currentPage = val;
- this.bannerList()
- },
- bannerList(){
- this.loading = true
- bannerList(this.query).then(res=>{
- this.loading = false
- if(res.state == 'Success'){
- this.tableData = res.content.records
- this.total = res.content.total
- }
- })
- },
- // 获取分类列表
- getMenuName(){
- getMenuName().then(res=>{
- if(res.state == 'Success'){
- for (const key in res.content) {
- if (res.content.hasOwnProperty.call(res.content, key)) {
- this.options.push({
- label:res.content[key],
- value:key
- })
- }
- }
- }
- })
- }
- },
- created() {
- this.getMenuName()
- this.bannerList()
- },
- };
- </script>
-
- <style lang="scss" scoped>
- .bannerManage {
- .search{
- justify-content: space-between;
- }
- .icon{
- width: 120px;
- height: 80px;
- }
- }
- </style>
-
|