forked from github/dataease
Merge pull request #572 from dataease/pr@dev@feat_add_xpack_api
feat: 增加xpack插件内api
This commit is contained in:
commit
a211b8b765
@ -1,6 +1,7 @@
|
||||
package io.dataease.auth.api.dto;
|
||||
|
||||
import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@ -11,7 +12,9 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
public class CurrentUserDto extends SysUserEntity implements Serializable {
|
||||
|
||||
@ApiModelProperty("角色集合")
|
||||
private List<CurrentRoleDto> roles;
|
||||
|
||||
@ApiModelProperty("权限集合")
|
||||
private List<String> permissions;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.dataease.auth.entity;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -8,23 +9,33 @@ import java.io.Serializable;
|
||||
|
||||
public class SysUserEntity implements Serializable {
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("账号")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty("姓名")
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty("组织ID")
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("状态")
|
||||
private Integer enabled;
|
||||
|
||||
@ApiModelProperty("邮箱")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty("电话")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String language;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Boolean isAdmin;
|
||||
}
|
||||
|
@ -1,12 +1,17 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysMsgChannel implements Serializable {
|
||||
|
||||
@ApiModelProperty("消息渠道ID")
|
||||
private Long msgChannelId;
|
||||
|
||||
@ApiModelProperty("消息渠道名称")
|
||||
private String channelName;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -1,18 +1,25 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysMsgSetting implements Serializable {
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long msgSettingId;
|
||||
|
||||
@ApiModelProperty("订阅用户ID")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("订阅类型ID")
|
||||
private Long typeId;
|
||||
|
||||
@ApiModelProperty("订阅渠道ID")
|
||||
private Long channelId;
|
||||
|
||||
@ApiModelProperty("订阅状态ID")
|
||||
private Boolean enable;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -1,18 +1,26 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysMsgType implements Serializable {
|
||||
|
||||
@ApiModelProperty("消息类型ID")
|
||||
private Long msgTypeId;
|
||||
|
||||
@ApiModelProperty("上级类型ID")
|
||||
private Long pid;
|
||||
|
||||
@ApiModelProperty("消息类型名称")
|
||||
private String typeName;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String router;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String callback;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -1,40 +1,58 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysUser implements Serializable {
|
||||
@ApiModelProperty(value = "用户ID" , allowEmptyValue = false, position = 0)
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "组织ID" , allowEmptyValue = false, position = 7)
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty(value = "账号" , required = true)
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "姓名" , required = true, position = 2)
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty(value = "性别" ,allowableValues = "男,女", allowEmptyValue = true, position = 5)
|
||||
private String gender;
|
||||
|
||||
@ApiModelProperty(value = "电话" , allowEmptyValue = true, position = 1)
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "邮箱" , required = true, position = 3)
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "密码" , required = true, position = 4)
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Boolean isAdmin;
|
||||
|
||||
@ApiModelProperty(value = "状态" , allowableValues = "1,0", required = true, position = 6)
|
||||
private Long enabled;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long pwdResetTime;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long createTime;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long updateTime;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String language;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -0,0 +1,28 @@
|
||||
package io.dataease.commons.condition;
|
||||
|
||||
import io.dataease.commons.license.DefaultLicenseService;
|
||||
import io.dataease.commons.license.F2CLicenseResponse;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.context.annotation.Condition;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
|
||||
|
||||
|
||||
public class LicStatusCondition implements Condition {
|
||||
|
||||
@Override
|
||||
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
|
||||
// BeanDefinitionRegistry registry = conditionContext.getRegistry();
|
||||
|
||||
DefaultLicenseService defaultLicenseService = conditionContext.getBeanFactory().getBean(DefaultLicenseService.class);
|
||||
/*if (null == defaultLicenseService) {
|
||||
registry.registerBeanDefinition();
|
||||
}*/
|
||||
if (ObjectUtils.isNotEmpty(defaultLicenseService)) {
|
||||
F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.validateLicense();
|
||||
return F2CLicenseResponse.Status.valid == f2CLicenseResponse.getStatus();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,13 +1,10 @@
|
||||
package io.dataease.config;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
|
||||
import io.dataease.commons.condition.LicStatusCondition;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.context.annotation.*;
|
||||
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
|
||||
import springfox.documentation.builders.*;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
@ -15,6 +12,8 @@ import springfox.documentation.service.*;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -29,6 +28,7 @@ public class Knife4jConfiguration {
|
||||
private String version;
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
public Knife4jConfiguration(OpenApiExtensionResolver openApiExtensionResolver) {
|
||||
this.openApiExtensionResolver = openApiExtensionResolver;
|
||||
@ -64,6 +64,13 @@ public class Knife4jConfiguration {
|
||||
return defaultApi("系统管理", "io.dataease.controller.sys");
|
||||
}
|
||||
|
||||
@Bean(value = "pluginsApi")
|
||||
/*@DependsOn(value = "licStatusCondition")*/
|
||||
@Conditional(LicStatusCondition.class)
|
||||
public Docket pluginsApi() {
|
||||
return defaultApi("插件管理", "io.dataease.plugins.server");
|
||||
}
|
||||
|
||||
|
||||
private ApiInfo apiInfo(){
|
||||
return new ApiInfoBuilder()
|
||||
|
@ -4,14 +4,14 @@ import io.dataease.base.domain.SysDept;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.DeptCreateRequest;
|
||||
/*import io.dataease.controller.sys.request.DeptCreateRequest;
|
||||
import io.dataease.controller.sys.request.DeptDeleteRequest;
|
||||
import io.dataease.controller.sys.request.DeptStatusRequest;
|
||||
import io.dataease.controller.sys.request.DeptStatusRequest;*/
|
||||
import io.dataease.controller.sys.response.DeptNodeResponse;
|
||||
import io.dataease.controller.sys.response.DeptTreeNode;
|
||||
import io.dataease.service.sys.DeptService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
/*import io.swagger.annotations.ApiOperation;*/
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -46,7 +46,6 @@ public class SysDeptController extends ResultHolder {
|
||||
@PostMapping("/search")
|
||||
public List<DeptNodeResponse> search(@RequestBody BaseGridRequest request){
|
||||
List<SysDept> nodes = deptService.nodesTreeByCondition(request);
|
||||
//List<SysDept> nodes = deptService.nodesByPid(pid);
|
||||
List<DeptNodeResponse> nodeResponses = nodes.stream().map(node -> {
|
||||
DeptNodeResponse deptNodeResponse = BeanUtils.copyBean(new DeptNodeResponse(), node);
|
||||
deptNodeResponse.setHasChildren(node.getSubCount() > 0);
|
||||
@ -57,14 +56,14 @@ public class SysDeptController extends ResultHolder {
|
||||
return nodeResponses;
|
||||
}
|
||||
|
||||
@ApiOperation("查询部门")
|
||||
/*@ApiOperation("查询部门")
|
||||
@PostMapping("/root")
|
||||
public ResultHolder rootData(){
|
||||
List<SysDept> root = deptService.nodesByPid(null);
|
||||
return success(root);
|
||||
}
|
||||
}*/
|
||||
|
||||
@ApiOperation("新增部门")
|
||||
/*@ApiOperation("新增部门")
|
||||
@PostMapping("/create")
|
||||
public void create(@RequestBody DeptCreateRequest dept){
|
||||
deptService.add(dept);
|
||||
@ -84,7 +83,7 @@ public class SysDeptController extends ResultHolder {
|
||||
@PostMapping("/updateStatus")
|
||||
public void updateStatus(@RequestBody DeptStatusRequest request){
|
||||
deptService.updateStatus(request);
|
||||
}
|
||||
}*/
|
||||
|
||||
@PostMapping("/nodesByDeptId/{deptId}")
|
||||
public List<DeptTreeNode> nodesByDeptId(@PathVariable("deptId") Long deptId){
|
||||
|
@ -1,30 +1,30 @@
|
||||
package io.dataease.controller.sys;
|
||||
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
/*import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.dataease.base.domain.SysRole;
|
||||
import io.dataease.commons.utils.PageUtils;
|
||||
import io.dataease.commons.utils.Pager;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.RoleMenusRequest;
|
||||
import io.dataease.controller.sys.request.RoleMenusRequest;*/
|
||||
import io.dataease.controller.sys.response.RoleUserItem;
|
||||
import io.dataease.service.sys.SysRoleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
/*import io.swagger.annotations.ApiOperation;*/
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
@ApiIgnore
|
||||
/*@ApiIgnore
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "系统:角色管理")
|
||||
@RequestMapping("/api/role")
|
||||
public class SysRoleController {
|
||||
|
||||
public class SysRoleController {*/
|
||||
/*
|
||||
@Resource
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
@ -74,4 +74,5 @@ public class SysRoleController {
|
||||
public List<RoleUserItem> all(){
|
||||
return sysRoleService.allRoles();
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*}*/
|
||||
|
@ -12,7 +12,9 @@ import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.SysUserCreateRequest;
|
||||
import io.dataease.controller.sys.request.SysUserPwdRequest;
|
||||
import io.dataease.controller.sys.request.SysUserStateRequest;
|
||||
import io.dataease.controller.sys.response.RoleUserItem;
|
||||
import io.dataease.controller.sys.response.SysUserGridResponse;
|
||||
import io.dataease.service.sys.SysRoleService;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -32,6 +34,9 @@ public class SysUserController {
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
@ApiOperation("查询用户")
|
||||
@PostMapping("/userGrid/{goPage}/{pageSize}")
|
||||
public Pager<List<SysUserGridResponse>> userGrid(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody BaseGridRequest request) {
|
||||
@ -68,26 +73,27 @@ public class SysUserController {
|
||||
sysUserService.updateStatus(request);
|
||||
}
|
||||
|
||||
@ApiOperation("用户更新密码")
|
||||
@ApiOperation("更新当前用户密码")
|
||||
@PostMapping("/updatePwd")
|
||||
public void updatePwd(@RequestBody SysUserPwdRequest request){
|
||||
|
||||
sysUserService.updatePwd(request);
|
||||
}
|
||||
@ApiOperation("管理员更新密码")
|
||||
@ApiOperation("更新指定用户密码")
|
||||
@PostMapping("/adminUpdatePwd")
|
||||
public void adminUpdatePwd(@RequestBody SysUserPwdRequest request){
|
||||
sysUserService.adminUpdatePwd(request);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("个人信息")
|
||||
@ApiOperation("当前用户信息")
|
||||
@PostMapping("/personInfo")
|
||||
public CurrentUserDto personInfo() {
|
||||
CurrentUserDto user = AuthUtils.getUser();
|
||||
return user;
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@ApiOperation("更新个人信息")
|
||||
@PostMapping("/updatePersonInfo")
|
||||
public void updatePersonInfo(@RequestBody SysUserCreateRequest request){
|
||||
@ -104,4 +110,10 @@ public class SysUserController {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ApiOperation("查询所有角色")
|
||||
@PostMapping("/all")
|
||||
public List<RoleUserItem> all(){
|
||||
return sysRoleService.allRoles();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.dataease.controller.sys.base;
|
||||
|
||||
import io.dataease.base.mapper.ext.query.GridExample;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -9,6 +10,7 @@ import java.util.List;
|
||||
|
||||
public class BaseGridRequest implements Serializable {
|
||||
|
||||
@ApiModelProperty("查询条件")
|
||||
private List<ConditionEntity> conditions;
|
||||
|
||||
public List<ConditionEntity> getConditions() {
|
||||
@ -27,6 +29,7 @@ public class BaseGridRequest implements Serializable {
|
||||
this.orders = orders;
|
||||
}
|
||||
|
||||
@ApiModelProperty("排序描述")
|
||||
private List<String> orders;
|
||||
|
||||
public GridExample convertExample(){
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.dataease.controller.sys.base;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -7,10 +8,13 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class ConditionEntity implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "字段")
|
||||
private String field;
|
||||
|
||||
@ApiModelProperty(value = "操作符")
|
||||
private String operator;
|
||||
|
||||
@ApiModelProperty(value = "字段值")
|
||||
private Object value;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -7,10 +8,10 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BatchSettingRequest implements Serializable {
|
||||
|
||||
@ApiModelProperty("消息类型ID集合")
|
||||
private List<Long> typeIds;
|
||||
|
||||
@ApiModelProperty("消息类型ID")
|
||||
private Long channelId;
|
||||
|
||||
@ApiModelProperty("订阅状态")
|
||||
private Boolean enable;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -10,9 +11,12 @@ public class MsgRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1920091635946508658L;
|
||||
|
||||
@ApiModelProperty("消息类型ID")
|
||||
private Long type;
|
||||
|
||||
@ApiModelProperty("是否订阅")
|
||||
private Boolean status;
|
||||
|
||||
@ApiModelProperty("排序描述")
|
||||
private List<String> orders;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -8,7 +9,9 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class MsgSettingRequest implements Serializable {
|
||||
|
||||
@ApiModelProperty("消息类型ID")
|
||||
private Long typeId;
|
||||
|
||||
@ApiModelProperty("消息渠道ID")
|
||||
private Long channelId;
|
||||
}
|
||||
|
@ -1,13 +1,16 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
import io.dataease.base.domain.SysUser;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SysUserCreateRequest extends SysUser {
|
||||
|
||||
@ApiModelProperty(value = "角色ID集合", required = true, position = 7)
|
||||
private List<Long> roleIds;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -8,9 +9,13 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class SysUserPwdRequest implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "用户ID", required = true)
|
||||
private Long userId;
|
||||
@ApiModelProperty(value = "旧密码(密文)", required = true)
|
||||
private String password;
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String repeatPassword;
|
||||
@ApiModelProperty(value = "新密码(明文)", required = true)
|
||||
private String newPassword;
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -7,7 +8,9 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class SysUserStateRequest implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "用户ID", required = true)
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, allowableValues = "1,0")
|
||||
private Long enabled;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.dataease.controller.sys.response;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -11,9 +12,12 @@ public class SettingTreeNode implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2416283978185545199L;
|
||||
|
||||
@ApiModelProperty("消息类型ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("消息类型名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("子节点")
|
||||
private List<SettingTreeNode> children;
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
@ -17,6 +19,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@ApiIgnore
|
||||
@RestController
|
||||
@RequestMapping("/api/pluginCommon")
|
||||
public class PluginCommonServer {
|
||||
|
@ -11,14 +11,19 @@ import io.dataease.plugins.xpack.dept.dto.request.XpackMoveDept;
|
||||
import io.dataease.plugins.xpack.dept.dto.response.XpackDeptTreeNode;
|
||||
import io.dataease.plugins.xpack.dept.dto.response.XpackSysDept;
|
||||
import io.dataease.plugins.xpack.dept.service.DeptXpackService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(tags = "xpack:部门管理")
|
||||
@RequestMapping("/plugin/dept")
|
||||
@RestController
|
||||
public class XDeptServer {
|
||||
|
||||
@ApiOperation("查询子节点")
|
||||
@PostMapping("/childNodes/{pid}")
|
||||
public List<DeptNodeResponse> childNodes(@PathVariable("pid") Long pid){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
@ -33,6 +38,7 @@ public class XDeptServer {
|
||||
return nodeResponses;
|
||||
}
|
||||
|
||||
@ApiOperation("搜索组织树")
|
||||
@PostMapping("/search")
|
||||
public List<DeptNodeResponse> search(@RequestBody XpackGridRequest request){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
@ -47,6 +53,7 @@ public class XDeptServer {
|
||||
return nodeResponses;
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/root")
|
||||
public List<XpackSysDept> rootData(){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
@ -54,18 +61,21 @@ public class XDeptServer {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
@ApiOperation("创建")
|
||||
@PostMapping("/create")
|
||||
public int create(@RequestBody XpackCreateDept dept){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
return deptService.add(dept);
|
||||
}
|
||||
|
||||
@ApiOperation("删除")
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestBody List<XpackDeleteDept> requests){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
deptService.batchDelete(requests);
|
||||
}
|
||||
|
||||
@ApiOperation("更新")
|
||||
@PostMapping("/update")
|
||||
public int update(@RequestBody XpackCreateDept dept){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
@ -73,12 +83,15 @@ public class XDeptServer {
|
||||
}
|
||||
|
||||
|
||||
@ApiIgnore
|
||||
@ApiOperation("删除")
|
||||
@PostMapping("/nodesByDeptId/{deptId}")
|
||||
public List<XpackDeptTreeNode> nodesByDeptId(@PathVariable("deptId") Long deptId){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
return deptService.searchTree(deptId);
|
||||
}
|
||||
|
||||
@ApiOperation("移动")
|
||||
@PostMapping("/move")
|
||||
public void move(@RequestBody XpackMoveDept xpackMoveDept){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
|
@ -10,14 +10,19 @@ import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.role.dto.response.XpackRoleDto;
|
||||
import io.dataease.plugins.xpack.role.dto.response.XpackRoleItemDto;
|
||||
import io.dataease.plugins.xpack.role.service.RoleXpackService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.List;
|
||||
@Api(tags = "xpack:角色管理")
|
||||
@RequestMapping("/plugin/role")
|
||||
@RestController
|
||||
public class XRoleServer {
|
||||
|
||||
|
||||
@ApiOperation("新增角色")
|
||||
@PostMapping("/create")
|
||||
public void create(@RequestBody XpackRoleDto role){
|
||||
RoleXpackService roleXpackService = SpringContextUtil.getBean(RoleXpackService.class);
|
||||
@ -25,6 +30,7 @@ public class XRoleServer {
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("删除角色")
|
||||
@PostMapping("/delete/{roleId}")
|
||||
public void delete(@PathVariable("roleId") Long roleId){
|
||||
RoleXpackService roleXpackService = SpringContextUtil.getBean(RoleXpackService.class);
|
||||
@ -32,12 +38,14 @@ public class XRoleServer {
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("更新角色")
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody XpackRoleDto role){
|
||||
RoleXpackService roleXpackService = SpringContextUtil.getBean(RoleXpackService.class);
|
||||
roleXpackService.update(role);
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@PostMapping("/roleGrid/{goPage}/{pageSize}")
|
||||
public Pager<List<XpackRoleDto>> roleGrid(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody XpackGridRequest request) {
|
||||
RoleXpackService roleXpackService = SpringContextUtil.getBean(RoleXpackService.class);
|
||||
@ -46,6 +54,7 @@ public class XRoleServer {
|
||||
return listPager;
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/all")
|
||||
public List<XpackRoleItemDto> all() {
|
||||
RoleXpackService roleXpackService = SpringContextUtil.getBean(RoleXpackService.class);
|
||||
|
@ -1,38 +1,38 @@
|
||||
package io.dataease.service.sys;
|
||||
|
||||
|
||||
import io.dataease.base.domain.SysRole;
|
||||
/*import io.dataease.base.domain.SysRole;
|
||||
import io.dataease.base.domain.SysUsersRolesExample;
|
||||
import io.dataease.base.mapper.SysRoleMapper;
|
||||
import io.dataease.base.mapper.SysUsersRolesMapper;
|
||||
import io.dataease.base.mapper.SysUsersRolesMapper;*/
|
||||
import io.dataease.base.mapper.ext.ExtSysRoleMapper;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.RoleMenusRequest;
|
||||
/*import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.RoleMenusRequest;*/
|
||||
import io.dataease.controller.sys.response.RoleUserItem;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
/*import org.springframework.transaction.annotation.Transactional;*/
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
/*import java.util.HashMap;*/
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
/*import java.util.Map;
|
||||
import java.util.stream.Collectors;*/
|
||||
|
||||
@Service
|
||||
public class SysRoleService {
|
||||
|
||||
@Resource
|
||||
private SysRoleMapper mapper;
|
||||
/*@Resource
|
||||
private SysRoleMapper mapper;*/
|
||||
|
||||
@Resource
|
||||
private ExtSysRoleMapper extSysRoleMapper;
|
||||
|
||||
@Resource
|
||||
private SysUsersRolesMapper sysUsersRolesMapper;
|
||||
/*@Resource
|
||||
private SysUsersRolesMapper sysUsersRolesMapper;*/
|
||||
|
||||
|
||||
|
||||
public int add(SysRole role){
|
||||
/*public int add(SysRole role){
|
||||
Long now = System.currentTimeMillis();
|
||||
role.setCreateTime(now);
|
||||
role.setUpdateTime(now);
|
||||
@ -77,7 +77,7 @@ public class SysRoleService {
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return extSysRoleMapper.batchInsertRoleMenu(maps);
|
||||
}
|
||||
}*/
|
||||
|
||||
public List<RoleUserItem> allRoles(){
|
||||
return extSysRoleMapper.queryAll();
|
||||
|
@ -17,29 +17,29 @@ export function loadTable(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function addDept(data) {
|
||||
return request({
|
||||
url: '/api/dept/create',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
// export function addDept(data) {
|
||||
// return request({
|
||||
// url: '/api/dept/create',
|
||||
// method: 'post',
|
||||
// data
|
||||
// })
|
||||
// }
|
||||
|
||||
export function delDept(ids) {
|
||||
return request({
|
||||
url: '/api/dept/delete',
|
||||
method: 'post',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
// export function delDept(ids) {
|
||||
// return request({
|
||||
// url: '/api/dept/delete',
|
||||
// method: 'post',
|
||||
// data: ids
|
||||
// })
|
||||
// }
|
||||
|
||||
export function editDept(data) {
|
||||
return request({
|
||||
url: '/api/dept/update',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
// export function editDept(data) {
|
||||
// return request({
|
||||
// url: '/api/dept/update',
|
||||
// method: 'post',
|
||||
// data
|
||||
// })
|
||||
// }
|
||||
|
||||
export function treeByDeptId(deptId) {
|
||||
return request({
|
||||
@ -48,4 +48,4 @@ export function treeByDeptId(deptId) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { addDept, delDept, editDept, getDeptTree, loadTable, treeByDeptId }
|
||||
// export default { addDept, delDept, editDept, getDeptTree, loadTable, treeByDeptId }
|
||||
|
@ -1,57 +1,57 @@
|
||||
import request from '@/utils/request'
|
||||
// import request from '@/utils/request'
|
||||
|
||||
export function allRoles() {
|
||||
return request({
|
||||
url: '/api/role/all',
|
||||
method: 'post',
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
// export function allRoles() {
|
||||
// return request({
|
||||
// url: '/api/user/all',
|
||||
// method: 'post',
|
||||
// loading: true
|
||||
// })
|
||||
// }
|
||||
|
||||
export function roleGrid(pageIndex, pageSize, data) {
|
||||
return request({
|
||||
url: '/api/role/roleGrid/' + pageIndex + '/' + pageSize,
|
||||
method: 'post',
|
||||
data,
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
// export function roleGrid(pageIndex, pageSize, data) {
|
||||
// return request({
|
||||
// url: '/api/role/roleGrid/' + pageIndex + '/' + pageSize,
|
||||
// method: 'post',
|
||||
// data,
|
||||
// loading: true
|
||||
// })
|
||||
// }
|
||||
|
||||
export function delRole(pid) {
|
||||
return request({
|
||||
url: '/api/role/delete/' + pid,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
// export function delRole(pid) {
|
||||
// return request({
|
||||
// url: '/api/role/delete/' + pid,
|
||||
// method: 'post'
|
||||
// })
|
||||
// }
|
||||
|
||||
export function addRole(data) {
|
||||
return request({
|
||||
url: '/api/role/create',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
// export function addRole(data) {
|
||||
// return request({
|
||||
// url: '/api/role/create',
|
||||
// method: 'post',
|
||||
// data
|
||||
// })
|
||||
// }
|
||||
|
||||
export function editRole(data) {
|
||||
return request({
|
||||
url: '/api/role/update',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
// export function editRole(data) {
|
||||
// return request({
|
||||
// url: '/api/role/update',
|
||||
// method: 'post',
|
||||
// data
|
||||
// })
|
||||
// }
|
||||
|
||||
export function addRoleMenus(data) {
|
||||
return request({
|
||||
url: '/api/role/saveRolesMenus',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
// export function addRoleMenus(data) {
|
||||
// return request({
|
||||
// url: '/api/role/saveRolesMenus',
|
||||
// method: 'post',
|
||||
// data
|
||||
// })
|
||||
// }
|
||||
|
||||
export function menuIds(roleId) {
|
||||
return request({
|
||||
url: '/api/role/menuIds/' + roleId,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
export default { addRole, editRole, delRole, roleGrid, allRoles, addRoleMenus, menuIds }
|
||||
// export function menuIds(roleId) {
|
||||
// return request({
|
||||
// url: '/api/role/menuIds/' + roleId,
|
||||
// method: 'post'
|
||||
// })
|
||||
// }
|
||||
// export default { addRole, editRole, delRole, roleGrid, allRoles, addRoleMenus, menuIds }
|
||||
|
@ -81,4 +81,12 @@ export const updatePersonPwd = (data) => {
|
||||
})
|
||||
}
|
||||
|
||||
export default { editPassword, delUser, editUser, addUser, userLists, editStatus, persionInfo, updatePerson, updatePersonPwd }
|
||||
export const allRoles = () => {
|
||||
return request({
|
||||
url: '/api/user/all',
|
||||
method: 'post',
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
|
||||
export default { editPassword, delUser, editUser, addUser, userLists, editStatus, persionInfo, updatePerson, updatePersonPwd, allRoles }
|
||||
|
@ -1,161 +0,0 @@
|
||||
<template>
|
||||
<layout-content :header="formType=='add' ? $t('organization.create') : $t('organization.modify')" back-name="system-dept" style="height: 100%;">
|
||||
<el-form ref="deptForm" :model="form" :rules="rule" size="small" label-width="auto" label-position="right">
|
||||
<el-form-item :label="$t('organization.name')" prop="name">
|
||||
<el-input v-model="form.name" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('organization.sort')" prop="deptSort">
|
||||
<el-input-number
|
||||
|
||||
v-model.number="form.deptSort"
|
||||
:min="0"
|
||||
:max="999"
|
||||
controls-position="right"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('organization.top_org')" prop="top">
|
||||
<el-radio-group v-model="form.top" @change="topChange">
|
||||
<el-radio :label="true">{{ $t('commons.yes') }}</el-radio>
|
||||
<el-radio :label="false">{{ $t('commons.no') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="!form.top" :label="$t('organization.parent_org')" prop="pid">
|
||||
<treeselect
|
||||
v-model="form.pid"
|
||||
:auto-load-root-options="false"
|
||||
:load-options="loadDepts"
|
||||
:options="depts"
|
||||
:placeholder="$t('organization.select_parent_org')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="save">{{ $t('commons.save') }}</el-button>
|
||||
<el-button @click="reset">{{ $t('commons.reset') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</layout-content>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import { getDeptTree, treeByDeptId, addDept, editDept } from '@/api/system/dept'
|
||||
export default {
|
||||
|
||||
components: { LayoutContent },
|
||||
data() {
|
||||
return {
|
||||
defaultForm: { deptId: null, top: true, pid: null },
|
||||
maps: new Map(),
|
||||
form: {},
|
||||
rule: {
|
||||
name: [
|
||||
{ required: true, message: this.$t('organization.input_name'), trigger: 'blur' },
|
||||
{ min: 2, max: 25, message: this.$t('commons.input_limit', [2, 25]), trigger: 'blur' }
|
||||
],
|
||||
description: [
|
||||
{ max: 50, message: this.$t('commons.input_limit', [0, 50]), trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
depts: null,
|
||||
|
||||
formType: 'add'
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
if (this.$router.currentRoute.params && this.$router.currentRoute.params.deptId) {
|
||||
const row = this.$router.currentRoute.params
|
||||
this.edit(row)
|
||||
} else {
|
||||
this.create()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
create() {
|
||||
this.formType = 'add'
|
||||
this.form = Object.assign({}, this.defaultForm)
|
||||
},
|
||||
edit(row) {
|
||||
this.formType = 'modify'
|
||||
this.form = Object.assign({}, row)
|
||||
this.initDeptTree()
|
||||
},
|
||||
|
||||
initDeptTree() {
|
||||
treeByDeptId(this.form.pid || 0).then(res => {
|
||||
const results = res.data.map(node => {
|
||||
if (node.hasChildren && !node.children) {
|
||||
node.children = null
|
||||
}
|
||||
return node
|
||||
})
|
||||
this.depts = results
|
||||
})
|
||||
},
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === 'LOAD_ROOT_OPTIONS' && !this.form.pid) {
|
||||
const _self = this
|
||||
treeByDeptId(0).then(res => {
|
||||
const results = res.data.map(node => {
|
||||
if (node.hasChildren && !node.children) {
|
||||
node.children = null
|
||||
}
|
||||
return node
|
||||
})
|
||||
_self.depts = results
|
||||
callback()
|
||||
})
|
||||
}
|
||||
|
||||
if (action === 'LOAD_CHILDREN_OPTIONS') {
|
||||
const _self = this
|
||||
getDeptTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
return _self.normalizer(obj)
|
||||
})
|
||||
callback()
|
||||
})
|
||||
}
|
||||
},
|
||||
normalizer(node) {
|
||||
if (node.hasChildren) {
|
||||
node.children = null
|
||||
}
|
||||
return {
|
||||
id: node.deptId,
|
||||
label: node.name,
|
||||
children: node.children
|
||||
}
|
||||
},
|
||||
topChange(value) {
|
||||
if (!value) {
|
||||
this.form.pid = null
|
||||
this.depts = null
|
||||
}
|
||||
},
|
||||
reset() {
|
||||
this.$refs.deptForm.resetFields()
|
||||
},
|
||||
save() {
|
||||
this.$refs.deptForm.validate(valid => {
|
||||
if (valid) {
|
||||
const method = this.formType === 'add' ? addDept : editDept
|
||||
method(this.form).then(res => {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.backToList()
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
backToList() {
|
||||
this.$router.push({ name: 'system-dept' })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,521 +0,0 @@
|
||||
<template>
|
||||
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
|
||||
<tree-table
|
||||
:columns="columns"
|
||||
:search-config="searchConfig"
|
||||
@search="search"
|
||||
>
|
||||
<template #toolbar>
|
||||
<el-button v-permission="['dept:add']" icon="el-icon-circle-plus-outline" @click="create">{{ $t('organization.create') }}</el-button>
|
||||
</template>
|
||||
<el-table
|
||||
ref="table"
|
||||
:data="tableData"
|
||||
lazy
|
||||
:load="loadExpandDatas"
|
||||
style="width: 100%"
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
row-key="deptId"
|
||||
>
|
||||
<el-table-column :label="$t('organization.name')" prop="name" />
|
||||
<el-table-column :label="$t('organization.sub_organizations')" prop="subCount" />
|
||||
<el-table-column prop="createTime" :label="$t('organization.create_time')">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<fu-table-operations :buttons="buttons" :label="$t('commons.operating')" fix />
|
||||
</el-table>
|
||||
</tree-table>
|
||||
<!-- </complex-table> -->
|
||||
|
||||
<!-- add organization form -->
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
:title="formType=='add' ? $t('organization.create') : $t('organization.modify')"
|
||||
:visible.sync="dialogOrgAddVisible"
|
||||
width="500px"
|
||||
:destroy-on-close="true"
|
||||
@closed="closeFunc"
|
||||
>
|
||||
<el-form ref="createOrganization" inline :model="form" :rules="rule" size="small" label-width="80px">
|
||||
|
||||
<el-form-item :label="$t('organization.name')" prop="name">
|
||||
<el-input v-model="form.name" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('organization.sort')" prop="deptSort">
|
||||
<el-input-number
|
||||
v-model.number="form.deptSort"
|
||||
:min="0"
|
||||
:max="999"
|
||||
controls-position="right"
|
||||
style="width: 370px;"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('organization.top_org')" prop="top">
|
||||
<el-radio-group v-model="form.top" style="width: 140px" @change="topChange">
|
||||
<el-radio :label="true">{{ $t('commons.yes') }}</el-radio>
|
||||
<el-radio :label="false">{{ $t('commons.no') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="$t('commons.status')" prop="enabled">
|
||||
<el-radio-group v-model="form.enabled" style="width: 140px" disabled>
|
||||
<el-radio :label="true">{{ $t('commons.enable') }}</el-radio>
|
||||
<el-radio :label="false">{{ $t('commons.disable') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="!form.top" style="margin-bottom: 0;" :label="$t('organization.parent_org')" prop="pid">
|
||||
<treeselect
|
||||
v-model="form.pid"
|
||||
:auto-load-root-options="false"
|
||||
:load-options="loadDepts"
|
||||
:options="depts"
|
||||
style="width: 370px;"
|
||||
:placeholder="$t('organization.select_parent_org')"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="dialogOrgAddVisible = false">{{ $t('commons.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="createDept('createOrganization')">{{ $t('commons.confirm') }}</el-button>
|
||||
</div>
|
||||
|
||||
</el-dialog>
|
||||
|
||||
</layout-content>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import TreeTable from '@/components/business/tree-table'
|
||||
import { formatCondition, formatQuickCondition } from '@/utils/index'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import { checkPermission } from '@/utils/permission'
|
||||
import { getDeptTree, addDept, editDept, delDept, loadTable } from '@/api/system/dept'
|
||||
|
||||
export default {
|
||||
name: 'MsOrganization',
|
||||
components: {
|
||||
LayoutContent,
|
||||
TreeTable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
rootNodeLoaded: false,
|
||||
depts: null,
|
||||
formType: 'add',
|
||||
queryPath: '/api/dept/childNodes',
|
||||
deletePath: '/api/dept/delete',
|
||||
createPath: '/api/dept/create',
|
||||
updatePath: '/api/dept/update',
|
||||
changeStatusPath: '/api/dept/updateStatus',
|
||||
result: {},
|
||||
dialogOrgAddVisible: false,
|
||||
tableData: [],
|
||||
maps: new Map(),
|
||||
oldPid: null,
|
||||
form: {},
|
||||
rule: {
|
||||
name: [
|
||||
{ required: true, message: this.$t('organization.input_name'), trigger: 'blur' },
|
||||
{ min: 2, max: 25, message: this.$t('commons.input_limit', [2, 25]), trigger: 'blur' }
|
||||
],
|
||||
description: [
|
||||
{ max: 50, message: this.$t('commons.input_limit', [0, 50]), trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
permission: {
|
||||
add: ['dept:add'],
|
||||
edit: ['dept:edit'],
|
||||
del: ['dept:del']
|
||||
},
|
||||
header: '',
|
||||
columns: [],
|
||||
buttons: [
|
||||
{
|
||||
label: this.$t('commons.edit'), icon: 'el-icon-edit', type: 'primary', click: this.edit,
|
||||
show: checkPermission(['dept:edit'])
|
||||
}, {
|
||||
label: this.$t('commons.delete'), icon: 'el-icon-delete', type: 'danger', click: this._handleDelete,
|
||||
show: checkPermission(['dept:del'])
|
||||
}
|
||||
],
|
||||
searchConfig: {
|
||||
useQuickSearch: true,
|
||||
quickPlaceholder: this.$t('role.search_by_name'),
|
||||
components: [
|
||||
{ field: 'name', label: this.$t('organization.name'), component: 'FuComplexInput' }
|
||||
]
|
||||
},
|
||||
|
||||
defaultCondition: {
|
||||
field: 'pid',
|
||||
operator: 'eq',
|
||||
value: 0
|
||||
},
|
||||
defaultForm: { deptId: null, top: true, enabled: true, pid: null },
|
||||
isTableExpand: false,
|
||||
isLazy: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.form = Object.assign({}, this.defaultForm)
|
||||
this.search()
|
||||
},
|
||||
methods: {
|
||||
// create() {
|
||||
// this.form = Object.assign({}, this.defaultForm)
|
||||
// this.dialogOrgAddVisible = true
|
||||
// this.formType = 'add'
|
||||
// },
|
||||
// edit(row) {
|
||||
// this.dialogOrgAddVisible = true
|
||||
// this.formType = 'modify'
|
||||
// this.oldPid = row.pid
|
||||
// this.form = Object.assign({}, row)
|
||||
// this.treeByRow(row)
|
||||
// },
|
||||
create() {
|
||||
this.$router.push({ name: 'system-dept-form' })
|
||||
},
|
||||
edit(row) {
|
||||
this.$router.push({ name: 'system-dept-form', params: row })
|
||||
},
|
||||
|
||||
treeByRow(row) {
|
||||
!this.depts && (this.depts = [])
|
||||
if (!this.depts.some(node => node.id === row.pid) && row.pid !== 0) {
|
||||
const arr = this.mapToArray()
|
||||
const ids = arr.map(item => item.id)
|
||||
const tempTreeNodes = this.treeByArr(arr)
|
||||
const pnodes = this.tableData.filter(node => (node.pid === 0) && (ids.indexOf(node.deptId) === -1)).map(node => this.normalizer(node))
|
||||
const showNodes = tempTreeNodes.concat(pnodes)
|
||||
this.depts = this.depts.concat(showNodes)
|
||||
}
|
||||
},
|
||||
|
||||
mapToArray() {
|
||||
const result = []
|
||||
|
||||
this.maps.forEach((value, key) => {
|
||||
if (value.hasOwnProperty('row')) {
|
||||
result.push(this.editNormalizer(value.row))
|
||||
}
|
||||
})
|
||||
return result
|
||||
},
|
||||
treeByArr(arr) {
|
||||
if (!Array.isArray(arr) || !arr.length) return
|
||||
const map = {}
|
||||
arr.forEach(item => {
|
||||
map[item.id] = item
|
||||
})
|
||||
|
||||
const roots = []
|
||||
arr.forEach(item => {
|
||||
const parent = map[item.pid]
|
||||
if (parent) {
|
||||
(parent.children || (parent.children = [])).push(item)
|
||||
} else {
|
||||
roots.push(item)
|
||||
}
|
||||
})
|
||||
return roots
|
||||
},
|
||||
|
||||
quick_condition(condition) {
|
||||
const result = {}
|
||||
if (condition && condition.quick) {
|
||||
for (const [key, value] of Object.entries(condition)) {
|
||||
// console.log(`${key}`)
|
||||
if (`${key}` === 'quick') {
|
||||
const v_new = Object.assign({}, value)
|
||||
v_new['field'] = 'name'
|
||||
result['name'] = v_new
|
||||
} else {
|
||||
result[`${key}`] = value
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
return Object.assign({}, condition)
|
||||
},
|
||||
|
||||
setTableAttr(isSearch) {
|
||||
if (isSearch) {
|
||||
this.lazy = false
|
||||
this.isTableExpand = true
|
||||
} else {
|
||||
this.lazy = true
|
||||
this.isTableExpand = false
|
||||
}
|
||||
},
|
||||
// 加载表格数据
|
||||
search(condition) {
|
||||
condition = formatQuickCondition(condition, 'name')
|
||||
let conditionExist = false
|
||||
const temp = formatCondition(condition)
|
||||
this.tableData = []
|
||||
let param = {}
|
||||
if (temp && temp.conditions && temp.conditions.length !== 0) {
|
||||
conditionExist = true
|
||||
param = temp
|
||||
} else {
|
||||
param = { conditions: [this.defaultCondition] }
|
||||
}
|
||||
|
||||
loadTable(param).then(res => {
|
||||
let data = res.data
|
||||
data = data.map(obj => {
|
||||
if (obj.subCount > 0) {
|
||||
obj.hasChildren = true
|
||||
}
|
||||
return obj
|
||||
})
|
||||
|
||||
if (conditionExist) {
|
||||
data = this.buildTree(data)
|
||||
}
|
||||
this.tableData = data
|
||||
this.$nextTick(() => {
|
||||
this.tableData.forEach(node => {
|
||||
this.$refs.table.toggleRowExpansion(node, conditionExist)
|
||||
})
|
||||
})
|
||||
this.depts = null
|
||||
})
|
||||
},
|
||||
|
||||
buildTree(arrs) {
|
||||
const idMapping = arrs.reduce((acc, el, i) => {
|
||||
acc[el.deptId] = i
|
||||
return acc
|
||||
}, {})
|
||||
const roots = []
|
||||
arrs.forEach(el => {
|
||||
// 判断根节点
|
||||
if (el.pid === null || el.pid === 0) {
|
||||
roots.push(el)
|
||||
return
|
||||
}
|
||||
// 用映射表找到父元素
|
||||
const parentEl = arrs[idMapping[el.pid]]
|
||||
// 把当前元素添加到父元素的`children`数组中
|
||||
parentEl.children = [...(parentEl.children || []), el]
|
||||
})
|
||||
return roots
|
||||
},
|
||||
|
||||
// 加载下一级子节点数据
|
||||
loadExpandDatas(row, treeNode, resolve) {
|
||||
getDeptTree(row.deptId).then(res => {
|
||||
let data = res.data
|
||||
data = data.map(obj => {
|
||||
if (obj.subCount > 0) {
|
||||
obj.hasChildren = true
|
||||
}
|
||||
return obj
|
||||
})
|
||||
this.maps.set(row.deptId, { row, treeNode, resolve })
|
||||
resolve && resolve(data)
|
||||
})
|
||||
},
|
||||
|
||||
// initTableData(row, treeNode, resolve) {
|
||||
// const _self = this
|
||||
// const pid = (row && row.deptId) ? row.deptId : '0'
|
||||
// getDeptTree(pid).then(response => {
|
||||
// let data = response.data
|
||||
// data = data.map(obj => {
|
||||
// if (obj.subCount > 0) {
|
||||
// obj.hasChildren = true
|
||||
// }
|
||||
// return obj
|
||||
// })
|
||||
// if (!row) {
|
||||
// data.some(node => {
|
||||
// node.children = null
|
||||
// })
|
||||
// _self.tableData = data
|
||||
// _self.depts = null
|
||||
// } else {
|
||||
// this.maps.set(row.deptId, { row, treeNode, resolve })
|
||||
// resolve && resolve(data)
|
||||
// }
|
||||
// })
|
||||
// },
|
||||
closeFunc() {
|
||||
this.search()
|
||||
this.form = {}
|
||||
this.oldPid = null
|
||||
this.depts = null
|
||||
this.dialogOrgAddVisible = false
|
||||
},
|
||||
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === 'LOAD_ROOT_OPTIONS') {
|
||||
const _self = this
|
||||
!this.depts && getDeptTree('0').then(res => {
|
||||
_self.depts = res.data.map(node => _self.normalizer(node))
|
||||
callback()
|
||||
})
|
||||
}
|
||||
|
||||
if (action === 'LOAD_CHILDREN_OPTIONS') {
|
||||
const _self = this
|
||||
getDeptTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
return _self.normalizer(obj)
|
||||
})
|
||||
callback()
|
||||
})
|
||||
}
|
||||
},
|
||||
normalizer(node) {
|
||||
if (node.hasChildren) {
|
||||
node.children = null
|
||||
}
|
||||
return {
|
||||
id: node.deptId,
|
||||
label: node.name,
|
||||
children: node.children
|
||||
}
|
||||
},
|
||||
editNormalizer(node) {
|
||||
return {
|
||||
id: node.deptId,
|
||||
pid: node.pid,
|
||||
label: node.name,
|
||||
children: node.children || null
|
||||
}
|
||||
},
|
||||
// 改变状态
|
||||
changeEnabled(data, val) {
|
||||
this.$confirm('此操作将 "停用" ' + data.name + '组织, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
const param = { deptId: data.deptId, status: data.enabled }
|
||||
this.$post(this.changeStatusPath, param, () => {
|
||||
this.$success(this.$t('commons.modify_success'))
|
||||
})
|
||||
}).catch(() => {
|
||||
data.enabled = !data.enabled
|
||||
})
|
||||
},
|
||||
// checkboxT(row, rowIndex) {
|
||||
// return row.depId !== 1
|
||||
// },
|
||||
createDept(createOrganizationForm) {
|
||||
this.$refs[createOrganizationForm].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.formType !== 'modify') {
|
||||
addDept(this.form).then(res => {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.search()
|
||||
this.oldPid && this.reloadByPid(this.oldPid)
|
||||
this.reloadByPid(this.form['pid'])
|
||||
this.dialogOrgAddVisible = false
|
||||
})
|
||||
} else {
|
||||
editDept(this.form).then(res => {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.search()
|
||||
this.oldPid && this.reloadByPid(this.oldPid)
|
||||
this.reloadByPid(this.form['pid'])
|
||||
this.dialogOrgAddVisible = false
|
||||
})
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
_handleDelete(organization) {
|
||||
this.$confirm(this.$t('organization.delete_confirm'), '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
cancelButtonText: this.$t('commons.cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
const requests = [{ deptId: organization.deptId, pid: organization.pid }]
|
||||
delDept(requests).then(res => {
|
||||
this.$success(this.$t('commons.delete_success'))
|
||||
this.search()
|
||||
this.reloadByPid(organization.pid)
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: this.$t('commons.delete_cancelled')
|
||||
})
|
||||
})
|
||||
},
|
||||
reloadByPid(pid) {
|
||||
if (pid !== 0 && this.maps.get(pid)) {
|
||||
const { row, treeNode, resolve } = this.maps.get(pid)
|
||||
this.$set(this.$refs.table.store.states.lazyTreeNodeMap, pid, [])
|
||||
this.loadExpandDatas(row, treeNode, resolve)
|
||||
}
|
||||
},
|
||||
array2Tree(arr) {
|
||||
if (!Array.isArray(arr) || !arr.length) return
|
||||
const map = {}
|
||||
arr.forEach(item => {
|
||||
map[item.id] = item
|
||||
})
|
||||
|
||||
const roots = []
|
||||
arr.forEach(item => {
|
||||
const parent = map[item.pid]
|
||||
if (parent) {
|
||||
(parent.children || (parent.children = [])).push(item)
|
||||
} else {
|
||||
roots.push(item)
|
||||
}
|
||||
})
|
||||
return roots
|
||||
},
|
||||
topChange(value) {
|
||||
// console.log(value)
|
||||
!value && (this.depts = null)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.member-size {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.org-member-id {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.org-member-email {
|
||||
float: right;
|
||||
color: #8492a6;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.select-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-css >>> .el-dialog__header {
|
||||
padding: 0;
|
||||
}
|
||||
::v-deep .el-input-number .el-input__inner {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
</style>
|
@ -1,104 +0,0 @@
|
||||
<template>
|
||||
<layout-content :header="formType=='add' ? $t('role.add') : $t('role.modify')" back-name="system-role">
|
||||
<el-form ref="roleForm" :model="form" :rules="rule" size="small" label-width="auto" label-position="right">
|
||||
<el-form-item :label="$t('commons.name')" prop="name">
|
||||
<el-input v-model="form.name" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.description')" prop="description">
|
||||
<el-input v-model="form.description" type="textarea" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="save">{{ $t('commons.save') }}</el-button>
|
||||
<el-button @click="reset">{{ $t('commons.reset') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</layout-content>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import { addRole, editRole, allRoles } from '@/api/system/role'
|
||||
export default {
|
||||
|
||||
components: { LayoutContent },
|
||||
data() {
|
||||
return {
|
||||
formType: 'add',
|
||||
form: {},
|
||||
rule: {
|
||||
name: [
|
||||
{ required: true, trigger: 'blur', validator: this.roleValidator }
|
||||
],
|
||||
description: [{ max: 50, message: this.$t('commons.char_can_not_more_50'), trigger: 'blur' }]
|
||||
},
|
||||
roles: [],
|
||||
originName: null
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
if (this.$router.currentRoute.params && this.$router.currentRoute.params.roleId) {
|
||||
const row = this.$router.currentRoute.params
|
||||
this.edit(row)
|
||||
} else {
|
||||
this.create()
|
||||
}
|
||||
this.queryAllRoles()
|
||||
},
|
||||
methods: {
|
||||
create() {
|
||||
this.formType = 'add'
|
||||
},
|
||||
edit(row) {
|
||||
this.formType = 'modify'
|
||||
this.form = Object.assign({}, row)
|
||||
this.originName = row.name
|
||||
},
|
||||
|
||||
reset() {
|
||||
this.$refs.roleForm.resetFields()
|
||||
},
|
||||
save() {
|
||||
this.$refs.roleForm.validate(valid => {
|
||||
if (valid) {
|
||||
const method = this.formType === 'add' ? addRole : editRole
|
||||
method(this.form).then(res => {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.backToList()
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
queryAllRoles() {
|
||||
allRoles().then(res => {
|
||||
this.roles = res.data
|
||||
})
|
||||
},
|
||||
nameRepeat(value) {
|
||||
if (!this.roles || this.roles.length === 0) {
|
||||
return false
|
||||
}
|
||||
// 编辑场景 不能 因为名称重复而报错
|
||||
if (this.formType === 'modify' && this.originName === value) {
|
||||
return false
|
||||
}
|
||||
return this.roles.some(role => role.name === value)
|
||||
},
|
||||
roleValidator(rule, value, callback) {
|
||||
if (!value || value.length === 0) {
|
||||
callback(new Error('请输入名称'))
|
||||
} else if (this.nameRepeat(value)) {
|
||||
callback(new Error('角色名称已存在'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
backToList() {
|
||||
this.$router.push({ name: 'system-role' })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,276 +0,0 @@
|
||||
<template>
|
||||
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
|
||||
<!-- <div v-loading="result.loading" style="height: 100%"> -->
|
||||
<el-container style="width: 100%; height: 100%;">
|
||||
<el-aside width="70%">
|
||||
<complex-table
|
||||
highlight-current-row
|
||||
:data="tableData"
|
||||
:columns="columns"
|
||||
|
||||
:search-config="searchConfig"
|
||||
:pagination-config="paginationConfig"
|
||||
@search="search"
|
||||
@row-click="rowClick"
|
||||
>
|
||||
<template #toolbar>
|
||||
<el-button v-permission="['role:add']" icon="el-icon-circle-plus-outline" @click="create">{{ $t('role.add') }}</el-button>
|
||||
</template>
|
||||
|
||||
<el-table-column prop="name" :label="$t('commons.name')" />
|
||||
<el-table-column :show-overflow-tooltip="true" prop="description" :label="$t('commons.description')" />
|
||||
<el-table-column :show-overflow-tooltip="true" prop="createTime" :label="$t('commons.create_time')">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<fu-table-operations :buttons="buttons" :label="$t('commons.operating')" fix />
|
||||
</complex-table>
|
||||
</el-aside>
|
||||
<el-main style="padding: 8px 20px;">
|
||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||
<el-tab-pane :label="$t('role.menu_authorization')" name="first">
|
||||
<el-tree
|
||||
ref="menu"
|
||||
lazy
|
||||
:data="menus"
|
||||
:default-checked-keys="menuIds"
|
||||
:load="getMenuDatas"
|
||||
:props="defaultProps"
|
||||
check-strictly
|
||||
show-checkbox
|
||||
node-key="id"
|
||||
@check="menuChange"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('role.data_authorization')" name="second">玩命开发中...</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-main>
|
||||
</el-container>
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
:title="formType=='add' ? $t('role.add') : $t('role.modify')"
|
||||
:visible.sync="dialogVisible"
|
||||
width="580px"
|
||||
:destroy-on-close="true"
|
||||
@closed="closeFunc"
|
||||
>
|
||||
<el-form ref="roleForm" inline :model="form" :rules="rule" size="small" label-width="80px">
|
||||
|
||||
<el-form-item label="角色名称" prop="name">
|
||||
<el-input v-model="form.name" style="width: 380px;" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="角色代码" prop="code">
|
||||
<el-input v-model="form.code" style="width: 380px;" />
|
||||
</el-form-item> -->
|
||||
|
||||
<el-form-item label="描述信息" prop="description">
|
||||
<el-input v-model="form.description" style="width: 380px;" rows="5" type="textarea" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="dialogVisible = false">{{ $t('commons.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="saveRole('roleForm')">{{ $t('commons.confirm') }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
</layout-content>
|
||||
|
||||
</template>
|
||||
<script>
|
||||
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import ComplexTable from '@/components/business/complex-table'
|
||||
import { formatCondition, formatQuickCondition } from '@/utils/index'
|
||||
import { addRole, editRole, delRole, roleGrid, addRoleMenus, menuIds } from '@/api/system/role'
|
||||
|
||||
import { getMenusTree, getChild } from '@/api/system/menu'
|
||||
export default {
|
||||
name: 'Role',
|
||||
components: {
|
||||
LayoutContent,
|
||||
ComplexTable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
tableData: [],
|
||||
menus: [],
|
||||
menuIds: [],
|
||||
defaultProps: { children: 'children', label: 'label', isLeaf: 'isLeaf' },
|
||||
activeName: 'first',
|
||||
dialogVisible: false,
|
||||
formType: 'add',
|
||||
form: {},
|
||||
rule: {
|
||||
name: [
|
||||
{ required: true, message: this.$t('role.pls_input_name'), trigger: 'blur' }
|
||||
],
|
||||
code: [{ required: true, message: '请输入代码', trigger: 'blur' }]
|
||||
},
|
||||
currentRow: null,
|
||||
permission: {
|
||||
add: ['role:add'],
|
||||
edit: ['role:edit'],
|
||||
del: ['role:del']
|
||||
},
|
||||
header: '',
|
||||
columns: [],
|
||||
buttons: [
|
||||
{
|
||||
label: this.$t('commons.edit'), icon: 'el-icon-edit', type: 'primary', click: this.edit, disabled: this.btnDisabled
|
||||
}, {
|
||||
label: this.$t('commons.delete'), icon: 'el-icon-delete', type: 'danger', click: this.handleDelete, disabled: this.btnDisabled
|
||||
}
|
||||
],
|
||||
searchConfig: {
|
||||
useQuickSearch: true,
|
||||
quickPlaceholder: this.$t('role.search_by_name'),
|
||||
components: [
|
||||
{ field: 'name', label: this.$t('role.role_name'), component: 'FuComplexInput' }
|
||||
]
|
||||
},
|
||||
paginationConfig: {
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
currentRow: 'currentRowChange'
|
||||
},
|
||||
mounted() {
|
||||
this.search()
|
||||
},
|
||||
methods: {
|
||||
handleClick(tab, event) {
|
||||
// console.log(tab, event)
|
||||
},
|
||||
create() {
|
||||
this.$router.push({ name: 'system-role-form' })
|
||||
},
|
||||
search(condition) {
|
||||
condition = formatQuickCondition(condition, 'name')
|
||||
const temp = formatCondition(condition)
|
||||
const param = temp || {}
|
||||
roleGrid(this.paginationConfig.currentPage, this.paginationConfig.pageSize, param).then(response => {
|
||||
const data = response.data
|
||||
this.paginationConfig.total = data.itemCount
|
||||
this.tableData = data.listObject
|
||||
})
|
||||
},
|
||||
edit(row) {
|
||||
this.$router.push({ name: 'system-role-form', params: row })
|
||||
},
|
||||
|
||||
saveRole(roleForm) {
|
||||
this.$refs[roleForm].validate(valid => {
|
||||
if (valid) {
|
||||
const method = this.formType === 'add' ? addRole : editRole
|
||||
method(this.form).then(res => {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.search()
|
||||
this.dialogVisible = false
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
closeFunc() {
|
||||
this.dialogVisible = false
|
||||
},
|
||||
|
||||
getMenuDatas(node, resolve) {
|
||||
const pid = node.data.id ? node.data.id : '0'
|
||||
getMenusTree(pid).then(res => {
|
||||
const datas = res.data
|
||||
const nodes = datas.map(data => this.formatNode(data))
|
||||
resolve && resolve(nodes)
|
||||
})
|
||||
},
|
||||
formatNode(node) {
|
||||
const result = {
|
||||
id: node.menuId,
|
||||
label: node.title,
|
||||
isLeaf: !node.hasChildren,
|
||||
children: node.children
|
||||
}
|
||||
return result
|
||||
},
|
||||
menuChange(menu) {
|
||||
getChild(menu.id).then(res => {
|
||||
const childIds = res.data
|
||||
if (this.menuIds.indexOf(menu.id) !== -1) {
|
||||
for (let i = 0; i < childIds.length; i++) {
|
||||
const index = this.menuIds.indexOf(childIds[i])
|
||||
if (index !== -1) {
|
||||
this.menuIds.splice(index, 1)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < childIds.length; i++) {
|
||||
const index = this.menuIds.indexOf(childIds[i])
|
||||
if (index === -1) {
|
||||
this.menuIds.push(childIds[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
this.$refs.menu.setCheckedKeys(this.menuIds)
|
||||
this.saveMenus()
|
||||
})
|
||||
},
|
||||
saveMenus() {
|
||||
if (!this.currentRow) {
|
||||
return
|
||||
}
|
||||
const param = { roleId: this.currentRow.roleId, menuIds: this.menuIds }
|
||||
addRoleMenus(param).then(res => {
|
||||
this.search()
|
||||
})
|
||||
},
|
||||
rowClick(row, column, event) {
|
||||
menuIds(row.roleId).then(res => {
|
||||
const menuIds = res.data
|
||||
row.menuIds = menuIds
|
||||
this.currentRow = row
|
||||
})
|
||||
},
|
||||
currentRowChange(newVal, oldVal) {
|
||||
if (newVal === oldVal) {
|
||||
return
|
||||
}
|
||||
if (!newVal) {
|
||||
this.menuIds = []
|
||||
return
|
||||
}
|
||||
|
||||
this.menuIds = newVal.menuIds
|
||||
this.$refs.menu.setCheckedKeys(this.menuIds)
|
||||
},
|
||||
handleDelete(row) {
|
||||
this.$confirm(this.$t('role.confirm_delete') + ': ' + row.name + '?', this.$t('role.tips'), {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
cancelButtonText: this.$t('commons.cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
delRole(row.roleId).then(res => {
|
||||
this.$success(this.$t('commons.delete_success'))
|
||||
this.search()
|
||||
})
|
||||
}).catch(() => {
|
||||
|
||||
})
|
||||
},
|
||||
btnDisabled(row) {
|
||||
return !row.updateTime
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
@ -72,16 +72,11 @@
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
// import Treeselect from '@riophae/vue-treeselect'
|
||||
// import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import { PHONE_REGEX } from '@/utils/validate'
|
||||
// import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { getDeptTree, treeByDeptId } from '@/api/system/dept'
|
||||
import { allRoles } from '@/api/system/role'
|
||||
import { addUser, editUser } from '@/api/system/user'
|
||||
import { addUser, editUser, allRoles } from '@/api/system/user'
|
||||
export default {
|
||||
|
||||
// components: { LayoutContent, Treeselect },
|
||||
components: { LayoutContent },
|
||||
data() {
|
||||
return {
|
||||
|
@ -169,8 +169,8 @@ import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselec
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
|
||||
import { userLists, addUser, editUser, delUser, editPassword, editStatus } from '@/api/system/user'
|
||||
import { allRoles } from '@/api/system/role'
|
||||
import { userLists, addUser, editUser, delUser, editPassword, editStatus, allRoles } from '@/api/system/user'
|
||||
// import { allRoles } from '@/api/system/role'
|
||||
import { getDeptTree, treeByDeptId } from '@/api/system/dept'
|
||||
|
||||
export default {
|
||||
|
Loading…
Reference in New Issue
Block a user