提交代码

master
胡锐 7 months ago
parent 6686a0f171
commit 5742b70a5b
  1. 4
      src/app/pages/account/account.routes.ts
  2. 46
      src/app/pages/account/sys-role/sys-role.component.html
  3. 33
      src/app/pages/account/sys-role/sys-role.component.less
  4. 23
      src/app/pages/account/sys-role/sys-role.component.spec.ts
  5. 83
      src/app/pages/account/sys-role/sys-role.component.ts
  6. 6
      src/app/pages/body/index/index.component.html
  7. 9
      src/app/pages/body/index/index.component.ts
  8. 2
      src/app/pages/body/tab/tab.component.ts
  9. 5
      src/app/pages/system/menu/menu.component.html
  10. 32
      src/app/pages/system/menu/menu.component.ts
  11. 2
      src/app/servies/menu/menu.service.ts
  12. 57
      src/app/servies/role/role.service.ts

@ -1,6 +1,8 @@
import { Routes } from '@angular/router'; import { Routes } from '@angular/router';
import {SysAccountComponent} from "./sys-account/sys-account.component"; import {SysAccountComponent} from "./sys-account/sys-account.component";
import {SysRoleComponent} from "./sys-role/sys-role.component";
export const ACCOUNT_ROUTES: Routes = [ export const ACCOUNT_ROUTES: Routes = [
{ path: 'sys_account', component: SysAccountComponent} { path: 'sys_account', component: SysAccountComponent},
{ path: 'sys_role', component: SysRoleComponent}
]; ];

@ -0,0 +1,46 @@
<form nz-form [formGroup]="searchForm">
<div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label>角色名称</nz-form-label>
<nz-form-control>
<input nz-input formControlName="roleName" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<div class="search-area">
<button nz-button [nzType]="'primary'">搜索</button>
<button nz-button (click)="resetForm()">重置</button>
</div>
</div>
</div>
</form>
<nz-table #basicTable
[nzShowQuickJumper]="true"
[nzShowTotal]="totalTemplate"
[nzData]="tableData.list" >
<thead>
<tr>
<th>角色名称</th>
<th>角色描述</th>
<th>创建时间</th>
<th>修改时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of basicTable.data">
<td>{{data.roleName}}</td>
<td>{{data.roleStatus}}</td>
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{data.updateTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>
</td>
</tr>
</tbody>
<ng-template #totalTemplate let-total>总计 {{ total }} 条</ng-template>
</nz-table>

@ -0,0 +1,33 @@
.ant-advanced-search-form {
padding: 24px;
background: #fbfbfb;
border: 1px solid #d9d9d9;
border-radius: 6px;
}
.search-result-list {
margin-top: 16px;
border: 1px dashed #e9e9e9;
border-radius: 6px;
background-color: #fafafa;
min-height: 200px;
text-align: center;
padding-top: 80px;
}
[nz-form-label] {
overflow: visible;
}
button {
margin-left: 8px;
}
.collapse {
margin-left: 8px;
font-size: 12px;
}
.search-area {
text-align: right;
}

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SysRoleComponent } from './sys-role.component';
describe('SysRoleComponent', () => {
let component: SysRoleComponent;
let fixture: ComponentFixture<SysRoleComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SysRoleComponent]
})
.compileComponents();
fixture = TestBed.createComponent(SysRoleComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,83 @@
import { Component } from '@angular/core';
import {NzTableComponent, NzTbodyComponent, NzTheadComponent} from "ng-zorro-antd/table";
import {NzDividerComponent} from "ng-zorro-antd/divider";
import {NzFormDirective, NzFormModule} from "ng-zorro-antd/form";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {
FormGroup,
NonNullableFormBuilder,
ReactiveFormsModule,
} from "@angular/forms";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzFlexDirective} from "ng-zorro-antd/flex";
import {DatePipe, NgForOf} from "@angular/common";
import {RoleService} from "../../../servies/role/role.service";
@Component({
selector: 'app-sys-role',
standalone: true,
imports: [
NzTableComponent,
NzTheadComponent,
NzDividerComponent,
NzTbodyComponent,
NzFormDirective,
NzRowDirective,
ReactiveFormsModule,
NzColDirective,
NzButtonComponent,
NzIconDirective,
NzInputDirective,
NzFormModule,
NzFlexDirective,
NgForOf,
DatePipe,
],
templateUrl: './sys-role.component.html',
styleUrl: './sys-role.component.less'
})
export class SysRoleComponent {
// 表单数据
tableData: any = {
total: 0,
list: [],
};
searchForm: FormGroup;
constructor(private fb: NonNullableFormBuilder,
private roleService: RoleService) {
// 初始化搜索框
this.searchForm = this.fb.group({
roleName: [''],
});
this.queryData();
}
/**
*
*/
queryData() {
this.searchForm.value.pageNum = 1;
this.searchForm.value.pageSize = 10;
this.roleService.queryList(this.searchForm.value, (data: any) => {
console.log(data);
this.tableData = data['return_data'];
if (data['return_code'] == '000000') {
}
});
}
/**
*
*/
resetForm(): void {
this.searchForm.reset();
}
}

@ -30,10 +30,10 @@
<!-- start 菜单内容 end--> <!-- start 菜单内容 end-->
<div> <div>
<ul nz-menu nzMode="inline"> <ul nz-menu nzMode="inline">
<li nz-submenu *ngFor="let item of leftMenuData" nzTitle="{{item.menuName}}" nzIcon="{{item.menuUrlImg}}" > <li nz-submenu nzOpen *ngFor="let item of leftMenuData" nzTitle="{{item.menuName}}" nzIcon="{{item.menuUrlImg}}" >
<ul> <ul>
<li nz-menu-item *ngFor="let childMenu of item['childMenuList']"> <li nz-menu-item nzMatchRouter *ngFor="let childMenu of item['childMenuList']">
<a [routerLink]="[item['menuUrl'], childMenu['menuUrl']]" [queryParams]="{title: item['menuName']}">{{childMenu['menuName']}}</a> <a [routerLink]="[item['menuUrl'], childMenu['menuUrl']]" [queryParams]="{title: childMenu['menuName']}">{{childMenu['menuName']}}</a>
</li> </li>
</ul> </ul>
</li> </li>

@ -61,7 +61,8 @@ export class IndexComponent {
// 侧边菜单展示开关 // 侧边菜单展示开关
isCollapse = true; isCollapse = true;
constructor(private storage: BrowserStorageService) { constructor(private storage: BrowserStorageService,
private router: Router) {
this.menuData = this.menuData.concat(this.storage.get(DATA)['menuTree']); this.menuData = this.menuData.concat(this.storage.get(DATA)['menuTree']);
} }
@ -70,7 +71,13 @@ export class IndexComponent {
this.menuData.map((data: any) => { this.menuData.map((data: any) => {
data.selected = data.menuName === item.menuName; data.selected = data.menuName === item.menuName;
}); });
if (item.menuName === '首页') {
// 激活首页路由
this.router.navigateByUrl('/admin/index').finally();
}
this.leftMenuData = item['childMenuList']; this.leftMenuData = item['childMenuList'];
this.isCollapse = item['menuName'] === '首页'; this.isCollapse = item['menuName'] === '首页';
} }
} }

@ -30,13 +30,11 @@ export class TabComponent {
// 监听路由事件,只订阅 ActivationEnd 事件 // 监听路由事件,只订阅 ActivationEnd 事件
this.router.events.pipe(filter(e => e instanceof ActivationEnd)) this.router.events.pipe(filter(e => e instanceof ActivationEnd))
.subscribe((e) => { .subscribe((e) => {
// 这里不强转VS Code编译通不过,有没有大佬有解决方法
const thisEvt = <ActivationEnd>e; const thisEvt = <ActivationEnd>e;
if (thisEvt.snapshot.routeConfig?.loadChildren) { if (thisEvt.snapshot.routeConfig?.loadChildren) {
// 当前激活的路由 // 当前激活的路由
// const activatedRoutePath = thisEvt.snapshot.routeConfig?.path; // const activatedRoutePath = thisEvt.snapshot.routeConfig?.path;
const activatedRoutePath = this.router.url; const activatedRoutePath = this.router.url;
// console.log(activatedRoutePath);
const routeData = thisEvt.snapshot.queryParams; const routeData = thisEvt.snapshot.queryParams;
let menuTitle = '新标签页'; let menuTitle = '新标签页';
if(routeData) { if(routeData) {

@ -2,9 +2,10 @@
<div nz-col nzSpan="12"> <div nz-col nzSpan="12">
<nz-card nzTitle="系统菜单"> <nz-card nzTitle="系统菜单">
<nz-spin [nzSpinning]="!treeView"></nz-spin>
<nz-tree <nz-tree
#nzTreeComponent #nzTreeComponent
*ngIf="menuTree.length > 0" *ngIf="menuTree.length > 0 && treeView"
[nzData]="menuTree" [nzData]="menuTree"
[nzShowLine]="true" [nzShowLine]="true"
[nzExpandAll]="true" [nzExpandAll]="true"
@ -25,7 +26,7 @@
<nz-descriptions-item nzTitle="菜单名称">{{menuDetail.menuName?menuDetail.menuName:'无'}}</nz-descriptions-item> <nz-descriptions-item nzTitle="菜单名称">{{menuDetail.menuName?menuDetail.menuName:'无'}}</nz-descriptions-item>
<nz-descriptions-item nzTitle="菜单类型">{{menuDetail.menuType| menuType}}</nz-descriptions-item> <nz-descriptions-item nzTitle="菜单类型">{{menuDetail.menuType| menuType}}</nz-descriptions-item>
<nz-descriptions-item nzTitle="菜单URL">{{menuDetail.menuUrl?menuDetail.menuUrl:'无'}}</nz-descriptions-item> <nz-descriptions-item nzTitle="菜单URL">{{menuDetail.menuUrl?menuDetail.menuUrl:'无'}}</nz-descriptions-item>
<nz-descriptions-item nzTitle="菜单图标">{{menuDetail.name?menuDetail.name:'无'}}</nz-descriptions-item> <nz-descriptions-item nzTitle="菜单图标">{{menuDetail.menuUrlImg?menuDetail.menuUrlImg:'无'}}</nz-descriptions-item>
<nz-descriptions-item nzTitle="菜单描述">{{menuDetail.menuDesc?menuDetail.menuDesc:'无'}}</nz-descriptions-item> <nz-descriptions-item nzTitle="菜单描述">{{menuDetail.menuDesc?menuDetail.menuDesc:'无'}}</nz-descriptions-item>
</nz-descriptions> </nz-descriptions>
</nz-card> </nz-card>

@ -1,5 +1,5 @@
import {Component, ViewChild} from '@angular/core'; import {ChangeDetectorRef, Component, ViewChild} from '@angular/core';
import {NzTreeComponent} from "ng-zorro-antd/tree"; import {NzFormatEmitEvent, NzTreeComponent, NzTreeNode, NzTreeService} from "ng-zorro-antd/tree";
import {NgForOf, NgIf} from "@angular/common"; import {NgForOf, NgIf} from "@angular/common";
import {NzIconDirective} from "ng-zorro-antd/icon"; import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzDropdownMenuComponent} from "ng-zorro-antd/dropdown"; import {NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
@ -23,7 +23,7 @@ import {NzFlexDirective} from "ng-zorro-antd/flex";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {NzInputNumberComponent} from "ng-zorro-antd/input-number"; import {NzInputNumberComponent} from "ng-zorro-antd/input-number";
import {NzMessageService} from "ng-zorro-antd/message"; import {NzMessageService} from "ng-zorro-antd/message";
import {NzTreeNode} from "ng-zorro-antd/core/tree/nz-tree-base-node"; import {NzSpinComponent} from "ng-zorro-antd/spin";
@Component({ @Component({
selector: 'app-menu', selector: 'app-menu',
@ -55,7 +55,8 @@ import {NzTreeNode} from "ng-zorro-antd/core/tree/nz-tree-base-node";
NzSelectComponent, NzSelectComponent,
NzOptionComponent, NzOptionComponent,
NgForOf, NgForOf,
NzInputNumberComponent NzInputNumberComponent,
NzSpinComponent
], ],
templateUrl: './menu.component.html', templateUrl: './menu.component.html',
styleUrl: './menu.component.less' styleUrl: './menu.component.less'
@ -64,7 +65,7 @@ export class MenuComponent {
// 菜单数据 // 菜单数据
menuData: any = []; menuData: any = [];
// 菜单树形数据 // 菜单树形数据
menuTree: any = []; menuTree: any[] = [];
// 菜单详情 // 菜单详情
menuDetail: any = {}; menuDetail: any = {};
// 编辑菜单弹出框 // 编辑菜单弹出框
@ -73,7 +74,9 @@ export class MenuComponent {
editMenuForm: FormGroup; editMenuForm: FormGroup;
// 编辑菜单标题 // 编辑菜单标题
editMenuTitle = ''; editMenuTitle = '';
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent; // 树视图展示状态
treeView= false;
constructor(private menuService: MenuService, constructor(private menuService: MenuService,
private fb: NonNullableFormBuilder, private fb: NonNullableFormBuilder,
private modal: NzModalService, private modal: NzModalService,
@ -98,6 +101,7 @@ export class MenuComponent {
queryMenuTree() { queryMenuTree() {
this.menuService.queryRoleMenuTreeCustomized('', (data: any) => { this.menuService.queryRoleMenuTreeCustomized('', (data: any) => {
this.menuTree = data['return_data']; this.menuTree = data['return_data'];
this.treeView = true;
this.queryMenuData(); this.queryMenuData();
}); });
} }
@ -124,7 +128,6 @@ export class MenuComponent {
menuObj['parentMenu'] = this.menuData.find((o: any) => o.id == menuObj.menuPSid); menuObj['parentMenu'] = this.menuData.find((o: any) => o.id == menuObj.menuPSid);
} }
this.menuDetail = menuObj; this.menuDetail = menuObj;
console.log(this.menuDetail);
} }
} }
@ -141,6 +144,14 @@ export class MenuComponent {
menuType: '1' menuType: '1'
}; };
if (edit == false && this.menuDetail?.id == null) {
this.modal.confirm({
nzTitle: '提示',
nzContent: '请点击需要修改的菜单',
});
return;
}
if (this.menuDetail != null) { if (this.menuDetail != null) {
if (edit) { if (edit) {
// 增加 // 增加
@ -165,6 +176,7 @@ export class MenuComponent {
*/ */
submitEditMenuForm() { submitEditMenuForm() {
if (this.editMenuForm.valid) { if (this.editMenuForm.valid) {
this.treeView = false;
this.menuService.editMenu(this.editMenuForm.value, (data: any) => { this.menuService.editMenu(this.editMenuForm.value, (data: any) => {
if (data['return_code'] == '000000') { if (data['return_code'] == '000000') {
// 刷新数据 // 刷新数据
@ -213,14 +225,14 @@ export class MenuComponent {
const param = { const param = {
menuId: this.menuDetail.id menuId: this.menuDetail.id
} }
this.treeView = false;
this.menuService.delMenu(param, (data: any) => { this.menuService.delMenu(param, (data: any) => {
if (data['return_code'] == '000000') { if (data['return_code'] == '000000') {
// 刷新数据 // 刷新数据
const s = this.nzTreeComponent.getTreeNodeByKey(""+this.menuDetail.menuPSid) this.queryMenuTree();
this.message.create('success', '操作成功'); this.message.create('success', '操作成功');
} else { } else {
this.treeView = true;
this.message.create('error', data['return_msg']); this.message.create('error', data['return_msg']);
} }
}); });

@ -39,7 +39,7 @@ export class MenuService {
* @param callBack * @param callBack
*/ */
public queryMenuList(callBack:any) { public queryMenuList(callBack:any) {
this.http.get(environment.baseUrl + 'secMenu/queryMenuList').subscribe(data => { this.http.post(environment.baseUrl + 'secMenu/queryMenuList', null).subscribe(data => {
callBack(data); callBack(data);
}); });
} }

@ -0,0 +1,57 @@
import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {environment} from "../../../environments/environment";
import {ObjectData} from "../../utils/objectData.service";
@Injectable({
providedIn: 'root'
})
export class RoleService {
constructor(private http: HttpClient) { }
/**
*
* @param params
* @param callBack
*/
public editRole(params: object, callBack:any) {
this.http.post(environment.baseUrl + 'secRole/editRole', params).subscribe(data => {
callBack(data);
});
}
/**
*
* @param params
* @param callBack
*/
public delRole(params: object, callBack:any) {
this.http.post(environment.baseUrl + 'secRole/delRole', params).subscribe(data => {
callBack(data);
});
}
/**
*
* @param roleId
* @param callBack
*/
public queryDetail(roleId: number, callBack:any) {
this.http.get(environment.baseUrl + 'secRole/queryDetail?roleId='+roleId).subscribe(data => {
callBack(data);
});
}
/**
*
* @param params
* @param callBack
*/
public queryList(params: object, callBack:any) {
this.http.get(environment.baseUrl + 'secRole/queryList?'+ObjectData.objectByString(params)).subscribe(data => {
callBack(data);
});
}
}
Loading…
Cancel
Save