数据权限
This commit is contained in:
@@ -23,7 +23,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "数据管理")
|
||||
@RequestMapping("/api/dataPermission")
|
||||
@RequestMapping("/api/dataPermission2")
|
||||
@Slf4j
|
||||
public class DataPermissionController {
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.nl.system.controller.permission;
|
||||
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.sso.service.dto.DataPermissionDto;
|
||||
import org.nl.system.service.permission.ISysDataPermissionService;
|
||||
import org.nl.system.service.permission.dao.SysDataPermission;
|
||||
import org.nl.system.service.permission.dto.SysDataPermissionQuery;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据数据权限表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-20
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "数据管理")
|
||||
@RequestMapping("/api/dataPermission")
|
||||
public class SysDataPermissionController {
|
||||
|
||||
private final ISysDataPermissionService dataPermissionService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询数据权限")
|
||||
@ApiOperation("查询数据权限")
|
||||
//@SaCheckPermission("@el.check('dataPermission:list')")
|
||||
public ResponseEntity<Object> query(SysDataPermissionQuery dataPermissionQuery, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(dataPermissionService.queryAll(dataPermissionQuery, page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增数据权限")
|
||||
@ApiOperation("新增数据权限")
|
||||
//@SaCheckPermission("@el.check('dataPermission:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SysDataPermission permission) {
|
||||
dataPermissionService.create(permission);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改数据权限")
|
||||
@ApiOperation("修改数据权限")
|
||||
//@SaCheckPermission("@el.check('dataPermission:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SysDataPermission permission) {
|
||||
dataPermissionService.update(permission);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除数据权限")
|
||||
@ApiOperation("删除数据权限")
|
||||
//@SaCheckPermission("@el.check('dataPermission:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||
dataPermissionService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/scopeType")
|
||||
@Log("获取数据权限范围")
|
||||
@ApiOperation("获取数据权限范围")
|
||||
public ResponseEntity<Object> getDataScopeType(){
|
||||
return new ResponseEntity<>(dataPermissionService.getDataScopeType(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/dataPermissionOption")
|
||||
@Log("获取数据权限下拉框")
|
||||
@ApiOperation("获取数据权限下拉框")
|
||||
public ResponseEntity<Object> getDataPermissionOption(){
|
||||
return new ResponseEntity<>(dataPermissionService.getDataPermissionOption(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.nl.system.service.permission;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.permission.dao.SysDataPermission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.system.service.permission.dto.SysDataPermissionQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据数据权限表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-20
|
||||
*/
|
||||
public interface ISysDataPermissionService extends IService<SysDataPermission> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param dataPermissionQuery
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
IPage<SysDataPermission> queryAll(SysDataPermissionQuery dataPermissionQuery, PageQuery page);
|
||||
|
||||
/**
|
||||
* 新增数据权限
|
||||
* @param dto
|
||||
*/
|
||||
void create(SysDataPermission permission);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param permission
|
||||
*/
|
||||
void update(SysDataPermission permission);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param ids
|
||||
*/
|
||||
void deleteAll(Set<String> ids);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Dict> getDataScopeType();
|
||||
|
||||
/**
|
||||
* 获取数据权限下拉框
|
||||
* @return
|
||||
*/
|
||||
Object getDataPermissionOption();
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package org.nl.system.service.permission.dao;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据数据权限表
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-20
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_data_permission")
|
||||
public class SysDataPermission implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* permission_id
|
||||
*/
|
||||
@TableId(value = "permission_id")
|
||||
private String permissionId;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@NotNull
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotNull
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private BigDecimal orderSort;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private String isUsed;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private String isDelete;
|
||||
|
||||
/**
|
||||
* 创建人标识
|
||||
*/
|
||||
private String createId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 修改人标识
|
||||
*/
|
||||
private String updateId;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateName;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.system.service.permission.dao.mapper;
|
||||
|
||||
import org.nl.system.service.permission.dao.SysDataPermission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据数据权限表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-20
|
||||
*/
|
||||
public interface SysDataPermissionMapper extends BaseMapper<SysDataPermission> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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="org.nl.system.service.permission.dao.mapper.SysDataPermissionMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.nl.system.service.permission.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.common.domain.query.BaseQuery;
|
||||
import org.nl.system.service.permission.dao.SysDataPermission;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description:
|
||||
* @Date: 2022/12/20
|
||||
*/
|
||||
@Data
|
||||
public class SysDataPermissionQuery extends BaseQuery<SysDataPermission> {
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package org.nl.system.service.permission.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.dict.dao.mapper.SysDictMapper;
|
||||
import org.nl.system.service.permission.dao.SysDataPermission;
|
||||
import org.nl.system.service.permission.dao.mapper.SysDataPermissionMapper;
|
||||
import org.nl.system.service.permission.ISysDataPermissionService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.system.service.permission.dto.SysDataPermissionQuery;
|
||||
import org.nl.system.service.user.ISysUserService;
|
||||
import org.nl.system.service.user.dto.UserDataPermissionDto;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据数据权限表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-20
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysDataPermissionServiceImpl extends ServiceImpl<SysDataPermissionMapper, SysDataPermission> implements ISysDataPermissionService {
|
||||
|
||||
private final SysDataPermissionMapper dataPermissionMapper;
|
||||
private final ISysUserService userService;
|
||||
private final SysDictMapper dictMapper;
|
||||
|
||||
@Override
|
||||
public IPage<SysDataPermission> queryAll(SysDataPermissionQuery dataPermissionQuery, PageQuery page) {
|
||||
return this.page(page.build(SysDataPermission.class), dataPermissionQuery.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(SysDataPermission permission) {
|
||||
SysDataPermission sysDataPermission = dataPermissionMapper.selectOne(new LambdaQueryWrapper<SysDataPermission>().eq(SysDataPermission::getCode, permission.getCode()));
|
||||
if (ObjectUtil.isNotEmpty(sysDataPermission)) throw new BadRequestException("编码为[" + permission.getCode() + "]的数据权限已存在");
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
permission.setPermissionId(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
permission.setCreateId(currentUserId);
|
||||
permission.setCreateName(nickName);
|
||||
permission.setUpdateId(currentUserId);
|
||||
permission.setUpdateName(nickName);
|
||||
permission.setUpdateTime(now);
|
||||
permission.setCreateTime(now);
|
||||
dataPermissionMapper.insert(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(SysDataPermission permission) {
|
||||
SysDataPermission dataPermission = dataPermissionMapper.selectById(permission.getPermissionId());
|
||||
if (ObjectUtil.isEmpty(dataPermission)) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
permission.setUpdateTime(DateUtil.now());
|
||||
permission.setUpdateId(SecurityUtils.getCurrentUserId());
|
||||
permission.setUpdateName(SecurityUtils.getCurrentNickName());
|
||||
dataPermissionMapper.updateById(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Set<String> ids) {
|
||||
ids.forEach(id -> {
|
||||
List<UserDataPermissionDto> permissions = userService.getUserDataPermissionByPermissionId(id);
|
||||
if (ObjectUtil.isNotEmpty(permissions)) throw new BadRequestException("存在相关联的数据权限,请解除关联后删除");
|
||||
dataPermissionMapper.deleteById(id);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dict> getDataScopeType() {
|
||||
return dictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, "permission_scope_type"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDataPermissionOption() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.nl.system.service.user.dto.SysUserDetail;
|
||||
import org.nl.system.service.user.dto.UserDataPermissionDto;
|
||||
import org.nl.system.service.user.dto.UserQuery;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -29,4 +30,5 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
|
||||
void update(Map userDetail);
|
||||
|
||||
List<UserDataPermissionDto> getUserDataPermissionByPermissionId(String permissionId);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Select;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.nl.system.service.user.dto.SysUserDetail;
|
||||
import org.nl.system.service.user.dto.UserDataPermissionDto;
|
||||
import org.nl.system.service.user.dto.UserQuery;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,4 +26,5 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
List<Map<String,Object>> getDetailForMap(@Param("query") UserQuery query, @Param("page")PageQuery page);
|
||||
|
||||
List<UserDataPermissionDto> getUserDataPermissionByPermissionId(String permissionId);
|
||||
}
|
||||
|
||||
@@ -114,4 +114,8 @@
|
||||
</where>
|
||||
GROUP BY sys_user.user_id
|
||||
</select>
|
||||
<select id="getUserDataPermissionByPermissionId"
|
||||
resultType="org.nl.system.service.user.dto.UserDataPermissionDto">
|
||||
SELECT * FROM sys_user_data_permission WHERE permission_id = #{permissionId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.nl.system.service.user.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 用户-权限表
|
||||
* @Date: 2022/12/20
|
||||
*/
|
||||
@Data
|
||||
public class UserDataPermissionDto {
|
||||
private String userId;
|
||||
|
||||
private String permissionScopeType;
|
||||
|
||||
private String permissionId;
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import org.nl.system.service.user.ISysUserService;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.nl.system.service.user.dao.mapper.SysUserMapper;
|
||||
import org.nl.system.service.user.dto.SysUserDetail;
|
||||
import org.nl.system.service.user.dto.UserDataPermissionDto;
|
||||
import org.nl.system.service.user.dto.UserQuery;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -140,4 +141,9 @@ public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
|
||||
roleService.saveUserRoleRelation(sysUser.getUserId(),(List) userDetail.get("roleIds"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDataPermissionDto> getUserDataPermissionByPermissionId(String permissionId) {
|
||||
return sysUserMapper.getUserDataPermissionByPermissionId(permissionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,42 @@ export function edit(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del }
|
||||
export function getDataScopeType() {
|
||||
return request({
|
||||
url: 'api/dataPermission/scopeType',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getDataPermissionOption() {
|
||||
return request({
|
||||
url: 'api/dataPermission/dataPermissionOption',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function saveDataPermission(data) {
|
||||
return request({
|
||||
url: 'api/dataPermission/saveDataPermission',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function getDataShow(id) {
|
||||
return request({
|
||||
url: 'api/dataPermission/dataShow',
|
||||
method: 'post',
|
||||
data: id
|
||||
})
|
||||
}
|
||||
|
||||
export function getDataDetail(data) {
|
||||
return request({
|
||||
url: 'api/dataPermission/dataDetail',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getDataScopeType, getDataPermissionOption, saveDataPermission, getDataShow, getDataDetail }
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
<!--表单组件-->
|
||||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="80px">
|
||||
<el-form-item label="permission_id" prop="permission_id">
|
||||
<el-input v-model="form.permission_id" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="编码" prop="code">
|
||||
<el-input v-model="form.code" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
@@ -17,34 +14,19 @@
|
||||
<el-input v-model="form.name" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序">
|
||||
<el-input v-model="form.order_sort" style="width: 370px;" />
|
||||
<el-input-number
|
||||
v-model.number="form.orderSort"
|
||||
:min="0"
|
||||
:max="999"
|
||||
controls-position="right"
|
||||
style="width: 370px;"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.remark" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="是否启用" prop="is_used">
|
||||
<el-input v-model="form.is_used" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="是否删除" prop="is_delete">
|
||||
<el-input v-model="form.is_delete" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="创建人标识">
|
||||
<el-input v-model="form.create_id" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="创建人">
|
||||
<el-input v-model="form.create_name" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间">
|
||||
<el-input v-model="form.create_time" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="修改人标识">
|
||||
<el-input v-model="form.update_optid" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="修改人">
|
||||
<el-input v-model="form.update_optname" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="修改时间">
|
||||
<el-input v-model="form.update_time" style="width: 370px;" />
|
||||
<el-form-item label="是否启用">
|
||||
<el-switch v-model="form.isUsed" active-value="1" inactive-value="0" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
@@ -55,19 +37,19 @@
|
||||
<!--表格渲染-->
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="permission_id" label="permission_id" :min-width="flexWidth('permission_id',crud.data,'permission_id')" />
|
||||
<el-table-column v-if="false" prop="permissionId" label="permissionId" :min-width="flexWidth('permissionId',crud.data,'permissionId')" />
|
||||
<el-table-column prop="code" label="编码" :min-width="flexWidth('code',crud.data,'编码')" />
|
||||
<el-table-column prop="name" label="名称" :min-width="flexWidth('name',crud.data,'名称')" />
|
||||
<el-table-column prop="order_sort" label="排序" :min-width="flexWidth('order_sort',crud.data,'排序')" />
|
||||
<el-table-column prop="orderSort" label="排序" :min-width="flexWidth('orderSort',crud.data,'排序')" />
|
||||
<el-table-column prop="remark" label="备注" :min-width="flexWidth('remark',crud.data,'备注')" />
|
||||
<el-table-column prop="is_used" label="是否启用" :min-width="flexWidth('is_used',crud.data,'是否启用')" />
|
||||
<el-table-column prop="is_delete" label="是否删除" :min-width="flexWidth('is_delete',crud.data,'是否删除')" />
|
||||
<el-table-column prop="create_id" label="创建人标识" :min-width="flexWidth('create_id',crud.data,'创建人标识')" />
|
||||
<el-table-column prop="create_name" label="创建人" :min-width="flexWidth('create_name',crud.data,'创建人')" />
|
||||
<el-table-column prop="create_time" label="创建时间" :min-width="flexWidth('create_time',crud.data,'创建时间')" />
|
||||
<el-table-column prop="update_optid" label="修改人标识" :min-width="flexWidth('update_optid',crud.data,'修改人标识')" />
|
||||
<el-table-column prop="update_optname" label="修改人" :min-width="flexWidth('update_optname',crud.data,'修改人')" />
|
||||
<el-table-column prop="update_time" label="修改时间" :min-width="flexWidth('update_time',crud.data,'修改时间')" />
|
||||
<el-table-column prop="createName" label="创建人" :min-width="flexWidth('createName',crud.data,'创建人')" />
|
||||
<el-table-column prop="isUsed" label="是否启用" :min-width="flexWidth('isUsed',crud.data,'是否启用')" >
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.isUsed==1?'是':'否' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createName" label="创建人" :min-width="flexWidth('createName',crud.data,'创建人')" />
|
||||
<el-table-column prop="updateTime" label="修改时间" :min-width="flexWidth('updateTime',crud.data,'修改时间')" />
|
||||
<el-table-column v-permission="[]" label="操作" width="120px" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
@@ -84,43 +66,34 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import crudDataPermission from '@/views/system/dataPermission'
|
||||
import crudDataPermission from './dataPermission'
|
||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
const defaultForm = { permission_id: null, code: null, name: null, order_sort: null, remark: null, is_used: null, is_delete: null, create_id: null, create_name: null, create_time: null, update_optid: null, update_optname: null, update_time: null }
|
||||
const defaultForm = { permissionId: null, code: null, name: null, orderSort: '1', remark: null, createName: null, isUsed: '1', createId: null, createTime: null, updateTime: null, updateId: null, updateName: null }
|
||||
export default {
|
||||
name: 'DataPermission',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({ title: '2', url: 'api/dataPermission', idField: 'permission_id', sort: 'permission_id,desc', crudMethod: { ...crudDataPermission }})
|
||||
return CRUD({ title: '数据权限', url: 'api/dataPermission', idField: 'permissionId', sort: 'order_sort,asc', crudMethod: { ...crudDataPermission }})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
permission: {
|
||||
},
|
||||
rules: {
|
||||
permission_id: [
|
||||
{ required: true, message: 'permission_id不能为空', trigger: 'blur' }
|
||||
],
|
||||
code: [
|
||||
{ required: true, message: '编码不能为空', trigger: 'blur' }
|
||||
],
|
||||
name: [
|
||||
{ required: true, message: '名称不能为空', trigger: 'blur' }
|
||||
],
|
||||
is_used: [
|
||||
{ required: true, message: '是否启用不能为空', trigger: 'blur' }
|
||||
],
|
||||
is_delete: [
|
||||
{ required: true, message: '是否删除不能为空', trigger: 'blur' }
|
||||
]
|
||||
}}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
|
||||
181
nladmin-ui/src/views/system/user/dialog/relevanceDeptDialog.vue
Normal file
181
nladmin-ui/src/views/system/user/dialog/relevanceDeptDialog.vue
Normal file
@@ -0,0 +1,181 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="关联用户"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="1000px"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-form
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
label-position="right"
|
||||
label-width="80px"
|
||||
label-suffix=":"
|
||||
>
|
||||
<el-form-item label="模糊搜索">
|
||||
<el-input
|
||||
v-model="query.name"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="输入部门名称搜索"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<rrOperation />
|
||||
</el-form>
|
||||
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
lazy
|
||||
row-key="dept_id"
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
:load="getDeptDatas"
|
||||
default-expand-all
|
||||
style="width: 100%;"
|
||||
size="mini"
|
||||
border
|
||||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
|
||||
@select="handleSelectionChange"
|
||||
@current-change="clickChange"
|
||||
>
|
||||
<el-table-column v-if="!isSingle" type="selection" width="55" />
|
||||
<el-table-column v-if="isSingle" label="选择" width="55">
|
||||
<template slot-scope="scope">
|
||||
<el-radio v-model="tableRadio" :label="scope.row"><i /></el-radio>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="名称" prop="name" />
|
||||
<el-table-column label="排序" prop="dept_sort" />
|
||||
<el-table-column prop="create_time" label="创建日期" />
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import crudDept from '@/api/system/dept'
|
||||
import CRUD, { header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
export default {
|
||||
name: 'RelevanceDeptDialog',
|
||||
components: { rrOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({ title: '部门', idField: 'dept_id', url: 'api/dept/vo', crudMethod: { ...crudDept }, query: { is_used: '1' }})
|
||||
},
|
||||
mixins: [presenter(), header()],
|
||||
dicts: ['product_series'],
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isSingle: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
depts: {
|
||||
type: Array
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
classes: [],
|
||||
tableRadio: null,
|
||||
class_idStr: null,
|
||||
checkrow: null,
|
||||
rows: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickChange(item) {
|
||||
this.tableRadio = item
|
||||
},
|
||||
open() {
|
||||
// 回显
|
||||
this.$nextTick(function() {
|
||||
for (var k = 0; k < this.depts.length; k++) {
|
||||
for (var i = 0; i < this.crud.data.length; i++) {
|
||||
if (this.crud.data[i].dept_id == this.depts[k].dept_id) {
|
||||
this.$refs.table.toggleRowSelection(this.crud.data[i], true)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
handleSelectionChange(val, row) {
|
||||
if (val.length > 1 && this.isSingle) {
|
||||
this.$refs.table.clearSelection()
|
||||
this.$refs.table.toggleRowSelection(val.pop())
|
||||
} else {
|
||||
this.checkrow = row
|
||||
}
|
||||
},
|
||||
onSelectAll() {
|
||||
this.$refs.table.clearSelection()
|
||||
},
|
||||
close() {
|
||||
this.crud.resetQuery(false)
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
submit() {
|
||||
// 处理单选
|
||||
if (this.isSingle && this.tableRadio) {
|
||||
this.$emit('update:dialogShow', false)
|
||||
this.$emit('selectDepts', this.tableRadio)
|
||||
return
|
||||
}
|
||||
this.rows = this.$refs.table.selection
|
||||
if (this.rows.length <= 0) {
|
||||
this.$message('请先勾选用户')
|
||||
return
|
||||
}
|
||||
this.crud.resetQuery(false)
|
||||
this.$emit('update:dialogShow', false)
|
||||
this.$emit('selectDepts', this.rows)
|
||||
// console.log(this.rows)
|
||||
},
|
||||
getDeptDatas(tree, treeNode, resolve) {
|
||||
const params = { pid: tree.dept_id }
|
||||
setTimeout(() => {
|
||||
crudDept.getDeptvo(params).then(res => {
|
||||
resolve(res.content)
|
||||
})
|
||||
}, 100)
|
||||
},
|
||||
[CRUD.HOOK.afterRefresh]() {
|
||||
this.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
::v-deep .el-dialog__body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
174
nladmin-ui/src/views/system/user/dialog/relevanceUserDialog.vue
Normal file
174
nladmin-ui/src/views/system/user/dialog/relevanceUserDialog.vue
Normal file
@@ -0,0 +1,174 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="关联用户"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="1000px"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-form
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
label-position="right"
|
||||
label-width="80px"
|
||||
label-suffix=":"
|
||||
>
|
||||
<el-form-item label="模糊搜索">
|
||||
<el-input
|
||||
v-model="query.blurry"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="输入账号或者名称"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<rrOperation />
|
||||
</el-form>
|
||||
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
style="width: 100%;"
|
||||
size="mini"
|
||||
border
|
||||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
|
||||
@select="handleSelectionChange"
|
||||
@current-change="clickChange"
|
||||
>
|
||||
<el-table-column v-if="!isSingle" type="selection" width="55" />
|
||||
<el-table-column v-if="isSingle" label="选择" width="55">
|
||||
<template slot-scope="scope">
|
||||
<el-radio v-model="tableRadio" :label="scope.row"><i /></el-radio>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="username" label="用户名" :min-width="flexWidth('username',crud.data,'用户名')" />
|
||||
<el-table-column
|
||||
prop="person_name"
|
||||
label="姓名"
|
||||
:min-width="flexWidth('person_name',crud.data,'姓名')"
|
||||
/>
|
||||
<el-table-column show-overflow-tooltip prop="deptnames" label="部门" />
|
||||
<el-table-column label="状态" align="center" prop="enabled">
|
||||
<template slot-scope="scope">
|
||||
{{scope.row.is_used==1?'启用':'禁用'}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import crudUser from '../user'
|
||||
import CRUD, { header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
export default {
|
||||
name: 'RelevanceUserDialog',
|
||||
components: { rrOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({ title: '用户', idField: 'user_id', url: 'api/users', crudMethod: { ...crudUser }, query: {is_used: '1'}})
|
||||
},
|
||||
mixins: [presenter(), header()],
|
||||
dicts: ['product_series'],
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isSingle: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
users: {
|
||||
type: Array
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
classes: [],
|
||||
tableRadio: null,
|
||||
class_idStr: null,
|
||||
checkrow: null,
|
||||
rows: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickChange(item) {
|
||||
this.tableRadio = item
|
||||
},
|
||||
open() {
|
||||
this.$nextTick(function() {
|
||||
for (var k = 0; k < this.users.length; k++) {
|
||||
for (var i = 0; i < this.crud.data.length; i++) {
|
||||
if (this.crud.data[i].user_id == this.users[k].user_id) {
|
||||
this.$refs.table.toggleRowSelection(this.crud.data[i], true)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
handleSelectionChange(val, row) {
|
||||
if (val.length > 1 && this.isSingle) {
|
||||
this.$refs.table.clearSelection()
|
||||
this.$refs.table.toggleRowSelection(val.pop())
|
||||
} else {
|
||||
this.checkrow = row
|
||||
}
|
||||
},
|
||||
onSelectAll() {
|
||||
this.$refs.table.clearSelection()
|
||||
},
|
||||
close() {
|
||||
this.crud.resetQuery(false)
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
submit() {
|
||||
// 处理单选
|
||||
if (this.isSingle && this.tableRadio) {
|
||||
this.$emit('update:dialogShow', false)
|
||||
this.$emit('selectUsers', this.tableRadio)
|
||||
return
|
||||
}
|
||||
this.rows = this.$refs.table.selection
|
||||
if (this.rows.length <= 0) {
|
||||
this.$message('请先勾选用户')
|
||||
return
|
||||
}
|
||||
this.crud.resetQuery(false)
|
||||
this.$emit('update:dialogShow', false)
|
||||
this.$emit('selectUsers', this.rows)
|
||||
// console.log(this.rows)
|
||||
},
|
||||
[CRUD.HOOK.afterRefresh]() {
|
||||
this.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
::v-deep .el-dialog__body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="数据权限"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="1000px"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
style="width: 100%;"
|
||||
size="mini"
|
||||
border
|
||||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
|
||||
>
|
||||
<el-table-column prop="permission_scope_type" label="权限类型" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="permission_name" label="权限范围" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="dept_name" label="部门名称" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="person_name" label="用户名称" min-width="100" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import CRUD, { header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
export default {
|
||||
name: 'ShowDataPermissionDialog',
|
||||
components: { rrOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({ title: '权限明细', idField: 'user_id', url: 'api/dataPermission/dataDetail'})
|
||||
},
|
||||
mixins: [presenter(), header()],
|
||||
dicts: ['product_series'],
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
currentUserId: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
classes: [],
|
||||
tableRadio: null,
|
||||
rows: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickChange(item) {
|
||||
this.tableRadio = item
|
||||
},
|
||||
open() {
|
||||
console.log(this.currentUserId)
|
||||
},
|
||||
close() {
|
||||
this.crud.resetQuery(false)
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
[CRUD.HOOK.afterRefresh]() {
|
||||
this.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
::v-deep .el-dialog__body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -179,9 +179,9 @@
|
||||
<el-dropdown-item icon="el-icon-key">
|
||||
<span @click="openDeptDrawer(scope.row)">部门权限</span>
|
||||
</el-dropdown-item>
|
||||
<!-- <el-dropdown-item icon="el-icon-key">-->
|
||||
<!-- <span @click="openDataDialog(scope.row)">数据权限</span>-->
|
||||
<!-- </el-dropdown-item>-->
|
||||
<el-dropdown-item icon="el-icon-key">
|
||||
<span @click="openDataDialog(scope.row)">数据权限</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-lock"><span @click="changeEnabled(scope.row)">{{ enabledTypeOptions.find(item => {return item.key !== scope.row.isUsed}).display_name }}账号</span></el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-circle-check">
|
||||
<span @click="openRoleDrawer(scope.row)">分配角色</span>
|
||||
@@ -314,15 +314,15 @@
|
||||
<el-table-column prop="personName" label="用户名称" min-width="100" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
<!-- <relevance-user-dialog :dialog-show.sync="relevanceUser" :is-single="false" :users="userIds" @selectUsers="selectUsers" />-->
|
||||
<!-- <relevance-dept-dialog :dialog-show.sync="relevanceDept" :is-single="false" :depts="deptIds" @selectDepts="selectDepts" />-->
|
||||
<relevance-user-dialog :dialog-show.sync="relevanceUser" :is-single="false" :users="userIds" @selectUsers="selectUsers" />
|
||||
<relevance-dept-dialog :dialog-show.sync="relevanceDept" :is-single="false" :depts="deptIds" @selectDepts="selectDepts" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudUser from '@/views/system/user/user'
|
||||
import crudDept from '@/api/system/dept'
|
||||
// import crudDataPermission from '@/views/system/permission/dataPermission'
|
||||
import crudDataPermission from '@/views/system/dataPermission/dataPermission'
|
||||
import { getAll, getLevel } from '@/views/system/role/role'
|
||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
@@ -332,8 +332,8 @@ import pagination from '@crud/Pagination'
|
||||
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { mapGetters } from 'vuex'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
// import RelevanceUserDialog from '@/views/system/user/dialog/relevanceUserDialog'
|
||||
// import RelevanceDeptDialog from '@/views/system/user/dialog/relevanceDeptDialog'
|
||||
import RelevanceUserDialog from '@/views/system/user/dialog/relevanceUserDialog'
|
||||
import RelevanceDeptDialog from '@/views/system/user/dialog/relevanceDeptDialog'
|
||||
|
||||
let userRoles = []
|
||||
const defaultForm = {
|
||||
@@ -350,7 +350,7 @@ const defaultForm = {
|
||||
}
|
||||
export default {
|
||||
name: 'User',
|
||||
components: { Treeselect, crudOperation, rrOperation, udOperation, pagination },
|
||||
components: { RelevanceDeptDialog, RelevanceUserDialog, Treeselect, crudOperation, rrOperation, udOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({ title: '用户', idField: 'userId', url: 'api/users', crudMethod: { ...crudUser }})
|
||||
},
|
||||
@@ -671,73 +671,73 @@ export default {
|
||||
this.flag = false
|
||||
this.giveValue(row)
|
||||
},
|
||||
// openDataDialog(row) {
|
||||
// // 清空数据 应该需要初始化赋值
|
||||
// this.dataDialog = {}
|
||||
// this.multipleSelection = []
|
||||
// // 获取权限范围
|
||||
// crudDataPermission.getDataScopeType().then(res => {
|
||||
// this.dataDialog.dataScopeType = res
|
||||
// // permissions
|
||||
// crudDataPermission.getDataPermissionOption().then(res => {
|
||||
// this.permissions = res
|
||||
// this.dataDialog.personName = row.personName
|
||||
// this.dataDialog.username = row.username
|
||||
// this.dataDialog.user_id = row.user_id
|
||||
// this.dataPermissionTitle = '[' + row.personName + '] 数据权限'
|
||||
// this.dataPerm = true
|
||||
// // 回显数据
|
||||
// crudDataPermission.getDataShow(row.user_id).then(res => {
|
||||
// this.$nextTick(function() {
|
||||
// for (var index = 0; index < res.length; index++) {
|
||||
// for (var i = 0; i < this.dataDialog.dataScopeType.length; i++) {
|
||||
// if (this.dataDialog.dataScopeType[i].value == res[index].permission_scope_type) {
|
||||
// this.dataDialog.dataScopeType[i].permission_id = res[index].permission_id
|
||||
// if (res[index].users) this.dataDialog.dataScopeType[i].users = res[index].users
|
||||
// if (res[index].depts) this.dataDialog.dataScopeType[i].depts = res[index].depts
|
||||
// // 选中
|
||||
// this.$refs.dialogTable.toggleRowSelection(this.dataDialog.dataScopeType[i], true)
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
// },
|
||||
openDataDialog(row) {
|
||||
// 清空数据 应该需要初始化赋值
|
||||
this.dataDialog = {}
|
||||
this.multipleSelection = []
|
||||
// 获取权限范围
|
||||
crudDataPermission.getDataScopeType().then(res => {
|
||||
this.dataDialog.dataScopeType = res
|
||||
// permissions
|
||||
crudDataPermission.getDataPermissionOption().then(res => {
|
||||
this.permissions = res
|
||||
this.dataDialog.personName = row.personName
|
||||
this.dataDialog.username = row.username
|
||||
this.dataDialog.user_id = row.user_id
|
||||
this.dataPermissionTitle = '[' + row.personName + '] 数据权限'
|
||||
this.dataPerm = true
|
||||
// 回显数据
|
||||
crudDataPermission.getDataShow(row.user_id).then(res => {
|
||||
this.$nextTick(function() {
|
||||
for (var index = 0; index < res.length; index++) {
|
||||
for (var i = 0; i < this.dataDialog.dataScopeType.length; i++) {
|
||||
if (this.dataDialog.dataScopeType[i].value == res[index].permission_scope_type) {
|
||||
this.dataDialog.dataScopeType[i].permission_id = res[index].permission_id
|
||||
if (res[index].users) this.dataDialog.dataScopeType[i].users = res[index].users
|
||||
if (res[index].depts) this.dataDialog.dataScopeType[i].depts = res[index].depts
|
||||
// 选中
|
||||
this.$refs.dialogTable.toggleRowSelection(this.dataDialog.dataScopeType[i], true)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
getRows(val) { // 获取行数据
|
||||
this.multipleSelection = val
|
||||
},
|
||||
// openRelevance(row, index) {
|
||||
// for (var i = 0; i < this.permissions.length; i++) {
|
||||
// if (this.permissions[i].permission_id != undefined && this.permissions[i].permission_id && this.permissions[i].permission_id != row.permission_id) {
|
||||
// this.$delete(this.dataDialog.dataScopeType[index], this.permissions[i].permission_id.toString())
|
||||
// }
|
||||
// }
|
||||
// this.$set(this.dataDialog.dataScopeType[index], this.dataDialog.dataScopeType[index].permission_id, row.permission_id)
|
||||
// this.rowData = {}
|
||||
// this.deptIds = []
|
||||
// this.userIds = []
|
||||
// if (row.permission_id == '1601040560293023744') { // 选择用户
|
||||
// this.userIds = this.dataDialog.dataScopeType[index].users
|
||||
// this.rowData = row
|
||||
// this.relevanceUser = true
|
||||
// } else if (row.permission_id == '1601040621190123520') { // 选择部门
|
||||
// this.deptIds = this.dataDialog.dataScopeType[index].depts
|
||||
// this.rowData = row
|
||||
// this.relevanceDept = true
|
||||
// } else if (row.permission_id == '1601038030326599680') { // 自身
|
||||
// const param = {
|
||||
// user_id: this.dataDialog.user_id
|
||||
// }
|
||||
// this.dataDialog.dataScopeType[index].users = []
|
||||
// this.dataDialog.dataScopeType[index].users.push(param)
|
||||
// } else { // 其他应该清空
|
||||
// this.dataDialog.dataScopeType[index].depts = []
|
||||
// this.dataDialog.dataScopeType[index].users = []
|
||||
// }
|
||||
// },
|
||||
openRelevance(row, index) {
|
||||
for (var i = 0; i < this.permissions.length; i++) {
|
||||
if (this.permissions[i].permission_id != undefined && this.permissions[i].permission_id && this.permissions[i].permission_id != row.permission_id) {
|
||||
this.$delete(this.dataDialog.dataScopeType[index], this.permissions[i].permission_id.toString())
|
||||
}
|
||||
}
|
||||
this.$set(this.dataDialog.dataScopeType[index], this.dataDialog.dataScopeType[index].permission_id, row.permission_id)
|
||||
this.rowData = {}
|
||||
this.deptIds = []
|
||||
this.userIds = []
|
||||
if (row.permission_id == '1601040560293023744') { // 选择用户
|
||||
this.userIds = this.dataDialog.dataScopeType[index].users
|
||||
this.rowData = row
|
||||
this.relevanceUser = true
|
||||
} else if (row.permission_id == '1601040621190123520') { // 选择部门
|
||||
this.deptIds = this.dataDialog.dataScopeType[index].depts
|
||||
this.rowData = row
|
||||
this.relevanceDept = true
|
||||
} else if (row.permission_id == '1601038030326599680') { // 自身
|
||||
const param = {
|
||||
user_id: this.dataDialog.user_id
|
||||
}
|
||||
this.dataDialog.dataScopeType[index].users = []
|
||||
this.dataDialog.dataScopeType[index].users.push(param)
|
||||
} else { // 其他应该清空
|
||||
this.dataDialog.dataScopeType[index].depts = []
|
||||
this.dataDialog.dataScopeType[index].users = []
|
||||
}
|
||||
},
|
||||
selectUsers(row) { // row对话框传来的数据
|
||||
for (var i = 0; i < this.dataDialog.dataScopeType.length; i++) {
|
||||
if (this.dataDialog.dataScopeType[i].dict_id == this.rowData.dict_id) {
|
||||
@@ -761,17 +761,17 @@ export default {
|
||||
cancelDataPerm() {
|
||||
this.dataPerm = false
|
||||
},
|
||||
// savePermise() {
|
||||
// const param = {
|
||||
// user_id: this.dataDialog.user_id,
|
||||
// datas: this.multipleSelection
|
||||
// }
|
||||
// crudDataPermission.saveDataPermission(param).then(res => {
|
||||
// this.dataPerm = false
|
||||
// this.crud.notify('添加数据权限成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
// this.crud.toQuery()
|
||||
// })
|
||||
// },
|
||||
savePermise() {
|
||||
const param = {
|
||||
user_id: this.dataDialog.user_id,
|
||||
datas: this.multipleSelection
|
||||
}
|
||||
crudDataPermission.saveDataPermission(param).then(res => {
|
||||
this.dataPerm = false
|
||||
this.crud.notify('添加数据权限成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.crud.toQuery()
|
||||
})
|
||||
},
|
||||
openDrawer() {
|
||||
this.syncDrawer = true
|
||||
this.depCheckedId = ''
|
||||
|
||||
Reference in New Issue
Block a user