|
|
|
|
@ -103,15 +103,24 @@
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceStatus')"
|
|
|
|
|
align="center" prop="deviceStatus" sortable>
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-tag
|
|
|
|
|
:type="getTzStatusTagType(scope.row.deviceStatus)"
|
|
|
|
|
:color="getTzStatusTagColor(scope.row.deviceStatus)"
|
|
|
|
|
:style="getTzStatusTagStyle(scope.row.deviceStatus)" effect="light"
|
|
|
|
|
disable-transitions>
|
|
|
|
|
{{ getTzStatusLabel(scope.row.deviceStatus) }}
|
|
|
|
|
<el-switch
|
|
|
|
|
:model-value="isDeviceLedgerEnabled(scope.row)"
|
|
|
|
|
:loading="Boolean(deviceStatusUpdatingMap[scope.row.id])"
|
|
|
|
|
inline-prompt
|
|
|
|
|
@change="(val) => handleDeviceStatusChange(scope.row, val)"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.isSchedueld')"
|
|
|
|
|
align="center" prop="isSchedueld" min-width="100px">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-tag :type="Number(scope.row.isSchedueld ?? scope.row.isScheduled) === 1 ? 'success' : 'info'" effect="light">
|
|
|
|
|
{{ formatScheduleLabel(scope.row.isSchedueld ?? scope.row.isScheduled) }}
|
|
|
|
|
</el-tag>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.ratedCapacity')"
|
|
|
|
|
align="center" prop="ratedCapacity" min-width="120px"/>
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceSpec')"
|
|
|
|
|
align="center" prop="deviceSpec"/>
|
|
|
|
|
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceModel')"
|
|
|
|
|
@ -255,7 +264,7 @@
|
|
|
|
|
{{ detailData?.deviceName ?? '' }}
|
|
|
|
|
</el-descriptions-item>
|
|
|
|
|
<el-descriptions-item :label="t('EquipmentManagement.EquipmentLedger.deviceStatus')">
|
|
|
|
|
<dict-tag type="mes_tz_status" :value="detailData?.deviceStatus"/>
|
|
|
|
|
<dict-tag type="mes_tz_status" :value="detailData?.deviceStatus"/>
|
|
|
|
|
</el-descriptions-item>
|
|
|
|
|
<!-- <el-descriptions-item :label="t('EquipmentManagement.EquipmentLedger.deviceBrand')">{{ detailData?.deviceBrand ?? '' }}</el-descriptions-item> -->
|
|
|
|
|
<el-descriptions-item :label="t('EquipmentManagement.EquipmentLedger.deviceModel')">
|
|
|
|
|
@ -1099,6 +1108,8 @@ const tzStatusOptions = computed(() => {
|
|
|
|
|
const detailVisible = ref(false)
|
|
|
|
|
const detailLoading = ref(false)
|
|
|
|
|
const detailData = ref<DeviceLedgerVO | undefined>()
|
|
|
|
|
const detailStatusLoading = ref(false)
|
|
|
|
|
const deviceStatusUpdatingMap = ref<Record<number, boolean>>({})
|
|
|
|
|
const detailActiveTab = ref('check')
|
|
|
|
|
const selectedDetailId = ref<number | undefined>()
|
|
|
|
|
|
|
|
|
|
@ -1179,6 +1190,42 @@ const getTzStatusTagStyle = (value: any) => {
|
|
|
|
|
return 'color: #fff'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const formatScheduleLabel = (value: any) => {
|
|
|
|
|
return Number(value) === 1
|
|
|
|
|
? t('EquipmentManagement.EquipmentLedger.yes')
|
|
|
|
|
: t('EquipmentManagement.EquipmentLedger.no')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const isDeviceLedgerEnabled = (row: DeviceLedgerVO) => {
|
|
|
|
|
return Number((row as any)?.deviceStatus) === 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleDeviceStatusChange = async (row: DeviceLedgerVO, value: boolean) => {
|
|
|
|
|
if (!row?.id) return
|
|
|
|
|
const oldValue = Number((row as any).deviceStatus)
|
|
|
|
|
const nextValue = value ? 0 : 1
|
|
|
|
|
;(row as any).deviceStatus = nextValue
|
|
|
|
|
deviceStatusUpdatingMap.value[row.id] = true
|
|
|
|
|
try {
|
|
|
|
|
await DeviceLedgerApi.updateDeviceLedger({
|
|
|
|
|
id: row.id,
|
|
|
|
|
deviceStatus: nextValue
|
|
|
|
|
} as DeviceLedgerVO)
|
|
|
|
|
if (detailData.value?.id === row.id) {
|
|
|
|
|
detailData.value.deviceStatus = nextValue
|
|
|
|
|
}
|
|
|
|
|
message.success(t('common.updateSuccess'))
|
|
|
|
|
} catch {
|
|
|
|
|
;(row as any).deviceStatus = oldValue
|
|
|
|
|
if (detailData.value?.id === row.id) {
|
|
|
|
|
detailData.value.deviceStatus = oldValue
|
|
|
|
|
}
|
|
|
|
|
message.error(t('common.updateFail'))
|
|
|
|
|
} finally {
|
|
|
|
|
deviceStatusUpdatingMap.value[row.id] = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const formatDetailDate = (value: any) => {
|
|
|
|
|
if (!value) return ''
|
|
|
|
|
return formatDate(new Date(value), 'YYYY-MM-DD')
|
|
|
|
|
@ -1219,6 +1266,28 @@ const handleDetail = async (id: number) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleDetailStatusChange = async (value: number) => {
|
|
|
|
|
if (!detailData.value?.id) return
|
|
|
|
|
const oldValue = value === 0 ? 1 : 0
|
|
|
|
|
detailStatusLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
await DeviceLedgerApi.updateDeviceLedger({
|
|
|
|
|
id: detailData.value.id,
|
|
|
|
|
deviceStatus: value
|
|
|
|
|
} as DeviceLedgerVO)
|
|
|
|
|
const current = list.value.find((item) => item.id === detailData.value?.id)
|
|
|
|
|
if (current) {
|
|
|
|
|
current.deviceStatus = value
|
|
|
|
|
}
|
|
|
|
|
message.success(t('common.updateSuccess'))
|
|
|
|
|
} catch {
|
|
|
|
|
detailData.value.deviceStatus = oldValue
|
|
|
|
|
message.error(t('common.updateFail'))
|
|
|
|
|
} finally {
|
|
|
|
|
detailStatusLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const closeDetail = () => {
|
|
|
|
|
detailVisible.value = false
|
|
|
|
|
selectedDetailId.value = undefined
|
|
|
|
|
|