From fe6a11009b0e2672c0ccb80a927005d0db8518e3 Mon Sep 17 00:00:00 2001 From: hwj Date: Thu, 5 Feb 2026 17:03:22 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E9=85=8D=E6=96=B9=E7=AE=A1?= =?UTF-8?q?=E7=90=86-=E9=85=8D=E6=96=B9=E9=85=8D=E7=BD=AE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=96=B0=E5=A2=9E/=E7=BC=96=E8=BE=91=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/recipeConfig/index.ts | 14 ++--- src/views/formula/formulaConfig/index.vue | 62 +++++++++++++++-------- 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/src/api/iot/recipeConfig/index.ts b/src/api/iot/recipeConfig/index.ts index 53034c1e..f0aabf39 100644 --- a/src/api/iot/recipeConfig/index.ts +++ b/src/api/iot/recipeConfig/index.ts @@ -6,9 +6,11 @@ export interface RecipeConfigVO { recipeName?: string name?: string recipeType?: string | number + recipeTypeId?: string | number productId?: number productName?: string machineName?: string + machineId?: number deviceId?: number deviceName?: string recipeDesc?: string @@ -120,9 +122,9 @@ export const RecipeConfigApi = { id: data.id, name: data.name ?? data.recipeName, recipeCode: data.recipeCode, - recipeType: data.recipeType, - productName: data.productName, - machineName: data.machineName ?? data.deviceName, + recipeTypeId: (data as any).recipeTypeId ?? data.recipeType, + productId: data.productId, + machineId: (data as any).machineId ?? data.deviceId, recipeDesc: data.recipeDesc ?? data.remark, isEnable: data.isEnable, dataUnit: data.dataUnit @@ -135,9 +137,9 @@ export const RecipeConfigApi = { id: data.id, name: data.name ?? data.recipeName, recipeCode: data.recipeCode, - recipeType: data.recipeType, - productName: data.productName, - machineName: data.machineName ?? data.deviceName, + recipeTypeId: (data as any).recipeTypeId ?? data.recipeType, + productId: data.productId, + machineId: (data as any).machineId ?? data.deviceId, recipeDesc: data.recipeDesc ?? data.remark, isEnable: data.isEnable, dataUnit: data.dataUnit diff --git a/src/views/formula/formulaConfig/index.vue b/src/views/formula/formulaConfig/index.vue index 2a7413e3..871ade72 100644 --- a/src/views/formula/formulaConfig/index.vue +++ b/src/views/formula/formulaConfig/index.vue @@ -155,9 +155,9 @@ ref="detailRef" :visible="detailVisible" clearable /> - + - + - + []>([]) const getRecipeTypeLabel = (value: unknown) => { - return value === undefined || value === null ? '' : String(value) + if (value === undefined || value === null || value === '') return '' + const matched = recipeTypeOptions.value.find( + (item) => item.value === value || String(item.value) === String(value) || item.label === value + ) + return matched?.label ?? String(value) } const getProductOptions = async () => { productLoading.value = true try { const data = await ProductApi.getProductSimpleList() - productOptions.value = (data ?? []).map((item: any) => ({ label: item.name, value: item.name })) + productOptions.value = (data ?? []).map((item: any) => ({ label: item.name, value: item.id })) } finally { productLoading.value = false } @@ -407,7 +411,7 @@ const getDeviceOptions = async () => { deviceLoading.value = true try { const data = await DeviceApi.getDeviceList() - deviceOptions.value = (data ?? []).map((item: any) => ({ label: item.deviceName, value: item.deviceName })) + deviceOptions.value = (data ?? []).map((item: any) => ({ label: item.deviceName, value: item.id })) } finally { deviceLoading.value = false } @@ -417,7 +421,7 @@ const getRecipeTypeOptions = async () => { recipeTypeLoading.value = true try { const data = await RecipeApi.getRecipePage({}) - recipeTypeOptions.value = (data?.list ?? []).map((item: any) => ({ label: item.name, value: item.name })) + recipeTypeOptions.value = (data?.list ?? []).map((item: any) => ({ label: item.name, value: item.id })) } finally { recipeTypeLoading.value = false } @@ -443,9 +447,9 @@ const dialogForm = reactive({ id: undefined as number | undefined, recipeCode: '', name: '', - recipeType: '' as string | undefined, - productName: '' as string | undefined, - machineName: '' as string | undefined, + recipeTypeId: '' as string | number | undefined, + productId: '' as string | number | undefined, + machineId: '' as string | number | undefined, recipeDesc: '' }) @@ -478,9 +482,9 @@ const openDialog = async (mode: DialogMode, row?: RecipeConfigVO) => { dialogForm.id = undefined dialogForm.recipeCode = '' dialogForm.name = '' - dialogForm.recipeType = '' - dialogForm.productName = '' - dialogForm.machineName = '' + dialogForm.recipeTypeId = '' + dialogForm.productId = '' + dialogForm.machineId = '' dialogForm.recipeDesc = '' return } @@ -488,9 +492,23 @@ const openDialog = async (mode: DialogMode, row?: RecipeConfigVO) => { dialogForm.id = row?.id dialogForm.recipeCode = row?.recipeCode ?? '' dialogForm.name = row?.name ?? row?.recipeName ?? '' - dialogForm.recipeType = row?.recipeType === undefined || row?.recipeType === null ? '' : String(row.recipeType) - dialogForm.productName = row?.productName ?? '' - dialogForm.machineName = row?.machineName ?? row?.deviceName ?? '' + dialogForm.recipeTypeId = + (row as any)?.recipeTypeId ?? + (row?.recipeType === undefined || row?.recipeType === null ? '' : (row as any).recipeType) + + const findProductValueByName = (name: string | undefined) => { + if (!name) return '' + const matched = productOptions.value.find((o) => o.label === name || String(o.value) === String((row as any)?.productId)) + return matched?.value ?? '' + } + const findDeviceValueByName = (name: string | undefined) => { + if (!name) return '' + const matched = deviceOptions.value.find((o) => o.label === name || String(o.value) === String((row as any)?.machineId ?? (row as any)?.deviceId)) + return matched?.value ?? '' + } + + dialogForm.productId = (row as any)?.productId ?? findProductValueByName(row?.productName) + dialogForm.machineId = (row as any)?.machineId ?? (row as any)?.deviceId ?? findDeviceValueByName(row?.machineName ?? row?.deviceName) dialogForm.recipeDesc = row?.recipeDesc ?? row?.remark ?? '' } @@ -503,9 +521,9 @@ const submitDialog = async () => { id: dialogForm.id, recipeCode: dialogForm.recipeCode, name: dialogForm.name, - recipeType: dialogForm.recipeType, - productName: dialogForm.productName, - machineName: dialogForm.machineName, + recipeTypeId: dialogForm.recipeTypeId, + productId: dialogForm.productId, + machineId: dialogForm.machineId, recipeDesc: dialogForm.recipeDesc } if (dialogMode.value === 'create') {