实现所有监控展示
This commit is contained in:
94
src/views/monitor/MedicationLogsView.vue
Normal file
94
src/views/monitor/MedicationLogsView.vue
Normal file
@@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<div class="medication-logs-view">
|
||||
<GenericMonitorList
|
||||
:fetchData="fetchMedicationLogs"
|
||||
:columnsConfig="medicationLogColumns"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import GenericMonitorList from '../../components/GenericMonitorList.vue';
|
||||
import { getMedicationLogs } from '../../api/monitor.js';
|
||||
import { formatRFC3339 } from '../../utils/format.js';
|
||||
|
||||
// 适配通用组件的 fetchData prop
|
||||
const fetchMedicationLogs = async (params) => {
|
||||
return await getMedicationLogs(params);
|
||||
};
|
||||
|
||||
// 定义表格的列,依据 swagger.json
|
||||
const medicationLogColumns = [
|
||||
{
|
||||
title: '记录ID',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
sorter: true,
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
title: '药品名称',
|
||||
dataIndex: ['medication', 'name'], // 嵌套属性
|
||||
key: 'medication_name',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
title: '用量',
|
||||
dataIndex: 'dosage_used',
|
||||
key: 'dosage_used',
|
||||
sorter: true,
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
title: '目标数量',
|
||||
dataIndex: 'target_count',
|
||||
key: 'target_count',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
title: '原因',
|
||||
dataIndex: 'reason',
|
||||
key: 'reason',
|
||||
filterType: 'select',
|
||||
filterOptions: [
|
||||
{ text: '预防', value: '预防' },
|
||||
{ text: '治疗', value: '治疗' },
|
||||
{ text: '保健', value: '保健' },
|
||||
],
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: '发生时间',
|
||||
dataIndex: 'happened_at',
|
||||
key: 'happened_at',
|
||||
sorter: true,
|
||||
filterType: 'dateRange',
|
||||
formatter: (row, column, cellValue) => formatRFC3339(cellValue),
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
title: '猪批次ID',
|
||||
dataIndex: 'pig_batch_id',
|
||||
key: 'pig_batch_id',
|
||||
filterType: 'number',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: '操作员ID',
|
||||
dataIndex: 'operator_id',
|
||||
key: 'operator_id',
|
||||
filterType: 'number',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
title: '描述',
|
||||
dataIndex: 'description',
|
||||
key: 'description',
|
||||
minWidth: 200,
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 视图容器样式 */
|
||||
</style>
|
||||
Reference in New Issue
Block a user