feat:设备台账-添加是否排产、额定产能字段;状态改成switch切换

pull/1/head
黄伟杰 2 months ago
parent b3c22ec032
commit b8dc35bc23

@ -26,6 +26,9 @@ export interface DeviceLedgerVO {
remark: string // 备注 remark: string // 备注
fileUrl?: string // 附件下载 fileUrl?: string // 附件下载
qrcodeUrl?: string qrcodeUrl?: string
isSchedueld?: number
isScheduled?: number
ratedCapacity?: number
componentId?: string // 关键件ids集合 componentId?: string // 关键件ids集合
componentList?: CriticalComponentVO[] componentList?: CriticalComponentVO[]
beijianId?: string // 备件ids集合 beijianId?: string // 备件ids集合

@ -1196,9 +1196,15 @@ export default {
qrcode: 'QR Code/Barcode', qrcode: 'QR Code/Barcode',
deviceName: 'Name', deviceName: 'Name',
deviceStatus: 'Status', deviceStatus: 'Status',
statusEnabled: 'Enabled',
statusDisabled: 'Disabled',
deviceType: 'Type', deviceType: 'Type',
deviceSpec: 'Spec', deviceSpec: 'Spec',
deviceModel: 'Model', deviceModel: 'Model',
isSchedueld: 'Schedule',
ratedCapacity: 'Rated Capacity',
yes: 'Yes',
no: 'No',
productionDate: 'Production Date', productionDate: 'Production Date',
factoryEntryDate: 'Factory Entry Date', factoryEntryDate: 'Factory Entry Date',
deviceLocation: 'Location', deviceLocation: 'Location',
@ -1218,6 +1224,7 @@ export default {
placeholderDeviceType: 'Please select type', placeholderDeviceType: 'Please select type',
placeholderDeviceModel: 'Please input model', placeholderDeviceModel: 'Please input model',
placeholderDeviceSpec: 'Please input spec', placeholderDeviceSpec: 'Please input spec',
placeholderRatedCapacity: 'Please input rated capacity',
placeholderProductionDate: 'Please select production date', placeholderProductionDate: 'Please select production date',
placeholderFactoryEntryDate: 'Please select factory entry date', placeholderFactoryEntryDate: 'Please select factory entry date',
placeholderDeviceLocation: 'Please input location', placeholderDeviceLocation: 'Please input location',

@ -1188,9 +1188,15 @@ export default {
qrcode: '二维码/条形码', qrcode: '二维码/条形码',
deviceName: '名称', deviceName: '名称',
deviceStatus: '状态', deviceStatus: '状态',
statusEnabled: '启用',
statusDisabled: '不启用',
deviceType: '类型', deviceType: '类型',
deviceSpec: '规格', deviceSpec: '规格',
deviceModel: '型号', deviceModel: '型号',
isSchedueld: '是否排产',
ratedCapacity: '额定产能',
yes: '是',
no: '否',
productionDate: '生产日期', productionDate: '生产日期',
factoryEntryDate: '入厂日期', factoryEntryDate: '入厂日期',
deviceLocation: '位置', deviceLocation: '位置',
@ -1210,6 +1216,7 @@ export default {
placeholderDeviceType: '请选择类型', placeholderDeviceType: '请选择类型',
placeholderDeviceModel: '请输入型号', placeholderDeviceModel: '请输入型号',
placeholderDeviceSpec: '请输入规格', placeholderDeviceSpec: '请输入规格',
placeholderRatedCapacity: '请输入额定产能',
placeholderProductionDate: '请选择生产日期', placeholderProductionDate: '请选择生产日期',
placeholderFactoryEntryDate: '请选择入厂日期', placeholderFactoryEntryDate: '请选择入厂日期',
placeholderDeviceLocation: '请输入位置', placeholderDeviceLocation: '请输入位置',

@ -73,6 +73,30 @@
<el-input v-model="formData.deviceSpec" :placeholder="t('EquipmentManagement.EquipmentLedger.placeholderDeviceSpec')" /> <el-input v-model="formData.deviceSpec" :placeholder="t('EquipmentManagement.EquipmentLedger.placeholderDeviceSpec')" />
</el-form-item> </el-form-item>
</el-col> </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-col :span="12">
<el-form-item label="供应商" prop="supplier"> <el-form-item label="供应商" prop="supplier">
@ -395,6 +419,8 @@ const initFormData = () => ({
deviceBrand: undefined, deviceBrand: undefined,
deviceModel: undefined, deviceModel: undefined,
deviceSpec: undefined, deviceSpec: undefined,
isSchedueld: 0,
ratedCapacity: undefined,
deviceType: undefined, deviceType: undefined,
supplier: undefined, supplier: undefined,
workshop: undefined, workshop: undefined,
@ -561,6 +587,8 @@ const open = async (type: string, id?: number, defaultDeviceTypeId?: number) =>
...initFormData(), ...initFormData(),
...(detail as any), ...(detail as any),
isCode: (detail as any)?.isCode ?? false, 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), deviceType: normalizeNumberish((detail as any)?.deviceType),
deviceManagerIds: parseIdsValue((detail as any)?.deviceManager), deviceManagerIds: parseIdsValue((detail as any)?.deviceManager),
productionDate: normalizeYmd((detail as any)?.productionDate), productionDate: normalizeYmd((detail as any)?.productionDate),
@ -591,6 +619,8 @@ const submitForm = async () => {
try { try {
const data = { const data = {
...(formData.value as any), ...(formData.value as any),
isSchedueld: normalizeNumberish((formData.value as any).isSchedueld) ?? 0,
ratedCapacity: normalizeNumberish((formData.value as any).ratedCapacity),
deviceType: normalizeNumberish(formData.value.deviceType), deviceType: normalizeNumberish(formData.value.deviceType),
productionDate: normalizeYmd(formData.value.productionDate), productionDate: normalizeYmd(formData.value.productionDate),
factoryEntryDate: normalizeYmd(formData.value.factoryEntryDate), factoryEntryDate: normalizeYmd(formData.value.factoryEntryDate),

@ -103,15 +103,24 @@
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceStatus')" <el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceStatus')"
align="center" prop="deviceStatus" sortable> align="center" prop="deviceStatus" sortable>
<template #default="scope"> <template #default="scope">
<el-tag <el-switch
:type="getTzStatusTagType(scope.row.deviceStatus)" :model-value="isDeviceLedgerEnabled(scope.row)"
:color="getTzStatusTagColor(scope.row.deviceStatus)" :loading="Boolean(deviceStatusUpdatingMap[scope.row.id])"
:style="getTzStatusTagStyle(scope.row.deviceStatus)" effect="light" inline-prompt
disable-transitions> @change="(val) => handleDeviceStatusChange(scope.row, val)"
{{ getTzStatusLabel(scope.row.deviceStatus) }} />
</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> </el-tag>
</template> </template>
</el-table-column> </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')" <el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceSpec')"
align="center" prop="deviceSpec"/> align="center" prop="deviceSpec"/>
<el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceModel')" <el-table-column :label="t('EquipmentManagement.EquipmentLedger.deviceModel')"
@ -255,7 +264,7 @@
{{ detailData?.deviceName ?? '' }} {{ detailData?.deviceName ?? '' }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item :label="t('EquipmentManagement.EquipmentLedger.deviceStatus')"> <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>
<!-- <el-descriptions-item :label="t('EquipmentManagement.EquipmentLedger.deviceBrand')">{{ detailData?.deviceBrand ?? '' }}</el-descriptions-item> --> <!-- <el-descriptions-item :label="t('EquipmentManagement.EquipmentLedger.deviceBrand')">{{ detailData?.deviceBrand ?? '' }}</el-descriptions-item> -->
<el-descriptions-item :label="t('EquipmentManagement.EquipmentLedger.deviceModel')"> <el-descriptions-item :label="t('EquipmentManagement.EquipmentLedger.deviceModel')">
@ -1099,6 +1108,8 @@ const tzStatusOptions = computed(() => {
const detailVisible = ref(false) const detailVisible = ref(false)
const detailLoading = ref(false) const detailLoading = ref(false)
const detailData = ref<DeviceLedgerVO | undefined>() const detailData = ref<DeviceLedgerVO | undefined>()
const detailStatusLoading = ref(false)
const deviceStatusUpdatingMap = ref<Record<number, boolean>>({})
const detailActiveTab = ref('check') const detailActiveTab = ref('check')
const selectedDetailId = ref<number | undefined>() const selectedDetailId = ref<number | undefined>()
@ -1179,6 +1190,42 @@ const getTzStatusTagStyle = (value: any) => {
return 'color: #fff' 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) => { const formatDetailDate = (value: any) => {
if (!value) return '' if (!value) return ''
return formatDate(new Date(value), 'YYYY-MM-DD') 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 = () => { const closeDetail = () => {
detailVisible.value = false detailVisible.value = false
selectedDetailId.value = undefined selectedDetailId.value = undefined

Loading…
Cancel
Save