fix: 数据权限
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.nl.system.service.permission.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
@@ -39,6 +40,12 @@ public class SysDataScope implements Serializable {
|
||||
* 用户权限列表
|
||||
*/
|
||||
private String user_id;
|
||||
@TableField(exist = false)
|
||||
private String deptName;
|
||||
@TableField(exist = false)
|
||||
private String person_name;
|
||||
@TableField(exist = false)
|
||||
private String permissionName;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -106,16 +106,27 @@ public class SysDataPermissionServiceImpl extends ServiceImpl<SysDataPermissionM
|
||||
public List<UserDataPermissionDto> getDataShow(String userId) {
|
||||
List<UserDataPermissionDto> userDataPermissionDtoList = userService.getUserDataPermissionByUserId(userId);
|
||||
userDataPermissionDtoList.forEach(userDataPermissionDto -> {
|
||||
SysDataPermission sysDataPermission = dataPermissionMapper.selectOne(new LambdaQueryWrapper<SysDataPermission>().eq(SysDataPermission::getPermission_id, userDataPermissionDto.getPermission_id()));
|
||||
SysDataPermission sysDataPermission = dataPermissionMapper.selectOne(
|
||||
new LambdaQueryWrapper<SysDataPermission>()
|
||||
.eq(SysDataPermission::getPermission_id, userDataPermissionDto.getPermission_id()));
|
||||
if (sysDataPermission.getCode().equals(DataScopeEnum.USER.getCode())) { // 用户权限
|
||||
List<String> userIds = dataPermissionMapper.findDataScopeUserIdBySelfUserIdAndScopeType(userId, userDataPermissionDto.getPermission_scope_type());
|
||||
if (ObjectUtil.isNotEmpty(userIds)) userDataPermissionDto.setUsers(userIds);
|
||||
List<String> userIds = dataPermissionMapper.findDataScopeUserIdBySelfUserIdAndScopeType(
|
||||
userId, userDataPermissionDto.getPermission_scope_type());
|
||||
if (ObjectUtil.isNotEmpty(userIds)) {
|
||||
userDataPermissionDto.setUsers(userIds);
|
||||
}
|
||||
} else if (sysDataPermission.getCode().equals(DataScopeEnum.DEPT.getCode())) { // 部门权限
|
||||
List<String> deptIds = dataPermissionMapper.findDataScopeDeptIdBySelfUserIdAndScopeType(userId, userDataPermissionDto.getPermission_scope_type());
|
||||
if (ObjectUtil.isNotEmpty(deptIds)) userDataPermissionDto.setDepts(deptIds);
|
||||
List<String> deptIds = dataPermissionMapper.findDataScopeDeptIdBySelfUserIdAndScopeType(
|
||||
userId, userDataPermissionDto.getPermission_scope_type());
|
||||
if (ObjectUtil.isNotEmpty(deptIds)) {
|
||||
userDataPermissionDto.setDepts(deptIds);
|
||||
}
|
||||
} else if (sysDataPermission.getCode().equals(DataScopeEnum.SELF.getCode())) { // 自身
|
||||
List<String> userIds = dataPermissionMapper.findDataScopeUserIdBySelfUserIdAndScopeType(userId, userDataPermissionDto.getPermission_scope_type());
|
||||
if (ObjectUtil.isNotEmpty(userIds)) userDataPermissionDto.setUsers(userIds);
|
||||
List<String> userIds = dataPermissionMapper.findDataScopeUserIdBySelfUserIdAndScopeType(
|
||||
userId, userDataPermissionDto.getPermission_scope_type());
|
||||
if (ObjectUtil.isNotEmpty(userIds)) {
|
||||
userDataPermissionDto.setUsers(userIds);
|
||||
}
|
||||
}
|
||||
// 其他不做处理
|
||||
});
|
||||
@@ -127,7 +138,9 @@ public class SysDataPermissionServiceImpl extends ServiceImpl<SysDataPermissionM
|
||||
public void savePermission(JSONObject datas) {
|
||||
String user_id = datas.getString("user_id");
|
||||
JSONArray data = datas.getJSONArray("datas");
|
||||
if (ObjectUtil.isEmpty(user_id)) throw new BadRequestException(LangProcess.msg("error_isNull",user_id));
|
||||
if (ObjectUtil.isEmpty(user_id)) {
|
||||
throw new BadRequestException(LangProcess.msg("error_isNull",user_id));
|
||||
}
|
||||
// 删除用户绑定的数据
|
||||
userService.deleteDataPermissionById(user_id);
|
||||
dataPermissionMapper.deleteScopeBySelfUserId(user_id);
|
||||
@@ -145,8 +158,7 @@ public class SysDataPermissionServiceImpl extends ServiceImpl<SysDataPermissionM
|
||||
// 如果是用户直接将用户的id绑定进去
|
||||
if (ObjectUtil.isNotEmpty(users)) {
|
||||
for (int j = 0; j < users.size(); j++) {
|
||||
JSONObject user = users.getJSONObject(j);
|
||||
String userId = user.getString("user_id");
|
||||
String userId = users.getString(j);
|
||||
SysDataScope dataScope = new SysDataScope();
|
||||
dataScope.setUser_id(userId);
|
||||
dataScope.setSelf_user_id(user_id);
|
||||
|
||||
@@ -76,7 +76,7 @@ export default {
|
||||
name: 'RelevanceDeptDialog',
|
||||
components: { rrOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({ title: '部门', idField: 'deptId', url: 'api/dept/vo', crudMethod: { ...crudDept }, query: { isUsed: '1' }})
|
||||
return CRUD({ title: '部门', idField: 'dept_id', url: 'api/dept/vo', crudMethod: { ...crudDept }, query: { isUsed: '1' }})
|
||||
},
|
||||
mixins: [presenter(), header()],
|
||||
dicts: ['product_series'],
|
||||
@@ -87,7 +87,7 @@ export default {
|
||||
},
|
||||
isSingle: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
default: false
|
||||
},
|
||||
depts: {
|
||||
type: Array
|
||||
@@ -119,7 +119,7 @@ export default {
|
||||
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].deptId == this.depts[k].deptId) {
|
||||
if (this.crud.data[i].dept_id === this.depts[k].dept_id) {
|
||||
this.$refs.table.toggleRowSelection(this.crud.data[i], true)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="username" label="用户名" :min-width="flexWidth('username',crud.data,'用户名')" />
|
||||
<el-table-column
|
||||
prop="personName"
|
||||
prop="person_name"
|
||||
label="姓名"
|
||||
:min-width="flexWidth('personName',crud.data,'姓名')"
|
||||
:min-width="flexWidth('person_name',crud.data,'姓名')"
|
||||
/>
|
||||
<el-table-column show-overflow-tooltip prop="deptnames" label="部门" />
|
||||
<el-table-column label="状态" align="center" prop="enabled">
|
||||
@@ -78,7 +78,7 @@ export default {
|
||||
name: 'RelevanceUserDialog',
|
||||
components: { rrOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({ title: '用户', idField: 'userId', url: 'api/users', crudMethod: { ...crudUser }, query: {isUsed: '1'}})
|
||||
return CRUD({ title: '用户', idField: 'user_id', url: 'api/users', crudMethod: { ...crudUser }, query: {isUsed: '1'}})
|
||||
},
|
||||
mixins: [presenter(), header()],
|
||||
dicts: ['product_series'],
|
||||
@@ -121,7 +121,7 @@ export default {
|
||||
console.log(this.crud.data)
|
||||
for (var k = 0; k < this.users.length; k++) {
|
||||
for (var i = 0; i < this.crud.data.length; i++) {
|
||||
if (this.crud.data[i].userId == this.users[k].userId) {
|
||||
if (this.crud.data[i].user_id == this.users[k]) {
|
||||
this.$refs.table.toggleRowSelection(this.crud.data[i], true)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -640,6 +640,7 @@ export default {
|
||||
// return row.id !== this.user.id
|
||||
return true
|
||||
},
|
||||
// 重置密码
|
||||
resetPassword(row) {
|
||||
this.$confirm(i18n.t('User.msg.m1'), i18n.t('common.Tips'), {
|
||||
confirmButtonText: i18n.t('common.Confirm'),
|
||||
@@ -693,6 +694,7 @@ export default {
|
||||
this.flag = false
|
||||
this.giveValue(row)
|
||||
},
|
||||
// 打开数据权限
|
||||
openDataDialog(row) {
|
||||
// 清空数据 应该需要初始化赋值
|
||||
this.dataDialog = {}
|
||||
@@ -713,7 +715,7 @@ export default {
|
||||
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].permissionScopeType) {
|
||||
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
|
||||
@@ -731,6 +733,7 @@ export default {
|
||||
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) {
|
||||
@@ -739,41 +742,46 @@ export default {
|
||||
}
|
||||
this.$set(this.dataDialog.dataScopeType[index], this.dataDialog.dataScopeType[index].permission_id, row.permission_id)
|
||||
this.rowData = {}
|
||||
// 提供给另一个dialog的数据
|
||||
this.deptIds = []
|
||||
this.userIds = []
|
||||
if (row.permission_id == '1605129738328870912') { // 选择用户
|
||||
this.userIds = this.dataDialog.dataScopeType[index].users
|
||||
this.rowData = row
|
||||
// 打开用户关系对话框
|
||||
this.relevanceUser = true
|
||||
} else if (row.permission_id == '1605129882164137984') { // 选择部门
|
||||
this.deptIds = this.dataDialog.dataScopeType[index].depts
|
||||
this.rowData = row
|
||||
// 打开部门关系对话框
|
||||
this.relevanceDept = true
|
||||
} else if (row.permission_id == '1605128919449735168') { // 自身
|
||||
const param = {
|
||||
userId: this.dataDialog.userId
|
||||
}
|
||||
this.dataDialog.dataScopeType[index].users = []
|
||||
this.dataDialog.dataScopeType[index].users.push(param)
|
||||
this.dataDialog.dataScopeType[index].users = this.dataDialog.user_id
|
||||
} else { // 其他应该清空
|
||||
this.dataDialog.dataScopeType[index].depts = []
|
||||
this.dataDialog.dataScopeType[index].users = []
|
||||
}
|
||||
},
|
||||
selectUsers(row) { // row对话框传来的数据
|
||||
// row 用户关系对话框传来的数据
|
||||
selectUsers(row) {
|
||||
for (var i = 0; i < this.dataDialog.dataScopeType.length; i++) {
|
||||
if (this.dataDialog.dataScopeType[i].dict_id == this.rowData.dict_id) {
|
||||
if (this.dataDialog.dataScopeType[i].depts != undefined && this.dataDialog.dataScopeType[i].depts.length > 0) this.dataDialog.dataScopeType[i].depts = []
|
||||
this.dataDialog.dataScopeType[i].users = row
|
||||
if (this.dataDialog.dataScopeType[i].dict_id === this.rowData.dict_id) {
|
||||
if (this.dataDialog.dataScopeType[i].depts !== undefined && this.dataDialog.dataScopeType[i].depts.length > 0) {
|
||||
this.dataDialog.dataScopeType[i].depts = []
|
||||
}
|
||||
this.dataDialog.dataScopeType[i].users = row.map(item => item.user_id)
|
||||
break
|
||||
}
|
||||
}
|
||||
this.rowData = {}
|
||||
},
|
||||
// row 部门关系对话框传来的数据
|
||||
selectDepts(row) {
|
||||
for (var i = 0; i < this.dataDialog.dataScopeType.length; i++) {
|
||||
if (this.dataDialog.dataScopeType[i].dict_id == this.rowData.dictId) {
|
||||
if (this.dataDialog.dataScopeType[i].users != undefined && this.dataDialog.dataScopeType[i].users.length > 0) this.dataDialog.dataScopeType[i].users = []
|
||||
if (this.dataDialog.dataScopeType[i].dict_id === this.rowData.dict_id) {
|
||||
if (this.dataDialog.dataScopeType[i].users !== undefined && this.dataDialog.dataScopeType[i].users.length > 0) {
|
||||
this.dataDialog.dataScopeType[i].users = []
|
||||
}
|
||||
this.dataDialog.dataScopeType[i].depts = row
|
||||
break
|
||||
}
|
||||
@@ -877,7 +885,7 @@ export default {
|
||||
},
|
||||
showDatas(row) {
|
||||
const param = {
|
||||
userId: this.dataDialog.userId,
|
||||
userId: this.dataDialog.user_id,
|
||||
permissionScopeType: row.value
|
||||
}
|
||||
crudDataPermission.getDataDetail(param).then(res => {
|
||||
|
||||
@@ -147,7 +147,7 @@ import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import i18n from "@/i18n";
|
||||
import i18n from '@/i18n'
|
||||
|
||||
const defaultForm = { }
|
||||
export default {
|
||||
@@ -157,7 +157,7 @@ export default {
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
title: '烘烤区任务明细',
|
||||
title: i18n.t('Hot.pan2.title'),
|
||||
url: 'api/hotpointivt/taskDtlQuery',
|
||||
idField: 'ivt_id',
|
||||
sort: 'ivt_id,desc',
|
||||
|
||||
Reference in New Issue
Block a user