irriWaterInputFlux.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <div class="container">
  3. <el-card shadow="always" class="gradient-card">
  4. <!-- 标题区域 -->
  5. <div class="title-section">
  6. <h1 class="main-title">灌溉水输入通量计算</h1>
  7. <p class="sub-title">请选择土地类型并输入相应的灌溉参数</p>
  8. </div>
  9. <!-- 水地参数输入 -->
  10. <div class="land-section">
  11. <el-row :gutter="30">
  12. <el-col :span="6">
  13. <el-checkbox v-model="waterLand" label="水地" class="land-checkbox" />
  14. </el-col>
  15. <el-col :span="9">
  16. <div class="input-label">
  17. <i class="fas fa-faucet"></i> 灌溉水用量 (m³)
  18. </div>
  19. <el-input
  20. v-model="irrigationWaterUsage"
  21. placeholder="请输入灌溉水用量"
  22. :disabled="!waterLand"
  23. size="large"
  24. />
  25. </el-col>
  26. <el-col :span="9">
  27. <div class="input-label">
  28. <i class="fas fa-percentage"></i> 有效利用率 (%)
  29. </div>
  30. <el-input
  31. v-model="irrigationEfficiency"
  32. placeholder="请输入有效利用率"
  33. :disabled="!waterLand"
  34. size="large"
  35. />
  36. </el-col>
  37. </el-row>
  38. </div>
  39. <!-- 水浇地参数输入 -->
  40. <div class="land-section">
  41. <el-row :gutter="30">
  42. <el-col :span="6">
  43. <el-checkbox v-model="irrigatedLand" label="水浇地" class="land-checkbox" />
  44. </el-col>
  45. <el-col :span="9">
  46. <div class="input-label">
  47. <i class="fas fa-faucet"></i> 灌溉水用量 (m³)
  48. </div>
  49. <el-input
  50. v-model="irrigatedWaterUsage"
  51. placeholder="请输入灌溉水用量"
  52. :disabled="!irrigatedLand"
  53. size="large"
  54. />
  55. </el-col>
  56. <el-col :span="9">
  57. <div class="input-label">
  58. <i class="fas fa-percentage"></i> 有效利用率 (%)
  59. </div>
  60. <el-input
  61. v-model="irrigatedEfficiency"
  62. placeholder="请输入有效利用率"
  63. :disabled="!irrigatedLand"
  64. size="large"
  65. />
  66. </el-col>
  67. </el-row>
  68. </div>
  69. <!-- 旱地参数输入 -->
  70. <div class="land-section">
  71. <el-row :gutter="30">
  72. <el-col :span="6">
  73. <el-checkbox v-model="dryLand" label="旱地" class="land-checkbox" />
  74. </el-col>
  75. <el-col :span="9">
  76. <div class="input-label">
  77. <i class="fas fa-faucet"></i> 灌溉水用量 (m³)
  78. </div>
  79. <el-input
  80. v-model="dryWaterUsage"
  81. placeholder="请输入灌溉水用量"
  82. :disabled="!dryLand"
  83. size="large"
  84. />
  85. </el-col>
  86. <el-col :span="9">
  87. <div class="input-label">
  88. <i class="fas fa-percentage"></i> 有效利用率 (%)
  89. </div>
  90. <el-input
  91. v-model="dryEfficiency"
  92. placeholder="请输入有效利用率"
  93. :disabled="!dryLand"
  94. size="large"
  95. />
  96. </el-col>
  97. </el-row>
  98. </div>
  99. <!-- 计算按钮 -->
  100. <el-row justify="center" class="button-section">
  101. <el-button
  102. class="calculate-btn"
  103. @click="calculateFlux"
  104. >
  105. <i class="fas fa-calculator"></i> 计算灌溉水输入通量
  106. </el-button>
  107. </el-row>
  108. <!-- 计算结果 -->
  109. <div v-if="fluxResult !== null" class="result-section">
  110. <div class="result-title">
  111. <i class="fas fa-chart-bar"></i> 计算结果
  112. </div>
  113. <div class="flux-value">{{ fluxResult.toFixed(2) }} <span class="unit">m³</span></div>
  114. <p class="result-description">灌溉水输入通量计算结果</p>
  115. </div>
  116. </el-card>
  117. </div>
  118. </template>
  119. <script>
  120. import { ref } from 'vue';
  121. import { ElCheckbox, ElInput, ElButton, ElMessage, ElCard, ElRow, ElCol } from 'element-plus';
  122. import { library } from '@fortawesome/fontawesome-svg-core';
  123. import { faFaucet, faPercentage, faCalculator, faChartBar } from '@fortawesome/free-solid-svg-icons';
  124. import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
  125. library.add(faFaucet, faPercentage, faCalculator, faChartBar);
  126. export default {
  127. components: {
  128. ElCheckbox,
  129. ElInput,
  130. ElButton,
  131. ElMessage,
  132. ElCard,
  133. ElRow,
  134. ElCol,
  135. FontAwesomeIcon
  136. },
  137. setup() {
  138. const waterLand = ref(false);
  139. const irrigatedLand = ref(false);
  140. const dryLand = ref(false);
  141. const irrigationWaterUsage = ref('');
  142. const irrigationEfficiency = ref('');
  143. const irrigatedWaterUsage = ref('');
  144. const irrigatedEfficiency = ref('');
  145. const dryWaterUsage = ref('');
  146. const dryEfficiency = ref('');
  147. const fluxResult = ref(null);
  148. const calculateFlux = () => {
  149. let totalFlux = 0;
  150. let valid = true;
  151. if (waterLand.value) {
  152. if (!irrigationWaterUsage.value || !irrigationEfficiency.value) {
  153. ElMessage.warning('请输入水地的灌溉水用量和灌溉水有效利用率');
  154. valid = false;
  155. } else {
  156. const usage = parseFloat(irrigationWaterUsage.value);
  157. const efficiency = parseFloat(irrigationEfficiency.value) / 100; // 转换为小数
  158. if (isNaN(usage) || isNaN(efficiency)) {
  159. ElMessage.error('请输入有效的数字');
  160. valid = false;
  161. } else if (efficiency > 1 || efficiency < 0) {
  162. ElMessage.error('有效利用率应在0-100%之间');
  163. valid = false;
  164. } else {
  165. totalFlux += usage * efficiency;
  166. }
  167. }
  168. }
  169. if (irrigatedLand.value) {
  170. if (!irrigatedWaterUsage.value || !irrigatedEfficiency.value) {
  171. ElMessage.warning('请输入水浇地的灌溉水用量和灌溉水有效利用率');
  172. valid = false;
  173. } else {
  174. const usage = parseFloat(irrigatedWaterUsage.value);
  175. const efficiency = parseFloat(irrigatedEfficiency.value) / 100;
  176. if (isNaN(usage) || isNaN(efficiency)) {
  177. ElMessage.error('请输入有效的数字');
  178. valid = false;
  179. } else if (efficiency > 1 || efficiency < 0) {
  180. ElMessage.error('有效利用率应在0-100%之间');
  181. valid = false;
  182. } else {
  183. totalFlux += usage * efficiency;
  184. }
  185. }
  186. }
  187. if (dryLand.value) {
  188. if (!dryWaterUsage.value || !dryEfficiency.value) {
  189. ElMessage.warning('请输入旱地的灌溉水用量和灌溉水有效利用率');
  190. valid = false;
  191. } else {
  192. const usage = parseFloat(dryWaterUsage.value);
  193. const efficiency = parseFloat(dryEfficiency.value) / 100;
  194. if (isNaN(usage) || isNaN(efficiency)) {
  195. ElMessage.error('请输入有效的数字');
  196. valid = false;
  197. } else if (efficiency > 1 || efficiency < 0) {
  198. ElMessage.error('有效利用率应在0-100%之间');
  199. valid = false;
  200. } else {
  201. totalFlux += usage * efficiency;
  202. }
  203. }
  204. }
  205. if (valid) {
  206. fluxResult.value = totalFlux;
  207. ElMessage.success(`灌溉水输入通量为: ${totalFlux.toFixed(2)} m³`);
  208. }
  209. };
  210. return {
  211. waterLand,
  212. irrigatedLand,
  213. dryLand,
  214. irrigationWaterUsage,
  215. irrigationEfficiency,
  216. irrigatedWaterUsage,
  217. irrigatedEfficiency,
  218. dryWaterUsage,
  219. dryEfficiency,
  220. calculateFlux,
  221. fluxResult
  222. };
  223. }
  224. };
  225. </script>
  226. <style scoped>
  227. .container {
  228. display: flex;
  229. justify-content: center;
  230. align-items: center;
  231. min-height: 100vh;
  232. padding: 20px;
  233. }
  234. .gradient-card {
  235. background: linear-gradient(90deg, rgba(250, 253, 255, 0.7) 0%, rgba(137, 223, 252, 0.7) 90%);
  236. padding: 40px;
  237. border: none;
  238. width: 90%;
  239. max-width: 900px;
  240. border-radius: 20px;
  241. }
  242. .title-section {
  243. text-align: center;
  244. margin-bottom: 40px;
  245. }
  246. .main-title {
  247. font-size: 2.5rem;
  248. color: #1a3c7a;
  249. margin-bottom: 15px;
  250. font-weight: 700;
  251. }
  252. .sub-title {
  253. font-size: 1.4rem;
  254. color: #555;
  255. }
  256. .land-section {
  257. background: rgba(255, 255, 255, 0.85);
  258. border-radius: 15px;
  259. padding: 25px;
  260. margin-bottom: 30px;
  261. box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  262. transition: all 0.3s ease;
  263. }
  264. .land-section:hover {
  265. transform: translateY(-5px);
  266. box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  267. }
  268. .land-checkbox {
  269. height: 100%;
  270. display: flex;
  271. align-items: center;
  272. }
  273. .land-checkbox :deep(.el-checkbox__label) {
  274. font-size: 1.6rem;
  275. font-weight: 600;
  276. color: #1a3c7a;
  277. }
  278. .land-checkbox :deep(.el-checkbox__inner) {
  279. width: 24px;
  280. height: 24px;
  281. }
  282. .land-checkbox :deep(.el-checkbox__inner::after) {
  283. height: 12px;
  284. left: 7px;
  285. width: 6px;
  286. }
  287. .input-label {
  288. font-size: 1.4rem;
  289. font-weight: 600;
  290. margin-bottom: 15px;
  291. color: #2c3e50;
  292. display: flex;
  293. align-items: center;
  294. gap: 12px;
  295. }
  296. :deep(.el-input) .el-input__inner {
  297. height: 60px;
  298. font-size: 1.5rem;
  299. border-radius: 10px;
  300. padding: 0 20px;
  301. border: 2px solid #dcdfe6;
  302. transition: all 0.3s ease;
  303. }
  304. :deep(.el-input) .el-input__inner:focus {
  305. border-color: #409EFF;
  306. box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.2);
  307. }
  308. :deep(.el-input) .el-input__inner:disabled {
  309. background-color: #f5f7fa;
  310. opacity: 0.7;
  311. }
  312. .button-section {
  313. margin: 40px 0 30px;
  314. }
  315. .calculate-btn {
  316. width: 100%;
  317. max-width: 500px;
  318. height: 70px;
  319. border: none;
  320. border-radius: 35px;
  321. font-size: 1.8rem;
  322. font-weight: bold;
  323. transition: all 0.4s ease;
  324. background: linear-gradient(45deg, #1a8cff, #00cc99);
  325. color: white;
  326. box-shadow: 0 6px 15px rgba(26, 140, 255, 0.4);
  327. }
  328. .calculate-btn:hover {
  329. transform: translateY(-3px);
  330. box-shadow: 0 10px 20px rgba(26, 140, 255, 0.5);
  331. background: linear-gradient(45deg, #0d7de0, #00b386);
  332. }
  333. .calculate-btn:active {
  334. transform: translateY(1px);
  335. box-shadow: 0 4px 10px rgba(26, 140, 255, 0.4);
  336. }
  337. .result-section {
  338. text-align: center;
  339. margin-top: 30px;
  340. padding: 30px;
  341. border-radius: 15px;
  342. background: rgba(255, 255, 255, 0.9);
  343. box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  344. border: 2px solid #e0f7fa;
  345. }
  346. .result-title {
  347. font-size: 1.8rem;
  348. color: #1a3c7a;
  349. margin-bottom: 25px;
  350. font-weight: 600;
  351. display: flex;
  352. align-items: center;
  353. justify-content: center;
  354. gap: 15px;
  355. }
  356. .flux-value {
  357. font-size: 3.5rem;
  358. font-weight: 800;
  359. color: #e91e63;
  360. margin: 10px 0;
  361. text-shadow: 0 2px 4px rgba(0,0,0,0.1);
  362. }
  363. .unit {
  364. font-size: 2rem;
  365. color: #555;
  366. font-weight: 600;
  367. margin-left: 10px;
  368. }
  369. .result-description {
  370. font-size: 1.4rem;
  371. color: #555;
  372. margin-top: 15px;
  373. }
  374. </style>