From 67d0fab0c684a911eb1c802d3063624d0e6ac02b Mon Sep 17 00:00:00 2001
From: tanghaolin <1723298894@qq.com>
Date: 星期三, 02 四月 2025 11:21:30 +0800
Subject: [PATCH] 修改能效计算表单校验

---
 src/views/GB19762-2025.vue |  864 +++++++++++++++++++++++++++++++++------------------------
 1 files changed, 502 insertions(+), 362 deletions(-)

diff --git a/src/views/GB19762-2025.vue b/src/views/GB19762-2025.vue
index 97d3dd0..9f2b82c 100644
--- a/src/views/GB19762-2025.vue
+++ b/src/views/GB19762-2025.vue
@@ -1,98 +1,118 @@
 <template>
-    <!-- <div class="detail-container">{{ Math.pow(Math.log(60), 2) }}
+	<!-- <div class="detail-container">{{ Math.pow(Math.log(60), 2) }}
     </div> -->
-    <div class="container mx-auto px-4 py-8 bg-white industrial-soft-style" style="margin-top: 20px; padding-top: 15px">
-        <div class="w-100 h-100" style="background-color: #fff">
-            <div class="mb-6 text-gray-500">
+	<div class="container mx-auto px-4 py-8 bg-white industrial-soft-style" style="margin-top: 20px; padding-top: 15px">
+		<div class="w-100 h-100" style="background-color: #fff">
+			<div class="mb-6 text-gray-500">
 				<el-breadcrumb separator="/">
 					<el-breadcrumb-item :to="{ path: '/' }">棣栭〉</el-breadcrumb-item>
 					<el-breadcrumb-item>鑳芥晥绛夌骇璁$畻</el-breadcrumb-item>
 				</el-breadcrumb>
 			</div>
-            <!-- 椤堕儴鍒嗙被鑿滃崟 -->
-            <div class="rounded-lg shadow" style="background-color: #f6f7f9; margin-bottom: 10px">
-                <div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
-                    <div class="flex items-center">
-                        <span class="text-gray-500">绂诲績娉电被鍨嬶細</span>
-                        <div class="flex flex-1 flex-wrap">
-                            <span v-for="item in pumptype" class="ant-tag !px-2"
-                                :class="pumpSelect === item.id ? 'ant-tag-checked' : ''" :key="item.id"
-                                @click="changeSelectPumpType(item.id)"
-                                :type="pumpSelect === item.id ? 'primary' : 'default'" size="small">
-                                {{ item.name }}
-                            </span>
-                        </div>
-                    </div>
-                </div>
-                <div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
-                    <div class="flex items-center">
-                        <span class="text-gray-500">姘存车绫诲瀷锛�</span>
-                        <div class="flex flex-1 flex-wrap">
-                            <span v-for="item in type.filter((c) => { return c.pumpid == pumpSelect })"
-                                class="ant-tag !px-2" :class="typeSelect === item.tag ? 'ant-tag-checked' : ''"
-                                :key="item.tag" @click="changeSelectType(item.tag)"
-                                :type="typeSelect === item.tag ? 'primary' : 'default'" size="small">
-                                {{ item.name }}
-                            </span>
-                        </div>
-                    </div>
-                </div>
-                <div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
-                    <div class="flex items-center">
-                        <span class="text-gray-500">鏈�楂樻晥鐜囩偣娴侀噺(m鲁/h)锛�</span>
-                        <div class="flex flex-1">
-                            <el-input v-model="MaxFlow" placeholder="璇疯緭鍏ユ渶楂樻晥鐜囩偣娴侀噺" class="!w-[300px]" clearable>
-                            </el-input>
-                        </div>
-                    </div>
-                </div>
-                <div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
-                    <div class="flex items-center">
-                        <span class="text-gray-500">鏈�楂樻晥鐜囩偣鎵▼(m)锛�</span>
-                        <div class="flex flex-1">
-                            <el-input v-model="MaxHead" placeholder="璇疯緭鍏ユ渶楂樻晥鐜囩偣鎵▼" class="!w-[300px]" clearable>
-                            </el-input>
-                        </div>
-                    </div>
-                </div>
-                <div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
-                    <div class="flex items-center">
-                        <span class="text-gray-500">姘存车杞��(r/min)锛�</span>
-                        <div class="flex flex-1">
-                            <el-input v-model="Speed" placeholder="璇疯緭鍏ユ按娉佃浆閫�" class="!w-[300px]" clearable>
-                            </el-input>
-                        </div>
-                    </div>
-                </div>
-                <div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
-                    <div class="flex items-center">
-                        <span class="text-gray-500" style="color:blue">姘存车鏁堢巼(%)锛�</span>
-                        <div class="flex flex-1">
-                            <el-input v-model="Efficiency" placeholder="璇疯緭鍏ユ晥鐜�" class="!w-[300px]" clearable>
-                            </el-input>
-                        </div>
-                    </div>
-                </div>
-                <div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
-                    <div class="flex items-center">
-                        <el-button type="primary" @click="Calc">璁$畻</el-button>
-                        <el-button @click="clear" type="info">娓呯┖</el-button>
-                        <span style="margin-left: 85px;">鍙傝�冨浗鏍囨枃浠讹細</span>
-                        <span style="color:dodgerblue;cursor: pointer;font-weight: bold;">
-                            <a :href="`${SERVE_URL}files/pdf/GB19762-2025.pdf`" target="_blank">
-                                绂诲績娉佃兘鏁堥檺瀹氬�煎強鑳芥晥绛夌骇 GB+19762-2025</a>
-                        </span>
-                    </div>
-                </div>
-            </div>
+			<!-- 椤堕儴鍒嗙被鑿滃崟 -->
+			<div class="rounded-lg shadow" style="background-color: #f6f7f9; margin-bottom: 10px">
+				<div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
+					<div class="flex items-center">
+						<span class="text-gray-500">绂诲績娉电被鍨嬶細</span>
+						<div class="flex flex-1 flex-wrap">
+							<span
+								v-for="item in pumptype"
+								class="ant-tag !px-2"
+								:class="pumpSelect === item.id ? 'ant-tag-checked' : ''"
+								:key="item.id"
+								@click="changeSelectPumpType(item.id)"
+								:type="pumpSelect === item.id ? 'primary' : 'default'"
+								size="small"
+							>
+								{{ item.name }}
+							</span>
+						</div>
+					</div>
+				</div>
+				<div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
+					<div class="flex items-center">
+						<span class="text-gray-500">姘存车绫诲瀷锛�</span>
+						<div class="flex flex-1 flex-wrap">
+							<span
+								v-for="item in type.filter((c) => {
+									return c.pumpid == pumpSelect;
+								})"
+								class="ant-tag !px-2"
+								:class="typeSelect === item.tag ? 'ant-tag-checked' : ''"
+								:key="item.tag"
+								@click="changeSelectType(item.tag)"
+								:type="typeSelect === item.tag ? 'primary' : 'default'"
+								size="small"
+							>
+								{{ item.name }}
+							</span>
+						</div>
+					</div>
+				</div>
+				<el-form ref="formRef" :model="form" :rules="rules" label-width="160px">
+					<!-- 鏈�楂樻晥鐜囩偣娴侀噺 -->
+					<div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
+						<div class="flex items-center">
+							<!-- <span class="text-gray-500">鏈�楂樻晥鐜囩偣娴侀噺(m鲁/h)锛�</span> -->
+							<div class="flex flex-1">
+								<el-form-item prop="MaxFlow" label="鏈�楂樻晥鐜囩偣娴侀噺(m鲁/h)">
+									<el-input v-model="form.MaxFlow" placeholder="璇疯緭鍏ユ渶楂樻晥鐜囩偣娴侀噺" class="!w-[300px]" clearable> </el-input>
+								</el-form-item>
+							</div>
+						</div>
+					</div>
+					<!-- 鏈�楂樻晥鐜囩偣鎵▼ -->
+					<div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
+						<div class="flex items-center">
+							<!-- <span class="text-gray-500">鏈�楂樻晥鐜囩偣鎵▼(m)锛�</span> -->
+							<div class="flex flex-1">
+								<el-form-item prop="MaxHead" label="鏈�楂樻晥鐜囩偣鎵▼(m)">
+									<el-input v-model="form.MaxHead" placeholder="璇疯緭鍏ユ渶楂樻晥鐜囩偣鎵▼" class="!w-[300px]" clearable> </el-input>
+								</el-form-item>
+							</div>
+						</div>
+					</div>
+					<!-- 姘存车杞�� -->
+					<div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
+						<div class="flex items-center">
+							<!-- <span class="text-gray-500">姘存车杞��(r/min)锛�</span> -->
+							<div class="flex flex-1">
+								<el-form-item prop="Speed" label="姘存车杞��(r/min)">
+									<el-input v-model="form.Speed" placeholder="璇疯緭鍏ユ按娉佃浆閫�" class="!w-[300px]" clearable> </el-input>
+								</el-form-item>
+							</div>
+						</div>
+					</div>
+					<!-- 姘存车鏁堢巼 -->
+					<div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
+						<div class="flex items-center">
+							<!-- <span class="text-gray-500" style="color:blue">姘存车鏁堢巼(%)锛�</span> -->
+							<div class="flex flex-1">
+								<el-form-item prop="Efficiency" label="姘存车鏁堢巼(%)">
+									<el-input v-model="form.Efficiency" placeholder="璇疯緭鍏ユ晥鐜�" class="!w-[300px]" clearable> </el-input>
+								</el-form-item>
+							</div>
+						</div>
+					</div>
+				</el-form>
+				<div class="border-b p-4 border-bottom-dashed-1 box-border" style="padding: 10px">
+					<div class="flex items-center">
+						<el-button type="primary" @click="Calc">璁$畻</el-button>
+						<el-button @click="clear" type="info">娓呯┖</el-button>
+						<span style="margin-left: 85px">鍙傝�冨浗鏍囨枃浠讹細</span>
+						<span style="color: dodgerblue; cursor: pointer; font-weight: bold">
+							<a :href="`${SERVE_URL}files/pdf/GB19762-2025.pdf`" target="_blank"> 绂诲績娉佃兘鏁堥檺瀹氬�煎強鑳芥晥绛夌骇 GB+19762-2025</a>
+						</span>
+					</div>
+				</div>
+			</div>
 
-            <div class="grid" style="padding: 15px 10px; min-height: 30px">
-                <img v-if="level > -1" style="width:78px;height: 30px;" :src="getImgUrl()"><span v-if="level > -1">{{
-                    calcResult }}</span>
-                <!-- <span v-if="level == 0">鏈绠楀嚭鑳芥晥绛夌骇锛岃妫�鏌ヨ緭鍏ユ暟鎹�!</span> -->
-            </div>
-        </div>
-    </div>
+			<div class="grid" style="padding: 15px 10px; min-height: 30px">
+				<img v-if="level > -1" style="width: 78px; height: 30px" :src="getImgUrl()" /><span v-if="level > -1">{{ calcResult }}</span>
+				<!-- <span v-if="level == 0">鏈绠楀嚭鑳芥晥绛夌骇锛岃妫�鏌ヨ緭鍏ユ暟鎹�!</span> -->
+			</div>
+		</div>
+	</div>
 </template>
 <script setup lang="ts">
 import { onMounted, ref, computed } from 'vue';
@@ -104,356 +124,476 @@
 const route = useRoute();
 
 const pumptype = [
-    { name: '娓呮按绂诲績娉�', id: 1 },
-    { name: '鐭虫补鍖栧伐绂诲績娉�', id: 2 },
-]
+	{ name: '娓呮按绂诲績娉�', id: 1 },
+	{ name: '鐭虫补鍖栧伐绂诲績娉�', id: 2 },
+];
 
 const type = [
-    {
-        name: '鍗曠骇鍗曞惛娓呮按绂诲績娉�', isdouble: false, issingle: true, pumpid: 1, tag: 1, contant: [
-            { minFlow: 5, maxFlow: 300, c1: 162.33, c2: 163.33, c3: 168.33 },
-            { minFlow: 300, maxFlow: 10000, c1: 161.33, c2: 163.33, c3: 168.33 },
-        ]
-    },
-    {
-        name: '鍗曠骇鍙屽惛娓呮按绂诲績娉�', isdouble: true, issingle: true, pumpid: 1, tag: 2, contant: [
-            { minFlow: 50, maxFlow: 600, c1: 162.33, c2: 163.33, c3: 168.33 },
-            { minFlow: 600, maxFlow: 20000, c1: 161.33, c2: 163.33, c3: 168.33 },
-        ]
-    },
-    {
-        name: '绠¢亾娓呮按绂诲績娉�', isdouble: false, issingle: true, pumpid: 1, tag: 3, contant: [
-            { minFlow: 5, maxFlow: 300, c1: 164.33, c2: 165.33, c3: 171.33 },
-            { minFlow: 300, maxFlow: 3000, c1: 163.33, c2: 165.33, c3: 171.33 },
-        ]
-    },
-    {
-        name: '澶氱骇娓呮按绂诲績娉�', isdouble: false, issingle: false, pumpid: 1, tag: 4, contant: [
-            { minFlow: 5, maxFlow: 100, c1: 140.33, c2: 142.33, c3: 150.33 },
-            { minFlow: 100, maxFlow: 3000, c1: 139.33, c2: 142.33, c3: 150.33 },
-        ]
-    },
-    {
-        name: '杞诲瀷澶氱骇娓呮按绂诲績娉�(绔嬪紡)', isdouble: false, issingle: false, pumpid: 1, tag: 5, contant: [
-            { minFlow: 5, maxFlow: 300, c1: 137.33, c2: 139.33, c3: 144.33 },
-        ]
-    },
-    {
-        name: '杞诲瀷澶氱骇娓呮按绂诲績娉�(鍗у紡)', isdouble: false, issingle: false, pumpid: 1, tag: 6, contant: [
-            { minFlow: 5, maxFlow: 300, c1: 140.33, c2: 142.33, c3: 147.33 },
-        ]
-    },
-    {
-        name: '鍗曠骇鍗曞惛鐭虫补鍖栧伐绂诲績娉�', isdouble: false, issingle: true, pumpid: 2, tag: 7, contant: [
-            {
-                minFlow: 6, maxFlow: 300, speed: [
-                    { min: 20, max: 59, c1: 10, c2: 5, c3: -4 },
-                    { min: 60, max: 119, c1: 4, c2: 1, c3: -6 },
-                    { min: 120, max: 210, c1: 3, c2: 1, c3: -6 },
-                    { min: 211, max: 300, c1: 3, c2: 1, c3: -6 },
-                ]
-            },
-            {
-                minFlow: 301, maxFlow: 30000, speed: [
-                    { min: 20, max: 59, c1: 11, c2: 5, c3: -5 },
-                    { min: 60, max: 119, c1: 5, c2: 1, c3: -5 },
-                    { min: 120, max: 210, c1: 3, c2: 2, c3: -5 },
-                    { min: 211, max: 300, c1: 3, c2: 2, c3: -5 },
-                ]
-            },
-        ]
-    },
-    {
-        name: '鍗曠骇鍙屽惛鐭虫补鍖栧伐绂诲績娉�', isdouble: true, issingle: true, pumpid: 2, tag: 8, contant: [
-            {
-                minFlow: 6, maxFlow: 300, speed: [
-                    { min: 20, max: 59, c1: 10, c2: 5, c3: -4 },
-                    { min: 60, max: 119, c1: 4, c2: 1, c3: -6 },
-                    { min: 120, max: 210, c1: 3, c2: 1, c3: -6 },
-                    { min: 211, max: 300, c1: 3, c2: 1, c3: -6 },
-                ]
-            },
-            {
-                minFlow: 301, maxFlow: 30000, speed: [
-                    { min: 20, max: 59, c1: 11, c2: 5, c3: -5 },
-                    { min: 60, max: 119, c1: 5, c2: 1, c3: -5 },
-                    { min: 120, max: 210, c1: 3, c2: 2, c3: -5 },
-                    { min: 211, max: 300, c1: 3, c2: 2, c3: -5 },
-                ]
-            },
-        ]
-    },
-    {
-        name: '澶氱骇鐭虫补鍖栧伐绂诲績娉�', isdouble: false, issingle: false, pumpid: 2, tag: 9, contant: [
-            {
-                minFlow: 6, maxFlow: 300, speed: [
-                    { min: 20, max: 59, c1: 5, c2: 3, c3: -5 },
-                    { min: 60, max: 119, c1: 6, c2: 4, c3: -4 },
-                    { min: 120, max: 210, c1: 1, c2: -1, c3: -5 },
-                    { min: 211, max: 300, c1: 1, c2: -1, c3: -5 },
-                ]
-            },
-            {
-                minFlow: 301, maxFlow: 30000, speed: [
-                    { min: 20, max: 59, c1: 3, c2: 1, c3: -4 },
-                    { min: 60, max: 119, c1: 3, c2: 1, c3: -4 },
-                    { min: 120, max: 210, c1: 1, c2: -1, c3: -5 },
-                    { min: 211, max: 300, c1: 1, c2: -1, c3: -5 },
-                ]
-            },
-        ]
-    },
+	{
+		name: '鍗曠骇鍗曞惛娓呮按绂诲績娉�',
+		isdouble: false,
+		issingle: true,
+		pumpid: 1,
+		tag: 1,
+		contant: [
+			{ minFlow: 5, maxFlow: 300, c1: 162.33, c2: 163.33, c3: 168.33 },
+			{ minFlow: 300, maxFlow: 10000, c1: 161.33, c2: 163.33, c3: 168.33 },
+		],
+	},
+	{
+		name: '鍗曠骇鍙屽惛娓呮按绂诲績娉�',
+		isdouble: true,
+		issingle: true,
+		pumpid: 1,
+		tag: 2,
+		contant: [
+			{ minFlow: 50, maxFlow: 600, c1: 162.33, c2: 163.33, c3: 168.33 },
+			{ minFlow: 600, maxFlow: 20000, c1: 161.33, c2: 163.33, c3: 168.33 },
+		],
+	},
+	{
+		name: '绠¢亾娓呮按绂诲績娉�',
+		isdouble: false,
+		issingle: true,
+		pumpid: 1,
+		tag: 3,
+		contant: [
+			{ minFlow: 5, maxFlow: 300, c1: 164.33, c2: 165.33, c3: 171.33 },
+			{ minFlow: 300, maxFlow: 3000, c1: 163.33, c2: 165.33, c3: 171.33 },
+		],
+	},
+	{
+		name: '澶氱骇娓呮按绂诲績娉�',
+		isdouble: false,
+		issingle: false,
+		pumpid: 1,
+		tag: 4,
+		contant: [
+			{ minFlow: 5, maxFlow: 100, c1: 140.33, c2: 142.33, c3: 150.33 },
+			{ minFlow: 100, maxFlow: 3000, c1: 139.33, c2: 142.33, c3: 150.33 },
+		],
+	},
+	{
+		name: '杞诲瀷澶氱骇娓呮按绂诲績娉�(绔嬪紡)',
+		isdouble: false,
+		issingle: false,
+		pumpid: 1,
+		tag: 5,
+		contant: [{ minFlow: 5, maxFlow: 300, c1: 137.33, c2: 139.33, c3: 144.33 }],
+	},
+	{
+		name: '杞诲瀷澶氱骇娓呮按绂诲績娉�(鍗у紡)',
+		isdouble: false,
+		issingle: false,
+		pumpid: 1,
+		tag: 6,
+		contant: [{ minFlow: 5, maxFlow: 300, c1: 140.33, c2: 142.33, c3: 147.33 }],
+	},
+	{
+		name: '鍗曠骇鍗曞惛鐭虫补鍖栧伐绂诲績娉�',
+		isdouble: false,
+		issingle: true,
+		pumpid: 2,
+		tag: 7,
+		contant: [
+			{
+				minFlow: 6,
+				maxFlow: 300,
+				speed: [
+					{ min: 20, max: 59, c1: 10, c2: 5, c3: -4 },
+					{ min: 60, max: 119, c1: 4, c2: 1, c3: -6 },
+					{ min: 120, max: 210, c1: 3, c2: 1, c3: -6 },
+					{ min: 211, max: 300, c1: 3, c2: 1, c3: -6 },
+				],
+			},
+			{
+				minFlow: 301,
+				maxFlow: 30000,
+				speed: [
+					{ min: 20, max: 59, c1: 11, c2: 5, c3: -5 },
+					{ min: 60, max: 119, c1: 5, c2: 1, c3: -5 },
+					{ min: 120, max: 210, c1: 3, c2: 2, c3: -5 },
+					{ min: 211, max: 300, c1: 3, c2: 2, c3: -5 },
+				],
+			},
+		],
+	},
+	{
+		name: '鍗曠骇鍙屽惛鐭虫补鍖栧伐绂诲績娉�',
+		isdouble: true,
+		issingle: true,
+		pumpid: 2,
+		tag: 8,
+		contant: [
+			{
+				minFlow: 6,
+				maxFlow: 300,
+				speed: [
+					{ min: 20, max: 59, c1: 10, c2: 5, c3: -4 },
+					{ min: 60, max: 119, c1: 4, c2: 1, c3: -6 },
+					{ min: 120, max: 210, c1: 3, c2: 1, c3: -6 },
+					{ min: 211, max: 300, c1: 3, c2: 1, c3: -6 },
+				],
+			},
+			{
+				minFlow: 301,
+				maxFlow: 30000,
+				speed: [
+					{ min: 20, max: 59, c1: 11, c2: 5, c3: -5 },
+					{ min: 60, max: 119, c1: 5, c2: 1, c3: -5 },
+					{ min: 120, max: 210, c1: 3, c2: 2, c3: -5 },
+					{ min: 211, max: 300, c1: 3, c2: 2, c3: -5 },
+				],
+			},
+		],
+	},
+	{
+		name: '澶氱骇鐭虫补鍖栧伐绂诲績娉�',
+		isdouble: false,
+		issingle: false,
+		pumpid: 2,
+		tag: 9,
+		contant: [
+			{
+				minFlow: 6,
+				maxFlow: 300,
+				speed: [
+					{ min: 20, max: 59, c1: 5, c2: 3, c3: -5 },
+					{ min: 60, max: 119, c1: 6, c2: 4, c3: -4 },
+					{ min: 120, max: 210, c1: 1, c2: -1, c3: -5 },
+					{ min: 211, max: 300, c1: 1, c2: -1, c3: -5 },
+				],
+			},
+			{
+				minFlow: 301,
+				maxFlow: 30000,
+				speed: [
+					{ min: 20, max: 59, c1: 3, c2: 1, c3: -4 },
+					{ min: 60, max: 119, c1: 3, c2: 1, c3: -4 },
+					{ min: 120, max: 210, c1: 1, c2: -1, c3: -5 },
+					{ min: 211, max: 300, c1: 1, c2: -1, c3: -5 },
+				],
+			},
+		],
+	},
 ];
 const clear = () => {
-    MaxFlow.value = '';
-    MaxHead.value = '';
-    Speed.value = '';
-    Efficiency.value = '';
-    typeSelect.value = 1;
-    calcResult.value = null;
-    level.value = 0;
-}
+	form.value = {
+		MaxFlow: '',
+		MaxHead: '',
+		Speed: '',
+		Efficiency: '',
+	};
+	typeSelect.value = 1;
+	calcResult.value = null;
+	level.value = -1;
+
+	formRef.value.resetFields();
+};
 
 const getImgUrl = () => {
-    return `${SERVE_URL}static/img/calc-icons/${level.value}.png`;
-}
+	return `${SERVE_URL}static/img/calc-icons/${level.value}.png`;
+};
 // 璁$畻
-const Calc = () => {
+const Calc = async () => {
+	// 琛ㄥ崟鏍¢獙
+	await formRef.value.validate();
 
-    if (MaxFlow.value == null) {
-        ElMessage.error("璇疯緭鍏ユ湁鏁堟祦閲忔暟鎹�!");
-        return;
-    }
-    if (MaxHead.value == null) {
-        ElMessage.error("璇疯緭鍏ユ湁鏁堟壃绋嬫暟鎹�!");
-        return;
-    }
-    if (Speed.value == null) {
-        ElMessage.error("璇疯緭鍏ユ湁鏁堣浆閫熸暟鎹�!");
-        return;
-    }
-    if (Efficiency.value == null) {
-        ElMessage.error("璇疯緭鍏ユ湁鏁堟晥鐜囨暟鎹�!");
-        return;
-    }
-    if (Efficiency.value < 0 || Efficiency.value > 100) {
-        ElMessage.error("璇疯緭鍏ユ湁鏁堟晥鐜囨暟鎹��0-100銆�!");
-        return;
-    }
-
-    let pump = type.filter((c) => { return c.tag == typeSelect.value })
-    if (pump[0].pumpid == 1)
-        CalcClearWaterPump(pump[0])
-    else
-        CalcPetrochemicalPump(pump[0])
-}
+	let pump = type.filter((c) => {
+		return c.tag == typeSelect.value;
+	});
+	if (pump[0].pumpid == 1) CalcClearWaterPump(pump[0]);
+	else CalcPetrochemicalPump(pump[0]);
+};
 //娓呮按绂诲績娉佃绠�
 const CalcClearWaterPump = (pump) => {
-    let speedrate = SpeedRate(Speed.value, MaxFlow.value, MaxHead.value, pump.issingle, pump.isdouble)
-    let c1V, c2V, c3V = 0;
-    let cv = pump.contant.filter((c) => { return c.minFlow <= MaxFlow.value && c.maxFlow >= MaxFlow.value });
-    if (pump.issingle) {
-        c1V = -8.44 * Math.pow(Math.log(speedrate), 2) - 0.48 * Math.pow(Math.log(MaxFlow.value), 2) + 0.09 * Math.log(speedrate) * Math.log(MaxFlow.value) +
-            84.63 * Math.log(speedrate) + 8.5 * Math.log(MaxFlow.value) - cv[0].c1;
+	let speedrate = SpeedRate(form.value.Speed, form.value.MaxFlow, form.value.MaxHead, pump.issingle, pump.isdouble);
+	let c1V,
+		c2V,
+		c3V = 0;
+	let cv = pump.contant.filter((c) => {
+		return c.minFlow <= form.value.MaxFlow && c.maxFlow >= form.value.MaxFlow;
+	});
+	if (pump.issingle) {
+		c1V =
+			-8.44 * Math.pow(Math.log(speedrate), 2) -
+			0.48 * Math.pow(Math.log(form.value.MaxFlow), 2) +
+			0.09 * Math.log(speedrate) * Math.log(form.value.MaxFlow) +
+			84.63 * Math.log(speedrate) +
+			8.5 * Math.log(form.value.MaxFlow) -
+			cv[0].c1;
 
-        c2V = -8.44 * Math.pow(Math.log(speedrate), 2) - 0.48 * Math.pow(Math.log(MaxFlow.value), 2) + 0.09 * Math.log(speedrate) * Math.log(MaxFlow.value) +
-            84.63 * Math.log(speedrate) + 8.5 * Math.log(MaxFlow.value) - cv[0].c2;
+		c2V =
+			-8.44 * Math.pow(Math.log(speedrate), 2) -
+			0.48 * Math.pow(Math.log(form.value.MaxFlow), 2) +
+			0.09 * Math.log(speedrate) * Math.log(form.value.MaxFlow) +
+			84.63 * Math.log(speedrate) +
+			8.5 * Math.log(form.value.MaxFlow) -
+			cv[0].c2;
 
-        c3V = -8.44 * Math.pow(Math.log(speedrate), 2) - 0.48 * Math.pow(Math.log(MaxFlow.value), 2) + 0.09 * Math.log(speedrate) * Math.log(MaxFlow.value) +
-            84.63 * Math.log(speedrate) + 8.5 * Math.log(MaxFlow.value) - cv[0].c3;
-    }
-    else {
-        c1V = -6.93 * Math.pow(Math.log(speedrate), 2) - 0.19 * Math.pow(Math.log(MaxFlow.value), 2) - 0.4 * Math.log(speedrate) * Math.log(MaxFlow.value) +
-            72.67 * Math.log(speedrate) + 8.73 * Math.log(MaxFlow.value) - cv[0].c1;
+		c3V =
+			-8.44 * Math.pow(Math.log(speedrate), 2) -
+			0.48 * Math.pow(Math.log(form.value.MaxFlow), 2) +
+			0.09 * Math.log(speedrate) * Math.log(form.value.MaxFlow) +
+			84.63 * Math.log(speedrate) +
+			8.5 * Math.log(form.value.MaxFlow) -
+			cv[0].c3;
+	} else {
+		c1V =
+			-6.93 * Math.pow(Math.log(speedrate), 2) -
+			0.19 * Math.pow(Math.log(form.value.MaxFlow), 2) -
+			0.4 * Math.log(speedrate) * Math.log(form.value.MaxFlow) +
+			72.67 * Math.log(speedrate) +
+			8.73 * Math.log(form.value.MaxFlow) -
+			cv[0].c1;
 
-        c2V = -6.93 * Math.pow(Math.log(speedrate), 2) - 0.19 * Math.pow(Math.log(MaxFlow.value), 2) - 0.4 * Math.log(speedrate) * Math.log(MaxFlow.value) +
-            72.67 * Math.log(speedrate) + 8.73 * Math.log(MaxFlow.value) - cv[0].c2;
+		c2V =
+			-6.93 * Math.pow(Math.log(speedrate), 2) -
+			0.19 * Math.pow(Math.log(form.value.MaxFlow), 2) -
+			0.4 * Math.log(speedrate) * Math.log(form.value.MaxFlow) +
+			72.67 * Math.log(speedrate) +
+			8.73 * Math.log(form.value.MaxFlow) -
+			cv[0].c2;
 
-        c3V = -6.93 * Math.pow(Math.log(speedrate), 2) - 0.19 * Math.pow(Math.log(MaxFlow.value), 2) - 0.4 * Math.log(speedrate) * Math.log(MaxFlow.value) +
-            72.67 * Math.log(speedrate) + 8.73 * Math.log(MaxFlow.value) - cv[0].c3;
-
-    }
-    let level = GetEnergyLevel(c1V, c2V, c3V);
-    //calcResult.value = level;
-}
+		c3V =
+			-6.93 * Math.pow(Math.log(speedrate), 2) -
+			0.19 * Math.pow(Math.log(form.value.MaxFlow), 2) -
+			0.4 * Math.log(speedrate) * Math.log(form.value.MaxFlow) +
+			72.67 * Math.log(speedrate) +
+			8.73 * Math.log(form.value.MaxFlow) -
+			cv[0].c3;
+	}
+	let level = GetEnergyLevel(c1V, c2V, c3V);
+	//calcResult.value = level;
+};
 
 const GetEnergyLevel = (c1V: number, c2V: number, c3V: number) => {
-    let levelDic = [
-        { level: 1, min: c1V, max: 100 },
-        { level: 2, min: c2V, max: c1V },
-        { level: 3, min: c3V, max: c2V }
-    ]
-    let levelV = 0;
-    for (const range of levelDic) {
-        if (Efficiency.value >= range.min && Efficiency.value <= range.max) {
-            levelV = range.level;
-        }
-    }
-    calcResult.value = "璁$畻缁撴灉锛�1绾ф晥鐜囧�� " + c1V.toFixed(2) + "%锛�2绾ф晥鐜囧�� " + c2V.toFixed(2) + "%锛�3绾ф晥鐜囧�� " + c3V.toFixed(2) + "%";
+	let levelDic = [
+		{ level: 1, min: c1V, max: 100 },
+		{ level: 2, min: c2V, max: c1V },
+		{ level: 3, min: c3V, max: c2V },
+	];
+	let levelV = 0;
+	for (const range of levelDic) {
+		if (form.value.Efficiency >= range.min && form.value.Efficiency <= range.max) {
+			levelV = range.level;
+		}
+	}
+	calcResult.value =
+		'璁$畻缁撴灉锛�1绾ф晥鐜囧�� ' + c1V.toFixed(2) + '%锛�2绾ф晥鐜囧�� ' + c2V.toFixed(2) + '%锛�3绾ф晥鐜囧�� ' + c3V.toFixed(2) + '%';
 
-    level.value = levelV;
-    return levelV;
-}
+	level.value = levelV;
+	return levelV;
+};
 
 //鐭虫补鍖栧伐绂诲績娉佃绠�
 const CalcPetrochemicalPump = (pump) => {
-    let speedrate = SpeedRate(Speed.value, MaxFlow.value, MaxHead.value, pump.issingle, pump.isdouble)
-    console.log(speedrate)
+	let speedrate = SpeedRate(form.value.Speed, form.value.MaxFlow, form.value.MaxHead, pump.issingle, pump.isdouble);
+	console.log(speedrate);
 
-    let jzV = 0;
-    let jzFlow = MaxFlow.value;
-    if (MaxFlow.value > 3000)
-        jzFlow = 3000
-    if (pump.issingle) {
-        jzV = 4.7057338 * Math.pow(10, -5) * Math.pow(Math.log(jzFlow), 6) - 6.6320555 * Math.pow(10, -3) * Math.pow(Math.log(jzFlow), 5) +
-            1.5115754 * Math.pow(10, -1) * Math.pow(Math.log(jzFlow), 4) - 1.4023278 * Math.pow(Math.log(jzFlow), 3) +
-            5.5234828 * Math.pow(Math.log(jzFlow), 2) - 8.3298912 * Math.pow(10, -1) * Math.log(jzFlow) +
-            4.1951745 * 10;
-    } else {
-        jzV = 5.5836234 * Math.pow(10, -4) * Math.pow(Math.log(jzFlow), 6) - 1.2499816 * Math.pow(10, -2) * Math.pow(Math.log(jzFlow), 5) +
-            9.9576618 * Math.pow(10, -2) * Math.pow(Math.log(jzFlow), 4) - 4.6811292 * Math.pow(10, -1) * Math.pow(Math.log(jzFlow), 3) +
-            1.9459872 * Math.pow(Math.log(jzFlow), 2) + 1.4371144 * Math.log(jzFlow) +
-            4.1467097 * 10;
-    }
+	let jzV = 0;
+	let jzFlow = form.value.MaxFlow;
+	if (form.value.MaxFlow > 3000) jzFlow = 3000;
+	if (pump.issingle) {
+		jzV =
+			4.7057338 * Math.pow(10, -5) * Math.pow(Math.log(jzFlow), 6) -
+			6.6320555 * Math.pow(10, -3) * Math.pow(Math.log(jzFlow), 5) +
+			1.5115754 * Math.pow(10, -1) * Math.pow(Math.log(jzFlow), 4) -
+			1.4023278 * Math.pow(Math.log(jzFlow), 3) +
+			5.5234828 * Math.pow(Math.log(jzFlow), 2) -
+			8.3298912 * Math.pow(10, -1) * Math.log(jzFlow) +
+			4.1951745 * 10;
+	} else {
+		jzV =
+			5.5836234 * Math.pow(10, -4) * Math.pow(Math.log(jzFlow), 6) -
+			1.2499816 * Math.pow(10, -2) * Math.pow(Math.log(jzFlow), 5) +
+			9.9576618 * Math.pow(10, -2) * Math.pow(Math.log(jzFlow), 4) -
+			4.6811292 * Math.pow(10, -1) * Math.pow(Math.log(jzFlow), 3) +
+			1.9459872 * Math.pow(Math.log(jzFlow), 2) +
+			1.4371144 * Math.log(jzFlow) +
+			4.1467097 * 10;
+	}
 
-    let xzV = 0;
-    if (speedrate > 210 && speedrate <= 300) {
-        xzV = -1.1111111 * Math.pow(10, -10) * Math.pow(speedrate, 6) + 1.6769231 * Math.pow(10, -7) * Math.pow(speedrate, 5) -
-            1.0507265 * Math.pow(10, -4) * Math.pow(speedrate, 4) + 3.4987040 * Math.pow(10, -2) * Math.pow(speedrate, 3) -
-            6.5298720 * Math.pow(speedrate, 2) + 6.4773909 * Math.pow(10, 2) * speedrate -
-            2.6684155 * Math.pow(10, 4);
-    } else if (speedrate >= 20 && speedrate < 120) {
-        xzV = 3.7873403 * Math.pow(10, -10) * Math.pow(speedrate, 6) - 1.7898913 * Math.pow(10, -7) * Math.pow(speedrate, 5) +
-            3.4269717 * Math.pow(10, -5) * Math.pow(speedrate, 4) - 3.4148047 * Math.pow(10, -3) * Math.pow(speedrate, 3) +
-            1.9050630 * Math.pow(speedrate, 2) * Math.pow(10, -1) - 6.0391904 * speedrate +
-            9.8970658 * 10;
-    } else xzV = 0;
+	let xzV = 0;
+	if (speedrate > 210 && speedrate <= 300) {
+		xzV =
+			-1.1111111 * Math.pow(10, -10) * Math.pow(speedrate, 6) +
+			1.6769231 * Math.pow(10, -7) * Math.pow(speedrate, 5) -
+			1.0507265 * Math.pow(10, -4) * Math.pow(speedrate, 4) +
+			3.498704 * Math.pow(10, -2) * Math.pow(speedrate, 3) -
+			6.529872 * Math.pow(speedrate, 2) +
+			6.4773909 * Math.pow(10, 2) * speedrate -
+			2.6684155 * Math.pow(10, 4);
+	} else if (speedrate >= 20 && speedrate < 120) {
+		xzV =
+			3.7873403 * Math.pow(10, -10) * Math.pow(speedrate, 6) -
+			1.7898913 * Math.pow(10, -7) * Math.pow(speedrate, 5) +
+			3.4269717 * Math.pow(10, -5) * Math.pow(speedrate, 4) -
+			3.4148047 * Math.pow(10, -3) * Math.pow(speedrate, 3) +
+			1.905063 * Math.pow(speedrate, 2) * Math.pow(10, -1) -
+			6.0391904 * speedrate +
+			9.8970658 * 10;
+	} else xzV = 0;
 
-    let oV = 0;
-    if (speedrate >= 120 && speedrate <= 210)
-        oV = jzV
-    else oV = jzV - xzV
+	let oV = 0;
+	if (speedrate >= 120 && speedrate <= 210) oV = jzV;
+	else oV = jzV - xzV;
 
-    let conV = pump.contant.filter((c) => { return c.minFlow <= MaxFlow.value && c.maxFlow >= MaxFlow.value });
-    let cv = conV[0].speed.filter((c) => {
-        return c.min <= speedrate && c.max >= speedrate
-    })
-    let c1V, c2V, c3V = 0;
-    c1V = oV + cv[0].c1;
-    c2V = oV + cv[0].c2;
-    c3V = oV + cv[0].c3;
-    let level = GetEnergyLevel(c1V, c2V, c3V);
-    //calcResult.value = level;
-}
+	let conV = pump.contant.filter((c) => {
+		return c.minFlow <= form.value.MaxFlow && c.maxFlow >= form.value.MaxFlow;
+	});
+	let cv = conV[0].speed.filter((c) => {
+		return c.min <= speedrate && c.max >= speedrate;
+	});
+	let c1V,
+		c2V,
+		c3V = 0;
+	c1V = oV + cv[0].c1;
+	c2V = oV + cv[0].c2;
+	c3V = oV + cv[0].c3;
+	let level = GetEnergyLevel(c1V, c2V, c3V);
+	//calcResult.value = level;
+};
 
 //issingle: 鏄惁鍗曠骇,isdouble: 鏄惁鍙屽惛
 const SpeedRate = (speed: number, q: number, h: number, issingle: boolean, isdouble: boolean) => {
-    let singleV = 1;
-    let doubleV = 1;
-    if (!issingle)
-        singleV = 5;
-    if (isdouble)
-        doubleV = 2;
-    return 3.65 * speed * Math.pow(q / 3600 / doubleV, 0.5) / Math.pow(h / singleV, 0.75)
-}
+	let singleV = 1;
+	let doubleV = 1;
+	if (!issingle) singleV = 5;
+	if (isdouble) doubleV = 2;
+	return (3.65 * speed * Math.pow(q / 3600 / doubleV, 0.5)) / Math.pow(h / singleV, 0.75);
+};
+
+// 鏁堢巼鏍¢獙
+const validateEfficiency = (rule, value, callback) => {
+	if (!value || value == '') {
+		callback(new Error('璇疯緭鍏ユ按娉垫晥鐜�!'));
+	} else if (value < 0 || value > 100) {
+		callback(new Error('璇疯緭鍏ユ湁鏁堟晥鐜囨暟鎹��0-100銆�!'));
+	} else {
+		callback();
+	}
+};
+
 // 閫変腑鐘舵��
 const typeSelect = ref(1);
 const pumpSelect = ref(1);
 const MaxFlow = ref(null);
-const MaxHead = ref(null)
+const MaxHead = ref(null);
 const Speed = ref(null);
 const Efficiency = ref(null);
 const calcResult = ref(null);
-const level = ref(-1)
+const level = ref(-1);
+
+const formRef = ref(null);
+const form = ref({
+	MaxFlow: null,
+	MaxHead: null,
+	Speed: null,
+	Efficiency: null,
+});
+const rules = ref({
+	MaxFlow: [{ required: true, message: '璇疯緭鍏ユ渶楂樻晥鐜囩偣娴侀噺' }],
+	MaxHead: [{ required: true, message: '璇疯緭鍏ユ渶楂樻晥鐜囩偣鎵▼' }],
+	Speed: [{ required: true, message: '璇疯緭鍏ユ按娉佃浆閫�' }],
+	Efficiency: [{ required: true, validator: validateEfficiency }],
+});
 //鐩戝惉绫诲瀷閫夋嫨绛涢��
 const changeSelectType = (tag: number) => {
-    typeSelect.value = tag;
+	typeSelect.value = tag;
 };
 const changeSelectPumpType = (tag: number) => {
-    pumpSelect.value = tag;
-    typeSelect.value = type.filter((c) => { return c.pumpid == tag })[0].tag;
+	pumpSelect.value = tag;
+	typeSelect.value = type.filter((c) => {
+		return c.pumpid == tag;
+	})[0].tag;
 };
 </script>
 <style lang="scss" scoped>
 .w-100 {
-    width: 100%;
+	width: 100%;
 }
 
 .text-gray-500 {
-    display: inline-block;
-    width: 150px;
-    flex-shrink: 0;
+	display: inline-block;
+	width: 150px;
+	flex-shrink: 0;
 }
 
 .h-100 {
-    height: 100%;
+	height: 100%;
 }
 
 .industrial-soft-style {
-    position: relative;
+	position: relative;
 }
 
 .border-bottom-dashed-1 {
-    // border-bottom: 1px dashed #e2e8f0;
+	// border-bottom: 1px dashed #e2e8f0;
 }
 
 .box-border {
-    box-sizing: border-box;
+	box-sizing: border-box;
 }
 
 .industrial-soft-style::after {
-    content: '';
-    position: absolute;
-    top: 0;
-    left: 0;
-    width: 100%;
-    height: 3px;
-    background-color: #38ca94;
-    background-image: linear-gradient(90deg, #9bc864, #40cb8f 21%, #00c7c4 47%, #00bcef 74%, #0af);
+	content: '';
+	position: absolute;
+	top: 0;
+	left: 0;
+	width: 100%;
+	height: 3px;
+	background-color: #38ca94;
+	background-image: linear-gradient(90deg, #9bc864, #40cb8f 21%, #00c7c4 47%, #00bcef 74%, #0af);
 }
 
 .ant-tag {
-    box-sizing: border-box;
-    color: rgba(0, 0, 0, 0.65);
-    font-variant: tabular-nums;
-    line-height: 1.5;
-    list-style: none;
-    font-feature-settings: 'tnum';
-    display: inline-block;
-    height: auto;
-    margin: 0 4px 0 0;
-    padding: 2px 2px;
-    line-height: 20px;
-    white-space: nowrap;
-    cursor: default;
-    opacity: 1;
-    transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
-    margin-right: 5px;
-    font-size: 14px;
+	box-sizing: border-box;
+	color: rgba(0, 0, 0, 0.65);
+	font-variant: tabular-nums;
+	line-height: 1.5;
+	list-style: none;
+	font-feature-settings: 'tnum';
+	display: inline-block;
+	height: auto;
+	margin: 0 4px 0 0;
+	padding: 2px 2px;
+	line-height: 20px;
+	white-space: nowrap;
+	cursor: default;
+	opacity: 1;
+	transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
+	margin-right: 5px;
+	font-size: 14px;
 }
 
 .ant-tag:hover {
-    color: #1c97b7;
-    cursor: pointer;
+	color: #1c97b7;
+	cursor: pointer;
 }
 
 .ant-tag-checked {
-    background-color: #1c97b7;
-    color: #fff;
+	background-color: #1c97b7;
+	color: #fff;
 }
 
 .ant-tag-checked:hover {
-    color: #fff;
+	color: #fff;
 }
 .flex-wrap {
-    flex-wrap: wrap;
+	flex-wrap: wrap;
 }
-
+:deep(.el-form-item__label) {
+	justify-content: flex-start;
+}
+:deep(.el-form-item) {
+	margin-bottom: 0;
+}
 
 :deep(.el-button--default) {
-    --el-button-bg-color: transparent;
-    --el-button-border-color: transparent;
-    --el-button-hover-bg-color: var(--el-color-primary-light-9);
-    --el-button-hover-border-color: transparent;
+	--el-button-bg-color: transparent;
+	--el-button-border-color: transparent;
+	--el-button-hover-bg-color: var(--el-color-primary-light-9);
+	--el-button-hover-border-color: transparent;
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3