|
|
|
@ -267,6 +267,18 @@ const parseIdsValue = (value: any): number[] => {
|
|
|
|
.filter((v) => !Number.isNaN(v))
|
|
|
|
.filter((v) => !Number.isNaN(v))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const normalizeNumberish = (value: any): number | undefined => {
|
|
|
|
|
|
|
|
if (value === null || value === undefined || value === '') return undefined
|
|
|
|
|
|
|
|
if (typeof value === 'number') return Number.isFinite(value) ? value : undefined
|
|
|
|
|
|
|
|
if (typeof value === 'string') {
|
|
|
|
|
|
|
|
const trimmed = value.trim()
|
|
|
|
|
|
|
|
if (!trimmed) return undefined
|
|
|
|
|
|
|
|
const n = Number(trimmed)
|
|
|
|
|
|
|
|
return Number.isFinite(n) ? n : undefined
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return undefined
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const normalizeYmd = (value: any): string | undefined => {
|
|
|
|
const normalizeYmd = (value: any): string | undefined => {
|
|
|
|
if (value === null || value === undefined || value === '') return undefined
|
|
|
|
if (value === null || value === undefined || value === '') return undefined
|
|
|
|
if (typeof value === 'string') {
|
|
|
|
if (typeof value === 'string') {
|
|
|
|
@ -475,6 +487,7 @@ const open = async (type: string, id?: number, defaultDeviceTypeId?: number) =>
|
|
|
|
formData.value = {
|
|
|
|
formData.value = {
|
|
|
|
...initFormData(),
|
|
|
|
...initFormData(),
|
|
|
|
...(detail as any),
|
|
|
|
...(detail as any),
|
|
|
|
|
|
|
|
deviceType: normalizeNumberish((detail as any)?.deviceType),
|
|
|
|
deviceManagerIds: parseIdsValue((detail as any)?.deviceManager),
|
|
|
|
deviceManagerIds: parseIdsValue((detail as any)?.deviceManager),
|
|
|
|
productionDate: normalizeYmd((detail as any)?.productionDate),
|
|
|
|
productionDate: normalizeYmd((detail as any)?.productionDate),
|
|
|
|
factoryEntryDate: normalizeYmd((detail as any)?.factoryEntryDate),
|
|
|
|
factoryEntryDate: normalizeYmd((detail as any)?.factoryEntryDate),
|
|
|
|
@ -503,6 +516,7 @@ const submitForm = async () => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const data = {
|
|
|
|
const data = {
|
|
|
|
...(formData.value as any),
|
|
|
|
...(formData.value as any),
|
|
|
|
|
|
|
|
deviceType: normalizeNumberish(formData.value.deviceType),
|
|
|
|
productionDate: normalizeYmd(formData.value.productionDate),
|
|
|
|
productionDate: normalizeYmd(formData.value.productionDate),
|
|
|
|
factoryEntryDate: normalizeYmd(formData.value.factoryEntryDate),
|
|
|
|
factoryEntryDate: normalizeYmd(formData.value.factoryEntryDate),
|
|
|
|
deviceManager: formData.value.deviceManagerIds?.length ? formData.value.deviceManagerIds.join(',') : undefined,
|
|
|
|
deviceManager: formData.value.deviceManagerIds?.length ? formData.value.deviceManagerIds.join(',') : undefined,
|
|
|
|
|