修改后端API,完成天然气差压式计算,

This commit is contained in:
廖德云 2025-02-24 23:58:53 +08:00
parent 399b0456d0
commit 150d195f23
3 changed files with 48 additions and 6 deletions

View File

@ -3,7 +3,18 @@ import request from '@/utils/request'
// 天然气物性参数计算
export function calcNGPar(data) {
return request({
url: '/NGCalcTools/calculate',
url: '/NGCalcTools/ngCalc',
method: 'post',
data: data,
headers: {
'Content-Type': 'application/json'
}
})
}
// 天然气物性参数计算
export function calcFlow(data) {
return request({
url: '/flowCalcTools/flowCalc',
method: 'post',
data: data,
headers: {

View File

@ -111,6 +111,7 @@ export default {
const result = this.calculateSum(newVal);
this.sumzf = result.sum;
const valuesStr = result.valuesStr;
console.log(this.sumzf, valuesStr);
const diff = Math.abs(this.sumzf - 100);
if (diff < 0.0001) {
this.$emit('update:strZf', valuesStr);

View File

@ -1,7 +1,8 @@
<template>
<div>
<div>
<button @click="calc">计算组分参数</button>
<button @click="calc" type="primary" class="animated-button">计算组分参数</button>
<button @click="calcFlow" type="primary" class="animated-button">计算流量</button>
</div>
<el-tabs v-model="activeTab">
@ -10,7 +11,7 @@
</el-tab-pane>
<el-tab-pane label="天然气组分" name="ngComponents">
<ngComponents v-model="componentString" />
<ngComponents v-model="parentMeterPar.dngComponents" />
</el-tab-pane>
<el-tab-pane label="流量计算结果" name="meterresult">
<meterResult v-model:meterResult="parentMeterResult" />
@ -24,7 +25,7 @@ import meterPar from '@/components/NGTools/meterPar';
import ngComponents from '@/components/NGTools/NGCom';
import meterResult from '@/components/NGTools/meterResult';
import { calcNGPar } from '@/api/ngtools/NGCalcTools.js';
import { calcNGPar, calcFlow } from '@/api/ngtools/NGCalcTools.js';
export default {
name: 'TabbedComponentWrapper',
@ -46,7 +47,7 @@ export default {
dtbE: 0,
dPatm: 0.101325,
dPatmUnit: 2,
dngComponents: this.componentString,
dngComponents: '',
dMeterType: '0',
dCoreType: '0',
dPtmode: '0',
@ -129,11 +130,40 @@ export default {
.catch((error) => {
console.error('Request error:', error);
});
},
calcFlow() {
console.log(this.parentMeterPar);
calcFlow(this.parentMeterPar)
.then((res) => {
console.log('Response:', res);
})
.catch((error) => {
console.error('Request error:', error);
});
}
}
};
</script>
<style scoped>
/* 可按需添加样式 */
.animated-button {
background-color: #007bff;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
margin-right: 10px;
transition: background-color 0.3s ease;
}
.animated-button:last-child {
margin-right: 0;
}
.animated-button:hover {
background-color: #0056b3;
transform: scale(1.05);
}
.animated-button:active {
transform: scale(0.95);
}
</style>