✨ feat(mes): 新增设备编码生成逻辑及相关常量
parent
4bbe313ef8
commit
3db2347f67
|
|
@ -100,7 +100,7 @@
|
|||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<!-- TODO @芋艿:barcodeimg -->
|
||||
|
||||
<!-- 编辑时显示子资源 Tab -->
|
||||
<el-tabs v-if="formType === 'update'" v-model="activeTab" class="mt-10px">
|
||||
<el-tab-pane label="点检记录" name="check">
|
||||
|
|
@ -126,12 +126,14 @@
|
|||
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, BarcodeBizTypeEnum } from '@/views/mes/utils/constants'
|
||||
import { generateRandomStr } from '@/utils'
|
||||
import {
|
||||
MesDvMachineryStatusEnum,
|
||||
MesAutoCodeRuleCode
|
||||
} from '@/views/mes/utils/constants'
|
||||
import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record'
|
||||
|
||||
defineOptions({ name: 'MachineryForm' })
|
||||
|
||||
|
|
@ -165,14 +167,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)
|
||||
const generateCode = async () => {
|
||||
formData.value.code = await AutoCodeRecordApi.generateAutoCode(
|
||||
MesAutoCodeRuleCode.DV_MACHINERY_CODE
|
||||
)
|
||||
}
|
||||
|
||||
/** 打开弹窗 */
|
||||
|
|
@ -189,19 +190,7 @@ 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
|
||||
}
|
||||
|
|
@ -248,8 +237,7 @@ const resetForm = () => {
|
|||
lastMaintenTime: undefined,
|
||||
remark: undefined
|
||||
}
|
||||
barcodeContent.value = ''
|
||||
barcodeFormat.value = 0
|
||||
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
|||
import { DvMachineryTypeApi, DvMachineryTypeVO } from '@/api/mes/dv/machinery/type'
|
||||
import { defaultProps, handleTree } from '@/utils/tree'
|
||||
import { CommonStatusEnum } from '@/utils/constants'
|
||||
import { MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
|
||||
import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record'
|
||||
|
||||
defineOptions({ name: 'MachineryTypeForm' })
|
||||
|
|
@ -151,7 +152,9 @@ const resetForm = () => {
|
|||
|
||||
/** 生成设备类型编码 */
|
||||
const generateCode = async () => {
|
||||
formData.value.code = await AutoCodeRecordApi.generateAutoCode('DV_MACHINERY_TYPE_CODE')
|
||||
formData.value.code = await AutoCodeRecordApi.generateAutoCode(
|
||||
MesAutoCodeRuleCode.DV_MACHINERY_TYPE_CODE
|
||||
)
|
||||
}
|
||||
|
||||
/** 获得设备类型树 */
|
||||
|
|
|
|||
|
|
@ -446,7 +446,9 @@ export const MesAutoCodeRuleCode = {
|
|||
TRANSFER_CODE: 'TRANSFER_CODE', // 转移调拨单编码
|
||||
WM_OUTSOURCE_ISSUE_CODE: 'WM_OUTSOURCE_ISSUE_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
|
||||
|
||||
/** 获取物料/产品标识的标签 */
|
||||
|
|
|
|||
Loading…
Reference in New Issue