Commit 227e1a0a0443f605c384d4fce79c4c27d2c4b35a
Merge remote-tracking branch 'origin/master'
Showing
13 changed files
with
1238 additions
and
11 deletions
ruoyi-archives/src/main/resources/mapper/archives/ArchivesBoxMapper.xml
| ... | ... | @@ -39,6 +39,7 @@ |
| 39 | 39 | where apprvoal='4' |
| 40 | 40 | <if test="archivesBox.deportNodeId =='isNull'"> and deport_node_id is null</if> |
| 41 | 41 | <if test="archivesBox.deportNodeId =='isNotNull'"> and deport_node_id is not null</if> |
| 42 | + <if test="archivesBox.deportNodeId !='' and archivesBox.deportNodeId !='isNull' and archivesBox.deportNodeId !='isNotNull'"> and deport_node_id = #{archivesBox.deportNodeId}</if> | |
| 42 | 43 | <if test="ids !=null and ids.length>0"> |
| 43 | 44 | and id in |
| 44 | 45 | <foreach item="id" collection="ids" open="(" separator="," close=")"> | ... | ... |
ruoyi-service/src/main/java/com/ruoyi/service/controller/DeptNodeController.java
0 → 100644
| 1 | +package com.ruoyi.service.controller; | |
| 2 | + | |
| 3 | +import com.ruoyi.common.annotation.Log; | |
| 4 | +import com.ruoyi.common.core.controller.BaseController; | |
| 5 | +import com.ruoyi.common.core.domain.AjaxResult; | |
| 6 | +import com.ruoyi.common.enums.BusinessType; | |
| 7 | +import com.ruoyi.common.utils.StringUtils; | |
| 8 | +import com.ruoyi.common.utils.poi.ExcelUtil; | |
| 9 | +import com.ruoyi.service.domain.DepotNode; | |
| 10 | +import com.ruoyi.service.service.DepotNodeService; | |
| 11 | +import org.apache.commons.lang3.ArrayUtils; | |
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 14 | +import org.springframework.web.bind.annotation.*; | |
| 15 | + | |
| 16 | +import javax.servlet.http.HttpServletResponse; | |
| 17 | +import java.util.Iterator; | |
| 18 | +import java.util.List; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * 库房维护 控制层 | |
| 22 | + * | |
| 23 | + * @author ym | |
| 24 | + * @date 2022-08-19 | |
| 25 | + */ | |
| 26 | +@RestController | |
| 27 | +@RequestMapping("/service/depotNode") | |
| 28 | +public class DeptNodeController extends BaseController | |
| 29 | +{ | |
| 30 | + @Autowired | |
| 31 | + private DepotNodeService depotNodeService; | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 查询库房列表 | |
| 35 | + */ | |
| 36 | + @PreAuthorize("@ss.hasPermi('service:depotNode:list')") | |
| 37 | + @GetMapping("/list") | |
| 38 | + public AjaxResult list(DepotNode depotNode) | |
| 39 | + { | |
| 40 | + startPage(); | |
| 41 | + List<DepotNode> list = depotNodeService.selectDepotNodeList(depotNode); | |
| 42 | + return AjaxResult.success(list); | |
| 43 | + } | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * 导出库房列表 | |
| 47 | + */ | |
| 48 | + @PreAuthorize("@ss.hasPermi('service:depotNode:export')") | |
| 49 | + @Log(title = "库房", businessType = BusinessType.EXPORT) | |
| 50 | + @PostMapping("/export") | |
| 51 | + public void export(HttpServletResponse response, DepotNode serviceDept) | |
| 52 | + { | |
| 53 | + List<DepotNode> list = depotNodeService.selectDepotNodeList(serviceDept); | |
| 54 | + ExcelUtil<DepotNode> util = new ExcelUtil<DepotNode>(DepotNode.class); | |
| 55 | + util.exportExcel(response, list, "库房数据"); | |
| 56 | + } | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * 获取库房详细信息 | |
| 60 | + */ | |
| 61 | + @PreAuthorize("@ss.hasPermi('service:depotNode:query')") | |
| 62 | + @GetMapping(value = "/{id}") | |
| 63 | + public AjaxResult getInfo(@PathVariable("id") Long id) | |
| 64 | + { | |
| 65 | + DepotNode serviceDept=depotNodeService.selectDepotNodeById(id); | |
| 66 | + System.out.println(serviceDept); | |
| 67 | + return AjaxResult.success(depotNodeService.selectDepotNodeById(id)); | |
| 68 | + } | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * 新增库房 | |
| 72 | + */ | |
| 73 | + @PreAuthorize("@ss.hasPermi('service:depotNode:add')") | |
| 74 | + @Log(title = "库房", businessType = BusinessType.INSERT) | |
| 75 | + @PostMapping | |
| 76 | + public AjaxResult add(@RequestBody DepotNode serviceDept) | |
| 77 | + { | |
| 78 | + return toAjax(depotNodeService.insertDepotNode(serviceDept)); | |
| 79 | + } | |
| 80 | + | |
| 81 | + /** | |
| 82 | + * 修改库房 | |
| 83 | + */ | |
| 84 | + @PreAuthorize("@ss.hasPermi('service:depotNode:edit')") | |
| 85 | + @Log(title = "库房", businessType = BusinessType.UPDATE) | |
| 86 | + @PutMapping | |
| 87 | + public AjaxResult edit(@RequestBody DepotNode serviceDept) | |
| 88 | + { | |
| 89 | + return toAjax(depotNodeService.updateDepotNode(serviceDept)); | |
| 90 | + } | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * 删除库房 | |
| 94 | + */ | |
| 95 | + @PreAuthorize("@ss.hasPermi('service:depotNode:remove')") | |
| 96 | + @Log(title = "库房", businessType = BusinessType.DELETE) | |
| 97 | + @DeleteMapping("/{depotNodeIds}") | |
| 98 | + public AjaxResult remove(@PathVariable Long[] depotNodeIds) | |
| 99 | + { | |
| 100 | + return toAjax(depotNodeService.deleteDepotNodeByIds(depotNodeIds)); | |
| 101 | + } | |
| 102 | + | |
| 103 | + @GetMapping("/treeselect") | |
| 104 | + public AjaxResult treeselect(DepotNode serviceDept) | |
| 105 | + { | |
| 106 | + List<DepotNode> depotNodes = depotNodeService.selectDepotNodeList(serviceDept); | |
| 107 | + return AjaxResult.success(depotNodeService.buildDepotNodeTreeSelect(depotNodes)); | |
| 108 | + } | |
| 109 | + | |
| 110 | + | |
| 111 | + /** | |
| 112 | + * 查询库房列表(排除节点) | |
| 113 | + */ | |
| 114 | + @PreAuthorize("@ss.hasPermi('system:depotNode:list')") | |
| 115 | + @GetMapping("/list/exclude/{depotNodeId}") | |
| 116 | + public AjaxResult excludeChild(@PathVariable(value = "depotNodeId", required = false) Long depotNodeId) | |
| 117 | + { | |
| 118 | + List<DepotNode> depotNodes = depotNodeService.selectDepotNodeList(new DepotNode()); | |
| 119 | + Iterator<DepotNode> it = depotNodes.iterator(); | |
| 120 | + while (it.hasNext()) | |
| 121 | + { | |
| 122 | + DepotNode d = (DepotNode) it.next(); | |
| 123 | + if (d.getId().intValue() == depotNodeId | |
| 124 | + || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), depotNodeId + "")) | |
| 125 | + { | |
| 126 | + it.remove(); | |
| 127 | + } | |
| 128 | + } | |
| 129 | + return AjaxResult.success(depotNodes); | |
| 130 | + } | |
| 131 | + | |
| 132 | +} | ... | ... |
ruoyi-service/src/main/java/com/ruoyi/service/domain/DepotNode.java
0 → 100644
| 1 | +package com.ruoyi.service.domain; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
| 4 | +import com.ruoyi.common.annotation.Excel; | |
| 5 | +import com.ruoyi.common.core.domain.BaseEntity; | |
| 6 | +import org.apache.commons.lang3.builder.ToStringBuilder; | |
| 7 | +import org.apache.commons.lang3.builder.ToStringStyle; | |
| 8 | + | |
| 9 | +import java.util.ArrayList; | |
| 10 | +import java.util.Date; | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 库房 depot_node | |
| 15 | + * | |
| 16 | + * @author ym | |
| 17 | + * @date 2022-08-19 | |
| 18 | + */ | |
| 19 | +public class DepotNode extends BaseEntity | |
| 20 | +{ | |
| 21 | + private static final long serialVersionUID = 1L; | |
| 22 | + | |
| 23 | + private Long id; | |
| 24 | + | |
| 25 | + /** 父id */ | |
| 26 | + private Long parentId; | |
| 27 | + | |
| 28 | + /** 祖级列表 */ | |
| 29 | + private String ancestors; | |
| 30 | + | |
| 31 | + /** 节点名称 */ | |
| 32 | + private String nodeName; | |
| 33 | + | |
| 34 | + /** 显示顺序 */ | |
| 35 | + private Integer orderNum; | |
| 36 | + | |
| 37 | + /** 状态(0正常 1停用) */ | |
| 38 | + private String status; | |
| 39 | + | |
| 40 | + /** 删除标志(0代表存在 2代表删除) */ | |
| 41 | + private String delFlag; | |
| 42 | + | |
| 43 | + /** 是否是架子( 1是 2不是) */ | |
| 44 | + private String nodeFlag; | |
| 45 | + | |
| 46 | + /** 库位码 */ | |
| 47 | + private String depotCode; | |
| 48 | + | |
| 49 | + private String createUser; | |
| 50 | + | |
| 51 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
| 52 | + private Date createTime; | |
| 53 | + | |
| 54 | + private String updateUser; | |
| 55 | + | |
| 56 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
| 57 | + private Date updateTime; | |
| 58 | + | |
| 59 | + /** 子部门 */ | |
| 60 | + private List<DepotNode> children = new ArrayList<DepotNode>(); | |
| 61 | + | |
| 62 | + public Long getId() { | |
| 63 | + return id; | |
| 64 | + } | |
| 65 | + | |
| 66 | + public void setId(Long id) { | |
| 67 | + this.id = id; | |
| 68 | + } | |
| 69 | + | |
| 70 | + public Long getParentId() { | |
| 71 | + return parentId; | |
| 72 | + } | |
| 73 | + | |
| 74 | + public void setParentId(Long parentId) { | |
| 75 | + this.parentId = parentId; | |
| 76 | + } | |
| 77 | + | |
| 78 | + public String getAncestors() { | |
| 79 | + return ancestors; | |
| 80 | + } | |
| 81 | + | |
| 82 | + public void setAncestors(String ancestors) { | |
| 83 | + this.ancestors = ancestors; | |
| 84 | + } | |
| 85 | + | |
| 86 | + public String getNodeName() { | |
| 87 | + return nodeName; | |
| 88 | + } | |
| 89 | + | |
| 90 | + public void setNodeName(String nodeName) { | |
| 91 | + this.nodeName = nodeName; | |
| 92 | + } | |
| 93 | + | |
| 94 | + public Integer getOrderNum() { | |
| 95 | + return orderNum; | |
| 96 | + } | |
| 97 | + | |
| 98 | + public void setOrderNum(Integer orderNum) { | |
| 99 | + this.orderNum = orderNum; | |
| 100 | + } | |
| 101 | + | |
| 102 | + public String getStatus() { | |
| 103 | + return status; | |
| 104 | + } | |
| 105 | + | |
| 106 | + public void setStatus(String status) { | |
| 107 | + this.status = status; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public String getDelFlag() { | |
| 111 | + return delFlag; | |
| 112 | + } | |
| 113 | + | |
| 114 | + public void setDelFlag(String delFlag) { | |
| 115 | + this.delFlag = delFlag; | |
| 116 | + } | |
| 117 | + | |
| 118 | + public String getNodeFlag() { | |
| 119 | + return nodeFlag; | |
| 120 | + } | |
| 121 | + | |
| 122 | + public void setNodeFlag(String nodeFlag) { | |
| 123 | + this.nodeFlag = nodeFlag; | |
| 124 | + } | |
| 125 | + | |
| 126 | + public String getDepotCode() { | |
| 127 | + return depotCode; | |
| 128 | + } | |
| 129 | + | |
| 130 | + public void setDepotCode(String depotCode) { | |
| 131 | + this.depotCode = depotCode; | |
| 132 | + } | |
| 133 | + | |
| 134 | + public String getCreateUser() { | |
| 135 | + return createUser; | |
| 136 | + } | |
| 137 | + | |
| 138 | + public void setCreateUser(String createUser) { | |
| 139 | + this.createUser = createUser; | |
| 140 | + } | |
| 141 | + | |
| 142 | + @Override | |
| 143 | + public Date getCreateTime() { | |
| 144 | + return createTime; | |
| 145 | + } | |
| 146 | + | |
| 147 | + @Override | |
| 148 | + public void setCreateTime(Date createTime) { | |
| 149 | + this.createTime = createTime; | |
| 150 | + } | |
| 151 | + | |
| 152 | + public String getUpdateUser() { | |
| 153 | + return updateUser; | |
| 154 | + } | |
| 155 | + | |
| 156 | + public void setUpdateUser(String updateUser) { | |
| 157 | + this.updateUser = updateUser; | |
| 158 | + } | |
| 159 | + | |
| 160 | + @Override | |
| 161 | + public Date getUpdateTime() { | |
| 162 | + return updateTime; | |
| 163 | + } | |
| 164 | + | |
| 165 | + @Override | |
| 166 | + public void setUpdateTime(Date updateTime) { | |
| 167 | + this.updateTime = updateTime; | |
| 168 | + } | |
| 169 | + | |
| 170 | + public List<DepotNode> getChildren() { | |
| 171 | + return children; | |
| 172 | + } | |
| 173 | + | |
| 174 | + public void setChildren(List<DepotNode> children) { | |
| 175 | + this.children = children; | |
| 176 | + } | |
| 177 | +} | ... | ... |
ruoyi-service/src/main/java/com/ruoyi/service/mapper/DepotNodeMapper.java
0 → 100644
| 1 | +package com.ruoyi.service.mapper; | |
| 2 | + | |
| 3 | +import com.ruoyi.service.domain.DepotNode; | |
| 4 | +import java.util.List; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * 库房管理 数据层 | |
| 8 | + * | |
| 9 | + * @author ym | |
| 10 | + * @date 2022-08-19 | |
| 11 | + */ | |
| 12 | +public interface DepotNodeMapper | |
| 13 | +{ | |
| 14 | + /** | |
| 15 | + * 查询库房 | |
| 16 | + * | |
| 17 | + * @param id 库房主键 | |
| 18 | + * @return 库房 | |
| 19 | + */ | |
| 20 | + DepotNode selectDepotNodeById(Long id); | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 查询库房列表 | |
| 24 | + * | |
| 25 | + * @param depotNode 库房 | |
| 26 | + * @return 库房集合 | |
| 27 | + */ | |
| 28 | + List<DepotNode> selectDepotNodeList(DepotNode depotNode); | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 新增库房 | |
| 32 | + * | |
| 33 | + * @param depotNode 库房 | |
| 34 | + * @return 结果 | |
| 35 | + */ | |
| 36 | + int insertDepotNode(DepotNode depotNode); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 修改库房 | |
| 40 | + * | |
| 41 | + * @param depotNode 库房 | |
| 42 | + * @return 结果 | |
| 43 | + */ | |
| 44 | + int updateDepotNode(DepotNode depotNode); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 删除库房 | |
| 48 | + * | |
| 49 | + * @param deptId 库房主键 | |
| 50 | + * @return 结果 | |
| 51 | + */ | |
| 52 | + int deleteDepotNodeById(Long deptId); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 批量删除库房 | |
| 56 | + * | |
| 57 | + * @param deptIds 需要删除的数据主键集合 | |
| 58 | + * @return 结果 | |
| 59 | + */ | |
| 60 | + int deleteDepotNodeByIds(Long[] deptIds); | |
| 61 | + | |
| 62 | +} | ... | ... |
ruoyi-service/src/main/java/com/ruoyi/service/service/DepotNodeService.java
0 → 100644
| 1 | +package com.ruoyi.service.service; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.ruoyi.service.domain.DepotNode; | |
| 5 | +import com.ruoyi.service.util.TreeSelect; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 库房管理 服务层 | |
| 11 | + * | |
| 12 | + * @author ym | |
| 13 | + * @date 2022-08-19 | |
| 14 | + */ | |
| 15 | +public interface DepotNodeService | |
| 16 | +{ | |
| 17 | + /** | |
| 18 | + * 查询库房 | |
| 19 | + * | |
| 20 | + * @param id 库房主键 | |
| 21 | + * @return 库房 | |
| 22 | + */ | |
| 23 | + DepotNode selectDepotNodeById(Long id); | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 查询库房列表 | |
| 27 | + * | |
| 28 | + * @param depotNode 库房 | |
| 29 | + * @return 库房集合 | |
| 30 | + */ | |
| 31 | + List<DepotNode> selectDepotNodeList(DepotNode depotNode); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 新增库房 | |
| 35 | + * | |
| 36 | + * @param depotNode 库房 | |
| 37 | + * @return 结果 | |
| 38 | + */ | |
| 39 | + int insertDepotNode(DepotNode depotNode); | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 修改库房 | |
| 43 | + * | |
| 44 | + * @param depotNode 库房 | |
| 45 | + * @return 结果 | |
| 46 | + */ | |
| 47 | + int updateDepotNode(DepotNode depotNode); | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 批量删除库房 | |
| 51 | + * | |
| 52 | + * @param ids 需要删除的库房主键集合 | |
| 53 | + * @return 结果 | |
| 54 | + */ | |
| 55 | + int deleteDepotNodeByIds(Long[] ids); | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 删除库房信息 | |
| 59 | + * | |
| 60 | + * @param id 库房主键 | |
| 61 | + * @return 结果 | |
| 62 | + */ | |
| 63 | + int deleteDepotNodeById(Long id); | |
| 64 | + | |
| 65 | + | |
| 66 | + List<DepotNode> buildDepotNodeTree(List<DepotNode> depotNodes); | |
| 67 | + /** | |
| 68 | + * 构建前端所需要下拉树结构 | |
| 69 | + * | |
| 70 | + * @param depotNodes 库房列表 | |
| 71 | + * @return 下拉树结构列表 | |
| 72 | + */ | |
| 73 | + List<TreeSelect> buildDepotNodeTreeSelect(List<DepotNode> depotNodes); | |
| 74 | + | |
| 75 | +} | ... | ... |
ruoyi-service/src/main/java/com/ruoyi/service/service/impl/DepotNodeServiceImpl.java
0 → 100644
| 1 | +package com.ruoyi.service.service.impl; | |
| 2 | + | |
| 3 | +import com.ruoyi.common.utils.DateUtils; | |
| 4 | +import com.ruoyi.common.utils.StringUtils; | |
| 5 | +import com.ruoyi.service.domain.DepotNode; | |
| 6 | +import com.ruoyi.service.mapper.DepotNodeMapper; | |
| 7 | +import com.ruoyi.service.service.DepotNodeService; | |
| 8 | +import com.ruoyi.service.util.TreeSelect; | |
| 9 | +import org.springframework.stereotype.Service; | |
| 10 | +import org.springframework.transaction.annotation.Transactional; | |
| 11 | + | |
| 12 | +import javax.annotation.Resource; | |
| 13 | +import java.util.ArrayList; | |
| 14 | +import java.util.Iterator; | |
| 15 | +import java.util.List; | |
| 16 | +import java.util.stream.Collectors; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 库房管理 服务实现 | |
| 20 | + * | |
| 21 | + * @author ym | |
| 22 | + * @date 2022-08-19 | |
| 23 | + */ | |
| 24 | +@Service | |
| 25 | +public class DepotNodeServiceImpl implements DepotNodeService | |
| 26 | +{ | |
| 27 | + @Resource | |
| 28 | + private DepotNodeMapper depotNodeMapper; | |
| 29 | + /** | |
| 30 | + * 查询库房 | |
| 31 | + * | |
| 32 | + * @param id 库房主键 | |
| 33 | + * @return 库房 | |
| 34 | + */ | |
| 35 | + @Override | |
| 36 | + public DepotNode selectDepotNodeById(Long id) | |
| 37 | + { | |
| 38 | + return depotNodeMapper.selectDepotNodeById(id); | |
| 39 | + } | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 查询库房列表 | |
| 43 | + * | |
| 44 | + * @param depotNode 库房 | |
| 45 | + * @return 库房 | |
| 46 | + */ | |
| 47 | + @Override | |
| 48 | + public List<DepotNode> selectDepotNodeList(DepotNode depotNode) | |
| 49 | + { | |
| 50 | + return depotNodeMapper.selectDepotNodeList(depotNode); | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * 新增库房 | |
| 55 | + * | |
| 56 | + * @param depotNode 库房 | |
| 57 | + * @return 结果 | |
| 58 | + */ | |
| 59 | + @Override | |
| 60 | + @Transactional | |
| 61 | + public int insertDepotNode(DepotNode depotNode) | |
| 62 | + { | |
| 63 | + DepotNode DepotNodeP=depotNodeMapper.selectDepotNodeById(depotNode.getParentId()); | |
| 64 | + String ancestors=DepotNodeP.getAncestors()+","+DepotNodeP.getId(); | |
| 65 | + depotNode.setAncestors(ancestors); | |
| 66 | + int i=depotNodeMapper.insertDepotNode(depotNode); | |
| 67 | + String depotCode=ancestors.replace(",","-")+"-"+depotNode.getId(); | |
| 68 | + depotNode.setDepotCode(depotCode); | |
| 69 | + depotNodeMapper.updateDepotNode(depotNode); | |
| 70 | + return i; | |
| 71 | + } | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * 修改库房 | |
| 75 | + * | |
| 76 | + * @param depotNode 库房 | |
| 77 | + * @return 结果 | |
| 78 | + */ | |
| 79 | + @Override | |
| 80 | + public int updateDepotNode(DepotNode depotNode) | |
| 81 | + { | |
| 82 | + depotNode.setUpdateTime(DateUtils.getNowDate()); | |
| 83 | + return depotNodeMapper.updateDepotNode(depotNode); | |
| 84 | + } | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * 批量删除库房 | |
| 88 | + * | |
| 89 | + * @param ids 需要删除的库房主键 | |
| 90 | + * @return 结果 | |
| 91 | + */ | |
| 92 | + @Override | |
| 93 | + public int deleteDepotNodeByIds(Long[] ids) | |
| 94 | + { | |
| 95 | + return depotNodeMapper.deleteDepotNodeByIds(ids); | |
| 96 | + } | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * 删除库房信息 | |
| 100 | + * | |
| 101 | + * @param id 库房主键 | |
| 102 | + * @return 结果 | |
| 103 | + */ | |
| 104 | + @Override | |
| 105 | + public int deleteDepotNodeById(Long id) | |
| 106 | + { | |
| 107 | + return depotNodeMapper.deleteDepotNodeById(id); | |
| 108 | + } | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + /** | |
| 113 | + * 构建前端所需要下拉树结构 | |
| 114 | + * | |
| 115 | + * @param depotNodes 库房列表 | |
| 116 | + * @return 下拉树结构列表 | |
| 117 | + */ | |
| 118 | + public List<TreeSelect> buildDepotNodeTreeSelect(List<DepotNode> depotNodes){ | |
| 119 | + | |
| 120 | + List<DepotNode> depotNodeTrees = buildDepotNodeTree(depotNodes); | |
| 121 | + return depotNodeTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); | |
| 122 | + } | |
| 123 | + /** | |
| 124 | + * 构建前端所需要树结构 | |
| 125 | + * | |
| 126 | + * @param depotNodes 库房列表 | |
| 127 | + * @return 树结构列表 | |
| 128 | + */ | |
| 129 | + @Override | |
| 130 | + public List<DepotNode> buildDepotNodeTree(List<DepotNode> depotNodes) | |
| 131 | + { | |
| 132 | + List<DepotNode> returnList = new ArrayList<DepotNode>(); | |
| 133 | + List<Long> tempList = new ArrayList<Long>(); | |
| 134 | + for (DepotNode dept : depotNodes) | |
| 135 | + { | |
| 136 | + tempList.add(dept.getId()); | |
| 137 | + } | |
| 138 | + for (DepotNode dept : depotNodes) | |
| 139 | + { | |
| 140 | + // 如果是顶级节点, 遍历该父节点的所有子节点 | |
| 141 | + if (!tempList.contains(dept.getParentId())) | |
| 142 | + { | |
| 143 | + recursionFn(depotNodes, dept); | |
| 144 | + returnList.add(dept); | |
| 145 | + } | |
| 146 | + } | |
| 147 | + if (returnList.isEmpty()) | |
| 148 | + { | |
| 149 | + returnList = depotNodes; | |
| 150 | + } | |
| 151 | + return returnList; | |
| 152 | + } | |
| 153 | + /** | |
| 154 | + * 递归列表 | |
| 155 | + */ | |
| 156 | + private void recursionFn(List<DepotNode> list, DepotNode t) | |
| 157 | + { | |
| 158 | + // 得到子节点列表 | |
| 159 | + List<DepotNode> childList = getChildList(list, t); | |
| 160 | + t.setChildren(childList); | |
| 161 | + for (DepotNode tChild : childList) | |
| 162 | + { | |
| 163 | + if (hasChild(list, tChild)) | |
| 164 | + { | |
| 165 | + recursionFn(list, tChild); | |
| 166 | + } | |
| 167 | + } | |
| 168 | + } | |
| 169 | + | |
| 170 | + /** | |
| 171 | + * 得到子节点列表 | |
| 172 | + */ | |
| 173 | + private List<DepotNode> getChildList(List<DepotNode> list, DepotNode t) | |
| 174 | + { | |
| 175 | + List<DepotNode> tlist = new ArrayList<DepotNode>(); | |
| 176 | + Iterator<DepotNode> it = list.iterator(); | |
| 177 | + while (it.hasNext()) | |
| 178 | + { | |
| 179 | + DepotNode n = (DepotNode) it.next(); | |
| 180 | + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue()) | |
| 181 | + { | |
| 182 | + tlist.add(n); | |
| 183 | + } | |
| 184 | + } | |
| 185 | + return tlist; | |
| 186 | + } | |
| 187 | + | |
| 188 | + /** | |
| 189 | + * 判断是否有子节点 | |
| 190 | + */ | |
| 191 | + private boolean hasChild(List<DepotNode> list, DepotNode t) | |
| 192 | + { | |
| 193 | + return getChildList(list, t).size() > 0; | |
| 194 | + } | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | +} | ... | ... |
ruoyi-service/src/main/java/com/ruoyi/service/util/TreeSelect.java
0 → 100644
| 1 | +package com.ruoyi.service.util; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.annotation.JsonInclude; | |
| 4 | +import com.ruoyi.common.core.domain.entity.SysMenu; | |
| 5 | +import com.ruoyi.domain.ArchivesDept; | |
| 6 | +import com.ruoyi.service.domain.DepotNode; | |
| 7 | + | |
| 8 | +import java.io.Serializable; | |
| 9 | +import java.util.List; | |
| 10 | +import java.util.stream.Collectors; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Treeselect树结构实体类 common copy过来的 | |
| 14 | + * | |
| 15 | + * @author ruoyi | |
| 16 | + */ | |
| 17 | +public class TreeSelect implements Serializable | |
| 18 | +{ | |
| 19 | + private static final long serialVersionUID = 1L; | |
| 20 | + | |
| 21 | + /** 节点ID */ | |
| 22 | + private Long id; | |
| 23 | + | |
| 24 | + /** 节点名称 */ | |
| 25 | + private String label; | |
| 26 | + | |
| 27 | + /** 库位码 */ | |
| 28 | + private String depotCode; | |
| 29 | + | |
| 30 | + private boolean disabled; | |
| 31 | + | |
| 32 | + | |
| 33 | + /** 子节点 */ | |
| 34 | + @JsonInclude(JsonInclude.Include.NON_EMPTY) | |
| 35 | + private List<TreeSelect> children; | |
| 36 | + | |
| 37 | + public TreeSelect() | |
| 38 | + { | |
| 39 | + | |
| 40 | + } | |
| 41 | + | |
| 42 | + public TreeSelect(DepotNode depotNode) | |
| 43 | + { | |
| 44 | + this.id = depotNode.getId(); | |
| 45 | + this.label = depotNode.getNodeName(); | |
| 46 | + this.children = depotNode.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); | |
| 47 | + this.depotCode = depotNode.getDepotCode(); | |
| 48 | + this.disabled ="2".equalsIgnoreCase(depotNode.getNodeFlag()); | |
| 49 | + } | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + public TreeSelect(SysMenu menu) | |
| 54 | + { | |
| 55 | + this.id = menu.getMenuId(); | |
| 56 | + this.label = menu.getMenuName(); | |
| 57 | + this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); | |
| 58 | + } | |
| 59 | + | |
| 60 | + public Long getId() | |
| 61 | + { | |
| 62 | + return id; | |
| 63 | + } | |
| 64 | + | |
| 65 | + public void setId(Long id) | |
| 66 | + { | |
| 67 | + this.id = id; | |
| 68 | + } | |
| 69 | + | |
| 70 | + public String getLabel() | |
| 71 | + { | |
| 72 | + return label; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public void setLabel(String label) | |
| 76 | + { | |
| 77 | + this.label = label; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public List<TreeSelect> getChildren() | |
| 81 | + { | |
| 82 | + return children; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public void setChildren(List<TreeSelect> children) | |
| 86 | + { | |
| 87 | + this.children = children; | |
| 88 | + } | |
| 89 | + | |
| 90 | + public String getDepotCode() { | |
| 91 | + return depotCode; | |
| 92 | + } | |
| 93 | + | |
| 94 | + public void setDepotCode(String depotCode) { | |
| 95 | + this.depotCode = depotCode; | |
| 96 | + } | |
| 97 | + | |
| 98 | + public boolean isDisabled() { | |
| 99 | + return disabled; | |
| 100 | + } | |
| 101 | + | |
| 102 | + public void setDisabled(boolean disabled) { | |
| 103 | + this.disabled = disabled; | |
| 104 | + } | |
| 105 | +} | ... | ... |
ruoyi-service/src/main/resources/mapper/sevice/DepotNodeMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
| 2 | +<!DOCTYPE mapper | |
| 3 | +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |
| 4 | +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 5 | +<mapper namespace="com.ruoyi.service.mapper.DepotNodeMapper"> | |
| 6 | + | |
| 7 | + <select id="selectDepotNodeList" parameterType="com.ruoyi.service.domain.DepotNode" resultType="com.ruoyi.service.domain.DepotNode"> | |
| 8 | + select * from depot_node | |
| 9 | + <where> | |
| 10 | + <if test="parentId != null "> and parentId = #{parentId}</if> | |
| 11 | + <if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if> | |
| 12 | + <if test="nodeName != null and nodeName != ''"> and nodeName like concat('%', #{nodeName}, '%')</if> | |
| 13 | + <if test="orderNum != null "> and orderNum = #{orderNum}</if> | |
| 14 | + <if test="status != null and status != ''"> and status = #{status}</if> | |
| 15 | + </where> | |
| 16 | + </select> | |
| 17 | + | |
| 18 | + <select id="selectDepotNodeById" parameterType="Long" resultType="com.ruoyi.service.domain.DepotNode"> | |
| 19 | + select * from depot_node | |
| 20 | + where id = #{id} | |
| 21 | + </select> | |
| 22 | + | |
| 23 | + <insert id="insertDepotNode" parameterType="com.ruoyi.service.domain.DepotNode" useGeneratedKeys="true" keyProperty="id"> | |
| 24 | + insert into depot_node | |
| 25 | + <trim prefix="(" suffix=")" suffixOverrides=","> | |
| 26 | + <if test="parentId != null">parentId,</if> | |
| 27 | + <if test="ancestors != null">ancestors,</if> | |
| 28 | + <if test="nodeName != null">nodeName,</if> | |
| 29 | + <if test="orderNum != null">orderNum,</if> | |
| 30 | + <if test="status != null">status,</if> | |
| 31 | + <if test="delFlag != null">delFlag,</if> | |
| 32 | + <if test="nodeFlag != null">nodeFlag,</if> | |
| 33 | + <if test="depotCode != null">depotCode,</if> | |
| 34 | + <if test="createUser != null">createUser,</if> | |
| 35 | + createTime | |
| 36 | + </trim> | |
| 37 | + <trim prefix="values (" suffix=")" suffixOverrides=","> | |
| 38 | + <if test="parentId != null">#{parentId},</if> | |
| 39 | + <if test="ancestors != null">#{ancestors},</if> | |
| 40 | + <if test="nodeName != null">#{nodeName},</if> | |
| 41 | + <if test="orderNum != null">#{orderNum},</if> | |
| 42 | + <if test="status != null">#{status},</if> | |
| 43 | + <if test="delFlag != null">#{delFlag},</if> | |
| 44 | + <if test="nodeFlag != null">#{nodeFlag},</if> | |
| 45 | + <if test="depotCode != null">#{depotCode},</if> | |
| 46 | + <if test="createUser != null">#{createUser},</if> | |
| 47 | + sysdate() | |
| 48 | + </trim> | |
| 49 | + </insert> | |
| 50 | + | |
| 51 | + <update id="updateDepotNode" parameterType="com.ruoyi.service.domain.DepotNode"> | |
| 52 | + update depot_node | |
| 53 | + <trim prefix="SET" suffixOverrides=","> | |
| 54 | + <if test="parentId != null">parentId = #{parentId},</if> | |
| 55 | + <if test="ancestors != null">ancestors = #{ancestors},</if> | |
| 56 | + <if test="nodeName != null">nodeName = #{nodeName},</if> | |
| 57 | + <if test="orderNum != null">orderNum = #{orderNum},</if> | |
| 58 | + <if test="depotCode != null">depotCode = #{depotCode},</if> | |
| 59 | + <if test="status != null">status = #{status},</if> | |
| 60 | + <if test="delFlag != null">delFlag = #{delFlag},</if> | |
| 61 | + <if test="nodeFlag != null">nodeFlag = #{nodeFlag},</if> | |
| 62 | + <if test="updateUser != null">updateUser = #{updateUser},</if> | |
| 63 | + updateTime = sysdate() | |
| 64 | + </trim> | |
| 65 | + where id = #{id} | |
| 66 | + </update> | |
| 67 | + | |
| 68 | + <delete id="deleteDepotNodeById" parameterType="Long"> | |
| 69 | + delete from depot_node where id = #{id} | |
| 70 | + </delete> | |
| 71 | + | |
| 72 | + <delete id="deleteDepotNodeByIds" parameterType="String"> | |
| 73 | + delete from depot_node where id in | |
| 74 | + <foreach item="id" collection="array" open="(" separator="," close=")"> | |
| 75 | + #{id} | |
| 76 | + </foreach> | |
| 77 | + </delete> | |
| 78 | + | |
| 79 | +</mapper> | |
| 0 | 80 | \ No newline at end of file | ... | ... |
ruoyi-ui/src/api/service/depot.js
ruoyi-ui/src/api/service/depotNode.js
0 → 100644
| 1 | +import request from '@/utils/request' | |
| 2 | + | |
| 3 | +// 查询部门列表 | |
| 4 | +export function listDept(query) { | |
| 5 | + return request({ | |
| 6 | + url: '/service/depotNode/list', | |
| 7 | + method: 'get', | |
| 8 | + params: query | |
| 9 | + }) | |
| 10 | +} | |
| 11 | + | |
| 12 | +// 查询部门详细 | |
| 13 | +export function getDepotNode(id) { | |
| 14 | + return request({ | |
| 15 | + url: '/service/depotNode/' + id, | |
| 16 | + method: 'get' | |
| 17 | + }) | |
| 18 | +} | |
| 19 | + | |
| 20 | +// 新增部门 | |
| 21 | +export function addDept(data) { | |
| 22 | + return request({ | |
| 23 | + url: '/service/depotNode', | |
| 24 | + method: 'post', | |
| 25 | + data: data | |
| 26 | + }) | |
| 27 | +} | |
| 28 | + | |
| 29 | +// 修改部门 | |
| 30 | +export function updateDept(data) { | |
| 31 | + return request({ | |
| 32 | + url: '/service/depotNode', | |
| 33 | + method: 'put', | |
| 34 | + data: data | |
| 35 | + }) | |
| 36 | +} | |
| 37 | + | |
| 38 | +// 删除部门 | |
| 39 | +export function delDept(id) { | |
| 40 | + return request({ | |
| 41 | + url: '/service/depotNode/' + id, | |
| 42 | + method: 'delete' | |
| 43 | + }) | |
| 44 | +} | |
| 45 | +// 查询部门下拉树结构 | |
| 46 | +export function treeselect() { | |
| 47 | + return request({ | |
| 48 | + url: '/service/depotNode/treeselect', | |
| 49 | + method: 'get' | |
| 50 | + }) | |
| 51 | +} | |
| 52 | +// 查询部门列表(排除节点) | |
| 53 | +export function listDeptExcludeChild(id) { | |
| 54 | + return request({ | |
| 55 | + url: '/service/depotNode/list/exclude/' + id, | |
| 56 | + method: 'get' | |
| 57 | + }) | |
| 58 | +} | |
| 59 | + | |
| 60 | + | ... | ... |
ruoyi-ui/src/views/archives/box/filingindex.vue
| ... | ... | @@ -348,6 +348,7 @@ export default { |
| 348 | 348 | this.shelveType=1; |
| 349 | 349 | this.shelveOpen = true; |
| 350 | 350 | this.$nextTick(()=>{ |
| 351 | + this.$refs.shelve.clearCheck(); | |
| 351 | 352 | this.$refs.shelve.getList(); |
| 352 | 353 | }) |
| 353 | 354 | }, |
| ... | ... | @@ -356,6 +357,7 @@ export default { |
| 356 | 357 | this.shelveType=2; |
| 357 | 358 | this.shelveOpen = true; |
| 358 | 359 | this.$nextTick(()=>{ |
| 360 | + this.$refs.shelve.clearCheck(); | |
| 359 | 361 | this.$refs.shelve.getList(); |
| 360 | 362 | }) |
| 361 | 363 | }, | ... | ... |
ruoyi-ui/src/views/archives/box/shelveindex.vue
| ... | ... | @@ -11,8 +11,9 @@ |
| 11 | 11 | :default-expand-all=true |
| 12 | 12 | node-key="id" |
| 13 | 13 | ref="tree" |
| 14 | + show-checkbox | |
| 14 | 15 | highlight-current |
| 15 | - @node-click="handleNodeClick" | |
| 16 | + @check="handleNodeClick" | |
| 16 | 17 | /> |
| 17 | 18 | </div> |
| 18 | 19 | </el-col> |
| ... | ... | @@ -56,7 +57,6 @@ export default { |
| 56 | 57 | single:true, |
| 57 | 58 | loading: true, |
| 58 | 59 | list: [], |
| 59 | - level:undefined, | |
| 60 | 60 | queryParams:{ |
| 61 | 61 | depotNodeId:undefined |
| 62 | 62 | }, |
| ... | ... | @@ -84,18 +84,28 @@ export default { |
| 84 | 84 | }, |
| 85 | 85 | // 节点单击事件 |
| 86 | 86 | handleNodeClick(data) { |
| 87 | - this.level=data.level; | |
| 88 | - this.params.depotNodeId=data.dbId; | |
| 89 | - this.params.depotCode=data.label; | |
| 87 | + this.clearCheck(); | |
| 88 | + this.$refs.tree.setChecked(data.id,true,false); | |
| 89 | + this.params.depotNodeId=data.id; | |
| 90 | + this.params.depotCode=data.depotCode; | |
| 91 | + this.queryParams.deportNodeId=data.depotCode; | |
| 92 | + this.getList(); | |
| 93 | + }, | |
| 94 | + clearCheck(){ | |
| 95 | + let arr=this.$refs.tree.getCheckedKeys(true); | |
| 96 | + arr.forEach(k=>{ | |
| 97 | + this.$refs.tree.setChecked(k,false,false); | |
| 98 | + }) | |
| 99 | + this.queryParams.deportNodeId=undefined; | |
| 90 | 100 | }, |
| 91 | 101 | getList() { |
| 92 | 102 | this.loading = true; |
| 103 | + if(this.shelveType==2 && this.queryParams.deportNodeId==undefined){ | |
| 104 | + this.queryParams.deportNodeId='isNotNull' | |
| 105 | + } | |
| 93 | 106 | if(this.shelveType==1){ |
| 94 | 107 | this.queryParams.deportNodeId='isNull' |
| 95 | 108 | } |
| 96 | - else if(this.shelveType==2){ | |
| 97 | - this.queryParams.deportNodeId='isNotNull' | |
| 98 | - } | |
| 99 | 109 | listByIds(this.queryParams,this.ids).then(response => { |
| 100 | 110 | this.list = response.rows; |
| 101 | 111 | this.loading = false; |
| ... | ... | @@ -108,8 +118,8 @@ export default { |
| 108 | 118 | this.multiple = !selection.length |
| 109 | 119 | }, |
| 110 | 120 | shelve(){ |
| 111 | - if(this.level!=6){ | |
| 112 | - this.$message.error('只能上架节点') | |
| 121 | + if(this.params.ids==undefined){ | |
| 122 | + this.$modal.msgWarning("至少选择一条") | |
| 113 | 123 | return; |
| 114 | 124 | } |
| 115 | 125 | shelve(this.params).then(response => { |
| ... | ... | @@ -118,6 +128,10 @@ export default { |
| 118 | 128 | }); |
| 119 | 129 | }, |
| 120 | 130 | shelveDown(){ |
| 131 | + if(this.params.ids==undefined){ | |
| 132 | + this.$modal.msgWarning("至少选择一条") | |
| 133 | + return; | |
| 134 | + } | |
| 121 | 135 | shelveDown(this.params).then(response => { |
| 122 | 136 | this.$modal.msgSuccess("修改成功"); |
| 123 | 137 | this.getList(); | ... | ... |
ruoyi-ui/src/views/service/depotNode/index.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <div class="app-container"> | |
| 3 | + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"> | |
| 4 | + <el-form-item label="库房名称" prop="nodeName"> | |
| 5 | + <el-input | |
| 6 | + v-model="queryParams.nodeName" | |
| 7 | + placeholder="请输入库房名称" | |
| 8 | + clearable | |
| 9 | + @keyup.enter.native="handleQuery" | |
| 10 | + /> | |
| 11 | + </el-form-item> | |
| 12 | + <el-form-item label="状态" prop="status"> | |
| 13 | + <el-select v-model="queryParams.status" placeholder="库房状态" clearable> | |
| 14 | + <el-option | |
| 15 | + v-for="dict in dict.type.sys_normal_disable" | |
| 16 | + :key="dict.value" | |
| 17 | + :label="dict.label" | |
| 18 | + :value="dict.value" | |
| 19 | + /> | |
| 20 | + </el-select> | |
| 21 | + </el-form-item> | |
| 22 | + <el-form-item> | |
| 23 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | |
| 24 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | |
| 25 | + </el-form-item> | |
| 26 | + </el-form> | |
| 27 | + | |
| 28 | + <el-row :gutter="10" class="mb8"> | |
| 29 | + <el-col :span="1.5"> | |
| 30 | + <el-button | |
| 31 | + type="primary" | |
| 32 | + plain | |
| 33 | + icon="el-icon-plus" | |
| 34 | + size="mini" | |
| 35 | + @click="handleAdd" | |
| 36 | + v-hasPermi="['service:depotNode:add']" | |
| 37 | + >新增</el-button> | |
| 38 | + </el-col> | |
| 39 | + <el-col :span="1.5"> | |
| 40 | + <el-button | |
| 41 | + type="info" | |
| 42 | + plain | |
| 43 | + icon="el-icon-sort" | |
| 44 | + size="mini" | |
| 45 | + @click="toggleExpandAll" | |
| 46 | + >展开/折叠</el-button> | |
| 47 | + </el-col> | |
| 48 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | |
| 49 | + </el-row> | |
| 50 | + | |
| 51 | + <el-table | |
| 52 | + v-if="refreshTable" | |
| 53 | + v-loading="loading" | |
| 54 | + :data="deptList" | |
| 55 | + row-key="id" | |
| 56 | + :default-expand-all="isExpandAll" | |
| 57 | + :tree-props="{children: 'children', hasChildren: 'hasChildren'}" | |
| 58 | + > | |
| 59 | + <el-table-column prop="nodeName" label="名称" width="260"></el-table-column> | |
| 60 | + <el-table-column prop="orderNum" label="排序" width="200"></el-table-column> | |
| 61 | + <el-table-column prop="status" label="状态" width="100"> | |
| 62 | + <template slot-scope="scope"> | |
| 63 | + <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/> | |
| 64 | + </template> | |
| 65 | + </el-table-column> | |
| 66 | + | |
| 67 | + <el-table-column label="创建时间" align="center" prop="createTime" width="200"> | |
| 68 | + <template slot-scope="scope"> | |
| 69 | + <span>{{ parseTime(scope.row.createTime) }}</span> | |
| 70 | + </template> | |
| 71 | + </el-table-column> | |
| 72 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | |
| 73 | + <template slot-scope="scope"> | |
| 74 | + <el-button | |
| 75 | + size="mini" | |
| 76 | + type="text" | |
| 77 | + icon="el-icon-edit" | |
| 78 | + @click="handleUpdate(scope.row)" | |
| 79 | + v-hasPermi="['service:depotNode:edit']" | |
| 80 | + >修改</el-button> | |
| 81 | + <el-button | |
| 82 | + size="mini" | |
| 83 | + type="text" | |
| 84 | + icon="el-icon-plus" | |
| 85 | + @click="handleAdd(scope.row)" | |
| 86 | + v-hasPermi="['service:depotNode:add']" | |
| 87 | + >新增</el-button> | |
| 88 | + <el-button | |
| 89 | + v-if="scope.row.parentId != 0" | |
| 90 | + size="mini" | |
| 91 | + type="text" | |
| 92 | + icon="el-icon-delete" | |
| 93 | + @click="handleDelete(scope.row)" | |
| 94 | + v-hasPermi="['service:depotNode:remove']" | |
| 95 | + >删除</el-button> | |
| 96 | + </template> | |
| 97 | + </el-table-column> | |
| 98 | + </el-table> | |
| 99 | + | |
| 100 | + <!-- 添加或修改库房对话框 --> | |
| 101 | + <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> | |
| 102 | + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | |
| 103 | + <el-row> | |
| 104 | + <el-col :span="24" v-if="form.parentId !== 0" > | |
| 105 | + <el-form-item label="上级" prop="parentId" > | |
| 106 | + <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级" :disabled="type==2"/> | |
| 107 | + </el-form-item> | |
| 108 | + </el-col> | |
| 109 | + </el-row> | |
| 110 | + <el-row> | |
| 111 | + <el-col :span="12"> | |
| 112 | + <el-form-item label="名称" prop="nodeName"> | |
| 113 | + <el-input v-model="form.nodeName" placeholder="请输入库房名称" /> | |
| 114 | + </el-form-item> | |
| 115 | + </el-col> | |
| 116 | + <el-col :span="12"> | |
| 117 | + <el-form-item label="显示排序" prop="orderNum"> | |
| 118 | + <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> | |
| 119 | + </el-form-item> | |
| 120 | + </el-col> | |
| 121 | + </el-row> | |
| 122 | + <el-row> | |
| 123 | + <el-col :span="12"> | |
| 124 | + <el-form-item label="档案架"> | |
| 125 | + <el-radio-group v-model="form.nodeFlag"> | |
| 126 | + <el-radio | |
| 127 | + v-for="dict in dict.type.yes_no" | |
| 128 | + :key="dict.value" | |
| 129 | + :label="dict.value" | |
| 130 | + >{{dict.label}}</el-radio> | |
| 131 | + </el-radio-group> | |
| 132 | + </el-form-item> | |
| 133 | + </el-col> | |
| 134 | + <el-col :span="12"> | |
| 135 | + <el-form-item label="库房状态"> | |
| 136 | + <el-radio-group v-model="form.status"> | |
| 137 | + <el-radio | |
| 138 | + v-for="dict in dict.type.sys_normal_disable" | |
| 139 | + :key="dict.value" | |
| 140 | + :label="dict.value" | |
| 141 | + >{{dict.label}}</el-radio> | |
| 142 | + </el-radio-group> | |
| 143 | + </el-form-item> | |
| 144 | + </el-col> | |
| 145 | + </el-row> | |
| 146 | + </el-form> | |
| 147 | + <div slot="footer" class="dialog-footer"> | |
| 148 | + <el-button type="primary" @click="submitForm">确 定</el-button> | |
| 149 | + <el-button @click="cancel">取 消</el-button> | |
| 150 | + </div> | |
| 151 | + </el-dialog> | |
| 152 | + </div> | |
| 153 | +</template> | |
| 154 | + | |
| 155 | +<script> | |
| 156 | +import { listDept, getDepotNode, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/service/depotNode"; | |
| 157 | +import Treeselect from "@riophae/vue-treeselect"; | |
| 158 | +import "@riophae/vue-treeselect/dist/vue-treeselect.css"; | |
| 159 | + | |
| 160 | +export default { | |
| 161 | + name: "DepotNode", | |
| 162 | + dicts: ['sys_normal_disable','yes_no'], | |
| 163 | + components: { Treeselect }, | |
| 164 | + data() { | |
| 165 | + return { | |
| 166 | + // 遮罩层 | |
| 167 | + loading: true, | |
| 168 | + // 显示搜索条件 | |
| 169 | + showSearch: true, | |
| 170 | + // 表格树数据 | |
| 171 | + deptList: [], | |
| 172 | + // 库房树选项 | |
| 173 | + deptOptions: [], | |
| 174 | + // 弹出层标题 | |
| 175 | + title: "", | |
| 176 | + // 是否显示弹出层 | |
| 177 | + open: false, | |
| 178 | + // 是否展开,默认全部展开 | |
| 179 | + isExpandAll: true, | |
| 180 | + // 重新渲染表格状态 | |
| 181 | + refreshTable: true, | |
| 182 | + // 查询参数 | |
| 183 | + queryParams: { | |
| 184 | + nodeName: undefined, | |
| 185 | + status: undefined | |
| 186 | + }, | |
| 187 | + // 表单参数 | |
| 188 | + form: {}, | |
| 189 | + // 表单校验 | |
| 190 | + rules: { | |
| 191 | + parentId: [ | |
| 192 | + { required: true, message: "上级库房不能为空", trigger: "blur" } | |
| 193 | + ], | |
| 194 | + nodeName: [ | |
| 195 | + { required: true, message: "库房名称不能为空", trigger: "blur" } | |
| 196 | + ], | |
| 197 | + orderNum: [ | |
| 198 | + { required: true, message: "显示排序不能为空", trigger: "blur" } | |
| 199 | + ], | |
| 200 | + nodeFlag: [ | |
| 201 | + { required: true, message: "档案架不能为空", trigger: "blur" } | |
| 202 | + ] | |
| 203 | + }, | |
| 204 | + type:undefined | |
| 205 | + }; | |
| 206 | + }, | |
| 207 | + created() { | |
| 208 | + this.getList(); | |
| 209 | + }, | |
| 210 | + methods: { | |
| 211 | + /** 查询库房列表 */ | |
| 212 | + getList() { | |
| 213 | + this.loading = true; | |
| 214 | + listDept(this.queryParams).then(response => { | |
| 215 | + this.deptList = this.handleTree(response.data, "id"); | |
| 216 | + this.loading = false; | |
| 217 | + }); | |
| 218 | + }, | |
| 219 | + /** 转换库房数据结构 */ | |
| 220 | + normalizer(node) { | |
| 221 | + if (node.children && !node.children.length) { | |
| 222 | + delete node.children; | |
| 223 | + } | |
| 224 | + return { | |
| 225 | + id: node.id, | |
| 226 | + label: node.nodeName, | |
| 227 | + children: node.children | |
| 228 | + }; | |
| 229 | + }, | |
| 230 | + // 取消按钮 | |
| 231 | + cancel() { | |
| 232 | + this.open = false; | |
| 233 | + this.reset(); | |
| 234 | + }, | |
| 235 | + // 表单重置 | |
| 236 | + reset() { | |
| 237 | + this.form = { | |
| 238 | + id: undefined, | |
| 239 | + parentId: undefined, | |
| 240 | + nodeName: undefined, | |
| 241 | + orderNum: undefined, | |
| 242 | + nodeFlag: undefined, | |
| 243 | + status: "0" | |
| 244 | + }; | |
| 245 | + this.resetForm("form"); | |
| 246 | + }, | |
| 247 | + /** 搜索按钮操作 */ | |
| 248 | + handleQuery() { | |
| 249 | + this.getList(); | |
| 250 | + }, | |
| 251 | + /** 重置按钮操作 */ | |
| 252 | + resetQuery() { | |
| 253 | + this.resetForm("queryForm"); | |
| 254 | + this.handleQuery(); | |
| 255 | + }, | |
| 256 | + /** 新增按钮操作 */ | |
| 257 | + handleAdd(row) { | |
| 258 | + this.reset(); | |
| 259 | + this.type=1; | |
| 260 | + if (row != undefined) { | |
| 261 | + this.form.parentId = row.id; | |
| 262 | + } | |
| 263 | + this.open = true; | |
| 264 | + this.title = "添加库房"; | |
| 265 | + listDept().then(response => { | |
| 266 | + this.deptOptions = this.handleTree(response.data, "id"); | |
| 267 | + }); | |
| 268 | + }, | |
| 269 | + /** 展开/折叠操作 */ | |
| 270 | + toggleExpandAll() { | |
| 271 | + this.refreshTable = false; | |
| 272 | + this.isExpandAll = !this.isExpandAll; | |
| 273 | + this.$nextTick(() => { | |
| 274 | + this.refreshTable = true; | |
| 275 | + }); | |
| 276 | + }, | |
| 277 | + /** 修改按钮操作 */ | |
| 278 | + handleUpdate(row) { | |
| 279 | + this.reset(); | |
| 280 | + this.type=2; | |
| 281 | + getDepotNode(row.id).then(response => { | |
| 282 | + this.form = response.data; | |
| 283 | + this.open = true; | |
| 284 | + this.title = "修改"; | |
| 285 | + }); | |
| 286 | + | |
| 287 | + listDeptExcludeChild(row.id).then(response => { | |
| 288 | + this.deptOptions = this.handleTree(response.data, "id"); | |
| 289 | + }); | |
| 290 | + }, | |
| 291 | + /** 提交按钮 */ | |
| 292 | + submitForm: function() { | |
| 293 | + this.$refs["form"].validate(valid => { | |
| 294 | + if (valid) { | |
| 295 | + if (this.form.id != undefined) { | |
| 296 | + updateDept(this.form).then(response => { | |
| 297 | + this.$modal.msgSuccess("修改成功"); | |
| 298 | + this.open = false; | |
| 299 | + this.getList(); | |
| 300 | + }); | |
| 301 | + } else { | |
| 302 | + addDept(this.form).then(response => { | |
| 303 | + this.$modal.msgSuccess("新增成功"); | |
| 304 | + this.open = false; | |
| 305 | + this.getList(); | |
| 306 | + }); | |
| 307 | + } | |
| 308 | + } | |
| 309 | + }); | |
| 310 | + }, | |
| 311 | + /** 删除按钮操作 */ | |
| 312 | + handleDelete(row) { | |
| 313 | + this.$modal.confirm('是否确认删除名称为"' + row.nodeName + '"的数据项?').then(function() { | |
| 314 | + return delDept(row.id); | |
| 315 | + }).then(() => { | |
| 316 | + this.getList(); | |
| 317 | + this.$modal.msgSuccess("删除成功"); | |
| 318 | + }).catch(() => {}); | |
| 319 | + } | |
| 320 | + } | |
| 321 | +}; | |
| 322 | +</script> | ... | ... |