From e327be6bce36e99649b47b51cc1e47166b28b402 Mon Sep 17 00:00:00 2001 From: cgx <2606784146@qq.com> Date: Sat, 7 Dec 2024 15:53:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E4=B8=9A=E5=B7=A5=E7=A7=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../industry/controller/TbIndustryController.java | 216 ++++++++++++ .../jeecg/modules/industry/entity/TbIndustry.java | 92 ++++++ .../modules/industry/mapper/TbIndustryMapper.java | 22 ++ .../industry/mapper/xml/TbIndustryMapper.xml | 9 + .../industry/service/ITbIndustryService.java | 38 +++ .../service/impl/TbIndustryServiceImpl.java | 191 +++++++++++ .../jeecg/modules/industry/vue/TbIndustryList.vue | 366 +++++++++++++++++++++ .../industry/vue/modules/TbIndustryModal.vue | 162 +++++++++ .../jeecg/modules/industry/vue3/TbIndustry.api.ts | 82 +++++ .../jeecg/modules/industry/vue3/TbIndustry.data.ts | 64 ++++ .../jeecg/modules/industry/vue3/TbIndustryList.vue | 272 +++++++++++++++ .../industry/vue3/components/TbIndustryModal.vue | 87 +++++ 12 files changed, 1601 insertions(+) create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/controller/TbIndustryController.java create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/entity/TbIndustry.java create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/mapper/TbIndustryMapper.java create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/mapper/xml/TbIndustryMapper.xml create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/service/ITbIndustryService.java create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/service/impl/TbIndustryServiceImpl.java create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue/TbIndustryList.vue create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue/modules/TbIndustryModal.vue create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustry.api.ts create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustry.data.ts create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustryList.vue create mode 100644 jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/components/TbIndustryModal.vue diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/controller/TbIndustryController.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/controller/TbIndustryController.java new file mode 100644 index 0000000..bcfa396 --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/controller/TbIndustryController.java @@ -0,0 +1,216 @@ +package org.jeecg.modules.industry.controller; + +import java.util.Arrays; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.industry.entity.TbIndustry; +import org.jeecg.modules.industry.service.ITbIndustryService; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.extern.slf4j.Slf4j; + +import org.jeecg.common.system.base.controller.JeecgController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.ModelAndView; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.jeecg.common.aspect.annotation.AutoLog; + + /** + * @Description: tb_industry + * @Author: jeecg-boot + * @Date: 2024-12-07 + * @Version: V1.0 + */ +@Api(tags="tb_industry") +@RestController +@RequestMapping("/industry/tbIndustry") +@Slf4j +public class TbIndustryController extends JeecgController{ + @Autowired + private ITbIndustryService tbIndustryService; + + /** + * 分页列表查询 + * + * @param tbIndustry + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "tb_industry-分页列表查询") + @ApiOperation(value="tb_industry-分页列表查询", notes="tb_industry-分页列表查询") + @GetMapping(value = "/rootList") + public Result> queryPageList(TbIndustry tbIndustry, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + String hasQuery = req.getParameter("hasQuery"); + if(hasQuery != null && "true".equals(hasQuery)){ + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(tbIndustry, req.getParameterMap()); + List list = tbIndustryService.queryTreeListNoPage(queryWrapper); + IPage pageList = new Page<>(1, 10, list.size()); + pageList.setRecords(list); + return Result.OK(pageList); + }else{ + String parentId = tbIndustry.getPid(); + if (oConvertUtils.isEmpty(parentId)) { + parentId = "0"; + } + tbIndustry.setPid(null); + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(tbIndustry, req.getParameterMap()); + // 使用 eq 防止模糊查询 + queryWrapper.eq("pid", parentId); + Page page = new Page(pageNo, pageSize); + IPage pageList = tbIndustryService.page(page, queryWrapper); + return Result.OK(pageList); + } + } + + /** + * 获取子数据 + * @param tbIndustry + * @param req + * @return + */ + //@AutoLog(value = "tb_industry-获取子数据") + @ApiOperation(value="tb_industry-获取子数据", notes="tb_industry-获取子数据") + @GetMapping(value = "/childList") + public Result> queryPageList(TbIndustry tbIndustry,HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(tbIndustry, req.getParameterMap()); + List list = tbIndustryService.list(queryWrapper); + IPage pageList = new Page<>(1, 10, list.size()); + pageList.setRecords(list); + return Result.OK(pageList); + } + + /** + * 批量查询子节点 + * @param parentIds 父ID(多个采用半角逗号分割) + * @return 返回 IPage + * @param parentIds + * @return + */ + //@AutoLog(value = "tb_industry-批量获取子数据") + @ApiOperation(value="tb_industry-批量获取子数据", notes="tb_industry-批量获取子数据") + @GetMapping("/getChildListBatch") + public Result getChildListBatch(@RequestParam("parentIds") String parentIds) { + try { + QueryWrapper queryWrapper = new QueryWrapper<>(); + List parentIdList = Arrays.asList(parentIds.split(",")); + queryWrapper.in("pid", parentIdList); + List list = tbIndustryService.list(queryWrapper); + IPage pageList = new Page<>(1, 10, list.size()); + pageList.setRecords(list); + return Result.OK(pageList); + } catch (Exception e) { + log.error(e.getMessage(), e); + return Result.error("批量查询子节点失败:" + e.getMessage()); + } + } + + /** + * 添加 + * + * @param tbIndustry + * @return + */ + @AutoLog(value = "tb_industry-添加") + @ApiOperation(value="tb_industry-添加", notes="tb_industry-添加") + @PostMapping(value = "/add") + public Result add(@RequestBody TbIndustry tbIndustry) { + tbIndustryService.addTbIndustry(tbIndustry); + return Result.OK("添加成功!"); + } + + /** + * 编辑 + * + * @param tbIndustry + * @return + */ + @AutoLog(value = "tb_industry-编辑") + @ApiOperation(value="tb_industry-编辑", notes="tb_industry-编辑") + @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) + public Result edit(@RequestBody TbIndustry tbIndustry) { + tbIndustryService.updateTbIndustry(tbIndustry); + return Result.OK("编辑成功!"); + } + + /** + * 通过id删除 + * + * @param id + * @return + */ + @AutoLog(value = "tb_industry-通过id删除") + @ApiOperation(value="tb_industry-通过id删除", notes="tb_industry-通过id删除") + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name="id",required=true) String id) { + tbIndustryService.deleteTbIndustry(id); + return Result.OK("删除成功!"); + } + + /** + * 批量删除 + * + * @param ids + * @return + */ + @AutoLog(value = "tb_industry-批量删除") + @ApiOperation(value="tb_industry-批量删除", notes="tb_industry-批量删除") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) { + this.tbIndustryService.removeByIds(Arrays.asList(ids.split(","))); + return Result.OK("批量删除成功!"); + } + + /** + * 通过id查询 + * + * @param id + * @return + */ + //@AutoLog(value = "tb_industry-通过id查询") + @ApiOperation(value="tb_industry-通过id查询", notes="tb_industry-通过id查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name="id",required=true) String id) { + TbIndustry tbIndustry = tbIndustryService.getById(id); + if(tbIndustry==null) { + return Result.error("未找到对应数据"); + } + return Result.OK(tbIndustry); + } + + /** + * 导出excel + * + * @param request + * @param tbIndustry + */ + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, TbIndustry tbIndustry) { + return super.exportXls(request, tbIndustry, TbIndustry.class, "tb_industry"); + } + + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + return super.importExcel(request, response, TbIndustry.class); + } + +} diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/entity/TbIndustry.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/entity/TbIndustry.java new file mode 100644 index 0000000..3e58ffa --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/entity/TbIndustry.java @@ -0,0 +1,92 @@ +package org.jeecg.modules.industry.entity; + +import java.io.Serializable; +import java.util.Date; +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecg.common.aspect.annotation.Dict; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.UnsupportedEncodingException; + +/** + * @Description: tb_industry + * @Author: jeecg-boot + * @Date: 2024-12-07 + * @Version: V1.0 + */ +@Data +@TableName("tb_industry") +@ApiModel(value="tb_industry对象", description="tb_industry") +public class TbIndustry implements Serializable { + private static final long serialVersionUID = 1L; + + /**主键id*/ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "主键id") + private java.lang.String id; + /**父id*/ + @Excel(name = "父id", width = 15) + @ApiModelProperty(value = "父id") + private java.lang.String parentId; + /**行业名称*/ + @Excel(name = "行业名称", width = 15) + @ApiModelProperty(value = "行业名称") + private java.lang.String name; + /**菜单类型(0:一级行业菜单; 1:工种菜单)*/ + @Excel(name = "菜单类型(0:一级行业菜单; 1:工种菜单)", width = 15, dicCode = "emp_menu_type") + @Dict(dicCode = "emp_menu_type") + @ApiModelProperty(value = "菜单类型(0:一级行业菜单; 1:工种菜单)") + private java.lang.Integer menuType; + /**排序*/ + @Excel(name = "排序", width = 15) + @ApiModelProperty(value = "排序") + private java.lang.Double sortNo; + /**图标*/ + @Excel(name = "图标", width = 15) + @ApiModelProperty(value = "图标") + private java.lang.String icon; + /**是否叶子节点: 1:是 0:不是*/ + @Excel(name = "是否叶子节点: 1:是 0:不是", width = 15) + @ApiModelProperty(value = "是否叶子节点: 1:是 0:不是") + private java.lang.Integer isLeaf; + /**描述*/ + @Excel(name = "描述", width = 15) + @ApiModelProperty(value = "描述") + private java.lang.String description; + /**创建人*/ + @ApiModelProperty(value = "创建人") + private java.lang.String createBy; + /**创建时间*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "创建时间") + private java.util.Date createTime; + /**更新人*/ + @ApiModelProperty(value = "更新人") + private java.lang.String updateBy; + /**更新时间*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ApiModelProperty(value = "更新时间") + private java.util.Date updateTime; + /**删除状态 0正常 1已删除*/ + @Excel(name = "删除状态 0正常 1已删除", width = 15) + @ApiModelProperty(value = "删除状态 0正常 1已删除") + private java.lang.Integer delFlag; + /**父级节点*/ + @Excel(name = "父级节点", width = 15) + @ApiModelProperty(value = "父级节点") + private java.lang.String pid; + /**是否有子节点*/ + @Excel(name = "是否有子节点", width = 15, dicCode = "yn") + @Dict(dicCode = "yn") + @ApiModelProperty(value = "是否有子节点") + private java.lang.String hasChild; +} diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/mapper/TbIndustryMapper.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/mapper/TbIndustryMapper.java new file mode 100644 index 0000000..fd0ef7f --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/mapper/TbIndustryMapper.java @@ -0,0 +1,22 @@ +package org.jeecg.modules.industry.mapper; + +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.industry.entity.TbIndustry; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @Description: tb_industry + * @Author: jeecg-boot + * @Date: 2024-12-07 + * @Version: V1.0 + */ +public interface TbIndustryMapper extends BaseMapper { + + /** + * 编辑节点状态 + * @param id + * @param status + */ + void updateTreeNodeStatus(@Param("id") String id,@Param("status") String status); + +} diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/mapper/xml/TbIndustryMapper.xml b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/mapper/xml/TbIndustryMapper.xml new file mode 100644 index 0000000..d03c408 --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/mapper/xml/TbIndustryMapper.xml @@ -0,0 +1,9 @@ + + + + + + update tb_industry set has_child = #{status} where id = #{id} + + + \ No newline at end of file diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/service/ITbIndustryService.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/service/ITbIndustryService.java new file mode 100644 index 0000000..047e25e --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/service/ITbIndustryService.java @@ -0,0 +1,38 @@ +package org.jeecg.modules.industry.service; + +import org.jeecg.modules.industry.entity.TbIndustry; +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.common.exception.JeecgBootException; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import java.util.List; + +/** + * @Description: tb_industry + * @Author: jeecg-boot + * @Date: 2024-12-07 + * @Version: V1.0 + */ +public interface ITbIndustryService extends IService { + + /**根节点父ID的值*/ + public static final String ROOT_PID_VALUE = "0"; + + /**树节点有子节点状态值*/ + public static final String HASCHILD = "1"; + + /**树节点无子节点状态值*/ + public static final String NOCHILD = "0"; + + /**新增节点*/ + void addTbIndustry(TbIndustry tbIndustry); + + /**修改节点*/ + void updateTbIndustry(TbIndustry tbIndustry) throws JeecgBootException; + + /**删除节点*/ + void deleteTbIndustry(String id) throws JeecgBootException; + + /**查询所有数据,无分页*/ + List queryTreeListNoPage(QueryWrapper queryWrapper); + +} diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/service/impl/TbIndustryServiceImpl.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/service/impl/TbIndustryServiceImpl.java new file mode 100644 index 0000000..b1531c1 --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/service/impl/TbIndustryServiceImpl.java @@ -0,0 +1,191 @@ +package org.jeecg.modules.industry.service.impl; + +import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.industry.entity.TbIndustry; +import org.jeecg.modules.industry.mapper.TbIndustryMapper; +import org.jeecg.modules.industry.service.ITbIndustryService; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +/** + * @Description: tb_industry + * @Author: jeecg-boot + * @Date: 2024-12-07 + * @Version: V1.0 + */ +@Service +public class TbIndustryServiceImpl extends ServiceImpl implements ITbIndustryService { + + @Override + public void addTbIndustry(TbIndustry tbIndustry) { + //新增时设置hasChild为0 + tbIndustry.setHasChild(ITbIndustryService.NOCHILD); + if(oConvertUtils.isEmpty(tbIndustry.getPid())){ + tbIndustry.setPid(ITbIndustryService.ROOT_PID_VALUE); + }else{ + //如果当前节点父ID不为空 则设置父节点的hasChildren 为1 + TbIndustry parent = baseMapper.selectById(tbIndustry.getPid()); + if(parent!=null && !"1".equals(parent.getHasChild())){ + parent.setHasChild("1"); + baseMapper.updateById(parent); + } + } + baseMapper.insert(tbIndustry); + } + + @Override + public void updateTbIndustry(TbIndustry tbIndustry) { + TbIndustry entity = this.getById(tbIndustry.getId()); + if(entity==null) { + throw new JeecgBootException("未找到对应实体"); + } + String old_pid = entity.getPid(); + String new_pid = tbIndustry.getPid(); + if(!old_pid.equals(new_pid)) { + updateOldParentNode(old_pid); + if(oConvertUtils.isEmpty(new_pid)){ + tbIndustry.setPid(ITbIndustryService.ROOT_PID_VALUE); + } + if(!ITbIndustryService.ROOT_PID_VALUE.equals(tbIndustry.getPid())) { + baseMapper.updateTreeNodeStatus(tbIndustry.getPid(), ITbIndustryService.HASCHILD); + } + } + baseMapper.updateById(tbIndustry); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteTbIndustry(String id) throws JeecgBootException { + //查询选中节点下所有子节点一并删除 + id = this.queryTreeChildIds(id); + if(id.indexOf(",")>0) { + StringBuffer sb = new StringBuffer(); + String[] idArr = id.split(","); + for (String idVal : idArr) { + if(idVal != null){ + TbIndustry tbIndustry = this.getById(idVal); + String pidVal = tbIndustry.getPid(); + //查询此节点上一级是否还有其他子节点 + List dataList = baseMapper.selectList(new QueryWrapper().eq("pid", pidVal).notIn("id",Arrays.asList(idArr))); + if((dataList == null || dataList.size()==0) && !Arrays.asList(idArr).contains(pidVal) + && !sb.toString().contains(pidVal)){ + //如果当前节点原本有子节点 现在木有了,更新状态 + sb.append(pidVal).append(","); + } + } + } + //批量删除节点 + baseMapper.deleteBatchIds(Arrays.asList(idArr)); + //修改已无子节点的标识 + String[] pidArr = sb.toString().split(","); + for(String pid : pidArr){ + this.updateOldParentNode(pid); + } + }else{ + TbIndustry tbIndustry = this.getById(id); + if(tbIndustry==null) { + throw new JeecgBootException("未找到对应实体"); + } + updateOldParentNode(tbIndustry.getPid()); + baseMapper.deleteById(id); + } + } + + @Override + public List queryTreeListNoPage(QueryWrapper queryWrapper) { + List dataList = baseMapper.selectList(queryWrapper); + List mapList = new ArrayList<>(); + for(TbIndustry data : dataList){ + String pidVal = data.getPid(); + //递归查询子节点的根节点 + if(pidVal != null && !"0".equals(pidVal)){ + TbIndustry rootVal = this.getTreeRoot(pidVal); + if(rootVal != null && !mapList.contains(rootVal)){ + mapList.add(rootVal); + } + }else{ + if(!mapList.contains(data)){ + mapList.add(data); + } + } + } + return mapList; + } + + /** + * 根据所传pid查询旧的父级节点的子节点并修改相应状态值 + * @param pid + */ + private void updateOldParentNode(String pid) { + if(!ITbIndustryService.ROOT_PID_VALUE.equals(pid)) { + Long count = baseMapper.selectCount(new QueryWrapper().eq("pid", pid)); + if(count==null || count<=1) { + baseMapper.updateTreeNodeStatus(pid, ITbIndustryService.NOCHILD); + } + } + } + + /** + * 递归查询节点的根节点 + * @param pidVal + * @return + */ + private TbIndustry getTreeRoot(String pidVal){ + TbIndustry data = baseMapper.selectById(pidVal); + if(data != null && !"0".equals(data.getPid())){ + return this.getTreeRoot(data.getPid()); + }else{ + return data; + } + } + + /** + * 根据id查询所有子节点id + * @param ids + * @return + */ + private String queryTreeChildIds(String ids) { + //获取id数组 + String[] idArr = ids.split(","); + StringBuffer sb = new StringBuffer(); + for (String pidVal : idArr) { + if(pidVal != null){ + if(!sb.toString().contains(pidVal)){ + if(sb.toString().length() > 0){ + sb.append(","); + } + sb.append(pidVal); + this.getTreeChildIds(pidVal,sb); + } + } + } + return sb.toString(); + } + + /** + * 递归查询所有子节点 + * @param pidVal + * @param sb + * @return + */ + private StringBuffer getTreeChildIds(String pidVal,StringBuffer sb){ + List dataList = baseMapper.selectList(new QueryWrapper().eq("pid", pidVal)); + if(dataList != null && dataList.size()>0){ + for(TbIndustry tree : dataList) { + if(!sb.toString().contains(tree.getId())){ + sb.append(",").append(tree.getId()); + } + this.getTreeChildIds(tree.getId(),sb); + } + } + return sb; + } + +} diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue/TbIndustryList.vue b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue/TbIndustryList.vue new file mode 100644 index 0000000..78853b1 --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue/TbIndustryList.vue @@ -0,0 +1,366 @@ + + + + \ No newline at end of file diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue/modules/TbIndustryModal.vue b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue/modules/TbIndustryModal.vue new file mode 100644 index 0000000..5ca07eb --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue/modules/TbIndustryModal.vue @@ -0,0 +1,162 @@ + + + \ No newline at end of file diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustry.api.ts b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustry.api.ts new file mode 100644 index 0000000..57f687a --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustry.api.ts @@ -0,0 +1,82 @@ +import {defHttp} from "/@/utils/http/axios"; +import {Modal} from 'ant-design-vue'; + +enum Api { + list = '/industry/tbIndustry/rootList', + save='/industry/tbIndustry/add', + edit='/industry/tbIndustry/edit', + deleteTbIndustry = '/sys/tbIndustry/delete', + deleteBatch = '/industry/tbIndustry/deleteBatch', + importExcel = '/industry/tbIndustry/importExcel', + exportXls = '/industry/tbIndustry/exportXls', + loadTreeData = '/industry/tbIndustry/loadTreeRoot', + getChildList = '/industry/tbIndustry/childList', + getChildListBatch = '/industry/tbIndustry/getChildListBatch', +} +/** + * 导出api + * @param params + */ +export const getExportUrl = Api.exportXls; +/** + * 导入api + * @param params + */ +export const getImportUrl = Api.importExcel; +/** + * 列表接口 + * @param params + */ +export const list = (params) => + defHttp.get({url: Api.list, params}); +/** + * 删除 + */ +export const deleteTbIndustry = (params,handleSuccess) => { + return defHttp.delete({url: Api.deleteTbIndustry, params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); +} +/** + * 批量删除 + * @param params + */ +export const batchDeleteTbIndustry = (params, handleSuccess) => { + Modal.confirm({ + title: '确认删除', + content: '是否删除选中数据', + okText: '确认', + cancelText: '取消', + onOk: () => { + return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); + } + }); +} +/** + * 保存或者更新 + * @param params + */ +export const saveOrUpdateDict = (params, isUpdate) => { + let url = isUpdate ? Api.edit : Api.save; + return defHttp.post({url: url, params}); +} +/** + * 查询全部树形节点数据 + * @param params + */ +export const loadTreeData = (params) => + defHttp.get({url: Api.loadTreeData,params}); +/** + * 查询子节点数据 + * @param params + */ +export const getChildList = (params) => + defHttp.get({url: Api.getChildList, params}); +/** + * 批量查询子节点数据 + * @param params + */ +export const getChildListBatch = (params) => + defHttp.get({url: Api.getChildListBatch, params},{isTransformResponse:false}); diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustry.data.ts b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustry.data.ts new file mode 100644 index 0000000..adcc007 --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustry.data.ts @@ -0,0 +1,64 @@ +import {BasicColumn} from '/@/components/Table'; +import {FormSchema} from '/@/components/Table'; +import { rules} from '/@/utils/helper/validator'; +import { render } from '/@/utils/common/renderUtils'; +//列表数据 +export const columns: BasicColumn[] = [ + { + title: '行业名称', + align:"center", + dataIndex: 'name' + }, + { + title: '菜单类型(0:一级行业菜单; 1:工种菜单)', + align:"center", + dataIndex: 'menuType_dictText' + }, + { + title: '排序', + align:"center", + dataIndex: 'sortNo' + }, + { + title: '图标', + align:"center", + dataIndex: 'icon', + customRender:render.renderAvatar, + }, +]; +//查询数据 +export const searchFormSchema: FormSchema[] = [ +]; +//表单数据 +export const formSchema: FormSchema[] = [ + { + label: '行业名称', + field: 'name', + component: 'Input', + }, + { + label: '菜单类型(0:一级行业菜单; 1:工种菜单)', + field: 'menuType', + component: 'JDictSelectTag', + componentProps:{ + dictCode:"emp_menu_type" + }, + }, + { + label: '排序', + field: 'sortNo', + component: 'InputNumber', + }, + { + label: '图标', + field: 'icon', + component: 'JImageUpload', + componentProps:{ + }, + }, + { + label: '父级节点', + field: 'pid', + component: 'Input', + }, +]; diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustryList.vue b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustryList.vue new file mode 100644 index 0000000..2bed60d --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/TbIndustryList.vue @@ -0,0 +1,272 @@ + + + + + diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/components/TbIndustryModal.vue b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/components/TbIndustryModal.vue new file mode 100644 index 0000000..ef9c2e6 --- /dev/null +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/industry/vue3/components/TbIndustryModal.vue @@ -0,0 +1,87 @@ + +