SpringBoot + Vue 微人事(十二)

职位批量删除实现

编写后端接口

PositionController

java 复制代码
 @DeleteMapping("/")
    public RespBean deletePositionByIds(Integer[] ids){
        if(positionsService.deletePositionsByIds(ids)==ids.length){
            return RespBean.ok("删除成功");
        }
        return RespBean.err("删除失败");
    }

PositionsService

java 复制代码
    public int deletePositionsByIds(Integer[] ids) {
        return positionMapper.deletePositionsByIds(ids);
    }

PositionMapper

java 复制代码
    int deletePositionsByIds(@Param("ids") Integer[] idsInteger[] ids);

PositionMapper.xml

xml 复制代码
  delete  from position where  id in
        <foreach collection="ids" item="id" separator="," open="(" close=")">
           #{id}
         </foreach>;

添加批量删除按钮

bash 复制代码
            <el-button type="danger" size="small" style="margin-top:10px" >批量删除</el-button>

没有选中肯定默认是禁用批量删除按钮的,添加一个

赋值就是当前选择的项

定义一个变量,空数组变量

bash 复制代码
   multipleSelection: []

添加一个点击事件,这个是一个点击多选框会触发的点击事件

赋值给这个空数组变量,保存着始终点击项

按钮禁用

bash 复制代码
            <el-button type="danger" size="small" style="margin-top:10px" :disabled="multipleSelection.length==0">批量删除</el-button>

给这个按钮添加一个点击事件,进行连接后端,批量删除

bash 复制代码
<el-button type="danger" size="small" style="margin-top:10px" :disabled="multipleSelection.length==0" @click="deleteMany">批量删除</el-button>
bash 复制代码
 deleteMany(){
                let ids ="?";
                this.multipleSelection.forEach(item=>{
                    ids += 'ids='+item.id+'&'   //ida = ?ids=  + id + &  ids=  + id + &
                })
                console.log(ids)
                this.deleteRequest("/system/basic/pos/"+ids).then(resp=>{
                    if (resp){
                        this.initPositions()
                    }
                })
            },
相关推荐
SamDeepThinking18 分钟前
别让一个超时的第三方http接口拖垮所有接口
java·后端·架构
我母鸡啊34 分钟前
软考架构师故事系列-操作系统
后端
阿聪谈架构37 分钟前
第08章:MCP 模型上下文协议(上)
人工智能·后端
雨白1 小时前
使用 Kotlin 与 Spring Boot 从零搭建 Web 应用
spring boot·kotlin
mrchan1 小时前
markdown 画图总结
后端
开心就好20251 小时前
全面介绍iOS开发工具:Xcode、AppCode、CocoaPods、Fastlane和Git
后端·ios
一 乐1 小时前
交通感知与车路协同系统|基于springboot + vue交通感知与车路协同系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·交通感知与车路协同系统
uElY ITER1 小时前
基于Spring Boot 3 + Spring Security6 + JWT + Redis实现登录、token身份认证
spring boot·redis·spring
Rust研习社2 小时前
Rust Pin 解析:核心原理与异步编程实践
开发语言·后端·rust
book123_0_992 小时前
Spring Boot 条件注解:@ConditionalOnProperty 完全解析
java·spring boot·后端