feat: add generated code
This commit is contained in:
205
backend/prisma/schema.prisma
Normal file
205
backend/prisma/schema.prisma
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
datasource db {
|
||||||
|
provider = "postgresql"
|
||||||
|
url = env("DATABASE_URL")
|
||||||
|
}
|
||||||
|
|
||||||
|
generator client {
|
||||||
|
provider = "prisma-client-js"
|
||||||
|
}
|
||||||
|
|
||||||
|
enum EquipmentStatus {
|
||||||
|
Active
|
||||||
|
Repair
|
||||||
|
Reserve
|
||||||
|
WriteOff
|
||||||
|
}
|
||||||
|
|
||||||
|
enum laborOperation {
|
||||||
|
Manual
|
||||||
|
MachineManual
|
||||||
|
Machine
|
||||||
|
}
|
||||||
|
|
||||||
|
enum EnumPeriodicityTO {
|
||||||
|
Ежедневное
|
||||||
|
Еженедельное
|
||||||
|
Ежемесячное
|
||||||
|
Полугодовое
|
||||||
|
Годовое
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Role {
|
||||||
|
Исполнитель
|
||||||
|
Подписант
|
||||||
|
Пользователь
|
||||||
|
}
|
||||||
|
|
||||||
|
enum CategoryPart {
|
||||||
|
Расходник
|
||||||
|
Запчасть
|
||||||
|
Инструмент
|
||||||
|
Спецодежда
|
||||||
|
}
|
||||||
|
|
||||||
|
enum EquipmentType {
|
||||||
|
Производственное
|
||||||
|
Энергетическое
|
||||||
|
Насосное
|
||||||
|
Компрессорное
|
||||||
|
}
|
||||||
|
|
||||||
|
enum RepairKind {
|
||||||
|
TO
|
||||||
|
TR
|
||||||
|
TRE
|
||||||
|
KR
|
||||||
|
AR
|
||||||
|
MP
|
||||||
|
}
|
||||||
|
|
||||||
|
enum RepairOrderStatus {
|
||||||
|
Draft
|
||||||
|
Approved
|
||||||
|
InWork
|
||||||
|
Done
|
||||||
|
Cancelled
|
||||||
|
}
|
||||||
|
|
||||||
|
model Equipment {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
name String
|
||||||
|
serialNumber String
|
||||||
|
dateOfInspection DateTime? @db.Date
|
||||||
|
inventoryNumber String @unique
|
||||||
|
equipmentType EquipmentType
|
||||||
|
periodicityTO EnumPeriodicityTO
|
||||||
|
status EquipmentStatus @default(Active)
|
||||||
|
commissionedAt DateTime? @db.Date
|
||||||
|
totalEngineHours Decimal?
|
||||||
|
engineHoursSinceLastRepair Decimal?
|
||||||
|
lastRepairAt DateTime? @db.Date
|
||||||
|
notes String?
|
||||||
|
workAsPartOf laborOperation?
|
||||||
|
fuelСonsumed Float?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
// Relations
|
||||||
|
repairOrders RepairOrder[]
|
||||||
|
changeEquipmentStatuses ChangeEquipmentStatus[]
|
||||||
|
consumptionRegistrations ConsumptionRegistration[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Employee {
|
||||||
|
code String @id
|
||||||
|
fullName String
|
||||||
|
role Role
|
||||||
|
position String
|
||||||
|
price Float?
|
||||||
|
phoneNumber Float?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
// Self-referential relation for boss/subordinates
|
||||||
|
bossCode String?
|
||||||
|
boss Employee? @relation("EmployeeBoss", fields: [bossCode], references: [code])
|
||||||
|
subordinates Employee[] @relation("EmployeeBoss")
|
||||||
|
|
||||||
|
// Relations
|
||||||
|
confirmationDocuments ConfirmationDocument[]
|
||||||
|
categoryResources CategoryResource[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Part {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
name String
|
||||||
|
categories CategoryPart?
|
||||||
|
price Float?
|
||||||
|
description String?
|
||||||
|
serialNumber String?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
// Relations
|
||||||
|
categoryResources CategoryResource[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model CategoryResource {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
partId String?
|
||||||
|
employeeCode String?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
// Relations
|
||||||
|
part Part? @relation(fields: [partId], references: [id])
|
||||||
|
employee Employee? @relation(fields: [employeeCode], references: [code])
|
||||||
|
}
|
||||||
|
|
||||||
|
model RepairOrder {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
number String @unique
|
||||||
|
date DateTime @db.Date
|
||||||
|
equipmentId String
|
||||||
|
repairKind RepairKind
|
||||||
|
status RepairOrderStatus @default(Draft)
|
||||||
|
plannedAt DateTime @db.Date
|
||||||
|
startedAt DateTime? @db.Date
|
||||||
|
completedAt DateTime? @db.Date
|
||||||
|
contractor String?
|
||||||
|
engineHoursAtRepair Decimal?
|
||||||
|
description String?
|
||||||
|
notes String?
|
||||||
|
confirmed Boolean?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
// Relations
|
||||||
|
equipment Equipment @relation(fields: [equipmentId], references: [id])
|
||||||
|
confirmationDocuments ConfirmationDocument[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model ChangeEquipmentStatus {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
equipmentId String
|
||||||
|
newStatus EquipmentStatus
|
||||||
|
number String?
|
||||||
|
comment String?
|
||||||
|
date DateTime @db.Date
|
||||||
|
responsible String?
|
||||||
|
document String? // Storing file path/URL
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
// Relations
|
||||||
|
equipment Equipment @relation(fields: [equipmentId], references: [id])
|
||||||
|
}
|
||||||
|
|
||||||
|
model ConfirmationDocument {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
number String?
|
||||||
|
date DateTime @db.Date
|
||||||
|
managerCode String?
|
||||||
|
orderId String
|
||||||
|
confirmed Boolean?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
// Relations
|
||||||
|
manager Employee? @relation(fields: [managerCode], references: [code])
|
||||||
|
order RepairOrder @relation(fields: [orderId], references: [id])
|
||||||
|
}
|
||||||
|
|
||||||
|
model ConsumptionRegistration {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
number String?
|
||||||
|
date DateTime @db.Date
|
||||||
|
equipmentId String
|
||||||
|
totalEngineHours Decimal?
|
||||||
|
fuelConsumption Float?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
// Relations
|
||||||
|
equipment Equipment @relation(fields: [equipmentId], references: [id])
|
||||||
|
}
|
||||||
27
backend/src/app.module.ts
Normal file
27
backend/src/app.module.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { EquipmentModule } from './equipment/equipment.module';
|
||||||
|
import { EmployeeModule } from './employee/employee.module';
|
||||||
|
import { PartModule } from './part/part.module';
|
||||||
|
import { CategoryResourceModule } from './category-resource/category-resource.module';
|
||||||
|
import { RepairOrderModule } from './repair-order/repair-order.module';
|
||||||
|
import { ChangeEquipmentStatusModule } from './change-equipment-status/change-equipment-status.module';
|
||||||
|
import { ConfirmationDocumentModule } from './confirmation-document/confirmation-document.module';
|
||||||
|
import { ConsumptionRegistrationModule } from './consumption-registration/consumption-registration.module';
|
||||||
|
import { AuthModule } from './auth/auth.module';
|
||||||
|
import { PrismaService } from './prisma/prisma.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
AuthModule,
|
||||||
|
EquipmentModule,
|
||||||
|
EmployeeModule,
|
||||||
|
PartModule,
|
||||||
|
CategoryResourceModule,
|
||||||
|
RepairOrderModule,
|
||||||
|
ChangeEquipmentStatusModule,
|
||||||
|
ConfirmationDocumentModule,
|
||||||
|
ConsumptionRegistrationModule,
|
||||||
|
],
|
||||||
|
providers: [PrismaService],
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseGuards } from '@nestjs/common';
|
||||||
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { CategoryResourceService } from './category-resource.service';
|
||||||
|
import { CreateCategoryResourceDto } from './dto/create-category-resource.dto';
|
||||||
|
import { UpdateCategoryResourceDto } from './dto/update-category-resource.dto';
|
||||||
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||||
|
|
||||||
|
const parseJson = <T>(value?: string): T | undefined => {
|
||||||
|
if (!value) return undefined;
|
||||||
|
try { return JSON.parse(value) as T; } catch { return undefined; }
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiTags('category-resource')
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@UseGuards(JwtAuthGuard)
|
||||||
|
@Controller('category-resource')
|
||||||
|
export class CategoryResourceController {
|
||||||
|
constructor(private readonly categoryResourceService: CategoryResourceService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
findAll(
|
||||||
|
@Query('skip') skip?: string,
|
||||||
|
@Query('take') take?: string,
|
||||||
|
@Query('orderBy') orderBy?: string,
|
||||||
|
@Query('where') where?: string,
|
||||||
|
) {
|
||||||
|
return this.categoryResourceService.findAll({
|
||||||
|
skip: skip ? Number(skip) : 0,
|
||||||
|
take: take ? Number(take) : 25,
|
||||||
|
orderBy: parseJson(orderBy),
|
||||||
|
where: parseJson(where),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
findOne(@Param('id') id: string) {
|
||||||
|
return this.categoryResourceService.findOne({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
create(@Body() dto: CreateCategoryResourceDto) {
|
||||||
|
return this.categoryResourceService.create(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id')
|
||||||
|
update(@Param('id') id: string, @Body() dto: UpdateCategoryResourceDto) {
|
||||||
|
return this.categoryResourceService.update({ where: { id }, data: dto });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
remove(@Param('id') id: string) {
|
||||||
|
return this.categoryResourceService.remove({ id });
|
||||||
|
}
|
||||||
|
}
|
||||||
10
backend/src/category-resource/category-resource.module.ts
Normal file
10
backend/src/category-resource/category-resource.module.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { CategoryResourceService } from './category-resource.service';
|
||||||
|
import { CategoryResourceController } from './category-resource.controller';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [CategoryResourceController],
|
||||||
|
providers: [CategoryResourceService, PrismaService],
|
||||||
|
})
|
||||||
|
export class CategoryResourceModule {}
|
||||||
41
backend/src/category-resource/category-resource.service.ts
Normal file
41
backend/src/category-resource/category-resource.service.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
import { CategoryResource, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CategoryResourceService {
|
||||||
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
|
async findAll(params: {
|
||||||
|
skip?: number;
|
||||||
|
take?: number;
|
||||||
|
where?: Prisma.CategoryResourceWhereInput;
|
||||||
|
orderBy?: Prisma.CategoryResourceOrderByWithRelationInput;
|
||||||
|
}): Promise<{ data: CategoryResource[]; total: number }> {
|
||||||
|
const { skip, take, where, orderBy } = params;
|
||||||
|
const [data, total] = await this.prisma.$transaction([
|
||||||
|
this.prisma.categoryResource.findMany({ skip, take, where, orderBy }),
|
||||||
|
this.prisma.categoryResource.count({ where }),
|
||||||
|
]);
|
||||||
|
return { data, total };
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(where: Prisma.CategoryResourceWhereUniqueInput): Promise<CategoryResource | null> {
|
||||||
|
return this.prisma.categoryResource.findUnique({ where });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: Prisma.CategoryResourceCreateInput): Promise<CategoryResource> {
|
||||||
|
return this.prisma.categoryResource.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(params: {
|
||||||
|
where: Prisma.CategoryResourceWhereUniqueInput;
|
||||||
|
data: Prisma.CategoryResourceUpdateInput;
|
||||||
|
}): Promise<CategoryResource> {
|
||||||
|
return this.prisma.categoryResource.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(where: Prisma.CategoryResourceWhereUniqueInput): Promise<CategoryResource> {
|
||||||
|
return this.prisma.categoryResource.delete({ where });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsString, IsOptional } from 'class-validator';
|
||||||
|
|
||||||
|
export class CreateCategoryResourceDto {
|
||||||
|
@ApiProperty({ description: 'Идентификатор ЗИП/ТМЦ', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
partId?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Код сотрудника', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
employeeCode?: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { PartialType } from '@nestjs/mapped-types';
|
||||||
|
import { CreateCategoryResourceDto } from './create-category-resource.dto';
|
||||||
|
|
||||||
|
export class UpdateCategoryResourceDto extends PartialType(CreateCategoryResourceDto) {}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseGuards } from '@nestjs/common';
|
||||||
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { ChangeEquipmentStatusService } from './change-equipment-status.service';
|
||||||
|
import { CreateChangeEquipmentStatusDto } from './dto/create-change-equipment-status.dto';
|
||||||
|
import { UpdateChangeEquipmentStatusDto } from './dto/update-change-equipment-status.dto';
|
||||||
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||||
|
|
||||||
|
const parseJson = <T>(value?: string): T | undefined => {
|
||||||
|
if (!value) return undefined;
|
||||||
|
try { return JSON.parse(value) as T; } catch { return undefined; }
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiTags('change-equipment-status')
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@UseGuards(JwtAuthGuard)
|
||||||
|
@Controller('change-equipment-status')
|
||||||
|
export class ChangeEquipmentStatusController {
|
||||||
|
constructor(private readonly changeEquipmentStatusService: ChangeEquipmentStatusService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
findAll(
|
||||||
|
@Query('skip') skip?: string,
|
||||||
|
@Query('take') take?: string,
|
||||||
|
@Query('orderBy') orderBy?: string,
|
||||||
|
@Query('where') where?: string,
|
||||||
|
) {
|
||||||
|
return this.changeEquipmentStatusService.findAll({
|
||||||
|
skip: skip ? Number(skip) : 0,
|
||||||
|
take: take ? Number(take) : 25,
|
||||||
|
orderBy: parseJson(orderBy),
|
||||||
|
where: parseJson(where),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
findOne(@Param('id') id: string) {
|
||||||
|
return this.changeEquipmentStatusService.findOne({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
create(@Body() dto: CreateChangeEquipmentStatusDto) {
|
||||||
|
return this.changeEquipmentStatusService.create(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id')
|
||||||
|
update(@Param('id') id: string, @Body() dto: UpdateChangeEquipmentStatusDto) {
|
||||||
|
return this.changeEquipmentStatusService.update({ where: { id }, data: dto });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
remove(@Param('id') id: string) {
|
||||||
|
return this.changeEquipmentStatusService.remove({ id });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ChangeEquipmentStatusService } from './change-equipment-status.service';
|
||||||
|
import { ChangeEquipmentStatusController } from './change-equipment-status.controller';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [ChangeEquipmentStatusController],
|
||||||
|
providers: [ChangeEquipmentStatusService, PrismaService],
|
||||||
|
})
|
||||||
|
export class ChangeEquipmentStatusModule {}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
import { ChangeEquipmentStatus, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ChangeEquipmentStatusService {
|
||||||
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
|
async findAll(params: {
|
||||||
|
skip?: number;
|
||||||
|
take?: number;
|
||||||
|
where?: Prisma.ChangeEquipmentStatusWhereInput;
|
||||||
|
orderBy?: Prisma.ChangeEquipmentStatusOrderByWithRelationInput;
|
||||||
|
}): Promise<{ data: ChangeEquipmentStatus[]; total: number }> {
|
||||||
|
const { skip, take, where, orderBy } = params;
|
||||||
|
const [data, total] = await this.prisma.$transaction([
|
||||||
|
this.prisma.changeEquipmentStatus.findMany({ skip, take, where, orderBy }),
|
||||||
|
this.prisma.changeEquipmentStatus.count({ where }),
|
||||||
|
]);
|
||||||
|
return { data, total };
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(where: Prisma.ChangeEquipmentStatusWhereUniqueInput): Promise<ChangeEquipmentStatus | null> {
|
||||||
|
return this.prisma.changeEquipmentStatus.findUnique({ where });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: Prisma.ChangeEquipmentStatusCreateInput): Promise<ChangeEquipmentStatus> {
|
||||||
|
return this.prisma.changeEquipmentStatus.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(params: {
|
||||||
|
where: Prisma.ChangeEquipmentStatusWhereUniqueInput;
|
||||||
|
data: Prisma.ChangeEquipmentStatusUpdateInput;
|
||||||
|
}): Promise<ChangeEquipmentStatus> {
|
||||||
|
return this.prisma.changeEquipmentStatus.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(where: Prisma.ChangeEquipmentStatusWhereUniqueInput): Promise<ChangeEquipmentStatus> {
|
||||||
|
return this.prisma.changeEquipmentStatus.delete({ where });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Type } from 'class-transformer';
|
||||||
|
import { IsString, IsNotEmpty, IsEnum, IsISO8601, IsOptional } from 'class-validator';
|
||||||
|
import { EquipmentStatus } from '@prisma/client';
|
||||||
|
|
||||||
|
export class CreateChangeEquipmentStatusDto {
|
||||||
|
@ApiProperty({ description: 'Идентификатор оборудования' })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
equipmentId: string;
|
||||||
|
|
||||||
|
@ApiProperty({ enum: EquipmentStatus, enumName: 'EquipmentStatus', description: 'Новый статус' })
|
||||||
|
@IsEnum(EquipmentStatus)
|
||||||
|
newStatus: EquipmentStatus;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Номер', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
number?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Комментарий', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
comment?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Дата изменения статуса' })
|
||||||
|
@IsISO8601()
|
||||||
|
@Type(() => Date)
|
||||||
|
date: Date;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Ответственный', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
responsible?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Прикрепить документ (путь/URL)', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
document?: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { PartialType } from '@nestjs/mapped-types';
|
||||||
|
import { CreateChangeEquipmentStatusDto } from './create-change-equipment-status.dto';
|
||||||
|
|
||||||
|
export class UpdateChangeEquipmentStatusDto extends PartialType(CreateChangeEquipmentStatusDto) {}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseGuards } from '@nestjs/common';
|
||||||
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { ConfirmationDocumentService } from './confirmation-document.service';
|
||||||
|
import { CreateConfirmationDocumentDto } from './dto/create-confirmation-document.dto';
|
||||||
|
import { UpdateConfirmationDocumentDto } from './dto/update-confirmation-document.dto';
|
||||||
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||||
|
|
||||||
|
const parseJson = <T>(value?: string): T | undefined => {
|
||||||
|
if (!value) return undefined;
|
||||||
|
try { return JSON.parse(value) as T; } catch { return undefined; }
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiTags('confirmation-document')
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@UseGuards(JwtAuthGuard)
|
||||||
|
@Controller('confirmation-document')
|
||||||
|
export class ConfirmationDocumentController {
|
||||||
|
constructor(private readonly confirmationDocumentService: ConfirmationDocumentService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
findAll(
|
||||||
|
@Query('skip') skip?: string,
|
||||||
|
@Query('take') take?: string,
|
||||||
|
@Query('orderBy') orderBy?: string,
|
||||||
|
@Query('where') where?: string,
|
||||||
|
) {
|
||||||
|
return this.confirmationDocumentService.findAll({
|
||||||
|
skip: skip ? Number(skip) : 0,
|
||||||
|
take: take ? Number(take) : 25,
|
||||||
|
orderBy: parseJson(orderBy),
|
||||||
|
where: parseJson(where),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
findOne(@Param('id') id: string) {
|
||||||
|
return this.confirmationDocumentService.findOne({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
create(@Body() dto: CreateConfirmationDocumentDto) {
|
||||||
|
return this.confirmationDocumentService.create(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id')
|
||||||
|
update(@Param('id') id: string, @Body() dto: UpdateConfirmationDocumentDto) {
|
||||||
|
return this.confirmationDocumentService.update({ where: { id }, data: dto });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
remove(@Param('id') id: string) {
|
||||||
|
return this.confirmationDocumentService.remove({ id });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ConfirmationDocumentService } from './confirmation-document.service';
|
||||||
|
import { ConfirmationDocumentController } from './confirmation-document.controller';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [ConfirmationDocumentController],
|
||||||
|
providers: [ConfirmationDocumentService, PrismaService],
|
||||||
|
})
|
||||||
|
export class ConfirmationDocumentModule {}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
import { ConfirmationDocument, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ConfirmationDocumentService {
|
||||||
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
|
async findAll(params: {
|
||||||
|
skip?: number;
|
||||||
|
take?: number;
|
||||||
|
where?: Prisma.ConfirmationDocumentWhereInput;
|
||||||
|
orderBy?: Prisma.ConfirmationDocumentOrderByWithRelationInput;
|
||||||
|
}): Promise<{ data: ConfirmationDocument[]; total: number }> {
|
||||||
|
const { skip, take, where, orderBy } = params;
|
||||||
|
const [data, total] = await this.prisma.$transaction([
|
||||||
|
this.prisma.confirmationDocument.findMany({ skip, take, where, orderBy }),
|
||||||
|
this.prisma.confirmationDocument.count({ where }),
|
||||||
|
]);
|
||||||
|
return { data, total };
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(where: Prisma.ConfirmationDocumentWhereUniqueInput): Promise<ConfirmationDocument | null> {
|
||||||
|
return this.prisma.confirmationDocument.findUnique({ where });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: Prisma.ConfirmationDocumentCreateInput): Promise<ConfirmationDocument> {
|
||||||
|
return this.prisma.confirmationDocument.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(params: {
|
||||||
|
where: Prisma.ConfirmationDocumentWhereUniqueInput;
|
||||||
|
data: Prisma.ConfirmationDocumentUpdateInput;
|
||||||
|
}): Promise<ConfirmationDocument> {
|
||||||
|
return this.prisma.confirmationDocument.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(where: Prisma.ConfirmationDocumentWhereUniqueInput): Promise<ConfirmationDocument> {
|
||||||
|
return this.prisma.confirmationDocument.delete({ where });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Type } from 'class-transformer';
|
||||||
|
import { IsString, IsNotEmpty, IsISO8601, IsOptional, IsBoolean } from 'class-validator';
|
||||||
|
|
||||||
|
export class CreateConfirmationDocumentDto {
|
||||||
|
@ApiProperty({ description: 'Номер', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
number?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Дата согласования' })
|
||||||
|
@IsISO8601()
|
||||||
|
@Type(() => Date)
|
||||||
|
date: Date;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Код руководителя, который согласовал', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
managerCode?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Идентификатор заявки, которую согласовал' })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
orderId: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Согласовано/Не согласовано', required: false })
|
||||||
|
@IsBoolean()
|
||||||
|
@IsOptional()
|
||||||
|
confirmed?: boolean;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { PartialType } from '@nestjs/mapped-types';
|
||||||
|
import { CreateConfirmationDocumentDto } from './create-confirmation-document.dto';
|
||||||
|
|
||||||
|
export class UpdateConfirmationDocumentDto extends PartialType(CreateConfirmationDocumentDto) {}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseGuards } from '@nestjs/common';
|
||||||
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { ConsumptionRegistrationService } from './consumption-registration.service';
|
||||||
|
import { CreateConsumptionRegistrationDto } from './dto/create-consumption-registration.dto';
|
||||||
|
import { UpdateConsumptionRegistrationDto } from './dto/update-consumption-registration.dto';
|
||||||
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||||
|
|
||||||
|
const parseJson = <T>(value?: string): T | undefined => {
|
||||||
|
if (!value) return undefined;
|
||||||
|
try { return JSON.parse(value) as T; } catch { return undefined; }
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiTags('consumption-registration')
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@UseGuards(JwtAuthGuard)
|
||||||
|
@Controller('consumption-registration')
|
||||||
|
export class ConsumptionRegistrationController {
|
||||||
|
constructor(private readonly consumptionRegistrationService: ConsumptionRegistrationService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
findAll(
|
||||||
|
@Query('skip') skip?: string,
|
||||||
|
@Query('take') take?: string,
|
||||||
|
@Query('orderBy') orderBy?: string,
|
||||||
|
@Query('where') where?: string,
|
||||||
|
) {
|
||||||
|
return this.consumptionRegistrationService.findAll({
|
||||||
|
skip: skip ? Number(skip) : 0,
|
||||||
|
take: take ? Number(take) : 25,
|
||||||
|
orderBy: parseJson(orderBy),
|
||||||
|
where: parseJson(where),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
findOne(@Param('id') id: string) {
|
||||||
|
return this.consumptionRegistrationService.findOne({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
create(@Body() dto: CreateConsumptionRegistrationDto) {
|
||||||
|
return this.consumptionRegistrationService.create(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id')
|
||||||
|
update(@Param('id') id: string, @Body() dto: UpdateConsumptionRegistrationDto) {
|
||||||
|
return this.consumptionRegistrationService.update({ where: { id }, data: dto });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
remove(@Param('id') id: string) {
|
||||||
|
return this.consumptionRegistrationService.remove({ id });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ConsumptionRegistrationService } from './consumption-registration.service';
|
||||||
|
import { ConsumptionRegistrationController } from './consumption-registration.controller';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [ConsumptionRegistrationController],
|
||||||
|
providers: [ConsumptionRegistrationService, PrismaService],
|
||||||
|
})
|
||||||
|
export class ConsumptionRegistrationModule {}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
import { ConsumptionRegistration, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ConsumptionRegistrationService {
|
||||||
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
|
async findAll(params: {
|
||||||
|
skip?: number;
|
||||||
|
take?: number;
|
||||||
|
where?: Prisma.ConsumptionRegistrationWhereInput;
|
||||||
|
orderBy?: Prisma.ConsumptionRegistrationOrderByWithRelationInput;
|
||||||
|
}): Promise<{ data: ConsumptionRegistration[]; total: number }> {
|
||||||
|
const { skip, take, where, orderBy } = params;
|
||||||
|
const [data, total] = await this.prisma.$transaction([
|
||||||
|
this.prisma.consumptionRegistration.findMany({ skip, take, where, orderBy }),
|
||||||
|
this.prisma.consumptionRegistration.count({ where }),
|
||||||
|
]);
|
||||||
|
return { data, total };
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(where: Prisma.ConsumptionRegistrationWhereUniqueInput): Promise<ConsumptionRegistration | null> {
|
||||||
|
return this.prisma.consumptionRegistration.findUnique({ where });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: Prisma.ConsumptionRegistrationCreateInput): Promise<ConsumptionRegistration> {
|
||||||
|
return this.prisma.consumptionRegistration.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(params: {
|
||||||
|
where: Prisma.ConsumptionRegistrationWhereUniqueInput;
|
||||||
|
data: Prisma.ConsumptionRegistrationUpdateInput;
|
||||||
|
}): Promise<ConsumptionRegistration> {
|
||||||
|
return this.prisma.consumptionRegistration.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(where: Prisma.ConsumptionRegistrationWhereUniqueInput): Promise<ConsumptionRegistration> {
|
||||||
|
return this.prisma.consumptionRegistration.delete({ where });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Type } from 'class-transformer';
|
||||||
|
import { IsString, IsNotEmpty, IsISO8601, IsOptional, IsNumber } from 'class-validator';
|
||||||
|
|
||||||
|
export class CreateConsumptionRegistrationDto {
|
||||||
|
@ApiProperty({ description: 'Номер', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
number?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Дата регистрации' })
|
||||||
|
@IsISO8601()
|
||||||
|
@Type(() => Date)
|
||||||
|
date: Date;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Идентификатор оборудования' })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
equipmentId: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Наработка', required: false })
|
||||||
|
@IsOptional()
|
||||||
|
totalEngineHours?: any;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Расход топлива', required: false })
|
||||||
|
@IsNumber()
|
||||||
|
@IsOptional()
|
||||||
|
fuelConsumption?: number;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { PartialType } from '@nestjs/mapped-types';
|
||||||
|
import { CreateConsumptionRegistrationDto } from './create-consumption-registration.dto';
|
||||||
|
|
||||||
|
export class UpdateConsumptionRegistrationDto extends PartialType(CreateConsumptionRegistrationDto) {}
|
||||||
39
backend/src/employee/dto/create-employee.dto.ts
Normal file
39
backend/src/employee/dto/create-employee.dto.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsString, IsNotEmpty, IsEnum, IsOptional, IsNumber } from 'class-validator';
|
||||||
|
import { Role } from '@prisma/client';
|
||||||
|
|
||||||
|
export class CreateEmployeeDto {
|
||||||
|
@ApiProperty({ description: 'Номер сотрудника (Табельный номер)' })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
code: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'ФИО сотрудника' })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
fullName: string;
|
||||||
|
|
||||||
|
@ApiProperty({ enum: Role, enumName: 'Role', description: 'Роль сотрудника' })
|
||||||
|
@IsEnum(Role)
|
||||||
|
role: Role;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Должность сотрудника' })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
position: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Код руководителя', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
bossCode?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Стоимость часа работы сотрудника', required: false })
|
||||||
|
@IsNumber()
|
||||||
|
@IsOptional()
|
||||||
|
price?: number;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Номер телефона', required: false })
|
||||||
|
@IsNumber()
|
||||||
|
@IsOptional()
|
||||||
|
phoneNumber?: number;
|
||||||
|
}
|
||||||
4
backend/src/employee/dto/update-employee.dto.ts
Normal file
4
backend/src/employee/dto/update-employee.dto.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import { PartialType } from '@nestjs/mapped-types';
|
||||||
|
import { CreateEmployeeDto } from './create-employee.dto';
|
||||||
|
|
||||||
|
export class UpdateEmployeeDto extends PartialType(CreateEmployeeDto) {}
|
||||||
54
backend/src/employee/employee.controller.ts
Normal file
54
backend/src/employee/employee.controller.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseGuards } from '@nestjs/common';
|
||||||
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { EmployeeService } from './employee.service';
|
||||||
|
import { CreateEmployeeDto } from './dto/create-employee.dto';
|
||||||
|
import { UpdateEmployeeDto } from './dto/update-employee.dto';
|
||||||
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||||
|
|
||||||
|
const parseJson = <T>(value?: string): T | undefined => {
|
||||||
|
if (!value) return undefined;
|
||||||
|
try { return JSON.parse(value) as T; } catch { return undefined; }
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiTags('employee')
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@UseGuards(JwtAuthGuard)
|
||||||
|
@Controller('employee')
|
||||||
|
export class EmployeeController {
|
||||||
|
constructor(private readonly employeeService: EmployeeService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
findAll(
|
||||||
|
@Query('skip') skip?: string,
|
||||||
|
@Query('take') take?: string,
|
||||||
|
@Query('orderBy') orderBy?: string,
|
||||||
|
@Query('where') where?: string,
|
||||||
|
) {
|
||||||
|
return this.employeeService.findAll({
|
||||||
|
skip: skip ? Number(skip) : 0,
|
||||||
|
take: take ? Number(take) : 25,
|
||||||
|
orderBy: parseJson(orderBy),
|
||||||
|
where: parseJson(where),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':code')
|
||||||
|
findOne(@Param('code') code: string) {
|
||||||
|
return this.employeeService.findOne({ code });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
create(@Body() dto: CreateEmployeeDto) {
|
||||||
|
return this.employeeService.create(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':code')
|
||||||
|
update(@Param('code') code: string, @Body() dto: UpdateEmployeeDto) {
|
||||||
|
return this.employeeService.update({ where: { code }, data: dto });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':code')
|
||||||
|
remove(@Param('code') code: string) {
|
||||||
|
return this.employeeService.remove({ code });
|
||||||
|
}
|
||||||
|
}
|
||||||
10
backend/src/employee/employee.module.ts
Normal file
10
backend/src/employee/employee.module.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { EmployeeService } from './employee.service';
|
||||||
|
import { EmployeeController } from './employee.controller';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [EmployeeController],
|
||||||
|
providers: [EmployeeService, PrismaService],
|
||||||
|
})
|
||||||
|
export class EmployeeModule {}
|
||||||
41
backend/src/employee/employee.service.ts
Normal file
41
backend/src/employee/employee.service.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
import { Employee, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class EmployeeService {
|
||||||
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
|
async findAll(params: {
|
||||||
|
skip?: number;
|
||||||
|
take?: number;
|
||||||
|
where?: Prisma.EmployeeWhereInput;
|
||||||
|
orderBy?: Prisma.EmployeeOrderByWithRelationInput;
|
||||||
|
}): Promise<{ data: Employee[]; total: number }> {
|
||||||
|
const { skip, take, where, orderBy } = params;
|
||||||
|
const [data, total] = await this.prisma.$transaction([
|
||||||
|
this.prisma.employee.findMany({ skip, take, where, orderBy }),
|
||||||
|
this.prisma.employee.count({ where }),
|
||||||
|
]);
|
||||||
|
return { data, total };
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(where: Prisma.EmployeeWhereUniqueInput): Promise<Employee | null> {
|
||||||
|
return this.prisma.employee.findUnique({ where });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: Prisma.EmployeeCreateInput): Promise<Employee> {
|
||||||
|
return this.prisma.employee.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(params: {
|
||||||
|
where: Prisma.EmployeeWhereUniqueInput;
|
||||||
|
data: Prisma.EmployeeUpdateInput;
|
||||||
|
}): Promise<Employee> {
|
||||||
|
return this.prisma.employee.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(where: Prisma.EmployeeWhereUniqueInput): Promise<Employee> {
|
||||||
|
return this.prisma.employee.delete({ where });
|
||||||
|
}
|
||||||
|
}
|
||||||
75
backend/src/equipment/dto/create-equipment.dto.ts
Normal file
75
backend/src/equipment/dto/create-equipment.dto.ts
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Type } from 'class-transformer';
|
||||||
|
import { IsString, IsNotEmpty, IsEnum, IsISO8601, IsOptional, IsNumber } from 'class-validator';
|
||||||
|
import { EquipmentType, EnumPeriodicityTO, EquipmentStatus, laborOperation } from '@prisma/client';
|
||||||
|
|
||||||
|
export class CreateEquipmentDto {
|
||||||
|
@ApiProperty({ description: 'Название оборудования' })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Заводской (серийный) номер' })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
serialNumber: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Инвентарный номер', required: true })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
inventoryNumber: string;
|
||||||
|
|
||||||
|
@ApiProperty({ enum: EquipmentType, enumName: 'EquipmentType', description: 'Тип оборудования' })
|
||||||
|
@IsEnum(EquipmentType)
|
||||||
|
equipmentType: EquipmentType;
|
||||||
|
|
||||||
|
@ApiProperty({ enum: EnumPeriodicityTO, enumName: 'EnumPeriodicityTO', description: 'Периодичность ТО' })
|
||||||
|
@IsEnum(EnumPeriodicityTO)
|
||||||
|
periodicityTO: EnumPeriodicityTO;
|
||||||
|
|
||||||
|
@ApiProperty({ enum: EquipmentStatus, enumName: 'EquipmentStatus', description: 'Текущий статус', required: false })
|
||||||
|
@IsEnum(EquipmentStatus)
|
||||||
|
@IsOptional()
|
||||||
|
status?: EquipmentStatus;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Дата проверки', required: false })
|
||||||
|
@IsISO8601()
|
||||||
|
@Type(() => Date)
|
||||||
|
@IsOptional()
|
||||||
|
dateOfInspection?: Date;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Год изготовления', required: false })
|
||||||
|
@IsISO8601()
|
||||||
|
@Type(() => Date)
|
||||||
|
@IsOptional()
|
||||||
|
commissionedAt?: Date;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Общая наработка, моточасов', required: false })
|
||||||
|
@IsOptional()
|
||||||
|
totalEngineHours?: any;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Наработка с последнего ремонта, моточасов', required: false })
|
||||||
|
@IsOptional()
|
||||||
|
engineHoursSinceLastRepair?: any;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Дата последнего ремонта', required: false })
|
||||||
|
@IsISO8601()
|
||||||
|
@Type(() => Date)
|
||||||
|
@IsOptional()
|
||||||
|
lastRepairAt?: Date;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Примечания', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
notes?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ enum: laborOperation, enumName: 'laborOperation', description: 'Работы в составе', required: false })
|
||||||
|
@IsEnum(laborOperation)
|
||||||
|
@IsOptional()
|
||||||
|
workAsPartOf?: laborOperation;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Расход топлива', required: false })
|
||||||
|
@IsNumber()
|
||||||
|
@IsOptional()
|
||||||
|
fuelСonsumed?: number;
|
||||||
|
}
|
||||||
4
backend/src/equipment/dto/update-equipment.dto.ts
Normal file
4
backend/src/equipment/dto/update-equipment.dto.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import { PartialType } from '@nestjs/mapped-types';
|
||||||
|
import { CreateEquipmentDto } from './create-equipment.dto';
|
||||||
|
|
||||||
|
export class UpdateEquipmentDto extends PartialType(CreateEquipmentDto) {}
|
||||||
54
backend/src/equipment/equipment.controller.ts
Normal file
54
backend/src/equipment/equipment.controller.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseGuards } from '@nestjs/common';
|
||||||
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { EquipmentService } from './equipment.service';
|
||||||
|
import { CreateEquipmentDto } from './dto/create-equipment.dto';
|
||||||
|
import { UpdateEquipmentDto } from './dto/update-equipment.dto';
|
||||||
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||||
|
|
||||||
|
const parseJson = <T>(value?: string): T | undefined => {
|
||||||
|
if (!value) return undefined;
|
||||||
|
try { return JSON.parse(value) as T; } catch { return undefined; }
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiTags('equipment')
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@UseGuards(JwtAuthGuard)
|
||||||
|
@Controller('equipment')
|
||||||
|
export class EquipmentController {
|
||||||
|
constructor(private readonly equipmentService: EquipmentService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
findAll(
|
||||||
|
@Query('skip') skip?: string,
|
||||||
|
@Query('take') take?: string,
|
||||||
|
@Query('orderBy') orderBy?: string,
|
||||||
|
@Query('where') where?: string,
|
||||||
|
) {
|
||||||
|
return this.equipmentService.findAll({
|
||||||
|
skip: skip ? Number(skip) : 0,
|
||||||
|
take: take ? Number(take) : 25,
|
||||||
|
orderBy: parseJson(orderBy),
|
||||||
|
where: parseJson(where),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
findOne(@Param('id') id: string) {
|
||||||
|
return this.equipmentService.findOne({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
create(@Body() dto: CreateEquipmentDto) {
|
||||||
|
return this.equipmentService.create(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id')
|
||||||
|
update(@Param('id') id: string, @Body() dto: UpdateEquipmentDto) {
|
||||||
|
return this.equipmentService.update({ where: { id }, data: dto });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
remove(@Param('id') id: string) {
|
||||||
|
return this.equipmentService.remove({ id });
|
||||||
|
}
|
||||||
|
}
|
||||||
10
backend/src/equipment/equipment.module.ts
Normal file
10
backend/src/equipment/equipment.module.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { EquipmentService } from './equipment.service';
|
||||||
|
import { EquipmentController } from './equipment.controller';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [EquipmentController],
|
||||||
|
providers: [EquipmentService, PrismaService],
|
||||||
|
})
|
||||||
|
export class EquipmentModule {}
|
||||||
41
backend/src/equipment/equipment.service.ts
Normal file
41
backend/src/equipment/equipment.service.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
import { Equipment, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class EquipmentService {
|
||||||
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
|
async findAll(params: {
|
||||||
|
skip?: number;
|
||||||
|
take?: number;
|
||||||
|
where?: Prisma.EquipmentWhereInput;
|
||||||
|
orderBy?: Prisma.EquipmentOrderByWithRelationInput;
|
||||||
|
}): Promise<{ data: Equipment[]; total: number }> {
|
||||||
|
const { skip, take, where, orderBy } = params;
|
||||||
|
const [data, total] = await this.prisma.$transaction([
|
||||||
|
this.prisma.equipment.findMany({ skip, take, where, orderBy }),
|
||||||
|
this.prisma.equipment.count({ where }),
|
||||||
|
]);
|
||||||
|
return { data, total };
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(where: Prisma.EquipmentWhereUniqueInput): Promise<Equipment | null> {
|
||||||
|
return this.prisma.equipment.findUnique({ where });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: Prisma.EquipmentCreateInput): Promise<Equipment> {
|
||||||
|
return this.prisma.equipment.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(params: {
|
||||||
|
where: Prisma.EquipmentWhereUniqueInput;
|
||||||
|
data: Prisma.EquipmentUpdateInput;
|
||||||
|
}): Promise<Equipment> {
|
||||||
|
return this.prisma.equipment.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(where: Prisma.EquipmentWhereUniqueInput): Promise<Equipment> {
|
||||||
|
return this.prisma.equipment.delete({ where });
|
||||||
|
}
|
||||||
|
}
|
||||||
30
backend/src/part/dto/create-part.dto.ts
Normal file
30
backend/src/part/dto/create-part.dto.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsString, IsNotEmpty, IsEnum, IsOptional, IsNumber } from 'class-validator';
|
||||||
|
import { CategoryPart } from '@prisma/client';
|
||||||
|
|
||||||
|
export class CreatePartDto {
|
||||||
|
@ApiProperty({ description: 'Название' })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@ApiProperty({ enum: CategoryPart, enumName: 'CategoryPart', description: 'Категории', required: false })
|
||||||
|
@IsEnum(CategoryPart)
|
||||||
|
@IsOptional()
|
||||||
|
categories?: CategoryPart;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Стоимость ЗИП/ТМЦ', required: false })
|
||||||
|
@IsNumber()
|
||||||
|
@IsOptional()
|
||||||
|
price?: number;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Описание ЗИП/ТМЦ', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
description?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Серийный номер запасных частей / инструментов / расходников', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
serialNumber?: string;
|
||||||
|
}
|
||||||
4
backend/src/part/dto/update-part.dto.ts
Normal file
4
backend/src/part/dto/update-part.dto.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import { PartialType } from '@nestjs/mapped-types';
|
||||||
|
import { CreatePartDto } from './create-part.dto';
|
||||||
|
|
||||||
|
export class UpdatePartDto extends PartialType(CreatePartDto) {}
|
||||||
54
backend/src/part/part.controller.ts
Normal file
54
backend/src/part/part.controller.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseGuards } from '@nestjs/common';
|
||||||
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { PartService } from './part.service';
|
||||||
|
import { CreatePartDto } from './dto/create-part.dto';
|
||||||
|
import { UpdatePartDto } from './dto/update-part.dto';
|
||||||
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||||
|
|
||||||
|
const parseJson = <T>(value?: string): T | undefined => {
|
||||||
|
if (!value) return undefined;
|
||||||
|
try { return JSON.parse(value) as T; } catch { return undefined; }
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiTags('part')
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@UseGuards(JwtAuthGuard)
|
||||||
|
@Controller('part')
|
||||||
|
export class PartController {
|
||||||
|
constructor(private readonly partService: PartService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
findAll(
|
||||||
|
@Query('skip') skip?: string,
|
||||||
|
@Query('take') take?: string,
|
||||||
|
@Query('orderBy') orderBy?: string,
|
||||||
|
@Query('where') where?: string,
|
||||||
|
) {
|
||||||
|
return this.partService.findAll({
|
||||||
|
skip: skip ? Number(skip) : 0,
|
||||||
|
take: take ? Number(take) : 25,
|
||||||
|
orderBy: parseJson(orderBy),
|
||||||
|
where: parseJson(where),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
findOne(@Param('id') id: string) {
|
||||||
|
return this.partService.findOne({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
create(@Body() dto: CreatePartDto) {
|
||||||
|
return this.partService.create(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id')
|
||||||
|
update(@Param('id') id: string, @Body() dto: UpdatePartDto) {
|
||||||
|
return this.partService.update({ where: { id }, data: dto });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
remove(@Param('id') id: string) {
|
||||||
|
return this.partService.remove({ id });
|
||||||
|
}
|
||||||
|
}
|
||||||
10
backend/src/part/part.module.ts
Normal file
10
backend/src/part/part.module.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { PartService } from './part.service';
|
||||||
|
import { PartController } from './part.controller';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [PartController],
|
||||||
|
providers: [PartService, PrismaService],
|
||||||
|
})
|
||||||
|
export class PartModule {}
|
||||||
41
backend/src/part/part.service.ts
Normal file
41
backend/src/part/part.service.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
import { Part, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class PartService {
|
||||||
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
|
async findAll(params: {
|
||||||
|
skip?: number;
|
||||||
|
take?: number;
|
||||||
|
where?: Prisma.PartWhereInput;
|
||||||
|
orderBy?: Prisma.PartOrderByWithRelationInput;
|
||||||
|
}): Promise<{ data: Part[]; total: number }> {
|
||||||
|
const { skip, take, where, orderBy } = params;
|
||||||
|
const [data, total] = await this.prisma.$transaction([
|
||||||
|
this.prisma.part.findMany({ skip, take, where, orderBy }),
|
||||||
|
this.prisma.part.count({ where }),
|
||||||
|
]);
|
||||||
|
return { data, total };
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(where: Prisma.PartWhereUniqueInput): Promise<Part | null> {
|
||||||
|
return this.prisma.part.findUnique({ where });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: Prisma.PartCreateInput): Promise<Part> {
|
||||||
|
return this.prisma.part.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(params: {
|
||||||
|
where: Prisma.PartWhereUniqueInput;
|
||||||
|
data: Prisma.PartUpdateInput;
|
||||||
|
}): Promise<Part> {
|
||||||
|
return this.prisma.part.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(where: Prisma.PartWhereUniqueInput): Promise<Part> {
|
||||||
|
return this.prisma.part.delete({ where });
|
||||||
|
}
|
||||||
|
}
|
||||||
71
backend/src/repair-order/dto/create-repair-order.dto.ts
Normal file
71
backend/src/repair-order/dto/create-repair-order.dto.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Type } from 'class-transformer';
|
||||||
|
import { IsString, IsNotEmpty, IsEnum, IsISO8601, IsOptional, IsBoolean } from 'class-validator';
|
||||||
|
import { RepairKind, RepairOrderStatus } from '@prisma/client';
|
||||||
|
|
||||||
|
export class CreateRepairOrderDto {
|
||||||
|
@ApiProperty({ description: 'Номер заявки' })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
number: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Дата заявки' })
|
||||||
|
@IsISO8601()
|
||||||
|
@Type(() => Date)
|
||||||
|
date: Date;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Идентификатор оборудования' })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
equipmentId: string;
|
||||||
|
|
||||||
|
@ApiProperty({ enum: RepairKind, enumName: 'RepairKind', description: 'Вид ремонта' })
|
||||||
|
@IsEnum(RepairKind)
|
||||||
|
repairKind: RepairKind;
|
||||||
|
|
||||||
|
@ApiProperty({ enum: RepairOrderStatus, enumName: 'RepairOrderStatus', description: 'Статус заявки', required: false })
|
||||||
|
@IsEnum(RepairOrderStatus)
|
||||||
|
@IsOptional()
|
||||||
|
status?: RepairOrderStatus;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Плановая дата начала' })
|
||||||
|
@IsISO8601()
|
||||||
|
@Type(() => Date)
|
||||||
|
plannedAt: Date;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Фактическая дата начала', required: false })
|
||||||
|
@IsISO8601()
|
||||||
|
@Type(() => Date)
|
||||||
|
@IsOptional()
|
||||||
|
startedAt?: Date;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Фактическая дата завершения', required: false })
|
||||||
|
@IsISO8601()
|
||||||
|
@Type(() => Date)
|
||||||
|
@IsOptional()
|
||||||
|
completedAt?: Date;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Подрядная организация (если внешний ремонт)', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
contractor?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Наработка на момент ремонта, моточасов', required: false })
|
||||||
|
@IsOptional()
|
||||||
|
engineHoursAtRepair?: any;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Описание работ / дефекта', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
description?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Примечания', required: false })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
notes?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Согласовано/Не согласовано', required: false })
|
||||||
|
@IsBoolean()
|
||||||
|
@IsOptional()
|
||||||
|
confirmed?: boolean;
|
||||||
|
}
|
||||||
4
backend/src/repair-order/dto/update-repair-order.dto.ts
Normal file
4
backend/src/repair-order/dto/update-repair-order.dto.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import { PartialType } from '@nestjs/mapped-types';
|
||||||
|
import { CreateRepairOrderDto } from './create-repair-order.dto';
|
||||||
|
|
||||||
|
export class UpdateRepairOrderDto extends PartialType(CreateRepairOrderDto) {}
|
||||||
54
backend/src/repair-order/repair-order.controller.ts
Normal file
54
backend/src/repair-order/repair-order.controller.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseGuards } from '@nestjs/common';
|
||||||
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { RepairOrderService } from './repair-order.service';
|
||||||
|
import { CreateRepairOrderDto } from './dto/create-repair-order.dto';
|
||||||
|
import { UpdateRepairOrderDto } from './dto/update-repair-order.dto';
|
||||||
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||||
|
|
||||||
|
const parseJson = <T>(value?: string): T | undefined => {
|
||||||
|
if (!value) return undefined;
|
||||||
|
try { return JSON.parse(value) as T; } catch { return undefined; }
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiTags('repair-order')
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@UseGuards(JwtAuthGuard)
|
||||||
|
@Controller('repair-order')
|
||||||
|
export class RepairOrderController {
|
||||||
|
constructor(private readonly repairOrderService: RepairOrderService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
findAll(
|
||||||
|
@Query('skip') skip?: string,
|
||||||
|
@Query('take') take?: string,
|
||||||
|
@Query('orderBy') orderBy?: string,
|
||||||
|
@Query('where') where?: string,
|
||||||
|
) {
|
||||||
|
return this.repairOrderService.findAll({
|
||||||
|
skip: skip ? Number(skip) : 0,
|
||||||
|
take: take ? Number(take) : 25,
|
||||||
|
orderBy: parseJson(orderBy),
|
||||||
|
where: parseJson(where),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
findOne(@Param('id') id: string) {
|
||||||
|
return this.repairOrderService.findOne({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
create(@Body() dto: CreateRepairOrderDto) {
|
||||||
|
return this.repairOrderService.create(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id')
|
||||||
|
update(@Param('id') id: string, @Body() dto: UpdateRepairOrderDto) {
|
||||||
|
return this.repairOrderService.update({ where: { id }, data: dto });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
remove(@Param('id') id: string) {
|
||||||
|
return this.repairOrderService.remove({ id });
|
||||||
|
}
|
||||||
|
}
|
||||||
10
backend/src/repair-order/repair-order.module.ts
Normal file
10
backend/src/repair-order/repair-order.module.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { RepairOrderService } from './repair-order.service';
|
||||||
|
import { RepairOrderController } from './repair-order.controller';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [RepairOrderController],
|
||||||
|
providers: [RepairOrderService, PrismaService],
|
||||||
|
})
|
||||||
|
export class RepairOrderModule {}
|
||||||
41
backend/src/repair-order/repair-order.service.ts
Normal file
41
backend/src/repair-order/repair-order.service.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
|
import { RepairOrder, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class RepairOrderService {
|
||||||
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
|
async findAll(params: {
|
||||||
|
skip?: number;
|
||||||
|
take?: number;
|
||||||
|
where?: Prisma.RepairOrderWhereInput;
|
||||||
|
orderBy?: Prisma.RepairOrderOrderByWithRelationInput;
|
||||||
|
}): Promise<{ data: RepairOrder[]; total: number }> {
|
||||||
|
const { skip, take, where, orderBy } = params;
|
||||||
|
const [data, total] = await this.prisma.$transaction([
|
||||||
|
this.prisma.repairOrder.findMany({ skip, take, where, orderBy }),
|
||||||
|
this.prisma.repairOrder.count({ where }),
|
||||||
|
]);
|
||||||
|
return { data, total };
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(where: Prisma.RepairOrderWhereUniqueInput): Promise<RepairOrder | null> {
|
||||||
|
return this.prisma.repairOrder.findUnique({ where });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: Prisma.RepairOrderCreateInput): Promise<RepairOrder> {
|
||||||
|
return this.prisma.repairOrder.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(params: {
|
||||||
|
where: Prisma.RepairOrderWhereUniqueInput;
|
||||||
|
data: Prisma.RepairOrderUpdateInput;
|
||||||
|
}): Promise<RepairOrder> {
|
||||||
|
return this.prisma.repairOrder.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(where: Prisma.RepairOrderWhereUniqueInput): Promise<RepairOrder> {
|
||||||
|
return this.prisma.repairOrder.delete({ where });
|
||||||
|
}
|
||||||
|
}
|
||||||
90
frontend/src/App.tsx
Normal file
90
frontend/src/App.tsx
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import { Admin, Resource } from 'react-admin';
|
||||||
|
import { dataProvider } from './dataProvider';
|
||||||
|
import { authProvider } from './authProvider';
|
||||||
|
|
||||||
|
// Equipment
|
||||||
|
import { EquipmentList, EquipmentCreate, EquipmentEdit, EquipmentShow } from './resources/equipment';
|
||||||
|
|
||||||
|
// Employee
|
||||||
|
import { EmployeeList, EmployeeCreate, EmployeeEdit, EmployeeShow } from './resources/employee';
|
||||||
|
|
||||||
|
// Part
|
||||||
|
import { PartList, PartCreate, PartEdit, PartShow } from './resources/part';
|
||||||
|
|
||||||
|
// CategoryResource
|
||||||
|
import { CategoryResourceList, CategoryResourceCreate, CategoryResourceEdit, CategoryResourceShow } from './resources/category-resource';
|
||||||
|
|
||||||
|
// RepairOrder
|
||||||
|
import { RepairOrderList, RepairOrderCreate, RepairOrderEdit, RepairOrderShow } from './resources/repair-order';
|
||||||
|
|
||||||
|
// ChangeEquipmentStatus
|
||||||
|
import { ChangeEquipmentStatusList, ChangeEquipmentStatusCreate, ChangeEquipmentStatusEdit, ChangeEquipmentStatusShow } from './resources/change-equipment-status';
|
||||||
|
|
||||||
|
// ConfirmationDocument
|
||||||
|
import { ConfirmationDocumentList, ConfirmationDocumentCreate, ConfirmationDocumentEdit, ConfirmationDocumentShow } from './resources/confirmation-document';
|
||||||
|
|
||||||
|
// ConsumptionRegistration
|
||||||
|
import { ConsumptionRegistrationList, ConsumptionRegistrationCreate, ConsumptionRegistrationEdit, ConsumptionRegistrationShow } from './resources/consumption-registration';
|
||||||
|
|
||||||
|
const App = () => (
|
||||||
|
<Admin dataProvider={dataProvider} authProvider={authProvider}>
|
||||||
|
<Resource
|
||||||
|
name="equipment"
|
||||||
|
list={EquipmentList}
|
||||||
|
create={EquipmentCreate}
|
||||||
|
edit={EquipmentEdit}
|
||||||
|
show={EquipmentShow}
|
||||||
|
/>
|
||||||
|
<Resource
|
||||||
|
name="employee"
|
||||||
|
list={EmployeeList}
|
||||||
|
create={EmployeeCreate}
|
||||||
|
edit={EmployeeEdit}
|
||||||
|
show={EmployeeShow}
|
||||||
|
/>
|
||||||
|
<Resource
|
||||||
|
name="part"
|
||||||
|
list={PartList}
|
||||||
|
create={PartCreate}
|
||||||
|
edit={PartEdit}
|
||||||
|
show={PartShow}
|
||||||
|
/>
|
||||||
|
<Resource
|
||||||
|
name="category-resource"
|
||||||
|
list={CategoryResourceList}
|
||||||
|
create={CategoryResourceCreate}
|
||||||
|
edit={CategoryResourceEdit}
|
||||||
|
show={CategoryResourceShow}
|
||||||
|
/>
|
||||||
|
<Resource
|
||||||
|
name="repair-order"
|
||||||
|
list={RepairOrderList}
|
||||||
|
create={RepairOrderCreate}
|
||||||
|
edit={RepairOrderEdit}
|
||||||
|
show={RepairOrderShow}
|
||||||
|
/>
|
||||||
|
<Resource
|
||||||
|
name="change-equipment-status"
|
||||||
|
list={ChangeEquipmentStatusList}
|
||||||
|
create={ChangeEquipmentStatusCreate}
|
||||||
|
edit={ChangeEquipmentStatusEdit}
|
||||||
|
show={ChangeEquipmentStatusShow}
|
||||||
|
/>
|
||||||
|
<Resource
|
||||||
|
name="confirmation-document"
|
||||||
|
list={ConfirmationDocumentList}
|
||||||
|
create={ConfirmationDocumentCreate}
|
||||||
|
edit={ConfirmationDocumentEdit}
|
||||||
|
show={ConfirmationDocumentShow}
|
||||||
|
/>
|
||||||
|
<Resource
|
||||||
|
name="consumption-registration"
|
||||||
|
list={ConsumptionRegistrationList}
|
||||||
|
create={ConsumptionRegistrationCreate}
|
||||||
|
edit={ConsumptionRegistrationEdit}
|
||||||
|
show={ConsumptionRegistrationShow}
|
||||||
|
/>
|
||||||
|
</Admin>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default App;
|
||||||
15
frontend/src/main.tsx
Normal file
15
frontend/src/main.tsx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom/client';
|
||||||
|
import App from './App';
|
||||||
|
import { initKeycloak } from './authProvider';
|
||||||
|
|
||||||
|
// Initialize Keycloak before rendering the app
|
||||||
|
initKeycloak().then(() => {
|
||||||
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<App />
|
||||||
|
</React.StrictMode>
|
||||||
|
);
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error('Failed to initialize Keycloak:', error);
|
||||||
|
});
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { Create, SimpleForm, ReferenceInput, SelectInput } from 'react-admin';
|
||||||
|
|
||||||
|
export const CategoryResourceCreate = () => (
|
||||||
|
<Create>
|
||||||
|
<SimpleForm>
|
||||||
|
<ReferenceInput source="partId" reference="part">
|
||||||
|
<SelectInput optionText="name" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<ReferenceInput source="employeeCode" reference="employee">
|
||||||
|
<SelectInput optionText="fullName" />
|
||||||
|
</ReferenceInput>
|
||||||
|
</SimpleForm>
|
||||||
|
</Create>
|
||||||
|
);
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { Edit, SimpleForm, ReferenceInput, SelectInput } from 'react-admin';
|
||||||
|
|
||||||
|
export const CategoryResourceEdit = () => (
|
||||||
|
<Edit>
|
||||||
|
<SimpleForm>
|
||||||
|
<ReferenceInput source="partId" reference="part">
|
||||||
|
<SelectInput optionText="name" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<ReferenceInput source="employeeCode" reference="employee">
|
||||||
|
<SelectInput optionText="fullName" />
|
||||||
|
</ReferenceInput>
|
||||||
|
</SimpleForm>
|
||||||
|
</Edit>
|
||||||
|
);
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { List, DataTable, TextField, ReferenceField, EditButton } from 'react-admin';
|
||||||
|
|
||||||
|
export const CategoryResourceList = () => (
|
||||||
|
<List>
|
||||||
|
<DataTable>
|
||||||
|
<DataTable.Col source="id" />
|
||||||
|
<DataTable.Col source="partId" />
|
||||||
|
<DataTable.Col source="employeeCode" />
|
||||||
|
<DataTable.Col><EditButton /></DataTable.Col>
|
||||||
|
</DataTable>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { Show, SimpleShowLayout, TextField, ReferenceField, DateField } from 'react-admin';
|
||||||
|
|
||||||
|
export const CategoryResourceShow = () => (
|
||||||
|
<Show>
|
||||||
|
<SimpleShowLayout>
|
||||||
|
<TextField source="id" />
|
||||||
|
<ReferenceField source="partId" reference="part">
|
||||||
|
<TextField source="name" />
|
||||||
|
</ReferenceField>
|
||||||
|
<ReferenceField source="employeeCode" reference="employee">
|
||||||
|
<TextField source="fullName" />
|
||||||
|
</ReferenceField>
|
||||||
|
<DateField source="createdAt" showTime />
|
||||||
|
<DateField source="updatedAt" showTime />
|
||||||
|
</SimpleShowLayout>
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
4
frontend/src/resources/category-resource/index.ts
Normal file
4
frontend/src/resources/category-resource/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export { CategoryResourceList } from './CategoryResourceList';
|
||||||
|
export { CategoryResourceCreate } from './CategoryResourceCreate';
|
||||||
|
export { CategoryResourceEdit } from './CategoryResourceEdit';
|
||||||
|
export { CategoryResourceShow } from './CategoryResourceShow';
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { Create, SimpleForm, TextInput, DateInput, SelectInput, ReferenceInput } from 'react-admin';
|
||||||
|
|
||||||
|
const equipmentStatusChoices = [
|
||||||
|
{ id: 'Active', name: 'В эксплуатации' },
|
||||||
|
{ id: 'Repair', name: 'В ремонте' },
|
||||||
|
{ id: 'Reserve', name: 'В резерве' },
|
||||||
|
{ id: 'WriteOff', name: 'Списано' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const ChangeEquipmentStatusCreate = () => (
|
||||||
|
<Create>
|
||||||
|
<SimpleForm>
|
||||||
|
<ReferenceInput source="equipmentId" reference="equipment">
|
||||||
|
<SelectInput optionText="name" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<SelectInput source="newStatus" choices={equipmentStatusChoices} />
|
||||||
|
<TextInput source="number" />
|
||||||
|
<TextInput multiline source="comment" />
|
||||||
|
<DateInput source="date" />
|
||||||
|
<TextInput source="responsible" />
|
||||||
|
<TextInput source="document" />
|
||||||
|
</SimpleForm>
|
||||||
|
</Create>
|
||||||
|
);
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { Edit, SimpleForm, TextInput, DateInput, SelectInput, ReferenceInput } from 'react-admin';
|
||||||
|
|
||||||
|
const equipmentStatusChoices = [
|
||||||
|
{ id: 'Active', name: 'В эксплуатации' },
|
||||||
|
{ id: 'Repair', name: 'В ремонте' },
|
||||||
|
{ id: 'Reserve', name: 'В резерве' },
|
||||||
|
{ id: 'WriteOff', name: 'Списано' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const ChangeEquipmentStatusEdit = () => (
|
||||||
|
<Edit>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput disabled source="id" />
|
||||||
|
<ReferenceInput source="equipmentId" reference="equipment">
|
||||||
|
<SelectInput optionText="name" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<SelectInput source="newStatus" choices={equipmentStatusChoices} />
|
||||||
|
<TextInput source="number" />
|
||||||
|
<TextInput multiline source="comment" />
|
||||||
|
<DateInput source="date" />
|
||||||
|
<TextInput source="responsible" />
|
||||||
|
<TextInput source="document" />
|
||||||
|
</SimpleForm>
|
||||||
|
</Edit>
|
||||||
|
);
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { List, DataTable, TextField, DateField, EditButton } from 'react-admin';
|
||||||
|
|
||||||
|
export const ChangeEquipmentStatusList = () => (
|
||||||
|
<List>
|
||||||
|
<DataTable>
|
||||||
|
<DataTable.Col source="id" />
|
||||||
|
<DataTable.Col source="equipmentId" />
|
||||||
|
<DataTable.Col source="newStatus" />
|
||||||
|
<DataTable.Col source="number" />
|
||||||
|
<DataTable.Col source="date" field={DateField} />
|
||||||
|
<DataTable.Col source="responsible" />
|
||||||
|
<DataTable.Col><EditButton /></DataTable.Col>
|
||||||
|
</DataTable>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { Show, SimpleShowLayout, TextField, DateField, ReferenceField } from 'react-admin';
|
||||||
|
|
||||||
|
export const ChangeEquipmentStatusShow = () => (
|
||||||
|
<Show>
|
||||||
|
<SimpleShowLayout>
|
||||||
|
<TextField source="id" />
|
||||||
|
<ReferenceField source="equipmentId" reference="equipment">
|
||||||
|
<TextField source="name" />
|
||||||
|
</ReferenceField>
|
||||||
|
<TextField source="newStatus" />
|
||||||
|
<TextField source="number" />
|
||||||
|
<TextField source="comment" />
|
||||||
|
<DateField source="date" />
|
||||||
|
<TextField source="responsible" />
|
||||||
|
<TextField source="document" />
|
||||||
|
<DateField source="createdAt" showTime />
|
||||||
|
<DateField source="updatedAt" showTime />
|
||||||
|
</SimpleShowLayout>
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
4
frontend/src/resources/change-equipment-status/index.ts
Normal file
4
frontend/src/resources/change-equipment-status/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export { ChangeEquipmentStatusList } from './ChangeEquipmentStatusList';
|
||||||
|
export { ChangeEquipmentStatusCreate } from './ChangeEquipmentStatusCreate';
|
||||||
|
export { ChangeEquipmentStatusEdit } from './ChangeEquipmentStatusEdit';
|
||||||
|
export { ChangeEquipmentStatusShow } from './ChangeEquipmentStatusShow';
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { Create, SimpleForm, TextInput, DateInput, BooleanInput, ReferenceInput, SelectInput } from 'react-admin';
|
||||||
|
|
||||||
|
export const ConfirmationDocumentCreate = () => (
|
||||||
|
<Create>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput source="number" />
|
||||||
|
<DateInput source="date" />
|
||||||
|
<ReferenceInput source="managerCode" reference="employee">
|
||||||
|
<SelectInput optionText="fullName" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<ReferenceInput source="orderId" reference="repair-order">
|
||||||
|
<SelectInput optionText="number" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<BooleanInput source="confirmed" />
|
||||||
|
</SimpleForm>
|
||||||
|
</Create>
|
||||||
|
);
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { Edit, SimpleForm, TextInput, DateInput, BooleanInput, ReferenceInput, SelectInput } from 'react-admin';
|
||||||
|
|
||||||
|
export const ConfirmationDocumentEdit = () => (
|
||||||
|
<Edit>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput disabled source="id" />
|
||||||
|
<TextInput source="number" />
|
||||||
|
<DateInput source="date" />
|
||||||
|
<ReferenceInput source="managerCode" reference="employee">
|
||||||
|
<SelectInput optionText="fullName" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<ReferenceInput source="orderId" reference="repair-order">
|
||||||
|
<SelectInput optionText="number" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<BooleanInput source="confirmed" />
|
||||||
|
</SimpleForm>
|
||||||
|
</Edit>
|
||||||
|
);
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { List, DataTable, TextField, DateField, BooleanField, EditButton } from 'react-admin';
|
||||||
|
|
||||||
|
export const ConfirmationDocumentList = () => (
|
||||||
|
<List>
|
||||||
|
<DataTable>
|
||||||
|
<DataTable.Col source="id" />
|
||||||
|
<DataTable.Col source="number" />
|
||||||
|
<DataTable.Col source="date" field={DateField} />
|
||||||
|
<DataTable.Col source="managerCode" />
|
||||||
|
<DataTable.Col source="orderId" />
|
||||||
|
<DataTable.Col source="confirmed" field={BooleanField} />
|
||||||
|
<DataTable.Col><EditButton /></DataTable.Col>
|
||||||
|
</DataTable>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { Show, SimpleShowLayout, TextField, DateField, BooleanField, ReferenceField } from 'react-admin';
|
||||||
|
|
||||||
|
export const ConfirmationDocumentShow = () => (
|
||||||
|
<Show>
|
||||||
|
<SimpleShowLayout>
|
||||||
|
<TextField source="id" />
|
||||||
|
<TextField source="number" />
|
||||||
|
<DateField source="date" />
|
||||||
|
<ReferenceField source="managerCode" reference="employee">
|
||||||
|
<TextField source="fullName" />
|
||||||
|
</ReferenceField>
|
||||||
|
<ReferenceField source="orderId" reference="repair-order">
|
||||||
|
<TextField source="number" />
|
||||||
|
</ReferenceField>
|
||||||
|
<BooleanField source="confirmed" />
|
||||||
|
<DateField source="createdAt" showTime />
|
||||||
|
<DateField source="updatedAt" showTime />
|
||||||
|
</SimpleShowLayout>
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
4
frontend/src/resources/confirmation-document/index.ts
Normal file
4
frontend/src/resources/confirmation-document/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export { ConfirmationDocumentList } from './ConfirmationDocumentList';
|
||||||
|
export { ConfirmationDocumentCreate } from './ConfirmationDocumentCreate';
|
||||||
|
export { ConfirmationDocumentEdit } from './ConfirmationDocumentEdit';
|
||||||
|
export { ConfirmationDocumentShow } from './ConfirmationDocumentShow';
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { Create, SimpleForm, TextInput, DateInput, NumberInput, ReferenceInput, SelectInput } from 'react-admin';
|
||||||
|
|
||||||
|
export const ConsumptionRegistrationCreate = () => (
|
||||||
|
<Create>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput source="number" />
|
||||||
|
<DateInput source="date" />
|
||||||
|
<ReferenceInput source="equipmentId" reference="equipment">
|
||||||
|
<SelectInput optionText="name" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<NumberInput source="totalEngineHours" step={0.01} />
|
||||||
|
<NumberInput source="fuelConsumption" step={0.01} />
|
||||||
|
</SimpleForm>
|
||||||
|
</Create>
|
||||||
|
);
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { Edit, SimpleForm, TextInput, DateInput, NumberInput, ReferenceInput, SelectInput } from 'react-admin';
|
||||||
|
|
||||||
|
export const ConsumptionRegistrationEdit = () => (
|
||||||
|
<Edit>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput disabled source="id" />
|
||||||
|
<TextInput source="number" />
|
||||||
|
<DateInput source="date" />
|
||||||
|
<ReferenceInput source="equipmentId" reference="equipment">
|
||||||
|
<SelectInput optionText="name" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<NumberInput source="totalEngineHours" step={0.01} />
|
||||||
|
<NumberInput source="fuelConsumption" step={0.01} />
|
||||||
|
</SimpleForm>
|
||||||
|
</Edit>
|
||||||
|
);
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { List, DataTable, TextField, DateField, NumberField, EditButton } from 'react-admin';
|
||||||
|
|
||||||
|
export const ConsumptionRegistrationList = () => (
|
||||||
|
<List>
|
||||||
|
<DataTable>
|
||||||
|
<DataTable.Col source="id" />
|
||||||
|
<DataTable.Col source="number" />
|
||||||
|
<DataTable.Col source="date" field={DateField} />
|
||||||
|
<DataTable.Col source="equipmentId" />
|
||||||
|
<DataTable.Col source="totalEngineHours" field={NumberField} />
|
||||||
|
<DataTable.Col source="fuelConsumption" field={NumberField} />
|
||||||
|
<DataTable.Col><EditButton /></DataTable.Col>
|
||||||
|
</DataTable>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { Show, SimpleShowLayout, TextField, DateField, NumberField, ReferenceField } from 'react-admin';
|
||||||
|
|
||||||
|
export const ConsumptionRegistrationShow = () => (
|
||||||
|
<Show>
|
||||||
|
<SimpleShowLayout>
|
||||||
|
<TextField source="id" />
|
||||||
|
<TextField source="number" />
|
||||||
|
<DateField source="date" />
|
||||||
|
<ReferenceField source="equipmentId" reference="equipment">
|
||||||
|
<TextField source="name" />
|
||||||
|
</ReferenceField>
|
||||||
|
<NumberField source="totalEngineHours" />
|
||||||
|
<NumberField source="fuelConsumption" />
|
||||||
|
<DateField source="createdAt" showTime />
|
||||||
|
<DateField source="updatedAt" showTime />
|
||||||
|
</SimpleShowLayout>
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
4
frontend/src/resources/consumption-registration/index.ts
Normal file
4
frontend/src/resources/consumption-registration/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export { ConsumptionRegistrationList } from './ConsumptionRegistrationList';
|
||||||
|
export { ConsumptionRegistrationCreate } from './ConsumptionRegistrationCreate';
|
||||||
|
export { ConsumptionRegistrationEdit } from './ConsumptionRegistrationEdit';
|
||||||
|
export { ConsumptionRegistrationShow } from './ConsumptionRegistrationShow';
|
||||||
23
frontend/src/resources/employee/EmployeeCreate.tsx
Normal file
23
frontend/src/resources/employee/EmployeeCreate.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Create, SimpleForm, TextInput, NumberInput, SelectInput, ReferenceInput } from 'react-admin';
|
||||||
|
|
||||||
|
const roleChoices = [
|
||||||
|
{ id: 'Исполнитель', name: 'Исполнитель' },
|
||||||
|
{ id: 'Подписант', name: 'Подписант' },
|
||||||
|
{ id: 'Пользователь', name: 'Пользователь' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const EmployeeCreate = () => (
|
||||||
|
<Create>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput source="code" />
|
||||||
|
<TextInput source="fullName" />
|
||||||
|
<SelectInput source="role" choices={roleChoices} />
|
||||||
|
<TextInput source="position" />
|
||||||
|
<ReferenceInput source="bossCode" reference="employee">
|
||||||
|
<SelectInput optionText="fullName" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<NumberInput source="price" step={0.01} />
|
||||||
|
<NumberInput source="phoneNumber" step={0.01} />
|
||||||
|
</SimpleForm>
|
||||||
|
</Create>
|
||||||
|
);
|
||||||
23
frontend/src/resources/employee/EmployeeEdit.tsx
Normal file
23
frontend/src/resources/employee/EmployeeEdit.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Edit, SimpleForm, TextInput, NumberInput, SelectInput, ReferenceInput } from 'react-admin';
|
||||||
|
|
||||||
|
const roleChoices = [
|
||||||
|
{ id: 'Исполнитель', name: 'Исполнитель' },
|
||||||
|
{ id: 'Подписант', name: 'Подписант' },
|
||||||
|
{ id: 'Пользователь', name: 'Пользователь' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const EmployeeEdit = () => (
|
||||||
|
<Edit>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput disabled source="code" />
|
||||||
|
<TextInput source="fullName" />
|
||||||
|
<SelectInput source="role" choices={roleChoices} />
|
||||||
|
<TextInput source="position" />
|
||||||
|
<ReferenceInput source="bossCode" reference="employee">
|
||||||
|
<SelectInput optionText="fullName" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<NumberInput source="price" step={0.01} />
|
||||||
|
<NumberInput source="phoneNumber" step={0.01} />
|
||||||
|
</SimpleForm>
|
||||||
|
</Edit>
|
||||||
|
);
|
||||||
16
frontend/src/resources/employee/EmployeeList.tsx
Normal file
16
frontend/src/resources/employee/EmployeeList.tsx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { List, DataTable, TextField, NumberField, EditButton } from 'react-admin';
|
||||||
|
|
||||||
|
export const EmployeeList = () => (
|
||||||
|
<List>
|
||||||
|
<DataTable>
|
||||||
|
<DataTable.Col source="code" />
|
||||||
|
<DataTable.Col source="fullName" />
|
||||||
|
<DataTable.Col source="role" />
|
||||||
|
<DataTable.Col source="position" />
|
||||||
|
<DataTable.Col source="bossCode" />
|
||||||
|
<DataTable.Col source="price" field={NumberField} />
|
||||||
|
<DataTable.Col source="phoneNumber" field={NumberField} />
|
||||||
|
<DataTable.Col><EditButton /></DataTable.Col>
|
||||||
|
</DataTable>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
19
frontend/src/resources/employee/EmployeeShow.tsx
Normal file
19
frontend/src/resources/employee/EmployeeShow.tsx
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { Show, SimpleShowLayout, TextField, NumberField, DateField, ReferenceField } from 'react-admin';
|
||||||
|
|
||||||
|
export const EmployeeShow = () => (
|
||||||
|
<Show>
|
||||||
|
<SimpleShowLayout>
|
||||||
|
<TextField source="code" />
|
||||||
|
<TextField source="fullName" />
|
||||||
|
<TextField source="role" />
|
||||||
|
<TextField source="position" />
|
||||||
|
<ReferenceField source="bossCode" reference="employee">
|
||||||
|
<TextField source="fullName" />
|
||||||
|
</ReferenceField>
|
||||||
|
<NumberField source="price" />
|
||||||
|
<NumberField source="phoneNumber" />
|
||||||
|
<DateField source="createdAt" showTime />
|
||||||
|
<DateField source="updatedAt" showTime />
|
||||||
|
</SimpleShowLayout>
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
4
frontend/src/resources/employee/index.ts
Normal file
4
frontend/src/resources/employee/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export { EmployeeList } from './EmployeeList';
|
||||||
|
export { EmployeeCreate } from './EmployeeCreate';
|
||||||
|
export { EmployeeEdit } from './EmployeeEdit';
|
||||||
|
export { EmployeeShow } from './EmployeeShow';
|
||||||
50
frontend/src/resources/equipment/EquipmentCreate.tsx
Normal file
50
frontend/src/resources/equipment/EquipmentCreate.tsx
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { Create, SimpleForm, TextInput, DateInput, NumberInput, SelectInput } from 'react-admin';
|
||||||
|
|
||||||
|
const equipmentTypeChoices = [
|
||||||
|
{ id: 'Производственное', name: 'Производственное' },
|
||||||
|
{ id: 'Энергетическое', name: 'Энергетическое' },
|
||||||
|
{ id: 'Насосное', name: 'Насосное' },
|
||||||
|
{ id: 'Компрессорное', name: 'Компрессорное' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const equipmentStatusChoices = [
|
||||||
|
{ id: 'Active', name: 'В эксплуатации' },
|
||||||
|
{ id: 'Repair', name: 'В ремонте' },
|
||||||
|
{ id: 'Reserve', name: 'В резерве' },
|
||||||
|
{ id: 'WriteOff', name: 'Списано' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const periodicityTOChoices = [
|
||||||
|
{ id: 'Ежедневное', name: 'Ежедневное' },
|
||||||
|
{ id: 'Еженедельное', name: 'Еженедельное' },
|
||||||
|
{ id: 'Ежемесячное', name: 'Ежемесячное' },
|
||||||
|
{ id: 'Полугодовое', name: 'Полугодовое' },
|
||||||
|
{ id: 'Годовое', name: 'Годовое' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const laborOperationChoices = [
|
||||||
|
{ id: 'Manual', name: 'Ручные' },
|
||||||
|
{ id: 'MachineManual', name: 'Машинно-ручные' },
|
||||||
|
{ id: 'Machine', name: 'Машинные' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const EquipmentCreate = () => (
|
||||||
|
<Create>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput source="name" />
|
||||||
|
<TextInput source="serialNumber" />
|
||||||
|
<TextInput source="inventoryNumber" />
|
||||||
|
<SelectInput source="equipmentType" choices={equipmentTypeChoices} />
|
||||||
|
<SelectInput source="status" choices={equipmentStatusChoices} defaultValue="Active" />
|
||||||
|
<DateInput source="dateOfInspection" />
|
||||||
|
<SelectInput source="periodicityTO" choices={periodicityTOChoices} />
|
||||||
|
<DateInput source="commissionedAt" />
|
||||||
|
<NumberInput source="totalEngineHours" step={0.01} />
|
||||||
|
<NumberInput source="engineHoursSinceLastRepair" step={0.01} />
|
||||||
|
<DateInput source="lastRepairAt" />
|
||||||
|
<TextInput multiline source="notes" />
|
||||||
|
<SelectInput source="workAsPartOf" choices={laborOperationChoices} />
|
||||||
|
<NumberInput source="fuelСonsumed" step={0.01} />
|
||||||
|
</SimpleForm>
|
||||||
|
</Create>
|
||||||
|
);
|
||||||
51
frontend/src/resources/equipment/EquipmentEdit.tsx
Normal file
51
frontend/src/resources/equipment/EquipmentEdit.tsx
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { Edit, SimpleForm, TextInput, DateInput, NumberInput, SelectInput } from 'react-admin';
|
||||||
|
|
||||||
|
const equipmentTypeChoices = [
|
||||||
|
{ id: 'Производственное', name: 'Производственное' },
|
||||||
|
{ id: 'Энергетическое', name: 'Энергетическое' },
|
||||||
|
{ id: 'Насосное', name: 'Насосное' },
|
||||||
|
{ id: 'Компрессорное', name: 'Компрессорное' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const equipmentStatusChoices = [
|
||||||
|
{ id: 'Active', name: 'В эксплуатации' },
|
||||||
|
{ id: 'Repair', name: 'В ремонте' },
|
||||||
|
{ id: 'Reserve', name: 'В резерве' },
|
||||||
|
{ id: 'WriteOff', name: 'Списано' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const periodicityTOChoices = [
|
||||||
|
{ id: 'Ежедневное', name: 'Ежедневное' },
|
||||||
|
{ id: 'Еженедельное', name: 'Еженедельное' },
|
||||||
|
{ id: 'Ежемесячное', name: 'Ежемесячное' },
|
||||||
|
{ id: 'Полугодовое', name: 'Полугодовое' },
|
||||||
|
{ id: 'Годовое', name: 'Годовое' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const laborOperationChoices = [
|
||||||
|
{ id: 'Manual', name: 'Ручные' },
|
||||||
|
{ id: 'MachineManual', name: 'Машинно-ручные' },
|
||||||
|
{ id: 'Machine', name: 'Машинные' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const EquipmentEdit = () => (
|
||||||
|
<Edit>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput disabled source="id" />
|
||||||
|
<TextInput source="name" />
|
||||||
|
<TextInput source="serialNumber" />
|
||||||
|
<TextInput source="inventoryNumber" />
|
||||||
|
<SelectInput source="equipmentType" choices={equipmentTypeChoices} />
|
||||||
|
<SelectInput source="status" choices={equipmentStatusChoices} />
|
||||||
|
<DateInput source="dateOfInspection" />
|
||||||
|
<SelectInput source="periodicityTO" choices={periodicityTOChoices} />
|
||||||
|
<DateInput source="commissionedAt" />
|
||||||
|
<NumberInput source="totalEngineHours" step={0.01} />
|
||||||
|
<NumberInput source="engineHoursSinceLastRepair" step={0.01} />
|
||||||
|
<DateInput source="lastRepairAt" />
|
||||||
|
<TextInput multiline source="notes" />
|
||||||
|
<SelectInput source="workAsPartOf" choices={laborOperationChoices} />
|
||||||
|
<NumberInput source="fuelСonsumed" step={0.01} />
|
||||||
|
</SimpleForm>
|
||||||
|
</Edit>
|
||||||
|
);
|
||||||
21
frontend/src/resources/equipment/EquipmentList.tsx
Normal file
21
frontend/src/resources/equipment/EquipmentList.tsx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { List, DataTable, TextField, DateField, NumberField, EditButton } from 'react-admin';
|
||||||
|
|
||||||
|
export const EquipmentList = () => (
|
||||||
|
<List>
|
||||||
|
<DataTable>
|
||||||
|
<DataTable.Col source="id" />
|
||||||
|
<DataTable.Col source="name" />
|
||||||
|
<DataTable.Col source="serialNumber" />
|
||||||
|
<DataTable.Col source="inventoryNumber" />
|
||||||
|
<DataTable.Col source="equipmentType" />
|
||||||
|
<DataTable.Col source="status" />
|
||||||
|
<DataTable.Col source="dateOfInspection" field={DateField} />
|
||||||
|
<DataTable.Col source="periodicityTO" />
|
||||||
|
<DataTable.Col source="commissionedAt" field={DateField} />
|
||||||
|
<DataTable.Col source="totalEngineHours" field={NumberField} />
|
||||||
|
<DataTable.Col source="engineHoursSinceLastRepair" field={NumberField} />
|
||||||
|
<DataTable.Col source="lastRepairAt" field={DateField} />
|
||||||
|
<DataTable.Col><EditButton /></DataTable.Col>
|
||||||
|
</DataTable>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
25
frontend/src/resources/equipment/EquipmentShow.tsx
Normal file
25
frontend/src/resources/equipment/EquipmentShow.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { Show, SimpleShowLayout, TextField, DateField, NumberField } from 'react-admin';
|
||||||
|
|
||||||
|
export const EquipmentShow = () => (
|
||||||
|
<Show>
|
||||||
|
<SimpleShowLayout>
|
||||||
|
<TextField source="id" />
|
||||||
|
<TextField source="name" />
|
||||||
|
<TextField source="serialNumber" />
|
||||||
|
<TextField source="inventoryNumber" />
|
||||||
|
<TextField source="equipmentType" />
|
||||||
|
<TextField source="status" />
|
||||||
|
<DateField source="dateOfInspection" />
|
||||||
|
<TextField source="periodicityTO" />
|
||||||
|
<DateField source="commissionedAt" />
|
||||||
|
<NumberField source="totalEngineHours" />
|
||||||
|
<NumberField source="engineHoursSinceLastRepair" />
|
||||||
|
<DateField source="lastRepairAt" />
|
||||||
|
<TextField source="notes" />
|
||||||
|
<TextField source="workAsPartOf" />
|
||||||
|
<NumberField source="fuelСonsumed" />
|
||||||
|
<DateField source="createdAt" showTime />
|
||||||
|
<DateField source="updatedAt" showTime />
|
||||||
|
</SimpleShowLayout>
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
4
frontend/src/resources/equipment/index.ts
Normal file
4
frontend/src/resources/equipment/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export { EquipmentList } from './EquipmentList';
|
||||||
|
export { EquipmentCreate } from './EquipmentCreate';
|
||||||
|
export { EquipmentEdit } from './EquipmentEdit';
|
||||||
|
export { EquipmentShow } from './EquipmentShow';
|
||||||
20
frontend/src/resources/part/PartCreate.tsx
Normal file
20
frontend/src/resources/part/PartCreate.tsx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { Create, SimpleForm, TextInput, NumberInput, SelectInput } from 'react-admin';
|
||||||
|
|
||||||
|
const categoryPartChoices = [
|
||||||
|
{ id: 'Расходник', name: 'Расходник' },
|
||||||
|
{ id: 'Запчасть', name: 'Запчасть' },
|
||||||
|
{ id: 'Инструмент', name: 'Инструмент' },
|
||||||
|
{ id: 'Спецодежда', name: 'Спецодежда' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const PartCreate = () => (
|
||||||
|
<Create>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput source="name" />
|
||||||
|
<SelectInput source="categories" choices={categoryPartChoices} />
|
||||||
|
<NumberInput source="price" step={0.01} />
|
||||||
|
<TextInput multiline source="description" />
|
||||||
|
<TextInput source="serialNumber" />
|
||||||
|
</SimpleForm>
|
||||||
|
</Create>
|
||||||
|
);
|
||||||
21
frontend/src/resources/part/PartEdit.tsx
Normal file
21
frontend/src/resources/part/PartEdit.tsx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { Edit, SimpleForm, TextInput, NumberInput, SelectInput } from 'react-admin';
|
||||||
|
|
||||||
|
const categoryPartChoices = [
|
||||||
|
{ id: 'Расходник', name: 'Расходник' },
|
||||||
|
{ id: 'Запчасть', name: 'Запчасть' },
|
||||||
|
{ id: 'Инструмент', name: 'Инструмент' },
|
||||||
|
{ id: 'Спецодежда', name: 'Спецодежда' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const PartEdit = () => (
|
||||||
|
<Edit>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput disabled source="id" />
|
||||||
|
<TextInput source="name" />
|
||||||
|
<SelectInput source="categories" choices={categoryPartChoices} />
|
||||||
|
<NumberInput source="price" step={0.01} />
|
||||||
|
<TextInput multiline source="description" />
|
||||||
|
<TextInput source="serialNumber" />
|
||||||
|
</SimpleForm>
|
||||||
|
</Edit>
|
||||||
|
);
|
||||||
15
frontend/src/resources/part/PartList.tsx
Normal file
15
frontend/src/resources/part/PartList.tsx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { List, DataTable, TextField, NumberField, EditButton } from 'react-admin';
|
||||||
|
|
||||||
|
export const PartList = () => (
|
||||||
|
<List>
|
||||||
|
<DataTable>
|
||||||
|
<DataTable.Col source="id" />
|
||||||
|
<DataTable.Col source="name" />
|
||||||
|
<DataTable.Col source="categories" />
|
||||||
|
<DataTable.Col source="price" field={NumberField} />
|
||||||
|
<DataTable.Col source="description" />
|
||||||
|
<DataTable.Col source="serialNumber" />
|
||||||
|
<DataTable.Col><EditButton /></DataTable.Col>
|
||||||
|
</DataTable>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
16
frontend/src/resources/part/PartShow.tsx
Normal file
16
frontend/src/resources/part/PartShow.tsx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { Show, SimpleShowLayout, TextField, NumberField, DateField } from 'react-admin';
|
||||||
|
|
||||||
|
export const PartShow = () => (
|
||||||
|
<Show>
|
||||||
|
<SimpleShowLayout>
|
||||||
|
<TextField source="id" />
|
||||||
|
<TextField source="name" />
|
||||||
|
<TextField source="categories" />
|
||||||
|
<NumberField source="price" />
|
||||||
|
<TextField source="description" />
|
||||||
|
<TextField source="serialNumber" />
|
||||||
|
<DateField source="createdAt" showTime />
|
||||||
|
<DateField source="updatedAt" showTime />
|
||||||
|
</SimpleShowLayout>
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
4
frontend/src/resources/part/index.ts
Normal file
4
frontend/src/resources/part/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export { PartList } from './PartList';
|
||||||
|
export { PartCreate } from './PartCreate';
|
||||||
|
export { PartEdit } from './PartEdit';
|
||||||
|
export { PartShow } from './PartShow';
|
||||||
40
frontend/src/resources/repair-order/RepairOrderCreate.tsx
Normal file
40
frontend/src/resources/repair-order/RepairOrderCreate.tsx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { Create, SimpleForm, TextInput, DateInput, NumberInput, BooleanInput, SelectInput, ReferenceInput } from 'react-admin';
|
||||||
|
|
||||||
|
const repairKindChoices = [
|
||||||
|
{ id: 'TO', name: 'Техническое обслуживание' },
|
||||||
|
{ id: 'TR', name: 'Текущий ремонт' },
|
||||||
|
{ id: 'TRE', name: 'Текущий расширенный ремонт' },
|
||||||
|
{ id: 'KR', name: 'Капитальный ремонт' },
|
||||||
|
{ id: 'AR', name: 'Аварийный ремонт' },
|
||||||
|
{ id: 'MP', name: 'Метрологическая поверка' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const repairOrderStatusChoices = [
|
||||||
|
{ id: 'Draft', name: 'Черновик' },
|
||||||
|
{ id: 'Approved', name: 'Утверждена' },
|
||||||
|
{ id: 'InWork', name: 'В работе' },
|
||||||
|
{ id: 'Done', name: 'Выполнена' },
|
||||||
|
{ id: 'Cancelled', name: 'Отменена' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const RepairOrderCreate = () => (
|
||||||
|
<Create>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput source="number" />
|
||||||
|
<DateInput source="date" />
|
||||||
|
<ReferenceInput source="equipmentId" reference="equipment">
|
||||||
|
<SelectInput optionText="name" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<SelectInput source="repairKind" choices={repairKindChoices} />
|
||||||
|
<SelectInput source="status" choices={repairOrderStatusChoices} defaultValue="Draft" />
|
||||||
|
<DateInput source="plannedAt" />
|
||||||
|
<DateInput source="startedAt" />
|
||||||
|
<DateInput source="completedAt" />
|
||||||
|
<TextInput source="contractor" />
|
||||||
|
<NumberInput source="engineHoursAtRepair" step={0.01} />
|
||||||
|
<TextInput multiline source="description" />
|
||||||
|
<TextInput multiline source="notes" />
|
||||||
|
<BooleanInput source="confirmed" />
|
||||||
|
</SimpleForm>
|
||||||
|
</Create>
|
||||||
|
);
|
||||||
41
frontend/src/resources/repair-order/RepairOrderEdit.tsx
Normal file
41
frontend/src/resources/repair-order/RepairOrderEdit.tsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Edit, SimpleForm, TextInput, DateInput, NumberInput, BooleanInput, SelectInput, ReferenceInput } from 'react-admin';
|
||||||
|
|
||||||
|
const repairKindChoices = [
|
||||||
|
{ id: 'TO', name: 'Техническое обслуживание' },
|
||||||
|
{ id: 'TR', name: 'Текущий ремонт' },
|
||||||
|
{ id: 'TRE', name: 'Текущий расширенный ремонт' },
|
||||||
|
{ id: 'KR', name: 'Капитальный ремонт' },
|
||||||
|
{ id: 'AR', name: 'Аварийный ремонт' },
|
||||||
|
{ id: 'MP', name: 'Метрологическая поверка' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const repairOrderStatusChoices = [
|
||||||
|
{ id: 'Draft', name: 'Черновик' },
|
||||||
|
{ id: 'Approved', name: 'Утверждена' },
|
||||||
|
{ id: 'InWork', name: 'В работе' },
|
||||||
|
{ id: 'Done', name: 'Выполнена' },
|
||||||
|
{ id: 'Cancelled', name: 'Отменена' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const RepairOrderEdit = () => (
|
||||||
|
<Edit>
|
||||||
|
<SimpleForm>
|
||||||
|
<TextInput disabled source="id" />
|
||||||
|
<TextInput source="number" />
|
||||||
|
<DateInput source="date" />
|
||||||
|
<ReferenceInput source="equipmentId" reference="equipment">
|
||||||
|
<SelectInput optionText="name" />
|
||||||
|
</ReferenceInput>
|
||||||
|
<SelectInput source="repairKind" choices={repairKindChoices} />
|
||||||
|
<SelectInput source="status" choices={repairOrderStatusChoices} />
|
||||||
|
<DateInput source="plannedAt" />
|
||||||
|
<DateInput source="startedAt" />
|
||||||
|
<DateInput source="completedAt" />
|
||||||
|
<TextInput source="contractor" />
|
||||||
|
<NumberInput source="engineHoursAtRepair" step={0.01} />
|
||||||
|
<TextInput multiline source="description" />
|
||||||
|
<TextInput multiline source="notes" />
|
||||||
|
<BooleanInput source="confirmed" />
|
||||||
|
</SimpleForm>
|
||||||
|
</Edit>
|
||||||
|
);
|
||||||
21
frontend/src/resources/repair-order/RepairOrderList.tsx
Normal file
21
frontend/src/resources/repair-order/RepairOrderList.tsx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { List, DataTable, TextField, DateField, NumberField, BooleanField, EditButton } from 'react-admin';
|
||||||
|
|
||||||
|
export const RepairOrderList = () => (
|
||||||
|
<List>
|
||||||
|
<DataTable>
|
||||||
|
<DataTable.Col source="id" />
|
||||||
|
<DataTable.Col source="number" />
|
||||||
|
<DataTable.Col source="date" field={DateField} />
|
||||||
|
<DataTable.Col source="equipmentId" />
|
||||||
|
<DataTable.Col source="repairKind" />
|
||||||
|
<DataTable.Col source="status" />
|
||||||
|
<DataTable.Col source="plannedAt" field={DateField} />
|
||||||
|
<DataTable.Col source="startedAt" field={DateField} />
|
||||||
|
<DataTable.Col source="completedAt" field={DateField} />
|
||||||
|
<DataTable.Col source="contractor" />
|
||||||
|
<DataTable.Col source="engineHoursAtRepair" field={NumberField} />
|
||||||
|
<DataTable.Col source="confirmed" field={BooleanField} />
|
||||||
|
<DataTable.Col><EditButton /></DataTable.Col>
|
||||||
|
</DataTable>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
26
frontend/src/resources/repair-order/RepairOrderShow.tsx
Normal file
26
frontend/src/resources/repair-order/RepairOrderShow.tsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { Show, SimpleShowLayout, TextField, DateField, NumberField, BooleanField, ReferenceField } from 'react-admin';
|
||||||
|
|
||||||
|
export const RepairOrderShow = () => (
|
||||||
|
<Show>
|
||||||
|
<SimpleShowLayout>
|
||||||
|
<TextField source="id" />
|
||||||
|
<TextField source="number" />
|
||||||
|
<DateField source="date" />
|
||||||
|
<ReferenceField source="equipmentId" reference="equipment">
|
||||||
|
<TextField source="name" />
|
||||||
|
</ReferenceField>
|
||||||
|
<TextField source="repairKind" />
|
||||||
|
<TextField source="status" />
|
||||||
|
<DateField source="plannedAt" />
|
||||||
|
<DateField source="startedAt" />
|
||||||
|
<DateField source="completedAt" />
|
||||||
|
<TextField source="contractor" />
|
||||||
|
<NumberField source="engineHoursAtRepair" />
|
||||||
|
<TextField source="description" />
|
||||||
|
<TextField source="notes" />
|
||||||
|
<BooleanField source="confirmed" />
|
||||||
|
<DateField source="createdAt" showTime />
|
||||||
|
<DateField source="updatedAt" showTime />
|
||||||
|
</SimpleShowLayout>
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
4
frontend/src/resources/repair-order/index.ts
Normal file
4
frontend/src/resources/repair-order/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export { RepairOrderList } from './RepairOrderList';
|
||||||
|
export { RepairOrderCreate } from './RepairOrderCreate';
|
||||||
|
export { RepairOrderEdit } from './RepairOrderEdit';
|
||||||
|
export { RepairOrderShow } from './RepairOrderShow';
|
||||||
Reference in New Issue
Block a user