优化项目bug
This commit is contained in:
@@ -390,6 +390,7 @@ import { message } from 'ant-design-vue'
|
||||
import { PlusOutlined, SearchOutlined, ExportOutlined, ImportOutlined, DownloadOutlined } from '@ant-design/icons-vue'
|
||||
import { api } from '@/utils/api'
|
||||
import { ExportUtils } from '../utils/exportUtils'
|
||||
import { getSexName, getCategoryName, getSourceTypeName, getStrainName } from '../utils/fieldMappings'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
// 响应式数据
|
||||
@@ -506,11 +507,7 @@ const columns = [
|
||||
key: 'sex',
|
||||
width: 80,
|
||||
customRender: ({ text }) => {
|
||||
const sexMap = {
|
||||
1: '公',
|
||||
2: '母'
|
||||
}
|
||||
return sexMap[text] || '未知'
|
||||
return getSexName(text)
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -519,8 +516,8 @@ const columns = [
|
||||
key: 'strain',
|
||||
width: 120,
|
||||
customRender: ({ text }) => {
|
||||
const user = cattleUsers.value.find(u => u.id === text)
|
||||
return user ? user.name : text || '-'
|
||||
// 后端已经返回格式化好的名称,直接显示
|
||||
return text || '-'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -529,26 +526,27 @@ const columns = [
|
||||
key: 'varieties',
|
||||
width: 120,
|
||||
customRender: ({ text }) => {
|
||||
const type = cattleTypes.value.find(t => t.id === text)
|
||||
return type ? type.name : text || '-'
|
||||
}
|
||||
return text || '-'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '类别',
|
||||
{
|
||||
title: '类别',
|
||||
dataIndex: 'cate', // 映射iot_cattle.cate
|
||||
key: 'cate',
|
||||
width: 100,
|
||||
key: 'cate',
|
||||
width: 100,
|
||||
customRender: ({ text }) => {
|
||||
const cateMap = {
|
||||
1: '犊牛',
|
||||
2: '育成母牛',
|
||||
3: '架子牛',
|
||||
4: '青年牛',
|
||||
5: '基础母牛',
|
||||
6: '育肥牛'
|
||||
// 添加调试日志查看实际的cate值
|
||||
console.log('类别值:', text, '类型:', typeof text)
|
||||
// 如果是数字类型,使用映射函数;如果是字符串但不为空,直接显示;否则显示未知
|
||||
if (typeof text === 'number' || !isNaN(parseInt(text))) {
|
||||
const categoryName = getCategoryName(typeof text === 'number' ? text : parseInt(text))
|
||||
// 如果映射结果为'未知'且有原始值,显示原始值
|
||||
return categoryName === '未知' && text ? `未定义(${text})` : categoryName
|
||||
} else if (text && text !== '') {
|
||||
return text
|
||||
}
|
||||
return cateMap[text] || text || '-'
|
||||
}
|
||||
return '未知'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '出生体重(kg)',
|
||||
@@ -587,7 +585,7 @@ const fetchAnimals = async (page = 1, pageSize = 10) => {
|
||||
try {
|
||||
loading.value = true
|
||||
const token = localStorage.getItem('token')
|
||||
const response = await api.get('/iot-cattle', {
|
||||
const response = await api.get('/iot-cattle/public', {
|
||||
params: { page, pageSize }
|
||||
})
|
||||
|
||||
@@ -1101,7 +1099,7 @@ const searchAnimals = async () => {
|
||||
|
||||
console.log('发送搜索请求,参数:', params)
|
||||
|
||||
const response = await api.get('/iot-cattle', {
|
||||
const response = await api.get('/iot-cattle/public', {
|
||||
params: params
|
||||
})
|
||||
|
||||
@@ -1158,7 +1156,7 @@ const exportAnimals = async () => {
|
||||
message.loading('正在获取所有动物数据...', 0)
|
||||
|
||||
// 获取所有动物数据,不受分页限制
|
||||
const response = await api.get('/iot-cattle', {
|
||||
const response = await api.get('/iot-cattle/public', {
|
||||
params: {
|
||||
page: 1,
|
||||
pageSize: 1000 // 获取大量数据
|
||||
|
||||
@@ -392,6 +392,19 @@ const tableData = ref([
|
||||
}
|
||||
])
|
||||
|
||||
// 类别映射函数(与后端保持一致)
|
||||
const getCategoryName = (cate) => {
|
||||
const categoryMap = {
|
||||
1: '犊牛',
|
||||
2: '育成母牛',
|
||||
3: '架子牛',
|
||||
4: '青年牛',
|
||||
5: '基础母牛',
|
||||
6: '育肥牛'
|
||||
};
|
||||
return categoryMap[cate] || '未知';
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = [
|
||||
{
|
||||
@@ -423,7 +436,10 @@ const columns = [
|
||||
title: '品类',
|
||||
dataIndex: 'category',
|
||||
key: 'category',
|
||||
width: 100
|
||||
width: 100,
|
||||
customRender: ({ text }) => {
|
||||
return getCategoryName(text)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '品种',
|
||||
|
||||
@@ -83,9 +83,6 @@
|
||||
<a-button type="link" size="small" @click="handleViewCattle(record)">
|
||||
查看牛只
|
||||
</a-button>
|
||||
<a-button type="link" size="small" @click="handleAddCattle(record)">
|
||||
添加牛只
|
||||
</a-button>
|
||||
<a-button type="link" size="small" danger @click="handleDelete(record)">
|
||||
删除
|
||||
</a-button>
|
||||
@@ -235,7 +232,15 @@
|
||||
<a-table
|
||||
:columns="cattleColumns"
|
||||
:data-source="currentBatchCattle"
|
||||
:pagination="{ pageSize: 10 }"
|
||||
:pagination="{
|
||||
current: cattlePagination.current,
|
||||
pageSize: cattlePagination.pageSize,
|
||||
total: cattlePagination.total,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total, range) => `第 ${range[0]}-${range[1]} 条,共 ${total} 条`
|
||||
}"
|
||||
@change="handleCattleTableChange"
|
||||
size="small"
|
||||
/>
|
||||
</a-modal>
|
||||
@@ -305,6 +310,12 @@ const tableData = ref([])
|
||||
|
||||
// 当前批次的牛只数据
|
||||
const currentBatchCattle = ref([])
|
||||
const currentBatchId = ref(null)
|
||||
const cattlePagination = ref({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
})
|
||||
|
||||
// 可添加的牛只数据
|
||||
const availableCattle = ref([
|
||||
@@ -759,20 +770,65 @@ const handleExport = async () => {
|
||||
|
||||
const handleViewCattle = async (record) => {
|
||||
try {
|
||||
const response = await api.cattleBatches.getAnimals(record.id)
|
||||
if (response.success) {
|
||||
currentBatchCattle.value = response.data.list.map(item => ({
|
||||
...item.animal,
|
||||
key: item.id
|
||||
}))
|
||||
cattleModalVisible.value = true
|
||||
}
|
||||
console.log('🔍 开始获取批次牛只数据');
|
||||
console.log('📋 批次信息:', {
|
||||
id: record.id,
|
||||
name: record.name,
|
||||
currentCount: record.currentCount
|
||||
});
|
||||
|
||||
currentBatchId.value = record.id
|
||||
cattlePagination.value.current = 1
|
||||
cattlePagination.value.total = 0
|
||||
|
||||
await loadBatchCattle(record.id, 1, 10)
|
||||
cattleModalVisible.value = true
|
||||
} catch (error) {
|
||||
console.error('获取批次牛只失败:', error)
|
||||
message.error('获取批次牛只失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 加载批次牛只数据
|
||||
const loadBatchCattle = async (batchId, page = 1, pageSize = 10) => {
|
||||
try {
|
||||
console.log(`🔍 加载批次${batchId}第${page}页数据,每页${pageSize}条`);
|
||||
|
||||
const response = await api.cattleBatches.getAnimals(batchId, { page, pageSize })
|
||||
console.log('✅ API响应:', response);
|
||||
|
||||
if (response.success) {
|
||||
console.log(`🐄 获取到的牛只数量: ${response.data.list.length}`);
|
||||
console.log(`📊 总记录数: ${response.data.total}`);
|
||||
|
||||
currentBatchCattle.value = response.data.list.map(item => ({
|
||||
...item,
|
||||
key: item.id
|
||||
}))
|
||||
|
||||
// 更新分页信息
|
||||
cattlePagination.value = {
|
||||
current: response.data.page,
|
||||
pageSize: response.data.pageSize,
|
||||
total: response.data.total
|
||||
}
|
||||
|
||||
console.log('📊 更新后的分页信息:', cattlePagination.value);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载批次牛只失败:', error)
|
||||
message.error('加载批次牛只失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 处理牛只表格分页变化
|
||||
const handleCattleTableChange = (pagination) => {
|
||||
console.log('🔄 牛只表格分页变化:', pagination);
|
||||
if (currentBatchId.value) {
|
||||
loadBatchCattle(currentBatchId.value, pagination.current, pagination.pageSize)
|
||||
}
|
||||
}
|
||||
|
||||
const handleAddCattle = (record) => {
|
||||
addCattleModalVisible.value = true
|
||||
selectedCattleKeys.value = []
|
||||
|
||||
@@ -51,10 +51,7 @@
|
||||
</a-space>
|
||||
</template>
|
||||
</a-input>
|
||||
<!-- 搜索提示 -->
|
||||
<!-- <div v-if="searchValue && searchValue.trim()" class="search-hint">
|
||||
💡 按回车键或点击搜索图标进行搜索
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -68,6 +65,7 @@
|
||||
allowClear
|
||||
style="width: 100%"
|
||||
@change="handleFilterChange"
|
||||
@select="(value, option) => handleFilterSelect(value, option, 'exitReason')"
|
||||
>
|
||||
<a-select-option value="出售">出售</a-select-option>
|
||||
<a-select-option value="死亡">死亡</a-select-option>
|
||||
@@ -83,19 +81,20 @@
|
||||
allowClear
|
||||
style="width: 100%"
|
||||
@change="handleFilterChange"
|
||||
@select="(value, option) => handleFilterSelect(value, option, 'status')"
|
||||
>
|
||||
<a-select-option value="已确认">已确认</a-select-option>
|
||||
<a-select-option value="待确认">待确认</a-select-option>
|
||||
<a-select-option value="已取消">已取消</a-select-option>
|
||||
</a-select>
|
||||
</a-col>
|
||||
<a-col :span="6">
|
||||
<!-- <a-col :span="6">
|
||||
<a-range-picker
|
||||
v-model="filters.dateRange"
|
||||
style="width: 100%"
|
||||
@change="handleFilterChange"
|
||||
/>
|
||||
</a-col>
|
||||
</a-col> -->
|
||||
<a-col :span="6">
|
||||
<a-button @click="handleResetFilters">重置筛选</a-button>
|
||||
</a-col>
|
||||
@@ -861,7 +860,41 @@ const handleResetSearch = () => {
|
||||
message.success('搜索已重置');
|
||||
}
|
||||
|
||||
const handleFilterSelect = (value, option, filterType) => {
|
||||
console.group('🎯 [离栏记录] 筛选选择事件');
|
||||
console.log('🕒 选择时间:', new Date().toLocaleString());
|
||||
console.log('📝 选择的值:', value);
|
||||
console.log('📋 选择的选项:', option);
|
||||
console.log('🏷️ 筛选类型:', filterType);
|
||||
console.log('🏠 选择前filters.exitReason:', filters.exitReason);
|
||||
console.log('🏠 选择前filters.status:', filters.status);
|
||||
|
||||
// 手动更新filters对象
|
||||
if (filterType === 'exitReason') {
|
||||
filters.exitReason = value;
|
||||
console.log('✅ 手动设置filters.exitReason为:', value);
|
||||
} else if (filterType === 'status') {
|
||||
filters.status = value;
|
||||
console.log('✅ 手动设置filters.status为:', value);
|
||||
}
|
||||
|
||||
console.log('🏠 选择后filters.exitReason:', filters.exitReason);
|
||||
console.log('🏠 选择后filters.status:', filters.status);
|
||||
console.groupEnd();
|
||||
|
||||
// 触发筛选条件变化
|
||||
handleFilterChange();
|
||||
}
|
||||
|
||||
const handleFilterChange = () => {
|
||||
console.group('🔄 [离栏记录] 筛选条件变化');
|
||||
console.log('🕒 变化时间:', new Date().toLocaleString());
|
||||
console.log('🏠 离栏原因:', filters.exitReason);
|
||||
console.log('🏠 记录状态:', filters.status);
|
||||
console.log('📅 日期范围:', filters.dateRange);
|
||||
console.log('📊 完整filters对象:', JSON.stringify(filters, null, 2));
|
||||
console.groupEnd();
|
||||
|
||||
pagination.current = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
@@ -203,7 +203,15 @@
|
||||
<a-table
|
||||
:columns="animalColumns"
|
||||
:data-source="currentPenAnimals"
|
||||
:pagination="{ pageSize: 5 }"
|
||||
:pagination="{
|
||||
current: animalsPagination.current,
|
||||
pageSize: animalsPagination.pageSize,
|
||||
total: animalsPagination.total,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total, range) => `第 ${range[0]}-${range[1]} 条,共 ${total} 条`
|
||||
}"
|
||||
@change="handleAnimalsTableChange"
|
||||
size="small"
|
||||
/>
|
||||
</a-modal>
|
||||
@@ -222,6 +230,7 @@ import {
|
||||
import { ExportUtils } from '../utils/exportUtils'
|
||||
import { api } from '../utils/api'
|
||||
import dayjs from 'dayjs'
|
||||
import { getBreedName } from '../utils/fieldMappings'
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false)
|
||||
@@ -237,6 +246,12 @@ const tableData = ref([])
|
||||
|
||||
// 当前栏舍的牛只数据
|
||||
const currentPenAnimals = ref([])
|
||||
const currentPenId = ref(null)
|
||||
const animalsPagination = ref({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
})
|
||||
|
||||
// 表格列配置
|
||||
const columns = [
|
||||
@@ -499,20 +514,66 @@ const handleBatchDelete = () => {
|
||||
|
||||
const handleViewAnimals = async (record) => {
|
||||
try {
|
||||
const response = await api.cattlePens.getAnimals(record.id)
|
||||
if (response.success) {
|
||||
currentPenAnimals.value = response.data.list.map(item => ({
|
||||
...item,
|
||||
key: item.id
|
||||
}))
|
||||
animalsModalVisible.value = true
|
||||
}
|
||||
console.log('🚀 开始获取栏舍牛只数据');
|
||||
console.log('📋 栏舍信息:', {
|
||||
id: record.id,
|
||||
name: record.name,
|
||||
currentAnimalCount: record.currentAnimalCount
|
||||
});
|
||||
|
||||
currentPenId.value = record.id
|
||||
animalsPagination.value.current = 1
|
||||
animalsPagination.value.total = 0
|
||||
|
||||
await loadPenAnimals(record.id, 1, 10)
|
||||
animalsModalVisible.value = true
|
||||
} catch (error) {
|
||||
console.error('获取栏舍牛只失败:', error)
|
||||
message.error('获取栏舍牛只失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 加载栏舍牛只数据
|
||||
const loadPenAnimals = async (penId, page = 1, pageSize = 10) => {
|
||||
try {
|
||||
console.log(`🔍 加载栏舍${penId}第${page}页数据,每页${pageSize}条`);
|
||||
|
||||
const response = await api.cattlePens.getAnimals(penId, { page, pageSize })
|
||||
console.log('✅ API响应:', response);
|
||||
|
||||
if (response.success) {
|
||||
console.log(`🐄 获取到的牛只数量: ${response.data.list.length}`);
|
||||
console.log(`📊 总记录数: ${response.data.total}`);
|
||||
|
||||
currentPenAnimals.value = response.data.list.map(item => ({
|
||||
...item,
|
||||
key: item.id,
|
||||
breed: getBreedName(item.varieties || item.breed || '')
|
||||
}))
|
||||
|
||||
// 更新分页信息
|
||||
animalsPagination.value = {
|
||||
current: response.data.page,
|
||||
pageSize: response.data.pageSize,
|
||||
total: response.data.total
|
||||
}
|
||||
|
||||
console.log('📊 更新后的分页信息:', animalsPagination.value);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载栏舍牛只失败:', error)
|
||||
message.error('加载栏舍牛只失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 处理牛只表格分页变化
|
||||
const handleAnimalsTableChange = (pagination) => {
|
||||
console.log('🔄 牛只表格分页变化:', pagination);
|
||||
if (currentPenId.value) {
|
||||
loadPenAnimals(currentPenId.value, pagination.current, pagination.pageSize)
|
||||
}
|
||||
}
|
||||
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
console.log('=== 开始导出栏舍数据 ===')
|
||||
|
||||
@@ -31,19 +31,24 @@
|
||||
<!-- 搜索区域 -->
|
||||
<div class="search-container">
|
||||
<div class="search-input-group">
|
||||
<a-input
|
||||
v-model="searchValue"
|
||||
placeholder="请输入耳号搜索"
|
||||
class="search-input"
|
||||
@pressEnter="handleSearch"
|
||||
@input="handleInputChange"
|
||||
@focus="handleSearchFocus"
|
||||
@blur="handleSearchBlur"
|
||||
>
|
||||
<template #suffix>
|
||||
<SearchOutlined @click="handleSearch" style="cursor: pointer;" />
|
||||
</template>
|
||||
</a-input>
|
||||
<div style="position: relative; flex: 1;">
|
||||
<input
|
||||
ref="searchInputRef"
|
||||
v-model="searchValue"
|
||||
placeholder="请输入耳号搜索"
|
||||
class="search-input"
|
||||
@keyup.enter="handleSearch"
|
||||
@input="handleInputChange"
|
||||
@change="handleInputChange"
|
||||
@focus="handleSearchFocus"
|
||||
@blur="handleSearchBlur"
|
||||
style="width: 100%; height: 40px; padding: 8px 40px 8px 12px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 14px; outline: none;"
|
||||
/>
|
||||
<SearchOutlined
|
||||
@click="handleSearch"
|
||||
style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); cursor: pointer; color: #999;"
|
||||
/>
|
||||
</div>
|
||||
<a-button
|
||||
class="search-reset-btn"
|
||||
@click="handleResetSearch"
|
||||
@@ -54,10 +59,7 @@
|
||||
重置
|
||||
</a-button>
|
||||
</div>
|
||||
<!-- 搜索提示 -->
|
||||
<!-- <div v-if="searchValue && searchValue.trim()" class="search-hint">
|
||||
💡 按回车键或点击搜索图标进行搜索
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -71,10 +73,15 @@
|
||||
allowClear
|
||||
style="width: 100%"
|
||||
@change="handleFilterChange"
|
||||
@select="(value, option) => handlePenSelect(value, option, 'fromPen')"
|
||||
>
|
||||
<a-select-option value="杭嘉新村栏舍01">杭嘉新村栏舍01</a-select-option>
|
||||
<a-select-option value="杭嘉新村栏舍02">杭嘉新村栏舍02</a-select-option>
|
||||
<a-select-option value="杭嘉新村栏舍03">杭嘉新村栏舍03</a-select-option>
|
||||
<a-select-option
|
||||
v-for="pen in penList"
|
||||
:key="pen.id"
|
||||
:value="pen.name"
|
||||
>
|
||||
{{ pen.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-col>
|
||||
<a-col :span="6">
|
||||
@@ -84,19 +91,24 @@
|
||||
allowClear
|
||||
style="width: 100%"
|
||||
@change="handleFilterChange"
|
||||
@select="(value, option) => handlePenSelect(value, option, 'toPen')"
|
||||
>
|
||||
<a-select-option value="杭嘉新村栏舍01">杭嘉新村栏舍01</a-select-option>
|
||||
<a-select-option value="杭嘉新村栏舍02">杭嘉新村栏舍02</a-select-option>
|
||||
<a-select-option value="杭嘉新村栏舍03">杭嘉新村栏舍03</a-select-option>
|
||||
<a-select-option
|
||||
v-for="pen in penList"
|
||||
:key="pen.id"
|
||||
:value="pen.name"
|
||||
>
|
||||
{{ pen.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-col>
|
||||
<a-col :span="6">
|
||||
<!-- <a-col :span="6">
|
||||
<a-range-picker
|
||||
v-model="filters.dateRange"
|
||||
style="width: 100%"
|
||||
@change="handleFilterChange"
|
||||
/>
|
||||
</a-col>
|
||||
</a-col> -->
|
||||
<a-col :span="6">
|
||||
<a-button @click="handleResetFilters">重置筛选</a-button>
|
||||
</a-col>
|
||||
@@ -299,6 +311,7 @@ const modalVisible = ref(false)
|
||||
const detailsModalVisible = ref(false)
|
||||
const modalTitle = ref('新增转栏记录')
|
||||
const formRef = ref()
|
||||
const searchInputRef = ref()
|
||||
const selectedRowKeys = ref([])
|
||||
|
||||
// 筛选条件
|
||||
@@ -445,12 +458,16 @@ const formRules = {
|
||||
const loadData = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
// 将栏舍名称转换为栏舍ID
|
||||
const fromPenId = filters.fromPen ? penList.value.find(pen => pen.name === filters.fromPen)?.id : null;
|
||||
const toPenId = filters.toPen ? penList.value.find(pen => pen.name === filters.toPen)?.id : null;
|
||||
|
||||
const params = {
|
||||
page: pagination.current,
|
||||
pageSize: pagination.pageSize,
|
||||
search: searchValue.value,
|
||||
fromPen: filters.fromPen,
|
||||
toPen: filters.toPen,
|
||||
fromPen: fromPenId,
|
||||
toPen: toPenId,
|
||||
dateRange: filters.dateRange
|
||||
};
|
||||
|
||||
@@ -458,6 +475,12 @@ const loadData = async () => {
|
||||
console.group('📡 [转栏记录] API请求详情');
|
||||
console.log('🕒 请求时间:', new Date().toISOString());
|
||||
console.log('🔍 搜索参数:', searchValue.value);
|
||||
console.log('🏠 栏舍筛选转换:', {
|
||||
转出栏舍名称: filters.fromPen,
|
||||
转出栏舍ID: fromPenId,
|
||||
转入栏舍名称: filters.toPen,
|
||||
转入栏舍ID: toPenId
|
||||
});
|
||||
console.log('📋 完整请求参数:', JSON.stringify(params, null, 2));
|
||||
console.log('🔗 请求路径:', '/api/cattle-transfer-records');
|
||||
console.log('🔄 请求方法:', 'GET');
|
||||
@@ -516,12 +539,25 @@ const loadData = async () => {
|
||||
|
||||
const loadPenList = async () => {
|
||||
try {
|
||||
const response = await api.cattlePens.getList({ page: 1, pageSize: 1000 })
|
||||
console.log('🔍 开始加载栏舍列表...')
|
||||
const response = await api.get('/cattle-pens/public', {
|
||||
params: { page: 1, pageSize: 1000 }
|
||||
})
|
||||
console.log('✅ 栏舍列表API响应:', response)
|
||||
|
||||
if (response.success) {
|
||||
penList.value = response.data.list
|
||||
penList.value = response.data.list || []
|
||||
console.log(`📊 加载到 ${penList.value.length} 个栏舍`)
|
||||
if (penList.value.length > 0) {
|
||||
console.log('📋 栏舍列表示例:', penList.value.slice(0, 3))
|
||||
}
|
||||
} else {
|
||||
console.error('❌ 加载栏舍列表失败:', response.message)
|
||||
message.error('加载栏舍列表失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载栏舍列表失败:', error)
|
||||
console.error('❌ 加载栏舍列表异常:', error)
|
||||
message.error('加载栏舍列表失败')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -698,6 +734,13 @@ const handleSearch = () => {
|
||||
// 获取当前用户信息
|
||||
const userInfo = JSON.parse(localStorage.getItem('user') || '{}');
|
||||
|
||||
// 强制从DOM获取最新值
|
||||
const domValue = searchInputRef.value?.inputValue || searchInputRef.value?.value || '';
|
||||
if (domValue && domValue !== searchValue.value) {
|
||||
searchValue.value = domValue;
|
||||
console.log('🔄 [转栏记录] 从DOM同步搜索值:', domValue);
|
||||
}
|
||||
|
||||
// 使用nextTick确保获取到最新的搜索值
|
||||
nextTick(() => {
|
||||
// 获取当前搜索值,确保获取到最新的值
|
||||
@@ -768,7 +811,41 @@ const handleSearch = () => {
|
||||
});
|
||||
}
|
||||
|
||||
const handlePenSelect = (value, option, penType) => {
|
||||
console.group('🎯 [转栏记录] 栏舍选择事件');
|
||||
console.log('🕒 选择时间:', new Date().toLocaleString());
|
||||
console.log('📝 选择的值:', value);
|
||||
console.log('📋 选择的选项:', option);
|
||||
console.log('🏠 栏舍类型:', penType);
|
||||
console.log('🏠 选择前filters.fromPen:', filters.fromPen);
|
||||
console.log('🏠 选择前filters.toPen:', filters.toPen);
|
||||
|
||||
// 手动更新filters对象
|
||||
if (penType === 'fromPen') {
|
||||
filters.fromPen = value;
|
||||
console.log('✅ 手动设置filters.fromPen为:', value);
|
||||
} else if (penType === 'toPen') {
|
||||
filters.toPen = value;
|
||||
console.log('✅ 手动设置filters.toPen为:', value);
|
||||
}
|
||||
|
||||
console.log('🏠 选择后filters.fromPen:', filters.fromPen);
|
||||
console.log('🏠 选择后filters.toPen:', filters.toPen);
|
||||
console.groupEnd();
|
||||
|
||||
// 触发筛选条件变化
|
||||
handleFilterChange();
|
||||
}
|
||||
|
||||
const handleFilterChange = () => {
|
||||
console.group('🔄 [转栏记录] 筛选条件变化');
|
||||
console.log('🕒 变化时间:', new Date().toLocaleString());
|
||||
console.log('🏠 转出栏舍:', filters.fromPen);
|
||||
console.log('🏠 转入栏舍:', filters.toPen);
|
||||
console.log('📅 日期范围:', filters.dateRange);
|
||||
console.log('📊 完整filters对象:', JSON.stringify(filters, null, 2));
|
||||
console.groupEnd();
|
||||
|
||||
pagination.current = 1
|
||||
loadData()
|
||||
}
|
||||
@@ -846,24 +923,12 @@ const handleModalCancel = () => {
|
||||
// 防抖计时器
|
||||
let inputDebounceTimer = null;
|
||||
|
||||
// 手动处理输入变化
|
||||
// 处理输入变化
|
||||
const handleInputChange = (e) => {
|
||||
const value = e.target.value;
|
||||
console.group('⌨️ [转栏记录] 手动输入处理');
|
||||
console.log('🕒 时间:', new Date().toLocaleString());
|
||||
console.log('📝 输入值:', value);
|
||||
console.log('📏 输入长度:', value.length);
|
||||
console.log('🔍 当前searchValue:', searchValue.value);
|
||||
console.log('🔍 值是否相等:', value === searchValue.value);
|
||||
console.groupEnd();
|
||||
|
||||
// 手动更新searchValue
|
||||
searchValue.value = value;
|
||||
|
||||
// 如果输入框有值,显示搜索提示
|
||||
if (value && value.trim()) {
|
||||
console.log('💡 [转栏记录] 搜索提示: 按回车键或点击搜索图标进行搜索');
|
||||
}
|
||||
console.log('⌨️ [转栏记录] 原生input输入变化:', value);
|
||||
console.log('🔍 [转栏记录] 当前searchValue:', searchValue.value);
|
||||
console.log('✅ [转栏记录] v-model应该自动更新searchValue');
|
||||
};
|
||||
|
||||
// 搜索框焦点事件
|
||||
@@ -937,13 +1002,20 @@ watch(searchValue, (newValue, oldValue) => {
|
||||
console.log('📏 旧值长度:', oldValue ? oldValue.length : 0);
|
||||
console.log('🔄 变化类型:', (newValue?.length || 0) > (oldValue?.length || 0) ? '新增字符' : (newValue?.length || 0) < (oldValue?.length || 0) ? '删除字符' : '无变化');
|
||||
console.log('🔍 值是否相等:', newValue === oldValue);
|
||||
console.log('🎯 搜索框状态:', {
|
||||
hasValue: !!newValue,
|
||||
isEmpty: !newValue || newValue.trim() === '',
|
||||
isWhitespace: newValue && newValue.trim() === ''
|
||||
});
|
||||
console.groupEnd();
|
||||
|
||||
// 如果输入框有值,显示搜索提示
|
||||
if (newValue && newValue.trim()) {
|
||||
console.log('💡 [转栏记录] 搜索提示: 按回车键或点击搜索图标进行搜索');
|
||||
} else {
|
||||
console.log('📭 [转栏记录] 搜索框为空');
|
||||
}
|
||||
}, { immediate: false });
|
||||
}, { immediate: true });
|
||||
|
||||
// 生命周期
|
||||
onMounted(() => {
|
||||
|
||||
@@ -693,7 +693,7 @@ const handleSearch = async () => {
|
||||
console.log('🔄 [搜索监听] 发送搜索请求到后端:', searchKeywordValue)
|
||||
loading.value = true
|
||||
|
||||
const searchUrl = `/farms/search?name=${encodeURIComponent(searchKeywordValue.trim())}`
|
||||
const searchUrl = `/api/farms/search?name=${encodeURIComponent(searchKeywordValue.trim())}`
|
||||
console.log('🌐 [搜索监听] 请求URL:', searchUrl)
|
||||
|
||||
// 获取认证token
|
||||
|
||||
@@ -336,6 +336,7 @@ import { message } from 'ant-design-vue'
|
||||
import { EnvironmentOutlined, SearchOutlined, ExportOutlined } from '@ant-design/icons-vue'
|
||||
import { api, directApi } from '../utils/api'
|
||||
import { ExportUtils } from '../utils/exportUtils'
|
||||
import { formatBindingInfo } from '../utils/fieldMappings'
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false)
|
||||
@@ -854,17 +855,14 @@ const showBindingInfo = async (record) => {
|
||||
// 获取绑定信息
|
||||
const getBindInfo = async (eartagNumber) => {
|
||||
try {
|
||||
const response = await api.get(`/animals/binding-info/${eartagNumber}`)
|
||||
const result = await api.get(`/animals/binding-info/${eartagNumber}`)
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status === 404) {
|
||||
throw new Error('该耳标未绑定动物,暂无绑定信息')
|
||||
}
|
||||
throw new Error(`HTTP error! status: ${response.status}`)
|
||||
}
|
||||
|
||||
const result = await response.json()
|
||||
if (result.success) {
|
||||
// 如果后端返回的数据没有basicInfo,则使用前端的formatBindingInfo函数进行格式化
|
||||
if (result.data && result.data.cattle && !result.data.basicInfo) {
|
||||
return formatBindingInfo(result.data.cattle, result.data.device)
|
||||
}
|
||||
// 后端已经返回格式化好的数据,直接使用
|
||||
return result.data
|
||||
} else {
|
||||
if (result.message && result.message.includes('未找到')) {
|
||||
|
||||
Reference in New Issue
Block a user