diff --git a/yanzhu-admin/src/main/java/com/yanzhu/web/controller/system/SysDeptController.java b/yanzhu-admin/src/main/java/com/yanzhu/web/controller/system/SysDeptController.java index c3d50cc..610df83 100644 --- a/yanzhu-admin/src/main/java/com/yanzhu/web/controller/system/SysDeptController.java +++ b/yanzhu-admin/src/main/java/com/yanzhu/web/controller/system/SysDeptController.java @@ -70,7 +70,7 @@ public class SysDeptController extends BaseController /** * 根据部门编号获取详细信息 */ - @PreAuthorize("@ss.hasPermi('system:dept:query')") + @PreAuthorize("@ss.hasAnyPermi('system:dept:query,project:subCompany:edit,project:project:edit')") @GetMapping(value = "/{deptId}") public AjaxResult getInfo(@PathVariable Long deptId) { @@ -81,7 +81,7 @@ public class SysDeptController extends BaseController /** * 新增部门 */ - @PreAuthorize("@ss.hasPermi('system:dept:add')") + @PreAuthorize("@ss.hasAnyPermi('system:dept:query,project:subCompany:edit,project:project:edit')") @Log(title = "部门管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysDept dept) @@ -97,7 +97,7 @@ public class SysDeptController extends BaseController /** * 修改部门 */ - @PreAuthorize("@ss.hasPermi('system:dept:edit')") + @PreAuthorize("@ss.hasAnyPermi('system:dept:query,project:subCompany:edit,project:project:edit')") @Log(title = "部门管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysDept dept) diff --git a/yanzhu-common/src/main/java/com/yanzhu/common/core/domain/entity/SysDept.java b/yanzhu-common/src/main/java/com/yanzhu/common/core/domain/entity/SysDept.java index bc746c9..77cbbf7 100644 --- a/yanzhu-common/src/main/java/com/yanzhu/common/core/domain/entity/SysDept.java +++ b/yanzhu-common/src/main/java/com/yanzhu/common/core/domain/entity/SysDept.java @@ -54,6 +54,16 @@ public class SysDept extends BaseEntity private String unit; + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + private Integer level; + public String getUnit() { return unit; } diff --git a/yanzhu-manage/src/main/java/com/yanzhu/web/CompanyController.java b/yanzhu-manage/src/main/java/com/yanzhu/web/CompanyController.java index d5b69bc..a8acb37 100644 --- a/yanzhu-manage/src/main/java/com/yanzhu/web/CompanyController.java +++ b/yanzhu-manage/src/main/java/com/yanzhu/web/CompanyController.java @@ -30,7 +30,7 @@ public class CompanyController extends BaseController { return success(depts); } - @PreAuthorize("@ss.hasAnyPermi('project:subCompany:list')") + @PreAuthorize("@ss.hasAnyPermi('project:subCompany:list,project:project:list')") @PostMapping("/subList") public AjaxResult subList(@RequestBody SysDept where){ where.setDelFlag("0"); @@ -41,6 +41,14 @@ public class CompanyController extends BaseController { @Log(title = "段队管理", businessType = BusinessType.DELETE) @DeleteMapping("/{deptId}") public AjaxResult remove(@PathVariable Long deptId) { + SysDept where=new SysDept(); + where.setParentId(deptId); + where.setLevel(300); + where.setDelFlag("0"); + List list=deptService.selectDeptList(where); + if(list.size()>0){ + return AjaxResult.error("段队下面有项目,不能删除!"); + } return toAjax(deptService.deleteDeepDeptById(deptId)); } @@ -50,10 +58,20 @@ public class CompanyController extends BaseController { public AjaxResult addSubCompany(@RequestBody SysDept dept){ if (!deptService.checkDeptNameUnique(dept)) { - return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); + return error("新增部门'" + dept.getDeptName() + "'失败,段队名称已存在"); } dept.setCreateBy(getUsername()); return toAjax(deptService.insertSubCompany(dept)); } - + @PreAuthorize("@ss.hasAnyPermi('project:project:add')") + @Log(title = "项目管理", businessType = BusinessType.INSERT) + @PostMapping("/addSubProject") + public AjaxResult addSubProject(@RequestBody SysDept dept){ + if (!deptService.checkDeptNameUnique(dept)) + { + return error("新增部门'" + dept.getDeptName() + "'失败,项目名称已存在"); + } + dept.setCreateBy(getUsername()); + return toAjax(deptService.inertSubProject(dept)); + } } diff --git a/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysDeptService.java b/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysDeptService.java index 2591407..a5955f2 100644 --- a/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysDeptService.java +++ b/yanzhu-system/src/main/java/com/yanzhu/system/service/ISysDeptService.java @@ -137,5 +137,17 @@ public interface ISysDeptService */ public int deleteDeepDeptById(Long deptId); + /** + * 增加段队 + * @param dept + * @return + */ public int insertSubCompany(SysDept dept); + + /** + * 增加项目 + * @param dept + * @return + */ + public int inertSubProject(SysDept dept); } diff --git a/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysDeptServiceImpl.java b/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysDeptServiceImpl.java index b1b77be..947e9b0 100644 --- a/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysDeptServiceImpl.java +++ b/yanzhu-system/src/main/java/com/yanzhu/system/service/impl/SysDeptServiceImpl.java @@ -227,9 +227,10 @@ public class SysDeptServiceImpl implements ISysDeptService // 如果父节点不为正常状态,则不允许新增子节点 if (UserConstants.DEPT_DISABLE.equals(info.getStatus())) { - throw new ServiceException("部门停用,不允许新增"); + throw new ServiceException("段位停用,不允许新增"); } - dept.setStatus("3"); + dept.setStatus("0"); + dept.setLevel(2); dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); int id=deptMapper.insertDept(dept); String[] subDepts="成本部,行政部,工程部".split(","); @@ -243,11 +244,43 @@ public class SysDeptServiceImpl implements ISysDeptService dpt.setPhone(dept.getPhone()); dpt.setEmail(dept.getPhone()); dpt.setLeader(dept.getLeader()); - dpt.setStatus("4"); + dpt.setStatus("0"); + dpt.setLevel(3); deptMapper.insertDept(dpt); } return id; } + + @Override + public int inertSubProject(SysDept dept) { + SysDept info = deptMapper.selectDeptById(dept.getParentId()); + // 如果父节点不为正常状态,则不允许新增子节点 + if (UserConstants.DEPT_DISABLE.equals(info.getStatus())) + { + throw new ServiceException("项目停用,不允许新增"); + } + dept.setStatus("0"); + dept.setLevel(300); + dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); + int id=deptMapper.insertDept(dept); + String[] subDepts="科技部,采购部,商务部,工程部,财务部".split(","); + for(String it:subDepts){ + SysDept dpt=new SysDept(); + dpt.setParentId(dept.getDeptId()); + dpt.setAncestors(dept.getAncestors()+","+dpt.getParentId()); + dpt.setDeptName(it); + dpt.setCreateBy(dept.getCreateBy()); + dpt.setCreateTime(new Date()); + dpt.setPhone(dept.getPhone()); + dpt.setEmail(dept.getPhone()); + dpt.setLeader(dept.getLeader()); + dpt.setStatus("0"); + dpt.setLevel(4); + deptMapper.insertDept(dpt); + } + return id; + } + /** * 修改保存部门信息 * diff --git a/yanzhu-system/src/main/resources/mapper/system/SysDeptMapper.xml b/yanzhu-system/src/main/resources/mapper/system/SysDeptMapper.xml index 70c1984..75da5e9 100644 --- a/yanzhu-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/yanzhu-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -21,10 +21,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,d.unit + select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,d.unit,d.level from sys_dept d @@ -43,6 +44,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND status = #{status} + + AND level = #{level} + ${params.dataScope} order by d.parent_id, d.order_num @@ -101,6 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" status, create_by, unit, + level, create_time )values( #{deptId}, @@ -114,6 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{status}, #{createBy}, #{unit}, + #{level}, sysdate() ) @@ -131,6 +137,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" status = #{status}, update_by = #{updateBy}, unit = #{unit}, + level = #{level}, update_time = sysdate() where dept_id = #{deptId} @@ -161,6 +168,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update sys_dept set del_flag = '2' where ancestors like concat('%,', #{deptId}, ',%') or dept_id = #{deptId} + update sys_dept set del_flag = '2' where parent_id =#{deptId} or dept_id = #{deptId} \ No newline at end of file diff --git a/yanzhu-ui/src/api/project/company.js b/yanzhu-ui/src/api/project/company.js index b169f4b..053ce0c 100644 --- a/yanzhu-ui/src/api/project/company.js +++ b/yanzhu-ui/src/api/project/company.js @@ -26,10 +26,18 @@ export function companyList(data) { }) } - export function addSubCompany(data){ - return request({ - url: '/project/company/addSubCompany', - method: 'post', - data: data - }) - } \ No newline at end of file +export function addSubCompany(data){ + return request({ + url: '/project/company/addSubCompany', + method: 'post', + data: data + }) +} + +export function addSubProject(data){ + return request({ + url: '/project/company/addSubProject', + method: 'post', + data: data + }) +} \ No newline at end of file diff --git a/yanzhu-ui/src/views/login.vue b/yanzhu-ui/src/views/login.vue index 74ebb74..6aa9cb5 100644 --- a/yanzhu-ui/src/views/login.vue +++ b/yanzhu-ui/src/views/login.vue @@ -145,6 +145,7 @@ export default { Cookies.remove('rememberMe'); } this.$store.dispatch("Login", this.loginForm).then(() => { + this.$store.state.tagsView.visitedViews.splice(1) this.$router.push({ path: this.redirect || "/" }).catch(()=>{}); }).catch(() => { this.loading = false; diff --git a/yanzhu-ui/src/views/project/project/index.vue b/yanzhu-ui/src/views/project/project/index.vue index 1680cbb..fd76f6c 100644 --- a/yanzhu-ui/src/views/project/project/index.vue +++ b/yanzhu-ui/src/views/project/project/index.vue @@ -1,27 +1,13 @@ - + - \ No newline at end of file + + \ No newline at end of file diff --git a/yanzhu-ui/src/views/project/project/index2.vue b/yanzhu-ui/src/views/project/project/index2.vue new file mode 100644 index 0000000..1680cbb --- /dev/null +++ b/yanzhu-ui/src/views/project/project/index2.vue @@ -0,0 +1,288 @@ + + + + \ No newline at end of file diff --git a/yanzhu-ui/src/views/project/subCompany/index.vue b/yanzhu-ui/src/views/project/subCompany/index.vue index 72ef430..b19f8d5 100644 --- a/yanzhu-ui/src/views/project/subCompany/index.vue +++ b/yanzhu-ui/src/views/project/subCompany/index.vue @@ -125,6 +125,7 @@ export default { deptName: '', status: '', leader: '', + level:2 }, // 表单参数 form: {}, @@ -213,14 +214,7 @@ export default { this.form = response.data; this.form.parentId = 100; this.open = true; - this.title = "修改段队"; - listDeptExcludeChild(row.deptId).then(response => { - this.deptOptions = this.handleTree(response.data, "deptId"); - if (this.deptOptions.length == 0) { - const noResultsOptions = { deptId: this.form.parentId, deptName: this.form.parentName, children: [] }; - this.deptOptions.push(noResultsOptions); - } - }); + this.title = "修改段队"; }); }, /** 提交按钮 */ diff --git a/yanzhu-ui/src/views/system/user/index.vue b/yanzhu-ui/src/views/system/user/index.vue index 41f5818..9aea1a0 100644 --- a/yanzhu-ui/src/views/system/user/index.vue +++ b/yanzhu-ui/src/views/system/user/index.vue @@ -344,11 +344,23 @@ export default { setTimeout(()=>{ this.form.deptId=undefined; },400); - }else{ - if(a.data.status=='2'){//公司 + }else{ + if(a.data.level==1){//公司 this.roleOptions=this.oldRoleOptions.filter(d=>{ return d.roleName=="公司管理员"||d.roleName=="普通角色"; - }) + }); + }else if(a.data.level==2){//段队 + this.roleOptions=this.oldRoleOptions.filter(d=>{ + return d.roleName=="段队管理员"||d.roleName=="普通角色"; + }); + }else if(a.data.level==300){//项目 + this.roleOptions=this.oldRoleOptions.filter(d=>{ + return d.roleName=="项目管理员"||d.roleName=="普通角色"; + }); + }else{ + this.roleOptions=this.oldRoleOptions.filter(d=>{ + return d.roleName=="公司管理员"||d.roleName=="普通角色"; + }); } }