Files
pig-farm-controller-fe/src/views/monitor/MedicationLogsView.vue
2025-10-20 16:31:16 +08:00

95 lines
2.0 KiB
Vue

<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>