|
@@ -2,11 +2,12 @@ import { Component } from '@angular/core';
|
|
|
import { horizontalInOutReverse300ms } from '../../../../common.animation';
|
|
|
import { CommonNzModule } from '../../../../common.nz.module';
|
|
|
import { DataEmptyComponent } from '../../../../shared/data-empty/data-empty.component';
|
|
|
+import { hazardLevelColor } from '../hazard.utils';
|
|
|
import { ApiService } from './../../../../services/api.service';
|
|
|
import { SettingService } from './../../../../services/setting.service';
|
|
|
import { CustomDrawerComponent } from './../../../../shared/custom-drawer/custom-drawer.component';
|
|
|
import { InspectionPlanDetailComponent } from './detail/detail.component';
|
|
|
-import { cycleOptions, hazardPlanTypeOptions, planLevelOptions } from './inspection-plan.utils';
|
|
|
+import { hazardPlanTypeOptions, PlanType } from './inspection-plan.utils';
|
|
|
import { PlanCardComponent } from './plan-card/plan-card.component';
|
|
|
import { PlanFormComponent, PlanFormComponentProps } from './plan-form/plan-form.component';
|
|
|
|
|
@@ -15,39 +16,13 @@ export interface InspectionPlanDetailConfig {
|
|
|
data: Hazard.InspectionPlanDetail;
|
|
|
}
|
|
|
|
|
|
+type SemiAnnual = { label: string; start: Date; end: Date; key: number };
|
|
|
+
|
|
|
const notificationConfig = [
|
|
|
{ type: 1, text: '通知', color: '#165DFF', backgroundColor: '#E8F3FF' },
|
|
|
{ type: 2, text: '消息', color: '#0FC6C2', backgroundColor: '#E8FFFB' },
|
|
|
];
|
|
|
|
|
|
-// const departments = Array.from({ length: 15 }, (_, i) => i + 1);
|
|
|
-const getRandomSizeN = (max: number) => Math.floor(Math.random() * max);
|
|
|
-const getRandomSize = (arr: Option<string | number>[]) => arr[Math.floor(Math.random() * arr.length)];
|
|
|
-
|
|
|
-const getMockPlan = (index: number, name: string): Hazard.InspectionPlan => {
|
|
|
- return {
|
|
|
- id: index,
|
|
|
- type: getRandomSize(hazardPlanTypeOptions).value as string,
|
|
|
- title: `${name}隐患排查计划`,
|
|
|
- status: '',
|
|
|
- startDate: parseInt(name) + '-11-12T00:00:00',
|
|
|
- endDate: parseInt(name) + '-11-14T00:00:00',
|
|
|
- createdDate: parseInt(name) + '-11-10T00:00:00',
|
|
|
- departments: [getRandomSizeN(13) + 1],
|
|
|
- createUserId: '123',
|
|
|
- createUserName: '张三',
|
|
|
- createUserDept: 1,
|
|
|
- targets: [323, 346, 349, 16, 12, 8, 5, 4],
|
|
|
- level: getRandomSize(planLevelOptions).value as string,
|
|
|
- cycle: getRandomSize(cycleOptions).value as string,
|
|
|
- frequency: getRandomSizeN(4) || 1,
|
|
|
- frequencyTimes: getRandomSizeN(4) || 1,
|
|
|
- // time: [],
|
|
|
- content: '',
|
|
|
- isUnited: false,
|
|
|
- };
|
|
|
-};
|
|
|
-
|
|
|
@Component({
|
|
|
selector: 'app-inspection-plan',
|
|
|
standalone: true,
|
|
@@ -73,29 +48,44 @@ export class InspectionPlanComponent {
|
|
|
data: undefined,
|
|
|
isEdit: false,
|
|
|
};
|
|
|
- semiAnnualOptions = [
|
|
|
- { label: '2023上半年度', value: 202301 },
|
|
|
- { label: '2023下半年度', value: 202306 },
|
|
|
- { label: '2024上半年度', value: 202401 },
|
|
|
- { label: '2024下半年度', value: 202406 },
|
|
|
- { label: '2025上半年度', value: 202501 },
|
|
|
- ];
|
|
|
- firstSection = [
|
|
|
- { label: '日常隐患排查计划', value: 3, key: 1 },
|
|
|
- { label: '专项隐患排查计划', value: 6, key: 2 },
|
|
|
- { label: '其他隐患排查计划', value: 9, key: 3 },
|
|
|
- ];
|
|
|
- secondSection = [
|
|
|
- { label: '计划站点排查覆盖', value: 65 },
|
|
|
- { label: '其他场所排查覆盖', value: 100 },
|
|
|
- { label: '计划人员排查占比', value: 95 },
|
|
|
+
|
|
|
+ hazardLevelColor = hazardLevelColor;
|
|
|
+
|
|
|
+ semiAnnualOptions: SemiAnnual[] = [];
|
|
|
+
|
|
|
+ // firstSection = [
|
|
|
+ // { label: '日常隐患排查计划', value: 3, key: 1 },
|
|
|
+ // { label: '专项隐患排查计划', value: 6, key: 2 },
|
|
|
+ // { label: '其他隐患排查计划', value: 9, key: 3 },
|
|
|
+ // ];
|
|
|
+ types = hazardPlanTypeOptions.map(t => ({ label: t.label, key: t.value as PlanType, count: 0 }));
|
|
|
+ // secondSection = [
|
|
|
+ // { label: '计划站点排查覆盖', value: 65 },
|
|
|
+ // { label: '其他场所排查覆盖', value: 100 },
|
|
|
+ // { label: '计划人员排查占比', value: 95 },
|
|
|
+ // ];
|
|
|
+ discoveryList = [
|
|
|
+ {
|
|
|
+ level: '重大',
|
|
|
+ count: 0,
|
|
|
+ color: hazardLevelColor['重大'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ level: 'A级',
|
|
|
+ count: 3,
|
|
|
+ color: hazardLevelColor['A'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ level: 'B级',
|
|
|
+ count: 8,
|
|
|
+ color: hazardLevelColor['B'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ level: 'C级',
|
|
|
+ count: 112,
|
|
|
+ color: hazardLevelColor['C'],
|
|
|
+ },
|
|
|
];
|
|
|
- discovery = {
|
|
|
- significant: 1,
|
|
|
- a: 2,
|
|
|
- b: 3,
|
|
|
- c: 5,
|
|
|
- };
|
|
|
notifications = [
|
|
|
{
|
|
|
type: 1,
|
|
@@ -122,12 +112,9 @@ export class InspectionPlanComponent {
|
|
|
createDate: '2024-11-16T00:00:00',
|
|
|
},
|
|
|
];
|
|
|
- currentPlanKey = 2;
|
|
|
- semiAnnualKey = 202406;
|
|
|
+ currentType?: PlanType;
|
|
|
+ semiAnnual?: SemiAnnual;
|
|
|
|
|
|
- // plans: Hazard.InspectionPlan[] = Array.from({ length: getRandomSizeN(30) }, (_, i) =>
|
|
|
- // getMockPlan(i, this.getSemiAnnualLabel(this.semiAnnualKey))
|
|
|
- // );
|
|
|
plans: Hazard.InspectionPlan[] = [];
|
|
|
fetching = false;
|
|
|
fetchingDetail = false;
|
|
@@ -141,27 +128,92 @@ export class InspectionPlanComponent {
|
|
|
private setting: SettingService
|
|
|
) {
|
|
|
setting.getUsersOfCurrentCompany();
|
|
|
+ this.setSemiAnnualOptions();
|
|
|
}
|
|
|
|
|
|
ngOnInit() {
|
|
|
this.fetchPlans();
|
|
|
}
|
|
|
+ setSemiAnnualOptions() {
|
|
|
+ const upperHalf = '上半年度';
|
|
|
+ const lowerHalf = '下半年度';
|
|
|
+ const upperHalfRange = ['-01-01T00:00:00', '-06-30T23:59:59'];
|
|
|
+ const lowerHalfRange = ['-07-01T00:00:00', '-12-31T23:59:59'];
|
|
|
+
|
|
|
+ // 从 2024/12/27 开始,每半年一个周期
|
|
|
+ const start = new Date('2024-12-27T00:00:00');
|
|
|
+ const now = new Date();
|
|
|
+ let semiAnnualOptions = [
|
|
|
+ {
|
|
|
+ label: '2024下半年度',
|
|
|
+ start: new Date(2024 + lowerHalfRange[0]),
|
|
|
+ end: new Date(2024 + lowerHalfRange[1]),
|
|
|
+ key: 202407,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ const fullYears = now.getFullYear() - start.getFullYear() - 1;
|
|
|
+
|
|
|
+ function pushSemiAnnualOptions(year: number, half: string) {
|
|
|
+ const range = half === upperHalf ? upperHalfRange : lowerHalfRange;
|
|
|
+ semiAnnualOptions.push({
|
|
|
+ label: `${year}${half}`,
|
|
|
+ start: new Date(year + range[0]),
|
|
|
+ end: new Date(year + range[1]),
|
|
|
+ key: year,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ for (let i = 0; i < fullYears; i++) {
|
|
|
+ pushSemiAnnualOptions(start.getFullYear() + i + 1, upperHalf);
|
|
|
+ pushSemiAnnualOptions(start.getFullYear() + i + 1, lowerHalf);
|
|
|
+ }
|
|
|
+
|
|
|
+ const isWhole = now.getMonth() > 6;
|
|
|
+
|
|
|
+ pushSemiAnnualOptions(now.getFullYear(), upperHalf);
|
|
|
+ if (isWhole) {
|
|
|
+ pushSemiAnnualOptions(now.getFullYear(), lowerHalf);
|
|
|
+ }
|
|
|
+ this.semiAnnualOptions = semiAnnualOptions;
|
|
|
+ this.semiAnnual = this.semiAnnualOptions[this.semiAnnualOptions.length - 1];
|
|
|
+ }
|
|
|
+ getParams() {
|
|
|
+ const params: Hazard.GetPlansParams = {
|
|
|
+ startDate: this.semiAnnual?.start.toISOString(),
|
|
|
+ endDate: this.semiAnnual?.end.toISOString(),
|
|
|
+ page: this.pageConfig.page,
|
|
|
+ size: this.pageConfig.size,
|
|
|
+ };
|
|
|
+ if (this.currentType) {
|
|
|
+ params.type = this.currentType;
|
|
|
+ }
|
|
|
+ return params;
|
|
|
+ }
|
|
|
|
|
|
fetchPlans() {
|
|
|
this.fetching = true;
|
|
|
this.api.hazard
|
|
|
- .getPlans({
|
|
|
- page: this.pageConfig.page,
|
|
|
- size: this.pageConfig.size,
|
|
|
- })
|
|
|
+ .getPlans(this.getParams())
|
|
|
.then(res => {
|
|
|
this.plans = res.items;
|
|
|
this.pageConfig.total = res.total;
|
|
|
+ this.setTypesCount(res);
|
|
|
+ this.setDiscoveryCount(res);
|
|
|
})
|
|
|
.finally(() => {
|
|
|
this.fetching = false;
|
|
|
});
|
|
|
}
|
|
|
+ setTypesCount(res: Hazard.PlanListResponse) {
|
|
|
+ this.types.find(t => t.key === PlanType.COMPREHENSIVE)!.count = res.troubleshootTypeNumber.typeSpecial;
|
|
|
+ this.types.find(t => t.key === PlanType.DAILY)!.count = res.troubleshootTypeNumber.typeCommon;
|
|
|
+ this.types.find(t => t.key === PlanType.OTHER)!.count = res.troubleshootTypeNumber.typeOther;
|
|
|
+ }
|
|
|
+ setDiscoveryCount(res: Hazard.PlanListResponse) {
|
|
|
+ this.discoveryList.find(d => d.level === '重大')!.count = res.troubleLevelNumber.levelImportantTotal;
|
|
|
+ this.discoveryList.find(d => d.level === 'A级')!.count = res.troubleLevelNumber.levelATotal;
|
|
|
+ this.discoveryList.find(d => d.level === 'B级')!.count = res.troubleLevelNumber.levelBTotal;
|
|
|
+ this.discoveryList.find(d => d.level === 'C级')!.count = res.troubleLevelNumber.levelCTotal;
|
|
|
+ }
|
|
|
onCurrentPageChange(page: number) {
|
|
|
this.pageConfig.page = page;
|
|
|
this.fetchPlans();
|
|
@@ -170,11 +222,14 @@ export class InspectionPlanComponent {
|
|
|
this.pageConfig.page = 0;
|
|
|
this.fetchPlans();
|
|
|
}
|
|
|
- getSemiAnnualLabel(key: number) {
|
|
|
- return this.semiAnnualOptions.find(s => s.value === key)?.label || '2025上半年度';
|
|
|
- }
|
|
|
- handlePlanTypeChange(type: number) {
|
|
|
- this.currentPlanKey = type;
|
|
|
+
|
|
|
+ handlePlanTypeChange(type: PlanType) {
|
|
|
+ if (this.currentType === type) {
|
|
|
+ this.currentType = undefined;
|
|
|
+ } else {
|
|
|
+ this.currentType = type;
|
|
|
+ }
|
|
|
+ this.handleRefreshList();
|
|
|
}
|
|
|
handleSemiAnnualChange(direction: 'left' | 'right') {
|
|
|
const index = this.currentSemiAnnualOptionIndex;
|
|
@@ -184,7 +239,7 @@ export class InspectionPlanComponent {
|
|
|
if (direction === 'right') {
|
|
|
if (!this.rightArrowVisible) return;
|
|
|
}
|
|
|
- this.semiAnnualKey = this.semiAnnualOptions[index + (direction === 'left' ? -1 : 1)]?.value || 0;
|
|
|
+ this.semiAnnual = this.semiAnnualOptions[index + (direction === 'left' ? -1 : 1)];
|
|
|
}
|
|
|
|
|
|
getNotificationTypeText(t: number) {
|
|
@@ -223,11 +278,6 @@ export class InspectionPlanComponent {
|
|
|
closeFormDrawer() {
|
|
|
this.formConfig.visible = false;
|
|
|
}
|
|
|
- handleFetch() {
|
|
|
- this.plans = Array.from({ length: getRandomSizeN(30) }, (_, i) =>
|
|
|
- getMockPlan(i, this.getSemiAnnualLabel(this.semiAnnualKey))
|
|
|
- );
|
|
|
- }
|
|
|
async handleFetchDetail(id: number) {
|
|
|
this.fetchingDetail = true;
|
|
|
await this.api.hazard
|
|
@@ -244,10 +294,10 @@ export class InspectionPlanComponent {
|
|
|
});
|
|
|
}
|
|
|
get currentSemiAnnualOptionIndex() {
|
|
|
- return this.semiAnnualOptions.findIndex(se => se.value === this.semiAnnualKey);
|
|
|
+ return this.semiAnnualOptions.findIndex(se => se.key === this.semiAnnual?.key);
|
|
|
}
|
|
|
get semiAnnualText() {
|
|
|
- return this.semiAnnualOptions.find(se => se.value === this.semiAnnualKey)?.label || '';
|
|
|
+ return this.semiAnnualOptions.find(se => se.key === this.semiAnnual?.key)?.label || '';
|
|
|
}
|
|
|
get leftArrowVisible() {
|
|
|
const index = this.currentSemiAnnualOptionIndex;
|