|
|
|
|
@ -223,7 +223,8 @@ import { RecipeConfigApi } from '@/api/iot/recipeConfig'
|
|
|
|
|
import { RecipePointApi } from '@/api/iot/recipePoint'
|
|
|
|
|
import FormulaLibraryDetailTabs from './components/FormulaLibraryDetailTabs.vue'
|
|
|
|
|
import FormulaLibraryReadDialog from './components/FormulaLibraryReadDialog.vue'
|
|
|
|
|
import { RecipeDeviceRecordApi} from '@/api/iot/recipeDeviceRecord'
|
|
|
|
|
import { RecipeDeviceRecordApi } from '@/api/iot/recipeDeviceRecord'
|
|
|
|
|
import { RecipePointRecordApi } from '@/api/iot/recipepointrecord'
|
|
|
|
|
|
|
|
|
|
type SelectOption<T = any> = { label: string; value: T }
|
|
|
|
|
|
|
|
|
|
@ -398,11 +399,37 @@ const openDialog = async (type: 'create' | 'update', row?: RecipePlanDetailVO) =
|
|
|
|
|
|
|
|
|
|
const readDialogRef = ref<InstanceType<typeof FormulaLibraryReadDialog>>()
|
|
|
|
|
|
|
|
|
|
const checkRecipeRecords = async (recipeId: string | number) => {
|
|
|
|
|
const params = {
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 1,
|
|
|
|
|
recipeId: String(recipeId)
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const [devicePage, manualPage] = await Promise.all([
|
|
|
|
|
RecipeDeviceRecordApi.getRecipeDeviceRecordPage(params),
|
|
|
|
|
RecipePointRecordApi.getRecipePointRecordPage(params)
|
|
|
|
|
])
|
|
|
|
|
const deviceTotal = Number((devicePage as any)?.total ?? 0)
|
|
|
|
|
const manualTotal = Number((manualPage as any)?.total ?? 0)
|
|
|
|
|
return {
|
|
|
|
|
hasDeviceRecords: deviceTotal > 0,
|
|
|
|
|
hasManualRecords: manualTotal > 0
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
return {
|
|
|
|
|
hasDeviceRecords: false,
|
|
|
|
|
hasManualRecords: false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleRead = async (row: RecipePlanDetailVO) => {
|
|
|
|
|
const recipeId = row?.recipeId
|
|
|
|
|
const id = row?.id
|
|
|
|
|
if (!recipeId) return
|
|
|
|
|
const recipeName = row?.recipeName
|
|
|
|
|
const { hasDeviceRecords, hasManualRecords } = await checkRecipeRecords(recipeId)
|
|
|
|
|
const data = await RecipePointApi.getRecipePointList(Number(recipeId))
|
|
|
|
|
if (!data?.length) {
|
|
|
|
|
await message.confirm(t('RecipeManagement.RecipeLibrary.readDeviceConfirmMessage'))
|
|
|
|
|
@ -412,7 +439,13 @@ const handleRead = async (row: RecipePlanDetailVO) => {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await readDialogRef.value?.open({ recipeId, recipeName, data, id })
|
|
|
|
|
await readDialogRef.value?.open({
|
|
|
|
|
recipeId,
|
|
|
|
|
recipeName,
|
|
|
|
|
data,
|
|
|
|
|
id,
|
|
|
|
|
hasExistingRecords: hasDeviceRecords || hasManualRecords
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const submitDialog = async () => {
|
|
|
|
|
|