68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { ApiProperty, IntersectionType, PartialType } from '@nestjs/swagger';
|
|
import {
|
|
IsArray,
|
|
IsDate,
|
|
IsDateString,
|
|
IsEnum,
|
|
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';
|
|
import { HasInventoryStatusEnum } from '~/constants/enum';
|
|
|
|
export class MaterialsInventoryDto {}
|
|
|
|
export class MaterialsInventoryUpdateDto extends PartialType(MaterialsInventoryDto) {}
|
|
export class MaterialsInventoryQueryDto extends IntersectionType(
|
|
PagerDto<MaterialsInventoryDto>,
|
|
PartialType(MaterialsInventoryDto)
|
|
) {
|
|
@ApiProperty({ description: '产品名' })
|
|
@IsOptional()
|
|
@IsString()
|
|
product: string;
|
|
|
|
@ApiProperty({ description: '关键字' })
|
|
@IsOptional()
|
|
@IsString()
|
|
keyword: string;
|
|
|
|
@ApiProperty({ description: '产品名' })
|
|
@IsOptional()
|
|
@IsEnum(HasInventoryStatusEnum)
|
|
isHasInventory: HasInventoryStatusEnum;
|
|
|
|
@ApiProperty({ description: '项目Id' })
|
|
@IsOptional()
|
|
@IsNumber()
|
|
projectId: number;
|
|
}
|
|
export class MaterialsInventoryExportDto {
|
|
@ApiProperty({ description: '项目' })
|
|
@IsOptional()
|
|
@IsNumber()
|
|
projectId: number;
|
|
|
|
@ApiProperty({ description: '导出时间YYYY-MM-DD' })
|
|
@IsOptional()
|
|
@IsArray()
|
|
@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[];
|
|
}
|