数据权限回显
This commit is contained in:
@@ -86,4 +86,11 @@ public class DataPermissionController {
|
||||
dataPermissionService.savePermission(datas);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PostMapping("/dataShow")
|
||||
@Log("查看数据权限")
|
||||
@ApiOperation("查看数据权限")
|
||||
public ResponseEntity<Object> getDataShow(@RequestBody String id){
|
||||
return new ResponseEntity<>(dataPermissionService.getDataShow(id),HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,4 +81,11 @@ public interface DataPermissionService {
|
||||
* @param datas
|
||||
*/
|
||||
void savePermission(JSONObject datas);
|
||||
|
||||
/**
|
||||
* 通过用户id获取其数据权限
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
JSONArray getDataShow(String userId);
|
||||
}
|
||||
|
||||
@@ -210,4 +210,25 @@ public class DataPermissionServiceImpl implements DataPermissionService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getDataShow(String userId) {
|
||||
WQLObject scopeTab = WQLObject.getWQLObject("sys_user_data_permission"); // 用户数据权限表
|
||||
WQLObject dataTab = WQLObject.getWQLObject("sys_data_permission"); // 权限:user用户权限,dept部门权限
|
||||
JSONArray resultJSONArray = scopeTab.query("user_id = '" + userId + "'").getResultJSONArray(0);
|
||||
for (int i = 0; i < resultJSONArray.size(); i++) {
|
||||
JSONObject jsonObject = resultJSONArray.getJSONObject(i);
|
||||
String permissionId = jsonObject.getString("permission_id");
|
||||
JSONObject dataObj = dataTab.query("permission_id = '" + permissionId + "'").uniqueResult(0);
|
||||
if (dataObj.getString("code").equals("user")) { // 用户权限
|
||||
JSONArray userIds = WQL.getWO("Query").addParamMap(MapOf.of("flag", "2", "self_user_id", userId, "permission_scope_type", jsonObject.getString("permission_scope_type"))).process().getResultJSONArray(0);
|
||||
jsonObject.put("users", userIds);
|
||||
} else if (dataObj.getString("code").equals("dept")) { // 部门权限
|
||||
JSONArray deptIds = WQL.getWO("Query").addParamMap(MapOf.of("flag", "3", "self_user_id", userId, "permission_scope_type", jsonObject.getString("permission_scope_type"))).process().getResultJSONArray(0);
|
||||
jsonObject.put("depts", deptIds);
|
||||
}
|
||||
// 其他不做处理
|
||||
}
|
||||
return resultJSONArray;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
#################################################
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.flag TYPEAS s_string
|
||||
输入.dept_id TYPEAS s_string
|
||||
输入.self_user_id TYPEAS s_string
|
||||
输入.permission_scope_type TYPEAS s_string
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
@@ -52,3 +54,37 @@
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
IF 输入.flag = "2"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
scop.user_id
|
||||
FROM
|
||||
`sys_data_scope` scop
|
||||
WHERE
|
||||
1 = 1
|
||||
OPTION 输入.self_user_id <> ""
|
||||
self_user_id = 输入.self_user_id
|
||||
ENDOPTION
|
||||
OPTION 输入.permission_scope_type <> ""
|
||||
permission_scope_type = 输入.permission_scope_type
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
IF 输入.flag = "3"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
DISTINCT scop.dept_id
|
||||
FROM
|
||||
`sys_data_scope` scop
|
||||
WHERE
|
||||
1 = 1
|
||||
OPTION 输入.self_user_id <> ""
|
||||
self_user_id = 输入.self_user_id
|
||||
ENDOPTION
|
||||
OPTION 输入.permission_scope_type <> ""
|
||||
permission_scope_type = 输入.permission_scope_type
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -46,4 +46,12 @@ export function saveDataPermission(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getDataScopeType, getDataPermissionOption, saveDataPermission }
|
||||
export function getDataShow(id) {
|
||||
return request({
|
||||
url: 'api/dataPermission/dataShow',
|
||||
method: 'post',
|
||||
data: id
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getDataScopeType, getDataPermissionOption, saveDataPermission, getDataShow }
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
border
|
||||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
|
||||
@select="handleSelectionChange"
|
||||
@select-all="onSelectAll"
|
||||
@current-change="clickChange"
|
||||
>
|
||||
<el-table-column v-if="!isSingle" type="selection" width="55" />
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
border
|
||||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
|
||||
@select="handleSelectionChange"
|
||||
@select-all="onSelectAll"
|
||||
@current-change="clickChange"
|
||||
>
|
||||
<el-table-column v-if="!isSingle" type="selection" width="55" />
|
||||
|
||||
@@ -258,9 +258,12 @@
|
||||
>
|
||||
<el-table-column :selectable="checkboxT" type="selection" width="55" />
|
||||
<el-table-column prop="label" label="权限范围" />
|
||||
<el-table-column prop="permission_id" label="数据权限">
|
||||
<el-table-column label="数据权限">
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.permission_id" placeholder="请选择" @change="openRelevance(scope.row)">
|
||||
<el-select
|
||||
v-model="scope.row.permission_id"
|
||||
placeholder="请选择"
|
||||
@change="openRelevance(scope.row, scope.$index)">
|
||||
<el-option
|
||||
v-for="item in permissions"
|
||||
:key="item.permission_id"
|
||||
@@ -270,16 +273,16 @@
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column-->
|
||||
<!-- label="操作"-->
|
||||
<!-- fixed="right"-->
|
||||
<!-- align="center"-->
|
||||
<!-- width="80"-->
|
||||
<!-- >-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <el-button type="text" icon="el-icon-arrow-right" @click="openRelevance(scope.row)">关联</el-button>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column-->
|
||||
<!-- label="操作"-->
|
||||
<!-- fixed="right"-->
|
||||
<!-- align="center"-->
|
||||
<!-- width="100"-->
|
||||
<!-- >-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <el-button type="text">查看明细</el-button>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
</el-table>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
@@ -288,7 +291,7 @@
|
||||
</div>
|
||||
</el-dialog>
|
||||
<relevance-user-dialog :dialog-show.sync="relevanceUser" :is-single="false" @selectUsers="selectUsers" />
|
||||
<relevance-dept-dialog :dialog-show.sync="relevanceDept" :is-single="false" @selectDepts="selectDepts"/>
|
||||
<relevance-dept-dialog :dialog-show.sync="relevanceDept" :is-single="false" @selectDepts="selectDepts" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -649,16 +652,40 @@ export default {
|
||||
this.dataDialog.username = row.username
|
||||
this.dataDialog.user_id = row.user_id
|
||||
this.dataPerm = true
|
||||
console.log(res)
|
||||
// console.log(res)
|
||||
// 回显数据
|
||||
crudDataPermission.getDataShow(row.user_id).then(res => {
|
||||
console.log('回显数据', res)
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(this.dataDialog.dataScopeType)
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
getRows(val) { // 获取行数据
|
||||
this.multipleSelection = val
|
||||
console.log(val)
|
||||
console.log('选中', val)
|
||||
},
|
||||
openRelevance(row) {
|
||||
openRelevance(row, index) {
|
||||
console.log('下标', index)
|
||||
console.log('关联的当行数据', row)
|
||||
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 = {}
|
||||
if (row.permission_id == '1601040560293023744') { // 用户
|
||||
this.rowData = row
|
||||
@@ -696,6 +723,7 @@ export default {
|
||||
user_id: this.dataDialog.user_id,
|
||||
datas: this.multipleSelection
|
||||
}
|
||||
console.log(this.dataDialog)
|
||||
crudDataPermission.saveDataPermission(param).then(res => {
|
||||
this.dataPerm = false
|
||||
this.crud.notify('添加数据权限成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
|
||||
Reference in New Issue
Block a user