From 3539bd2a079e47e14a792aec1af4f90673ba9b30 Mon Sep 17 00:00:00 2001 From: TaricXin <583259872@qq.com> Date: Tue, 15 Mar 2022 17:32:24 +0800 Subject: [PATCH] edit --- src/app/global-config.module.ts | 9 ++- .../dashboard/dashboard.component.html | 13 ++++ .../dashboard/dashboard.component.less | 0 .../dashboard/dashboard.component.ts | 66 +++++++++++++++++++ .../regulatory-data-routing.module.ts | 12 ++++ .../regulatory-data/regulatory-data.module.ts | 14 ++++ .../services/regulatory-data.service.ts | 9 +++ src/app/routes/routes-routing.module.ts | 4 +- src/app/shared/index.ts | 1 + src/app/shared/shared-g2.module.ts | 6 ++ src/assets/mocks/menu-data.json | 10 +++ 11 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 src/app/routes/regulatory-data/components/dashboard/dashboard.component.html create mode 100644 src/app/routes/regulatory-data/components/dashboard/dashboard.component.less create mode 100644 src/app/routes/regulatory-data/components/dashboard/dashboard.component.ts create mode 100644 src/app/routes/regulatory-data/regulatory-data-routing.module.ts create mode 100644 src/app/routes/regulatory-data/regulatory-data.module.ts create mode 100644 src/app/routes/regulatory-data/services/regulatory-data.service.ts create mode 100644 src/app/shared/shared-g2.module.ts diff --git a/src/app/global-config.module.ts b/src/app/global-config.module.ts index 163c16c9..d92a7840 100644 --- a/src/app/global-config.module.ts +++ b/src/app/global-config.module.ts @@ -20,7 +20,14 @@ const alainConfig: AlainConfig = { sf: { button: { search: '查询' }, ui: { placeholder: '请输入' } }, pageHeader: { homeI18n: 'home', recursiveBreadcrumb: true }, auth: { login_url: '/passport/login' }, - acl: { guard_url: '/exception/403' } + acl: { guard_url: '/exception/403' }, + chart: { + // 以下是默认配置,如果项目无法外网访问,可以根据 `angular.json` 配置将依赖包直接使用 `./assets***` 路径 + libs: [ + 'https://gw.alipayobjects.com/os/lib/antv/g2/4.1.4/dist/g2.min.js', + 'https://gw.alipayobjects.com/os/lib/antv/data-set/0.11.7/dist/data-set.js' + ] + } }; const alainModules = [AlainThemeModule.forRoot(), DelonACLModule.forRoot()]; diff --git a/src/app/routes/regulatory-data/components/dashboard/dashboard.component.html b/src/app/routes/regulatory-data/components/dashboard/dashboard.component.html new file mode 100644 index 00000000..06139f88 --- /dev/null +++ b/src/app/routes/regulatory-data/components/dashboard/dashboard.component.html @@ -0,0 +1,13 @@ + + diff --git a/src/app/routes/regulatory-data/components/dashboard/dashboard.component.less b/src/app/routes/regulatory-data/components/dashboard/dashboard.component.less new file mode 100644 index 00000000..e69de29b diff --git a/src/app/routes/regulatory-data/components/dashboard/dashboard.component.ts b/src/app/routes/regulatory-data/components/dashboard/dashboard.component.ts new file mode 100644 index 00000000..d895eedc --- /dev/null +++ b/src/app/routes/regulatory-data/components/dashboard/dashboard.component.ts @@ -0,0 +1,66 @@ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { G2PieClickItem, G2PieComponent, G2PieData } from '@delon/chart/pie'; +import { NzMessageService } from 'ng-zorro-antd/message'; + +@Component({ + selector: 'app-dashboard', + templateUrl: './dashboard.component.html', + styleUrls: ['./dashboard.component.less'] +}) +export class DashboardComponent implements OnInit { + @ViewChild('pie', { static: false }) readonly pie!: G2PieComponent; + salesPieData: G2PieData[] = []; + total = ''; + + constructor(private msg: NzMessageService) { + this.refresh(); + } + ngOnInit(): void { + throw new Error('Method not implemented.'); + } + + refresh(): void { + const rv = (min: number = 0, max: number = 5000) => Math.floor(Math.random() * (max - min + 1) + min); + this.salesPieData = [ + { + x: '家用电器', + y: rv() + }, + { + x: '食用酒水', + y: rv() + }, + { + x: '个护健康', + y: rv() + }, + { + x: '服饰箱包', + y: rv() + }, + { + x: '母婴产品', + y: rv() + } + ]; + if (Math.random() > 0.5) { + this.salesPieData.push({ + x: '其他', + y: rv() + }); + } + this.total = `¥ ${this.salesPieData.reduce((pre, now) => now.y + pre, 0).toFixed(2)}`; + if (this.pie) { + // 等待组件渲染 + setTimeout(() => this.pie.changeData()); + } + } + + format(val: number): string { + return `¥ ${val.toFixed(2)}`; + } + + handleClick(data: G2PieClickItem): void { + this.msg.info(`${data.item.x} - ${data.item.y}`); + } +} diff --git a/src/app/routes/regulatory-data/regulatory-data-routing.module.ts b/src/app/routes/regulatory-data/regulatory-data-routing.module.ts new file mode 100644 index 00000000..bb68bd97 --- /dev/null +++ b/src/app/routes/regulatory-data/regulatory-data-routing.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; + +import { DashboardComponent } from './components/dashboard/dashboard.component'; + +const routes: Routes = [{ path: 'dashboard', component: DashboardComponent }]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class RegulatoryDataRoutingModule {} diff --git a/src/app/routes/regulatory-data/regulatory-data.module.ts b/src/app/routes/regulatory-data/regulatory-data.module.ts new file mode 100644 index 00000000..c76d3521 --- /dev/null +++ b/src/app/routes/regulatory-data/regulatory-data.module.ts @@ -0,0 +1,14 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { SharedModule, SHARED_G2_MODULES } from '@shared'; + +import { DashboardComponent } from './components/dashboard/dashboard.component'; +import { RegulatoryDataRoutingModule } from './regulatory-data-routing.module'; + +const COMPONENTS: any = [DashboardComponent]; +const NOTROUTECOMPONENTS: any = []; +@NgModule({ + declarations: [...COMPONENTS, ...NOTROUTECOMPONENTS], + imports: [CommonModule, RegulatoryDataRoutingModule, SharedModule, SHARED_G2_MODULES] +}) +export class RegulatoryDataModule {} diff --git a/src/app/routes/regulatory-data/services/regulatory-data.service.ts b/src/app/routes/regulatory-data/services/regulatory-data.service.ts new file mode 100644 index 00000000..7206840f --- /dev/null +++ b/src/app/routes/regulatory-data/services/regulatory-data.service.ts @@ -0,0 +1,9 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class RegulatoryDataService { + + constructor() { } +} diff --git a/src/app/routes/routes-routing.module.ts b/src/app/routes/routes-routing.module.ts index 68b60fe7..712e39ec 100644 --- a/src/app/routes/routes-routing.module.ts +++ b/src/app/routes/routes-routing.module.ts @@ -15,6 +15,7 @@ import { RouterModule, Routes } from '@angular/router'; import { LayoutProComponent } from '@brand'; import { EATokenGuard } from '@core'; import { environment } from '@env/environment'; + import { AuthGuard } from '../core/guards/auth.guard'; // dashboard pages @@ -68,6 +69,7 @@ const routes: Routes = [ }, { path: 'menu-management', loadChildren: () => import('./menu-manager/menu-manager.module').then(m => m.MenuManagerModule) }, { path: 'partner', loadChildren: () => import('./partner/partner.module').then(m => m.PartnerModule) }, + { path: 'regulatory-data', loadChildren: () => import('./regulatory-data/regulatory-data.module').then(m => m.RegulatoryDataModule) }, { path: 'download', loadChildren: () => import('./download/download.module').then(m => m.DownloadModule) @@ -92,4 +94,4 @@ const routes: Routes = [ ], exports: [RouterModule] }) -export class RouteRoutingModule { } +export class RouteRoutingModule {} diff --git a/src/app/shared/index.ts b/src/app/shared/index.ts index d8f2d2d9..7ea8c70d 100644 --- a/src/app/shared/index.ts +++ b/src/app/shared/index.ts @@ -33,4 +33,5 @@ export * from './shared.module'; export * from './shared-delon.module'; export * from './shared-zorro.module'; export * from './shared-third.module'; +export * from './shared-g2.module'; export * from './widget/st-widget.module'; diff --git a/src/app/shared/shared-g2.module.ts b/src/app/shared/shared-g2.module.ts new file mode 100644 index 00000000..685f05bc --- /dev/null +++ b/src/app/shared/shared-g2.module.ts @@ -0,0 +1,6 @@ +import { G2BarModule } from '@delon/chart/bar'; +import { G2MiniAreaModule } from '@delon/chart/mini-area'; +import { G2PieModule } from '@delon/chart/pie'; +import { G2TimelineModule } from '@delon/chart/timeline'; + +export const SHARED_G2_MODULES = [G2BarModule, G2PieModule, G2TimelineModule, G2MiniAreaModule]; diff --git a/src/assets/mocks/menu-data.json b/src/assets/mocks/menu-data.json index 82dcd221..22c0317b 100644 --- a/src/assets/mocks/menu-data.json +++ b/src/assets/mocks/menu-data.json @@ -630,6 +630,16 @@ } ] + }, + { + "text": "数据监管", + "icon": "iconfont icon-hetong-copy", + "group": true, + "children": [{ + "text": "数据报表", + "link": "/regulatory-data/dashboard" + } + ] } ] }]