4c117d87a5
角色权限弹窗支持按菜单批量设置数据范围;用户管理去掉组织/客商权限配置;角色别名改为角色标识。 Co-authored-by: Cursor <cursoragent@cursor.com>
752 lines
22 KiB
Vue
752 lines
22 KiB
Vue
<template>
|
||
<basic-container>
|
||
<avue-crud
|
||
:option="option"
|
||
:table-loading="loading"
|
||
:data="data"
|
||
ref="crud"
|
||
v-model="form"
|
||
:permission="permissionList"
|
||
:before-open="beforeOpen"
|
||
@row-del="rowDel"
|
||
@row-update="rowUpdate"
|
||
@row-save="rowSave"
|
||
@search-change="searchChange"
|
||
@search-reset="searchReset"
|
||
@selection-change="selectionChange"
|
||
@current-change="currentChange"
|
||
@size-change="sizeChange"
|
||
@refresh-change="refreshChange"
|
||
@on-load="onLoad"
|
||
>
|
||
<template #menu-left>
|
||
<el-button
|
||
type="danger"
|
||
icon="el-icon-delete"
|
||
v-if="permission.role_delete"
|
||
plain
|
||
@click="handleDelete"
|
||
>删除
|
||
</el-button>
|
||
<el-button
|
||
icon="el-icon-setting"
|
||
@click="handleRole"
|
||
v-if="isAdministrator"
|
||
plain
|
||
>权限设置
|
||
</el-button>
|
||
</template>
|
||
<template #menu="{ row }">
|
||
<el-link
|
||
type="primary"
|
||
v-if="isAdministrator"
|
||
style="border: 0; background-color: transparent !important"
|
||
@click.stop="handleRowRole(row)"
|
||
>权限设置
|
||
</el-link>
|
||
</template>
|
||
</avue-crud>
|
||
<el-dialog
|
||
title="角色权限配置"
|
||
append-to-body
|
||
v-model="box"
|
||
width="960px"
|
||
@close="handleDialogClose"
|
||
>
|
||
<el-tabs type="border-card">
|
||
<el-tab-pane label="菜单权限">
|
||
<el-row
|
||
justify="space-between"
|
||
align="middle"
|
||
style="margin-bottom: 12px; background: #f5f7fa; padding: 6px 10px; border-radius: 4px"
|
||
>
|
||
<span style="display: inline-flex; align-items: center">
|
||
<el-switch
|
||
v-model="menuLinked"
|
||
active-text="节点联动"
|
||
size="small"
|
||
@change="handleLinkedChange('treeMenu')"
|
||
/>
|
||
<el-tooltip content="开启后勾选父节点会自动勾选所有子节点,关闭则可独立勾选任意节点" placement="top">
|
||
<el-icon style="margin-left: 4px; color: #909399; cursor: pointer"><el-icon-question-filled /></el-icon>
|
||
</el-tooltip>
|
||
</span>
|
||
<el-button-group>
|
||
<el-button size="small" plain @click="handleSelectAll('treeMenu', menuGrantList)"
|
||
>全选</el-button
|
||
>
|
||
<el-button
|
||
size="small"
|
||
plain
|
||
@click="handleInvertSelect('treeMenu', menuGrantList, menuLinked)"
|
||
>反选</el-button
|
||
>
|
||
</el-button-group>
|
||
</el-row>
|
||
<el-tree
|
||
:data="menuGrantList"
|
||
show-checkbox
|
||
:check-strictly="!menuLinked"
|
||
node-key="id"
|
||
ref="treeMenu"
|
||
:default-checked-keys="menuTreeObj"
|
||
:props="props"
|
||
>
|
||
</el-tree>
|
||
</el-tab-pane>
|
||
<el-tab-pane label="数据权限">
|
||
<el-row
|
||
justify="space-between"
|
||
align="middle"
|
||
style="margin-bottom: 12px; background: #f5f7fa; padding: 6px 10px; border-radius: 4px"
|
||
>
|
||
<span style="color: #606266; font-size: 13px"
|
||
>勾选多个菜单后点击「设置」,可批量配置数据权限;设置后菜单旁展示当前范围</span
|
||
>
|
||
<el-button type="primary" size="small" @click="openDataScopeSetting">设置</el-button>
|
||
</el-row>
|
||
<el-tree
|
||
:data="roleDataScopeMenuTree"
|
||
show-checkbox
|
||
node-key="id"
|
||
ref="treeRoleDataScope"
|
||
:props="props"
|
||
>
|
||
<template #default="{ data }">
|
||
<span class="role-data-scope-node">
|
||
<span>{{ data.title }}</span>
|
||
<span v-if="getMenuScopeLabel(data.id)" class="role-data-scope-tag"
|
||
>【{{ getMenuScopeLabel(data.id) }}】</span
|
||
>
|
||
</span>
|
||
</template>
|
||
</el-tree>
|
||
</el-tab-pane>
|
||
<el-tab-pane label="接口权限">
|
||
<el-row
|
||
justify="space-between"
|
||
align="middle"
|
||
style="margin-bottom: 12px; background: #f5f7fa; padding: 6px 10px; border-radius: 4px"
|
||
>
|
||
<span style="display: inline-flex; align-items: center">
|
||
<el-switch
|
||
v-model="apiScopeLinked"
|
||
active-text="节点联动"
|
||
size="small"
|
||
@change="handleLinkedChange('treeApiScope')"
|
||
/>
|
||
<el-tooltip content="开启后勾选父节点会自动勾选所有子节点,关闭则可独立勾选任意节点" placement="top">
|
||
<el-icon style="margin-left: 4px; color: #909399; cursor: pointer"><el-icon-question-filled /></el-icon>
|
||
</el-tooltip>
|
||
</span>
|
||
<el-button-group>
|
||
<el-button
|
||
size="small"
|
||
plain
|
||
@click="handleSelectAll('treeApiScope', apiScopeGrantList)"
|
||
>全选</el-button
|
||
>
|
||
<el-button
|
||
size="small"
|
||
plain
|
||
@click="handleInvertSelect('treeApiScope', apiScopeGrantList, apiScopeLinked)"
|
||
>反选</el-button
|
||
>
|
||
</el-button-group>
|
||
</el-row>
|
||
<el-tree
|
||
:data="apiScopeGrantList"
|
||
show-checkbox
|
||
:check-strictly="!apiScopeLinked"
|
||
node-key="id"
|
||
ref="treeApiScope"
|
||
:default-checked-keys="apiScopeTreeObj"
|
||
:props="props"
|
||
>
|
||
</el-tree>
|
||
</el-tab-pane>
|
||
</el-tabs>
|
||
<template #footer>
|
||
<span class="dialog-footer">
|
||
<el-button @click="box = false">取 消</el-button>
|
||
<el-button type="primary" @click="submit">确 定</el-button>
|
||
</span>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<el-dialog
|
||
title="数据权限设置"
|
||
append-to-body
|
||
v-model="dataScopeSettingBox"
|
||
width="560px"
|
||
class="role-data-scope-setting-dialog"
|
||
>
|
||
<el-form label-position="right" label-width="auto">
|
||
<el-form-item label="角色名称">
|
||
<el-input v-model="dataScopeSetting.roleName" disabled />
|
||
</el-form-item>
|
||
<el-form-item label="数据权限">
|
||
<el-radio-group v-model="dataScopeSetting.scopeType">
|
||
<el-radio :value="1">所在部门及下级</el-radio>
|
||
<el-radio :value="2">全部组织</el-radio>
|
||
<el-radio :value="3">本人创建</el-radio>
|
||
<el-radio :value="4">自定义组织</el-radio>
|
||
</el-radio-group>
|
||
</el-form-item>
|
||
<el-form-item v-if="Number(dataScopeSetting.scopeType) === 4" label="组织">
|
||
<el-tree
|
||
ref="treeCustomDept"
|
||
:data="deptTree"
|
||
show-checkbox
|
||
node-key="id"
|
||
default-expand-all
|
||
:props="{ label: 'title', children: 'children' }"
|
||
style="width: 100%; max-height: 320px; overflow: auto; border: 1px solid #ebeef5; padding: 8px"
|
||
/>
|
||
</el-form-item>
|
||
</el-form>
|
||
<template #footer>
|
||
<span class="dialog-footer">
|
||
<el-button @click="dataScopeSettingBox = false">取消</el-button>
|
||
<el-button type="primary" @click="submitDataScopeSetting">保存</el-button>
|
||
</span>
|
||
</template>
|
||
</el-dialog>
|
||
</basic-container>
|
||
</template>
|
||
|
||
<script>
|
||
import {
|
||
add,
|
||
getList,
|
||
getRole,
|
||
getRoleTreeById,
|
||
grant,
|
||
grantTree,
|
||
remove,
|
||
update,
|
||
} from '@/api/system/role';
|
||
import { getRoleMenuDataScopeTree, submitRoleMenuDataScope } from '@/api/system/roleDataScope';
|
||
import { getDeptTree } from '@/api/system/dept';
|
||
import { mapGetters } from 'vuex';
|
||
import website from '@/config/website';
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
form: {},
|
||
box: false,
|
||
dataScopeSettingBox: false,
|
||
props: {
|
||
label: 'title',
|
||
value: 'key',
|
||
},
|
||
menuGrantList: [],
|
||
apiScopeGrantList: [],
|
||
apiGrantList: [],
|
||
menuTreeObj: [],
|
||
apiScopeTreeObj: [],
|
||
menuLinked: false,
|
||
apiScopeLinked: false,
|
||
currentRoleIds: [],
|
||
currentRoleName: '',
|
||
roleDataScopeMenuTree: [],
|
||
roleDataScopeMap: {},
|
||
deptTree: [],
|
||
dataScopeSetting: {
|
||
roleName: '',
|
||
scopeType: 2,
|
||
menuIds: [],
|
||
},
|
||
selectionList: [],
|
||
query: {},
|
||
loading: true,
|
||
page: {
|
||
pageSize: 10,
|
||
currentPage: 1,
|
||
total: 0,
|
||
},
|
||
option: {
|
||
tip: false,
|
||
simplePage: true,
|
||
searchShow: true,
|
||
searchMenuSpan: 24,
|
||
searchIcon: true,
|
||
searchIndex: 8,
|
||
searchMenuPosition: 'right',
|
||
tree: true,
|
||
border: true,
|
||
index: true,
|
||
selection: true,
|
||
viewBtn: true,
|
||
labelWidth: 'auto',
|
||
searchLabelWidth: 88,
|
||
menuWidth: 240,
|
||
dialogWidth: 600,
|
||
dialogClickModal: false,
|
||
column: [
|
||
{
|
||
label: '上级角色',
|
||
prop: 'parentId',
|
||
dicData: [],
|
||
type: 'tree',
|
||
hide: true,
|
||
span: 24,
|
||
props: {
|
||
label: 'title',
|
||
},
|
||
rules: [
|
||
{
|
||
required: false,
|
||
message: '请选择上级角色',
|
||
trigger: 'click',
|
||
},
|
||
],
|
||
},
|
||
{
|
||
label: '角色名称',
|
||
prop: 'roleName',
|
||
search: true,
|
||
span: 24,
|
||
rules: [
|
||
{
|
||
required: true,
|
||
message: '请输入角色名称',
|
||
trigger: 'blur',
|
||
},
|
||
],
|
||
},
|
||
{
|
||
label: '所属租户',
|
||
prop: 'tenantId',
|
||
type: 'tree',
|
||
dicUrl: '/blade-system/tenant/select',
|
||
addDisplay: false,
|
||
editDisplay: false,
|
||
viewDisplay: website.tenantMode,
|
||
span: 24,
|
||
props: {
|
||
label: 'tenantName',
|
||
value: 'tenantId',
|
||
},
|
||
hide: !website.tenantMode,
|
||
search: website.tenantMode,
|
||
rules: [
|
||
{
|
||
required: true,
|
||
message: '请输入所属租户',
|
||
trigger: 'click',
|
||
},
|
||
],
|
||
},
|
||
{
|
||
label: '角色标识',
|
||
labelTip: '用于权限校验与标注的属性',
|
||
prop: 'roleAlias',
|
||
search: true,
|
||
span: 24,
|
||
rules: [
|
||
{
|
||
required: true,
|
||
message: '请输入角色标识',
|
||
trigger: 'blur',
|
||
},
|
||
],
|
||
},
|
||
{
|
||
label: '角色排序',
|
||
prop: 'sort',
|
||
type: 'number',
|
||
span: 24,
|
||
rules: [
|
||
{
|
||
required: true,
|
||
message: '请输入角色排序',
|
||
trigger: 'blur',
|
||
},
|
||
],
|
||
},
|
||
],
|
||
},
|
||
data: [],
|
||
};
|
||
},
|
||
computed: {
|
||
...mapGetters(['userInfo', 'permission', 'isAdministrator']),
|
||
permissionList() {
|
||
return {
|
||
addBtn: this.validData(this.permission.role_add, false),
|
||
viewBtn: this.validData(this.permission.role_view, false),
|
||
delBtn: this.validData(this.permission.role_delete, false),
|
||
editBtn: this.validData(this.permission.role_edit, false),
|
||
};
|
||
},
|
||
ids() {
|
||
let ids = [];
|
||
this.selectionList.forEach(ele => {
|
||
ids.push(ele.id);
|
||
});
|
||
return ids.join(',');
|
||
},
|
||
idsArray() {
|
||
let ids = [];
|
||
this.selectionList.forEach(ele => {
|
||
ids.push(ele.id);
|
||
});
|
||
return ids;
|
||
},
|
||
},
|
||
methods: {
|
||
initData(roleId) {
|
||
getRoleTreeById(roleId).then(res => {
|
||
const column = this.findColumn(this.option.column, 'parentId');
|
||
column.dicData = res.data.data;
|
||
});
|
||
},
|
||
getAllNodeKeys(nodes) {
|
||
let keys = [];
|
||
nodes.forEach(node => {
|
||
keys.push(node.id);
|
||
if (node.children && node.children.length > 0) {
|
||
keys = keys.concat(this.getAllNodeKeys(node.children));
|
||
}
|
||
});
|
||
return keys;
|
||
},
|
||
getLeafKeys(nodes) {
|
||
let keys = [];
|
||
nodes.forEach(node => {
|
||
if (!node.children || node.children.length === 0) {
|
||
keys.push(node.id);
|
||
} else {
|
||
keys = keys.concat(this.getLeafKeys(node.children));
|
||
}
|
||
});
|
||
return keys;
|
||
},
|
||
handleSelectAll(treeRef, dataList) {
|
||
const tree = this.$refs[treeRef];
|
||
if (!tree) return;
|
||
const allKeys = this.getAllNodeKeys(dataList);
|
||
tree.setCheckedKeys(allKeys);
|
||
},
|
||
handleInvertSelect(treeRef, dataList, isLinked) {
|
||
const tree = this.$refs[treeRef];
|
||
if (!tree) return;
|
||
const checkedKeys = new Set(tree.getCheckedKeys());
|
||
if (isLinked) {
|
||
const leafKeys = this.getLeafKeys(dataList);
|
||
const invertedKeys = leafKeys.filter(key => !checkedKeys.has(key));
|
||
tree.setCheckedKeys(invertedKeys);
|
||
} else {
|
||
const allKeys = this.getAllNodeKeys(dataList);
|
||
const invertedKeys = allKeys.filter(key => !checkedKeys.has(key));
|
||
tree.setCheckedKeys(invertedKeys);
|
||
}
|
||
},
|
||
handleLinkedChange(treeRef) {
|
||
const tree = this.$refs[treeRef];
|
||
if (!tree) return;
|
||
const checkedKeys = tree.getCheckedKeys();
|
||
const halfCheckedKeys = tree.getHalfCheckedKeys();
|
||
this.$nextTick(() => {
|
||
tree.setCheckedKeys([...checkedKeys, ...halfCheckedKeys]);
|
||
});
|
||
},
|
||
// el-tree 会把 setCheckedKeys 的入参记录为默认勾选集并在树数据重载时回放,
|
||
// 复用的树实例需在打开配置时整体覆盖勾选状态,避免残留上一次配置的勾选
|
||
applyCheckedKeys(treeRef, keys) {
|
||
const tree = this.$refs[treeRef];
|
||
if (!tree) return;
|
||
tree.setCheckedKeys(keys);
|
||
},
|
||
submit() {
|
||
const menuList = this.$refs.treeMenu.getCheckedKeys();
|
||
const apiScopeList = this.$refs.treeApiScope.getCheckedKeys();
|
||
// 数据权限已改为角色菜单配置;传 null 跳过原生 dataScope 更新,避免误清历史配置
|
||
grant(this.currentRoleIds, menuList, null, apiScopeList).then(() => {
|
||
this.box = false;
|
||
this.$message({
|
||
type: 'success',
|
||
message: '操作成功!',
|
||
});
|
||
this.currentRoleIds = [];
|
||
this.selectionList = [];
|
||
this.onLoad(this.page);
|
||
});
|
||
},
|
||
getMenuScopeLabel(menuId) {
|
||
const scope = this.roleDataScopeMap[String(menuId)];
|
||
return scope ? scope.scopeTypeName : '';
|
||
},
|
||
loadRoleDataScopeTree(roleId) {
|
||
return getRoleMenuDataScopeTree(roleId).then(res => {
|
||
const data = res.data.data || {};
|
||
this.currentRoleName = data.roleName || '';
|
||
this.roleDataScopeMenuTree = data.menuTree || [];
|
||
const scopeMap = {};
|
||
(data.scopes || []).forEach(item => {
|
||
scopeMap[String(item.menuId)] = item;
|
||
});
|
||
this.roleDataScopeMap = scopeMap;
|
||
});
|
||
},
|
||
openDataScopeSetting() {
|
||
const tree = this.$refs.treeRoleDataScope;
|
||
if (!tree) {
|
||
return;
|
||
}
|
||
const menuIds = tree.getCheckedKeys();
|
||
if (!menuIds || menuIds.length === 0) {
|
||
this.$message.warning('请先勾选要设置的菜单');
|
||
return;
|
||
}
|
||
this.dataScopeSetting = {
|
||
roleName: this.currentRoleName,
|
||
scopeType: 2,
|
||
menuIds,
|
||
};
|
||
const loadDept =
|
||
this.deptTree && this.deptTree.length
|
||
? Promise.resolve()
|
||
: getDeptTree(this.userInfo.tenantId).then(res => {
|
||
this.deptTree = res.data.data || [];
|
||
});
|
||
loadDept.then(() => {
|
||
this.dataScopeSettingBox = true;
|
||
this.$nextTick(() => {
|
||
if (this.$refs.treeCustomDept) {
|
||
this.$refs.treeCustomDept.setCheckedKeys([]);
|
||
}
|
||
});
|
||
});
|
||
},
|
||
submitDataScopeSetting() {
|
||
const roleId = this.currentRoleIds && this.currentRoleIds[0];
|
||
if (!roleId) {
|
||
this.$message.warning('角色信息异常,请重新打开权限配置');
|
||
return;
|
||
}
|
||
const scopeType = Number(this.dataScopeSetting.scopeType || 2);
|
||
let deptIds = [];
|
||
if (scopeType === 4) {
|
||
deptIds = this.$refs.treeCustomDept ? this.$refs.treeCustomDept.getCheckedKeys() : [];
|
||
if (!deptIds.length) {
|
||
this.$message.warning('自定义组织时请勾选组织');
|
||
return;
|
||
}
|
||
}
|
||
submitRoleMenuDataScope({
|
||
roleId,
|
||
menuIds: this.dataScopeSetting.menuIds,
|
||
scopeType,
|
||
deptIds,
|
||
}).then(() => {
|
||
this.$message.success('数据权限设置成功');
|
||
this.dataScopeSettingBox = false;
|
||
this.loadRoleDataScopeTree(roleId).then(() => {
|
||
this.$nextTick(() => {
|
||
if (this.$refs.treeRoleDataScope) {
|
||
this.$refs.treeRoleDataScope.setCheckedKeys([]);
|
||
}
|
||
});
|
||
});
|
||
});
|
||
},
|
||
rowSave(row, done, loading) {
|
||
add(this.withTenantId(row)).then(
|
||
() => {
|
||
this.onLoad(this.page);
|
||
this.$message({
|
||
type: 'success',
|
||
message: '操作成功!',
|
||
});
|
||
done();
|
||
},
|
||
error => {
|
||
window.console.log(error);
|
||
loading();
|
||
}
|
||
);
|
||
},
|
||
rowUpdate(row, index, done, loading) {
|
||
update(this.withTenantId(row)).then(
|
||
() => {
|
||
this.onLoad(this.page);
|
||
this.$message({
|
||
type: 'success',
|
||
message: '操作成功!',
|
||
});
|
||
done();
|
||
},
|
||
error => {
|
||
window.console.log(error);
|
||
loading();
|
||
}
|
||
);
|
||
},
|
||
withTenantId(row) {
|
||
return {
|
||
...row,
|
||
tenantId: row.tenantId || this.userInfo.tenantId || website.tenantId,
|
||
};
|
||
},
|
||
rowDel(row) {
|
||
this.$confirm('确定将选择数据删除?', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning',
|
||
})
|
||
.then(() => {
|
||
return remove(row.id);
|
||
})
|
||
.then(() => {
|
||
this.onLoad(this.page);
|
||
this.$message({
|
||
type: 'success',
|
||
message: '操作成功!',
|
||
});
|
||
});
|
||
},
|
||
|
||
searchReset() {
|
||
this.query = {};
|
||
this.onLoad(this.page);
|
||
},
|
||
searchChange(params, done) {
|
||
this.query = params;
|
||
this.page.currentPage = 1;
|
||
this.onLoad(this.page, params);
|
||
done();
|
||
},
|
||
selectionChange(list) {
|
||
this.selectionList = list;
|
||
},
|
||
selectionClear() {
|
||
this.selectionList = [];
|
||
this.$refs.crud.toggleSelection();
|
||
},
|
||
beforeOpen(done, type) {
|
||
if (['add', 'edit'].includes(type)) {
|
||
this.initData(this.form.id);
|
||
}
|
||
if (['edit', 'view'].includes(type)) {
|
||
if (this.form.parentId === '0') {
|
||
this.form.parentId = '';
|
||
}
|
||
}
|
||
done();
|
||
},
|
||
handleRole() {
|
||
if (this.selectionList.length === 0) {
|
||
this.$message.warning('请选择一条数据');
|
||
return;
|
||
}
|
||
if (this.selectionList.length > 1) {
|
||
this.$message.warning('只能选择一条数据');
|
||
return;
|
||
}
|
||
this.menuTreeObj = [];
|
||
this.apiScopeTreeObj = [];
|
||
this.currentRoleIds = this.idsArray;
|
||
this.currentRoleName = (this.selectionList[0] && this.selectionList[0].roleName) || '';
|
||
const roleId = this.currentRoleIds[0];
|
||
Promise.all([grantTree(), getRole(this.ids), this.loadRoleDataScopeTree(roleId)]).then(results => {
|
||
const grantRes = results[0];
|
||
const roleRes = results[1];
|
||
this.menuGrantList = grantRes.data.data.menu;
|
||
this.apiScopeGrantList = grantRes.data.data.apiScope;
|
||
this.menuTreeObj = roleRes.data.data.menu;
|
||
this.apiScopeTreeObj = roleRes.data.data.apiScope;
|
||
this.box = true;
|
||
this.$nextTick(() => {
|
||
this.applyCheckedKeys('treeMenu', this.menuTreeObj);
|
||
this.applyCheckedKeys('treeApiScope', this.apiScopeTreeObj);
|
||
});
|
||
});
|
||
},
|
||
handleRowRole(row) {
|
||
this.menuTreeObj = [];
|
||
this.apiScopeTreeObj = [];
|
||
this.currentRoleIds = [row.id];
|
||
this.currentRoleName = row.roleName || '';
|
||
Promise.all([grantTree(), getRole(row.id), this.loadRoleDataScopeTree(row.id)]).then(results => {
|
||
const grantRes = results[0];
|
||
const roleRes = results[1];
|
||
this.menuGrantList = grantRes.data.data.menu;
|
||
this.apiScopeGrantList = grantRes.data.data.apiScope;
|
||
this.menuTreeObj = roleRes.data.data.menu;
|
||
this.apiScopeTreeObj = roleRes.data.data.apiScope;
|
||
this.box = true;
|
||
this.$nextTick(() => {
|
||
this.applyCheckedKeys('treeMenu', this.menuTreeObj);
|
||
this.applyCheckedKeys('treeApiScope', this.apiScopeTreeObj);
|
||
});
|
||
});
|
||
},
|
||
handleDialogClose() {
|
||
this.menuTreeObj = [];
|
||
this.apiScopeTreeObj = [];
|
||
this.menuLinked = false;
|
||
this.apiScopeLinked = false;
|
||
this.roleDataScopeMenuTree = [];
|
||
this.roleDataScopeMap = {};
|
||
this.currentRoleName = '';
|
||
this.dataScopeSettingBox = false;
|
||
this.selectionClear();
|
||
},
|
||
handleDelete() {
|
||
if (this.selectionList.length === 0) {
|
||
this.$message.warning('请选择至少一条数据');
|
||
return;
|
||
}
|
||
this.$confirm('确定将选择数据删除?', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning',
|
||
})
|
||
.then(() => {
|
||
return remove(this.ids);
|
||
})
|
||
.then(() => {
|
||
this.onLoad(this.page);
|
||
this.$message({
|
||
type: 'success',
|
||
message: '操作成功!',
|
||
});
|
||
this.$refs.crud.toggleSelection();
|
||
});
|
||
},
|
||
currentChange(currentPage) {
|
||
this.page.currentPage = currentPage;
|
||
},
|
||
sizeChange(pageSize) {
|
||
this.page.pageSize = pageSize;
|
||
},
|
||
refreshChange() {
|
||
this.onLoad(this.page, this.query);
|
||
},
|
||
onLoad(page, params = {}) {
|
||
this.loading = true;
|
||
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||
this.data = res.data.data;
|
||
this.loading = false;
|
||
this.selectionClear();
|
||
});
|
||
},
|
||
},
|
||
};
|
||
</script>
|
||
|
||
<style scoped>
|
||
.role-data-scope-node {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 4px;
|
||
}
|
||
.role-data-scope-tag {
|
||
color: #409eff;
|
||
font-size: 12px;
|
||
}
|
||
</style>
|