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()
                    }
                })
            },
相关推荐
子兮曰1 天前
jev-ultrafast 深度解析:7 秒订机票的浏览器 Agent 是如何炼成的
前端·后端·agent
子兮曰1 天前
Jev 爆发一周:7 秒 Agent 背后的 System One 生态与三场争议
前端·后端·ai编程
爱勇宝1 天前
ZCode 开源 24 小时:一份没有历史的账本,回答不了"有没有偷代码"
前端·后端·chatglm (智谱)
A黄俊辉A1 天前
uniapp webview中实现 app和内嵌的H5双向通信
vue.js·json
胡写代码1 天前
别再前后端各写一套表单校验了
java·后端
大勇前进1 天前
原生 PHP 还是 Laravel?小项目到底要不要上框架
后端
vipxieliang1 天前
ValidX 在 DDD 领域驱动设计中的实践
java·spring boot
yuzhi_liu1 天前
我用 LangGraph4j 实现 Multi-Agent Supervisor
后端
alsmile1 天前
Node-RED 之外,国产规则引擎的新方案:基于标准语法,Go 先行实现
后端·开源·go
大白801 天前
PHP 内存溢出排查思路:看懂报错日志,精准定位问题
后端