diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 73af1c10..32f1b6a4 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -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], diff --git a/src/app/core/guards/auth.guard.ts b/src/app/core/guards/auth.guard.ts index dc51f81d..47b7dcca 100644 --- a/src/app/core/guards/auth.guard.ts +++ b/src/app/core/guards/auth.guard.ts @@ -1,55 +1,51 @@ import { Inject, Injectable, Injector } from '@angular/core'; -import { - ActivatedRouteSnapshot, - CanActivate, - CanActivateChild, - CanLoad, - Route, - Router, - RouterStateSnapshot, - UrlSegment, - UrlTree -} from '@angular/router'; -import { sysConf } from '@conf/sys.conf'; -import { CoreService } from '@core'; +import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router'; 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) {} - canLoad(route: Route, segments: UrlSegment[]): boolean | UrlTree | Observable | Promise { - console.log(route); - - throw true; - } +export class AuthGuard implements CanActivate, CanActivateChild { + constructor(private srv: ACLService, private baseService: BaseService, private menuService: MenuService) {} canActivate(route: ActivatedRouteSnapshot, _state: RouterStateSnapshot | null): Observable { - const canOpen = this.eaUserSrv.loginStatus; - if (!canOpen) { - this.router2.navigate([sysConf.login_url], { - queryParams: { - returnUrl: _state?.url - } - }); - return of(!canOpen); + if (Object.keys(route.params)?.length > 0 || !route.routeConfig?.path) { + return this.handle(); + } else { + return this.handle(_state?.url); } - return of(true); } canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { - const canOpen = this.eaUserSrv.loginStatus; - if (!canOpen) { - this.router2.navigate([sysConf.login_url], { - queryParams: { - returnUrl: state?.url - } - }); - return of(!canOpen); + return this.handle(this.settingRoute(childRoute.params, state.url)); + } + + private handle(route?: string): Observable { + if (!route) { + return of(true); } - return of(true); + console.log(route); + + return this.baseService.request('/api/mdc/cuc/functionButton/getPermissionsCodeoByLink', { link: route }).pipe( + map(_ => { + this.srv.setAbility(auths); + this.menuService.resume(); + return true; + }) + ); + } + + private settingRoute(params: any, route: string) { + let _route = route; + for (const key of Object.keys(params)) { + if (_route.indexOf(params[key]) > -1) { + _route = _route.replace(params[key], ':id'); + } + } + return _route; } } diff --git a/src/app/global-config.module.ts b/src/app/global-config.module.ts index 6a0c819d..6db7bd50 100644 --- a/src/app/global-config.module.ts +++ b/src/app/global-config.module.ts @@ -11,10 +11,16 @@ import { environment } from '@env/environment'; // #region NG-ALAIN Config const alainConfig: AlainConfig = { - st: { modal: { size: 'lg' } }, + st: { + req: { method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' } }, + res: { reName: { list: 'data.records', total: 'data.total' } }, + page: { show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }, + modal: { size: 'lg' } + }, 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()]; diff --git a/src/app/routes/contract-management/components/contract-list/contract-list.component.html b/src/app/routes/contract-management/components/contract-list/contract-list.component.html index 939ea0b3..71189454 100644 --- a/src/app/routes/contract-management/components/contract-list/contract-list.component.html +++ b/src/app/routes/contract-management/components/contract-list/contract-list.component.html @@ -13,16 +13,8 @@
- +
@@ -37,7 +29,8 @@
- + + + +
- - - - -
- -
-
- - - - -
-
- + [loading]="service.http.loading"> -
{{item?.carModelLabel }}-{{item?.carLengthLabel? item?.carLengthLabel + '米' : ''}}-{{ item?.carLoad? item?.carLoad + '吨' : ''}}
+
{{item?.carModelLabel }}-{{item?.carLengthLabel? item?.carLengthLabel + '米' : ''}}-{{ item?.carLoad? + item?.carLoad + '吨' : ''}}
-
- {{ item?.isSelf ? '是' : '否' }} +
+ {{ item?.isSelf ? '是' : '否' }}
-
- {{ item?.putOnRecord ? '是' : '否' }} +
+ {{ item?.putOnRecord ? '是' : '否' }}
@@ -89,4 +67,4 @@ 正常 - + \ No newline at end of file diff --git a/src/app/routes/vehicle/components/list/list.component.spec.ts b/src/app/routes/vehicle/components/list/list.component.spec.ts deleted file mode 100644 index e815b19d..00000000 --- a/src/app/routes/vehicle/components/list/list.component.spec.ts +++ /dev/null @@ -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; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [VehicleComponentsListComponent], - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(VehicleComponentsListComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/routes/vehicle/components/list/list.component.ts b/src/app/routes/vehicle/components/list/list.component.ts index 61641d78..f6e84cab 100644 --- a/src/app/routes/vehicle/components/list/list.component.ts +++ b/src/app/routes/vehicle/components/list/list.component.ts @@ -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,36 +112,36 @@ export class VehicleComponentsListComponent implements OnInit { params: { dictKey: 'car:model' }, containsAllLable: true, visibleIf: { - expand: (value: boolean) => value, - }, - }, + expand: (value: boolean) => value + } + } }, carLength: { title: '车长', type: 'string', - ui: { + ui: { widget: 'dict-select', 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() } }; } @@ -212,43 +198,47 @@ export class VehicleComponentsListComponent implements OnInit { initST() { this.columns = [ // { title: '', type: 'checkbox', className: 'text-center' }, - { 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', - type: 'badge', - badge: { - true: { text: '运输中', color: 'success' }, - false: { text: '空闲', color: 'default' }, + { 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', + type: 'badge', + badge: { + true: { text: '运输中', color: 'success' }, + false: { text: '空闲', color: 'default' } + } }, - }, { title: '行驶证到期状态', - width:'180px', + width: '180px', className: 'text-center', index: 'driverLicenseStatus', type: 'badge', badge: { 1: { text: '正常', color: 'success' }, 2: { text: '即将到期', color: 'warning' }, - 3: { text: '已到期', color: 'error' }, - }, + 3: { text: '已到期', color: 'error' } + } }, { title: '道运证到期状态', - width:'180px', + width: '180px', className: 'text-center', index: 'roadTransportStatus', type: 'badge', 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: 'approvalAuditStatus' }, + { title: '所有人', width: '150px', className: 'text-center', index: 'carOwner' }, + { 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,19 @@ export class VehicleComponentsListComponent implements OnInit { buttons: [ { text: '查看', - click: (item) => { - this.router.navigate(['./detail', item.id], { relativeTo: this.ar,queryParams: { carId: item.carId } }); + 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 +269,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 }); } /** * 重置表单 @@ -291,6 +280,6 @@ export class VehicleComponentsListComponent implements OnInit { } // 导出 exportFire() { - this.service.downloadFile(this.service.$api_carLicense_export, this.reqParams ); + this.service.downloadFile(this.service.$api_carLicense_export, this.reqParams); } } diff --git a/src/app/routes/vehicle/vehicle-routing.module.ts b/src/app/routes/vehicle/vehicle-routing.module.ts index fa066cf2..3dbb76af 100644 --- a/src/app/routes/vehicle/vehicle-routing.module.ts +++ b/src/app/routes/vehicle/vehicle-routing.module.ts @@ -8,23 +8,41 @@ */ 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: '', + 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 {} diff --git a/src/app/shared/components/dynamic-setting/dynamic-setting-h5/dynamic-setting-h5.component.html b/src/app/shared/components/dynamic-setting/dynamic-setting-h5/dynamic-setting-h5.component.html index f9144846..91696c31 100644 --- a/src/app/shared/components/dynamic-setting/dynamic-setting-h5/dynamic-setting-h5.component.html +++ b/src/app/shared/components/dynamic-setting/dynamic-setting-h5/dynamic-setting-h5.component.html @@ -14,6 +14,9 @@

{{selectedTab?.name}}

+ @@ -37,36 +40,30 @@
- - +
+
+ +
+ + + + + + + + +
-
diff --git a/src/app/shared/components/dynamic-setting/dynamic-setting-h5/dynamic-setting-h5.component.ts b/src/app/shared/components/dynamic-setting/dynamic-setting-h5/dynamic-setting-h5.component.ts index 9043ffb4..fde89615 100644 --- a/src/app/shared/components/dynamic-setting/dynamic-setting-h5/dynamic-setting-h5.component.ts +++ b/src/app/shared/components/dynamic-setting/dynamic-setting-h5/dynamic-setting-h5.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, EventEmitter, Input, Output } from '@angular/core'; import { BaseService } from '@shared'; -const JSONTYPE = new Set([5]); +const JSONTYPE = new Set([5,6]); @Component({ selector: 'app-dynamic-setting-h5', templateUrl: './dynamic-setting-h5.component.html', diff --git a/src/app/shared/components/dynamic-setting/dynamic-setting.module.ts b/src/app/shared/components/dynamic-setting/dynamic-setting.module.ts index cddc9b6d..7154dc0e 100644 --- a/src/app/shared/components/dynamic-setting/dynamic-setting.module.ts +++ b/src/app/shared/components/dynamic-setting/dynamic-setting.module.ts @@ -5,10 +5,11 @@ import { SHARED_ZORRO_MODULES } from '../../shared-zorro.module'; import { SHARED_DELON_MODULES } from '../../shared-delon.module'; import { FormsModule } from '@angular/forms'; import { DynamicSettingModalComponent } from './dynamic-setting-modal/dynamic-setting-modal.component'; - +import { FreightTableComponent } from './freight-table/freight-table.component'; +const COMPONENTS = [DynamicSettingH5Component, DynamicSettingModalComponent, FreightTableComponent]; @NgModule({ - declarations: [DynamicSettingH5Component, DynamicSettingModalComponent], + declarations: [...COMPONENTS], imports: [CommonModule, FormsModule, SHARED_ZORRO_MODULES, SHARED_DELON_MODULES], - exports: [DynamicSettingH5Component] + exports: [...COMPONENTS] }) export class DynamicSettingModule {} diff --git a/src/app/shared/components/dynamic-setting/freight-table/freight-table.component.html b/src/app/shared/components/dynamic-setting/freight-table/freight-table.component.html new file mode 100644 index 00000000..e14c7991 --- /dev/null +++ b/src/app/shared/components/dynamic-setting/freight-table/freight-table.component.html @@ -0,0 +1,22 @@ + + + + 公里数 + 计算方式 + 车长(米) + 操作 + + + + + + + {{ item.startKm }} - {{ item.endKm }} + {{ item.computeMode }} + 最高{{ node.maxPrice }} 预警{{ + node.ewPrice }} + 删除 + + + \ No newline at end of file diff --git a/src/app/shared/components/dynamic-setting/freight-table/freight-table.component.less b/src/app/shared/components/dynamic-setting/freight-table/freight-table.component.less new file mode 100644 index 00000000..e69de29b diff --git a/src/app/shared/components/dynamic-setting/freight-table/freight-table.component.ts b/src/app/shared/components/dynamic-setting/freight-table/freight-table.component.ts new file mode 100644 index 00000000..2ed7b501 --- /dev/null +++ b/src/app/shared/components/dynamic-setting/freight-table/freight-table.component.ts @@ -0,0 +1,38 @@ +import { Component, OnInit } from '@angular/core'; +import { BaseService } from '@shared'; + +@Component({ + selector: 'app-freight-table', + templateUrl: './freight-table.component.html', + styleUrls: ['./freight-table.component.less'] +}) +export class FreightTableComponent implements OnInit { + data: any[] = []; + headers: any[] = []; + constructor(public service: BaseService) {} + + ngOnInit(): void { + this.loadHeaders(); + this.loadData(); + } + + loadHeaders() { + this.service.request('/api/mdc/cuc/freightConfigItem/list').subscribe(res => { + if (res) { + this.headers = res; + } + }); + } + + loadData() { + this.service.request('/api/mdc/cuc/freightConfig/list').subscribe(res => { + if (res) { + this.data = res; + } + }); + } + + changeEndLength(event: any, i: number) { + console.log(event, i); + } +} diff --git a/src/assets/mocks/menu-data.json b/src/assets/mocks/menu-data.json index 24ec1160..af8f9dab 100644 --- a/src/assets/mocks/menu-data.json +++ b/src/assets/mocks/menu-data.json @@ -103,7 +103,12 @@ }, { "text": "车辆审核列表", - "link": "/vehicle/audit" + "link": "/vehicle/audit", + "acl": { + "ability": [ + "YUNLI-CART-AUDIT-SEARCH" + ] + } }, { "hide": true,