feat:配方库-读取弹框
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>
|
||||
Loading…
Reference in New Issue