Files
pig-farm-controller-fe/src/views/monitor/PigSickLogsView.vue
2025-11-06 20:55:04 +08:00

97 lines
2.2 KiB
Vue

<template>
<div class="pig-sick-logs-view">
<GenericMonitorList
:fetchData="fetchPigSickLogs"
:columnsConfig="pigSickLogColumns"
/>
</div>
</template>
<script setup>
import GenericMonitorList from '../../components/GenericMonitorList.vue';
import { getPigSickLogs } from '../../api/monitor.js';
import { formatRFC3339 } from '../../utils/format.js';
import { PigBatchSickPigReasonType, PigBatchSickPigTreatmentLocation } from '../../enums.js';
// 适配通用组件的 fetchData prop
const fetchPigSickLogs = async (params) => {
return await getPigSickLogs(params);
};
// 定义表格的列,依据 swagger.json
const pigSickLogColumns = [
{
title: '记录ID',
dataIndex: 'id',
key: 'id',
sorter: true,
minWidth: 100,
},
{
title: '猪批次ID',
dataIndex: 'pig_batch_id',
key: 'pig_batch_id',
filterType: 'number',
sorter: true,
minWidth: 120,
},
{
title: '猪栏ID',
dataIndex: 'pen_id',
key: 'pen_id',
filterType: 'number',
sorter: true,
minWidth: 120,
},
{
title: '原因',
dataIndex: 'reason',
key: 'reason',
filterType: 'select',
filterOptions: Object.values(PigBatchSickPigReasonType).map(value => ({ text: value, value: value })),
minWidth: 120,
},
{
title: '治疗地点',
dataIndex: 'treatment_location',
key: 'treatment_location',
filterType: 'select',
filterOptions: Object.values(PigBatchSickPigTreatmentLocation).map(value => ({ text: value, value: value })),
minWidth: 130,
},
{
title: '变更数量',
dataIndex: 'change_count',
key: 'change_count',
sorter: true,
minWidth: 120,
},
{
title: '发生时间',
dataIndex: 'happened_at',
key: 'happened_at',
sorter: true,
filterType: 'dateRange',
formatter: (row, column, cellValue) => formatRFC3339(cellValue),
minWidth: 180,
},
{
title: '操作员ID',
dataIndex: 'operator_id',
key: 'operator_id',
filterType: 'number',
minWidth: 120,
},
{
title: '备注',
dataIndex: 'remarks',
key: 'remarks',
minWidth: 200,
},
];
</script>
<style scoped>
/* 视图容器样式 */
</style>