feat(mes): 新增设备台账导入功能及相关接口

新增设备台账导入功能,支持从 Excel 文件批量导入设备信息。实现了导入模板的生成和导入结果的反馈,包括成功创建和更新的设备编码,以及导入失败的原因提示。同时,更新了设备类型和车间的校验逻辑,确保数据的有效性和完整性。
pull/871/MERGE
YunaiV 2026-04-02 22:27:11 +08:00
parent 5ea8c24410
commit 4bbe313ef8
1 changed files with 24 additions and 1 deletions

View File

@ -75,6 +75,7 @@
placeholder="请选择最近点检时间"
value-format="x"
class="!w-1/1"
disabled
/>
</el-form-item>
</el-col>
@ -86,6 +87,7 @@
placeholder="请选择最近保养时间"
value-format="x"
class="!w-1/1"
disabled
/>
</el-form-item>
</el-col>
@ -124,9 +126,11 @@
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { DvMachineryApi, DvMachineryVO } from '@/api/mes/dv/machinery'
import { DvMachineryTypeApi } from '@/api/mes/dv/machinery/type'
import { WmBarcodeApi } from '@/api/mes/wm/barcode'
import MdWorkshopSelect from '@/views/mes/md/workstation/components/MdWorkshopSelect.vue'
import Barcode from '@/views/mes/wm/barcode/components/Barcode.vue'
import { defaultProps, handleTree } from '@/utils/tree'
import { MesDvMachineryStatusEnum } from '@/views/mes/utils/constants'
import { MesDvMachineryStatusEnum, BarcodeBizTypeEnum } from '@/views/mes/utils/constants'
import { generateRandomStr } from '@/utils'
defineOptions({ name: 'MachineryForm' })
@ -161,9 +165,13 @@ const formRules = reactive({
})
const formRef = ref() // Ref
const machineryTypeTree = ref<any[]>([]) //
const barcodeContent = ref('') //
const barcodeFormat = ref(0) //
/** 生成设备编码 */
const generateCode = () => {
// TODO @AI
// TODO @AI code
formData.value.code = 'M' + generateRandomStr(12)
}
@ -181,6 +189,19 @@ const open = async (type: string, id?: number) => {
formLoading.value = true
try {
formData.value = await DvMachineryApi.getMachinery(id)
//
try {
const barcode = await WmBarcodeApi.getBarcodeByBusiness(
BarcodeBizTypeEnum.MACHINERY,
id
)
if (barcode) {
barcodeContent.value = barcode.content || ''
barcodeFormat.value = barcode.format || 0
}
} catch {
//
}
} finally {
formLoading.value = false
}
@ -227,6 +248,8 @@ const resetForm = () => {
lastMaintenTime: undefined,
remark: undefined
}
barcodeContent.value = ''
barcodeFormat.value = 0
formRef.value?.resetFields()
}
</script>