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", "@vueuse/core": "10.11.0",
"axios": "0.28.1", "axios": "0.28.1",
"clipboard": "2.0.11", "clipboard": "2.0.11",
"date-fns": "^4.1.0",
"echarts": "5.5.1", "echarts": "5.5.1",
"element-plus": "^2.7.6", "element-plus": "^2.7.6",
"file-saver": "2.0.5", "file-saver": "2.0.5",

View File

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

View File

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