Compare commits

...

2 Commits

Author SHA1 Message Date
ll
a10983b719 Merge branch 'main' of http://e19510c831.iok.la/admin/zhyc-sheep-ui 2025-08-13 18:59:37 +08:00
ll
8b110b3169 奶产量分析 2025-08-13 18:59:24 +08:00
3 changed files with 68 additions and 84 deletions

View File

@ -21,6 +21,7 @@
"@vueuse/core": "10.11.0",
"axios": "0.28.1",
"clipboard": "2.0.11",
"date-fns": "^4.1.0",
"echarts": "5.5.1",
"element-plus": "^2.7.6",
"file-saver": "2.0.5",

View File

@ -1,44 +1,29 @@
// src/api/dairyProducts/sheepMilkAnalysis/sheepMilkAnalysis.js
import request from '@/utils/request'
// 查询羊奶出入库列表
export function listMilkInOutStore(query) {
// 查询羊奶产量分析列表(分页 + 条件)
export function listSheepMilkAnalysis(query) {
return request({
url: '/milkInOutStore/milkInOutStore/list',
url: '/dairyProducts/sheepMilkAnalysis/list',
method: 'get',
params: query
})
}
// 查询羊奶出入库详细
export function getMilkInOutStore(id) {
// 查询单个羊奶产量分析详细信息
export function getSheepMilkAnalysis(sheepId) {
return request({
url: '/milkInOutStore/milkInOutStore/' + id,
url: '/dairyProducts/sheepMilkAnalysis/' + sheepId,
method: 'get'
})
}
// 新增羊奶出入库
export function addMilkInOutStore(data) {
// 导出羊奶产量分析 Excel
export function exportSheepMilkAnalysis(query) {
return request({
url: '/milkInOutStore/milkInOutStore',
method: 'post',
data: data
})
}
// 修改羊奶出入库
export function updateMilkInOutStore(data) {
return request({
url: '/milkInOutStore/milkInOutStore',
method: 'put',
data: data
})
}
// 删除羊奶出入库
export function delMilkInOutStore(id) {
return request({
url: '/milkInOutStore/milkInOutStore/' + id,
method: 'delete'
url: '/dairyProducts/sheepMilkAnalysis/export',
method: 'get',
params: query,
responseType: 'blob' // 返回二进制流
})
}

View File

@ -6,7 +6,7 @@
<el-input v-model="queryParams.manageEarTag" placeholder="请输入耳号" />
</el-form-item>
<el-form-item label="筛选天数">
<el-input-number v-model="queryParams.screenDays" :min="0" placeholder="请输入天数" />
<el-input-number v-model="queryParams.screenDays" :min="1" placeholder="请输入天数" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">查询</el-button>
@ -18,34 +18,25 @@
<div class="button-group">
<el-button type="success" @click="handleExport">导出</el-button>
<el-popover
placement="bottom"
width="400"
trigger="click"
>
<el-checkbox-group v-model="selectedFields" class="checkbox-columns">
<el-checkbox
v-for="col in allColumns"
:key="col.prop"
:label="col.prop"
>{{ col.label }}</el-checkbox>
</el-checkbox-group>
<template #reference>
<el-button type="info">展示列</el-button>
</template>
</el-popover>
<el-popover placement="bottom" width="400" trigger="click">
<el-checkbox-group v-model="selectedFields" class="checkbox-columns">
<el-checkbox v-for="col in allColumns" :key="col.prop" :label="col.prop">{{ col.label }}</el-checkbox>
</el-checkbox-group>
<template #reference>
<el-button type="info">展示列</el-button>
</template>
</el-popover>
</div>
<!-- 数据表格 -->
<el-table :data="list" border style="width: 100%" v-loading="loading" :row-key="row => row.id">
<el-table :data="list" border style="width: 100%" v-loading="loading" :row-key="row => row.sheepId">
<el-table-column
v-for="col in visibleColumns"
:key="col.prop"
:label="col.label"
:prop="col.prop"
:min-width="col.minWidth || 120"
:formatter="col.formatter || undefined"
/>
</el-table>
@ -65,6 +56,7 @@
<script>
import { listSheepMilkAnalysis, exportSheepMilkAnalysis } from "@/api/dairyProducts/sheepMilkAnalysis/sheepMilkAnalysis.js";
import { format } from 'date-fns';
export default {
name: "SheepMilkAnalysis",
@ -77,47 +69,47 @@ export default {
pageNum: 1,
pageSize: 10,
manageEarTag: null,
screenDays: null
screenDays: 100 //
},
selectedFields: [],
allColumns: [
{ label: "耳号", prop: "manageEarTag" },
{ label: "品种", prop: "variety" },
{ label: "挤奶时间", prop: "milkingDate" },
{ label: "干奶时间", prop: "dryDate" },
{ label: "筛选天数", prop: "screeningDays" },
{ label: "挤奶开始时间", prop: "milkingStartTime", formatter: row => row.milkingStartTime ? format(new Date(row.milkingStartTime),'yyyy-MM-dd') : '' },
{ label: "干奶时间", prop: "dryEndTime", formatter: row => row.dryEndTime ? format(new Date(row.dryEndTime),'yyyy-MM-dd') : '' },
{ label: "筛选天数", prop: "screenDays" },
{ label: "挤奶天数", prop: "milkingDays" },
{ label: "校正后最大胎次", prop: "maxCorrectedParity" },
{ label: "系统奶量之合计", prop: "systemMilkTotal" },
{ label: "校正奶量之合计", prop: "correctedMilkTotal" },
{ label: "校正日平均奶量", prop: "avgDailyCorrectedMilk" },
{ label: "胎次1的总奶量", prop: "parity1TotalMilk" },
{ label: "胎次2的总奶量", prop: "parity2TotalMilk" },
{ label: "胎次3的总奶量", prop: "parity3TotalMilk" },
{ label: "胎次4的总奶量", prop: "parity4TotalMilk" },
{ label: "胎次1的日平均产量", prop: "parity1AvgDailyMilk" },
{ label: "胎次2的日平均产量", prop: "parity2AvgDailyMilk" },
{ label: "胎次3的日平均产量", prop: "parity3AvgDailyMilk" },
{ label: "胎次4的日平均产量", prop: "parity4AvgDailyMilk" },
{ label: "校正后最大胎次", prop: "maxParity" },
{ label: "系统奶量之合计", prop: "sumSystemMilk" },
{ label: "校正奶量之合计", prop: "sumCorrectedMilk" },
{ label: "校正日平均奶量", prop: "avgCorrectedDaily" },
{ label: "胎次1的总奶量", prop: "sumParity1Milk" },
{ label: "胎次2的总奶量", prop: "sumParity2Milk" },
{ label: "胎次3的总奶量", prop: "sumParity3Milk" },
{ label: "胎次4的总奶量", prop: "sumParity4Milk" },
{ label: "胎次1日平均", prop: "avgParity1Daily" },
{ label: "胎次2日平均", prop: "avgParity2Daily" },
{ label: "胎次3日平均", prop: "avgParity3Daily" },
{ label: "胎次4日平均", prop: "avgParity4Daily" },
{ label: "泌乳天数", prop: "lactationDays" },
{ label: "过去7日日平均奶量", prop: "past7DaysAvgMilk" },
{ label: "校正过去7日日平均奶量", prop: "past7DaysAvgCorrectedMilk" },
{ label: "过去14日日平均奶量", prop: "past14DaysAvgMilk" },
{ label: "过去30日日平均奶量", prop: "past30DaysAvgMilk" },
{ label: "羊只类型", prop: "sheepType" },
{ label: "生日", prop: "birthDate" },
{ label: "当前胎次", prop: "currentParity" },
{ label: "月龄", prop: "ageMonths" },
{ label: "过去7日均奶量", prop: "avgLast7Milk" },
{ label: "校正过去7日均", prop: "avgLast7Corrected" },
{ label: "过去14日均奶量", prop: "avgLast14Milk" },
{ label: "过去30日均奶量", prop: "avgLast30Milk" },
{ label: "羊只类别", prop: "sheepCategory" },
{ label: "生日", prop: "birthday", formatter: row => row.birthday ? format(new Date(row.birthday),'yyyy-MM-dd') : '' },
{ label: "当前胎次", prop: "parity" },
{ label: "月龄", prop: "monthAge" },
{ label: "当前体重", prop: "currentWeight" },
{ label: "繁育状态", prop: "breedStatus" },
{ label: "父号", prop: "fatherTag" },
{ label: "母号", prop: "motherTag" },
{ label: "牧场名称", prop: "ranchName" },
{ label: "家系", prop: "familyLine" },
{ label: "父号", prop: "fatherManageTags" },
{ label: "母号", prop: "motherManageTags" },
{ label: "牧场", prop: "ranchName" },
{ label: "家系", prop: "family" },
{ label: "母亲挤奶天数", prop: "motherMilkingDays" },
{ label: "母亲校正奶量之合计", prop: "motherCorrectedMilkTotal" },
{ label: "母亲校正后最大胎次", prop: "motherMaxCorrectedParity" },
{ label: "母亲校正日平均奶量", prop: "motherAvgDailyCorrectedMilk" }
{ label: "母亲校正奶量之合计", prop: "motherSumCorrected" },
{ label: "母亲校正后最大胎次", prop: "motherMaxParity" },
{ label: "母亲校正日平均奶量", prop: "motherAvgCorrectedDaily" }
]
};
},
@ -134,10 +126,12 @@ export default {
getList() {
this.loading = true;
listSheepMilkAnalysis(this.queryParams).then(response => {
this.list = response.rows;
this.total = response.total;
// axios wrapper { data: { rows, total } }, { rows, total }
const res = response && response.data ? response.data : response;
this.list = res.rows || res;
this.total = res.total || (Array.isArray(this.list) ? this.list.length : 0);
this.loading = false;
});
}).catch(()=>{ this.loading = false; });
},
handleQuery() {
this.queryParams.pageNum = 1;
@ -148,7 +142,7 @@ export default {
pageNum: 1,
pageSize: 10,
manageEarTag: null,
screenDays: null
screenDays: 100
};
this.selectedFields = this.allColumns.map(c => c.prop);
this.getList();
@ -163,7 +157,8 @@ export default {
},
handleExport() {
exportSheepMilkAnalysis(this.queryParams).then(response => {
const blob = new Blob([response], { type: 'application/vnd.ms-excel' });
const data = response && response.data ? response.data : response;
const blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
@ -171,6 +166,9 @@ export default {
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
}).catch(err => {
this.$message.error('导出失败,请检查后端是否正确返回文件流');
});
}
}