|
|
|
|
@ -506,7 +506,7 @@ defineOptions({ name: 'DvRepairForm' })
|
|
|
|
|
type RepairFormType = 'create' | 'update' | 'repair' | 'detail' | ''
|
|
|
|
|
|
|
|
|
|
interface DvRepairFormData extends Partial<DvRepairVO> {
|
|
|
|
|
deviceId?: number
|
|
|
|
|
deviceId?: string
|
|
|
|
|
componentId?: number
|
|
|
|
|
isShutdown?: boolean
|
|
|
|
|
isCode?: boolean
|
|
|
|
|
@ -607,13 +607,13 @@ const showComponentSelect = computed(() => formData.value.machineryTypeId === 2)
|
|
|
|
|
|
|
|
|
|
const selectedDeviceText = computed(() => {
|
|
|
|
|
const deviceId = formData.value.deviceId
|
|
|
|
|
if (typeof deviceId !== 'number') return ''
|
|
|
|
|
const option = deviceOptions.value.find((item) => item.value === deviceId)
|
|
|
|
|
if (deviceId == null || deviceId === '') return ''
|
|
|
|
|
const option = deviceOptions.value.find((item) => String(item.value) === String(deviceId))
|
|
|
|
|
return option?.label || `ID:${deviceId}`
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const deviceLoading = ref(false)
|
|
|
|
|
const deviceOptions = ref<{ label: string; value: number; raw?: DeviceLedgerVO }[]>([])
|
|
|
|
|
const deviceOptions = ref<{ label: string; value: string | number; raw?: DeviceLedgerVO }[]>([])
|
|
|
|
|
const deviceOptionsLoaded = ref(false)
|
|
|
|
|
|
|
|
|
|
const deviceDialogVisible = ref(false)
|
|
|
|
|
@ -697,7 +697,7 @@ const toComponentOption = (item: any) => {
|
|
|
|
|
return { label, value: id }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const loadComponentOptionsByDeviceId = async (deviceId: number) => {
|
|
|
|
|
const loadComponentOptionsByDeviceId = async (deviceId: string) => {
|
|
|
|
|
componentLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const data = await RepairItemsApi.getComponentList(deviceId)
|
|
|
|
|
@ -810,7 +810,7 @@ const confirmDeviceSelection = (row?: DeviceLedgerVO) => {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const id = Number(selected.id)
|
|
|
|
|
const id = String(selected.id)
|
|
|
|
|
const label = `${selected.deviceCode ?? ''} ${selected.deviceName ?? ''}`.trim()
|
|
|
|
|
deviceOptions.value = upsertDeviceOption(deviceOptions.value, { label, value: id, raw: selected })
|
|
|
|
|
formData.value.deviceId = id
|
|
|
|
|
@ -854,12 +854,12 @@ watch(
|
|
|
|
|
if (isHydrating.value) return
|
|
|
|
|
formData.value.componentId = undefined
|
|
|
|
|
componentOptions.value = []
|
|
|
|
|
if (typeof deviceId !== 'number') {
|
|
|
|
|
if (deviceId == null || deviceId === '') {
|
|
|
|
|
setLineRows([])
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const option = deviceOptions.value.find((item) => item.value === deviceId)
|
|
|
|
|
const option = deviceOptions.value.find((item) => String(item.value) === String(deviceId))
|
|
|
|
|
if (option?.raw) {
|
|
|
|
|
formData.value.machineryCode = option.raw.deviceCode
|
|
|
|
|
formData.value.machineryName = option.raw.deviceName
|
|
|
|
|
@ -883,7 +883,7 @@ watch(
|
|
|
|
|
if (isHydrating.value) return
|
|
|
|
|
if (formData.value.machineryTypeId !== 2) return
|
|
|
|
|
const deviceId = formData.value.deviceId
|
|
|
|
|
if (typeof deviceId !== 'number' || typeof componentId !== 'number') {
|
|
|
|
|
if (deviceId == null || deviceId === '' || typeof componentId !== 'number') {
|
|
|
|
|
setLineRows([])
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
@ -1103,14 +1103,14 @@ const open = async (type: string, id?: number) => {
|
|
|
|
|
formData.value.machineryTypeId = Number.isNaN(typeId) ? formData.value.machineryTypeId : typeId
|
|
|
|
|
|
|
|
|
|
const deviceId = formData.value.deviceId
|
|
|
|
|
const resolvedDeviceId = typeof deviceId === 'number' ? deviceId : formData.value.machineryId
|
|
|
|
|
if (typeof resolvedDeviceId === 'number') {
|
|
|
|
|
const resolvedDeviceId = (deviceId != null && deviceId !== '') ? deviceId : formData.value.machineryId
|
|
|
|
|
if (resolvedDeviceId != null && resolvedDeviceId !== '') {
|
|
|
|
|
formData.value.deviceId = resolvedDeviceId
|
|
|
|
|
const label = `${formData.value.machineryCode ?? ''} ${formData.value.machineryName ?? ''}`.trim() || `ID:${resolvedDeviceId}`
|
|
|
|
|
deviceOptions.value = upsertDeviceOption(deviceOptions.value, { label, value: resolvedDeviceId })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (formData.value.machineryTypeId === 2 && typeof formData.value.deviceId === 'number') {
|
|
|
|
|
if (formData.value.machineryTypeId === 2 && formData.value.deviceId != null && formData.value.deviceId !== '') {
|
|
|
|
|
await loadComponentOptionsByDeviceId(formData.value.deviceId)
|
|
|
|
|
const componentId = typeof formData.value.componentId === 'number'
|
|
|
|
|
? formData.value.componentId
|
|
|
|
|
|