style:配方配置-修改配方类型传参

liutao_branch
黄伟杰 4 months ago
parent f67e5136b5
commit a51f19db91

@ -232,19 +232,10 @@ const productOptions = ref<SelectOption<string>[]>([])
const deviceLoading = ref(false) const deviceLoading = ref(false)
const deviceOptions = ref<SelectOption<string>[]>([]) const deviceOptions = ref<SelectOption<string>[]>([])
const recipeTypeLoading = ref(false) const recipeTypeLoading = ref(false)
const recipeTypeOptions = ref<SelectOption<number>[]>([]) const recipeTypeOptions = ref<SelectOption<string>[]>([])
const recipeTypeLabelMap = computed<Record<number, string>>(() => {
return recipeTypeOptions.value.reduce((acc, cur) => {
acc[cur.value] = cur.label
return acc
}, {} as Record<number, string>)
})
const getRecipeTypeLabel = (value: unknown) => { const getRecipeTypeLabel = (value: unknown) => {
const num = Number(value) return value === undefined || value === null ? '' : String(value)
if (!Number.isNaN(num) && recipeTypeLabelMap.value[num]) return recipeTypeLabelMap.value[num]
return (value as any) ?? ''
} }
const getProductOptions = async () => { const getProductOptions = async () => {
@ -270,11 +261,8 @@ const getDeviceOptions = async () => {
const getRecipeTypeOptions = async () => { const getRecipeTypeOptions = async () => {
recipeTypeLoading.value = true recipeTypeLoading.value = true
try { try {
const data = await RecipeApi.getRecipePage(undefined) const data = await RecipeApi.getRecipePage()
recipeTypeOptions.value = (data?.list ?? []).map((item: any) => ({ recipeTypeOptions.value = (data?.list ?? []).map((item: any) => ({ label: item.name, value: item.name }))
label: item.name,
value: item.id
}))
} finally { } finally {
recipeTypeLoading.value = false recipeTypeLoading.value = false
} }
@ -296,7 +284,7 @@ const dialogForm = reactive({
id: undefined as number | undefined, id: undefined as number | undefined,
recipeCode: '', recipeCode: '',
name: '', name: '',
recipeType: undefined as number | undefined, recipeType: '' as string | undefined,
productName: '' as string | undefined, productName: '' as string | undefined,
machineName: '' as string | undefined, machineName: '' as string | undefined,
recipeDesc: '' recipeDesc: ''
@ -319,7 +307,7 @@ const openDialog = async (mode: DialogMode, row?: RecipeConfigVO) => {
dialogForm.id = undefined dialogForm.id = undefined
dialogForm.recipeCode = '' dialogForm.recipeCode = ''
dialogForm.name = '' dialogForm.name = ''
dialogForm.recipeType = undefined dialogForm.recipeType = ''
dialogForm.productName = '' dialogForm.productName = ''
dialogForm.machineName = '' dialogForm.machineName = ''
dialogForm.recipeDesc = '' dialogForm.recipeDesc = ''
@ -329,7 +317,7 @@ const openDialog = async (mode: DialogMode, row?: RecipeConfigVO) => {
dialogForm.id = row?.id dialogForm.id = row?.id
dialogForm.recipeCode = row?.recipeCode ?? '' dialogForm.recipeCode = row?.recipeCode ?? ''
dialogForm.name = row?.name ?? row?.recipeName ?? '' dialogForm.name = row?.name ?? row?.recipeName ?? ''
dialogForm.recipeType = typeof row?.recipeType === 'number' ? row.recipeType : Number(row?.recipeType) || undefined dialogForm.recipeType = row?.recipeType === undefined || row?.recipeType === null ? '' : String(row.recipeType)
dialogForm.productName = row?.productName ?? '' dialogForm.productName = row?.productName ?? ''
dialogForm.machineName = row?.machineName ?? row?.deviceName ?? '' dialogForm.machineName = row?.machineName ?? row?.deviceName ?? ''
dialogForm.recipeDesc = row?.recipeDesc ?? row?.remark ?? '' dialogForm.recipeDesc = row?.recipeDesc ?? row?.remark ?? ''

Loading…
Cancel
Save