mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-08 09:58:56 +08:00
用户组-资源绑定关系
This commit is contained in:
parent
951df265e5
commit
6e03a08599
@ -40,7 +40,7 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<insert id="insertGroupPrivileges" parameterType="java.util.List">
|
<insert id="insertGroupPrivileges" parameterType="java.util.List">
|
||||||
insert into mxk_role_privileges ( id,appid,groupid,resourceid,status,instid)
|
insert into mxk_group_privileges ( id,appid,groupid,resourceid,status,instid)
|
||||||
values
|
values
|
||||||
<foreach collection="list" item="item" index="index" separator=",">
|
<foreach collection="list" item="item" index="index" separator=",">
|
||||||
(#{item.id},#{item.appId},#{item.groupId},#{item.resourceId},#{item.status},#{item.instId})
|
(#{item.id},#{item.appId},#{item.groupId},#{item.resourceId},#{item.status},#{item.instId})
|
||||||
|
|||||||
@ -7,8 +7,14 @@
|
|||||||
<nz-form-item>
|
<nz-form-item>
|
||||||
<nz-form-label nzFor="groupName">{{ 'mxk.roles.name' | i18n }}</nz-form-label>
|
<nz-form-label nzFor="groupName">{{ 'mxk.roles.name' | i18n }}</nz-form-label>
|
||||||
<nz-form-control>
|
<nz-form-control>
|
||||||
<input nz-input [(ngModel)]="query.params.groupName" [ngModelOptions]="{ standalone: true }"
|
<input
|
||||||
name="groupName" placeholder="" id="groupName" />
|
nz-input
|
||||||
|
[(ngModel)]="query.params.groupName"
|
||||||
|
[ngModelOptions]="{ standalone: true }"
|
||||||
|
name="groupName"
|
||||||
|
placeholder=""
|
||||||
|
id="groupName"
|
||||||
|
/>
|
||||||
</nz-form-control>
|
</nz-form-control>
|
||||||
</nz-form-item>
|
</nz-form-item>
|
||||||
</div>
|
</div>
|
||||||
@ -17,23 +23,28 @@
|
|||||||
<nz-form-label nzFor="name">{{ 'mxk.resources.appName' | i18n }}</nz-form-label>
|
<nz-form-label nzFor="name">{{ 'mxk.resources.appName' | i18n }}</nz-form-label>
|
||||||
<nz-form-control>
|
<nz-form-control>
|
||||||
<nz-input-group nzSearch [nzAddOnAfter]="suffixButton">
|
<nz-input-group nzSearch [nzAddOnAfter]="suffixButton">
|
||||||
<input nz-input [(ngModel)]="query.params.appName" [ngModelOptions]="{ standalone: true }" name="appName"
|
<input
|
||||||
readonly placeholder="" id="appName" />
|
nz-input
|
||||||
|
[(ngModel)]="query.params.appName"
|
||||||
|
[ngModelOptions]="{ standalone: true }"
|
||||||
|
name="appName"
|
||||||
|
readonly
|
||||||
|
placeholder=""
|
||||||
|
id="appName"
|
||||||
|
/>
|
||||||
</nz-input-group>
|
</nz-input-group>
|
||||||
<ng-template #suffixButton>
|
<ng-template #suffixButton>
|
||||||
<button nz-button nzType="primary" (click)="onSelect($event)" nzSearch>{{ 'mxk.text.select' | i18n
|
<button nz-button nzType="primary" (click)="onSelect($event)" nzSearch>{{ 'mxk.text.select' | i18n }}</button>
|
||||||
}}</button>
|
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</nz-form-control>
|
</nz-form-control>
|
||||||
</nz-form-item>
|
</nz-form-item>
|
||||||
</div>
|
</div>
|
||||||
<div nz-col [nzSpan]="query.expandForm ? 24 : 4" [class.text-right]="query.expandForm">
|
<div nz-col [nzSpan]="query.expandForm ? 24 : 4" [class.text-right]="query.expandForm">
|
||||||
<button nz-button type="submit" [nzType]="'primary'" [nzLoading]="query.submitLoading">{{ 'mxk.text.query' |
|
<button nz-button type="submit" [nzType]="'primary'" [nzLoading]="query.submitLoading">{{ 'mxk.text.query' | i18n }}</button>
|
||||||
i18n }}</button>
|
<button nz-button type="reset" (click)="onReset()" class="mx-sm" style="display: none">{{ 'mxk.text.reset' | i18n }}</button>
|
||||||
<button nz-button type="reset" (click)="onReset()" class="mx-sm" style="display: none">{{ 'mxk.text.reset' |
|
|
||||||
i18n }}</button>
|
|
||||||
<button nz-button (click)="query.expandForm = !query.expandForm" class="mx-sm" style="display: none">
|
<button nz-button (click)="query.expandForm = !query.expandForm" class="mx-sm" style="display: none">
|
||||||
{{ query.expandForm ? ('mxk.text.collapse' | i18n) : ('mxk.text.expand' | i18n) }}</button>
|
{{ query.expandForm ? ('mxk.text.collapse' | i18n) : ('mxk.text.expand' | i18n) }}</button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -44,39 +55,59 @@
|
|||||||
</div>
|
</div>
|
||||||
<div nz-row [nzGutter]="{ xs: 8, sm: 8, md: 8, lg: 24, xl: 48, xxl: 48 }">
|
<div nz-row [nzGutter]="{ xs: 8, sm: 8, md: 8, lg: 24, xl: 48, xxl: 48 }">
|
||||||
<div nz-col [nzSpan]="10" class="grid-border">
|
<div nz-col [nzSpan]="10" class="grid-border">
|
||||||
<nz-table #dynamicTable nzTableLayout="auto" nzSize="small" nzBordered nzShowSizeChanger
|
<nz-table
|
||||||
[nzData]="query.results.rows" [nzFrontPagination]="false" [nzTotal]="query.results.records"
|
#dynamicTable
|
||||||
[nzPageSizeOptions]="query.params.pageSizeOptions" [nzPageSize]="query.params.pageSize"
|
nzTableLayout="auto"
|
||||||
[nzPageIndex]="query.params.pageNumber" [nzLoading]="this.query.tableLoading"
|
nzSize="small"
|
||||||
(nzQueryParams)="onQueryParamsChange($event)">
|
nzBordered
|
||||||
|
nzShowSizeChanger
|
||||||
|
[nzData]="query.results.rows"
|
||||||
|
[nzFrontPagination]="false"
|
||||||
|
[nzTotal]="query.results.records"
|
||||||
|
[nzPageSizeOptions]="query.params.pageSizeOptions"
|
||||||
|
[nzPageSize]="query.params.pageSize"
|
||||||
|
[nzPageIndex]="query.params.pageNumber"
|
||||||
|
[nzLoading]="this.query.tableLoading"
|
||||||
|
(nzQueryParams)="onQueryParamsChange($event)"
|
||||||
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<!--<th [nzChecked]="query.checked" [nzIndeterminate]="query.indeterminate" (nzCheckedChange)="onTableAllChecked($event)"></th>
|
<!--<th [nzChecked]="query.checked" [nzIndeterminate]="query.indeterminate" (nzCheckedChange)="onTableAllChecked($event)"></th>
|
||||||
-->
|
-->
|
||||||
<th nzAlign="center"></th>
|
<th nzAlign="center"></th>
|
||||||
<th nzAlign="center" style="display: none">Id</th>
|
<th nzAlign="center" style="display: none">Id</th>
|
||||||
<th nzAlign="center">{{ 'mxk.roles.name' | i18n }}</th>
|
<th nzAlign="center">{{ 'mxk.groups.name' | i18n }}</th>
|
||||||
<th nzAlign="center">{{ 'mxk.roles.category' | i18n }}</th>
|
<th nzAlign="center">{{ 'mxk.groups.category' | i18n }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let data of query.results.rows">
|
<tr *ngFor="let data of query.results.rows">
|
||||||
<td [nzChecked]="query.tableCheckedId.has(data.id)" [nzDisabled]="data.disabled"
|
<td
|
||||||
(nzCheckedChange)="onTableItemChecked(data.id, $event)"></td>
|
[nzChecked]="query.tableCheckedId.has(data.id)"
|
||||||
|
[nzDisabled]="data.disabled"
|
||||||
|
(nzCheckedChange)="onTableItemChecked(data.id, $event)"
|
||||||
|
></td>
|
||||||
<td nzAlign="left" style="display: none">
|
<td nzAlign="left" style="display: none">
|
||||||
<span>{{ data.id }}</span>
|
<span>{{ data.id }}</span>
|
||||||
</td>
|
</td>
|
||||||
<td nzAlign="left" nzBreakWord="false">{{ data.groupName }}</td>
|
<td nzAlign="left" nzBreakWord="false">{{ data.groupName }}</td>
|
||||||
<td nzAlign="center" *ngIf="data.category == 'dynamic'"> {{ 'mxk.roles.category.dynamic' | i18n }}</td>
|
<td nzAlign="center" *ngIf="data.category == 'dynamic'"> {{ 'mxk.groups.category.dynamic' | i18n }}</td>
|
||||||
<td nzAlign="center" *ngIf="data.category == 'static'"> {{ 'mxk.roles.category.static' | i18n }}</td>
|
<td nzAlign="center" *ngIf="data.category == 'static'"> {{ 'mxk.groups.category.static' | i18n }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</nz-table>
|
</nz-table>
|
||||||
</div>
|
</div>
|
||||||
<div nz-col [nzSpan]="14" class="grid-border">
|
<div nz-col [nzSpan]="14" class="grid-border">
|
||||||
<nz-tree #nzTreeComponent nzShowLine="false" [nzCheckable]="treeNodes.checkable"
|
<nz-tree
|
||||||
[nzCheckedKeys]="treeNodes.checkedKeys" nzBlockNode [nzData]="treeNodes.nodes" (nzDblClick)="openFolder($event)"
|
#nzTreeComponent
|
||||||
[nzTreeTemplate]="nzTreeTemplate"></nz-tree>
|
nzShowLine="false"
|
||||||
|
[nzCheckable]="treeNodes.checkable"
|
||||||
|
[nzCheckedKeys]="treeNodes.checkedKeys"
|
||||||
|
nzBlockNode
|
||||||
|
[nzData]="treeNodes.nodes"
|
||||||
|
(nzDblClick)="openFolder($event)"
|
||||||
|
[nzTreeTemplate]="nzTreeTemplate"
|
||||||
|
></nz-tree>
|
||||||
<ng-template #nzTreeTemplate let-node let-origin="origin">
|
<ng-template #nzTreeTemplate let-node let-origin="origin">
|
||||||
<span class="custom-node">
|
<span class="custom-node">
|
||||||
<span *ngIf="!node.isLeaf">
|
<span *ngIf="!node.isLeaf">
|
||||||
|
|||||||
@ -134,9 +134,9 @@ export class PrivilegesComponent implements OnInit {
|
|||||||
|
|
||||||
onSave(e: MouseEvent): void {
|
onSave(e: MouseEvent): void {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let _roleId: String = '';
|
let _groupId: String = '';
|
||||||
this.query.tableCheckedId.forEach(value => {
|
this.query.tableCheckedId.forEach(value => {
|
||||||
_roleId = value;
|
_groupId = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
let _resourceId = '';
|
let _resourceId = '';
|
||||||
@ -152,10 +152,10 @@ export class PrivilegesComponent implements OnInit {
|
|||||||
_resourceId = `${node.key},${_resourceId}`;
|
_resourceId = `${node.key},${_resourceId}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.query.params.appId == '' || _roleId == '' || _resourceId == '') {
|
if (this.query.params.appId == '' || _groupId == '' || _resourceId == '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.groupPrivilegesService.update({ appId: this.query.params.appId, roleId: _roleId, resourceId: _resourceId }).subscribe(res => {
|
this.groupPrivilegesService.update({ appId: this.query.params.appId, groupId: _groupId, resourceId: _resourceId }).subscribe(res => {
|
||||||
this.query.submitLoading = false;
|
this.query.submitLoading = false;
|
||||||
this.query.tableLoading = false;
|
this.query.tableLoading = false;
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
@ -236,7 +236,7 @@ export class PrivilegesComponent implements OnInit {
|
|||||||
this.onTableAllChecked(false);
|
this.onTableAllChecked(false);
|
||||||
this.updateTableCheckedSet(id, checked);
|
this.updateTableCheckedSet(id, checked);
|
||||||
this.refreshTableCheckedStatus();
|
this.refreshTableCheckedStatus();
|
||||||
this.groupPrivilegesService.getByParams({ appId: this.query.params.appId, roleId: id }).subscribe(res => {
|
this.groupPrivilegesService.getByParams({ appId: this.query.params.appId, groupId: id }).subscribe(res => {
|
||||||
this.treeNodes.checkedKeys = [];
|
this.treeNodes.checkedKeys = [];
|
||||||
for (let i = 0; i < res.data.length; i++) {
|
for (let i = 0; i < res.data.length; i++) {
|
||||||
this.treeNodes.checkedKeys.push(res.data[i].resourceId);
|
this.treeNodes.checkedKeys.push(res.data[i].resourceId);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user