当前位置: 首页 > article >正文

009 批量删除

文章目录

    • 前端
    • 后端

https://element.eleme.cn/#/zh-CN/component/button

前端

    <el-button type="danger" @click="batchDelete">批量删除</el-button>
    <el-tree
      ref="menuTree"
    batchDelete() {
      console.log("批量删除菜单...");


      //封装要删除的id
      let ids = [];
      //通过eltree菜单 获取
      let checkedNodes = this.$refs.menuTree.getCheckedNodes();
      console.log("被选中的元素",checkedNodes);
      for (let index = 0; index < checkedNodes.length; index++) {
        //把选中的CheckBox的id值 添加到ids集合中
        ids.push( checkedNodes[index].id );
      }


      this.$confirm(`是否批量删除[${ids}]菜单?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {


          this.$http({
            url: this.$http.adornUrl("/product/category/delete"),
            method: "post",
            data: this.$http.adornData(ids, false),
          }).then(({ data }) => {
            this.$message({
              type: "success",
              message: "菜单批量删除成功!",
            });

            //重新刷新当前菜单
            this.getMenus();
            //设置需要默认展开的菜单, 设置为 要删除节点的父节点
            // this.expandedKey = [node.parent.data.id];
          });
        })
        .catch(() => {});
    },
  },

后端

@RestController
@RequestMapping("product/category")
public class CategoryController {
	    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("product:category:delete")
    public R delete(@RequestBody Integer[] ids){
        //直接删除方式
		//categoryService.removeByIds(Arrays.asList(ids));

        //TODO 检查当前要删除的菜单,是否被别的地方引用
        //逻辑删除方式
        categoryService.removeMenuByIds(Arrays.asList(ids));

        return R.ok();
    }

}
@Service("categoryService")
public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity> implements CategoryService {
	    /**
     * 逻辑删除菜单
     * @param asList
     */
    @Override
    public void removeMenuByIds(List<Integer> asList) {
        //TODO 检查当前要删除的菜单是否被别的地方引用
        //逻辑删除
        baseMapper.deleteBatchIds(asList);
    }
}
#mybatis
mybatis-plus:
  mapper-locations: classpath*:/mapper/**/*.xml
  #实体扫描,多个package用逗号或者分号分隔
  typeAliasesPackage: io.renren.modules.*.entity
  global-config:
    #数据库相关配置
    db-config:
      #主键类型  AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
      id-type: AUTO
      logic-delete-value: -1
      logic-not-delete-value: 0
    banner: false
  #原生配置
  configuration:
    map-underscore-to-camel-case: true
    cache-enabled: false
    call-setters-on-nulls: true
    jdbc-type-for-null: 'null'


http://www.kler.cn/a/279892.html

相关文章:

  • docker 拉取镜像超时
  • visual studio 2022 加载.vdproj
  • 原神4.8版本抽到角色和重点培养数据表
  • EV代码签名证书——消除软件下载时的安全警告
  • AI学习指南深度学习篇-长短时记忆网络(LSTM)简介
  • 《Object-Oriented Software Construction》第2版读后感
  • 《机器学习》 SVM支持向量机 推导、参数解析、可视化实现
  • 高效能低延迟:EasyCVR平台WebRTC支持H.265在远程监控中的优势
  • react中的useCallback、useMemo、useRef 和 useContext
  • 京存分布式赋能EDA应用
  • 安卓中回调函数的使用
  • 一文读懂红鲸音视频SDK
  • 程序员职业转型难题解析:为何不尝试投身大模型开发的新赛道?
  • 区块链(币圈)常用网址大全
  • Java-BatchProcessingUtil结合CompletableFuture工具类
  • JDK17 隐藏类 Hidden Classes 介绍
  • 使用VScode的Git版本控制功能(图文版)
  • SQL语法:create、insert、update、
  • yolov8 安装流程
  • 基于pygame的雷电战机小游戏