feat:配方库-读取弹框

main
黄伟杰 4 weeks ago
parent 355c121814
commit 4192858e83

@ -0,0 +1,38 @@
import request from '@/config/axios'
export interface RecipePlanDetailVO {
id?: number
code?: string
name?: string
recipeId?: number | string
recipeName?: string
planId?: number | string
planCode?: string
creator?: string
createTime?: string
source?: string
isEnable?: string | number | boolean
}
export const RecipePlanDetailApi = {
getRecipePlanDetailPage: async (params: any) => {
return await request.get({ url: `/iot/recipe-plan-detail/page`, params })
},
createRecipePlanDetail: async (data: Partial<RecipePlanDetailVO>) => {
return await request.post({ url: `/iot/recipe-plan-detail/create`, data })
},
updateRecipePlanDetail: async (data: Partial<RecipePlanDetailVO>) => {
return await request.put({ url: `/iot/recipe-plan-detail/update`, data })
},
deleteRecipePlanDetail: async (id: number) => {
return await request.delete({ url: `/iot/recipe-plan-detail/delete?id=` + id })
},
exportRecipePlanDetail: async (params: any) => {
return await request.download({ url: `/iot/recipe-plan-detail/export-excel`, params })
}
}

@ -1,31 +1,21 @@
import request from '@/config/axios'
export interface RecipePointVO {
id: number
recipeId: string | number
id?: number
recipeId?: number | string
name?: string
max?: string | number
min?: string | number
dataType?: string
refer?: string
dataUnit?: string
remark?: string
max?: string
min?: string
dataType?: string
createTime?: string
}
export const RecipePointApi = {
getRecipePointPage: async (params: any) => {
return await request.get({ url: `/iot/recipe-point/page`, params })
},
createRecipePoint: async (params: Partial<RecipePointVO>) => {
return await request.post({ url: `/iot/recipe-point/create`, data: params })
},
updateRecipePoint: async (params: Partial<RecipePointVO>) => {
return await request.put({ url: `/iot/recipe-point/update`, data: params })
},
deleteRecipePoint: async (id: number) => {
return await request.delete({ url: `/iot/recipe-point/delete`, params: { id } })
}
}

@ -0,0 +1,117 @@
<template>
<Dialog v-model="visible" :title="title" width="920px">
<div class="formula-library-read-content">
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" row-key="id">
<el-table-column type="index" label="序号" align="center" width="70" />
<el-table-column label="名称" align="center" prop="name" min-width="160" />
<el-table-column label="参考值" align="center" prop="refer" min-width="160" />
<el-table-column label="单位" align="center" prop="dataUnit" width="140" />
<el-table-column label="备注" align="center" prop="remark" min-width="180" />
<el-table-column label="采集值" align="center" min-width="160" fixed="right">
<template #default="scope">
<el-input v-model="collectedValueMap[String(scope.row.id)]" placeholder="请输入采集值" clearable />
</template>
</el-table-column>
</el-table>
<el-pagination
v-show="total > 0"
class="mt-15px flex justify-end"
v-model:current-page="queryParams.pageNo"
v-model:page-size="queryParams.pageSize"
:background="true"
:page-sizes="[10, 20, 30, 50, 100]"
:pager-count="7"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
<template #footer>
<el-button @click="visible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { RecipePointApi, RecipePointVO } from '@/api/iot/recipePoint'
defineOptions({ name: 'FormulaLibraryReadDialog' })
type PageResult<T> = { list: T[]; total: number }
const visible = ref(false)
const title = ref('读取')
const loading = ref(false)
const recipeId = ref<string | number | undefined>(undefined)
const list = ref<RecipePointVO[]>([])
const total = ref(0)
const queryParams = reactive({
pageNo: 1,
pageSize: 10
})
const collectedValueMap = reactive<Record<string, string>>({})
const setPageData = (data: PageResult<RecipePointVO>) => {
list.value = data.list ?? []
total.value = data.total ?? 0
for (const row of list.value) {
const key = String(row.id ?? '')
if (!key) continue
if (collectedValueMap[key] === undefined) collectedValueMap[key] = ''
}
}
const getList = async () => {
if (!recipeId.value) return
loading.value = true
try {
const data = await RecipePointApi.getRecipePointPage({
pageNo: queryParams.pageNo,
pageSize: queryParams.pageSize,
recipeId: String(recipeId.value)
})
setPageData(data)
} finally {
loading.value = false
}
}
const handleSizeChange = () => {
queryParams.pageNo = 1
getList()
}
const handleCurrentChange = () => {
getList()
}
const open = async (options: {
recipeId: string | number
recipeName?: string
initialData?: PageResult<RecipePointVO>
}) => {
recipeId.value = options.recipeId
title.value = options.recipeName ? `读取-${options.recipeName}` : '读取'
queryParams.pageNo = 1
visible.value = true
if (options.initialData) {
setPageData(options.initialData)
return
}
await getList()
}
defineExpose({ open })
</script>
<style scoped>
.formula-library-read-content {
padding-bottom: 12px;
}
</style>

@ -111,6 +111,7 @@
</el-table-column>
<el-table-column label="操作" align="center" width="180" fixed="right">
<template #default="scope">
<el-button link type="primary" @click.stop="handleRead(scope.row)">读取</el-button>
<el-button link type="primary" @click.stop="openDialog('update', scope.row)">编辑</el-button>
<el-button link type="danger" @click.stop="handleDelete(scope.row)">删除</el-button>
</template>
@ -129,6 +130,8 @@
<FormulaLibraryDetailTabs :recipe-id="detailRecipeId" />
</ContentWrap>
<FormulaLibraryReadDialog ref="readDialogRef" />
<Dialog :title="dialogTitle" v-model="dialogVisible" width="720px">
<el-form ref="dialogFormRef" :model="dialogForm" :rules="dialogRules" label-width="100px" v-loading="dialogLoading">
<el-form-item label="编码" prop="code">
@ -165,8 +168,10 @@ import download from '@/utils/download'
import { dateFormatter } from '@/utils/formatTime'
import { RecipePlanDetailApi, RecipePlanDetailVO } from '@/api/iot/recipePlanDetail'
import { RecipeConfigApi } from '@/api/iot/recipeConfig'
import { RecipePointApi } from '@/api/iot/recipePoint'
import { PlanApi } from '@/api/mes/plan'
import FormulaLibraryDetailTabs from './components/FormulaLibraryDetailTabs.vue'
import FormulaLibraryReadDialog from './components/FormulaLibraryReadDialog.vue'
type SelectOption<T = any> = { label: string; value: T }
@ -341,6 +346,17 @@ const openDialog = async (type: 'create' | 'update', row?: RecipePlanDetailVO) =
}
}
const readDialogRef = ref<InstanceType<typeof FormulaLibraryReadDialog>>()
const handleRead = async (row: RecipePlanDetailVO) => {
const recipeId = row?.recipeId
if (!recipeId) return
const recipeName = row?.recipeName
const data = await RecipePointApi.getRecipePointPage({ pageNo: 1, pageSize: 10, recipeId: String(recipeId) })
if (!data?.list?.length) return
await readDialogRef.value?.open({ recipeId, recipeName, initialData: data })
}
const submitDialog = async () => {
await dialogFormRef.value.validate()
dialogLoading.value = true

Loading…
Cancel
Save