Merge remote-tracking branch 'origin/main'

pull/1/head
liutao 2 months ago
commit b3d07e3c89

@ -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集合

@ -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',

@ -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: '请输入位置',

@ -73,6 +73,30 @@
<el-input v-model="formData.deviceSpec" :placeholder="t('EquipmentManagement.EquipmentLedger.placeholderDeviceSpec')" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="t('EquipmentManagement.EquipmentLedger.isSchedueld')" prop="isSchedueld">
<el-switch
v-model="formData.isSchedueld"
:active-value="1"
:inactive-value="0"
:active-text="t('EquipmentManagement.EquipmentLedger.yes')"
:inactive-text="t('EquipmentManagement.EquipmentLedger.no')"
inline-prompt
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="t('EquipmentManagement.EquipmentLedger.ratedCapacity')" prop="ratedCapacity">
<el-input-number
v-model="formData.ratedCapacity"
:min="0"
:precision="0"
controls-position="right"
class="!w-full"
:placeholder="t('EquipmentManagement.EquipmentLedger.placeholderRatedCapacity')"
/>
</el-form-item>
</el-col>
<!-- <el-col :span="12">
<el-form-item label="供应商" prop="supplier">
@ -395,6 +419,8 @@ const initFormData = () => ({
deviceBrand: undefined,
deviceModel: undefined,
deviceSpec: undefined,
isSchedueld: 0,
ratedCapacity: undefined,
deviceType: undefined,
supplier: undefined,
workshop: undefined,
@ -561,6 +587,8 @@ const open = async (type: string, id?: number, defaultDeviceTypeId?: number) =>
...initFormData(),
...(detail as any),
isCode: (detail as any)?.isCode ?? false,
isSchedueld: normalizeNumberish((detail as any)?.isSchedueld ?? (detail as any)?.isScheduled) ?? 0,
ratedCapacity: normalizeNumberish((detail as any)?.ratedCapacity),
deviceType: normalizeNumberish((detail as any)?.deviceType),
deviceManagerIds: parseIdsValue((detail as any)?.deviceManager),
productionDate: normalizeYmd((detail as any)?.productionDate),
@ -591,6 +619,8 @@ const submitForm = async () => {
try {
const data = {
...(formData.value as any),
isSchedueld: normalizeNumberish((formData.value as any).isSchedueld) ?? 0,
ratedCapacity: normalizeNumberish((formData.value as any).ratedCapacity),
deviceType: normalizeNumberish(formData.value.deviceType),
productionDate: normalizeYmd(formData.value.productionDate),
factoryEntryDate: normalizeYmd(formData.value.factoryEntryDate),

@ -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

Loading…
Cancel
Save