Explorar el Código

Add添加鸡舍报表组件

Yue hace 3 semanas
padre
commit
3c233c6fcd

+ 262 - 0
UI/VB.VUE/src/components/reports/ChickenCoopReport.vue

@@ -0,0 +1,262 @@
+<script setup lang="ts">
+const props = withDefaults(
+	defineProps<{
+		title: string
+		data?: any[] | (() => any[])
+		totalData?: any | (() => any)
+		reportGenDate?: string
+		reportType?: "COOP" | "EGG"
+		reportDateType?: "D" | "M" | "Q" | "Y"
+	}>(),
+	{
+		reportType: "COOP",
+		reportDateType: "D"
+	}
+)
+const emits = defineEmits<{ (e: "update:modelValue", v: string): void }>()
+const dateTypeStr = computed(() => {
+	if (props.reportDateType === "D") {
+		return "日"
+	} else if (props.reportDateType === "M") {
+		return "月"
+	} else if (props.reportDateType === "Q") {
+		return "季"
+	} else if (props.reportDateType === "Y") {
+		return "年"
+	}
+})
+const showEggReport = computed(() => {
+	return props.reportType === "EGG"
+})
+const reportData = computed(() => {
+	if (!props.data) {
+		return []
+	}
+	if (typeof props.data === "function") {
+		return props.data()
+	}
+	return props.data
+})
+const totalData = computed(() => {
+	if (!props.totalData) {
+		return null
+	}
+	if (typeof props.totalData === "function") {
+		return props.totalData()
+	}
+	return props.totalData
+})
+
+function init() {
+	//
+}
+
+onMounted(init)
+</script>
+<template>
+	<div class="report-container">
+		<table class="table table-bordered report-table">
+			<thead>
+				<tr>
+					<th class="report-title" colspan="30">
+						<span class="report-title-text">
+							{{ title }}
+						</span>
+						<span v-if="reportGenDate" class="report-gen-date">生成时间:{{ reportGenDate }}</span>
+					</th>
+				</tr>
+				<tr>
+					<th class="s-1 w-100px" rowspan="2">鸡舍</th>
+					<th class="s-1 w-150px" rowspan="2">品种</th>
+					<th class="s-3 w-50px" rowspan="2">
+						<div v-if="reportDateType != 'D'">{{ dateTypeStr }}末</div>
+						<div>日龄</div>
+					</th>
+					<th class="s-1" colspan="2">上{{ dateTypeStr }}存栏</th>
+					<th class="s-2" colspan="2">本{{ dateTypeStr }}转入</th>
+					<th class="s-1" colspan="2">本{{ dateTypeStr }}淘汰</th>
+					<th class="s-2" colspan="2">本{{ dateTypeStr }}转出</th>
+					<th class="s-1" colspan="2">本{{ dateTypeStr }}存栏</th>
+					<template v-if="showEggReport">
+						<th class="s-2 w-80px" rowspan="2">合格蛋</th>
+						<th class="s-1 w-80px" rowspan="2">畸形蛋</th>
+						<th class="s-2 w-80px" rowspan="2">破蛋</th>
+						<th class="s-1 w-80px" rowspan="2">种蛋合格率</th>
+						<th class="s-1 w-80px" rowspan="2">产蛋率</th>
+					</template>
+					<th class="s-2 w-80px" rowspan="2">成活率</th>
+					<!-- <th class="s-2 w-150px" rowspan="2">备注</th> -->
+				</tr>
+				<tr>
+					<th class="s-1 s-g">♂</th>
+					<th class="s-1 s-g">♀</th>
+					<th class="s-2 s-g">♂</th>
+					<th class="s-2 s-g">♀</th>
+					<th class="s-1 s-g">♂</th>
+					<th class="s-1 s-g">♀</th>
+					<th class="s-2 s-g">♂</th>
+					<th class="s-2 s-g">♀</th>
+					<th class="s-1 s-g">♂</th>
+					<th class="s-1 s-g">♀</th>
+				</tr>
+			</thead>
+			<tbody>
+				<template v-for="(data, index) in reportData" :key="index">
+					<tr v-for="(item, index2) in data.data" :key="index2">
+						<td v-if="index2 === 0" class="s-1 s-js" :rowspan="data.data.length">
+							{{ data.coopName }}
+						</td>
+						<td class="s-1 s-pc">{{ item.batchName }}</td>
+						<td class="s-3">{{ item.dayAge }}</td>
+						<td class="s-1">{{ item.last_save_0 }}</td>
+						<td class="s-1">{{ item.last_save_1 }}</td>
+						<td class="s-2">{{ item.in_0 }}</td>
+						<td class="s-2">{{ item.in_1 }}</td>
+						<td class="s-1">{{ item.cull_0 }}</td>
+						<td class="s-1">{{ item.cull_1 }}</td>
+						<td class="s-2">{{ item.out_0 }}</td>
+						<td class="s-2">{{ item.out_1 }}</td>
+						<td class="s-1">{{ item.save_0 }}</td>
+						<td class="s-1">{{ item.save_1 }}</td>
+						<template v-if="showEggReport">
+							<td class="s-2">{{ item.qualified_egg }}</td>
+							<td class="s-1">{{ item.deformed_egg }}</td>
+							<td class="s-2">{{ item.break_egg }}</td>
+							<td class="s-1">{{ item.egg_pass_rate }}</td>
+							<td class="s-1">{{ item.egg_production_rate }}</td>
+						</template>
+						<td class="s-1">{{ item.life_rate }}</td>
+						<!-- <td class="s-1">{{ item.remark }}</td> -->
+					</tr>
+					<tr>
+						<td class="s-4" colspan="3">合计</td>
+						<td class="s-4">{{ data.total.last_save_0 }}</td>
+						<td class="s-4">{{ data.total.last_save_1 }}</td>
+						<td class="s-4">{{ data.total.in_0 }}</td>
+						<td class="s-4">{{ data.total.in_1 }}</td>
+						<td class="s-4">{{ data.total.cull_0 }}</td>
+						<td class="s-4">{{ data.total.cull_1 }}</td>
+						<td class="s-4">{{ data.total.out_0 }}</td>
+						<td class="s-4">{{ data.total.out_1 }}</td>
+						<td class="s-4">{{ data.total.save_0 }}</td>
+						<td class="s-4">{{ data.total.save_1 }}</td>
+						<template v-if="showEggReport">
+							<td class="s-4">{{ data.total.qualified_egg }}</td>
+							<td class="s-4">{{ data.total.deformed_egg }}</td>
+							<td class="s-4">{{ data.total.break_egg }}</td>
+							<td class="s-4">{{ data.total.egg_pass_rate }}</td>
+							<td class="s-4">{{ data.total.egg_production_rate }}</td>
+						</template>
+						<td class="s-4">{{ data.total.life_rate }}</td>
+						<!-- <td class="s-4">{{ data.total.remark }}</td> -->
+					</tr>
+				</template>
+				<tr class="h-30px">
+					<td colspan="30"></td>
+				</tr>
+				<tr class="total-row">
+					<td colspan="3">总合计</td>
+					<td>{{ totalData.last_save_0 }}</td>
+					<td>{{ totalData.last_save_1 }}</td>
+					<td>{{ totalData.in_0 }}</td>
+					<td>{{ totalData.in_1 }}</td>
+					<td>{{ totalData.cull_0 }}</td>
+					<td>{{ totalData.cull_1 }}</td>
+					<td>{{ totalData.out_0 }}</td>
+					<td>{{ totalData.out_1 }}</td>
+					<td>{{ totalData.save_0 }}</td>
+					<td>{{ totalData.save_1 }}</td>
+					<template v-if="showEggReport">
+						<td>{{ totalData.qualified_egg }}</td>
+						<td>{{ totalData.deformed_egg }}</td>
+						<td>{{ totalData.break_egg }}</td>
+						<td>{{ totalData.egg_pass_rate }}</td>
+						<td>{{ totalData.egg_production_rate }}</td>
+					</template>
+					<td>{{ totalData.life_rate }}</td>
+					<!-- <td>{{ totalData.remark }}</td> -->
+				</tr>
+			</tbody>
+		</table>
+	</div>
+</template>
+
+<style scoped lang="scss">
+.report-container {
+	width: 100%;
+	overflow: auto;
+	padding: 10px;
+	margin: 0;
+	box-sizing: border-box;
+	.report-title {
+		text-align: center;
+		position: relative;
+		padding: 0;
+		.report-title-text {
+			font-size: 18px;
+			font-weight: bold;
+			line-height: 40px;
+		}
+		.report-gen-date {
+			position: absolute;
+			bottom: 1px;
+			right: 15px;
+			font-size: 12px;
+		}
+	}
+}
+.report-table {
+	width: auto;
+	margin: 0 auto;
+
+	tr {
+		border-color: #3c3c3c;
+	}
+	th,
+	td {
+		text-align: center;
+		vertical-align: middle;
+		padding: 5px 0;
+		font-size: 12px;
+	}
+
+	thead {
+		tr {
+			th {
+				font-size: 16px;
+				font-weight: bold;
+				vertical-align: middle;
+			}
+		}
+	}
+
+	th {
+		width: 50px;
+	}
+	.s-js,
+	.s-pc {
+		font-weight: bold;
+	}
+	.s-1 {
+		background: #92d050;
+	}
+	.s-2 {
+		background: #ffff00;
+	}
+	.s-3 {
+		background: #ed7d31;
+	}
+	.s-4 {
+		background: #5b9bd5;
+		font-weight: bold;
+	}
+	.s-g {
+		font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
+	}
+	.total-row td {
+		font-weight: bold;
+		font-size: 14px;
+		background: #ffff00;
+	}
+}
+</style>

+ 8 - 0
UI/VB.VUE/src/router/_staticRouter.ts

@@ -10,6 +10,14 @@ export const staticRouter: RouteRecordRaw[] = [
 				meta: {
 					title: "ICON"
 				}
+			},
+			{
+				path: "/r",
+				name: "report",
+				component: () => import("@/views/report/chicken.vue"),
+				meta: {
+					title: "ICON"
+				}
 			}
 		]
 	},

+ 1 - 1
UI/VB.VUE/src/router/index.ts

@@ -8,7 +8,7 @@ import { isReLogin } from "@@/services/RequestService"
 import message from "@@/utils/message"
 import { staticRouter } from "./_staticRouter"
 
-const whiteList = ["/login", "/register", "/icon"]
+const whiteList = ["/login", "/register", "/icon", "/r"]
 
 export const to404: RouteRecordRaw = {
 	path: "/:pathMatch(.*)*",

+ 214 - 0
UI/VB.VUE/src/views/report/chicken.vue

@@ -0,0 +1,214 @@
+<script setup lang="ts">
+import ChickenCoopReport from "@@@/reports/ChickenCoopReport.vue"
+
+const data = ref([
+	{
+		coopName: "鸡舍1",
+		data: [
+			{
+				batchName: "批次1",
+				dayAge: 30,
+				last_save_0: 34,
+				last_save_1: 34,
+				save_0: 34,
+				save_1: 34,
+				cull_0: 12,
+				cull_1: 3,
+				in_0: 43,
+				in_1: 5,
+				out_0: 2,
+				out_1: 7,
+				qualified_egg: 90,
+				deformed_egg: 3,
+				break_egg: 2,
+				egg_production_rate: "45.12%",
+				egg_pass_rate: "42.12%",
+				cull_rate: "43.12%",
+				life_rate: "45.22%",
+				remark: "1"
+			},
+			{
+				batchName: "批次2",
+				dayAge: 30,
+				last_save_0: 34,
+				last_save_1: 34,
+				save_0: 34,
+				save_1: 34,
+				cull_0: 4,
+				cull_1: 6,
+				in_0: 7,
+				in_1: 7,
+				out_0: 7,
+				out_1: 7,
+				qualified_egg: 90,
+				deformed_egg: 3,
+				break_egg: 2,
+				egg_production_rate: 0.45,
+				egg_pass_rate: 0.9,
+				cull_rate: 0.1,
+				life_rate: 0.9,
+				remark: "2"
+			},
+			{
+				batchName: "批次3",
+				dayAge: 30,
+				last_save_0: 34,
+				last_save_1: 34,
+				save_0: 34,
+				save_1: 34,
+				cull_0: 4,
+				cull_1: 6,
+				in_0: 7,
+				in_1: 7,
+				out_0: 7,
+				out_1: 7,
+				qualified_egg: 90,
+				deformed_egg: 3,
+				break_egg: 2,
+				egg_production_rate: 0.45,
+				egg_pass_rate: 0.9,
+				cull_rate: 0.1,
+				life_rate: 0.9,
+				remark: "333"
+			}
+		],
+		total: {
+			last_save_0: 34,
+			last_save_1: 34,
+			save_0: 34,
+			save_1: 34,
+			cull_0: 4,
+			cull_1: 6,
+			in_0: 7,
+			in_1: 7,
+			out_0: 7,
+			out_1: 7,
+			qualified_egg: 90,
+			deformed_egg: 3,
+			break_egg: 2,
+			egg_production_rate: 0.45,
+			egg_pass_rate: 0.9,
+			cull_rate: 0.1,
+			life_rate: 0.9
+		}
+	},
+	{
+		coopName: "鸡舍2",
+		data: [
+			{
+				batchName: "批次1",
+				dayAge: 30,
+				last_save_0: 34,
+				last_save_1: 34,
+				save_0: 34,
+				save_1: 34,
+				cull_0: 4,
+				cull_1: 6,
+				in_0: 7,
+				in_1: 7,
+				out_0: 7,
+				out_1: 7,
+				qualified_egg: 90,
+				deformed_egg: 3,
+				break_egg: 2,
+				egg_production_rate: 0.45,
+				egg_pass_rate: 0.9,
+				cull_rate: 0.1,
+				life_rate: 0.9
+			},
+			{
+				batchName: "批次2",
+				dayAge: 30,
+				last_save_0: 34000,
+				last_save_1: 343420,
+				save_0: 34,
+				save_1: 34,
+				cull_0: 4,
+				cull_1: 6,
+				in_0: 7,
+				in_1: 7,
+				out_0: 7,
+				out_1: 7,
+				qualified_egg: 90,
+				deformed_egg: 3,
+				break_egg: 2,
+				egg_production_rate: 0.45,
+				egg_pass_rate: 0.9,
+				cull_rate: 0.1,
+				life_rate: 0.9
+			},
+			{
+				batchName: "批次3",
+				dayAge: 30,
+				last_save_0: 34,
+				last_save_1: 34,
+				save_0: 34,
+				save_1: 34,
+				cull_0: 4,
+				cull_1: 6,
+				in_0: 7,
+				in_1: 7,
+				out_0: 7,
+				out_1: 7,
+				qualified_egg: 90,
+				deformed_egg: 3,
+				break_egg: 2,
+				egg_production_rate: 0.45,
+				egg_pass_rate: 0.9,
+				cull_rate: 0.1,
+				life_rate: 0.9
+			}
+		],
+		total: {
+			last_save_0: 34,
+			last_save_1: 34,
+			save_0: 34,
+			save_1: 34,
+			cull_0: 4,
+			cull_1: 6,
+			in_0: 7,
+			in_1: 7,
+			out_0: 7,
+			out_1: 7,
+			qualified_egg: 90,
+			deformed_egg: 3,
+			break_egg: 2,
+			egg_production_rate: 0.45,
+			egg_pass_rate: 0.9,
+			cull_rate: 0.1,
+			life_rate: 0.9
+		}
+	}
+])
+const totalData = ref({
+	last_save_0: 34,
+	last_save_1: 34,
+	save_0: 34,
+	save_1: 34,
+	cull_0: 4,
+	cull_1: 6,
+	in_0: 7,
+	in_1: 7,
+	out_0: 7,
+	out_1: 7,
+	qualified_egg: 90,
+	deformed_egg: 3,
+	break_egg: 2,
+	egg_production_rate: 0.45,
+	egg_pass_rate: 0.9,
+	cull_rate: 0.1,
+	life_rate: 0.9
+})
+</script>
+
+<template>
+	<div>
+		<ChickenCoopReport
+			title="2025年5月份 弥勒育种场(育成舍) 月报表"
+			report-gen-date="2025-08-14 12:39:34"
+			report-type="EGG"
+			report-date-type="M"
+			:data="data"
+			:total-data="totalData"></ChickenCoopReport>
+	</div>
+</template>