oa_based/src/modules/materials_inventory/materials_inventory.dto.ts

45 lines
1.2 KiB
TypeScript

import { ApiProperty, IntersectionType, PartialType } from '@nestjs/swagger';
import {
IsArray,
IsDate,
IsDateString,
IsIn,
IsInt,
IsNumber,
IsOptional,
IsString,
Matches,
MinLength
} from 'class-validator';
import { PagerDto } from '~/common/dto/pager.dto';
import { Storage } from '../tools/storage/storage.entity';
import { Transform } from 'class-transformer';
import dayjs from 'dayjs';
import { formatToDate } from '~/utils';
export class MaterialsInventoryDto {}
export class MaterialsInventoryUpdateDto extends PartialType(MaterialsInventoryDto) {}
export class MaterialsInventoryQueryDto extends IntersectionType(
PagerDto<MaterialsInventoryDto>,
PartialType(MaterialsInventoryDto)
) {}
export class MaterialsInventoryExportDto {
@ApiProperty({ description: '项目' })
@IsOptional()
@IsNumber()
projectId: number;
@ApiProperty({ description: '导出时间YYYY-MM-DD' })
@IsOptional()
@Transform(params => {
// 开始和结束时间用的是一月的开始和一月的结束的时分秒
const date = params.value;
return [
date ? `${formatToDate(dayjs(date).startOf('month'))} 00:00:00` : null,
date ? `${formatToDate(dayjs(date).endOf('month'))} 23:59:59` : null
];
})
time?: string[];
}