栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

springboot+vue+mybtais 实现增删改查页面(三)实现批量删除,带分页操作。vue前端页面,前后端分离项目

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

springboot+vue+mybtais 实现增删改查页面(三)实现批量删除,带分页操作。vue前端页面,前后端分离项目

先来看前端怎么写

首先需要在每个表格的前面加上一个多选框,

 
        

data里加上

 multipleSelection:[],

逻辑script

  //删除多个
            deleteMany(){
                let ids = []
                this.$/confirm/i('此操作将永久删除'+this.multipleSelection.length+'条流程,是否继续?','提示',{
                    /confirm/iButtonText:'确定',
                    cancelButtonText: '取消',
                    type:'warning'
                }).then(()=>{
                    // let ids='?';
                    this.multipleSelection.forEach(item =>{
                        ids.push(item.id)
                });
                    const _this = this
                    axios.get('http://localhost:8282/flow/delEmps/'+ids).then(function(resp){
                        _this.$alert('删除成功!', '消息', {
                            /confirm/iButtonText: '确定',
                            callback: action => {
                                window.location.reload()
                            }
                })

                    })
                })
            },
            删除多个
            handleSelectionChange(val) {
                this.multipleSelection = val;
                console.log(val)
            },

前端完毕,'http://localhost:8282/flow/delEmps/'注意这里替换成自己的地址

后端springboot

dao层

  public int deleteByIds(Integer[] flowIds);//批量删除

sql语句


    
        delete from flowd where id in
        
            #{id}
        
    

service层

public int deleteByIds(Integer[] flowIds);//批量删除

实现类serviceimpl
@Override

  public int deleteByIds(Integer[] flowIds) {

        return flowMapper.deleteByIds(flowIds);

    }

controller层

 //批量删除
    @GetMapping("/delEmps/{ids}")
    @ResponseBody
    public String delEmp(@PathVariable("ids")  Integer[] ids){
        Integer result = flowService.deleteByIds(ids);
        if (result > 0) {
            return "success";
        } else {
            return "error";
        }
    }

完事结束,有需要的可以评论哈

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/694466.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号