|
@@ -2,9 +2,11 @@ import { Component } from '@angular/core';
|
|
import { horizontalInOutReverse300ms } from '../../../../common.animation';
|
|
import { horizontalInOutReverse300ms } from '../../../../common.animation';
|
|
import { CommonNzModule } from '../../../../common.nz.module';
|
|
import { CommonNzModule } from '../../../../common.nz.module';
|
|
import { CustomDrawerComponent } from '../../../../shared/custom-drawer/custom-drawer.component';
|
|
import { CustomDrawerComponent } from '../../../../shared/custom-drawer/custom-drawer.component';
|
|
|
|
+import { SearchParams } from '../hazard.utils';
|
|
import { HazardCardComponent } from './card/card.component';
|
|
import { HazardCardComponent } from './card/card.component';
|
|
import { HazardDetailComponent } from './detail/detail.component';
|
|
import { HazardDetailComponent } from './detail/detail.component';
|
|
import { HazardFormComponent, HazardFormComponentProps } from './hazard-form/hazard-form.component';
|
|
import { HazardFormComponent, HazardFormComponentProps } from './hazard-form/hazard-form.component';
|
|
|
|
+import { HazardSearchComponent } from './hazard-search/hazard-search.component';
|
|
|
|
|
|
export interface HazardDetailConfig {
|
|
export interface HazardDetailConfig {
|
|
visible: boolean;
|
|
visible: boolean;
|
|
@@ -14,6 +16,8 @@ export interface HazardDetailConfig {
|
|
const hazardLevels = ['重大', 'A', 'B', 'C'];
|
|
const hazardLevels = ['重大', 'A', 'B', 'C'];
|
|
const departments = Array.from({ length: 15 }, (_, i) => i + 1);
|
|
const departments = Array.from({ length: 15 }, (_, i) => i + 1);
|
|
|
|
|
|
|
|
+const getRandomSize = (max: number) => Math.floor(Math.random() * max);
|
|
|
|
+
|
|
const getMockHazard = (index: number): Hazard.HazardDto => {
|
|
const getMockHazard = (index: number): Hazard.HazardDto => {
|
|
return {
|
|
return {
|
|
id: index,
|
|
id: index,
|
|
@@ -26,22 +30,29 @@ const getMockHazard = (index: number): Hazard.HazardDto => {
|
|
creator: '张三',
|
|
creator: '张三',
|
|
reportingTime: '2024-09-25 12:00',
|
|
reportingTime: '2024-09-25 12:00',
|
|
responsible: 1,
|
|
responsible: 1,
|
|
- responsibleDepartments: departments.slice(0, Math.floor(Math.random() * departments.length)),
|
|
|
|
- images: Array.from({ length: 11 }).map(() => `https://loremflickr.com/260/150?q=${Math.random()}`),
|
|
|
|
|
|
+ responsibleDepartments: departments.slice(0, getRandomSize(departments.length)),
|
|
|
|
+ images: Array.from({ length: getRandomSize(11) }).map(() => `https://loremflickr.com/260/150?q=${Math.random()}`),
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-hazard-tracking',
|
|
selector: 'app-hazard-tracking',
|
|
standalone: true,
|
|
standalone: true,
|
|
- imports: [CommonNzModule, HazardCardComponent, HazardDetailComponent, CustomDrawerComponent, HazardFormComponent],
|
|
|
|
|
|
+ imports: [
|
|
|
|
+ CommonNzModule,
|
|
|
|
+ HazardCardComponent,
|
|
|
|
+ HazardDetailComponent,
|
|
|
|
+ CustomDrawerComponent,
|
|
|
|
+ HazardFormComponent,
|
|
|
|
+ HazardSearchComponent,
|
|
|
|
+ ],
|
|
templateUrl: './hazard-tracking.component.html',
|
|
templateUrl: './hazard-tracking.component.html',
|
|
styleUrl: './hazard-tracking.component.less',
|
|
styleUrl: './hazard-tracking.component.less',
|
|
animations: [horizontalInOutReverse300ms],
|
|
animations: [horizontalInOutReverse300ms],
|
|
})
|
|
})
|
|
export class HazardTrackingComponent {
|
|
export class HazardTrackingComponent {
|
|
hazards: Hazard.HazardDto[] = [];
|
|
hazards: Hazard.HazardDto[] = [];
|
|
-
|
|
|
|
|
|
+ filteredHazards: Hazard.HazardDto[] = [];
|
|
detailConfig: HazardDetailConfig = {
|
|
detailConfig: HazardDetailConfig = {
|
|
visible: false,
|
|
visible: false,
|
|
data: {} as Hazard.HazardDto,
|
|
data: {} as Hazard.HazardDto,
|
|
@@ -51,7 +62,18 @@ export class HazardTrackingComponent {
|
|
data: undefined,
|
|
data: undefined,
|
|
};
|
|
};
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
- this.hazards = Array.from({ length: 2 }, (_, i) => getMockHazard(i));
|
|
|
|
|
|
+ this.hazards = Array.from({ length: getRandomSize(11) }, (_, i) => getMockHazard(i));
|
|
|
|
+ this.filteredHazards = this.hazards.slice();
|
|
|
|
+ }
|
|
|
|
+ onSearchParamsChange(p: SearchParams) {
|
|
|
|
+ const { status, level } = p;
|
|
|
|
+ this.filteredHazards = this.hazards.filter(h => {
|
|
|
|
+ if (status !== -1) {
|
|
|
|
+ if (h.status !== status) return false;
|
|
|
|
+ }
|
|
|
|
+ if (level && h.level !== level) return false;
|
|
|
|
+ return true;
|
|
|
|
+ });
|
|
}
|
|
}
|
|
handleViewDetail(data: Hazard.HazardDto) {
|
|
handleViewDetail(data: Hazard.HazardDto) {
|
|
this.detailConfig.visible = true;
|
|
this.detailConfig.visible = true;
|