|
|
|
@ -425,8 +425,8 @@
|
|
|
|
<el-table-column width="56" align="center">
|
|
|
|
<el-table-column width="56" align="center">
|
|
|
|
<template #default="scope">
|
|
|
|
<template #default="scope">
|
|
|
|
<el-radio
|
|
|
|
<el-radio
|
|
|
|
:model-value="iotDeviceDraftId"
|
|
|
|
v-model="iotDeviceDraftId"
|
|
|
|
:label="scope.row.id"
|
|
|
|
:value="String(scope.row.id)"
|
|
|
|
:disabled="!isIotDeviceSelectable(scope.row)"
|
|
|
|
:disabled="!isIotDeviceSelectable(scope.row)"
|
|
|
|
@change="selectIotDevice(scope.row)"
|
|
|
|
@change="selectIotDevice(scope.row)"
|
|
|
|
@click.stop
|
|
|
|
@click.stop
|
|
|
|
@ -796,7 +796,7 @@ const iotDeviceDialogVisible = ref(false)
|
|
|
|
const iotDeviceList = ref<DeviceVO[]>([])
|
|
|
|
const iotDeviceList = ref<DeviceVO[]>([])
|
|
|
|
const iotDeviceTotal = ref(0)
|
|
|
|
const iotDeviceTotal = ref(0)
|
|
|
|
const iotDeviceSelectedLabel = ref('')
|
|
|
|
const iotDeviceSelectedLabel = ref('')
|
|
|
|
const iotDeviceDraftId = ref<number | undefined>()
|
|
|
|
const iotDeviceDraftId = ref<string | undefined>()
|
|
|
|
const iotDeviceDraftRow = ref<DeviceVO | undefined>()
|
|
|
|
const iotDeviceDraftRow = ref<DeviceVO | undefined>()
|
|
|
|
const list = ref<CriticalComponentVO[]>([])
|
|
|
|
const list = ref<CriticalComponentVO[]>([])
|
|
|
|
const bjList = ref<ProductVO[]>([])
|
|
|
|
const bjList = ref<ProductVO[]>([])
|
|
|
|
@ -825,6 +825,12 @@ const normalizeNumberish = (value: any): number | undefined => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return undefined
|
|
|
|
return undefined
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const normalizeId = (value: unknown): string | undefined => {
|
|
|
|
|
|
|
|
if (value === null || value === undefined) return undefined
|
|
|
|
|
|
|
|
const id = String(value).trim()
|
|
|
|
|
|
|
|
return id || 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
|
|
|
|
@ -1094,7 +1100,7 @@ const buildIotDeviceLabel = (item: any) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getIotDeviceIdFromDetail = (detail: any) =>
|
|
|
|
const getIotDeviceIdFromDetail = (detail: any) =>
|
|
|
|
normalizeNumberish(
|
|
|
|
normalizeId(
|
|
|
|
detail?.dvId ?? detail?.iotDeviceId ?? detail?.iotDevice?.id ?? detail?.device?.id
|
|
|
|
detail?.dvId ?? detail?.iotDeviceId ?? detail?.iotDevice?.id ?? detail?.device?.id
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@ -1118,8 +1124,19 @@ const getIotDeviceLabelFromDetail = (detail: any) => {
|
|
|
|
|
|
|
|
|
|
|
|
const iotDeviceDisplay = computed(() => iotDeviceSelectedLabel.value)
|
|
|
|
const iotDeviceDisplay = computed(() => iotDeviceSelectedLabel.value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isCurrentIotDevice = (row: any) => {
|
|
|
|
|
|
|
|
const rowId = normalizeId(row?.id)
|
|
|
|
|
|
|
|
const selectedId = normalizeId(formData.value.dvId)
|
|
|
|
|
|
|
|
if (rowId !== undefined && rowId === selectedId) return true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const boundLedgerId = normalizeId(row?.boundLedgerId)
|
|
|
|
|
|
|
|
const currentLedgerId = normalizeId(formData.value.id)
|
|
|
|
|
|
|
|
return boundLedgerId !== undefined && boundLedgerId === currentLedgerId
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const isIotDeviceSelectable = (row: any) => {
|
|
|
|
const isIotDeviceSelectable = (row: any) => {
|
|
|
|
const value = row?.selectable
|
|
|
|
const value = row?.selectable
|
|
|
|
|
|
|
|
if (isCurrentIotDevice(row)) return true
|
|
|
|
return value !== false && String(value ?? 'true').toLowerCase() !== 'false'
|
|
|
|
return value !== false && String(value ?? 'true').toLowerCase() !== 'false'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1134,7 +1151,7 @@ const isIotDeviceEnabled = (row: any) => {
|
|
|
|
|
|
|
|
|
|
|
|
const selectIotDevice = (row: DeviceVO) => {
|
|
|
|
const selectIotDevice = (row: DeviceVO) => {
|
|
|
|
if (!isIotDeviceSelectable(row)) return
|
|
|
|
if (!isIotDeviceSelectable(row)) return
|
|
|
|
const id = normalizeNumberish(row?.id)
|
|
|
|
const id = normalizeId(row?.id)
|
|
|
|
if (id === undefined) return
|
|
|
|
if (id === undefined) return
|
|
|
|
iotDeviceDraftId.value = id
|
|
|
|
iotDeviceDraftId.value = id
|
|
|
|
iotDeviceDraftRow.value = row
|
|
|
|
iotDeviceDraftRow.value = row
|
|
|
|
@ -1149,7 +1166,7 @@ const getIotDeviceRowClassName = ({ row }: { row: DeviceVO }) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const openIotDeviceDialog = async () => {
|
|
|
|
const openIotDeviceDialog = async () => {
|
|
|
|
const id = normalizeNumberish(formData.value.dvId)
|
|
|
|
const id = normalizeId(formData.value.dvId)
|
|
|
|
iotDeviceDraftId.value = id
|
|
|
|
iotDeviceDraftId.value = id
|
|
|
|
iotDeviceDraftRow.value =
|
|
|
|
iotDeviceDraftRow.value =
|
|
|
|
id === undefined ? undefined : ({ id, deviceName: iotDeviceSelectedLabel.value } as DeviceVO)
|
|
|
|
id === undefined ? undefined : ({ id, deviceName: iotDeviceSelectedLabel.value } as DeviceVO)
|
|
|
|
|