- 移除 lineId 字段,统一使用 lineIds 数组字段 - 更新创建任务请求体构建逻辑,不再包含 lineId 属性 - 修改任务详情和检测项明细的接口契约验证 - 更新稳态校验 API 文档说明,移除对 lineId 的支持 - 重构稳态校验表单项验证规则 - 移除磁盘监控作业详情抽屉组件 - 移除磁盘监控作业表格组件 - 更新路由配置以支持新的系统监控路径 - 添加测试报告相关字典代码常量 - 更新 ICD 路径表单和结果面板功能
72 lines
2.4 KiB
TypeScript
72 lines
2.4 KiB
TypeScript
import type { SteadyDataView } from '@/api/steady/steadyDataView/interface'
|
|
import { buildTimePeriodRange, type TimePeriodUnit } from '@/views/components/TimePeriodSearch/timePeriod'
|
|
|
|
export interface ChecksquareFormState {
|
|
timeRange: string[]
|
|
timeUnit: TimePeriodUnit
|
|
timeBaseDate: Date
|
|
}
|
|
|
|
export const defaultChecksquareFormState = (): ChecksquareFormState => {
|
|
const baseDate = new Date()
|
|
|
|
return {
|
|
timeRange: buildTimePeriodRange('day', baseDate),
|
|
timeUnit: 'day',
|
|
timeBaseDate: baseDate
|
|
}
|
|
}
|
|
|
|
const padTimeValue = (value: number) => `${value}`.padStart(2, '0')
|
|
|
|
export const formatChecksquareTime = (date: Date) => {
|
|
return `${date.getFullYear()}-${padTimeValue(date.getMonth() + 1)}-${padTimeValue(date.getDate())} ${padTimeValue(
|
|
date.getHours()
|
|
)}:${padTimeValue(date.getMinutes())}:${padTimeValue(date.getSeconds())}`
|
|
}
|
|
|
|
export const collectChecksquareIndicatorCodes = (indicators: SteadyDataView.SteadyIndicatorNode[]) => {
|
|
return Array.from(new Set(indicators.map(item => item.indicatorCode).filter(Boolean))) as string[]
|
|
}
|
|
|
|
export const calculateChecksquareExpectedItemCount = (params: {
|
|
lineCount: number
|
|
selectedIndicatorCount: number
|
|
totalIndicatorCount: number
|
|
}) => {
|
|
const { lineCount, selectedIndicatorCount, totalIndicatorCount } = params
|
|
const indicatorCount = selectedIndicatorCount > 0 ? selectedIndicatorCount : totalIndicatorCount
|
|
|
|
return lineCount * indicatorCount
|
|
}
|
|
|
|
export const buildSteadyChecksquareCreatePayload = (
|
|
lineIds: string[],
|
|
indicators: SteadyDataView.SteadyIndicatorNode[],
|
|
formState: ChecksquareFormState
|
|
): SteadyDataView.SteadyChecksquareCreateParams => {
|
|
return {
|
|
lineIds,
|
|
indicatorCodes: collectChecksquareIndicatorCodes(indicators),
|
|
timeStart: (formState.timeRange[0] || '').replace(/\.[^.]+$/, ''),
|
|
timeEnd: (formState.timeRange[1] || '').replace(/\.[^.]+$/, '')
|
|
}
|
|
}
|
|
|
|
export const validateChecksquareSelection = (params: {
|
|
lineIds: string[]
|
|
indicators: SteadyDataView.SteadyIndicatorNode[]
|
|
timeRange: string[]
|
|
}) => {
|
|
const { lineIds, timeRange } = params
|
|
|
|
if (!lineIds.length) return '请选择监测点'
|
|
if (!timeRange[0]) return '请选择开始时间'
|
|
if (!timeRange[1]) return '请选择结束时间'
|
|
if (Date.parse(timeRange[0].replace(' ', 'T')) > Date.parse(timeRange[1].replace(' ', 'T'))) {
|
|
return '开始时间不能大于结束时间'
|
|
}
|
|
|
|
return ''
|
|
}
|