用户管理新增附属机构配置,支持一个用户配置多个部门,支持多部门数据权限过滤
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package com.jeesite.modules.sys.dao;
|
||||
|
||||
import com.jeesite.common.dao.CrudDao;
|
||||
import com.jeesite.common.mybatis.annotation.MyBatisDao;
|
||||
import com.jeesite.modules.sys.entity.EmployeeOffice;
|
||||
|
||||
/**
|
||||
* 员工附属机构关系表DAO接口
|
||||
* @author ThinkGem
|
||||
* @version 2019-04-29
|
||||
*/
|
||||
@MyBatisDao
|
||||
public interface EmployeeOfficeDao extends CrudDao<EmployeeOffice> {
|
||||
|
||||
}
|
||||
@@ -61,6 +61,7 @@ public class Employee extends DataEntity<Employee> {
|
||||
private String postCode; // 根据职位查询
|
||||
|
||||
private List<EmployeePost> employeePostList = ListUtils.newArrayList(); // 关联岗位信息
|
||||
private List<EmployeeOffice> employeeOfficeList = ListUtils.newArrayList(); // 关联附属机构信息
|
||||
|
||||
public Employee() {
|
||||
this(null);
|
||||
@@ -150,5 +151,13 @@ public class Employee extends DataEntity<Employee> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<EmployeeOffice> getEmployeeOfficeList() {
|
||||
return employeeOfficeList;
|
||||
}
|
||||
|
||||
public void setEmployeeOfficeList(List<EmployeeOffice> employeeOfficeList) {
|
||||
this.employeeOfficeList = employeeOfficeList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package com.jeesite.modules.sys.entity;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import com.jeesite.common.entity.DataEntity;
|
||||
import com.jeesite.common.mybatis.annotation.Column;
|
||||
import com.jeesite.common.mybatis.annotation.JoinTable;
|
||||
import com.jeesite.common.mybatis.annotation.Table;
|
||||
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
|
||||
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||
|
||||
/**
|
||||
* 附属机构Entity
|
||||
* @author ThinkGem
|
||||
* @version 2019-04-29
|
||||
*/
|
||||
@Table(name="${_prefix}sys_employee_office", alias="a", columns={
|
||||
@Column(name="id", attrName="id", label="编码", isPK=true),
|
||||
@Column(name="emp_code", attrName="empCode", label="员工编码"),
|
||||
@Column(name="office_code", attrName="officeCode", label="机构编码"),
|
||||
@Column(name="post_code", attrName="postCode", label="岗位编码"),
|
||||
}, joinTable={
|
||||
@JoinTable(type=Type.LEFT_JOIN, entity=Office.class, alias="o",
|
||||
on="o.office_code=a.office_code", attrName="this",
|
||||
columns={
|
||||
@Column(name="office_code", label="机构编码", isPK=true),
|
||||
@Column(name="parent_codes",label="所有父级编码", queryType=QueryType.LIKE),
|
||||
@Column(name="office_name", label="机构名称", isQuery=false),
|
||||
}),
|
||||
@JoinTable(type=Type.LEFT_JOIN, entity=Post.class, alias="p",
|
||||
on="p.post_code=a.post_code", attrName="this",
|
||||
columns={
|
||||
@Column(name="post_code", label="岗位编码", isPK=true),
|
||||
@Column(name="post_name", label="岗位名称", isQuery=false),
|
||||
}),
|
||||
}, orderBy="a.id ASC"
|
||||
)
|
||||
public class EmployeeOffice extends DataEntity<EmployeeOffice> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String empCode; // 员工编码
|
||||
private String officeCode; // 机构编码
|
||||
private String postCode; // 岗位编码
|
||||
|
||||
private String parentCodes; // 机构所有上级编码(数据权限用)
|
||||
private String officeName; // 机构名称(联合查询项)
|
||||
private String postName; // 岗位名称(联合查询项)
|
||||
|
||||
public EmployeeOffice() {
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public EmployeeOffice(String empCode, String officeCode){
|
||||
super(null);
|
||||
this.empCode = empCode;
|
||||
this.officeCode = officeCode;
|
||||
}
|
||||
|
||||
public String getEmpCode() {
|
||||
return empCode;
|
||||
}
|
||||
|
||||
public void setEmpCode(String empCode) {
|
||||
this.empCode = empCode;
|
||||
}
|
||||
|
||||
public String getOfficeCode() {
|
||||
return officeCode;
|
||||
}
|
||||
|
||||
public void setOfficeCode(String officeCode) {
|
||||
this.officeCode = officeCode;
|
||||
}
|
||||
|
||||
@Length(min=0, max=64, message="岗位编码长度不能超过 64 个字符")
|
||||
public String getPostCode() {
|
||||
return postCode;
|
||||
}
|
||||
|
||||
public void setPostCode(String postCode) {
|
||||
this.postCode = postCode;
|
||||
}
|
||||
|
||||
public String getParentCodes() {
|
||||
return parentCodes;
|
||||
}
|
||||
|
||||
public void setParentCodes(String parentCodes) {
|
||||
this.parentCodes = parentCodes;
|
||||
}
|
||||
|
||||
public String getOfficeName() {
|
||||
return officeName;
|
||||
}
|
||||
|
||||
public void setOfficeName(String officeName) {
|
||||
this.officeName = officeName;
|
||||
}
|
||||
|
||||
public String getPostName() {
|
||||
return postName;
|
||||
}
|
||||
|
||||
public void setPostName(String postName) {
|
||||
this.postName = postName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package com.jeesite.modules.sys.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.service.CrudService;
|
||||
import com.jeesite.modules.sys.dao.EmployeeOfficeDao;
|
||||
import com.jeesite.modules.sys.entity.EmployeeOffice;
|
||||
|
||||
/**
|
||||
* 附属机构Service
|
||||
* @author ThinkGem
|
||||
* @version 2019-05-05
|
||||
*/
|
||||
@Service
|
||||
@Transactional(readOnly=true)
|
||||
public class EmployeeOfficeService extends CrudService<EmployeeOfficeDao, EmployeeOffice> {
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
* @param employeeOffice
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public EmployeeOffice get(EmployeeOffice employeeOffice) {
|
||||
return super.get(employeeOffice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param employeeOffice 查询条件
|
||||
* @param employeeOffice.page 分页对象
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Page<EmployeeOffice> findPage(EmployeeOffice employeeOffice) {
|
||||
return super.findPage(employeeOffice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据(插入或更新)
|
||||
* @param employeeOffice
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly=false)
|
||||
public void save(EmployeeOffice employeeOffice) {
|
||||
super.save(employeeOffice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新状态
|
||||
* @param employeeOffice
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly=false)
|
||||
public void updateStatus(EmployeeOffice employeeOffice) {
|
||||
super.updateStatus(employeeOffice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param employeeOffice
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly=false)
|
||||
public void delete(EmployeeOffice employeeOffice) {
|
||||
super.delete(employeeOffice);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.service.api.CrudServiceApi;
|
||||
import com.jeesite.modules.sys.entity.Employee;
|
||||
import com.jeesite.modules.sys.entity.EmployeeOffice;
|
||||
import com.jeesite.modules.sys.entity.EmployeePost;
|
||||
|
||||
/**
|
||||
@@ -45,5 +46,10 @@ public interface EmployeeService extends CrudServiceApi<Employee> {
|
||||
* 查询当前员工关联的岗位信息
|
||||
*/
|
||||
public List<EmployeePost> findEmployeePostList(Employee employee);
|
||||
|
||||
/**
|
||||
* 查询当前员工关联的附属机构信息
|
||||
*/
|
||||
public List<EmployeeOffice> findEmployeeOfficeList(Employee employee);
|
||||
|
||||
}
|
||||
@@ -19,8 +19,10 @@ import com.jeesite.common.service.ServiceException;
|
||||
import com.jeesite.common.utils.excel.ExcelImport;
|
||||
import com.jeesite.common.validator.ValidatorUtils;
|
||||
import com.jeesite.modules.sys.dao.EmpUserDao;
|
||||
import com.jeesite.modules.sys.dao.EmployeeOfficeDao;
|
||||
import com.jeesite.modules.sys.entity.EmpUser;
|
||||
import com.jeesite.modules.sys.entity.Employee;
|
||||
import com.jeesite.modules.sys.entity.EmployeeOffice;
|
||||
import com.jeesite.modules.sys.entity.User;
|
||||
import com.jeesite.modules.sys.service.EmpUserService;
|
||||
import com.jeesite.modules.sys.service.EmployeeService;
|
||||
@@ -39,9 +41,10 @@ public class EmpUserServiceSupport extends CrudService<EmpUserDao, EmpUser>
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
@Autowired
|
||||
private EmployeeOfficeDao employeeOfficeDao;
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
@@ -131,6 +134,17 @@ public class EmpUserServiceSupport extends CrudService<EmpUserDao, EmpUser>
|
||||
// 3、保存员工
|
||||
employee.setIsNewRecord(user.getIsNewRecord());
|
||||
employeeService.save(employee);
|
||||
// 4、保存附属机构
|
||||
EmployeeOffice employeeOfficeWhere = new EmployeeOffice();
|
||||
employeeOfficeWhere.setEmpCode(employee.getEmpCode());
|
||||
employeeOfficeDao.deleteByEntity(employeeOfficeWhere);
|
||||
if (employee.getEmployeeOfficeList().size() > 0){
|
||||
employee.getEmployeeOfficeList().forEach(employeeOffice -> {
|
||||
employeeOffice.setId(IdGen.nextId());
|
||||
employeeOffice.setEmpCode(employee.getEmpCode());
|
||||
});
|
||||
employeeOfficeDao.insertBatch(employee.getEmployeeOfficeList());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,8 +12,10 @@ import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.service.CrudService;
|
||||
import com.jeesite.modules.sys.dao.EmployeeDao;
|
||||
import com.jeesite.modules.sys.dao.EmployeeOfficeDao;
|
||||
import com.jeesite.modules.sys.dao.EmployeePostDao;
|
||||
import com.jeesite.modules.sys.entity.Employee;
|
||||
import com.jeesite.modules.sys.entity.EmployeeOffice;
|
||||
import com.jeesite.modules.sys.entity.EmployeePost;
|
||||
import com.jeesite.modules.sys.service.EmployeeService;
|
||||
|
||||
@@ -25,9 +27,11 @@ import com.jeesite.modules.sys.service.EmployeeService;
|
||||
@Transactional(readOnly=true)
|
||||
public class EmployeeServiceSupport extends CrudService<EmployeeDao, Employee>
|
||||
implements EmployeeService{
|
||||
|
||||
|
||||
@Autowired
|
||||
private EmployeePostDao employeePostDao;
|
||||
@Autowired
|
||||
private EmployeeOfficeDao employeeOfficeDao;
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
@@ -86,4 +90,13 @@ public class EmployeeServiceSupport extends CrudService<EmployeeDao, Employee>
|
||||
employeePost.setEmpCode(employee.getEmpCode());
|
||||
return employeePostDao.findList(employeePost);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前员工关联的附属机构信息
|
||||
*/
|
||||
public List<EmployeeOffice> findEmployeeOfficeList(Employee employee){
|
||||
EmployeeOffice employeeOffice = new EmployeeOffice();
|
||||
employeeOffice.setEmpCode(employee.getEmpCode());
|
||||
return employeeOfficeDao.findList(employeeOffice);
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,16 @@ package com.jeesite.modules.sys.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.utils.SpringUtils;
|
||||
import com.jeesite.modules.sys.entity.Company;
|
||||
import com.jeesite.modules.sys.entity.Employee;
|
||||
import com.jeesite.modules.sys.entity.EmployeeOffice;
|
||||
import com.jeesite.modules.sys.entity.Office;
|
||||
import com.jeesite.modules.sys.entity.User;
|
||||
import com.jeesite.modules.sys.service.CompanyService;
|
||||
import com.jeesite.modules.sys.service.EmployeeOfficeService;
|
||||
import com.jeesite.modules.sys.service.OfficeService;
|
||||
|
||||
/**
|
||||
@@ -35,6 +38,7 @@ public class EmpUtils {
|
||||
private static final class Static {
|
||||
private static OfficeService officeService = SpringUtils.getBean(OfficeService.class);
|
||||
private static CompanyService companyService = SpringUtils.getBean(CompanyService.class);
|
||||
private static EmployeeOfficeService employeeOfficeService = SpringUtils.getBean(EmployeeOfficeService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,10 +58,45 @@ public class EmpUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前部门对象
|
||||
* 获取当前附属部门对象列表
|
||||
*/
|
||||
public static Office getOffice(){
|
||||
return getEmployee().getOffice();
|
||||
public static List<EmployeeOffice> getEmployeeOfficeList(){
|
||||
List<EmployeeOffice> list = UserUtils.getCache("employeeOfficeList");
|
||||
if (list == null){
|
||||
EmployeeOffice where = new EmployeeOffice();
|
||||
where.setEmpCode(getEmployee().getEmpCode());
|
||||
list = Static.employeeOfficeService.findList(where);
|
||||
UserUtils.putCache("employeeOfficeList", list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有部门编码,包括附属部门(数据权限用)
|
||||
* @return
|
||||
* @author ThinkGem
|
||||
*/
|
||||
public static String[] getOfficeCodes(){
|
||||
List<String> list = ListUtils.newArrayList();
|
||||
list.add(getOffice().getOfficeCode());
|
||||
getEmployeeOfficeList().forEach(e -> {
|
||||
list.add(e.getOfficeCode());
|
||||
});
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有部门编码,包括附属部门(数据权限用)
|
||||
* @return
|
||||
* @author ThinkGem
|
||||
*/
|
||||
public static String[] getOfficeParentCodess(){
|
||||
List<String> list = ListUtils.newArrayList();
|
||||
list.add(getOffice().getParentCodes());
|
||||
getEmployeeOfficeList().forEach(e -> {
|
||||
list.add(e.getParentCodes());
|
||||
});
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,6 +113,13 @@ public class EmpUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前员工附属部门
|
||||
*/
|
||||
public static Office getOffice(){
|
||||
return getEmployee().getOffice();
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * 获取当前用户有权限访问的机构
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package com.jeesite.modules.sys.web.user;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.web.BaseController;
|
||||
import com.jeesite.modules.sys.entity.EmployeeOffice;
|
||||
import com.jeesite.modules.sys.entity.Post;
|
||||
import com.jeesite.modules.sys.service.EmployeeOfficeService;
|
||||
import com.jeesite.modules.sys.service.PostService;
|
||||
|
||||
/**
|
||||
* 附属机构Controller
|
||||
* @author ThinkGem
|
||||
* @version 2019-05-05
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/empOffice")
|
||||
public class EmpOfficeController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private EmployeeOfficeService employeeOfficeService;
|
||||
@Autowired
|
||||
private PostService postService;
|
||||
|
||||
/**
|
||||
* 获取数据
|
||||
*/
|
||||
@ModelAttribute
|
||||
public EmployeeOffice get(String empCode, String officeCode, boolean isNewRecord) {
|
||||
return employeeOfficeService.get(new Class<?>[]{String.class, String.class},
|
||||
new Object[]{empCode, officeCode}, isNewRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
@RequiresPermissions("sys:empUser:view")
|
||||
@RequestMapping(value = {"list", ""})
|
||||
public String list(EmployeeOffice employeeOffice, Model model) {
|
||||
model.addAttribute("employeeOffice", employeeOffice);
|
||||
return "modules/sys/user/empOfficeList";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表数据
|
||||
*/
|
||||
@RequiresPermissions("sys:empUser:view")
|
||||
@RequestMapping(value = "listData")
|
||||
@ResponseBody
|
||||
public Page<EmployeeOffice> listData(EmployeeOffice employeeOffice, HttpServletRequest request, HttpServletResponse response) {
|
||||
employeeOffice.setPage(new Page<>(request, response));
|
||||
Page<EmployeeOffice> page = employeeOfficeService.findPage(employeeOffice);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看编辑表单
|
||||
*/
|
||||
@RequiresPermissions("sys:empUser:view")
|
||||
@RequestMapping(value = "form")
|
||||
public String form(EmployeeOffice employeeOffice, Model model) {
|
||||
// 获取岗位列表
|
||||
Post post = new Post();
|
||||
model.addAttribute("postList", postService.findList(post));
|
||||
model.addAttribute("employeeOffice", employeeOffice);
|
||||
return "modules/sys/user/empOfficeForm";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存附属机构
|
||||
*/
|
||||
@RequiresPermissions("sys:empUser:edit")
|
||||
@PostMapping(value = "save")
|
||||
@ResponseBody
|
||||
public String save(@Validated EmployeeOffice employeeOffice) {
|
||||
employeeOfficeService.save(employeeOffice);
|
||||
return renderResult(Global.TRUE, text("保存附属机构成功!"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除附属机构
|
||||
*/
|
||||
@RequiresPermissions("sys:empUser:edit")
|
||||
@RequestMapping(value = "delete")
|
||||
@ResponseBody
|
||||
public String delete(EmployeeOffice employeeOffice) {
|
||||
employeeOfficeService.delete(employeeOffice);
|
||||
return renderResult(Global.TRUE, text("删除附属机构成功!"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -123,9 +123,11 @@ public class EmpUserController extends BaseController {
|
||||
Post post = new Post();
|
||||
model.addAttribute("postList", postService.findList(post));
|
||||
|
||||
// 获取当前用户所拥有的岗位
|
||||
if (StringUtils.isNotBlank(employee.getEmpCode())){
|
||||
// 获取当前用户所拥有的岗位
|
||||
employee.setEmployeePostList(employeeService.findEmployeePostList(employee));
|
||||
// 获取当前员工关联的附属机构信息
|
||||
employee.setEmployeeOfficeList(employeeService.findEmployeeOfficeList(employee));
|
||||
}
|
||||
|
||||
// 获取当前编辑用户的角色和权限
|
||||
|
||||
@@ -160,16 +160,18 @@ user:
|
||||
# 角色管理
|
||||
role:
|
||||
# 扩展数据权限定义:3:本部门;4:本公司;5:本部门和本公司
|
||||
# ctrlTypeClass 控制的 Class 类,如果为 NONE,则代表是不控制该类型权限;
|
||||
# ctrlDataAttrName 控制的数据,返回当前用户有权限的数据值,可以接受 String 或 String[] 的类型;
|
||||
# ctrlDataParentCodesAttrName 控制的数据所有上级,用于控制数据为树表的情况,为数组时,必须与 ctrlDataAttrName 长度相同。
|
||||
extendDataScopes: >
|
||||
{
|
||||
3: {
|
||||
Office: {
|
||||
#控制类型的类名 : "用来获取控制表名和主键,如果为 NONE,则代表是不控制该类型权限;",
|
||||
ctrlTypeClass: "com.jeesite.modules.sys.entity.Office",
|
||||
ctrlDataAttrName: "currentUser.refObj.office.officeCode",
|
||||
ctrlDataParentCodesAttrName: "currentUser.refObj.office.parentCodes"
|
||||
#控制数据的类名: "指定一个静态类名,方便 ctrlDataAttrName 得到权限数据,如:当前部门编码、公司编码",
|
||||
ctrlDataClass: "com.jeesite.modules.sys.utils.EmpUtils",
|
||||
#控制数据的类名下的属性名 : "可看做类下的 get 方法,如:EmpUtils.getOffices(),支持返回字符串或字符串数组类型",
|
||||
ctrlDataAttrName: "officeCodes",
|
||||
#控制数据的所有上级编码 : "用于控制数据为树表的情况,为数组时,必须与 ctrlDataAttrName 返回的长度相同,不是树表设置为空",
|
||||
ctrlDataParentCodesAttrName: "officeParentCodess"
|
||||
},
|
||||
Company: {
|
||||
ctrlTypeClass: "NONE"
|
||||
@@ -181,20 +183,23 @@ role:
|
||||
},
|
||||
Company: {
|
||||
ctrlTypeClass: "com.jeesite.modules.sys.entity.Company",
|
||||
ctrlDataAttrName: "currentUser.refObj.company.companyCode",
|
||||
ctrlDataParentCodesAttrName: "currentUser.refObj.company.parentCodes"
|
||||
ctrlDataClass: "com.jeesite.modules.sys.utils.EmpUtils",
|
||||
ctrlDataAttrName: "company.companyCode",
|
||||
ctrlDataParentCodesAttrName: "company.parentCodes"
|
||||
}
|
||||
},
|
||||
5: {
|
||||
Office: {
|
||||
ctrlTypeClass: "com.jeesite.modules.sys.entity.Office",
|
||||
ctrlDataAttrName: "currentUser.refObj.office.officeCode",
|
||||
ctrlDataParentCodesAttrName: "currentUser.refObj.office.parentCodes"
|
||||
ctrlDataClass: "com.jeesite.modules.sys.utils.EmpUtils",
|
||||
ctrlDataAttrName: "officeCodes",
|
||||
ctrlDataParentCodesAttrName: "officeParentCodess"
|
||||
},
|
||||
Company: {
|
||||
ctrlTypeClass: "com.jeesite.modules.sys.entity.Company",
|
||||
ctrlDataAttrName: "currentUser.refObj.company.companyCode",
|
||||
ctrlDataParentCodesAttrName: "currentUser.refObj.company.parentCodes"
|
||||
ctrlDataClass: "com.jeesite.modules.sys.utils.EmpUtils",
|
||||
ctrlDataAttrName: "company.companyCode",
|
||||
ctrlDataParentCodesAttrName: "company.parentCodes"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
|
||||
-- 新增文件管理模块
|
||||
INSERT INTO js_sys_module(module_code, module_name, description, main_class_name, current_version, upgrade_info, status, create_by, create_date, update_by, update_date, remarks)
|
||||
VALUES ('filemanager', '文件管理', '公共文件柜、个人文件柜、文件分享', 'com.jeesite.modules.filemanager.web.FilemanagerController', '4.1.4', NULL, '0', 'system', getdate(), 'system', getdate(), NULL);
|
||||
|
||||
-- 员工附属机构关系表
|
||||
CREATE TABLE [js_sys_employee_office]
|
||||
(
|
||||
[id] varchar(64) NOT NULL UNIQUE,
|
||||
[emp_code] varchar(64) NOT NULL,
|
||||
[office_code] varchar(64) NOT NULL,
|
||||
[post_code] varchar(64),
|
||||
PRIMARY KEY ([emp_code], [office_code])
|
||||
);
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
|
||||
-- 新增文件管理模块
|
||||
INSERT INTO js_sys_module(module_code, module_name, description, main_class_name, current_version, upgrade_info, status, create_by, create_date, update_by, update_date, remarks)
|
||||
VALUES ('filemanager', '文件管理', '公共文件柜、个人文件柜、文件分享', 'com.jeesite.modules.filemanager.web.FilemanagerController', '4.1.4', NULL, '0', 'system', now(), 'system', now(), NULL);
|
||||
|
||||
-- 员工附属机构关系表
|
||||
CREATE TABLE js_sys_employee_office
|
||||
(
|
||||
id varchar(64) NOT NULL COMMENT '编号',
|
||||
emp_code varchar(64) NOT NULL COMMENT '员工编码',
|
||||
office_code varchar(64) NOT NULL COMMENT '机构编码',
|
||||
post_code varchar(64) COMMENT '岗位编码',
|
||||
PRIMARY KEY (emp_code, office_code),
|
||||
UNIQUE (id)
|
||||
) COMMENT = '员工附属机构关系表';
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
|
||||
-- 新增文件管理模块
|
||||
INSERT INTO js_sys_module(module_code, module_name, description, main_class_name, current_version, upgrade_info, status, create_by, create_date, update_by, update_date, remarks)
|
||||
VALUES ('filemanager', '文件管理', '公共文件柜、个人文件柜、文件分享', 'com.jeesite.modules.filemanager.web.FilemanagerController', '4.1.4', NULL, '0', 'system', sysdate, 'system', sysdate, NULL);
|
||||
|
||||
-- 员工附属机构关系表
|
||||
CREATE TABLE js_sys_employee_office
|
||||
(
|
||||
id varchar2(64) NOT NULL UNIQUE,
|
||||
emp_code varchar2(64) NOT NULL,
|
||||
office_code varchar2(64) NOT NULL,
|
||||
post_code varchar2(64),
|
||||
PRIMARY KEY (emp_code, office_code)
|
||||
);
|
||||
COMMENT ON TABLE js_sys_employee_office IS '员工附属机构关系表';
|
||||
COMMENT ON COLUMN js_sys_employee_office.id IS '编号';
|
||||
COMMENT ON COLUMN js_sys_employee_office.emp_code IS '员工编码';
|
||||
COMMENT ON COLUMN js_sys_employee_office.office_code IS '机构编码';
|
||||
COMMENT ON COLUMN js_sys_employee_office.post_code IS '岗位编码';
|
||||
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
|
||||
-- 新增文件管理模块
|
||||
INSERT INTO js_sys_module(module_code, module_name, description, main_class_name, current_version, upgrade_info, status, create_by, create_date, update_by, update_date, remarks)
|
||||
VALUES ('filemanager', '文件管理', '公共文件柜、个人文件柜、文件分享', 'com.jeesite.modules.filemanager.web.FilemanagerController', '4.1.4', NULL, '0', 'system', now(), 'system', now(), NULL);
|
||||
|
||||
-- 员工附属机构关系表
|
||||
CREATE TABLE js_sys_employee_office
|
||||
(
|
||||
id varchar(64) NOT NULL UNIQUE,
|
||||
emp_code varchar(64) NOT NULL,
|
||||
office_code varchar(64) NOT NULL,
|
||||
post_code varchar(64),
|
||||
PRIMARY KEY (emp_code, office_code)
|
||||
) WITHOUT OIDS;
|
||||
COMMENT ON TABLE js_sys_employee_office IS '员工附属机构关系表';
|
||||
COMMENT ON COLUMN js_sys_employee_office.id IS '编号';
|
||||
COMMENT ON COLUMN js_sys_employee_office.emp_code IS '员工编码';
|
||||
COMMENT ON COLUMN js_sys_employee_office.office_code IS '机构编码';
|
||||
COMMENT ON COLUMN js_sys_employee_office.post_code IS '岗位编码';
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jeesite.modules.sys.dao.EmployeeOfficeDao">
|
||||
|
||||
<!-- 查询数据
|
||||
<select id="findList" resultType="EmployeeOffice">
|
||||
SELECT ${sqlMap.column.toSql()}
|
||||
FROM ${sqlMap.table.toSql()}
|
||||
<where>
|
||||
${sqlMap.where.toSql()}
|
||||
</where>
|
||||
ORDER BY ${sqlMap.order.toSql()}
|
||||
</select> -->
|
||||
|
||||
</mapper>
|
||||
@@ -107,7 +107,7 @@ for (c in child.columnList){
|
||||
id: 'office_'+editOptions.id, title: '机构选择',
|
||||
name: '${c.attrName}', value: val.split('|')[0],
|
||||
labelName: '${c.attrName2}', labelValue: val.split('|')[1],
|
||||
url: '\${ctx}/sys/office/treeData?officeTypes=1,2', cssClass: '${cssClass}'
|
||||
url: '\${ctx}/sys/office/treeData', cssClass: '${cssClass}'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<% layout('/layouts/default.html', {title: '附属机构管理', libs: ['validate']}){ %>
|
||||
<div class="main-content">
|
||||
<div class="box box-main">
|
||||
<div class="box-header with-border">
|
||||
<div class="box-title">
|
||||
<i class="fa fa-list-alt"></i> ${text(employeeOffice.isNewRecord ? '新增附属机构' : '编辑附属机构')}
|
||||
</div>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<#form:form id="inputForm" model="${employeeOffice}" action="${ctx}/sys/empOffice/save" method="post" class="form-horizontal">
|
||||
<#form:hidden path="empCode"/>
|
||||
<#form:hidden path="isNewRecord"/>
|
||||
<div class="box-body"><br/>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" title="">
|
||||
<span class="required hide">*</span> ${text('附属机构')}:<i class="fa icon-question hide"></i></label>
|
||||
<div class="col-sm-5">
|
||||
<#form:treeselect id="office" title="${text('机构选择')}"
|
||||
path="officeCode" labelPath="officeName" readonly="${!employeeOffice.isNewRecord}"
|
||||
url="${ctx}/sys/office/treeData?ctrlPermi=2" class="required" allowClear="false"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" title="">
|
||||
<span class="required hide">*</span> ${text('岗位编码')}:<i class="fa icon-question hide"></i></label>
|
||||
<div class="col-sm-5">
|
||||
<#form:select name="postCode" items="${postList}"
|
||||
itemLabel="postName" itemValue="postCode" class="form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<% if (hasPermi('sys:empUser:view')){ %>
|
||||
<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>
|
||||
<% } %>
|
||||
<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</#form:form>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<script>
|
||||
$("#inputForm").validate({
|
||||
submitHandler: function(form){
|
||||
js.ajaxSubmitForm($(form), function(data){
|
||||
js.showMessage(data.message);
|
||||
if(data.result == Global.TRUE){
|
||||
js.closeCurrentTabPage(function(contentWindow){
|
||||
contentWindow.page();
|
||||
});
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,53 @@
|
||||
<% layout('/layouts/default.html', {title: '附属机构管理', libs: ['dataGrid']}){ %>
|
||||
<div class="main-content">
|
||||
<div class="box box-main">
|
||||
<div class="box-header">
|
||||
<div class="box-title">
|
||||
<i class="fa fa-list-alt"></i> ${text('附属机构管理')}
|
||||
</div>
|
||||
<div class="box-tools pull-right">
|
||||
<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
|
||||
<% if(hasPermi('sys:empUser:view')){ %>
|
||||
<a href="${ctx}/sys/empOffice/form?empCode=1&isNewRecord=true" class="btn btn-default btnTool" title="${text('新增附属机构')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<#form:form id="searchForm" model="${employeeOffice}" action="${ctx}/sys/empOffice/listData" method="post" class="form-inline hide"
|
||||
data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
|
||||
<#form:hidden path="empCode"/>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
|
||||
<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
|
||||
</div>
|
||||
</#form:form>
|
||||
<table id="dataGrid"></table>
|
||||
<div id="dataGridPage"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<script>
|
||||
// 初始化DataGrid对象
|
||||
$('#dataGrid').dataGrid({
|
||||
searchForm: $("#searchForm"),
|
||||
columnModel: [
|
||||
{header:'${text("附属机构")}', name:'officeCode', index:'a.office_code', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){
|
||||
return '<a href="${ctx}/sys/empOffice/form?empCode='+row.empCode+'&officeCode='+row.officeCode+'" class="btnList" data-title="${text("编辑附属机构")}">'+(val||row.id)+'</a>';
|
||||
}},
|
||||
{header:'${text("岗位编码")}', name:'postCode', index:'a.post_code', width:200, align:"center"},
|
||||
{header:'${text("操作")}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
|
||||
var actions = [];
|
||||
<% if(hasPermi('sys:empUser:view')){ %>
|
||||
actions.push('<a href="${ctx}/sys/empOffice/form?empCode='+row.empCode+'&officeCode='+row.officeCode+'" class="btnList" title="${text("编辑附属机构")}"><i class="fa fa-pencil"></i></a> ');
|
||||
actions.push('<a href="${ctx}/sys/empOffice/delete?empCode='+row.empCode+'&officeCode='+row.officeCode+'" class="btnList" title="${text("删除附属机构")}" data-confirm="${text("确认要删除该附属机构吗?")}"><i class="fa fa-trash-o"></i></a> ');
|
||||
<% } %>
|
||||
return actions.join('');
|
||||
}}
|
||||
],
|
||||
// 加载成功后执行事件
|
||||
ajaxSuccess: function(data){
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -143,8 +143,8 @@
|
||||
<label class="control-label col-sm-4" title="">
|
||||
<span class="required hide">*</span> ${text('所在岗位')}:<i class="fa icon-question hide"></i></label>
|
||||
<div class="col-sm-8">
|
||||
<#form:select multiple="true" path="employee.employeePosts" items="${postList}"
|
||||
itemLabel="postName" itemValue="postCode" class="form-control"/>
|
||||
<#form:select multiple="true" path="employee.employeePosts" items="${postList}"
|
||||
itemLabel="postName" itemValue="postCode" class="form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -158,6 +158,20 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" title="">
|
||||
<span class="required hide">*</span> ${text('附属机构')}:<i class="fa icon-question hide"></i></label>
|
||||
<div class="col-sm-10">
|
||||
<table id="empOfficeGrid"></table>
|
||||
<% if (hasPermi('sys:empUser:edit')){ %>
|
||||
<a href="#" id="empOfficeGridAddRowBtn" class="btn btn-primary btn-sm mt10 mb10"><i class="fa fa-plus"></i> ${text('增行')}</a>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
@@ -195,21 +209,59 @@
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<script id="treeselectTpl" type="text/template">//<!--<div>
|
||||
<#form:treeselect id="{{d.id}}" title="{{d.title}}" name="{{d.name}}" value="{{d.value}}"
|
||||
labelName="{{d.labelName}}" labelValue="{{d.labelValue}}" url="{{d.url}}"
|
||||
class="{{d.cssClass}}" btnClass="btn-sm" allowClear="true"/>
|
||||
</div>//--></script>
|
||||
<script>
|
||||
$("#inputForm").validate({
|
||||
submitHandler: function(form){
|
||||
<% if(op == 'add' || op == 'auth') { // 获取选中角色 %>
|
||||
$("#userRoleString").val(roleGrid.dataGrid('getSelectRows').join(','));
|
||||
<% } %>
|
||||
js.ajaxSubmitForm($(form), function(data){
|
||||
js.showMessage(data.message);
|
||||
if(data.result == Global.TRUE){
|
||||
js.closeCurrentTabPage(function(contentWindow){
|
||||
contentWindow.page();
|
||||
});
|
||||
$("#empOfficeGrid").dataGrid({
|
||||
data: ${toJson(empUser.employee.employeeOfficeList)},
|
||||
datatype: "local", // 设置本地数据
|
||||
columnModel: [
|
||||
{header:'${text("附属机构")}', name:'officeName', sortable:false, width:100,
|
||||
formatter: function(val, obj, row, act){
|
||||
return js.val(row, 'officeCode')+'|'+js.val(row, 'officeName');
|
||||
}, editable: true, edittype: "custom", editoptions: {
|
||||
custom_element: function(val, editOptions) {
|
||||
return js.template('treeselectTpl', {
|
||||
id: 'office_'+editOptions.id, title: '机构选择',
|
||||
name: 'officeCode', value: val.split('|')[0],
|
||||
labelName: 'officeName', labelValue: val.split('|')[1],
|
||||
url: '${ctx}/sys/office/treeData', cssClass: 'required'
|
||||
});
|
||||
}
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
},
|
||||
{header:'${text("附属岗位")}', name:'postCode', sortable:false, width:100,
|
||||
editable:true, edittype:'select', editoptions:{'class':'form-control',
|
||||
items: $.merge([{postName:' ',postCode:''}], ${toJson(postList)}),
|
||||
itemLabel: 'postName', itemValue: 'postCode', dataInit: function(element){
|
||||
$(element).select2().on("change",function(){$(this).valid()});
|
||||
}
|
||||
}
|
||||
},
|
||||
{header:'${text("操作")}', name:'actions', width:80, sortable:false, fixed:true, formatter: function(val, obj, row, act){
|
||||
var actions = [];
|
||||
actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗?")}\', function(){$(\'#empOfficeGrid\').dataGrid(\'delRowData\',\''+obj.rowId+'\')});return false;"><i class="fa fa-trash-o"></i></a> ');
|
||||
return actions.join('');
|
||||
}, editoptions: {defaultValue: 'new'}}
|
||||
],
|
||||
autoGridHeight: function(){return 'auto'}, // 设置自动高度
|
||||
|
||||
// 编辑表格参数
|
||||
editGrid: true, // 是否是编辑表格
|
||||
editGridInitRowNum: 0, // 编辑表格的初始化新增行数
|
||||
editGridAddRowBtn: $('#empOfficeGridAddRowBtn'), // 子表增行按钮
|
||||
editGridAddRowInitData: {id: '', status: Global.STATUS_NORMAL}, // 新增行的时候初始化的数据
|
||||
|
||||
// 编辑表格的提交数据参数
|
||||
editGridInputFormListName: 'employee.employeeOfficeList', // 提交的数据列表名
|
||||
editGridInputFormListAttrs: 'officeCode,officeName,postCode,postName,', // 提交数据列表的属性字段
|
||||
|
||||
ajaxSuccess: function(){
|
||||
|
||||
}
|
||||
});
|
||||
<% if(op == 'add' || op == 'auth') {%>
|
||||
// 加载角色列表
|
||||
@@ -237,4 +289,19 @@ var roleGrid = $("#roleGrid").dataGrid({
|
||||
}
|
||||
});
|
||||
<% } %>
|
||||
$("#inputForm").validate({
|
||||
submitHandler: function(form){
|
||||
<% if(op == 'add' || op == 'auth') { // 获取选中角色 %>
|
||||
$("#userRoleString").val(roleGrid.dataGrid('getSelectRows').join(','));
|
||||
<% } %>
|
||||
js.ajaxSubmitForm($(form), function(data){
|
||||
js.showMessage(data.message);
|
||||
if(data.result == Global.TRUE){
|
||||
js.closeCurrentTabPage(function(contentWindow){
|
||||
contentWindow.page();
|
||||
});
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user