feat(mes): 新增设备编码生成逻辑及相关常量

pull/871/MERGE
YunaiV 2026-04-02 22:37:04 +08:00
parent 4bbe313ef8
commit 3db2347f67
3 changed files with 21 additions and 28 deletions

View File

@ -100,7 +100,7 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<!-- TODO @芋艿barcodeimg -->
<!-- 编辑时显示子资源 Tab --> <!-- 编辑时显示子资源 Tab -->
<el-tabs v-if="formType === 'update'" v-model="activeTab" class="mt-10px"> <el-tabs v-if="formType === 'update'" v-model="activeTab" class="mt-10px">
<el-tab-pane label="点检记录" name="check"> <el-tab-pane label="点检记录" name="check">
@ -126,12 +126,14 @@
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict' import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { DvMachineryApi, DvMachineryVO } from '@/api/mes/dv/machinery' import { DvMachineryApi, DvMachineryVO } from '@/api/mes/dv/machinery'
import { DvMachineryTypeApi } from '@/api/mes/dv/machinery/type' 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 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 { defaultProps, handleTree } from '@/utils/tree'
import { MesDvMachineryStatusEnum, BarcodeBizTypeEnum } from '@/views/mes/utils/constants' import {
import { generateRandomStr } from '@/utils' MesDvMachineryStatusEnum,
MesAutoCodeRuleCode
} from '@/views/mes/utils/constants'
import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record'
defineOptions({ name: 'MachineryForm' }) defineOptions({ name: 'MachineryForm' })
@ -165,14 +167,13 @@ const formRules = reactive({
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const machineryTypeTree = ref<any[]>([]) // const machineryTypeTree = ref<any[]>([]) //
const barcodeContent = ref('') //
const barcodeFormat = ref(0) //
/** 生成设备编码 */ /** 生成设备编码 */
const generateCode = () => { const generateCode = async () => {
// TODO @AI formData.value.code = await AutoCodeRecordApi.generateAutoCode(
// TODO @AI code MesAutoCodeRuleCode.DV_MACHINERY_CODE
formData.value.code = 'M' + generateRandomStr(12) )
} }
/** 打开弹窗 */ /** 打开弹窗 */
@ -189,19 +190,7 @@ const open = async (type: string, id?: number) => {
formLoading.value = true formLoading.value = true
try { try {
formData.value = await DvMachineryApi.getMachinery(id) 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 { } finally {
formLoading.value = false formLoading.value = false
} }
@ -248,8 +237,7 @@ const resetForm = () => {
lastMaintenTime: undefined, lastMaintenTime: undefined,
remark: undefined remark: undefined
} }
barcodeContent.value = ''
barcodeFormat.value = 0
formRef.value?.resetFields() formRef.value?.resetFields()
} }
</script> </script>

View File

@ -58,6 +58,7 @@ import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { DvMachineryTypeApi, DvMachineryTypeVO } from '@/api/mes/dv/machinery/type' import { DvMachineryTypeApi, DvMachineryTypeVO } from '@/api/mes/dv/machinery/type'
import { defaultProps, handleTree } from '@/utils/tree' import { defaultProps, handleTree } from '@/utils/tree'
import { CommonStatusEnum } from '@/utils/constants' import { CommonStatusEnum } from '@/utils/constants'
import { MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record' import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record'
defineOptions({ name: 'MachineryTypeForm' }) defineOptions({ name: 'MachineryTypeForm' })
@ -151,7 +152,9 @@ const resetForm = () => {
/** 生成设备类型编码 */ /** 生成设备类型编码 */
const generateCode = async () => { const generateCode = async () => {
formData.value.code = await AutoCodeRecordApi.generateAutoCode('DV_MACHINERY_TYPE_CODE') formData.value.code = await AutoCodeRecordApi.generateAutoCode(
MesAutoCodeRuleCode.DV_MACHINERY_TYPE_CODE
)
} }
/** 获得设备类型树 */ /** 获得设备类型树 */

View File

@ -446,7 +446,9 @@ export const MesAutoCodeRuleCode = {
TRANSFER_CODE: 'TRANSFER_CODE', // 转移调拨单编码 TRANSFER_CODE: 'TRANSFER_CODE', // 转移调拨单编码
WM_OUTSOURCE_ISSUE_CODE: 'WM_OUTSOURCE_ISSUE_CODE', // 外协发料单编码 WM_OUTSOURCE_ISSUE_CODE: 'WM_OUTSOURCE_ISSUE_CODE', // 外协发料单编码
CAL_TEAM_CODE: 'CAL_TEAM_CODE', // 班组编码 CAL_TEAM_CODE: 'CAL_TEAM_CODE', // 班组编码
CAL_PLAN_CODE: 'CAL_PLAN_CODE' // 排班计划编码 CAL_PLAN_CODE: 'CAL_PLAN_CODE', // 排班计划编码
DV_MACHINERY_CODE: 'DV_MACHINERY_CODE', // 设备编码
DV_MACHINERY_TYPE_CODE: 'DV_MACHINERY_TYPE_CODE' // 设备类型编码
} as const } as const
/** 获取物料/产品标识的标签 */ /** 获取物料/产品标识的标签 */