月木学途开发 5.轮播图模块

news2024/11/28 14:48:52

概述

效果图

 

数据库设计

轮播图表
DROP TABLE IF EXISTS `banner`;
CREATE TABLE `banner` (
  `bannerId` int(11) NOT NULL AUTO_INCREMENT,
  `bannerUrl` longtext,
  `bannerDesc` varchar(255) DEFAULT NULL,
  `bannerTypeId` int(11) DEFAULT NULL,
  PRIMARY KEY (`bannerId`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;

轮播图类型表
DROP TABLE IF EXISTS `banner_type`;
CREATE TABLE `banner_type` (
  `bannerTypeId` int(11) NOT NULL AUTO_INCREMENT,
  `bannerTypeName` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`bannerTypeId`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;

实体类设计

轮播图
package jkw.pojo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import java.io.Serializable;

/**
 * 轮播图
 */
@Data
public class Banner implements Serializable {
    @TableId
    private Integer bannerId;
    private String bannerUrl;//图片
    private String bannerDesc;//描述

    private Integer bannerTypeId;//类型
    @TableField(exist = false)
    private BannerType bannerType;
}

轮播图类型
package jkw.pojo;

import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import java.io.Serializable;

/**
 * 轮播图类型
 */
@Data
public class BannerType implements Serializable {
    @TableId
    private Integer bannerTypeId;
    private String bannerTypeName;//类型名
}

Mapper层开发

BannerTypeMapper
package jkw.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jkw.pojo.BannerType;

public interface BannerTypeMapper extends BaseMapper<BannerType> {
}

BannerMapper
package jkw.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jkw.pojo.Banner;

public interface BannerMapper extends BaseMapper<Banner> {
}

Service层开发

BannerTypeService
package jkw.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jkw.pojo.BannerType;

import java.util.List;

public interface BannerTypeService {
    void add(BannerType BannerType);

    void update(BannerType BannerType);

    void delete(Integer id);

    BannerType findById(Integer id);

    List<BannerType> findAll();

    Page<BannerType> search(String search, int page, int size);
}

BannerTypeServiceImpl
package jkw.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jkw.mapper.BannerTypeMapper;
import jkw.pojo.BannerType;
import jkw.service.BannerTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BannerTypeServiceImpl implements BannerTypeService {
    @Autowired
    private BannerTypeMapper bannerTypeMapper;

    @Override
    public void add(BannerType BannerType) {
        bannerTypeMapper.insert(BannerType);
    }

    @Override
    public void update(BannerType BannerType) {
        bannerTypeMapper.updateById(BannerType);
    }

    @Override
    public void delete(Integer id) {
        bannerTypeMapper.deleteById(id);
    }

    @Override
    public BannerType findById(Integer id) {
        return bannerTypeMapper.selectById(id);
    }

    @Override
    public List<BannerType> findAll() {
        return bannerTypeMapper.selectList(null);
    }

    @Override
    public Page<BannerType> search(String search, int page, int size) {
        QueryWrapper queryWrapper = new QueryWrapper();
        if (search != null) {

        }
        return bannerTypeMapper.selectPage(new Page<>(page, size), queryWrapper);
    }
}

BannerService
package jkw.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jkw.pojo.Banner;

import java.util.List;

public interface BannerService {
    void add(Banner Banner);

    void update(Banner Banner);

    void delete(Integer id);

    Banner findById(Integer id);

    List<Banner> findAll();

    Page<Banner> search(String search, int page, int size);
}

BannerServiceImpl
package jkw.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jkw.mapper.BannerMapper;
import jkw.pojo.Banner;
import jkw.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BannerServiceImpl implements BannerService {
    @Autowired
    private BannerMapper bannerMapper;

    @Override
    public void add(Banner Banner) {
        bannerMapper.insert(Banner);
    }

    @Override
    public void update(Banner Banner) {
        bannerMapper.updateById(Banner);
    }

    @Override
    public void delete(Integer id) {
        bannerMapper.deleteById(id);
    }

    @Override
    public Banner findById(Integer id) {
        return bannerMapper.selectById(id);
    }

    @Override
    public List<Banner> findAll() {
        return bannerMapper.selectList(null);
    }

    @Override
    public Page<Banner> search(String search, int page, int size) {
        QueryWrapper queryWrapper = new QueryWrapper();
        if (search != null) {

        }
        return bannerMapper.selectPage(new Page<>(page, size), queryWrapper);
    }
}

控制层开发

BannerTypeCon
package jkw.controller.back;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jkw.pojo.BannerType;
import jkw.service.BannerTypeService;
import jkw.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/back/bannerType")
public class BannerTypeCon {
    @Autowired
    private BannerTypeService bannerTypeService;

    /**
     * 新增
     *
     * @param bannerType
     * @return
     */
    @PostMapping("/add")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult add(BannerType bannerType) {
        bannerTypeService.add(bannerType);
        return BaseResult.ok();
    }

    /**
     * 修改
     *
     * @param bannerType
     * @return
     */
    @PostMapping("/update")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult update(BannerType bannerType) {
        bannerTypeService.update(bannerType);
        return BaseResult.ok();
    }

    /**
     * 删除
     *
     * @param bannerTypeId
     * @return
     */
    @DeleteMapping("/delete")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult delete(Integer bannerTypeId) {
        bannerTypeService.delete(bannerTypeId);
        return BaseResult.ok();
    }

    /**
     * 根据id查询
     *
     * @param bannerTypeId
     * @return
     */
    @GetMapping("/findById")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult findById(Integer bannerTypeId) {
        BannerType bannerType = bannerTypeService.findById(bannerTypeId);
        return BaseResult.ok(bannerType);
    }

    /**
     * 查询所有
     *
     * @return
     */
    @GetMapping("/findAll")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult findAll() {
        List<BannerType> all = bannerTypeService.findAll();
        return BaseResult.ok(all);
    }

    /**
     * 分页查询
     *
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/search")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult search(String search, int page, int size) {
        Page<BannerType> brandPage = bannerTypeService.search(search, page, size);
        return BaseResult.ok(brandPage);
    }
}

BannerCon
package jkw.controller.back;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jkw.pojo.Banner;
import jkw.service.BannerService;
import jkw.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/back/banner")
@CrossOrigin
@RestController
public class BannerCon {
    @Autowired
    private BannerService bannerService;

    /**
     * 新增
     *
     * @param banner
     * @return
     */
    @PostMapping("/add")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult add(Banner banner) {
        bannerService.add(banner);
        return BaseResult.ok();
    }

    /**
     * 修改
     *
     * @param banner
     * @return
     */
    @PostMapping("/update")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult update(Banner banner) {
        bannerService.update(banner);
        return BaseResult.ok();
    }

    /**
     * 删除
     *
     * @param bannerId
     * @return
     */
    @DeleteMapping("/delete")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult delete(Integer bannerId) {
        bannerService.delete(bannerId);
        return BaseResult.ok();
    }

    /**
     * 根据id查询
     *
     * @param bannerId
     * @return
     */
    @GetMapping("/findById")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult findById(Integer bannerId) {
        Banner banner = bannerService.findById(bannerId);
        return BaseResult.ok(banner);
    }

    /**
     * 查询所有
     *
     * @return
     */
    @GetMapping("/findAll")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult findAll() {
        List<Banner> all = bannerService.findAll();
        return BaseResult.ok(all);
    }

    /**
     * 分页查询
     *
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/search")
    @PreAuthorize("hasAnyAuthority('/website/banner')")
    public BaseResult search(String search, int page, int size) {
        Page<Banner> brandPage = bannerService.search(search, page, size);
        return BaseResult.ok(brandPage);
    }
}

后台ui设计

BannerType.vue
<template>
  <div class="data-container">
    <!--添加 start-->
    <div class="data-header">
      <el-input class="input" @keyup.enter="searchHandle" v-model="searchInfo" size="large"
                placeholder="请输入关键字"></el-input>
      <el-button @click="searchHandle" class="button" size="large" type="primary" plain>搜索</el-button>
      <el-button round @click="addHander" size="large" type="primary">
        <el-icon>
          <DocumentAdd/>
        </el-icon>
        <span>新增</span>
      </el-button>
    </div>
    <!--添加 end-->
    <!--表格数据展示 start-->
    <div class="data-table">
      <el-table :data="dataList.list" style="width: 550px;">
        <el-table-column show-overflow-tooltip label="类型名" prop="bannerTypeName" align="center" width="300"></el-table-column>
        <el-table-column label="操作" align="center" width="220">
          <template #default="scope">
            <el-button size="small" type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
            <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--分页 start-->
      <div class="page">
        <el-pagination background
                       layout="prev,pager,next,jumper"
                       :default-page-size="defaultPageSize"
                       :total="totalData"
                       @current-change="currentChangeHaddler"></el-pagination>
      </div>
      <!--分页 end-->
    </div>
    <!--表格数据展示 end-->
    <!--添加对话框 start-->
    <el-dialog draggable destroy-on-close v-model="dialogAddVisible" title="添加" width="35%" center>
      <el-form inline :model="addFormInfo" label-width="150px">
        <el-form-item label="类型名">
          <el-input v-model="addFormInfo.bannerTypeName"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogAddVisible = false">取消</el-button>
                <el-button type="primary" @click="sureHandler">确定</el-button>
            </span>
      </template>
    </el-dialog>
    <!--添加对话框 end-->
    <!--编辑对话框 start-->
    <!--destroy-on-close:每次关闭对话框时直接销毁对话框,没有缓存-->
    <el-dialog
        draggable
        destroy-on-close
        v-model="dialogEditorVisible"
        title="编辑"
        width="35%"
        center>
      <el-form inline :model="editorFormInfo" label-width="150px">
        <el-form-item label="类型名">
          <el-input v-model="editorFormInfo.bannerTypeName"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogEditorVisible = false">取消</el-button>
                <el-button type="primary" @click="sureEditorHandler">确定</el-button>
            </span>
      </template>
    </el-dialog>
    <!--编辑对话框 end-->
  </div>
</template>

<script setup>
import axios from "../../api/index.js"
import {onMounted, reactive, ref} from "vue";
import {ElMessage} from "element-plus";
//初始化分页查询数据
const dataList = reactive({
  list: []
})
//初始化总条数
const totalData = ref(0)
//当前页
const currentPage = ref(1)
//初始化分页显示条数
const defaultPageSize = ref(10)
//搜索初始化状态
const searchInfo = ref("")
//添加添加对话框控制器
const dialogAddVisible = ref(false)
//初始化添加对话框状态
const addFormInfo = reactive({
  bannerTypeName: "",
})
//编辑对话框控制器
const dialogEditorVisible = ref(false)
//初始化编辑对话框状态
const editorFormInfo = reactive({
  bannerTypeId: '',
  bannerTypeName: "",
})
/**
 * 网路请求:分页查询
 *  */
const http = (search, page, size) => {
  axios.banner_type_search({
    search: search,
    page: page,
    size: size
  }).then(res => {
    if (res.data.code == 200) {
      dataList.list = res.data.data.records
      totalData.value = res.data.data.total
    } else {
      ElMessage.error(res.data.message)
    }

  })
}
onMounted(() => {
  http(searchInfo.value, currentPage.value, defaultPageSize.value)
})
/**
 * 分页
 */
const currentChangeHaddler = (nowPage) => {
  http(searchInfo.value, nowPage, defaultPageSize.value)
  currentPage.value = nowPage
}
/**
 * 搜索按钮
 */
const searchHandle = () => {
  http(searchInfo.value, currentPage.value, defaultPageSize.value)
}
/**
 * 添加对话框弹出事件
 */
const addHander = () => {
  dialogAddVisible.value = true
}
/**
 * 添加对话框 确定事件
 */
const sureHandler = () => {
  axios.banner_type_add({
    bannerTypeName: addFormInfo.bannerTypeName,
  }).then(res => {
    if (res.data.code == 200) {
      dialogAddVisible.value = false
      http(searchInfo.value, currentPage.value, defaultPageSize.value)
    } else {
      ElMessage.error(res.data.message)
    }
  })
}
/**
 * 编辑对话框 弹出事件
 *  */
const handleEdit = (index, row) => {

  dialogEditorVisible.value = true
  axios.banner_type_findById({
    bannerTypeId: row.bannerTypeId
  }).then(res => {
    if (res.data.code == 200) {
      editorFormInfo.bannerTypeId = res.data.data.bannerTypeId;
      editorFormInfo.bannerTypeName = res.data.data.bannerTypeName;
    } else {
      ElMessage.error(res.data.data.message)
    }
  })

}
/**
 * 编辑对话框 确定事件
 */
const sureEditorHandler = () => {
  axios.banner_type_update({
    bannerTypeId: editorFormInfo.bannerTypeId,
    bannerTypeName: editorFormInfo.bannerTypeName,
  }).then(res => {
    if (res.data.code == 200) {
      dialogEditorVisible.value = false
      http(searchInfo.value, currentPage.value, defaultPageSize.value)
    } else {
      ElMessage.error(res.data.message)
    }
  })
}
/**删除 */
const handleDelete = (index, row) => {
  ElMessageBox.confirm(
      '确定删除么',
      '删除',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }
  ).then(() => {
    //确认删除
    axios.banner_type_delete({
      bannerTypeId: row.bannerTypeId
    }).then(res => {
      if (res.data.code == 200) {
        ElMessage({
          type: 'success',
          message: "删除成功!!!",
        })
        //刷新
        http(searchInfo.value, currentPage.value, defaultPageSize.value)
      } else {
        ElMessage({
          type: 'error',
          message: res.data.message,
        })
      }
    })
  }).catch(error => {
    ElMessage({
      type: 'info',
      message: "取消删除",
    })
  })


}
</script>
<style scoped>
.data-container {
  background: linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);
  background: -o-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);
  background: -ms-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);
  background: -moz-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);
  background: -webkit-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);
  height: 800px;
}

.data-header {
  padding: 20px;
}

.data-header .input {
  width: 300px;
}

.data-table {
  padding: 20px;
}

.page {
  position: fixed;
  right: 10px;
  bottom: 10px;
}
</style>

Banner.vue
<template>
  <div class="data-container">
    <!--添加 start-->
    <div class="data-header">
      <el-input class="input" @keyup.enter="searchHandle" v-model="searchInfo" size="large"
                placeholder="请输入关键字"></el-input>
      <el-button @click="searchHandle" class="button" size="large" type="primary" plain>搜索</el-button>
      <el-button round @click="addHander" size="large" type="primary">
        <el-icon>
          <DocumentAdd/>
        </el-icon>
        <span>新增</span>
      </el-button>
    </div>
    <!--添加 end-->
    <!--表格数据展示 start-->
    <div class="data-table">
      <el-table :data="dataList.list" style="width: 800px;">
        <el-table-column label="图片" prop="bannerUrl" align="center">
          <template #default="scope">
            <img :src="scope.row.bannerUrl" style="height:60px"/>
          </template>
        </el-table-column>
        <el-table-column label="类型" prop="bannerTypeId" align="center">
          <template #default="scope">
                  <span v-for="item in typeList.list" :key="item.bannerTypeId">
                      {{ scope.row.bannerTypeId == item.bannerTypeId ? item.bannerTypeName : '' }}
                  </span>
          </template>
        </el-table-column>
        <el-table-column show-overflow-tooltip label="描述" prop="bannerDesc" align="center"></el-table-column>
        <el-table-column label="操作" align="center" width="220">
          <template #default="scope">
            <el-button size="small" type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
            <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--分页 start-->
      <div class="page">
        <el-pagination background
                       layout="prev,pager,next,jumper"
                       :default-page-size="defaultPageSize"
                       :total="totalData"
                       @current-change="currentChangeHaddler"></el-pagination>
      </div>
      <!--分页 end-->
    </div>
    <!--表格数据展示 end-->
    <!--添加对话框 start-->
    <el-dialog draggable destroy-on-close v-model="dialogAddVisible" title="添加" width="35%" center>
      <el-form inline :model="addFormInfo" label-width="150px">
        <el-form-item label="图片">
          <el-upload list-type="picture-card"
                     :action="uploadStore.fastdfsUploadUrl"
                     :on-success="onHeadImageAddSuccess"
                     :on-remove="onHeadImageAddRemove">
            <el-icon>
            </el-icon>
          </el-upload>
        </el-form-item>
        <el-form-item label="类型">
          <el-select v-model="addFormInfo.bannerTypeId" placeholder="请选择类型" size="large">
            <el-option v-for="item in typeList.list" :key="item.bannerTypeId"
                       :label="item.bannerTypeName"
                       :value="item.bannerTypeId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="描述">
          <el-input type="textarea" rows="6" style="width: 200px" v-model="addFormInfo.bannerDesc"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogAddVisible = false">取消</el-button>
                <el-button type="primary" @click="sureHandler">确定</el-button>
            </span>
      </template>
    </el-dialog>
    <!--添加对话框 end-->
    <!--编辑对话框 start-->
    <!--destroy-on-close:每次关闭对话框时直接销毁对话框,没有缓存-->
    <el-dialog
        draggable
        destroy-on-close
        v-model="dialogEditorVisible"
        title="编辑"
        width="35%"
        center>
      <el-form inline :model="editorFormInfo" label-width="150px">
        <el-form-item label="头图">
          <el-upload list-type="picture-card"
                     :action="uploadStore.fastdfsUploadUrl"
                     :on-success="onHeadImageEditSuccess"
          >
            <el-image :src="editorFormInfo.bannerUrl"/>

          </el-upload>
        </el-form-item>
        <el-form-item label="类型">
          <el-select v-model="editorFormInfo.bannerTypeId" placeholder="请选择类型" size="large">
            <el-option v-for="item in typeList.list" :key="item.bannerTypeId"
                       :label="item.bannerTypeName"
                       :value="item.bannerTypeId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="描述">
          <el-input type="textarea" rows="6" style="width: 200px" v-model="editorFormInfo.bannerDesc"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogEditorVisible = false">取消</el-button>
                <el-button type="primary" @click="sureEditorHandler">确定</el-button>
            </span>
      </template>
    </el-dialog>
    <!--编辑对话框 end-->
  </div>
</template>

<script setup>
import axios from "../../api/index.js"
import {onMounted, reactive, ref} from "vue";
import {ElMessage} from "element-plus";
import {useUploadStore} from "../../stores/uploadStore.js"

const uploadStore = useUploadStore()
//初始化分页查询数据
const dataList = reactive({
  list: []
})
//初始化类型列表
const typeList = reactive({
  list: []
})
//初始化总条数
const totalData = ref(0)
//当前页
const currentPage = ref(1)
//初始化分页显示条数
const defaultPageSize = ref(10)
//搜索初始化状态
const searchInfo = ref("")
//添加添加对话框控制器
const dialogAddVisible = ref(false)
//初始化添加对话框状态
const addFormInfo = reactive({
  bannerUrl: "",
  bannerDesc: "",
  bannerTypeId: ''
})
//编辑对话框控制器
const dialogEditorVisible = ref(false)
//初始化编辑对话框状态
const editorFormInfo = reactive({
  bannerId: '',
  bannerUrl: "",
  bannerDesc: "",
  bannerTypeId: ''
})
/**
 * 网路请求:分页查询
 *  */
const http = (search, page, size) => {
  axios.banner_search({
    search: search,
    page: page,
    size: size
  }).then(res => {
    if (res.data.code == 200) {
      dataList.list = res.data.data.records
      totalData.value = res.data.data.total
    } else {
      ElMessage.error(res.data.message)
    }

  })
}
onMounted(() => {
  http(searchInfo.value, currentPage.value, defaultPageSize.value)
  axios.banner_type_findAll().then(res => {
    if (res.data.code == 200) {
      typeList.list = res.data.data
    }
  })
})
/**
 * 分页
 */
const currentChangeHaddler = (nowPage) => {
  http(searchInfo.value, nowPage, defaultPageSize.value)
  currentPage.value = nowPage
}
/**
 * 搜索按钮
 */
const searchHandle = () => {
  http(searchInfo.value, currentPage.value, defaultPageSize.value)
}
/**
 * 添加对话框弹出事件
 */
const addHander = () => {
  dialogAddVisible.value = true
}
//上传成功的钩子
const onHeadImageAddSuccess = (response, uploadFile) => {
  addFormInfo.bannerUrl = response.data
  ElMessage.success("上传成功")
}
//移除图片的钩子
const onHeadImageAddRemove = (response, uploadFile) => {
  axios.fastdfs_delete({

    filePath: addFormInfo.bannerUrl

  }).then(res => {
    if (res.data.code == 200) {
      ElMessage.success("移除成功")
    }
  })
}
/**
 * 添加对话框 确定事件
 */
const sureHandler = () => {
  axios.banner_add({
    bannerUrl: addFormInfo.bannerUrl,
    bannerDesc: addFormInfo.bannerDesc,
    bannerTypeId: addFormInfo.bannerTypeId,
  }).then(res => {
    if (res.data.code == 200) {
      dialogAddVisible.value = false
      http(searchInfo.value, currentPage.value, defaultPageSize.value)
    } else {
      ElMessage.error(res.data.message)
    }
  })
}
/**
 * 编辑对话框 弹出事件
 *  */
const handleEdit = (index, row) => {

  dialogEditorVisible.value = true
  axios.banner_findById({
    bannerId: row.bannerId
  }).then(res => {
    if (res.data.code == 200) {
      editorFormInfo.bannerId = res.data.data.bannerId;
      editorFormInfo.bannerUrl = res.data.data.bannerUrl;
      editorFormInfo.bannerDesc = res.data.data.bannerDesc;
      editorFormInfo.bannerTypeId = res.data.data.bannerTypeId;
    } else {
      ElMessage.error(res.data.data.message)
    }
  })

}
/**
 * 编辑对话框 头图修改时图片上传成功事件
 */
    //上传成功的钩子
const onHeadImageEditSuccess = (response, uploadFile) => {
      //删除以前图片
      axios.fastdfs_delete({

        filePath: editorFormInfo.bannerUrl

      }).then(res => {
        if (res.data.code == 200) {
          ElMessage.success("fastdfs移除原图片成功")
        }
      })
      //替换为现在的图片
      editorFormInfo.bannerUrl = response.data
      ElMessage.success("上传成功")

    }
/**
 * 编辑对话框 确定事件
 */
const sureEditorHandler = () => {
  axios.banner_update({
    bannerId: editorFormInfo.bannerId,
    bannerUrl: editorFormInfo.bannerUrl,
    bannerDesc: editorFormInfo.bannerDesc,
    bannerTypeId: editorFormInfo.bannerTypeId,

  }).then(res => {
    if (res.data.code == 200) {
      dialogEditorVisible.value = false
      http(searchInfo.value, currentPage.value, defaultPageSize.value)
    } else {
      ElMessage.error(res.data.message)
    }
  })
}
/**删除 */
const handleDelete = (index, row) => {
  ElMessageBox.confirm(
      '确定删除么',
      '删除',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }
  ).then(() => {
    //确认删除
    axios.banner_delete({
      bannerId: row.bannerId
    }).then(res => {
      if (res.data.code == 200) {
        ElMessage({
          type: 'success',
          message: "删除成功!!!",
        })
        //刷新
        http(searchInfo.value, currentPage.value, defaultPageSize.value)
      } else {
        ElMessage({
          type: 'error',
          message: res.data.message,
        })
      }
    })
  }).catch(error => {
    ElMessage({
      type: 'info',
      message: "取消删除",
    })
  })


}
</script>
<style scoped>
.data-container {
  background: linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);
  background: -o-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);
  background: -ms-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);
  background: -moz-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);
  background: -webkit-linear-gradient(left, rgb(89, 234, 233) 27%, rgb(131, 231, 218) 44%, rgb(69, 150, 216) 88%);
  height: 800px;
}

.data-header {
  padding: 20px;
}

.data-header .input {
  width: 300px;
}

.data-table {
  padding: 20px;
}

.page {
  position: fixed;
  right: 10px;
  bottom: 10px;
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1028454.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【UE 粒子练习】06——创建条带类型粒子

效果 下图呈现的是一种条带粒子跟随普通粒子移动的效果。其中&#xff0c;条带粒子为下图中蓝色部分&#xff0c;橙色部分为普通粒子 步骤 1. 新建一个材质&#xff0c;命名为“Mat_Ribbon”&#xff0c;将用于条带粒子材质 材质域设置为表面&#xff0c;混合模式设置为半透明…

DeepWalk实战---Wiki词条图嵌入可视化

DeepWalk是2014年提出的一种Graph中的Node进行Embedding的 算法&#xff0c;是首次将自然语言处理领域NLP中的 word2vec拓展到了graph。万事万物皆可embedding&#xff0c;所以DeepWalk我感觉在图机器学习中具有非常强的应用价值。 1. 首先打开Anaconda Prompt (Anaconda)&…

分享一个基于uniapp+springboot技术开发的校园失物招领小程序(源码、lw、调试)

&#x1f495;&#x1f495;作者&#xff1a;计算机源码社 &#x1f495;&#x1f495;个人简介&#xff1a;本人七年开发经验&#xff0c;擅长Java、Python、PHP、.NET、微信小程序、爬虫、大数据等&#xff0c;大家有这一块的问题可以一起交流&#xff01; &#x1f495;&…

海国图志#7:这一周难忘瞬间,吐血整理,不得不看

这里记录每周值得分享的新闻大图&#xff0c;周日发布。 文章以高清大图呈现&#xff0c;解说以汉语为主&#xff0c;英语为辅&#xff0c;英语句子均来自NYTimes、WSJ、The Guardian等权威媒体原刊。 归档时段&#xff1a;20230911-20230917 摩洛哥&#xff0c;阿米茨米兹 在阿…

calibre和cpolar搭建一个私有的网络书库

Kindle中国电子书店停运不要慌&#xff0c;十分钟搭建自己的在线书库随时随地看小说&#xff01; 文章目录 Kindle中国电子书店停运不要慌&#xff0c;十分钟搭建自己的在线书库随时随地看小说&#xff01;1.网络书库软件下载安装2.网络书库服务器设置3.内网穿透工具设置4.公网…

树莓派4b装系统到运行 Blazor Linux 本地程序全记录

在Linux下运行gui程序,咱也是第一次做,属于是瞎子过河乱摸一通,写得有什么不对和可以优化的地方,希望各位看官斧正斧正. ##1. 下载烧录器 https://www.raspberrypi.com/software/####我选择的是Raspbian 64位系统,并配置好ssh账号密码,wifi,以便启动后可以直接黑屏ssh连接 ##…

全流程HEC-RAS 1D/2D水动力与水环境模拟丨恒定流模型(1D/2D)、一维非恒定流、二维非恒定流模型、HEC-RAS水质模型

目录 ​专题一 ​水动力模型基础 专题二 恒定流模型(1D/2D) 专题三 一维非恒定流 专题四 二维非恒定流模型&#xff08;一&#xff09; 专题五 二维非恒定流模型&#xff08;二&#xff09; 专题六 HEC-RAS的水质模型 专题七 高级主题 更多应用 水动力与水环境模型的数…

【自学开发之旅】Flask-会话保持-API授权-注册登录

http - 无状态-无法记录是否已经登陆过 #会话保持 – session cookie session – 保存一些在服务端 cookie – 保存一些数据在客户端 session在单独服务器D上保存&#xff0c;前面数个服务器A,B,C上去取就好了&#xff0c;业务解耦。—》》现在都是基于token的验证。 以上是基…

stm32学习笔记:GPIO输入

1、寄存器输入输出函数 //读取输入数据寄存器某一个端口的输入值&#xff0c;参数用来指定某一个端口&#xff0c;返回值是 uint8_t类型&#xff0c;用来代表高低电平&#xff08;读取按键的值&#xff09;uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_…

JVM调优笔记

双亲委派机制 app---->ext----->bootstrap 保证系统的核心库不被修改 沙箱安全机制 限制系统资源访问&#xff0c;将java代码限制在虚拟机特定的运行范围中 基本组件 字节码校验器 确保java类文件遵循java规范&#xff0c;帮助java程序实现内存保护类加载器 native…

基于SSM的北京集联软件科技有限公司信息管理系统

末尾获取源码 开发语言&#xff1a;Java Java开发工具&#xff1a;JDK1.8 后端框架&#xff1a;SSM 前端&#xff1a;采用JSP技术开发 数据库&#xff1a;MySQL5.7和Navicat管理工具结合 服务器&#xff1a;Tomcat8.5 开发软件&#xff1a;IDEA / Eclipse 是否Maven项目&#x…

博客摘录「 MobaXterm登录密码重置」2023年9月21日

登录MobaXterm提示输入密码&#xff0c; 而且还 忘记密码 安装重置密码的工具 可以使用浏览器打开 如下网址&#xff1a; https://mobaxterm.mobatek.net/resetmasterpassword.html 打开如图&#xff1a; 下载MobaXterm软件密码重置工具&#xff0c;下载好并解压后 直接…

第二证券:创业板指失守2000点 算力概念股走势活跃

周三&#xff0c;沪深两市继续缩量震动调整&#xff0c;三大指数均小幅下跌&#xff0c;创业板指失守2000点整数关口&#xff0c;再创调整新低。到收盘&#xff0c;上证综指报3108.57点&#xff0c;跌0.52%&#xff1b;深证成指报10072.46点&#xff0c;跌0.53%&#xff1b;创业…

Python机器学习实战-特征重要性分析方法(1):排列重要性(附源码和实现效果)

实现功能 排列重要性 PermutationImportance&#xff1a;该方法会随机排列每个特征的值&#xff0c;然后监控模型性能下降的程度。如果获得了更大的下降意味着特征更重要 实现代码 from sklearn.datasets import load_breast_cancer from sklearn.ensemble import RandomFore…

应用程序处理:TCP模块的处理

1、应用程序处理 首先应用程序会进行编码处理&#xff0c;这些编码相当于 OSI 的表示层功能&#xff1b; 编码转化后&#xff0c;邮件不一定马上被发送出去&#xff0c;这种何时建立通信连接何时发送数据的管理功能&#xff0c;相当于 OSI 的会话层功能。 2、TCP 模块的处理 …

共聚焦显微镜在化学机械抛光课题研究中的应用

两个物体表面相互接触即会产生相互作用力&#xff0c;研究具有相对运动的相互作用表面间的摩擦、润滑与磨损及其三者之间关系即为摩擦学&#xff0c;目前摩擦学已涵盖了化学机械抛光、生物摩擦、流体摩擦等多个细分研究方向&#xff0c;其研究的数值量级也涵盖了亚纳米到百微米…

MYSQL不常用但好用写法

ORDER BY FIELD() 自定义排序逻辑 MySql 中的排序 ORDER BY 除了可以用 ASC 和 DESC&#xff0c;还可以通过 「ORDER BY FIELD(str,str1,…)」 自定义字符串/数字来实现排序。这里用 order_diy 表举例&#xff0c;结构以及表数据展示&#xff1a; ORDER BY FIELD(str,str1,…) …

【Excel加密】excel只读模式在哪里设置

Excel文件想要设置成只读模式&#xff0c;其实很简单&#xff0c;今天给大家分享四个excel设置只读模式的方法。 方法一&#xff1a;文件属性 右键点击文件&#xff0c;查看文件属性&#xff0c;在属性界面&#xff0c;勾选上只读属性就可以了。 方法二&#xff1a;始终以只读…

pixel2的root过程

用adb连接手机 首先学会用adb连接手机 可以配置在主机Windows和虚拟机上 手机打开设置&#xff0c;连续点击版本号进入开发者模式 点击进入开发者选项&#xff0c;允许USB调试&#xff0c;连接在电脑上&#xff0c;在手机授权对话框中允许电脑调试 连接完成后&#xff0c;输…

eslint代码校验及修复(Vue项目快速上手)

项目中配置eslint校验 文章目录 项目中配置eslint校验前言1. webpack5搭建 Vue项目如下🔗(可以查看)2. eslint+prettier Vue项目如下🔗(暂时未更新)一、什么是 ESLint?二、为什么要使用 ESLint?三、如何在 Vue 项目中集成 ESLint?3.1.安装依赖代码如下:如下图所示3…