feat:添加配方配置列表

liutao_branch
黄伟杰 4 months ago
parent 07ded7adf1
commit f67e5136b5

@ -65,6 +65,15 @@ export interface HistoryRecordParams {
collectionEndTime?: string collectionEndTime?: string
} }
export interface DeviceContactModelVO {
id: number
attributeCode?: string
attributeName?: string
attributeType?: string
dataType?: string
dataUnit?: string
}
// 物联设备 API // 物联设备 API
export const DeviceApi = { export const DeviceApi = {
// 查询物联设备分页 // 查询物联设备分页
@ -127,6 +136,10 @@ export const DeviceApi = {
getDeviceAttributePage: async (params) => { getDeviceAttributePage: async (params) => {
return await request.get({ url: `/iot/device/device-attribute/page`, params }) return await request.get({ url: `/iot/device/device-attribute/page`, params })
}, },
getDeviceContactModelPage: async () => {
return await request.get({ url: `/iot/device-contact-model/page` })
},
// 新增设备属性 // 新增设备属性
createDeviceAttribute: async (data) => { createDeviceAttribute: async (data) => {
return await request.post({ url: `/iot/device-contact-model/create`, data }) return await request.post({ url: `/iot/device-contact-model/create`, data })

@ -1,13 +1,21 @@
import request from '@/config/axios'
export interface RecipeConfigVO { export interface RecipeConfigVO {
id: number id: number
recipeCode: string recipeCode: string
recipeName: string recipeName?: string
name?: string
recipeType?: string | number recipeType?: string | number
productId?: number productId?: number
productName?: string productName?: string
machineName?: string
deviceId?: number deviceId?: number
deviceName?: string deviceName?: string
recipeDesc?: string
remark?: string remark?: string
isEnable?: string | number
dataUnit?: string
createTime?: string
} }
export interface RecipePointDetailVO { export interface RecipePointDetailVO {
@ -31,7 +39,6 @@ export interface RecipePointCandidateVO {
type PageResult<T> = { list: T[]; total: number } type PageResult<T> = { list: T[]; total: number }
const STORAGE_KEYS = { const STORAGE_KEYS = {
recipeList: 'mock:recipeConfig:recipes',
pointCandidates: 'mock:recipeConfig:pointCandidates', pointCandidates: 'mock:recipeConfig:pointCandidates',
recipePointRelation: 'mock:recipeConfig:recipePointRelation' recipePointRelation: 'mock:recipeConfig:recipePointRelation'
} as const } as const
@ -54,23 +61,6 @@ const saveToStorage = (key: string, value: any) => {
window.localStorage.setItem(key, JSON.stringify(value)) window.localStorage.setItem(key, JSON.stringify(value))
} }
const buildMockRecipes = (): RecipeConfigVO[] => {
return Array.from({ length: 18 }).map((_, idx) => {
const no = String(idx + 1).padStart(3, '0')
return {
id: idx + 1,
recipeCode: `RCP-${no}`,
recipeName: `配方-${no}`,
recipeType: idx % 2 === 0 ? '标准' : '自定义',
productId: undefined,
productName: idx % 3 === 0 ? '产品A' : idx % 3 === 1 ? '产品B' : '产品C',
deviceId: undefined,
deviceName: idx % 2 === 0 ? '设备1' : '设备2',
remark: idx % 4 === 0 ? '示例数据' : ''
}
})
}
const buildMockPointCandidates = (): RecipePointCandidateVO[] => { const buildMockPointCandidates = (): RecipePointCandidateVO[] => {
const pointTypes = ['模拟量', '开关量', '计算量'] const pointTypes = ['模拟量', '开关量', '计算量']
const dataTypes = ['int', 'float', 'string', 'bool'] const dataTypes = ['int', 'float', 'string', 'bool']
@ -88,9 +78,6 @@ const buildMockPointCandidates = (): RecipePointCandidateVO[] => {
} }
const ensureMockSeeded = () => { const ensureMockSeeded = () => {
const recipeList = loadFromStorage<RecipeConfigVO[]>(STORAGE_KEYS.recipeList, [])
if (!recipeList.length) saveToStorage(STORAGE_KEYS.recipeList, buildMockRecipes())
const pointCandidates = loadFromStorage<RecipePointCandidateVO[]>(STORAGE_KEYS.pointCandidates, []) const pointCandidates = loadFromStorage<RecipePointCandidateVO[]>(STORAGE_KEYS.pointCandidates, [])
if (!pointCandidates.length) saveToStorage(STORAGE_KEYS.pointCandidates, buildMockPointCandidates()) if (!pointCandidates.length) saveToStorage(STORAGE_KEYS.pointCandidates, buildMockPointCandidates())
@ -119,103 +106,53 @@ const contains = (value: string | undefined, keyword: string | undefined) => {
export const RecipeConfigApi = { export const RecipeConfigApi = {
getRecipeConfigPage: async (params: any) => { getRecipeConfigPage: async (params: any) => {
ensureMockSeeded() const finalParams = {
await sleep(120) ...(params ?? {}),
const recipeCode = params?.recipeCode name: params?.name ?? params?.recipeName
const recipeName = params?.recipeName }
const productName = params?.productName return await request.get({ url: `/iot/recipe/page`, params: finalParams })
const pageNo = params?.pageNo
const pageSize = params?.pageSize
const list = loadFromStorage<RecipeConfigVO[]>(STORAGE_KEYS.recipeList, buildMockRecipes())
const filtered = list.filter((item) => {
return (
contains(item.recipeCode, recipeCode) &&
contains(item.recipeName, recipeName) &&
contains(item.productName, productName)
)
})
return paginate(filtered, pageNo, pageSize)
}, },
createRecipeConfig: async (data: Partial<RecipeConfigVO>) => { createRecipeConfig: async (data: Partial<RecipeConfigVO>) => {
ensureMockSeeded() const finalData = {
await sleep(120) id: data.id,
const list = loadFromStorage<RecipeConfigVO[]>(STORAGE_KEYS.recipeList, buildMockRecipes()) name: data.name ?? data.recipeName,
const maxId = list.reduce((acc, cur) => Math.max(acc, cur.id), 0) recipeCode: data.recipeCode,
const nextId = maxId + 1
const newItem: RecipeConfigVO = {
id: nextId,
recipeCode: data.recipeCode ?? '',
recipeName: data.recipeName ?? '',
recipeType: data.recipeType, recipeType: data.recipeType,
productId: data.productId,
productName: data.productName, productName: data.productName,
deviceId: data.deviceId, machineName: data.machineName ?? data.deviceName,
deviceName: data.deviceName, recipeDesc: data.recipeDesc ?? data.remark,
remark: data.remark isEnable: data.isEnable,
dataUnit: data.dataUnit
} }
saveToStorage(STORAGE_KEYS.recipeList, [newItem, ...list]) return await request.post({ url: `/iot/recipe/create`, data: finalData })
return nextId
}, },
updateRecipeConfig: async (data: Partial<RecipeConfigVO>) => { updateRecipeConfig: async (data: Partial<RecipeConfigVO>) => {
ensureMockSeeded() const finalData = {
await sleep(120) id: data.id,
if (!data.id) return true name: data.name ?? data.recipeName,
const list = loadFromStorage<RecipeConfigVO[]>(STORAGE_KEYS.recipeList, buildMockRecipes()) recipeCode: data.recipeCode,
const next = list.map((item) => { recipeType: data.recipeType,
if (item.id !== data.id) return item productName: data.productName,
return { machineName: data.machineName ?? data.deviceName,
...item, recipeDesc: data.recipeDesc ?? data.remark,
recipeCode: data.recipeCode ?? item.recipeCode, isEnable: data.isEnable,
recipeName: data.recipeName ?? item.recipeName, dataUnit: data.dataUnit
recipeType: data.recipeType ?? item.recipeType,
productId: data.productId ?? item.productId,
productName: data.productName ?? item.productName,
deviceId: data.deviceId ?? item.deviceId,
deviceName: data.deviceName ?? item.deviceName,
remark: data.remark ?? item.remark
} }
}) return await request.put({ url: `/iot/recipe/update`, data: finalData })
saveToStorage(STORAGE_KEYS.recipeList, next)
return true
}, },
deleteRecipeConfig: async (id: number) => { deleteRecipeConfig: async (id: number) => {
ensureMockSeeded() return await request.delete({ url: `/iot/recipe/delete?id=` + id })
await sleep(120)
const list = loadFromStorage<RecipeConfigVO[]>(STORAGE_KEYS.recipeList, buildMockRecipes())
saveToStorage(
STORAGE_KEYS.recipeList,
list.filter((item) => item.id !== id)
)
const relation = loadFromStorage<Record<string, number[]>>(STORAGE_KEYS.recipePointRelation, {})
delete relation[String(id)]
saveToStorage(STORAGE_KEYS.recipePointRelation, relation)
return true
}, },
exportRecipeConfig: async (params: any) => { exportRecipeConfig: async (params: any) => {
ensureMockSeeded() const finalParams = {
await sleep(120) ...(params ?? {}),
const ids = String(params?.ids ?? '') name: params?.name ?? params?.recipeName
.split(',') }
.map((v) => Number(v)) return await request.download({ url: `/iot/recipe/export-excel`, params: finalParams })
.filter((v) => !Number.isNaN(v))
const list = loadFromStorage<RecipeConfigVO[]>(STORAGE_KEYS.recipeList, buildMockRecipes())
const exportList = ids.length ? list.filter((item) => ids.includes(item.id)) : list
const header = ['配方编码', '配方名称', '配方类型', '关联产品', '关联设备', '备注']
const rows = exportList.map((item) => [
item.recipeCode,
item.recipeName,
item.recipeType ?? '',
item.productName ?? '',
item.deviceName ?? '',
item.remark ?? ''
])
const csv = [header, ...rows].map((r) => r.map((v) => `"${String(v).replace(/"/g, '""')}"`).join(',')).join('\n')
return new Blob([csv], { type: 'text/csv;charset=utf-8' })
}, },
getPointCandidatePage: async (params: any): Promise<PageResult<RecipePointCandidateVO>> => { getPointCandidatePage: async (params: any): Promise<PageResult<RecipePointCandidateVO>> => {

@ -6,9 +6,9 @@
v-model="queryParams.recipeCode" placeholder="请输入配方编码" clearable @keyup.enter="handleQuery" v-model="queryParams.recipeCode" placeholder="请输入配方编码" clearable @keyup.enter="handleQuery"
class="!w-240px" /> class="!w-240px" />
</el-form-item> </el-form-item>
<el-form-item label="配方名称" prop="recipeName"> <el-form-item label="配方名称" prop="name">
<el-input <el-input
v-model="queryParams.recipeName" placeholder="请输入配方名称" clearable @keyup.enter="handleQuery" v-model="queryParams.name" placeholder="请输入配方名称" clearable @keyup.enter="handleQuery"
class="!w-240px" /> class="!w-240px" />
</el-form-item> </el-form-item>
<el-form-item label="产品名称" prop="productName"> <el-form-item label="产品名称" prop="productName">
@ -37,15 +37,15 @@ ref="tableRef" v-loading="loading" :data="list" :stripe="true" :show-overflow-to
highlight-current-row @selection-change="handleSelectionChange" @row-click="handleRowClick"> highlight-current-row @selection-change="handleSelectionChange" @row-click="handleRowClick">
<el-table-column type="selection" width="55" reserve-selection /> <el-table-column type="selection" width="55" reserve-selection />
<el-table-column label="配方编码" align="center" prop="recipeCode" /> <el-table-column label="配方编码" align="center" prop="recipeCode" />
<el-table-column label="配方名称" align="center" prop="recipeName" /> <el-table-column label="配方名称" align="center" prop="name" />
<el-table-column label="配方类型" align="center" prop="recipeType"> <el-table-column label="配方类型" align="center" prop="recipeType">
<template #default="scope"> <template #default="scope">
{{ getRecipeTypeLabel(scope.row.recipeType) }} {{ getRecipeTypeLabel(scope.row.recipeType) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="关联产品" align="center" prop="productName" /> <el-table-column label="关联产品" align="center" prop="productName" />
<el-table-column label="关联设备" align="center" prop="deviceName" /> <el-table-column label="关联设备" align="center" prop="machineName" />
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="配方描述" align="center" prop="recipeDesc" />
<el-table-column label="操作" align="center" width="240px" fixed="right"> <el-table-column label="操作" align="center" width="240px" fixed="right">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" @click.stop="openConfigDialog(scope.row)">配置</el-button> <el-button link type="primary" @click.stop="openConfigDialog(scope.row)">配置</el-button>
@ -64,7 +64,7 @@ ref="tableRef" v-loading="loading" :data="list" :stripe="true" :show-overflow-to
<template #extra> <template #extra>
<el-button link type="info" @click="closeDetail"></el-button> <el-button link type="info" @click="closeDetail"></el-button>
</template> </template>
<el-tab-pane :label="`详情:${detailMeta.recipeCode} - ${detailMeta.recipeName}`" name="detail"> <el-tab-pane :label="`详情:${detailMeta.recipeCode} - ${detailMeta.name}`" name="detail">
<el-table <el-table
v-loading="detailLoading" :data="detailList" :stripe="true" :show-overflow-tooltip="true" v-loading="detailLoading" :data="detailList" :stripe="true" :show-overflow-tooltip="true"
row-key="id"> row-key="id">
@ -90,8 +90,8 @@ v-loading="detailLoading" :data="detailList" :stripe="true" :show-overflow-toolt
<el-form-item label="配方编码" prop="recipeCode"> <el-form-item label="配方编码" prop="recipeCode">
<el-input v-model="dialogForm.recipeCode" placeholder="请输入配方编码" clearable /> <el-input v-model="dialogForm.recipeCode" placeholder="请输入配方编码" clearable />
</el-form-item> </el-form-item>
<el-form-item label="配方名称" prop="recipeName"> <el-form-item label="配方名称" prop="name">
<el-input v-model="dialogForm.recipeName" placeholder="请输入配方名称" clearable /> <el-input v-model="dialogForm.name" placeholder="请输入配方名称" clearable />
</el-form-item> </el-form-item>
<el-form-item label="配方类型" prop="recipeType"> <el-form-item label="配方类型" prop="recipeType">
<el-select <el-select
@ -100,22 +100,22 @@ v-model="dialogForm.recipeType" placeholder="请选择配方类型" clearable fi
<el-option v-for="item in recipeTypeOptions" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in recipeTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="关联产品" prop="productId"> <el-form-item label="关联产品" prop="productName">
<el-select <el-select
v-model="dialogForm.productId" placeholder="请选择关联产品" clearable filterable class="!w-full" v-model="dialogForm.productName" placeholder="请选择关联产品" clearable filterable class="!w-full"
:loading="productLoading"> :loading="productLoading">
<el-option v-for="item in productOptions" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in productOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="关联设备" prop="deviceId"> <el-form-item label="关联设备" prop="machineName">
<el-select <el-select
v-model="dialogForm.deviceId" placeholder="请选择关联设备" clearable filterable class="!w-full" v-model="dialogForm.machineName" placeholder="请选择关联设备" clearable filterable class="!w-full"
:loading="deviceLoading"> :loading="deviceLoading">
<el-option v-for="item in deviceOptions" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in deviceOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="配方描述" prop="recipeDesc">
<el-input v-model="dialogForm.remark" placeholder="请输入备注" clearable type="textarea" /> <el-input v-model="dialogForm.recipeDesc" placeholder="请输入配方描述" clearable type="textarea" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
@ -144,7 +144,7 @@ import { DeviceApi } from '@/api/iot/device'
import { RecipeApi } from '@/api/iot/recipe' import { RecipeApi } from '@/api/iot/recipe'
import { RecipeConfigApi, RecipeConfigVO, RecipePointDetailVO } from '@/api/iot/recipeConfig' import { RecipeConfigApi, RecipeConfigVO, RecipePointDetailVO } from '@/api/iot/recipeConfig'
type SelectOption = { label: string; value: number } type SelectOption<T = any> = { label: string; value: T }
defineOptions({ name: 'FormulaConfig' }) defineOptions({ name: 'FormulaConfig' })
@ -156,7 +156,7 @@ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
recipeCode: '', recipeCode: '',
recipeName: '', name: '',
productName: '' productName: ''
}) })
@ -171,13 +171,13 @@ const total = ref(0)
const buildQueryParams = () => { const buildQueryParams = () => {
const recipeCode = queryParams.recipeCode?.trim() const recipeCode = queryParams.recipeCode?.trim()
const recipeName = queryParams.recipeName?.trim() const name = queryParams.name?.trim()
const productName = queryParams.productName?.trim() const productName = queryParams.productName?.trim()
return { return {
pageNo: queryParams.pageNo, pageNo: queryParams.pageNo,
pageSize: queryParams.pageSize, pageSize: queryParams.pageSize,
recipeCode: recipeCode ? recipeCode : undefined, recipeCode: recipeCode ? recipeCode : undefined,
recipeName: recipeName ? recipeName : undefined, name: name ? name : undefined,
productName: productName ? productName : undefined productName: productName ? productName : undefined
} }
} }
@ -228,25 +228,11 @@ const handleDelete = async (row: RecipeConfigVO) => {
} }
const productLoading = ref(false) const productLoading = ref(false)
const productOptions = ref<SelectOption[]>([]) const productOptions = ref<SelectOption<string>[]>([])
const deviceLoading = ref(false) const deviceLoading = ref(false)
const deviceOptions = ref<SelectOption[]>([]) const deviceOptions = ref<SelectOption<string>[]>([])
const recipeTypeLoading = ref(false) const recipeTypeLoading = ref(false)
const recipeTypeOptions = ref<SelectOption[]>([]) const recipeTypeOptions = ref<SelectOption<number>[]>([])
const productLabelMap = computed<Record<number, string>>(() => {
return productOptions.value.reduce((acc, cur) => {
acc[cur.value] = cur.label
return acc
}, {} as Record<number, string>)
})
const deviceLabelMap = computed<Record<number, string>>(() => {
return deviceOptions.value.reduce((acc, cur) => {
acc[cur.value] = cur.label
return acc
}, {} as Record<number, string>)
})
const recipeTypeLabelMap = computed<Record<number, string>>(() => { const recipeTypeLabelMap = computed<Record<number, string>>(() => {
return recipeTypeOptions.value.reduce((acc, cur) => { return recipeTypeOptions.value.reduce((acc, cur) => {
@ -265,7 +251,7 @@ const getProductOptions = async () => {
productLoading.value = true productLoading.value = true
try { try {
const data = await ProductApi.getProductSimpleList() const data = await ProductApi.getProductSimpleList()
productOptions.value = (data ?? []).map((item: any) => ({ label: item.name, value: item.id })) productOptions.value = (data ?? []).map((item: any) => ({ label: item.name, value: item.name }))
} finally { } finally {
productLoading.value = false productLoading.value = false
} }
@ -275,7 +261,7 @@ const getDeviceOptions = async () => {
deviceLoading.value = true deviceLoading.value = true
try { try {
const data = await DeviceApi.getDeviceList() const data = await DeviceApi.getDeviceList()
deviceOptions.value = (data ?? []).map((item: any) => ({ label: item.deviceName, value: item.id })) deviceOptions.value = (data ?? []).map((item: any) => ({ label: item.deviceName, value: item.deviceName }))
} finally { } finally {
deviceLoading.value = false deviceLoading.value = false
} }
@ -309,16 +295,16 @@ const dialogLoading = ref(false)
const dialogForm = reactive({ const dialogForm = reactive({
id: undefined as number | undefined, id: undefined as number | undefined,
recipeCode: '', recipeCode: '',
recipeName: '', name: '',
recipeType: undefined as number | undefined, recipeType: undefined as number | undefined,
productId: undefined as number | undefined, productName: '' as string | undefined,
deviceId: undefined as number | undefined, machineName: '' as string | undefined,
remark: '' recipeDesc: ''
}) })
const dialogRules = reactive({ const dialogRules = reactive({
recipeCode: [{ required: true, message: '配方编码不能为空', trigger: 'blur' }], recipeCode: [{ required: true, message: '配方编码不能为空', trigger: 'blur' }],
recipeName: [{ required: true, message: '配方名称不能为空', trigger: 'blur' }] name: [{ required: true, message: '配方名称不能为空', trigger: 'blur' }]
}) })
const openDialog = async (mode: DialogMode, row?: RecipeConfigVO) => { const openDialog = async (mode: DialogMode, row?: RecipeConfigVO) => {
@ -332,21 +318,21 @@ const openDialog = async (mode: DialogMode, row?: RecipeConfigVO) => {
if (mode === 'create') { if (mode === 'create') {
dialogForm.id = undefined dialogForm.id = undefined
dialogForm.recipeCode = '' dialogForm.recipeCode = ''
dialogForm.recipeName = '' dialogForm.name = ''
dialogForm.recipeType = undefined dialogForm.recipeType = undefined
dialogForm.productId = undefined dialogForm.productName = ''
dialogForm.deviceId = undefined dialogForm.machineName = ''
dialogForm.remark = '' dialogForm.recipeDesc = ''
return return
} }
dialogForm.id = row?.id dialogForm.id = row?.id
dialogForm.recipeCode = row?.recipeCode ?? '' dialogForm.recipeCode = row?.recipeCode ?? ''
dialogForm.recipeName = row?.recipeName ?? '' dialogForm.name = row?.name ?? row?.recipeName ?? ''
dialogForm.recipeType = typeof row?.recipeType === 'number' ? row.recipeType : Number(row?.recipeType) || undefined dialogForm.recipeType = typeof row?.recipeType === 'number' ? row.recipeType : Number(row?.recipeType) || undefined
dialogForm.productId = row?.productId dialogForm.productName = row?.productName ?? ''
dialogForm.deviceId = row?.deviceId dialogForm.machineName = row?.machineName ?? row?.deviceName ?? ''
dialogForm.remark = row?.remark ?? '' dialogForm.recipeDesc = row?.recipeDesc ?? row?.remark ?? ''
} }
const submitDialog = async () => { const submitDialog = async () => {
@ -357,13 +343,11 @@ const submitDialog = async () => {
const data = { const data = {
id: dialogForm.id, id: dialogForm.id,
recipeCode: dialogForm.recipeCode, recipeCode: dialogForm.recipeCode,
recipeName: dialogForm.recipeName, name: dialogForm.name,
recipeType: dialogForm.recipeType, recipeType: dialogForm.recipeType,
productId: dialogForm.productId, productName: dialogForm.productName,
productName: dialogForm.productId ? productLabelMap.value[dialogForm.productId] : undefined, machineName: dialogForm.machineName,
deviceId: dialogForm.deviceId, recipeDesc: dialogForm.recipeDesc
deviceName: dialogForm.deviceId ? deviceLabelMap.value[dialogForm.deviceId] : undefined,
remark: dialogForm.remark
} }
if (dialogMode.value === 'create') { if (dialogMode.value === 'create') {
await RecipeConfigApi.createRecipeConfig(data) await RecipeConfigApi.createRecipeConfig(data)
@ -385,14 +369,14 @@ const detailLoading = ref(false)
const detailList = ref<RecipePointDetailVO[]>([]) const detailList = ref<RecipePointDetailVO[]>([])
const detailTotal = ref(0) const detailTotal = ref(0)
const detailMeta = reactive({ const detailMeta = reactive({
recipeId: undefined as number | undefined, recipeId: undefined as string | undefined,
recipeCode: '', recipeCode: '',
recipeName: '' name: ''
}) })
const detailQueryParams = reactive({ const detailQueryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
recipeId: undefined as number | undefined recipeId: undefined as string | undefined
}) })
const getDetailList = async () => { const getDetailList = async () => {
@ -404,7 +388,13 @@ const getDetailList = async () => {
pageSize: detailQueryParams.pageSize, pageSize: detailQueryParams.pageSize,
recipeId: detailQueryParams.recipeId recipeId: detailQueryParams.recipeId
}) })
detailList.value = data.list detailList.value = (data.list ?? []).map((item: any) => {
return {
...item,
pointName: item.pointName ?? item.attributeName,
pointType: item.pointType ?? item.attributeType
}
})
detailTotal.value = data.total detailTotal.value = data.total
} finally { } finally {
detailLoading.value = false detailLoading.value = false
@ -412,10 +402,10 @@ const getDetailList = async () => {
} }
const openDetail = async (row: RecipeConfigVO) => { const openDetail = async (row: RecipeConfigVO) => {
detailMeta.recipeId = row.id detailMeta.recipeId = row.recipeCode
detailMeta.recipeCode = row.recipeCode detailMeta.recipeCode = row.recipeCode
detailMeta.recipeName = row.recipeName detailMeta.name = row.name ?? row.recipeName ?? ''
detailQueryParams.recipeId = row.id detailQueryParams.recipeId = row.recipeCode
detailQueryParams.pageNo = 1 detailQueryParams.pageNo = 1
detailVisible.value = true detailVisible.value = true
detailActiveTab.value = 'detail' detailActiveTab.value = 'detail'
@ -433,7 +423,7 @@ const closeDetail = () => {
detailActiveTab.value = 'detail' detailActiveTab.value = 'detail'
detailMeta.recipeId = undefined detailMeta.recipeId = undefined
detailMeta.recipeCode = '' detailMeta.recipeCode = ''
detailMeta.recipeName = '' detailMeta.name = ''
detailQueryParams.recipeId = undefined detailQueryParams.recipeId = undefined
detailQueryParams.pageNo = 1 detailQueryParams.pageNo = 1
detailQueryParams.pageSize = 10 detailQueryParams.pageSize = 10
@ -449,25 +439,29 @@ type TransferItem = { key: number; label: string; disabled?: boolean }
const configVisible = ref(false) const configVisible = ref(false)
const configLoading = ref(false) const configLoading = ref(false)
const configRecipeId = ref<number | undefined>(undefined) const configRecipeId = ref<string | undefined>(undefined)
const configCandidates = ref<TransferItem[]>([]) const configCandidates = ref<TransferItem[]>([])
const configSelectedKeys = ref<number[]>([]) const configSelectedKeys = ref<number[]>([])
const openConfigDialog = async (row: RecipeConfigVO) => { const openConfigDialog = async (row: RecipeConfigVO) => {
configVisible.value = true configVisible.value = true
configRecipeId.value = row.id configRecipeId.value = row.recipeCode
configSelectedKeys.value = [] configSelectedKeys.value = []
configCandidates.value = [] configCandidates.value = []
configLoading.value = true configLoading.value = true
try { try {
const [candidateRes, selectedRes] = await Promise.all([ const [candidateRes, selectedRes] = await Promise.all([
RecipeConfigApi.getPointCandidatePage({ pageNo: 1, pageSize: 1000 }), DeviceApi.getDeviceContactModelPage(),
RecipeConfigApi.getRecipePointDetailPage({ pageNo: 1, pageSize: 1000, recipeId: row.id }) RecipeConfigApi.getRecipePointDetailPage({ pageNo: 1, pageSize: 1000, recipeId: row.recipeCode })
]) ])
configCandidates.value = (candidateRes.list ?? []).map((item: any) => ({ const candidateList = Array.isArray(candidateRes)
? candidateRes
: ((candidateRes as any)?.list ?? (candidateRes as any)?.data ?? [])
configCandidates.value = (candidateList ?? []).map((item: any) => ({
key: item.id, key: item.id,
label: `${item.pointName}${item.pointType ? '' + item.pointType : ''}${item.dataType ? '/' + item.dataType : ''}${item.dataUnit ? ' ' + item.dataUnit : ''}${item.pointType ? '' : ''}` label: `${item.attributeName ?? item.pointName ?? ''}${item.attributeType || item.pointType ? '' + (item.attributeType ?? item.pointType) : ''}${item.dataType ? '/' + item.dataType : ''}${item.dataUnit ? ' ' + item.dataUnit : ''}${item.attributeType || item.pointType ? '' : ''}`
})) }))
configSelectedKeys.value = (selectedRes.list ?? []) configSelectedKeys.value = (selectedRes.list ?? [])

Loading…
Cancel
Save