parent
6686a0f171
commit
5742b70a5b
@ -1,6 +1,8 @@ |
||||
import { Routes } from '@angular/router'; |
||||
import {SysAccountComponent} from "./sys-account/sys-account.component"; |
||||
import {SysRoleComponent} from "./sys-role/sys-role.component"; |
||||
|
||||
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(); |
||||
} |
||||
|
||||
} |
@ -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…
Reference in new issue