├── src ├── assets │ ├── .gitkeep │ └── icons │ │ ├── icon-128x128.png │ │ ├── icon-144x144.png │ │ ├── icon-152x152.png │ │ ├── icon-192x192.png │ │ ├── icon-384x384.png │ │ ├── icon-512x512.png │ │ ├── icon-72x72.png │ │ └── icon-96x96.png ├── app │ ├── shared │ │ ├── services │ │ │ ├── alert │ │ │ │ ├── alert.component.scss │ │ │ │ ├── alert.service.spec.ts │ │ │ │ ├── alert.component.ts │ │ │ │ ├── alert.service.ts │ │ │ │ ├── alert.component.spec.ts │ │ │ │ └── alert.component.html │ │ │ ├── data │ │ │ │ ├── data-pws.spec.ts │ │ │ │ ├── data-users.spec.ts │ │ │ │ ├── data-prices.spec.ts │ │ │ │ ├── data-customers.spec.ts │ │ │ │ ├── data-vehicle-steel.spec.ts │ │ │ │ ├── data-users.ts │ │ │ │ ├── data-prices.ts │ │ │ │ ├── data-pws.ts │ │ │ │ ├── data-customers.ts │ │ │ │ └── data-vehicle-steel.ts │ │ │ ├── auth.service.spec.ts │ │ │ ├── data.service.spec.ts │ │ │ ├── utils.service.spec.ts │ │ │ ├── calculate-patches.service.spec.ts │ │ │ ├── data.service.ts │ │ │ ├── utils.service.ts │ │ │ ├── calculate-patches.service.ts │ │ │ └── auth.service.ts │ │ ├── components │ │ │ ├── loading │ │ │ │ ├── loading.component.scss │ │ │ │ ├── loading.component.html │ │ │ │ ├── loading.component.ts │ │ │ │ └── loading.component.spec.ts │ │ │ ├── dashboard │ │ │ │ ├── dashboard.component.scss │ │ │ │ ├── dashboard.component.html │ │ │ │ ├── dashboard.component.ts │ │ │ │ └── dashboard.component.spec.ts │ │ │ ├── not-found │ │ │ │ ├── not-found.component.scss │ │ │ │ ├── not-found.component.html │ │ │ │ ├── not-found.component.ts │ │ │ │ └── not-found.component.spec.ts │ │ │ └── login │ │ │ │ ├── login.component.scss │ │ │ │ ├── login.component.spec.ts │ │ │ │ ├── login.component.html │ │ │ │ └── login.component.ts │ │ ├── guards │ │ │ ├── auth.guard.spec.ts │ │ │ └── auth.guard.ts │ │ └── shared.module.ts │ ├── customers │ │ ├── customer-dialog │ │ │ ├── customer-dialog.component.scss │ │ │ ├── customer-dialog-service.service.spec.ts │ │ │ ├── customer-dialog.component.spec.ts │ │ │ ├── customer-dialog.component.html │ │ │ ├── customer-dialog-service.service.ts │ │ │ └── customer-dialog.component.ts │ │ ├── customers-routing.module.ts │ │ └── customers.module.ts │ ├── app.component.scss │ ├── vehicle-steel │ │ ├── vehicle-steel-home │ │ │ ├── vehicle-steel-home.component.scss │ │ │ ├── vehicle-steel-home.component.spec.ts │ │ │ ├── vehicle-steel-home.component.html │ │ │ └── vehicle-steel-home.component.ts │ │ ├── vehicle-steel-weighing-survey │ │ │ ├── vehicle-steel-weighing-survey.component.scss │ │ │ ├── vehicle-steel-weighing-survey.component.spec.ts │ │ │ ├── vehicle-steel-weighing-survey.component.html │ │ │ └── vehicle-steel-weighing-survey.component.ts │ │ ├── vehicle-steel-weighing-survey-recent │ │ │ ├── vehicle-steel-weighing-survey-recent.component.scss │ │ │ ├── vehicle-steel-weighing-survey-recent.component.spec.ts │ │ │ ├── vehicle-steel-weighing-survey-recent.component.html │ │ │ └── vehicle-steel-weighing-survey-recent.component.ts │ │ ├── vehicle-steel-weighing-survey-dialog │ │ │ ├── vehicle-steel-weighing-survey-dialog.component.scss │ │ │ ├── vehicle-steel-weighing-survey-dialog.service.spec.ts │ │ │ ├── vehicle-steel-survey-print │ │ │ │ ├── vehicle-steel-survey-print.component.spec.ts │ │ │ │ ├── vehicle-steel-survey-print.component.scss │ │ │ │ ├── vehicle-steel-survey-print.component.html │ │ │ │ └── vehicle-steel-survey-print.component.ts │ │ │ ├── vehicle-steel-weighing-print │ │ │ │ ├── vehicle-steel-weighing-print.component.spec.ts │ │ │ │ ├── vehicle-steel-weighing-print.component.scss │ │ │ │ ├── vehicle-steel-weighing-print.component.ts │ │ │ │ └── vehicle-steel-weighing-print.component.html │ │ │ ├── vehicle-steel-weighing-survey-dialog.component.spec.ts │ │ │ ├── vehicle-steel-weighing-survey-dialog.service.ts │ │ │ ├── vehicle-steel-weighing-survey-dialog.component.html │ │ │ └── vehicle-steel-weighing-survey-dialog.component.ts │ │ ├── vehicle-steel-routing.module.ts │ │ └── vehicle-steel.module.ts │ ├── app.config.ts │ ├── app.component.ts │ ├── app.component.html │ ├── app-routing.module.ts │ ├── app.component.spec.ts │ └── app.module.ts ├── favicon.ico ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── main.ts ├── styles.scss ├── index.html ├── test.ts ├── manifest.webmanifest └── polyfills.ts ├── cert.rar ├── notes ├── deploy.md ├── certs.md ├── port-forwarding.md └── config.md ├── .editorconfig ├── tsconfig.app.json ├── tsconfig.spec.json ├── ngsw-config.json ├── .browserslistrc ├── .gitignore ├── tsconfig.json ├── README.md ├── package.json ├── karma.conf.js └── angular.json /src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/shared/services/alert/alert.component.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/shared/components/loading/loading.component.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/shared/components/dashboard/dashboard.component.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/shared/components/not-found/not-found.component.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/customers/customer-dialog/customer-dialog.component.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cert.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timathon/lyfront-vs/master/cert.rar -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- 1 | .example-spacer { 2 | flex: 1 1 auto; 3 | } -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-home/vehicle-steel-home.component.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/shared/components/dashboard/dashboard.component.html: -------------------------------------------------------------------------------- 1 |

dashboard works!

2 | -------------------------------------------------------------------------------- /src/app/shared/components/not-found/not-found.component.html: -------------------------------------------------------------------------------- 1 |

not-found works!

2 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timathon/lyfront-vs/master/src/favicon.ico -------------------------------------------------------------------------------- /src/app/shared/components/loading/loading.component.html: -------------------------------------------------------------------------------- 1 |

{{message}}

-------------------------------------------------------------------------------- /notes/deploy.md: -------------------------------------------------------------------------------- 1 | git checkout -b gh-pages 2 | ng build --output-path docs --base-href /lyfront-vs/ -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey/vehicle-steel-weighing-survey.component.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/icons/icon-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timathon/lyfront-vs/master/src/assets/icons/icon-128x128.png -------------------------------------------------------------------------------- /src/assets/icons/icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timathon/lyfront-vs/master/src/assets/icons/icon-144x144.png -------------------------------------------------------------------------------- /src/assets/icons/icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timathon/lyfront-vs/master/src/assets/icons/icon-152x152.png -------------------------------------------------------------------------------- /src/assets/icons/icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timathon/lyfront-vs/master/src/assets/icons/icon-192x192.png -------------------------------------------------------------------------------- /src/assets/icons/icon-384x384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timathon/lyfront-vs/master/src/assets/icons/icon-384x384.png -------------------------------------------------------------------------------- /src/assets/icons/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timathon/lyfront-vs/master/src/assets/icons/icon-512x512.png -------------------------------------------------------------------------------- /src/assets/icons/icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timathon/lyfront-vs/master/src/assets/icons/icon-72x72.png -------------------------------------------------------------------------------- /src/assets/icons/icon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timathon/lyfront-vs/master/src/assets/icons/icon-96x96.png -------------------------------------------------------------------------------- /src/app/shared/components/login/login.component.scss: -------------------------------------------------------------------------------- 1 | .example-card { 2 | max-width: 200px; 3 | // margin: auto; 4 | margin-left: 20px; 5 | } -------------------------------------------------------------------------------- /src/app/app.config.ts: -------------------------------------------------------------------------------- 1 | import { InjectionToken } from '@angular/core'; 2 | 3 | export const APP_CONFIG = new InjectionToken('Application Configuration'); -------------------------------------------------------------------------------- /notes/certs.md: -------------------------------------------------------------------------------- 1 | openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem 2 | openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out server.crt 3 | -------------------------------------------------------------------------------- /src/app/shared/services/data/data-pws.spec.ts: -------------------------------------------------------------------------------- 1 | import { DataPws } from './data-pws'; 2 | 3 | describe('DataPws', () => { 4 | it('should create an instance', () => { 5 | expect(new DataPws()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /src/app/shared/services/data/data-users.spec.ts: -------------------------------------------------------------------------------- 1 | import { DataUsers } from './data-users'; 2 | 3 | describe('DataUsers', () => { 4 | it('should create an instance', () => { 5 | expect(new DataUsers()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /src/app/shared/services/data/data-prices.spec.ts: -------------------------------------------------------------------------------- 1 | import { DataPrices } from './data-prices'; 2 | 3 | describe('DataPrices', () => { 4 | it('should create an instance', () => { 5 | expect(new DataPrices()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-recent/vehicle-steel-weighing-survey-recent.component.scss: -------------------------------------------------------------------------------- 1 | table { 2 | width: 100%; 3 | th { 4 | text-align: center; 5 | } 6 | td { 7 | text-align: center; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/app/shared/services/data/data-customers.spec.ts: -------------------------------------------------------------------------------- 1 | import { DataCustomers } from './data-customers'; 2 | 3 | describe('DataCustomers', () => { 4 | it('should create an instance', () => { 5 | expect(new DataCustomers()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /src/app/shared/services/data/data-vehicle-steel.spec.ts: -------------------------------------------------------------------------------- 1 | import { DataVehicleSteel } from './data-vehicle-steel'; 2 | 3 | describe('DataVehicleSteel', () => { 4 | it('should create an instance', () => { 5 | expect(new DataVehicleSteel()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'lyfront-vs'; 10 | } 11 | -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | authUrl: '', 4 | // backendUrl: 'https://47.104.155.50:3003' 5 | backendUrl: 'https://1586863340063318.cn-zhangjiakou.fc.aliyuncs.com/2016-08-15/proxy/ly.LATEST/ly-proxy/json_placeholder/' 6 | }; 7 | -------------------------------------------------------------------------------- /notes/port-forwarding.md: -------------------------------------------------------------------------------- 1 | netsh interface portproxy add v4tov4 listenport=4200 connectport=4200 connectaddress=$($(wsl hostname -I).Trim()) 2 | netsh interface portproxy add v4tov4 listenport=3003 connectport=3003 connectaddress=47.104.155.50 3 | 4 | netsh interface portproxy reset 5 | netsh interface portproxy show v4tov4 -------------------------------------------------------------------------------- /src/app/customers/customers-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | 4 | const routes: Routes = []; 5 | 6 | @NgModule({ 7 | imports: [RouterModule.forChild(routes)], 8 | exports: [RouterModule] 9 | }) 10 | export class CustomersRoutingModule { } 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /src/app/shared/components/dashboard/dashboard.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-dashboard', 5 | templateUrl: './dashboard.component.html', 6 | styleUrls: ['./dashboard.component.scss'] 7 | }) 8 | export class DashboardComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit(): void { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/app/shared/components/not-found/not-found.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-not-found', 5 | templateUrl: './not-found.component.html', 6 | styleUrls: ['./not-found.component.scss'] 7 | }) 8 | export class NotFoundComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit(): void { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/app/shared/guards/auth.guard.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { AuthGuard } from './auth.guard'; 4 | 5 | describe('AuthGuard', () => { 6 | let guard: AuthGuard; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | guard = TestBed.inject(AuthGuard); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(guard).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/shared/services/auth.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { AuthService } from './auth.service'; 4 | 5 | describe('AuthService', () => { 6 | let service: AuthService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(AuthService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/shared/services/data.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { DataService } from './data.service'; 4 | 5 | describe('DataService', () => { 6 | let service: DataService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(DataService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/shared/services/utils.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { UtilsService } from './utils.service'; 4 | 5 | describe('UtilsService', () => { 6 | let service: UtilsService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(UtilsService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/shared/services/alert/alert.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { AlertService } from './alert.service'; 4 | 5 | describe('AlertService', () => { 6 | let service: AlertService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(AlertService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-survey-dialog.component.scss: -------------------------------------------------------------------------------- 1 | .width-fifty { 2 | width: 50%; 3 | min-width: 50vw; 4 | } 5 | 6 | 7 | @media only screen and (min-width: 768px) { 8 | .width-five-vm { 9 | max-width: 4em; 10 | // min-width: 20vw; 11 | } 12 | .width-ten-vm { 13 | max-width: 10%; 14 | // min-width: 20vw; 15 | } 16 | .width-fifteen-vm { 17 | max-width: 15%; 18 | // min-width: 20vw; 19 | } 20 | } -------------------------------------------------------------------------------- /src/app/shared/services/calculate-patches.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { CalculatePatchesService } from './calculate-patches.service'; 4 | 5 | describe('CalculatePatchesService', () => { 6 | let service: CalculatePatchesService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(CalculatePatchesService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | dashboard 6 |   7 | 隆运 Q5 - 物资管理 8 | 9 | 10 | 11 |

12 | v20210902 13 |

14 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | import { VehicleSteelHomeComponent } from './vehicle-steel-home/vehicle-steel-home.component'; 4 | 5 | const routes: Routes = [ 6 | { path: '', component: VehicleSteelHomeComponent, /* canActivate: [AuthGuard], */pathMatch: 'full' } 7 | ]; 8 | 9 | @NgModule({ 10 | imports: [RouterModule.forChild(routes)], 11 | exports: [RouterModule] 12 | }) 13 | export class VehicleSteelRoutingModule { } 14 | -------------------------------------------------------------------------------- /src/app/customers/customer-dialog/customer-dialog-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { CustomerDialogServiceService } from './customer-dialog-service.service'; 4 | 5 | describe('CustomerDialogServiceService', () => { 6 | let service: CustomerDialogServiceService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(CustomerDialogServiceService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/shared/services/alert/alert.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Inject, OnInit } from '@angular/core'; 2 | import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; 3 | 4 | @Component({ 5 | selector: 'app-alert', 6 | templateUrl: './alert.component.html', 7 | styleUrls: ['./alert.component.scss'] 8 | }) 9 | export class AlertComponent implements OnInit { 10 | 11 | constructor( 12 | @Inject(MAT_DIALOG_DATA) public data: { alert: any }, 13 | private dialogRef: MatDialogRef, 14 | 15 | ) { } 16 | 17 | ngOnInit(): void { 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/app/shared/components/loading/loading.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Inject, OnInit } from '@angular/core'; 2 | import { MAT_DIALOG_DATA } from '@angular/material/dialog'; 3 | 4 | @Component({ 5 | selector: 'app-loading', 6 | templateUrl: './loading.component.html', 7 | styleUrls: ['./loading.component.scss'] 8 | }) 9 | export class LoadingComponent implements OnInit { 10 | message: string; 11 | constructor( 12 | @Inject(MAT_DIALOG_DATA) public data: { message: string }, 13 | ) { 14 | this.message = this.data && this.data.message ? this.data.message : '正在载入...' 15 | } 16 | 17 | ngOnInit(): void { 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /notes/config.md: -------------------------------------------------------------------------------- 1 | package.json 2 | 3 | "start": "ng serve --ssl --host 0.0.0.0", 4 | "buildx": "ng build --output-path docs --base-href /lyfront-vs/", 5 | 6 | 7 | angular.json 8 | 9 | "serve": { 10 | "builder": "@angular-devkit/build-angular:dev-server", 11 | "configurations": { 12 | "production": { 13 | "browserTarget": "lyfront-vs:build:production" 14 | }, 15 | "development": { 16 | "browserTarget": "lyfront-vs:build:development" 17 | } 18 | }, 19 | "defaultConfiguration": "development", 20 | "options":{ 21 | "sslKey": "../0-commons/ssl/cert.key", 22 | "sslCert": "../0-commons/ssl/cert.crt" 23 | } 24 | }, 25 | -------------------------------------------------------------------------------- /src/app/shared/services/alert/alert.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { MatDialog } from '@angular/material/dialog'; 3 | import { AlertComponent } from './alert.component'; 4 | 5 | @Injectable({ 6 | providedIn: 'root' 7 | }) 8 | export class AlertService { 9 | 10 | constructor( 11 | private dialog: MatDialog, 12 | ) { } 13 | openDialog(alert: { 14 | title: string, 15 | message: string, 16 | okOnly?: boolean 17 | }) { 18 | const dialogRef = this.dialog.open(AlertComponent, { 19 | disableClose: true, 20 | data: {alert} 21 | }); 22 | return dialogRef; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-survey-dialog.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { VehicleSteelWeighingSurveyDialogService } from './vehicle-steel-weighing-survey-dialog.service'; 4 | 5 | describe('VehicleSteelWeighingSurveyDialogService', () => { 6 | let service: VehicleSteelWeighingSurveyDialogService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(VehicleSteelWeighingSurveyDialogService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/customers/customers.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { SharedModule } from '../shared/shared.module'; 3 | 4 | import { CustomersRoutingModule } from './customers-routing.module'; 5 | import { CustomerDialogComponent } from './customer-dialog/customer-dialog.component'; 6 | import { CustomerDialogServiceService } from './customer-dialog/customer-dialog-service.service'; 7 | 8 | 9 | @NgModule({ 10 | declarations: [ 11 | CustomerDialogComponent 12 | ], 13 | imports: [ 14 | CustomersRoutingModule, 15 | SharedModule 16 | ], 17 | providers: [CustomerDialogServiceService] 18 | }) 19 | export class CustomersModule { } 20 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | 3 | html, body { height: 100%; } 4 | body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } 5 | 6 | .spacerx { 7 | flex: 1 1 auto; 8 | } 9 | 10 | // .full-width.cdk-global-overlay-wrapper#cdk-overlay-0 { 11 | // width: 100% !important; 12 | // max-width: 100% !important; 13 | // } 14 | 15 | 16 | @media print{ 17 | .noprint{ 18 | display:none; 19 | } 20 | 21 | 22 | * { 23 | visibility: hidden; 24 | height: 0; 25 | margin:0; padding:0; 26 | } 27 | 28 | #dataToPrint * { 29 | visibility: visible; 30 | height: auto; 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /ngsw-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/service-worker/config/schema.json", 3 | "index": "/index.html", 4 | "assetGroups": [ 5 | { 6 | "name": "app", 7 | "installMode": "prefetch", 8 | "resources": { 9 | "files": [ 10 | "/favicon.ico", 11 | "/index.html", 12 | "/manifest.webmanifest", 13 | "/*.css", 14 | "/*.js" 15 | ] 16 | } 17 | }, 18 | { 19 | "name": "assets", 20 | "installMode": "lazy", 21 | "updateMode": "prefetch", 22 | "resources": { 23 | "files": [ 24 | "/assets/**", 25 | "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)" 26 | ] 27 | } 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/app/shared/services/alert/alert.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { AlertComponent } from './alert.component'; 4 | 5 | describe('AlertComponent', () => { 6 | let component: AlertComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ AlertComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(AlertComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/components/login/login.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { LoginComponent } from './login.component'; 4 | 5 | describe('LoginComponent', () => { 6 | let component: LoginComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ LoginComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(LoginComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /src/app/shared/components/loading/loading.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { LoadingComponent } from './loading.component'; 4 | 5 | describe('LoadingComponent', () => { 6 | let component: LoadingComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ LoadingComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(LoadingComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/components/not-found/not-found.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NotFoundComponent } from './not-found.component'; 4 | 5 | describe('NotFoundComponent', () => { 6 | let component: NotFoundComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ NotFoundComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(NotFoundComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/components/dashboard/dashboard.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { DashboardComponent } from './dashboard.component'; 4 | 5 | describe('DashboardComponent', () => { 6 | let component: DashboardComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ DashboardComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(DashboardComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | 16 | # IDEs and editors 17 | /.idea 18 | .project 19 | .classpath 20 | .c9/ 21 | *.launch 22 | .settings/ 23 | *.sublime-workspace 24 | 25 | # IDE - VSCode 26 | .vscode/* 27 | !.vscode/settings.json 28 | !.vscode/tasks.json 29 | !.vscode/launch.json 30 | !.vscode/extensions.json 31 | .history/* 32 | 33 | # misc 34 | /.sass-cache 35 | /connect.lock 36 | /coverage 37 | /libpeerconnection.log 38 | npm-debug.log 39 | yarn-error.log 40 | testem.log 41 | /typings 42 | 43 | # System Files 44 | .DS_Store 45 | Thumbs.db 46 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LyfrontVs 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/app/customers/customer-dialog/customer-dialog.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CustomerDialogComponent } from './customer-dialog.component'; 4 | 5 | describe('CustomerDialogComponent', () => { 6 | let component: CustomerDialogComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ CustomerDialogComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(CustomerDialogComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting() 21 | ); 22 | // Then we find all the tests. 23 | const context = require.context('./', true, /\.spec\.ts$/); 24 | // And load the modules. 25 | context.keys().map(context); 26 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-home/vehicle-steel-home.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { VehicleSteelHomeComponent } from './vehicle-steel-home.component'; 4 | 5 | describe('VehicleSteelHomeComponent', () => { 6 | let component: VehicleSteelHomeComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ VehicleSteelHomeComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(VehicleSteelHomeComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/guards/auth.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router'; 3 | import { Observable } from 'rxjs'; 4 | import { AuthService } from '../services/auth.service'; 5 | 6 | @Injectable({ 7 | providedIn: 'root' 8 | }) 9 | export class AuthGuard implements CanActivate { 10 | constructor(private router: Router, private auth: AuthService) { } 11 | canActivate( 12 | route: ActivatedRouteSnapshot, 13 | state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { 14 | // return true; 15 | if (this.auth.isLoggedIn) { 16 | return true; 17 | } else { 18 | this.router.navigate(['/login', { 19 | queryParams: { 20 | lastUrl: state.url 21 | } 22 | }]); 23 | return false; 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey/vehicle-steel-weighing-survey.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { VehicleSteelWeighingSurveyComponent } from './vehicle-steel-weighing-survey.component'; 4 | 5 | describe('VehicleSteelWeighingSurveyComponent', () => { 6 | let component: VehicleSteelWeighingSurveyComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ VehicleSteelWeighingSurveyComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(VehicleSteelWeighingSurveyComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-survey-print/vehicle-steel-survey-print.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { VehicleSteelSurveyPrintComponent } from './vehicle-steel-survey-print.component'; 4 | 5 | describe('VehicleSteelSurveyPrintComponent', () => { 6 | let component: VehicleSteelSurveyPrintComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ VehicleSteelSurveyPrintComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(VehicleSteelSurveyPrintComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "paths": { 7 | "@app/*": ["src/app/*"] 8 | }, 9 | "outDir": "./dist/out-tsc", 10 | "forceConsistentCasingInFileNames": true, 11 | "strict": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": true, 14 | "sourceMap": true, 15 | "declaration": false, 16 | "downlevelIteration": true, 17 | "experimentalDecorators": true, 18 | "moduleResolution": "node", 19 | "importHelpers": true, 20 | "target": "es2017", 21 | "module": "es2020", 22 | "lib": [ 23 | "es2018", 24 | "dom" 25 | ] 26 | }, 27 | "angularCompilerOptions": { 28 | "enableI18nLegacyMessageIdFormat": false, 29 | "strictInjectionParameters": true, 30 | "strictInputAccessModifiers": true, 31 | "strictTemplates": true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-print/vehicle-steel-weighing-print.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { VehicleSteelWeighingPrintComponent } from './vehicle-steel-weighing-print.component'; 4 | 5 | describe('VehicleSteelWeighingPrintComponent', () => { 6 | let component: VehicleSteelWeighingPrintComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ VehicleSteelWeighingPrintComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(VehicleSteelWeighingPrintComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/shared/services/data/data-users.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient, HttpHeaders } from '@angular/common/http'; 2 | import { Observable } from 'rxjs'; 3 | import { CalculatePatchesService } from '../calculate-patches.service'; 4 | 5 | export class User { 6 | _id: any; 7 | username = ''; 8 | displayName = ''; 9 | isActive?= true; 10 | facility?= 'f001'; 11 | setting?: { [key: string]: any } 12 | } 13 | 14 | export class DataUsers { 15 | apiURL = this.appConfig.backendUrl + '/api/users'; 16 | 17 | constructor( 18 | private http: HttpClient, 19 | private setHeaders: (withJWT: boolean) => HttpHeaders | { 20 | [header: string]: string | string[]; 21 | }, 22 | private appConfig: any, 23 | private calculatePatches: CalculatePatchesService 24 | ) { } 25 | search(searchParams: { [key: string]: any }): Observable { 26 | return this.http.post(this.apiURL + '/search', searchParams, { 27 | headers: this.setHeaders(true) 28 | }) as Observable; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-home/vehicle-steel-home.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 24 | 25 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-survey-dialog.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { VehicleSteelWeighingSurveyDialogComponent } from './vehicle-steel-weighing-survey-dialog.component'; 4 | 5 | describe('VehicleSteelWeighingSurveyDialogComponent', () => { 6 | let component: VehicleSteelWeighingSurveyDialogComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ VehicleSteelWeighingSurveyDialogComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(VehicleSteelWeighingSurveyDialogComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-recent/vehicle-steel-weighing-survey-recent.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { VehicleSteelWeighingSurveyRecentComponent } from './vehicle-steel-weighing-survey-recent.component'; 4 | 5 | describe('VehicleSteelWeighingSurveyRecentComponent', () => { 6 | let component: VehicleSteelWeighingSurveyRecentComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ VehicleSteelWeighingSurveyRecentComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(VehicleSteelWeighingSurveyRecentComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false, 7 | authUrl: '', 8 | // authUrl: 'https://1586863340063318.cn-zhangjiakou.fc.aliyuncs.com/2016-08-15/proxy/ly/ly-auth/', 9 | backendUrl: 'https://1586863340063318.cn-zhangjiakou.fc.aliyuncs.com/2016-08-15/proxy/ly.LATEST/ly-proxy/json_placeholder/' 10 | // backendUrl: 'https://47.104.155.50:3003' 11 | }; 12 | 13 | /* 14 | * For easier debugging in development mode, you can import the following file 15 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 16 | * 17 | * This import should be commented out in production mode because it will have a negative impact 18 | * on performance if an error is thrown. 19 | */ 20 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 21 | -------------------------------------------------------------------------------- /src/app/shared/services/alert/alert.component.html: -------------------------------------------------------------------------------- 1 |

{{data.alert.title}}

2 | 3 | 4 | 5 | 8 | 9 | {{data.alert.message}} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LyfrontVs 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.0.0. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-home/vehicle-steel-home.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { MatDialog } from '@angular/material/dialog'; 3 | import { LoadingComponent } from '@app/shared/components/loading/loading.component'; 4 | import { DataService } from '@app/shared/services/data.service'; 5 | import { tap } from 'rxjs/operators'; 6 | 7 | @Component({ 8 | selector: 'app-vehicle-steel-home', 9 | templateUrl: './vehicle-steel-home.component.html', 10 | styleUrls: ['./vehicle-steel-home.component.scss'] 11 | }) 12 | export class VehicleSteelHomeComponent implements OnInit { 13 | 14 | constructor( 15 | private dialog: MatDialog, 16 | private backend: DataService 17 | ) { } 18 | 19 | ngOnInit(): void { 20 | } 21 | 22 | refresh() { 23 | const loadingDialogRef = this.dialog.open(LoadingComponent, { 24 | disableClose: true, 25 | data: { 26 | message: '正在更新物料名称...' 27 | } 28 | }); 29 | this.backend.dataPws.refreshPws() 30 | .subscribe(() => { 31 | loadingDialogRef.close(); 32 | }) 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | import { NotFoundComponent } from './shared/components/not-found/not-found.component'; 4 | import { LoginComponent } from './shared/components/login/login.component'; 5 | import { DashboardComponent } from './shared/components/dashboard/dashboard.component'; 6 | import { AuthGuard } from './shared/guards/auth.guard'; 7 | const routes: Routes = [ 8 | { 9 | path: '', children: [ 10 | // { path: '', canActivate: [AuthGuard], component: DashboardComponent, pathMatch: 'full' }, 11 | { path: '', redirectTo: '/vehicle-steel', pathMatch: 'full' }, 12 | { 13 | path: 'vehicle-steel', 14 | canActivate: [AuthGuard], 15 | loadChildren: () => import('./vehicle-steel/vehicle-steel.module').then(m => m.VehicleSteelModule) 16 | }, 17 | { path: 'login', component: LoginComponent }, 18 | { path: '**', component: NotFoundComponent } 19 | ] 20 | } 21 | ]; 22 | 23 | @NgModule({ 24 | imports: [RouterModule.forRoot(routes)], 25 | exports: [RouterModule] 26 | }) 27 | export class AppRoutingModule { } 28 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-print/vehicle-steel-weighing-print.component.scss: -------------------------------------------------------------------------------- 1 | .t3 { 2 | display: grid; 3 | grid-template-areas: 4 | "h1 h1 h1 h1 h1 h1" 5 | "m1 m1 m2 m2 m2 m3" 6 | "T1 C1 T2 C2 T3 C3" 7 | "T1 C1 T2 C2 T3 C3" 8 | "T1 C1 T2 C2 T3 C3" 9 | "nwat nwac nwbt nwbc nwbc nwbc"; 10 | grid-template-columns: 1.5fr 3.5fr 2fr 3.5fr 2fr 7.5fr; 11 | } 12 | 13 | 14 | .header { 15 | grid-area: h1; 16 | } 17 | 18 | .title { 19 | font-style: italic; 20 | } 21 | 22 | .content { 23 | font-size: 1.1em; 24 | } 25 | 26 | .meta1 { 27 | grid-area: m1; 28 | } 29 | .meta2 { 30 | grid-area: m2; 31 | } 32 | .meta3 { 33 | grid-area: m3; 34 | } 35 | .netweightbc { 36 | grid-area: nwbc; 37 | } 38 | 39 | .item { 40 | border-top: 1px black solid; 41 | border-left: 1px black solid; 42 | text-align: center; 43 | } 44 | 45 | .lastrow { 46 | border-bottom: 1px black solid; 47 | } 48 | .lastcolumn { 49 | border-right: 1px black solid; 50 | } 51 | 52 | .header { 53 | font-size: 1.5em; 54 | text-align: center; 55 | margin-bottom: 0.3em; 56 | } 57 | 58 | .meta { 59 | margin-bottom: 0.3em; 60 | } 61 | 62 | .meta3 { 63 | text-align: right; 64 | } -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async () => { 7 | await TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | }); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'lyfront-vs'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('lyfront-vs'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement; 33 | expect(compiled.querySelector('.content span').textContent).toContain('lyfront-vs app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /src/app/shared/components/login/login.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 登录 7 | 8 | 9 | 10 | 11 | 12 | 用户名 13 | 14 | 15 |
16 | 17 | 密码 18 | 19 | 20 |
21 | 22 | 24 | 25 | 26 |
27 |
28 | 29 |
-------------------------------------------------------------------------------- /src/app/shared/services/data/data-prices.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient, HttpHeaders } from '@angular/common/http'; 2 | import { Observable, of } from 'rxjs'; 3 | import { first, switchMap, tap } from 'rxjs/operators'; 4 | import { CalculatePatchesService } from '../calculate-patches.service'; 5 | 6 | 7 | export interface PriceNumber { 8 | default: number 9 | } 10 | 11 | export interface Price { 12 | _id?: any; 13 | brandId?: any; 14 | model?: any; 15 | pwId: any; 16 | numbers: PriceNumber 17 | } 18 | 19 | 20 | export class DataPrices { 21 | apiURL = this.appConfig.backendUrl + '/api/prices-v3'; 22 | constructor( 23 | private http: HttpClient, 24 | private setHeaders: (withJWT: boolean) => HttpHeaders | { 25 | [header: string]: string | string[]; 26 | }, 27 | private appConfig: any, 28 | private calculatePatches: CalculatePatchesService 29 | ) { } 30 | 31 | getPrices3(searchParams: { brandId?: string, model?: string, pwId?: string, spec?: string }, exact = false) { 32 | const searchParamsX: any = {}; 33 | // remove empty string 34 | Object.keys(searchParams).forEach(key => { 35 | if ((searchParams as any)[key]) { 36 | searchParamsX[key] = (searchParams as any)[key]; 37 | } 38 | }); 39 | 40 | return this.http.post(this.apiURL + `/search?exact=${exact}`, searchParamsX, { 41 | headers: this.setHeaders(true) 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey/vehicle-steel-weighing-survey.component.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |     9 | 仅显示【未验质】 10 |     11 | 仅显示【采购】 12 |
 
13 | 14 | 15 | 16 |
17 | 18 | 19 | 28 | 29 |
-------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lyfront-vs", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve --ssl --host 0.0.0.0", 7 | "starta": "ng serve --host 0.0.0.0", 8 | "build": "ng build", 9 | "buildx": "ng build --output-path docs --base-href /lyfront-vs/", 10 | "watch": "ng build --watch --configuration development", 11 | "test": "ng test" 12 | }, 13 | "private": true, 14 | "dependencies": { 15 | "@angular/animations": "~12.0.0", 16 | "@angular/cdk": "^12.0.0", 17 | "@angular/common": "~12.0.0", 18 | "@angular/compiler": "~12.0.0", 19 | "@angular/core": "~12.0.0", 20 | "@angular/forms": "~12.0.0", 21 | "@angular/material": "^12.0.0", 22 | "@angular/platform-browser": "~12.0.0", 23 | "@angular/platform-browser-dynamic": "~12.0.0", 24 | "@angular/router": "~12.0.0", 25 | "@angular/service-worker": "~12.0.0", 26 | "fast-json-patch": "^3.0.0-1", 27 | "jwt-decode": "^3.1.2", 28 | "rxjs": "~6.6.0", 29 | "tslib": "^2.1.0", 30 | "zone.js": "~0.11.4" 31 | }, 32 | "devDependencies": { 33 | "@angular-devkit/build-angular": "~12.0.0", 34 | "@angular/cli": "~12.0.0", 35 | "@angular/compiler-cli": "~12.0.0", 36 | "@types/jasmine": "~3.6.0", 37 | "@types/node": "^12.11.1", 38 | "jasmine-core": "~3.7.0", 39 | "karma": "~6.3.0", 40 | "karma-chrome-launcher": "~3.1.0", 41 | "karma-coverage": "~2.0.3", 42 | "karma-jasmine": "~4.0.0", 43 | "karma-jasmine-html-reporter": "^1.5.0", 44 | "typescript": "~4.2.3" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/app/customers/customer-dialog/customer-dialog.component.html: -------------------------------------------------------------------------------- 1 |

{{dialogTitle}}

2 | 3 |
4 | 5 | 6 | 9 | 10 | 11 | 12 | 客户名称 13 | 14 | 15 | 16 |   17 | 18 | 19 | 客户手机 20 | 21 | 22 | 23 |
24 | 25 | 26 | 备注 27 | 28 | 29 | 30 |   31 |
32 |
33 | 34 | 35 |
36 | 37 | 38 | 41 | 42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /src/app/customers/customer-dialog/customer-dialog-service.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { MatDialog } from '@angular/material/dialog'; 3 | // import { LoadingComponent } from '@app/shared/components/loading/loading.component'; 4 | // import { DataService } from '@app/shared/services/data.service'; 5 | import { Customer } from '@app/shared/services/data/data-customers'; 6 | import { of } from 'rxjs'; 7 | import { first } from 'rxjs/operators'; 8 | import { CustomerDialogComponent } from './customer-dialog.component'; 9 | 10 | @Injectable() 11 | export class CustomerDialogServiceService { 12 | 13 | constructor( 14 | private dialog: MatDialog, 15 | ) { } 16 | 17 | openDialog(customer?: Customer) { 18 | console.log('opening cutomerDialog with data:'); 19 | console.log(customer); 20 | // const prepareData = (customer?: Customer) => { 21 | // if (!customer) { 22 | // return of(new Customer()); 23 | // } else { 24 | // return of(customer); 25 | // } 26 | // } 27 | // prepareData(customer).pipe(first()).subscribe(customerX => { 28 | // const dialogRef = this.dialog.open(CustomerDialogComponent, { 29 | // disableClose: true, 30 | // data: { customer: customerX } 31 | // }); 32 | // dialogRef.afterClosed().subscribe(result => { 33 | // console.log(`Dialog result: ${result}`); 34 | // }); 35 | // }) 36 | return this.dialog.open(CustomerDialogComponent, { 37 | disableClose: true, 38 | data: { customer } 39 | }); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/lyfront-vs'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /src/manifest.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lyfront-vs", 3 | "short_name": "lyfront-vs", 4 | "theme_color": "#1976d2", 5 | "background_color": "#fafafa", 6 | "display": "standalone", 7 | "scope": "./", 8 | "start_url": "./", 9 | "icons": [ 10 | { 11 | "src": "assets/icons/icon-72x72.png", 12 | "sizes": "72x72", 13 | "type": "image/png", 14 | "purpose": "maskable any" 15 | }, 16 | { 17 | "src": "assets/icons/icon-96x96.png", 18 | "sizes": "96x96", 19 | "type": "image/png", 20 | "purpose": "maskable any" 21 | }, 22 | { 23 | "src": "assets/icons/icon-128x128.png", 24 | "sizes": "128x128", 25 | "type": "image/png", 26 | "purpose": "maskable any" 27 | }, 28 | { 29 | "src": "assets/icons/icon-144x144.png", 30 | "sizes": "144x144", 31 | "type": "image/png", 32 | "purpose": "maskable any" 33 | }, 34 | { 35 | "src": "assets/icons/icon-152x152.png", 36 | "sizes": "152x152", 37 | "type": "image/png", 38 | "purpose": "maskable any" 39 | }, 40 | { 41 | "src": "assets/icons/icon-192x192.png", 42 | "sizes": "192x192", 43 | "type": "image/png", 44 | "purpose": "maskable any" 45 | }, 46 | { 47 | "src": "assets/icons/icon-384x384.png", 48 | "sizes": "384x384", 49 | "type": "image/png", 50 | "purpose": "maskable any" 51 | }, 52 | { 53 | "src": "assets/icons/icon-512x512.png", 54 | "sizes": "512x512", 55 | "type": "image/png", 56 | "purpose": "maskable any" 57 | } 58 | ] 59 | } 60 | -------------------------------------------------------------------------------- /src/app/shared/services/data/data-pws.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient, HttpHeaders } from '@angular/common/http'; 2 | import { Observable, of } from 'rxjs'; 3 | import { first, switchMap, tap } from 'rxjs/operators'; 4 | import { CalculatePatchesService } from '../calculate-patches.service'; 5 | 6 | export class Pws { 7 | _id?: any; 8 | name: string = ''; 9 | unit?: string; 10 | type?: string; 11 | idA6?: string; 12 | hasBrand?: string; 13 | idForPlan?: string; 14 | isActive?: string; 15 | hasIdPerUnit?: string; 16 | specs?: string[]; 17 | bms?: string; 18 | } 19 | 20 | 21 | export class DataPws { 22 | apiURL = this.appConfig.backendUrl + '/api/pws-v2'; 23 | constructor( 24 | private http: HttpClient, 25 | private setHeaders: (withJWT: boolean) => HttpHeaders | { 26 | [header: string]: string | string[]; 27 | }, 28 | private appConfig: any, 29 | private calculatePatches: CalculatePatchesService 30 | ) { } 31 | 32 | 33 | search(searchParams: { [key: string]: any }): Observable { 34 | return this.http.post(this.apiURL + '/search', searchParams, { 35 | headers: this.setHeaders(true) 36 | }) as Observable; 37 | } 38 | 39 | getPws() { 40 | return of(localStorage.getItem('pws')) 41 | .pipe( 42 | switchMap(pws0 => { 43 | if (pws0) { 44 | return of(JSON.parse(pws0)); 45 | } else { 46 | return this.refreshPws() 47 | } 48 | }) 49 | ); 50 | } 51 | 52 | refreshPws() { 53 | return this.search({}).pipe( 54 | tap(pws => { 55 | localStorage.setItem('pws', JSON.stringify(pws)); 56 | }), 57 | first() 58 | ) 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/app/shared/components/login/login.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms'; 3 | import { Router, ActivatedRoute } from '@angular/router'; 4 | import { AuthService } from '@app/shared/services/auth.service' 5 | 6 | 7 | @Component({ 8 | selector: 'app-login', 9 | templateUrl: './login.component.html', 10 | styleUrls: ['./login.component.scss'] 11 | }) 12 | export class LoginComponent implements OnInit { 13 | loginForm: FormGroup; 14 | redirectUrl: string = ''; 15 | isAuthenticating = false; 16 | constructor( 17 | // private userService: UserService, 18 | private fb: FormBuilder, 19 | private router: Router, 20 | private route: ActivatedRoute, 21 | private auth: AuthService) { 22 | this.loginForm = this.fb.group({ 23 | username: ['', Validators.required], 24 | password: ['', Validators.required], 25 | }); 26 | } 27 | 28 | ngOnInit(): void { 29 | this.route.queryParams 30 | .subscribe(params => { 31 | this.redirectUrl = params['lastUrl'] || '/'; 32 | // this.router.navigateByUrl(this.redirectUrl); 33 | }); 34 | } 35 | 36 | onSubmit() { 37 | // console.log(this.loginForm.getRawValue()); 38 | // this.auth.getAppConfig(); 39 | this.auth.authenticate(this.loginForm.getRawValue()) 40 | .subscribe(x => { 41 | console.log(x); 42 | this.router.navigateByUrl(this.redirectUrl); 43 | }); 44 | } 45 | 46 | // login() { 47 | // if (this.username && this.password) { 48 | // this.userService.login(this.username); 49 | // this.router.navigateByUrl(this.redirectUrl); 50 | // } 51 | // } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule, APP_INITIALIZER, LOCALE_ID } from '@angular/core'; 2 | import { registerLocaleData } from '@angular/common'; 3 | import localeZh from '@angular/common/locales/zh'; 4 | import { BrowserModule } from '@angular/platform-browser'; 5 | import { AppRoutingModule } from './app-routing.module'; 6 | import { AppComponent } from './app.component'; 7 | import { ServiceWorkerModule } from '@angular/service-worker'; 8 | import { environment } from '../environments/environment'; 9 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 10 | import { SharedModule } from './shared/shared.module'; 11 | import { APP_CONFIG } from './app.config'; 12 | 13 | registerLocaleData(localeZh, 'zh'); 14 | 15 | export function appConfigFac() { 16 | function prepareUrl() { 17 | // http://localhost:3001 18 | const port = '3001'; 19 | const l = window.location; 20 | return `${l.protocol}//${l.hostname}:${port}`; 21 | }; 22 | return { 23 | backendUrl: environment['backendUrl'] ? environment['backendUrl'] : prepareUrl() 24 | }; 25 | } 26 | 27 | @NgModule({ 28 | declarations: [ 29 | AppComponent 30 | ], 31 | imports: [ 32 | BrowserModule, 33 | AppRoutingModule, 34 | ServiceWorkerModule.register('ngsw-worker.js', { 35 | enabled: environment.production, 36 | // Register the ServiceWorker as soon as the app is stable 37 | // or after 30 seconds (whichever comes first). 38 | registrationStrategy: 'registerWhenStable:30000' 39 | }), 40 | BrowserAnimationsModule, 41 | SharedModule 42 | ], 43 | providers: [{ provide: LOCALE_ID, useValue: 'zh' }, 44 | { 45 | provide: APP_CONFIG, 46 | useFactory: appConfigFac 47 | }], 48 | bootstrap: [AppComponent] 49 | }) 50 | export class AppModule { } 51 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { SharedModule } from '../shared/shared.module'; 3 | 4 | import { VehicleSteelRoutingModule } from './vehicle-steel-routing.module'; 5 | import { VehicleSteelHomeComponent } from './vehicle-steel-home/vehicle-steel-home.component'; 6 | import { VehicleSteelWeighingSurveyComponent } from './vehicle-steel-weighing-survey/vehicle-steel-weighing-survey.component'; 7 | import { VehicleSteelWeighingSurveyDialogComponent } from './vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-survey-dialog.component'; 8 | import { VehicleSteelWeighingSurveyRecentComponent } from './vehicle-steel-weighing-survey-recent/vehicle-steel-weighing-survey-recent.component'; 9 | import { VehicleSteelWeighingSurveyDialogService } from './vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-survey-dialog.service'; 10 | import { CustomersModule } from '@app/customers/customers.module'; 11 | import { DecimalPipe } from '@angular/common'; 12 | import { VehicleSteelWeighingPrintComponent } from './vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-print/vehicle-steel-weighing-print.component'; 13 | import { VehicleSteelSurveyPrintComponent } from './vehicle-steel-weighing-survey-dialog/vehicle-steel-survey-print/vehicle-steel-survey-print.component'; 14 | 15 | 16 | 17 | @NgModule({ 18 | declarations: [ 19 | VehicleSteelHomeComponent, 20 | VehicleSteelWeighingSurveyComponent, 21 | VehicleSteelWeighingSurveyDialogComponent, 22 | VehicleSteelWeighingSurveyRecentComponent, 23 | VehicleSteelWeighingPrintComponent, 24 | VehicleSteelSurveyPrintComponent, 25 | ], 26 | imports: [ 27 | VehicleSteelRoutingModule, 28 | SharedModule, 29 | CustomersModule 30 | ], 31 | providers: [VehicleSteelWeighingSurveyDialogService, DecimalPipe], 32 | }) 33 | export class VehicleSteelModule { } 34 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-print/vehicle-steel-weighing-print.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Inject, OnInit, OnDestroy } from '@angular/core'; 2 | import { FormBuilder, FormGroup } from '@angular/forms'; 3 | import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; 4 | import { VehicleSteelWeighingSurvey } from '@app/shared/services/data/data-vehicle-steel'; 5 | import { UtilsService } from '@app/shared/services/utils.service'; 6 | import { Subject } from 'rxjs'; 7 | 8 | 9 | @Component({ 10 | selector: 'app-vehicle-steel-weighing-print', 11 | templateUrl: './vehicle-steel-weighing-print.component.html', 12 | styleUrls: ['./vehicle-steel-weighing-print.component.scss'] 13 | }) 14 | export class VehicleSteelWeighingPrintComponent implements OnInit, OnDestroy { 15 | paddingForm: FormGroup; 16 | 17 | constructor( 18 | private fb: FormBuilder, 19 | @Inject(MAT_DIALOG_DATA) public data: { vsws: VehicleSteelWeighingSurvey, pws: any[], changesSaved$$: Subject }, 20 | public utils: UtilsService, 21 | private dialogRef: MatDialogRef, 22 | 23 | ) { 24 | const paddingCache = localStorage.getItem('paddingCache') ? 25 | JSON.parse(localStorage.getItem('paddingCache') as string) : 26 | { 27 | top: 0, bottom: 0, left: 0, right: 0 28 | }; 29 | this.paddingForm = this.fb.group(paddingCache); 30 | } 31 | 32 | ngOnInit(): void { 33 | console.log(this.data); 34 | } 35 | 36 | ngOnDestroy() { 37 | if (this.paddingForm.dirty) { 38 | console.log('changed'); 39 | localStorage.setItem('paddingCache', JSON.stringify(this.paddingForm.getRawValue())); 40 | } 41 | } 42 | 43 | closeDialog() { 44 | this.dialogRef.close(); 45 | } 46 | 47 | onBtnPrintClick() { 48 | window.print(); 49 | } 50 | 51 | get padding() { 52 | const paddingObj = this.paddingForm.getRawValue(); 53 | return `${paddingObj.top}px ${paddingObj.right}px ${paddingObj.bottom}px ${paddingObj.left}px`; 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/app/shared/services/data/data-customers.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient, HttpHeaders } from '@angular/common/http'; 2 | import { Observable } from 'rxjs'; 3 | import { map } from 'rxjs/operators'; 4 | import { CalculatePatchesService } from '../calculate-patches.service'; 5 | 6 | export class Customer { 7 | _id?: any; 8 | name: string = ''; 9 | mobile?: string = ''; 10 | notes?: string = ''; 11 | createdAt?: Date; 12 | createdBy?: any; 13 | } 14 | 15 | export class DataCustomers { 16 | apiURL = this.appConfig.backendUrl + '/api/customers'; 17 | 18 | constructor( 19 | private http: HttpClient, 20 | private setHeaders: (withJWT: boolean) => HttpHeaders | { 21 | [header: string]: string | string[]; 22 | }, 23 | private appConfig: any, 24 | private calculatePatches: CalculatePatchesService 25 | ) { 26 | } 27 | search(searchParams: { [key: string]: any }): Observable { 28 | return this.http.post(this.apiURL + '/search', searchParams, { 29 | headers: this.setHeaders(true) 30 | }) as Observable; 31 | } 32 | 33 | save(customerCombo: { 34 | oldCustomer: Customer, 35 | newCustomer: Customer 36 | }) { 37 | if (customerCombo.oldCustomer._id) { 38 | // calculate patches 39 | // return this.patch(customerOld._id, []); 40 | const patches = this.calculatePatches.calculatePatches({ 41 | oldObject: customerCombo.oldCustomer, 42 | newObject: customerCombo.newCustomer, 43 | keysToIgnore: ['_id', 'createdAt', 'createdBy', 'modifiedAt', 'modifiedBy'] 44 | }); 45 | console.log(patches); 46 | return this.patch(customerCombo.oldCustomer._id, patches); 47 | } else { 48 | return this.create(customerCombo.newCustomer); 49 | } 50 | } 51 | 52 | create(newOne: Customer) { 53 | return this.http.post(this.apiURL, newOne, { 54 | headers: this.setHeaders(true) 55 | }); 56 | } 57 | 58 | patch(_id: any, patches: any[]) { 59 | return this.http.patch(this.apiURL, { 60 | _id, patches 61 | }, { 62 | headers: this.setHeaders(true) 63 | }); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-survey-print/vehicle-steel-survey-print.component.scss: -------------------------------------------------------------------------------- 1 | .t3 { 2 | display: grid; 3 | grid-template-areas: 4 | "h1 h1 h1 h1 h1" 5 | "h2 h2 h2 h2 h2" 6 | "m11 m12 m13 m14 m15" 7 | "m11 m12 m13 m14 m15" 8 | "m11 m12 m13 m14 m15" 9 | // "m11 m12 m13 m14 m15" 10 | "C1 C2 C3 C4 C5" 11 | "C1 C2 C3 C4 C5" 12 | "C1 C2 C3 C4 C5" 13 | "C1 C2 C3 C4 C5" 14 | "C1 C2 C3 C4 C5" 15 | "C1 C2 C3 C4 C5" 16 | "C1 C2 C3 C4 C5" 17 | "F1 F2 F3 F4 F5" 18 | /* "m1 m1 m2 m2 m2 m3" 19 | "T1 C1 T2 C2 T3 C3" 20 | "T1 C1 T2 C2 T3 C3" 21 | "T1 C1 T2 C2 T3 C3" 22 | "nwat nwac nwbt nwbc nwbc nwbc" */; 23 | grid-template-columns: 2fr 7fr 3fr 3fr 3fr; 24 | } 25 | 26 | .item.number { 27 | text-align: right; 28 | padding-right: 1em; 29 | } 30 | 31 | .meta11 { 32 | text-align: right; 33 | } 34 | 35 | .meta14 { 36 | text-align: right; 37 | } 38 | 39 | .footer1 { 40 | text-align: right; 41 | } 42 | .footer22 { 43 | float: right; 44 | } 45 | .footer4 { 46 | text-align: right; 47 | } 48 | 49 | 50 | .title { 51 | font-style: italic; 52 | } 53 | 54 | .content { 55 | font-size: 1.1em; 56 | } 57 | 58 | .meta1 { 59 | grid-area: m1; 60 | } 61 | .meta2 { 62 | grid-area: m2; 63 | } 64 | .meta3 { 65 | grid-area: m3; 66 | } 67 | .netweightbc { 68 | grid-area: nwbc; 69 | } 70 | 71 | .item { 72 | border-top: 1px black solid; 73 | border-left: 1px black solid; 74 | text-align: center; 75 | } 76 | 77 | .lastrow { 78 | border-bottom: 1px black solid; 79 | } 80 | .lastcolumn { 81 | border-right: 1px black solid; 82 | } 83 | 84 | .header { 85 | grid-area: h1; 86 | font-size: 1.3em; 87 | text-align: center; 88 | margin-bottom: 0.3em; 89 | } 90 | 91 | .header2 { 92 | grid-area: h2; 93 | font-size: 1.5em; 94 | text-align: center; 95 | margin-bottom: 0.3em; 96 | } 97 | 98 | .meta { 99 | margin-bottom: 0.3em; 100 | } 101 | 102 | .meta3 { 103 | text-align: right; 104 | } 105 | 106 | .text-right { 107 | text-align: right; 108 | } -------------------------------------------------------------------------------- /src/app/shared/services/data.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable } from '@angular/core'; 2 | import { DataVehicleSteel } from './data/data-vehicle-steel'; 3 | import { HttpClient, HttpHeaders, HttpRequest } from '@angular/common/http'; 4 | import { DataCustomers } from './data/data-customers'; 5 | import { DataUsers } from './data/data-users'; 6 | import { APP_CONFIG } from '@app/app.config'; 7 | import { CalculatePatchesService } from './calculate-patches.service'; 8 | import { DataPws } from './data/data-pws'; 9 | import { forkJoin, of } from 'rxjs'; 10 | import { first, switchMap, tap } from 'rxjs/operators'; 11 | import { DataPrices } from './data/data-prices'; 12 | 13 | @Injectable({ 14 | providedIn: 'root' 15 | }) 16 | export class DataService { 17 | dataVS: DataVehicleSteel; 18 | dataCustomers: DataCustomers; 19 | dataUsers: DataUsers; 20 | dataPws: DataPws; 21 | dataPrices: DataPrices; 22 | cache: {[key: string]: any} = {}; 23 | constructor( 24 | private http: HttpClient, 25 | @Inject(APP_CONFIG) private appConfig: any, 26 | private calculatePatches: CalculatePatchesService 27 | 28 | ) { 29 | this.dataVS = new DataVehicleSteel(this.http, this.setHeaders, this.appConfig); 30 | this.dataCustomers = new DataCustomers(this.http, this.setHeaders, this.appConfig, this.calculatePatches); 31 | this.dataUsers = new DataUsers(this.http, this.setHeaders, this.appConfig, this.calculatePatches); 32 | this.dataPws = new DataPws(this.http, this.setHeaders, this.appConfig, this.calculatePatches); 33 | this.dataPrices = new DataPrices(this.http, this.setHeaders, this.appConfig, this.calculatePatches); 34 | this.cacheInit(); 35 | } 36 | 37 | 38 | cacheInit() { 39 | forkJoin({ 40 | pws: this.dataPws.getPws() 41 | }).pipe(first()).subscribe(results => { 42 | this.cache = results; 43 | }); 44 | 45 | } 46 | 47 | setHeaders(withJWT: Boolean = false): HttpHeaders | { 48 | [header: string]: string | string[]; 49 | }{ 50 | let headers; 51 | if (withJWT) { 52 | const jwt = JSON.parse(localStorage.getItem('currentUser') as string)['token']; 53 | headers = { 54 | 'Content-Type': 'application/json', 55 | 'Authorization': `Bearer ${jwt}` 56 | }; 57 | } else { 58 | headers = { 'Content-Type': 'application/json' }; 59 | } 60 | return headers; 61 | } 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-recent/vehicle-steel-weighing-survey-recent.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 24 | 25 | 26 | 27 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
货车进场日期 {{element.weighing?.inWeighedAt | date: 'y-MM-dd HH:mm'}} 货车车牌号 {{element.weighing.truckPlateNo}} 18 | 净重 19 | {{ 21 | getNetWeight(element) | number 22 | }} 23 | 操作 28 | 31 |   32 | 37 |   38 | 43 | 已验质 {{!!element.survey.surveyedAt ? '是' : '否'}} 采购 {{element.weighing.customerId === '60b99776fe22ea0526faa6c9' ? '' : '是'}}
-------------------------------------------------------------------------------- /src/app/shared/services/utils.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable({ 4 | providedIn: 'root' 5 | }) 6 | export class UtilsService { 7 | 8 | constructor() { } 9 | 10 | compareObjects(object1: { [key: string]: any }, object2: { [key: string]: any }, keys: string[] = []) { 11 | function deepEqual(object1: any, object2: any) { 12 | const keys1 = Object.keys(object1); 13 | const keys2 = Object.keys(object2); 14 | 15 | if (keys1.length !== keys2.length) { 16 | return false; 17 | } 18 | 19 | for (const key of keys1) { 20 | const val1 = object1[key]; 21 | const val2 = object2[key]; 22 | const areObjects = isObject(val1) && isObject(val2); 23 | if ( 24 | areObjects && !deepEqual(val1, val2) || !areObjects && val1 !== val2 25 | ) { 26 | return false; 27 | } 28 | } 29 | 30 | return true; 31 | } 32 | 33 | function isObject(object: any) { 34 | return object != null && typeof object === 'object'; 35 | } 36 | 37 | let objectA: any = {}, objectB: any = {}; 38 | 39 | if (keys.length) { 40 | keys.forEach(key => { 41 | objectA[key] = object1[key]; 42 | objectB[key] = object2[key]; 43 | }) 44 | } else { 45 | objectA = object1; 46 | objectB = object2; 47 | } 48 | return deepEqual(objectA, objectB); 49 | } 50 | 51 | toChineseNumber(n: number) { 52 | if (!Number.isInteger(n) || n < 0) { 53 | throw Error('请输入自然数'); 54 | } 55 | 56 | const digits = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']; 57 | const positions = ['', '十', '百', '千', '万', '十万', '百万', '千万', '亿', '十亿', '百亿', '千亿']; 58 | const charArray = String(n).split(''); 59 | let result = ''; 60 | let prevIsZero = false; 61 | //处理0 deal zero 62 | for (let i = 0; i < charArray.length; i++) { 63 | const ch = charArray[i]; 64 | if (ch !== '0' && !prevIsZero) { 65 | result += digits[parseInt(ch)] + positions[charArray.length - i - 1]; 66 | prevIsZero = false; 67 | } else if (ch === '0') { 68 | prevIsZero = true; 69 | } else if (ch !== '0' && prevIsZero) { 70 | result += '零' + digits[parseInt(ch)] + positions[charArray.length - i - 1]; 71 | prevIsZero = false; 72 | } 73 | } 74 | //处理十 deal ten 75 | if (n < 100) { 76 | result = result.replace('一十', '十'); 77 | } 78 | return result; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/app/shared/shared.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 4 | import { HttpClientModule } from '@angular/common/http' 5 | import { NotFoundComponent } from './components/not-found/not-found.component'; 6 | import { LoginComponent } from './components/login/login.component'; 7 | import { DashboardComponent } from './components/dashboard/dashboard.component'; 8 | import { MatToolbarModule } from '@angular/material/toolbar'; 9 | import { MatIconModule } from '@angular/material/icon'; 10 | import { MatTabsModule } from '@angular/material/tabs'; 11 | import { MatCardModule } from '@angular/material/card'; 12 | import { MatExpansionModule } from '@angular/material/expansion'; 13 | import { MatButtonModule } from '@angular/material/button'; 14 | import { MatDialogModule } from '@angular/material/dialog'; 15 | import { MatCheckboxModule } from '@angular/material/checkbox'; 16 | import { MatTableModule } from '@angular/material/table'; 17 | import { MatTooltipModule } from '@angular/material/tooltip'; 18 | import { MatInputModule } from '@angular/material/input'; 19 | import { MatAutocompleteModule } from '@angular/material/autocomplete'; 20 | import { MatDividerModule } from '@angular/material/divider' 21 | import { LoadingComponent } from './components/loading/loading.component'; 22 | import { AlertComponent } from './services/alert/alert.component'; 23 | import { MatSelectModule } from '@angular/material/select'; 24 | 25 | const materialModules = [ 26 | MatToolbarModule, 27 | MatIconModule, 28 | MatTabsModule, 29 | MatCardModule, 30 | MatExpansionModule, 31 | MatButtonModule, 32 | MatDialogModule, 33 | MatCheckboxModule, 34 | MatTableModule, 35 | MatTooltipModule, 36 | MatInputModule, 37 | MatAutocompleteModule, 38 | MatDividerModule, 39 | MatSelectModule 40 | ]; 41 | 42 | 43 | @NgModule({ 44 | declarations: [ 45 | NotFoundComponent, 46 | LoginComponent, 47 | DashboardComponent, 48 | LoadingComponent, 49 | AlertComponent, 50 | ], 51 | imports: [ 52 | CommonModule, 53 | HttpClientModule, 54 | ReactiveFormsModule, 55 | FormsModule, 56 | ...materialModules 57 | ], 58 | exports: [ 59 | CommonModule, 60 | ReactiveFormsModule, 61 | FormsModule, 62 | ...materialModules, 63 | // MatToolbarModule, 64 | // MatIconModule, 65 | // MatTabsModule 66 | ] 67 | }) 68 | export class SharedModule { } 69 | -------------------------------------------------------------------------------- /src/app/shared/services/calculate-patches.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import jsonpatch from 'fast-json-patch'; 3 | 4 | export interface CalculatePatchesInput { 5 | oldObject: { [key: string]: any }; 6 | newObject: { [key: string]: any }; 7 | keysToIgnore?: string[]; 8 | objectTemplate?: { [key: string]: any }; 9 | } 10 | 11 | @Injectable({ 12 | providedIn: 'root' 13 | }) 14 | export class CalculatePatchesService { 15 | 16 | constructor() { } 17 | 18 | trimObject(objectN: { [key: string]: any }, objectTemplate: { [key: string]: any }) { 19 | const objectY: { [key: string]: any } = {}; 20 | const applyX = (objectX: { [key: string]: any }, objectTemplateX: { [key: string]: any }, objectY: { [key: string]: any }) => { 21 | Object.keys(objectTemplateX).forEach(keyXX => { 22 | // console.log('on', keyXX); 23 | if (objectTemplateX[keyXX] && (typeof objectTemplateX[keyXX] !== 'object')) { 24 | objectY[keyXX] = objectX[keyXX]; 25 | } else { 26 | if (objectTemplateX[keyXX] && (typeof objectTemplateX[keyXX] === 'object')) { 27 | // console.log('working on subobject') 28 | objectY[keyXX] = {}; 29 | objectY[keyXX] = applyX(objectX[keyXX], objectTemplateX[keyXX], objectY[keyXX]) 30 | } else { 31 | // do nothing 32 | } 33 | } 34 | }); 35 | return objectY; 36 | } 37 | applyX(objectN, objectTemplate, objectY); 38 | return objectY; 39 | } 40 | 41 | calculatePatches(input: CalculatePatchesInput) { 42 | let patchesPrepare; 43 | if (input.keysToIgnore) { 44 | const prepareObject = (objectX: { [key: string]: any }, keysToIgnore: string[]) => { 45 | const objectY: { [key: string]: any } = {}; 46 | Object.keys(objectX).filter(keyX => keysToIgnore.indexOf(keyX) === -1).forEach(keyX => { 47 | objectY[keyX] = objectX[keyX]; 48 | }); 49 | return objectY; 50 | } 51 | patchesPrepare = jsonpatch.compare( 52 | prepareObject(input.oldObject, input.keysToIgnore), 53 | prepareObject(input.newObject, input.keysToIgnore), 54 | ); 55 | 56 | } else { 57 | if (input.objectTemplate) { 58 | patchesPrepare = jsonpatch.compare( 59 | this.trimObject(input.oldObject, input.objectTemplate), 60 | this.trimObject(input.newObject, input.objectTemplate), 61 | ); 62 | } else { 63 | throw ('bad option for calculate patches'); 64 | } 65 | 66 | } 67 | return patchesPrepare.map(patch => { 68 | if (patch.op === 'add') { 69 | (patch as any).op = 'replace'; 70 | } 71 | return patch; 72 | }); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * IE11 requires the following for NgClass support on SVG elements 23 | */ 24 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 25 | 26 | /** 27 | * Web Animations `@angular/platform-browser/animations` 28 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 29 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 30 | */ 31 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 32 | 33 | /** 34 | * By default, zone.js will patch all possible macroTask and DomEvents 35 | * user can disable parts of macroTask/DomEvents patch by setting following flags 36 | * because those flags need to be set before `zone.js` being loaded, and webpack 37 | * will put import in the top of bundle, so user need to create a separate file 38 | * in this directory (for example: zone-flags.ts), and put the following flags 39 | * into that file, and then add the following code before importing zone.js. 40 | * import './zone-flags'; 41 | * 42 | * The flags allowed in zone-flags.ts are listed here. 43 | * 44 | * The following flags will work for all browsers. 45 | * 46 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 47 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 48 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 49 | * 50 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 51 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 52 | * 53 | * (window as any).__Zone_enable_cross_context_check = true; 54 | * 55 | */ 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by default for Angular itself. 59 | */ 60 | import 'zone.js'; // Included with Angular CLI. 61 | 62 | 63 | /*************************************************************************************************** 64 | * APPLICATION IMPORTS 65 | */ 66 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey/vehicle-steel-weighing-survey.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } from '@angular/core'; 2 | import { MatDialog } from '@angular/material/dialog'; 3 | import { DataService } from "@app/shared/services/data.service"; 4 | import { Observable, BehaviorSubject, of, combineLatest } from 'rxjs'; 5 | import { map, startWith, switchMap, tap } from 'rxjs/operators'; 6 | import { VehicleSteelWeighingSurveyDialogService } from '@app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-survey-dialog.service'; 7 | import { LoadingComponent } from '@app/shared/components/loading/loading.component'; 8 | 9 | @Component({ 10 | selector: 'app-vehicle-steel-weighing-survey', 11 | templateUrl: './vehicle-steel-weighing-survey.component.html', 12 | styleUrls: ['./vehicle-steel-weighing-survey.component.scss'] 13 | }) 14 | export class VehicleSteelWeighingSurveyComponent implements OnInit { 15 | @Input() isOutbound: boolean = false; 16 | title = ''; 17 | public vswsRecentList$?: Observable 18 | filterSurveyDone$$ = new BehaviorSubject(false); 19 | filterIsProc$$ = new BehaviorSubject(false); 20 | 21 | constructor( 22 | private backend: DataService, 23 | private dialog: MatDialog, 24 | public vswsDialog: VehicleSteelWeighingSurveyDialogService 25 | ) { } 26 | 27 | onCreate() { 28 | this.vswsDialog.openDialog(undefined, undefined, this.isOutbound) 29 | .pipe( 30 | switchMap(dialogRef => { 31 | return dialogRef.afterClosed(); 32 | }) 33 | ) 34 | .subscribe(result => { 35 | console.log({ editResult: result }); 36 | // if changed, reload recent 37 | }) 38 | } 39 | 40 | ngOnInit(): void { 41 | this.title = this.isOutbound ? '近期出场物资' : '近期进场物资'; 42 | console.log({ 43 | isOutbound: this.isOutbound 44 | }) 45 | const loadingDialogRef = this.dialog.open(LoadingComponent, { 46 | disableClose: true, 47 | data: { 48 | message: '正在载入近期废钢进场记录...' 49 | } 50 | }); 51 | this.vswsRecentList$ = this.vswsDialog.changesSaved$$.pipe( 52 | startWith(null), 53 | switchMap(() => { 54 | return this.backend.dataVS.getRecent(this.isOutbound) 55 | }), 56 | switchMap((vswsRecentList) => { 57 | vswsRecentList = vswsRecentList.sort((a, b) => { 58 | return Date.parse(b.createdAt) - Date.parse(a.createdAt); 59 | }); 60 | return combineLatest([this.filterSurveyDone$$, this.filterIsProc$$]) 61 | .pipe( 62 | map((combo) => { 63 | const [showOnlySurveyNotDone, showOnlyIsProc] = combo; 64 | let theList = showOnlySurveyNotDone ? vswsRecentList.filter(item => !!item.survey.surveyedAt === false) : vswsRecentList; 65 | theList = showOnlyIsProc ? theList.filter(item => item.weighing.customerId !== '60b99776fe22ea0526faa6c9') : theList; 66 | return theList; 67 | }), 68 | tap(() => { 69 | loadingDialogRef.close(); 70 | }) 71 | ) 72 | 73 | }) 74 | ) 75 | 76 | } 77 | 78 | } 79 | 80 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-recent/vehicle-steel-weighing-survey-recent.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } from '@angular/core'; 2 | import { MatDialog } from '@angular/material/dialog'; 3 | 4 | import { VehicleSteelWeighingSurvey } from '@app/shared/services/data/data-vehicle-steel'; 5 | import { VehicleSteelWeighingSurveyDialogService } from '@app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-survey-dialog.service'; 6 | import { switchMap } from 'rxjs/operators'; 7 | 8 | 9 | @Component({ 10 | selector: 'app-vehicle-steel-weighing-survey-recent', 11 | templateUrl: './vehicle-steel-weighing-survey-recent.component.html', 12 | styleUrls: ['./vehicle-steel-weighing-survey-recent.component.scss'] 13 | }) 14 | export class VehicleSteelWeighingSurveyRecentComponent implements OnInit { 15 | @Input() vswsRecentList: VehicleSteelWeighingSurvey[] = []; 16 | @Input() isOutbound = false; 17 | // vswsRecentList$: Observable 18 | displayedColumns: string[] = []; 19 | constructor( 20 | // private backend: DataService, 21 | public dialog: MatDialog, 22 | public vswsDialog: VehicleSteelWeighingSurveyDialogService 23 | 24 | ) { 25 | // this.vswsRecentList$ = this.backend.dataVS.getRecent(); 26 | 27 | } 28 | 29 | ngOnInit(): void { 30 | this.displayedColumns = this.isOutbound ? [ 31 | '_id', 'truckPlateNo', 'netWeight', 'operations', /* 'print' */ 32 | ] : [ 33 | '_id', 'truckPlateNo', 'netWeight', 'surveyDone', 'isProc', 'operations', /* 'print' */ 34 | ] 35 | } 36 | 37 | onEdit(item: any) { 38 | console.log('on edit'); 39 | this.vswsDialog.openDialog(item) 40 | .pipe( 41 | switchMap(dialogRef => { 42 | return dialogRef.afterClosed(); 43 | }) 44 | ) 45 | .subscribe(result => { 46 | console.log({ editResult: result }); 47 | // if changed, reload recent 48 | }) 49 | } 50 | 51 | 52 | 53 | onPrint(item: VehicleSteelWeighingSurvey) { 54 | console.log('on printWeighing'); 55 | this.vswsDialog.openDialog(item, 'printWeighing') 56 | .pipe( 57 | switchMap(dialogRef => { 58 | return dialogRef.afterClosed(); 59 | }) 60 | ) 61 | .subscribe(result => { 62 | console.log({ editResult: result }); 63 | // if changed, reload recent 64 | }) 65 | } 66 | 67 | getNetWeight(item: VehicleSteelWeighingSurvey) { 68 | return item.isOutbound ? ( 69 | (item.weighing?.inWeightKG && item.weighing?.outWeightKG) ? 70 | (item.weighing?.outWeightKG - item.weighing?.inWeightKG) : 71 | 0 72 | ) : ( 73 | (item.weighing?.inWeightKG && item.weighing?.outWeightKG) ? 74 | (item.weighing?.inWeightKG - item.weighing?.outWeightKG) : 75 | 0 76 | ); 77 | 78 | 79 | } 80 | 81 | onPrintB(item: VehicleSteelWeighingSurvey) { 82 | // printing inventory entry receipt 83 | console.log('on printSurvey'); 84 | this.vswsDialog.openDialog(item, 'printSurvey') 85 | .pipe( 86 | switchMap(dialogRef => { 87 | return dialogRef.afterClosed(); 88 | }) 89 | ) 90 | .subscribe(result => { 91 | console.log({ editResult: result }); 92 | // if changed, reload recent 93 | }) 94 | } 95 | 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-print/vehicle-steel-weighing-print.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 上部缩进 5 | 6 | 7 | 8 | 15 |   16 | 17 | 18 | 左侧缩进 19 | 20 | 21 | 22 |   23 | 24 | 25 | 右侧缩进 26 | 27 | 28 | 29 |   30 | 33 | 36 | 37 |
38 | 39 |
40 |
辽宁隆运环保科技股份有限公司 - 过磅单(物资进场)(物资出场)
41 |
序号:{{data.vsws.weighing?.inWeighedAt | date: 'yMMddHHmm'}}
42 |
43 |
单位:公斤
44 | 45 |
车号
46 |
{{data.vsws.weighing.truckPlateNo}}
47 |
物资
48 |
车辆废钢
49 |
客户
50 |
{{data.vsws.weighing.customerName}}
51 | 52 |
毛重皮重
53 |
{{data.vsws.weighing.inWeightKG | number}}
54 |
司磅员
55 |
超级权限
56 |
日期
57 |
{{data.vsws.weighing?.inWeighedAt | date: 'y-MM-dd HH:mm'}}
58 | 59 |
皮重毛重
60 |
{{data.vsws.weighing.outWeightKG | number}}
61 |
司磅员
62 |
超级权限
63 |
日期
64 |
{{data.vsws.weighing?.outWeighedAt | date: 'y-MM-dd HH:mm'}}
65 | 66 |
净重
67 |
{{(data.vsws.weighing.inWeightKG - data.vsws.weighing.outWeightKG) * (data.vsws.isOutbound ? -1 : 1) | 68 | number}}
69 |
净重大写
70 |
71 | {{utils.toChineseNumber((data.vsws.weighing.inWeightKG - data.vsws.weighing.outWeightKG) * (data.vsws.isOutbound ? -1 : 1))}} 72 |
73 | 74 | 75 |
-------------------------------------------------------------------------------- /src/app/customers/customer-dialog/customer-dialog.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Inject, OnInit } from '@angular/core'; 2 | import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; 3 | import { Customer } from '@app/shared/services/data/data-customers'; 4 | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; 5 | import { Observable, of } from 'rxjs'; 6 | import { catchError, first, tap } from 'rxjs/operators'; 7 | import { UtilsService } from '@app/shared/services/utils.service'; 8 | import { DataService } from '@app/shared/services/data.service'; 9 | import { AlertService } from '@app/shared/services/alert/alert.service'; 10 | 11 | @Component({ 12 | selector: 'app-customer-dialog', 13 | templateUrl: './customer-dialog.component.html', 14 | styleUrls: ['./customer-dialog.component.scss'] 15 | }) 16 | export class CustomerDialogComponent implements OnInit { 17 | formX: FormGroup; 18 | dialogTitle: string; 19 | status$: Observable = of(); 20 | status = { 21 | changed: false 22 | }; 23 | constructor( 24 | private fb: FormBuilder, 25 | @Inject(MAT_DIALOG_DATA) public data: { customer: Customer }, 26 | private dialogRef: MatDialogRef, 27 | private utils: UtilsService, 28 | private backend: DataService, 29 | private alert: AlertService 30 | ) { 31 | 32 | this.dialogTitle = this.data.customer._id ? '编辑客户' : '新建客户' 33 | this.formX = this.fb.group({ 34 | _id: [this.data.customer._id], 35 | name: [{value: this.data.customer.name, disabled: !!this.data.customer._id}, Validators.required], 36 | mobile: [this.data.customer.mobile, [Validators.required, Validators.pattern(/^[0-9]*$/)]], 37 | notes: [this.data.customer.notes] 38 | }) 39 | } 40 | 41 | ngOnInit(): void { 42 | this.status$ = this.formX.valueChanges 43 | .pipe( 44 | tap(value => { 45 | // this.status.changed = (value.name === this.data.customer.name) || () || () 46 | // console.log(value); 47 | this.status.changed = !this.utils.compareObjects(this.formX.getRawValue(), this.data.customer, [ 48 | 'name', 'mobile', 'notes' 49 | ]); 50 | console.log('status', this.status) 51 | }) 52 | ) 53 | } 54 | 55 | onSubmit() { 56 | console.log('at onSubmit'); 57 | // save to server 58 | const newCustomer = this.formX.getRawValue(); 59 | const oldCustomer = this.data.customer ; 60 | this.backend.dataCustomers.save({ 61 | newCustomer, 62 | oldCustomer 63 | }).pipe( 64 | first(), 65 | catchError(error => of(error)) 66 | ).subscribe(res => { 67 | console.log(res); 68 | if (res.collection_upsert || res._id) { 69 | if (oldCustomer._id) { 70 | // patching old customer 71 | this.dialogRef.close(newCustomer); 72 | } else { 73 | // creating new customer 74 | this.dialogRef.close(res); 75 | } 76 | } else { 77 | console.log('got error'); 78 | console.log(res); 79 | } 80 | }) 81 | } 82 | 83 | onCancel() { 84 | console.log('at onCancel'); 85 | if (this.status.changed) { 86 | // alert changed 87 | const alertDialogRef = this.alert.openDialog({ 88 | title: '内容已变更', 89 | message: '是否放弃更改?' 90 | }); 91 | alertDialogRef.afterClosed().pipe( 92 | first() 93 | ).subscribe(alertConfirmed => { 94 | if (alertConfirmed) { 95 | // confirm discarding the changes 96 | this.dialogRef.close(); 97 | } 98 | }) 99 | } else { 100 | console.log('no change'); 101 | this.dialogRef.close(); 102 | } 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/app/shared/services/auth.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable } from '@angular/core'; 2 | import { HttpClient } from '@angular/common/http'; 3 | import { APP_CONFIG } from '@app/app.config'; 4 | import { map } from 'rxjs/operators'; 5 | import { environment } from '../../../environments/environment'; 6 | import { JsonPatchError } from 'fast-json-patch/module/core'; 7 | import { User } from './data/data-users'; 8 | import jwt_decode from "jwt-decode"; 9 | 10 | 11 | @Injectable({ 12 | providedIn: 'root' 13 | }) 14 | export class AuthService { 15 | backendUrl = this.appConfig.backendUrl; 16 | isLoggedIn = false; 17 | displayName = ''; 18 | constructor( 19 | private http: HttpClient, 20 | @Inject(APP_CONFIG) private appConfig: any 21 | ) { 22 | this.checkLoginStatus(); 23 | } 24 | 25 | getCurrentUser(): User | null { 26 | const cu = localStorage.getItem('currentUser'); 27 | if (cu) { 28 | return JSON.parse(cu); 29 | } else { 30 | return null; 31 | } 32 | } 33 | 34 | getJwtPayload(token: string) { 35 | if (!token) { 36 | console.log('no token provided'); 37 | return; 38 | } 39 | const parts = token.split('.'); 40 | return JSON.parse(atob(parts[1])); 41 | } 42 | 43 | checkLoginStatus(): void { 44 | const currentUserStr = localStorage.getItem('currentUser'); 45 | if (currentUserStr) { 46 | const currentUser = JSON.parse(currentUserStr); 47 | if ( 48 | currentUser.token && 49 | this.getJwtPayload(currentUser.token)['exp'] > (Math.ceil(Date.now() / 1000))) { 50 | this.isLoggedIn = true; 51 | this.displayName = currentUser.displayName; 52 | } 53 | } 54 | } 55 | 56 | getAppConfig() { 57 | console.log(this.appConfig); 58 | } 59 | 60 | authenticate(user: { username: string, password: string }) { 61 | console.log('authenticating at backend', this.backendUrl); 62 | const authenticateUrl = environment.authUrl ? environment.authUrl : `${this.backendUrl}/authenticate`; 63 | const authReq = environment.authUrl ? this.http.post(authenticateUrl, { 64 | username: user.username, 65 | password: user.password 66 | }, { params: { path: 'authx' } }) : this.http.post(authenticateUrl, { 67 | username: user.username, 68 | password: user.password 69 | }); 70 | return authReq 71 | .pipe( 72 | map((res: any) => { 73 | // console.log(res); 74 | const token = res['token']; 75 | const decodedJwt: any = jwt_decode(token); 76 | const displayName = res['displayName']; 77 | const settings = res['settings']; 78 | localStorage.setItem('currentUser', JSON.stringify({ 79 | _id: decodedJwt?.sub._id, 80 | username: user.username, 81 | displayName, 82 | token, 83 | settings 84 | })); 85 | this.isLoggedIn = true; 86 | }) 87 | ) 88 | 89 | 90 | 91 | // .map(res => { 92 | // if (res.json() && res.json()['token']) { 93 | // // console.log(res.json()); 94 | // const token = res.json()['token']; 95 | // const displayName = res.json()['displayName']; 96 | // const settings = res.json()['settings']; 97 | // localStorage.setItem('currentUser', JSON.stringify({ 98 | // username: user.username, 99 | // displayName, 100 | // token, 101 | // settings 102 | // })); 103 | // // this.isLoggedInRxx.next(true); 104 | // // const x = JSON.parse(localStorage.getItem('currentUser')); 105 | // // console.log(x.token); 106 | // // this.backend.rtcSocketInit(); 107 | // this.redirectAfterSuccess(); 108 | // return {ok: true}; 109 | // } 110 | // return {ok: false}; 111 | // }) 112 | // .catch(err => { 113 | // if (err.status === 401) { 114 | // return Observable.of({ 115 | // ok: false, 116 | // errorCode: 401, 117 | // error: 'Unauthorized' 118 | // }); 119 | // } 120 | // return this.handleError(err); 121 | // }); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "lyfront-vs": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "style": "scss" 11 | }, 12 | "@schematics/angular:application": { 13 | "strict": true 14 | } 15 | }, 16 | "root": "", 17 | "sourceRoot": "src", 18 | "prefix": "app", 19 | "architect": { 20 | "build": { 21 | "builder": "@angular-devkit/build-angular:browser", 22 | "options": { 23 | "outputPath": "dist/lyfront-vs", 24 | "index": "src/index.html", 25 | "main": "src/main.ts", 26 | "polyfills": "src/polyfills.ts", 27 | "tsConfig": "tsconfig.app.json", 28 | "inlineStyleLanguage": "scss", 29 | "assets": [ 30 | "src/favicon.ico", 31 | "src/assets", 32 | "src/manifest.webmanifest" 33 | ], 34 | "styles": [ 35 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 36 | "src/styles.scss" 37 | ], 38 | "scripts": [], 39 | "serviceWorker": true, 40 | "ngswConfigPath": "ngsw-config.json" 41 | }, 42 | "configurations": { 43 | "production": { 44 | "budgets": [ 45 | { 46 | "type": "initial", 47 | "maximumWarning": "1mb", 48 | "maximumError": "3mb" 49 | }, 50 | { 51 | "type": "anyComponentStyle", 52 | "maximumWarning": "2kb", 53 | "maximumError": "4kb" 54 | } 55 | ], 56 | "fileReplacements": [ 57 | { 58 | "replace": "src/environments/environment.ts", 59 | "with": "src/environments/environment.prod.ts" 60 | } 61 | ], 62 | "outputHashing": "all" 63 | }, 64 | "development": { 65 | "buildOptimizer": false, 66 | "optimization": false, 67 | "vendorChunk": true, 68 | "extractLicenses": false, 69 | "sourceMap": true, 70 | "namedChunks": true 71 | } 72 | }, 73 | "defaultConfiguration": "production" 74 | }, 75 | "serve": { 76 | "builder": "@angular-devkit/build-angular:dev-server", 77 | "configurations": { 78 | "production": { 79 | "browserTarget": "lyfront-vs:build:production" 80 | }, 81 | "development": { 82 | "browserTarget": "lyfront-vs:build:development" 83 | } 84 | }, 85 | "defaultConfiguration": "development", 86 | "options":{ 87 | "sslKey": "../0-commons/ssl/lyvs/cert.key", 88 | "sslCert": "../0-commons/ssl/lyvs/cert.crt" 89 | } 90 | }, 91 | "extract-i18n": { 92 | "builder": "@angular-devkit/build-angular:extract-i18n", 93 | "options": { 94 | "browserTarget": "lyfront-vs:build" 95 | } 96 | }, 97 | "test": { 98 | "builder": "@angular-devkit/build-angular:karma", 99 | "options": { 100 | "main": "src/test.ts", 101 | "polyfills": "src/polyfills.ts", 102 | "tsConfig": "tsconfig.spec.json", 103 | "karmaConfig": "karma.conf.js", 104 | "inlineStyleLanguage": "scss", 105 | "assets": [ 106 | "src/favicon.ico", 107 | "src/assets", 108 | "src/manifest.webmanifest" 109 | ], 110 | "styles": [ 111 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 112 | "src/styles.scss" 113 | ], 114 | "scripts": [] 115 | } 116 | } 117 | } 118 | } 119 | }, 120 | "defaultProject": "lyfront-vs" 121 | } 122 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-survey-print/vehicle-steel-survey-print.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 上部缩进 5 | 6 | 7 | 8 | 15 |   16 | 17 | 18 | 左侧缩进 19 | 20 | 21 | 22 |   23 | 24 | 25 | 右侧缩进 26 | 27 | 28 | 29 |   30 | 33 | 36 | 37 | 38 |
39 | 40 |
41 |
辽宁隆运环保科技股份有限公司
42 |
43 | 入库结算单【出库】结算单 44 |
45 | 48 | 49 |
结算单位:
50 |
{{data.vsws.weighing.customerName}}
51 |
52 |
结算单号:
53 |
{{data.vsws.weighing?.inWeighedAt | date: 'yMMddHHmm'}}
54 | 55 |
发票单位:
56 |
{{data.vsws.weighing.customerName}}
57 |
58 |
车号:
59 |
{{data.vsws.weighing.truckPlateNo}}
60 | 61 |
价格表:
62 |
采购
63 |
64 |
代垫运费:
65 |
0
66 | 67 | 72 | 73 |
产品代码
74 |
产品名称
75 |
结算数量(吨)
76 |
结算价格(元/吨)
77 |
结算金额(元)
78 | 79 | 80 |
{{material ? getPwCode(material) : ''}} 
81 |
{{material ? getPwName(material) : ''}}
82 |
{{material ? (getWeightTon(material) | number: '1.2-2' ) : ''}}
83 | 85 |
{{material ? (getTaxExclPrice(material) * 1000 | number: '1.2-2') : ''}}
86 |
{{material ? (getAmount(material) | number: '1.2-2') : ''}}
87 |
88 | 89 | 90 | 91 | 92 |
93 |
{{'合计(含税,税点' + data.vsws.taxRatio + '):'}}
94 |
{{getTotalWeightTon(data.vsws.survey.materials) | number: '1.2-2'}}
95 |
{{getAveragePrice(data.vsws.survey.materials) | number: '1.2-2'}}
96 |
{{getTotalAmount(data.vsws.survey.materials) | number: '1.2-2'}}
97 | 98 |
打印日期:
99 |
100 | {{todayDate | date: 'y-MM-dd HH:mm'}} 101 | 结算人员: 102 |
103 |
{{userName}}
104 |
负责人:
105 |
106 | 107 | 108 | 109 | 110 |
-------------------------------------------------------------------------------- /src/app/shared/services/data/data-vehicle-steel.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient, HttpHeaders } from '@angular/common/http'; 2 | import { forkJoin, Observable, of } from 'rxjs'; 3 | import { map } from 'rxjs/operators'; 4 | 5 | export interface VehicleSteelWeighing { 6 | truckPlateNo: string, 7 | customerId?: any, 8 | customerName?: string, // delete before patch 9 | customerTel?: string, // delete before patch 10 | inWeightKG: number, 11 | inWeighedAt?: Date, 12 | inWeighedBy?: any, 13 | inWeighedByName?: string, 14 | outWeightKG: number, 15 | outWeighedAt?: Date, 16 | outWeighedBy?: any, 17 | outWeighedByName?: any, 18 | notes?: string 19 | } 20 | 21 | export interface VehicleSteelSurvey { 22 | surveyedBy?: any; 23 | surveyedByName?: any; 24 | surveyedAt?: Date; 25 | materials: SurveyedMaterial[]; 26 | } 27 | 28 | export class SurveyedMaterial { 29 | _id?: any; 30 | pwId?: any; 31 | weightKG?: number; 32 | count?: number; 33 | cost?: number; 34 | price?: number; 35 | notes?: string; 36 | inventoryId?: any; 37 | createdAt?: Date; 38 | createdBy?: any; 39 | modifiedAt?: Date; 40 | modifiedBy?: any; 41 | isDeleted?: boolean; 42 | deletedAt?: Date; 43 | deletedBy?: any; 44 | deleteNote?: string; 45 | } 46 | 47 | export class VehicleSteelWeighingSurvey { 48 | _id?: any = null; 49 | createdAt?: any = null; 50 | createdBy?: any = null; 51 | modifiedAt?: any = null; 52 | modifiedBy?: any = null; 53 | isDeleted?: any = false; 54 | deletedAt?: any = null; 55 | deletedBy?: any = null; 56 | deletedNotes?: any = null; 57 | taxRatio?: number; 58 | isOutbound: boolean; // when false, it's inbound 59 | weighing: VehicleSteelWeighing = { 60 | truckPlateNo: '', 61 | customerId: '', 62 | notes: '', 63 | inWeightKG: 0, 64 | inWeighedBy: '', 65 | inWeighedAt: new Date(), 66 | outWeightKG: 0, 67 | outWeighedBy: '' 68 | }; 69 | survey: VehicleSteelSurvey = { 70 | surveyedBy: '', 71 | materials: [] 72 | } 73 | changeLogs?: any[] = []; // delete before patch 74 | constructor(/* creatorUserId: any */isOutbound = false) { 75 | // this.weighing.inWeighedBy = creatorUserId; 76 | this.isOutbound = isOutbound; 77 | } 78 | } 79 | 80 | 81 | export class DataVehicleSteel { 82 | apiURL = this.appConfig.backendUrl + '/api/vehicle-steel'; 83 | 84 | 85 | constructor( 86 | private http: HttpClient, 87 | private setHeaders: (withJWT: boolean) => HttpHeaders | { 88 | [header: string]: string | string[]; 89 | }, 90 | private appConfig: any, 91 | ) { 92 | 93 | } 94 | 95 | getRecent(isOutbound = false): Observable { 96 | // get items 97 | // 1) inWeighed within 7 days; 98 | // 2) inWeighed 7 days earlier and survey not done 99 | 100 | const dateX = new Date(); 101 | // recent 7 days 102 | // use recent 30 days 103 | dateX.setDate(dateX.getDate() - 29); 104 | const dateBeginningX = new Date(dateX.toISOString().substr(0, 10)); 105 | dateBeginningX.setHours(0); // 00hours of +8000 106 | const query1 = { 107 | createdAt: { $gte: new Date(dateBeginningX) }, 108 | isOutbound: isOutbound ? true : {$ne: true} 109 | }; 110 | const query2 = { 111 | createdAt: { $lt: new Date(dateBeginningX) }, 112 | 'survey.surveyedBy': '' 113 | }; 114 | 115 | const searchOp = isOutbound ? this.search(query1) : forkJoin({ 116 | within7days: this.search(query1), 117 | over7daysNotSurveyed: this.search(query2) 118 | }).pipe( 119 | map(result => { 120 | return [...result.within7days, ...result.over7daysNotSurveyed] 121 | }) 122 | ) 123 | 124 | return searchOp; 125 | // return of(this.weighingSurveyEntries); 126 | } 127 | 128 | insert(newOne: VehicleSteelWeighingSurvey) { 129 | return this.http.post(this.apiURL, newOne, { 130 | headers: this.setHeaders(true) 131 | }); 132 | } 133 | 134 | update(patchesObj: { 135 | _id: string, 136 | vswsPatches?: any[], 137 | materials?: { _id?: string, obj?: any, patches?: any[] }[] 138 | }) { 139 | console.log(patchesObj) 140 | return this.http.patch(this.apiURL + '/one', patchesObj, { 141 | headers: this.setHeaders(true) 142 | }) as Observable; 143 | } 144 | 145 | search(searchParams: { [key: string]: any }): Observable { 146 | return this.http.post(this.apiURL + '/search', searchParams, { 147 | headers: this.setHeaders(true) 148 | }) as Observable; 149 | } 150 | 151 | 152 | 153 | 154 | } 155 | 156 | // export interface VehicleSteelWeighingSurvey { 157 | // id?: any; 158 | // truckPlateNo: string; 159 | // grossWeight: number; 160 | // wDate?: Date; 161 | // sDate?: Date; 162 | // surveyDone: boolean; 163 | // } 164 | 165 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-survey-print/vehicle-steel-survey-print.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Inject, OnInit } from '@angular/core'; 2 | import { FormBuilder, FormGroup, FormControl } from '@angular/forms'; 3 | import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; 4 | import { AuthService } from '@app/shared/services/auth.service'; 5 | import { SurveyedMaterial, VehicleSteelWeighingSurvey } from '@app/shared/services/data/data-vehicle-steel'; 6 | import { UtilsService } from '@app/shared/services/utils.service'; 7 | import { Subject } from 'rxjs'; 8 | 9 | 10 | @Component({ 11 | selector: 'app-vehicle-steel-survey-print', 12 | templateUrl: './vehicle-steel-survey-print.component.html', 13 | styleUrls: ['./vehicle-steel-survey-print.component.scss'] 14 | }) 15 | export class VehicleSteelSurveyPrintComponent implements OnInit { 16 | 17 | paddingForm: FormGroup; 18 | materialsArr: any[]; 19 | selectedPws: any[]; 20 | todayDate = new Date(); 21 | userName: any; 22 | valueLessPwId = '60b046d142632c04fb202b57'; 23 | taxRatioCtrl = new FormControl(); 24 | 25 | constructor( 26 | private auth: AuthService, 27 | private fb: FormBuilder, 28 | @Inject(MAT_DIALOG_DATA) public data: { vsws: VehicleSteelWeighingSurvey, pws: any[], prices: any[], changesSaved$$: Subject }, 29 | public utils: UtilsService, 30 | private dialogRef: MatDialogRef, 31 | 32 | ) { 33 | this.userName = this.auth.getCurrentUser()?.displayName; 34 | // this.userName = 'a'; 35 | 36 | const paddingCache = localStorage.getItem('surveyPrintPaddingCache') ? 37 | JSON.parse(localStorage.getItem('surveyPrintPaddingCache') as string) : 38 | { 39 | top: 0, bottom: 0, left: 0, right: 0 40 | }; 41 | this.paddingForm = this.fb.group(paddingCache); 42 | this.materialsArr = this.prepareMaterialsArr(this.data.vsws.survey.materials); 43 | this.selectedPws = this.data.pws.filter(pw => pw.name.indexOf('废钢') > -1 && pw.name.indexOf('公斤') > -1); 44 | } 45 | 46 | prepareMaterialsArr(materials: SurveyedMaterial[]) { 47 | // at least 5 rows 48 | if (materials.length > 4) { 49 | return materials; 50 | } else { 51 | const thatArr = Array(5).fill(null).map((item, index) => { 52 | return materials[index] ? materials[index] : null 53 | }); 54 | console.log(thatArr); 55 | return thatArr; 56 | } 57 | } 58 | 59 | getPwCode(material: SurveyedMaterial) { 60 | const pwName = this.getPwName(material); 61 | switch (true) { 62 | case pwName.indexOf('轻薄料') > -1: 63 | return 23; 64 | case pwName.indexOf('中型') > -1: 65 | return '待查'; 66 | case pwName.indexOf('汽油') > -1: 67 | return '待查'; 68 | case pwName.indexOf('柴油') > -1: 69 | return '待查'; 70 | case pwName.indexOf('杂质') > -1: 71 | return 27; 72 | default: 73 | return '待查' 74 | } 75 | } 76 | 77 | getWeightTon(material: SurveyedMaterial) { 78 | return ((material.weightKG as number) / 1000); 79 | } 80 | 81 | getTotalWeightTon(materials: SurveyedMaterial[]) { 82 | // filter out 杂质 60b046d142632c04fb202b57 83 | return materials.reduce((acc, curr) => { 84 | return curr.pwId !== this.valueLessPwId ? 85 | (curr.weightKG ? (curr.weightKG as number) / 1000 + acc : acc) : 86 | acc; 87 | }, 0) 88 | } 89 | 90 | getTaxExclPrice(material: SurveyedMaterial) { 91 | const taxRatio = this.data.vsws.taxRatio || 0; 92 | const price = material.price || 0; 93 | return price * (1 - taxRatio / 100); 94 | } 95 | 96 | getTotalAmount(materials: SurveyedMaterial[]) { 97 | // const totalAmount0 = materials.reduce((acc, curr) => { 98 | // return curr.pwId !== this.valueLessPwId ? 99 | // (curr.price ? (curr.price as number) * (curr.weightKG as number) + acc : acc) : 100 | // acc; 101 | // }, 0) 102 | // return totalAmount0 * (1 + (this.data.vsws.taxRatio ? this.data.vsws.taxRatio * 0.01 : 0)); 103 | const totalAmount0 = materials.reduce((acc, curr) => { 104 | return curr.price ? (curr.price as number) * (curr.weightKG as number) + acc : acc 105 | }, 0) 106 | return totalAmount0; 107 | } 108 | 109 | getAveragePrice(materials: SurveyedMaterial[]) { 110 | return Math.round((this.getTotalAmount(materials) / this.getTotalWeightTon(materials) * 100)) / 100; 111 | } 112 | 113 | getAmount(material: SurveyedMaterial) { 114 | return this.getTaxExclPrice(material) * (material.weightKG || 0); 115 | } 116 | 117 | getDefaultPrice(material: SurveyedMaterial, prices: any[]) { 118 | const pwId = material.pwId; 119 | const [priceItem] = prices.filter(item => item.pwId === pwId); 120 | if (priceItem) { 121 | return priceItem.numbers.default * 1000; 122 | } else { 123 | return ''; 124 | } 125 | 126 | } 127 | 128 | ngOnInit(): void { 129 | console.log(this.data); 130 | } 131 | 132 | getPwName(material: SurveyedMaterial) { 133 | if (material) { 134 | const [pw] = this.selectedPws.filter(item => item._id === material.pwId); 135 | return (pw as any).name.replace('(公斤)', ''); 136 | } else { 137 | return ''; 138 | } 139 | } 140 | 141 | ngOnDestroy() { 142 | if (this.paddingForm.dirty) { 143 | console.log('changed'); 144 | localStorage.setItem('surveyPrintPaddingCache', JSON.stringify(this.paddingForm.getRawValue())); 145 | } 146 | } 147 | 148 | closeDialog() { 149 | this.dialogRef.close(); 150 | } 151 | 152 | get padding() { 153 | const paddingObj = this.paddingForm.getRawValue(); 154 | return `${paddingObj.top}px ${paddingObj.right}px ${paddingObj.bottom}px ${paddingObj.left}px`; 155 | } 156 | 157 | onBtnPrintClick() { 158 | window.print(); 159 | // let printData = document.getElementById('dataToPrint')?.cloneNode(true); 160 | // if (printData) { 161 | // document.body.appendChild(printData); 162 | // window.print(); 163 | // document.body.removeChild(printData); 164 | // } 165 | } 166 | 167 | 168 | } 169 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-survey-dialog.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { MatDialog } from '@angular/material/dialog'; 3 | import { LoadingComponent } from '@app/shared/components/loading/loading.component'; 4 | import { AuthService } from '@app/shared/services/auth.service'; 5 | import { DataService } from '@app/shared/services/data.service'; 6 | import { Customer } from '@app/shared/services/data/data-customers'; 7 | import { User } from '@app/shared/services/data/data-users'; 8 | import { VehicleSteelWeighingSurvey } from '@app/shared/services/data/data-vehicle-steel'; 9 | import { forkJoin, of, Subject, zip } from 'rxjs'; 10 | import { first, map, switchMap } from 'rxjs/operators'; 11 | import { VehicleSteelSurveyPrintComponent } from './vehicle-steel-survey-print/vehicle-steel-survey-print.component'; 12 | import { VehicleSteelWeighingPrintComponent } from './vehicle-steel-weighing-print/vehicle-steel-weighing-print.component'; 13 | import { VehicleSteelWeighingSurveyDialogComponent } from './vehicle-steel-weighing-survey-dialog.component'; 14 | 15 | 16 | @Injectable() 17 | export class VehicleSteelWeighingSurveyDialogService { 18 | public changesSaved$$ = new Subject(); 19 | constructor( 20 | private dialog: MatDialog, 21 | private backend: DataService, 22 | private auth: AuthService 23 | ) { } 24 | 25 | openDialog(vsws?: VehicleSteelWeighingSurvey, type?: string, isOutbound = false) { 26 | console.log('opening vswsDialog with data:'); 27 | console.log({vsws}); 28 | const prepareVSWS = (vsws?: VehicleSteelWeighingSurvey) => { 29 | if (!vsws) { 30 | const newVSWS = new VehicleSteelWeighingSurvey(isOutbound); 31 | // const currUser = this.auth.getCurrentUser(); 32 | // newVSWS.weighing.inWeighedBy = currUser?._id; 33 | // newVSWS.weighing.inWeighedByName = currUser?.displayName; 34 | return of(newVSWS); 35 | } else { 36 | // show 'loading...' before data is ready 37 | const loadingDialogRef = this.dialog.open(LoadingComponent, { 38 | disableClose: true 39 | }); 40 | 41 | 42 | const getDetails = forkJoin({ 43 | customer: vsws.weighing.customerId ? this.backend.dataCustomers.search({ _id: vsws.weighing.customerId }).pipe( 44 | map((customers: Customer[]) => { 45 | if (customers.length) { 46 | return customers[0]; 47 | } else { 48 | return null; 49 | } 50 | }) 51 | ) : of(null), 52 | inWeighedBy: vsws.weighing.inWeighedBy ? this.backend.dataUsers.search({ _id: vsws.weighing.inWeighedBy }).pipe( 53 | map((users: User[]) => { 54 | console.log(users); 55 | if (users.length) { 56 | return users[0]; 57 | } else { 58 | return null; 59 | } 60 | }) 61 | ) : of(null), 62 | outWeighedBy: vsws.weighing.outWeighedBy ? this.backend.dataUsers.search({ _id: vsws.weighing.outWeighedBy }).pipe( 63 | map((users: User[]) => { 64 | console.log(users); 65 | if (users.length) { 66 | return users[0]; 67 | } else { 68 | return null; 69 | } 70 | }) 71 | ) : of(null), 72 | surveyedBy: vsws.survey.surveyedBy ? this.backend.dataUsers.search({ _id: vsws.survey.surveyedBy }).pipe( 73 | map((users: User[]) => { 74 | console.log(users); 75 | if (users.length) { 76 | return users[0]; 77 | } else { 78 | return null; 79 | } 80 | }) 81 | ) : of(null) 82 | }); 83 | // get the customer details 84 | return getDetails 85 | .pipe( 86 | map((result) => { 87 | if (result.customer) { 88 | vsws.weighing.customerName = result.customer.name; 89 | vsws.weighing.customerTel = result.customer.mobile; 90 | } 91 | if (result.inWeighedBy) { 92 | vsws.weighing.inWeighedByName = result.inWeighedBy.displayName; 93 | } 94 | if (result.outWeighedBy) { 95 | vsws.weighing.outWeighedByName = result.outWeighedBy.displayName; 96 | } 97 | if (result.surveyedBy) { 98 | vsws.survey.surveyedByName = result.surveyedBy.displayName; 99 | } 100 | loadingDialogRef.close(); 101 | return vsws; 102 | }) 103 | ) 104 | // return of(vsws); 105 | } 106 | } 107 | const getPrices = (!!vsws && type === 'printSurvey') ? 108 | (() => { 109 | const pwIds = vsws.survey.materials.map(item => item.pwId); 110 | const gets = pwIds.map(pwId => this.backend.dataPrices.getPrices3({ 111 | pwId, spec: '.' 112 | }).pipe( 113 | map((results: any) => { 114 | return results[0]; 115 | }) 116 | )); 117 | return zip(...gets); 118 | })() 119 | : of(null); 120 | 121 | return forkJoin({ 122 | vsws: prepareVSWS(vsws), 123 | pws: this.backend.dataPws.getPws(), 124 | prices: getPrices 125 | }) 126 | .pipe( 127 | first(), 128 | map(combo => { 129 | let dialogRef; 130 | switch (type) { 131 | case 'printWeighing': 132 | dialogRef = this.dialog.open(VehicleSteelWeighingPrintComponent, { 133 | disableClose: false, 134 | data: { 135 | ...combo, 136 | changesSaved$$: this.changesSaved$$ 137 | }, 138 | // width: '50vw' 139 | // backdropClass: 'full-width' // todo 140 | width: '100%', 141 | height: '100%', 142 | maxWidth: '100%' 143 | }); 144 | break; 145 | case 'printSurvey': 146 | dialogRef = this.dialog.open(VehicleSteelSurveyPrintComponent, { 147 | disableClose: false, 148 | data: { 149 | ...combo, 150 | changesSaved$$: this.changesSaved$$ 151 | }, 152 | // width: '50vw' 153 | // backdropClass: 'full-width' // todo 154 | width: '100%', 155 | height: '100%', 156 | maxWidth: '100%' 157 | }); 158 | break; 159 | default: 160 | dialogRef = this.dialog.open(VehicleSteelWeighingSurveyDialogComponent, { 161 | disableClose: true, 162 | data: { 163 | ...combo, 164 | changesSaved$$: this.changesSaved$$ 165 | }, 166 | // width: '50vw' 167 | // backdropClass: 'full-width' // todo 168 | width: '100%', 169 | maxWidth: '100%' 170 | }); 171 | } 172 | return dialogRef; 173 | }) 174 | ) 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-survey-dialog.component.html: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 |

5 | 6 | 7 |
8 | 9 | 10 | 过磅信息 11 | 12 | 13 | 17 |   18 | 19 | 20 | 货车车牌号 21 | 22 | 24 | local_shipping 25 | 26 | 27 | 28 | {{option}} 29 | 30 | 31 | 32 |   33 | 34 | 35 | 客户名称 36 | 37 | 38 | 40 | 41 | 42 | {{customerOption.name}} 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |   51 | 52 | 53 | 客户电话 54 | 55 | 56 | 57 |   58 | 60 | 62 |
63 | 64 | 毛重(公斤) 65 | 66 | 67 | 68 | 69 | 皮重(公斤) 70 | 71 | 72 | 73 |   74 | 75 | 货车进场日期 76 | 77 | 78 |   79 | 80 | 货车进场时间 81 | 82 | 83 |   84 | 85 | 进场司磅 86 | 87 | 88 |
89 | 90 | 皮重(公斤) 91 | 92 | 93 | 94 | 95 | 毛重(公斤) 96 | 97 | 98 | 99 |   100 | 101 | 货车出场日期 102 | 103 | 104 |   105 | 106 | 货车出场时间 107 | 108 | 109 |   110 | 111 | 出场司磅 112 | 113 | 114 |
115 | 116 | 净重(公斤) 117 | 118 | 119 |   120 | 123 | 126 | 129 |
130 | 131 | 132 | 备注 133 | 134 | 135 | 136 | 137 |
138 |
139 |
140 | 141 | 142 | 143 | 物资信息 144 |     145 | 146 | 147 | 148 | 149 | 151 | 153 | 154 | 155 | 156 |     157 | 158 | 税点 159 | 160 | % 161 | 162 |     163 | 164 |     165 | 168 | 174 | 177 | 178 | 179 | 180 |
181 | 182 | 183 | 184 | 物资名称 185 | 186 | 187 | 188 | 189 | {{pw.name}} 190 | 191 | 192 | {{i + 1}}   193 | 194 | 195 |   196 | 197 | 重量 198 | 199 | 公斤 200 | 201 | 202 | 203 |   204 | 205 | 价格(含税) 206 | 207 | 元/公斤 208 | 209 |   210 | 211 | 金额 212 | 214 | 215 | 216 | 217 |   218 | 220 | 数量 221 | 222 | 223 |
224 | 225 | 226 | 备注 227 | 228 | 229 | 230 |   231 | 233 | 234 |
235 |
236 |
237 |
238 |
239 |
240 | 241 | 验质员 242 | 243 | assignment_ind 244 | 245 |   246 | 247 | 验质日期 248 | 249 | 250 |   251 | 252 | 验质时间 253 | 254 | 255 |
256 | 257 |
258 |
259 |
260 | 272 | 273 |
274 | 275 |
276 | 277 | 278 | 279 | 280 | 281 | -------------------------------------------------------------------------------- /src/app/vehicle-steel/vehicle-steel-weighing-survey-dialog/vehicle-steel-weighing-survey-dialog.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Inject, ViewChildren, ElementRef, QueryList, OnDestroy } from '@angular/core'; 2 | import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; 3 | import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; 4 | import { VehicleSteelWeighingSurvey } from '@app/shared/services/data/data-vehicle-steel'; 5 | import { Observable, of, Subject, Subscription } from 'rxjs'; 6 | import { DataService } from '@app/shared/services/data.service'; 7 | import { filter, first, map, startWith, switchMap, tap } from 'rxjs/operators'; 8 | import { Customer } from '@app/shared/services/data/data-customers'; 9 | import { CustomerDialogServiceService } from '@app/customers/customer-dialog/customer-dialog-service.service'; 10 | import { AuthService } from '@app/shared/services/auth.service'; 11 | import { AlertService } from '@app/shared/services/alert/alert.service'; 12 | import { CalculatePatchesService } from '@app/shared/services/calculate-patches.service'; 13 | import { LoadingComponent } from '@app/shared/components/loading/loading.component'; 14 | 15 | /* 16 | 17 | vswsForm is built according to class VehicleSteelWeighingSurvey, 18 | however, the SurveyedMaterial array is a separate formArray. 19 | 20 | */ 21 | @Component({ 22 | selector: 'app-vehicle-steel-weighing-survey-dialog', 23 | templateUrl: './vehicle-steel-weighing-survey-dialog.component.html', 24 | styleUrls: ['./vehicle-steel-weighing-survey-dialog.component.scss'] 25 | }) 26 | export class VehicleSteelWeighingSurveyDialogComponent implements OnInit, OnDestroy { 27 | sub0_: Subscription | undefined; 28 | vswsForm: FormGroup; 29 | materialsFormArray: FormArray; 30 | dialogTitle: string; 31 | truckPlateNoOptions: string[] = ['辽N']; 32 | subscriptions_: Subscription[] = []; 33 | possibleCustomers$?: Observable = of([]); 34 | loadingPossibleCustomers = false; 35 | disableEditCustomerButton = true; 36 | customer: Customer = { 37 | name: '' 38 | }; 39 | selectedPws: any[] = []; 40 | status = { 41 | showNewCustomerButton: false, 42 | observables: { 43 | valueChanges: of(null), // valueChanges for vswsForm 44 | }, 45 | netWeightKG: 0, 46 | materialTotalWeight: 0, 47 | materialTotalCost: 0, 48 | lastValue: { 49 | outWeightKG: 0 50 | } 51 | } 52 | @ViewChildren('formRows') materialRows: QueryList | undefined; 53 | objectTemplate = { 54 | _id: true, 55 | isDeleted: true, 56 | deletedAt: true, 57 | taxRatio: true, 58 | isOutbound: true, 59 | weighing: { 60 | truckPlateNo: true, 61 | customerId: true, 62 | inWeightKG: true, 63 | inWeighedAt: true, 64 | inWeighedBy: true, 65 | outWeightKG: true, 66 | outWeighedAt: true, 67 | outWeighedBy: true, 68 | notes: true 69 | }, 70 | survey: { 71 | surveyedBy: true, 72 | surveyedAt: true, 73 | materials: true 74 | } 75 | }; 76 | 77 | totalMaterialWeightGreaterThanWeighingNetweight = false; 78 | constructor( 79 | @Inject(MAT_DIALOG_DATA) public data: { vsws: VehicleSteelWeighingSurvey, pws: any[], changesSaved$$: Subject }, 80 | private fb: FormBuilder, 81 | private backend: DataService, 82 | public customerDialog: CustomerDialogServiceService, 83 | private auth: AuthService, 84 | private alert: AlertService, 85 | private calculatePatches: CalculatePatchesService, 86 | private dialog: MatDialog, 87 | private dialogRef: MatDialogRef, 88 | ) { 89 | const currUser = this.auth.getCurrentUser(); 90 | this.selectedPws = this.data.pws.filter(pw => pw.name.indexOf('废钢') > -1 && pw.name.indexOf('公斤') > -1); 91 | console.log(this.selectedPws); 92 | console.log(this.data.vsws); 93 | this.status.lastValue.outWeightKG = this.data.vsws.weighing.outWeightKG; 94 | this.status.netWeightKG = this.data.vsws.weighing.outWeightKG && this.data.vsws.weighing.inWeightKG ? 95 | this.data.vsws.weighing.outWeightKG - this.data.vsws.weighing.inWeightKG : 96 | 0; 97 | if (this.data.vsws.survey.materials && this.data.vsws.survey.materials.length) { 98 | console.log(this.data.vsws.survey.materials) 99 | this.materialsFormArray = this.fb.array(this.data.vsws.survey.materials?.map(material => this.fb.group({ 100 | // _id: material._id, 101 | pwId: [{ value: material.pwId, disabled: true }], 102 | weightKG: material.weightKG, 103 | count: material.count, 104 | price: material.price, 105 | // cost: [{value: (material.count || 0) * (material.price || 0), disabled: true}], 106 | notes: material.notes, 107 | inventoryId: material.inventoryId, 108 | }))); 109 | } else { 110 | this.materialsFormArray = this.fb.array([]); 111 | } 112 | this.vswsForm = this.fb.group({ 113 | _id: this.data.vsws._id, 114 | isDeleted: this.data.vsws.isDeleted, 115 | deletedAt: this.data.vsws.deletedAt, 116 | deletedBy: this.data.vsws.deletedBy, 117 | deletedNotes: this.data.vsws.deletedNotes, 118 | isOutbound: this.data.vsws.isOutbound, 119 | taxRatio: this.data.vsws.taxRatio, 120 | weighing: this.fb.group({ 121 | truckPlateNo: [{ 122 | value: this.data.vsws.weighing.truckPlateNo, disabled: !!this.data.vsws.weighing.truckPlateNo 123 | }, [Validators.required, Validators.minLength(7)]], 124 | customerId: this.data.vsws.weighing.customerId, 125 | customerName: [{ 126 | value: this.data.vsws.weighing.customerName, disabled: !!this.data.vsws.weighing.customerName 127 | }], 128 | customerTel: [{ 129 | value: this.data.vsws.weighing.customerTel, disabled: true 130 | }], 131 | inWeightKG: [{ 132 | value: this.data.vsws.weighing.inWeightKG, disabled: false 133 | }], 134 | inWeighedDate: this.data.vsws.weighing.inWeighedAt ? (new Date(this.data.vsws.weighing.inWeighedAt)).toLocaleDateString().split('/').map(item => item.padStart(2, '0')).join('-') : '', 135 | inWeighedTime: this.data.vsws.weighing.inWeighedAt ? (new Date(this.data.vsws.weighing.inWeighedAt)).toTimeString().substring(0, 5) : '', 136 | inWeighedBy: this.data.vsws.weighing.inWeighedBy ? this.data.vsws.weighing.inWeighedBy : currUser?._id, 137 | inWeighedByName: [{ 138 | value: this.data.vsws.weighing.inWeighedByName ? this.data.vsws.weighing.inWeighedByName : currUser?.displayName, 139 | disabled: true 140 | }], 141 | outWeightKG: [{ 142 | value: this.data.vsws.weighing.outWeightKG, disabled: false 143 | }], 144 | outWeighedDate: this.data.vsws.weighing.outWeighedAt ? (new Date(this.data.vsws.weighing.outWeighedAt)).toISOString().substring(0, 10) : '', 145 | outWeighedTime: this.data.vsws.weighing.outWeighedAt ? (new Date(this.data.vsws.weighing.outWeighedAt)).toTimeString().substring(0, 5) : '', 146 | outWeighedBy: this.data.vsws.weighing.outWeighedBy, 147 | outWeighedByName: [{ 148 | value: this.data.vsws.weighing.outWeighedByName, 149 | disabled: true 150 | }], 151 | notes: this.data.vsws.weighing.notes 152 | }), 153 | survey: this.fb.group({ 154 | surveyedBy: this.data.vsws.survey.surveyedBy, 155 | surveyedByName: [{ 156 | value: this.data.vsws.survey.surveyedByName, 157 | disabled: true 158 | }], 159 | surveyedDate: [{ 160 | value: this.data.vsws.survey.surveyedAt ? (new Date(this.data.vsws.survey.surveyedAt)).toISOString().substring(0, 10) : '', 161 | disabled: !!this.data.vsws.survey.surveyedAt 162 | }], 163 | surveyedTime: [{ 164 | value: this.data.vsws.survey.surveyedAt ? (new Date(this.data.vsws.survey.surveyedAt)).toTimeString().substring(0, 5) : '', 165 | disabled: !!this.data.vsws.survey.surveyedAt 166 | }], 167 | materials: this.materialsFormArray 168 | // surveyedBy?: any, 169 | // surveyedAt?: Date, 170 | // materials?: SurveyedMaterial[] 171 | }) 172 | }) 173 | 174 | this.dialogTitle = this.data.vsws.isOutbound ? ( 175 | this.data.vsws._id ? '编辑物资出场' : '新建物资出场' 176 | ) : ( 177 | this.data.vsws._id ? '编辑物资进场' : '新建物资进场' 178 | ) 179 | } 180 | 181 | ngOnDestroy() { 182 | this.sub0_?.unsubscribe() 183 | } 184 | 185 | ngOnInit(): void { 186 | // console.log(this.auth.getCurrentUser()) 187 | 188 | this.status.observables.valueChanges = this.vswsForm.valueChanges 189 | .pipe( 190 | startWith(this.vswsForm.getRawValue()), 191 | tap((value: any) => { 192 | const materialsFormValue: any[] = (value as any).survey.materials; 193 | 194 | console.log({ 195 | value 196 | }); 197 | materialsFormValue.forEach((materialX, index) => { 198 | // check if pwName includes 发动机 199 | // const pwFound = this.selectedPws.find(pw => pw._id === materialX.pwId); 200 | // if (pwFound && pwFound.name.indexOf('发动机') > -1) { 201 | // this.materialsFormArray.controls[index].get('count')?.enable({ emitEvent: false }); 202 | // } else { 203 | // if (pwFound) { 204 | // this.materialsFormArray.controls[index].get('count')?.disable({ emitEvent: false }); 205 | // } 206 | // } 207 | 208 | 209 | 210 | }) 211 | 212 | 213 | 214 | setTimeout(() => { 215 | this.status.materialTotalCost = materialsFormValue.reduce((acc, curr) => { 216 | return acc + curr.price * curr.weightKG 217 | }, 0); 218 | this.status.materialTotalWeight = materialsFormValue.reduce((acc, curr) => { 219 | // console.log(curr.weightKG * 1) 220 | return acc + curr.weightKG * 1; 221 | }, 0); 222 | 223 | // when inWeightKG changed from '' to number, set data time and inWeighedBy 224 | // const initInWeightKG = this.status.lastValue.weighing.inWeightKG; 225 | const newInWeightKG = value.weighing.inWeightKG; 226 | const initOutWeightKG = this.status.lastValue.outWeightKG; 227 | const newOutWeightKG = value.weighing.outWeightKG; 228 | if (!initOutWeightKG && newOutWeightKG) { 229 | const thatDate = new Date(); 230 | this.vswsForm.patchValue({ 231 | weighing: { 232 | outWeighedDate: thatDate.toISOString().substring(0, 10), 233 | outWeighedTime: thatDate.toTimeString().substring(0, 5), 234 | outWeighedBy: this.auth.getCurrentUser()?._id, 235 | outWeighedByName: this.auth.getCurrentUser()?.displayName, 236 | } 237 | }, { emitEvent: false }); 238 | this.status.lastValue.outWeightKG = newOutWeightKG; 239 | } 240 | this.status.netWeightKG = this.data.vsws.isOutbound ? ( 241 | (newInWeightKG && newOutWeightKG) ? (newOutWeightKG - newInWeightKG) : 0 242 | ) : ( 243 | (newInWeightKG && newOutWeightKG) ? (newInWeightKG - newOutWeightKG) : 0 244 | ); 245 | 246 | // if negative netWeightKG, add form error 247 | if (this.status.netWeightKG < 0) { 248 | this.vswsForm.setErrors({ 249 | weightError: true 250 | }) 251 | 252 | } 253 | 254 | 255 | 256 | if (this.status.materialTotalWeight > this.status.netWeightKG) { 257 | this.totalMaterialWeightGreaterThanWeighingNetweight = true; 258 | // 暂时允许“物资总重”大于“过磅净重”;当发生上述情况时,警告但不报错。 259 | // this.vswsForm.setErrors(Object.assign({}, this.vswsForm.errors, { 260 | // weightError2: 'material total weight cannot be greater than netWeightKG' 261 | // })) 262 | } else { 263 | this.totalMaterialWeightGreaterThanWeighingNetweight = false; 264 | } 265 | }, 0) 266 | 267 | }) 268 | ) 269 | 270 | this.sub0_ = this.status.observables.valueChanges.subscribe(); 271 | // if create new vsws, when keying in customerName, find by regex and autoComplete 272 | this.possibleCustomers$ = this.vswsForm.get('weighing.customerName')?.valueChanges 273 | .pipe( 274 | startWith(this.vswsForm.get('weighing.customerName')?.value), 275 | switchMap(customerNameX => { 276 | this.loadingPossibleCustomers = true; 277 | if (!customerNameX) { 278 | return of([]).pipe( 279 | map(customers => ({ customerNameX, possibleCustomers: customers })) 280 | ) 281 | } else { 282 | return this.backend.dataCustomers.search({ name: { $regex: `.*${customerNameX}.*` } }).pipe( 283 | map(customers => ({ customerNameX, possibleCustomers: customers })) 284 | ) 285 | } 286 | }), 287 | tap((combo) => { 288 | console.log(combo); 289 | const foundMatchCustomer = combo.possibleCustomers.find(pC => pC.name === combo.customerNameX); 290 | this.status.showNewCustomerButton = !!this.vswsForm.get('weighing.customerName')?.dirty && (!combo.customerNameX || (!!combo.customerNameX && !foundMatchCustomer)); 291 | this.disableEditCustomerButton = !combo.customerNameX; 292 | // console.log(possibleCustomers); 293 | // set customerTel 294 | if (foundMatchCustomer) { 295 | this.customer = foundMatchCustomer; 296 | this.vswsForm.patchValue({ 297 | weighing: { 298 | customerTel: foundMatchCustomer?.mobile, 299 | customerId: foundMatchCustomer?._id, 300 | } 301 | }, {emitEvent: false}) 302 | // this.vswsForm.get('weighing.customerTel')?.setValue(foundMatchCustomer?.mobile); 303 | // this.vswsForm.get('weighing.customerId')?.setValue(foundMatchCustomer?._id); 304 | // this.vswsForm.get('weighing.customerName')?.setErrors(null); // angular form will reset error on any changes 305 | } else { 306 | if (this.vswsForm.get('weighing.customerName')?.value) { 307 | this.vswsForm.get('weighing.customerName')?.setErrors({ 308 | notFound: true 309 | }); 310 | this.customer = { 311 | name: combo.customerNameX, 312 | mobile: '' 313 | }; 314 | this.vswsForm.get('weighing.customerTel')?.setValue(''); 315 | this.vswsForm.get('weighing.customerId')?.setValue(''); 316 | } 317 | } 318 | this.loadingPossibleCustomers = false; 319 | }), 320 | map((combo) => combo.possibleCustomers) 321 | ) 322 | 323 | } 324 | 325 | getMaterialControl(index: number, controlName: string) { 326 | return this.materialsFormArray.at(index).get(controlName) as FormControl; 327 | } 328 | 329 | addMaterial() { 330 | 331 | // set surveyedBy, if it's the first material to be added 332 | if (!this.materialsFormArray.controls.length) { 333 | const thatDate = new Date(); 334 | this.vswsForm.patchValue({ 335 | survey: { 336 | surveyedBy: this.auth.getCurrentUser()?._id, 337 | surveyedByName: this.auth.getCurrentUser()?.displayName, 338 | surveyedDate: thatDate.toISOString().substring(0, 10), 339 | surveyedTime: thatDate.toTimeString().substring(0, 5) 340 | } 341 | }) 342 | } 343 | if (this.materialsFormArray.controls.length < 5) { 344 | const newFormItem = this.fb.group({ 345 | pwId: ['', Validators.required], 346 | weightKG: [0, Validators.min(0.1)], 347 | count: [{ value: 0, disabled: true }], 348 | price: 0, 349 | // cost: 0, 350 | notes: '' 351 | }); 352 | this.materialsFormArray.push(newFormItem); 353 | setTimeout(() => { 354 | this.materialRows?.last.nativeElement.scrollIntoView(); 355 | this.materialRows?.last.nativeElement.querySelector('mat-select').click() 356 | }, 0) 357 | } else { 358 | // alert to prevent adding the 11th material 359 | this.alert.openDialog({ 360 | title: '出错了', 361 | message: '单车最多5种物资', 362 | okOnly: true 363 | }) 364 | } 365 | } 366 | 367 | removeMaterial(index: number) { 368 | this.materialsFormArray.removeAt(index); 369 | 370 | // clear surveyedBy, if 0 material 371 | if (!this.materialsFormArray.controls.length) { 372 | this.vswsForm.patchValue({ 373 | survey: { 374 | surveyedBy: '', 375 | surveyedByName: '', 376 | surveyedDate: '', 377 | surveyedTime: '' 378 | } 379 | }) 380 | } 381 | } 382 | 383 | openCustomerDialog(customer: Customer) { 384 | const dialogRef = this.customerDialog.openDialog(customer); 385 | dialogRef.afterClosed().subscribe(result => { 386 | if (result && result._id) { 387 | this.vswsForm.get('weighing.customerId')?.setValue(result._id); 388 | this.vswsForm.get('weighing.customerName')?.setValue(result.name); 389 | this.vswsForm.get('weighing.customerTel')?.setValue(result.mobiel); 390 | } 391 | }); 392 | } 393 | 394 | preparePatches() { 395 | const newObject = this.vswsForm.getRawValue(); 396 | const oldObject = this.data.vsws; 397 | // const newArray = this.materialsFormArray.getRawValue(); 398 | // const oldArray = this.data.vsws.survey.materials ? this.data.vsws.survey.materials : []; 399 | 400 | // prepareData 401 | if (newObject.weighing.inWeighedDate && newObject.weighing.inWeighedTime) { 402 | newObject.weighing.inWeighedAt = (new Date(newObject.weighing.inWeighedDate + ' ' + newObject.weighing.inWeighedTime)).toISOString(); 403 | } 404 | if (newObject.weighing.outWeighedDate && newObject.weighing.outWeighedTime) { 405 | newObject.weighing.outWeighedAt = (new Date(newObject.weighing.outWeighedDate + ' ' + newObject.weighing.outWeighedTime)).toISOString(); 406 | } 407 | if (newObject.survey.surveyedDate && newObject.survey.surveyedTime) { 408 | newObject.survey.surveyedAt = (new Date(newObject.survey.surveyedDate + ' ' + newObject.survey.surveyedTime)).toISOString(); 409 | } 410 | const vswsPatches = this.calculatePatches.calculatePatches({ 411 | oldObject, 412 | newObject, 413 | objectTemplate: this.objectTemplate 414 | }); 415 | 416 | // const martieralPatches = this.calculatePatches 417 | 418 | return { 419 | oldObject, 420 | newObject, 421 | vswsPatches, 422 | // oldArray, 423 | // newArray, 424 | // materialPatches 425 | }; 426 | 427 | } 428 | 429 | onCancel() { 430 | const patches = this.preparePatches().vswsPatches; 431 | console.log({ 432 | patches 433 | }) 434 | if (patches.length) { 435 | // alert changed 436 | const alertDialogRef = this.alert.openDialog({ 437 | title: '内容已变更', 438 | message: '是否放弃更改?' 439 | }); 440 | alertDialogRef.afterClosed().pipe( 441 | first() 442 | ).subscribe(alertConfirmed => { 443 | if (alertConfirmed) { 444 | // confirm discarding the changes 445 | this.dialogRef.close(); 446 | } // else do nothing, go on editing 447 | }) 448 | } else { 449 | console.log('no change'); 450 | this.dialogRef.close(); 451 | } 452 | } 453 | 454 | onSubmit2() { 455 | const { newObject, oldObject, vswsPatches } = this.preparePatches(); 456 | 457 | console.log({ newObject, oldObject, vswsPatches }) 458 | 459 | } 460 | 461 | onSubmit() { 462 | const { newObject, oldObject, vswsPatches } = this.preparePatches(); 463 | console.log({ newObject, oldObject, vswsPatches }) 464 | 465 | if (oldObject._id) { 466 | // patch object 467 | console.log(vswsPatches); 468 | if (!vswsPatches.length) { 469 | this.alert.openDialog({ 470 | title: '无变动', 471 | message: '内容没有任何变动,无需保存', 472 | okOnly: true 473 | }) 474 | } else { 475 | const loadingDialogRef = this.dialog.open(LoadingComponent, { 476 | disableClose: true, 477 | data: { 478 | message: '正在保存...' 479 | } 480 | }); 481 | this.backend.dataVS.update({ 482 | _id: oldObject._id, 483 | vswsPatches: vswsPatches 484 | }).pipe( 485 | first() 486 | ) 487 | .subscribe(res => { 488 | console.log({ 489 | vswsPatchResult: res 490 | }); 491 | loadingDialogRef.close(); 492 | // close dialog, update recent 493 | this.dialogRef.close(); 494 | this.data.changesSaved$$.next(); 495 | }) 496 | } 497 | } else { 498 | // create object 499 | const loadingDialogRef2 = this.dialog.open(LoadingComponent, { 500 | disableClose: true, 501 | data: { 502 | message: '正在保存...' 503 | } 504 | }); 505 | this.backend.dataVS.insert(this.calculatePatches.trimObject(newObject, this.objectTemplate) as VehicleSteelWeighingSurvey) 506 | .pipe( 507 | first() 508 | ) 509 | .subscribe(res => { 510 | console.log({ res }); 511 | loadingDialogRef2.close(); 512 | this.data.changesSaved$$.next(); 513 | this.dialogRef.close(); 514 | // colse dialog 515 | // refresh recent 516 | }) 517 | } 518 | 519 | } 520 | 521 | objectKeys(obj: {[key: string]: any}) { 522 | console.log({obj}); 523 | // console.log({ 524 | // keys: Object.keys(obj) 525 | // }); 526 | } 527 | 528 | 529 | } 530 | --------------------------------------------------------------------------------