This commit is contained in:
Taric Xin
2022-01-24 19:58:38 +08:00
9 changed files with 145 additions and 216 deletions

View File

@ -41,7 +41,8 @@ const APPINIT_PROVIDES = [
deps: [StartupService],
multi: true
},
{ provide: DEFAULT_CURRENCY_CODE, useValue: '¥' }
{ provide: DEFAULT_CURRENCY_CODE, useValue: '¥' },
AuthGuard
];
// #endregion
@ -53,6 +54,7 @@ import { RoutesModule } from './routes/routes.module';
import { SharedModule } from './shared/shared.module';
import { STWidgetModule } from './shared/widget/st-widget.module';
import { registerLocaleData } from '@angular/common';
import { AuthGuard } from './core/guards/auth.guard';
@NgModule({
declarations: [AppComponent],

View File

@ -13,43 +13,39 @@ import {
import { sysConf } from '@conf/sys.conf';
import { CoreService } from '@core';
import { ACLGuard, ACLService } from '@delon/acl';
import { EAUserService } from '@shared';
import { MenuService } from '@delon/theme';
import { BaseService, EAUserService } from '@shared';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
const auths = ['YUNLI-CART-SEARCH', 'YUNLI-CART-DAOCHU', 'YUNLI-CART-DETAIL'];
const auths = ['YUNLI-CART-SEARCH', 'YUNLI-CART-DAOC1HU', 'YUNLI-CART-DETAIL', 'YUNLI-CART-AUDIT-SEARCH'];
@Injectable()
export class AuthGuard implements CanActivate, CanActivateChild, CanLoad {
constructor(srv: ACLService, router: Router, private eaUserSrv: CoreService, private router2: Router, private inject: Injector) {}
constructor(private srv: ACLService, router: Router, private baseService: BaseService, private menuService: MenuService) {}
canLoad(route: Route, segments: UrlSegment[]): boolean | UrlTree | Observable<boolean | UrlTree> | Promise<boolean | UrlTree> {
console.log(route);
throw true;
return true;
}
canActivate(route: ActivatedRouteSnapshot, _state: RouterStateSnapshot | null): Observable<boolean> {
const canOpen = this.eaUserSrv.loginStatus;
if (!canOpen) {
this.router2.navigate([sysConf.login_url], {
queryParams: {
returnUrl: _state?.url
}
});
return of(!canOpen);
}
return of(true);
return this.handle();
}
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
const canOpen = this.eaUserSrv.loginStatus;
if (!canOpen) {
this.router2.navigate([sysConf.login_url], {
queryParams: {
returnUrl: state?.url
return this.handle();
}
});
return of(!canOpen);
}
return of(true);
private handle(): Observable<boolean> {
// 1
return this.baseService.request('/api/mdc/cuc/user/getUserDetail').pipe(
map(_ => {
console.log(this.srv.data);
this.srv.setAbility(auths);
this.menuService.resume();
console.log(this.srv.data);
return true;
})
);
}
}

View File

@ -19,7 +19,8 @@ const alainConfig: AlainConfig = {
},
sf: { button: { search: '查询' } },
pageHeader: { homeI18n: 'home', recursiveBreadcrumb: true },
auth: { login_url: '/dashboard' }
auth: { login_url: '/passport/login' },
acl: { guard_url: '/' }
};
const alainModules = [AlainThemeModule.forRoot(), DelonACLModule.forRoot()];

View File

@ -1,31 +0,0 @@
/*
* @Author: your name
* @Date: 2021-12-07 17:30:18
* @LastEditTime: 2021-12-09 17:47:33
* @LastEditors: your name
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath: \tms-obc-web\src\app\routes\vehicle\components\list\img-view\img-view.component.spec.ts
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { VehicleImgViewComponent } from './img-view.component';
describe('VehicleImgViewComponent', () => {
let component: VehicleImgViewComponent;
let fixture: ComponentFixture<VehicleImgViewComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [VehicleImgViewComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(VehicleImgViewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -12,55 +12,33 @@
<!-- 搜索区 -->
<!-- 搜索表单 -->
<div nz-row nzGutter="8">
<!-- 查询字段小于或等于3个时不显示伸缩按钮 -->
<div nz-col nzSpan="24" *ngIf="queryFieldCount <= 4">
<sf
#sf
[schema]="schema"
[ui]="ui"
[mode]="'search'"
[disabled]="!sf?.valid"
(formSubmit)="st?.load(1)"
(formReset)="resetSF()"
></sf>
</div>
<!-- [loading]="service.http.loading" -->
<!-- 查询字段大于3个时根据展开状态调整布局 -->
<ng-container *ngIf="queryFieldCount > 4">
<div nz-col [nzSpan]="_$expand ? 24 : 18">
<sf #sf [schema]="schema" [ui]="ui" [compact]="true" [button]="'none'"></sf>
</div>
<div nz-col [nzSpan]="_$expand ? 24 : 6" class="text-right">
<button nz-button nzType="primary" [nzLoading]="service.http.loading" (click)="st?.load(1)">查询</button>
<button nz-button nzType="primary" [disabled]="service.http.loading" (click)="exportFire()">导出</button>
<button nz-button nzType="primary" [disabled]="service.http.loading" (click)="exportFire()" acl
[acl-ability]="'YUNLI-CART-DAOCHU'">导出</button>
<button nz-button [disabled]="service.http.loading" (click)="resetSF()">重置</button>
<button nz-button nzType="link" (click)="expandToggle()">
{{ !_$expand ? '展开' : '收起' }}
<i nz-icon [nzType]="!_$expand ? 'down' : 'up'"></i>
</button>
</div>
</ng-container>
</div>
</nz-card>
<nz-card>
<!-- 数据列表 -->
<!-- [data]="service.$api_get_supplier_page" -->
<st
#st
[bordered]="true"
[scroll]="{ x: '1200px' }"
[columns]="columns"
[data]='service.$api_get_operate_list'
<st #st [bordered]="true" [scroll]="{ x: '1200px' }" [columns]="columns" [data]='service.$api_get_operate_list'
[req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }"
[res]="{ reName: { list: 'data.records', total: 'data.total' }, process: dataProcess }"
[page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }"
[loading]="service.http.loading"
>
[loading]="service.http.loading">
<ng-template st-row="carLength" let-item let-index="index">
<div>{{item?.carModelLabel }}-{{item?.carLengthLabel? item?.carLengthLabel + '米' : ''}}-{{ item?.carLoad? item?.carLoad + '吨' : ''}}</div>
<div>{{item?.carModelLabel }}-{{item?.carLengthLabel? item?.carLengthLabel + '米' : ''}}-{{ item?.carLoad?
item?.carLoad + '吨' : ''}}</div>
</ng-template>
<ng-template st-row="isSelf" let-item let-index="index">
<div>

View File

@ -1,31 +0,0 @@
/*
* @Author: your name
* @Date: 2021-12-01 20:05:59
* @LastEditTime: 2021-12-01 20:35:33
* @LastEditors: your name
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath: \tms-obc-web\src\app\routes\vehicle\components\list\list.component.spec.ts
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { VehicleComponentsListComponent } from './list.component';
describe('VehicleComponentsListComponent', () => {
let component: VehicleComponentsListComponent;
let fixture: ComponentFixture<VehicleComponentsListComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [VehicleComponentsListComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(VehicleComponentsListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -9,11 +9,10 @@ import { map } from 'rxjs/operators';
import { VehicleService } from '../../../vehicle/services/vehicle.service';
@Component({
selector: 'app-Vehicle-components-list',
templateUrl: './list.component.html',
templateUrl: './list.component.html'
})
export class VehicleComponentsListComponent implements OnInit {
_$expand = false;
url = `/rule?_allow_anonymous=true`;
ui!: SFUISchema;
schema!: SFSchema;
@ -22,19 +21,13 @@ export class VehicleComponentsListComponent implements OnInit {
@ViewChild('sf', { static: false }) sf!: SFComponent;
constructor(public service: VehicleService, private modal: NzModalService, private router: Router, private ar: ActivatedRoute) {}
/**
* 查询字段个数navigate
*/
get queryFieldCount(): number {
return Object.keys(this.schema?.properties || {}).length;
}
/**
* 查询参数
*/
get reqParams() {
const params: any = {
...(this.sf && this.sf.value),
...(this.sf && this.sf.value)
};
if (this.sf?.value.effectiveDate) {
params.effectiveDateStart = this.sf?.value.effectiveDate[0];
@ -45,14 +38,10 @@ export class VehicleComponentsListComponent implements OnInit {
return params;
}
get selectedRows() {
return this.st?.list.filter((item) => item.checked) || [];
}
ngOnInit() {
this.initSF();
this.initST();
this.ar.url.subscribe((params) => {
this.ar.url.subscribe(params => {
this.st?.load(1);
});
}
@ -68,8 +57,8 @@ export class VehicleComponentsListComponent implements OnInit {
expand: {
type: 'boolean',
ui: {
hidden: true,
},
hidden: true
}
},
carNo: {
title: '车牌号',
@ -91,9 +80,6 @@ export class VehicleComponentsListComponent implements OnInit {
} else {
return of([]);
}
},
visibleIf: {
_$expand: (value: boolean) => value
}
} as SFSelectWidgetSchema
},
@ -103,20 +89,20 @@ export class VehicleComponentsListComponent implements OnInit {
ui: {
widget: 'dict-select',
containsAllLable: true,
params: { dictKey: 'car:color' },
},
params: { dictKey: 'car:color' }
}
},
carStatus: {
title: '运营状态',
type: 'string',
enum: [
{ label: '空闲', value: 0 },
{ label: '运输中', value: 1 },
{ label: '运输中', value: 1 }
],
ui: {
allowClear: true,
widget: 'select',
},
widget: 'select'
}
},
carModel: {
title: '车型',
@ -126,9 +112,9 @@ export class VehicleComponentsListComponent implements OnInit {
params: { dictKey: 'car:model' },
containsAllLable: true,
visibleIf: {
expand: (value: boolean) => value,
},
},
expand: (value: boolean) => value
}
}
},
carLength: {
title: '车长',
@ -138,24 +124,24 @@ export class VehicleComponentsListComponent implements OnInit {
params: { dictKey: 'car:length' },
containsAllLable: true,
visibleIf: {
expand: (value: boolean) => value,
},
},
expand: (value: boolean) => value
}
}
},
isSelf: {
type: 'string',
title: '是否挂靠',
enum: [
{ label: '是', value: 1 },
{ label: '否', value: 0 },
{ label: '否', value: 0 }
],
ui: {
widget: 'select',
allowClear: true,
visibleIf: {
expand: (value: boolean) => value,
},
},
expand: (value: boolean) => value
}
}
},
driverLicenseStatus: {
type: 'string',
@ -163,16 +149,16 @@ export class VehicleComponentsListComponent implements OnInit {
enum: [
{ label: '正常', value: 1 },
{ label: '即将到期', value: 2 },
{ label: '已到期', value: 3},
{ label: '已到期', value: 3 }
],
default: '',
ui: {
widget: 'select',
allowClear: true,
visibleIf: {
expand: (value: boolean) => value,
},
},
expand: (value: boolean) => value
}
}
},
roadTransportStatus: {
type: 'string',
@ -180,16 +166,16 @@ export class VehicleComponentsListComponent implements OnInit {
enum: [
{ label: '正常', value: 1 },
{ label: '即将到期', value: 2 },
{ label: '已到期', value: 3},
{ label: '已到期', value: 3 }
],
ui: {
widget: 'select',
allowClear: true,
visibleIf: {
expand: (value: boolean) => value,
},
},
},
expand: (value: boolean) => value
}
}
}
// putOnRecord: {
// type: 'string',
// title: '是否已备案',
@ -204,7 +190,7 @@ export class VehicleComponentsListComponent implements OnInit {
// },
// },
// },
},
}
};
this.ui = { '*': { spanLabelFixed: 130, grid: { span: 8, gutter: 4 }, enter: () => this.st.load() } };
}
@ -215,12 +201,16 @@ export class VehicleComponentsListComponent implements OnInit {
{ title: '车牌号', width: '150px', className: 'text-center', index: 'carNo' },
{ title: '车牌颜色', width: '150px', className: 'text-center', index: 'carNoColorLabel' },
{ title: '车型-车长-载重', width: '150px', className: 'text-center', render: 'carLength' },
{ title: '运营状态',width:'150px', className: 'text-center', index: 'carStatus',
{
title: '运营状态',
width: '150px',
className: 'text-center',
index: 'carStatus',
type: 'badge',
badge: {
true: { text: '运输中', color: 'success' },
false: { text: '空闲', color: 'default' },
},
false: { text: '空闲', color: 'default' }
}
},
{
title: '行驶证到期状态',
@ -231,8 +221,8 @@ export class VehicleComponentsListComponent implements OnInit {
badge: {
1: { text: '正常', color: 'success' },
2: { text: '即将到期', color: 'warning' },
3: { text: '已到期', color: 'error' },
},
3: { text: '已到期', color: 'error' }
}
},
{
title: '道运证到期状态',
@ -243,11 +233,11 @@ export class VehicleComponentsListComponent implements OnInit {
badge: {
1: { text: '正常', color: 'success' },
2: { text: '即将到期', color: 'warning' },
3: { text: '已到期', color: 'error' },
},
3: { text: '已到期', color: 'error' }
}
},
{ title: '所有人', width: '150px', className: 'text-center', index: 'carOwner' },
{ title: '是否挂靠', width:'150px', className: 'text-center', render: 'isSelf', },
{ title: '是否挂靠', width: '150px', className: 'text-center', render: 'isSelf' },
{ title: '挂靠协议', width: '150px', className: 'text-center', render: 'approvalAuditStatus' },
// { title: '是否已备案', className: 'text-center', render: 'putOnRecord', },
@ -259,20 +249,20 @@ export class VehicleComponentsListComponent implements OnInit {
buttons: [
{
text: '查看',
click: (item) => {
acl: 'SUPPLY-INDEX-bulkSearch',
click: item => {
this.router.navigate(['./detail', item.id], { relativeTo: this.ar, queryParams: { carId: item.carId } });
// this.router.navigate(['./view', item.id], { relativeTo: this.ar, queryParams: { tenantId: item.tenantId } });
},
},
}
}
// {
// text: '申请备案',
// click: (item) => {
// },
// },
],
},
]
}
];
}
expandToggle() {
@ -280,7 +270,7 @@ export class VehicleComponentsListComponent implements OnInit {
this.sf?.setValue('/expand', this._$expand);
}
creat() {
this.router.navigate(['./new',], { relativeTo: this.ar });
this.router.navigate(['./new'], { relativeTo: this.ar });
}
/**
* 重置表单

View File

@ -8,23 +8,42 @@
*/
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { ACLGuard, ACLGuardType } from '@delon/acl';
import { AuthGuard } from 'src/app/core/guards/auth.guard';
import { VehicleComponentsAuditComponent } from './components/audit/audit.component';
import { VehicleComponentsAuditDetailComponent } from './components/audit/detail/detail.component';
import { VehicleComponentsListDetailComponent } from './components/list/detail/detail.component';
import { VehicleComponentsListComponent } from './components/list/list.component';
const routes: Routes = [
{ path: 'list', component: VehicleComponentsListComponent },
{ path: 'list/detail/:id', component: VehicleComponentsListDetailComponent },
{ path: 'audit', component: VehicleComponentsAuditComponent },
{ path: 'audit/detail/:id', component: VehicleComponentsAuditDetailComponent },
{
path: '',
canLoad: [AuthGuard],
canActivate: [AuthGuard],
canActivateChild: [AuthGuard],
children: [
{
path: 'list',
component: VehicleComponentsListComponent,
data: { guard: { ability: ['YUNLI-CART-SEARCH'] } as ACLGuardType }
},
{
path: 'list/detail/:id',
component: VehicleComponentsListDetailComponent,
data: { guard: { ability: ['YUNLI-CART-DETAIL'] } as ACLGuardType }
},
{
path: 'audit',
component: VehicleComponentsAuditComponent,
data: { guard: { ability: ['YUNLI-CART--AUDIT-SEARCH1'] } as ACLGuardType }
},
{ path: 'audit/detail/:id', component: VehicleComponentsAuditDetailComponent }
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
exports: [RouterModule]
})
export class VehicleRoutingModule {}

View File

@ -103,7 +103,12 @@
},
{
"text": "车辆审核列表",
"link": "/vehicle/audit"
"link": "/vehicle/audit",
"acl": {
"ability": [
"YUNLI-CART-AUDIT-SEARCH"
]
}
},
{
"hide": true,