From b8dc35bc23f4047c1fbeaa6aec2b31ccaae33ae7 Mon Sep 17 00:00:00 2001 From: hwj Date: Thu, 2 Apr 2026 10:57:54 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E8=AE=BE=E5=A4=87=E5=8F=B0?= =?UTF-8?q?=E8=B4=A6-=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6=E6=8E=92?= =?UTF-8?q?=E4=BA=A7=E3=80=81=E9=A2=9D=E5=AE=9A=E4=BA=A7=E8=83=BD=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=9B=E7=8A=B6=E6=80=81=E6=94=B9=E6=88=90switch?= =?UTF-8?q?=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mes/deviceledger/index.ts | 3 + src/locales/en.ts | 7 ++ src/locales/zh-CN.ts | 7 ++ .../mes/deviceledger/DeviceLedgerForm.vue | 30 +++++++ src/views/mes/deviceledger/index.vue | 83 +++++++++++++++++-- 5 files changed, 123 insertions(+), 7 deletions(-) diff --git a/src/api/mes/deviceledger/index.ts b/src/api/mes/deviceledger/index.ts index 17e8f030..3ffcc733 100644 --- a/src/api/mes/deviceledger/index.ts +++ b/src/api/mes/deviceledger/index.ts @@ -26,6 +26,9 @@ export interface DeviceLedgerVO { remark: string // 备注 fileUrl?: string // 附件下载 qrcodeUrl?: string + isSchedueld?: number + isScheduled?: number + ratedCapacity?: number componentId?: string // 关键件,ids集合 componentList?: CriticalComponentVO[] beijianId?: string // 备件,ids集合 diff --git a/src/locales/en.ts b/src/locales/en.ts index c039d4f7..6d0c83e0 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -1196,9 +1196,15 @@ export default { qrcode: 'QR Code/Barcode', deviceName: 'Name', deviceStatus: 'Status', + statusEnabled: 'Enabled', + statusDisabled: 'Disabled', deviceType: 'Type', deviceSpec: 'Spec', deviceModel: 'Model', + isSchedueld: 'Schedule', + ratedCapacity: 'Rated Capacity', + yes: 'Yes', + no: 'No', productionDate: 'Production Date', factoryEntryDate: 'Factory Entry Date', deviceLocation: 'Location', @@ -1218,6 +1224,7 @@ export default { placeholderDeviceType: 'Please select type', placeholderDeviceModel: 'Please input model', placeholderDeviceSpec: 'Please input spec', + placeholderRatedCapacity: 'Please input rated capacity', placeholderProductionDate: 'Please select production date', placeholderFactoryEntryDate: 'Please select factory entry date', placeholderDeviceLocation: 'Please input location', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index d7d22ba2..547ebe42 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -1188,9 +1188,15 @@ export default { qrcode: '二维码/条形码', deviceName: '名称', deviceStatus: '状态', + statusEnabled: '启用', + statusDisabled: '不启用', deviceType: '类型', deviceSpec: '规格', deviceModel: '型号', + isSchedueld: '是否排产', + ratedCapacity: '额定产能', + yes: '是', + no: '否', productionDate: '生产日期', factoryEntryDate: '入厂日期', deviceLocation: '位置', @@ -1210,6 +1216,7 @@ export default { placeholderDeviceType: '请选择类型', placeholderDeviceModel: '请输入型号', placeholderDeviceSpec: '请输入规格', + placeholderRatedCapacity: '请输入额定产能', placeholderProductionDate: '请选择生产日期', placeholderFactoryEntryDate: '请选择入厂日期', placeholderDeviceLocation: '请输入位置', diff --git a/src/views/mes/deviceledger/DeviceLedgerForm.vue b/src/views/mes/deviceledger/DeviceLedgerForm.vue index ba72d292..44a46134 100644 --- a/src/views/mes/deviceledger/DeviceLedgerForm.vue +++ b/src/views/mes/deviceledger/DeviceLedgerForm.vue @@ -73,6 +73,30 @@ + + + + + + + + + + @@ -1099,6 +1108,8 @@ const tzStatusOptions = computed(() => { const detailVisible = ref(false) const detailLoading = ref(false) const detailData = ref() +const detailStatusLoading = ref(false) +const deviceStatusUpdatingMap = ref>({}) const detailActiveTab = ref('check') const selectedDetailId = ref() @@ -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