父部门不能选择&选择树自适应

master
RuoYi 6 years ago committed by Limy
parent cb3df4b324
commit c6b772cafe

@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult; import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
@ -79,7 +80,12 @@ public class DeptController extends BaseController
@GetMapping("/edit/{deptId}") @GetMapping("/edit/{deptId}")
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap) public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
{ {
mmap.put("dept", deptService.selectDeptById(deptId)); SysDept dept = deptService.selectDeptById(deptId);
if (StringUtils.isNotNull(dept) && 100L == deptId)
{
dept.setParentName("无");
}
mmap.put("dept", dept);
return prefix + "/edit"; return prefix + "/edit";
} }

@ -31,7 +31,7 @@
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:job:export"><i class="fa fa-download"></i>&nbsp;导出</a> <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -45,6 +45,9 @@
<a class="btn btn-danger" onclick="$.operate.clean()" shiro:hasPermission="monitor:job:remove"> <a class="btn btn-danger" onclick="$.operate.clean()" shiro:hasPermission="monitor:job:remove">
<i class="fa fa-trash"></i> 清空 <i class="fa fa-trash"></i> 清空
</a> </a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:job:export">
<i class="fa fa-download"></i> 导出
</a>
</div> </div>
<div class="col-sm-12 select-table table-striped"> <div class="col-sm-12 select-table table-striped">

@ -31,7 +31,7 @@
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:logininfor:export"><i class="fa fa-download"></i>&nbsp;导出</a> <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -45,6 +45,9 @@
<a class="btn btn-danger" onclick="$.operate.clean()" shiro:hasPermission="monitor:logininfor:remove"> <a class="btn btn-danger" onclick="$.operate.clean()" shiro:hasPermission="monitor:logininfor:remove">
<i class="fa fa-trash"></i> 清空 <i class="fa fa-trash"></i> 清空
</a> </a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:logininfor:export">
<i class="fa fa-download"></i> 导出
</a>
</div> </div>
<div class="col-sm-12 select-table table-striped"> <div class="col-sm-12 select-table table-striped">

@ -31,7 +31,7 @@
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:logininfor:export"><i class="fa fa-download"></i>&nbsp;导出</a> <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -45,6 +45,9 @@
<a class="btn btn-danger" onclick="$.operate.clean()" shiro:hasPermission="monitor:logininfor:remove"> <a class="btn btn-danger" onclick="$.operate.clean()" shiro:hasPermission="monitor:logininfor:remove">
<i class="fa fa-trash"></i> 清空 <i class="fa fa-trash"></i> 清空
</a> </a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:logininfor:export">
<i class="fa fa-download"></i> 导出
</a>
</div> </div>
<div class="col-sm-12 select-table table-striped"> <div class="col-sm-12 select-table table-striped">

@ -107,7 +107,6 @@
var options = { var options = {
title: '部门选择', title: '部门选择',
width: "380", width: "380",
height: "380",
url: prefix + "/selectDeptTree/" + $("#treeId").val(), url: prefix + "/selectDeptTree/" + $("#treeId").val(),
callBack: doSubmit callBack: doSubmit
}; };

@ -108,14 +108,18 @@
/*部门管理-修改-选择部门树*/ /*部门管理-修改-选择部门树*/
function selectDeptTree() { function selectDeptTree() {
var options = { var deptId = $("#treeId").val();
title: '部门选择', if(deptId > 0) {
width: "380", var options = {
height: "380", title: '部门选择',
url: prefix + "/selectDeptTree/" + $("#treeId").val(), width: "380",
callBack: doSubmit url: prefix + "/selectDeptTree/" + $("#treeId").val(),
}; callBack: doSubmit
$.modal.openOptions(options); };
$.modal.openOptions(options);
} else {
$.modal.alertError("父部门不能选择");
}
} }
function doSubmit(index, layero){ function doSubmit(index, layero){

@ -151,7 +151,6 @@
var options = { var options = {
title: '菜单选择', title: '菜单选择',
width: "380", width: "380",
height: "380",
url: url, url: url,
callBack: doSubmit callBack: doSubmit
}; };

@ -164,8 +164,7 @@
if(menuId > 0) { if(menuId > 0) {
var url = prefix + "/selectMenuTree/" + menuId; var url = prefix + "/selectMenuTree/" + menuId;
$.modal.open("选择菜单", url, '380', '380'); $.modal.open("选择菜单", url, '380', '380');
} } else {
else {
$.modal.alertError("主菜单不能选择"); $.modal.alertError("主菜单不能选择");
} }
} }
@ -177,13 +176,11 @@
var options = { var options = {
title: '菜单选择', title: '菜单选择',
width: "380", width: "380",
height: "380",
url: url, url: url,
callBack: doSubmit callBack: doSubmit
}; };
$.modal.openOptions(options); $.modal.openOptions(options);
} } else {
else {
$.modal.alertError("主菜单不能选择"); $.modal.alertError("主菜单不能选择");
} }
} }

@ -216,7 +216,6 @@
var options = { var options = {
title: '选择部门', title: '选择部门',
width: "380", width: "380",
height: "380",
url: ctx + "system/dept/selectDeptTree/" + deptId, url: ctx + "system/dept/selectDeptTree/" + deptId,
callBack: doSubmit callBack: doSubmit
}; };

@ -189,7 +189,6 @@
var options = { var options = {
title: '选择部门', title: '选择部门',
width: "380", width: "380",
height: "380",
url: url, url: url,
callBack: doSubmit callBack: doSubmit
}; };

@ -173,9 +173,12 @@ public class SysDeptServiceImpl implements ISysDeptService
public int updateDept(SysDept dept) public int updateDept(SysDept dept)
{ {
SysDept info = deptMapper.selectDeptById(dept.getParentId()); SysDept info = deptMapper.selectDeptById(dept.getParentId());
String ancestors = info.getAncestors() + "," + dept.getParentId(); if (StringUtils.isNotNull(info))
dept.setAncestors(ancestors); {
updateDeptChildren(dept.getDeptId(), ancestors); String ancestors = info.getAncestors() + "," + dept.getParentId();
dept.setAncestors(ancestors);
updateDeptChildren(dept.getDeptId(), ancestors);
}
return deptMapper.updateDept(dept); return deptMapper.updateDept(dept);
} }

Loading…
Cancel
Save