style:配方库-若当前子列表有数据,则读取弹框添加覆盖提示

main
黄伟杰 1 month ago
parent b1d91ffc19
commit 755978994f

@ -176,7 +176,7 @@ export const RecipeConfigApi = {
},
getRecipePointDetailPage: async (params: any) => {
return await request.get({ url: `/iot/recipe-device-attribute/page`, params })
return await request.get({ url: `/iot/recipe-device-attribute/getList`, params })
},
updateRecipeDeviceAttribute: async (data: { recipeId: string | number; ids: number[] }) => {
return await request.put({ url: `/iot/recipe-device-attribute/update`, data })

@ -2657,6 +2657,7 @@ export default {
readDialogSubmitButtonText: 'Read',
readDialogCancelButton: 'Cancel',
readDeviceConfirmMessage: 'Do you want to read device data?',
readDialogOverwriteTip: 'Reading again will overwrite existing device data and manual parameters',
detailTabDeviceDataLabel: 'Device Data',
detailTabManualLabel: 'Manual Parameters',
detailDevicePointNameColumn: 'Point Name',

@ -2240,6 +2240,7 @@ export default {
readDialogSubmitButtonText: '读 取',
readDialogCancelButton: '取 消',
readDeviceConfirmMessage: '是否读取设备数据?',
readDialogOverwriteTip: '再次读取会覆盖已有设备数据和手动录入参数',
detailTabDeviceDataLabel: '设备数据',
detailTabManualLabel: '手动录入参数',
detailDevicePointNameColumn: '点位名称',

@ -1,6 +1,14 @@
<template>
<Dialog v-model="visible" :title="title" width="920px">
<div class="formula-library-read-content">
<el-alert
v-if="hasExistingRecords"
type="warning"
:closable="false"
:title="t('RecipeManagement.RecipeLibrary.readDialogOverwriteTip')"
show-icon
class="mb-15px"
/>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" row-key="id">
<!-- <el-table-column type="index" :label="t('RecipeManagement.RecipeLibrary.tableIndexColumn')" align="center" width="70" /> -->
<el-table-column
@ -94,6 +102,7 @@ type PageResult<T> = { list: T[]; total: number }
const visible = ref(false)
const title = ref('')
const loading = ref(false)
const hasExistingRecords = ref(false)
const recipeId = ref<string | number | undefined>(undefined)
const list = ref<RecipePointVO[]>([])
@ -144,11 +153,13 @@ const open = async (options: {
recipeId: string | number
recipeName?: string
data?: Array<RecipePointVO>
id : undefined | number
id: number | undefined
hasExistingRecords?: boolean
}) => {
visible.value = true
formulaLibraryId.value = options.id
recipeId.value = options.recipeId
hasExistingRecords.value = !!options.hasExistingRecords
const baseTitle = t('RecipeManagement.RecipeLibrary.readDialogTitle')
title.value = options.recipeName ? `${baseTitle}-${options.recipeName}` : baseTitle
queryParams.pageNo = 1

@ -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 () => {

Loading…
Cancel
Save