feat: 优化计算结果展示并添加交直流标识
在参数表单中重新排列计算结果和日志组件的位置,将跳闸率显示格式化为4位小数并添加单位。同时在后端日志中添加交直流标识输出,并自动根据电压等级更新ac_or_dc字段。
This commit is contained in:
1
main.py
1
main.py
@@ -152,6 +152,7 @@ def run_egm(para: Parameter) -> dict:
|
||||
logger.info(f"挂点处保护角{shield_angle_at_avg_height:.3f}°")
|
||||
logger.debug(f"最低相防护标识{rg_type}。(g表示地面,c表示下导线)")
|
||||
rated_voltage = para.rated_voltage
|
||||
logger.info(f"交、直流标识{para.ac_or_dc}")
|
||||
for u_bar in range(voltage_n): # 计算不同工作电压下的跳闸率
|
||||
if para.ac_or_dc=="AC":
|
||||
# TODO 需要区分交、直流
|
||||
|
||||
@@ -318,10 +318,7 @@
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
<!-- 运行日志 -->
|
||||
<LogComponent ref="logRef" />
|
||||
|
||||
<!-- 计算结果 -->
|
||||
<!-- 计算结果 -->
|
||||
<q-card v-if="result" class="q-mt-md shadow-2 bg-green-50">
|
||||
<q-card-section class="bg-green-100">
|
||||
<div class="text-h6 text-green-900 flex items-center gap-2">
|
||||
@@ -330,8 +327,8 @@
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<div class="text-body1">
|
||||
<div class="q-mb-sm"><strong>跳闸率:</strong>{{ result.tripping_rate }}</div>
|
||||
<div class="text-body1 result-text">
|
||||
<div class="q-mb-sm"><strong>跳闸率:</strong>{{ result.tripping_rate.toFixed(4) }} 次/(100km·a)</div>
|
||||
<div v-if="result.n_sf_phases && result.n_sf_phases.length > 0" class="q-mb-sm">
|
||||
<strong>各导线跳闸率:</strong>
|
||||
<span v-for="(rate, index) in result.n_sf_phases" :key="index" class="q-mr-md">
|
||||
@@ -342,6 +339,10 @@
|
||||
</div>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
<!-- 运行日志 -->
|
||||
<LogComponent ref="logRef" />
|
||||
|
||||
</div>
|
||||
</q-page>
|
||||
</q-page-container>
|
||||
@@ -382,7 +383,7 @@ const defaultParams: AllParameters = {
|
||||
|
||||
const params = reactive<AllParameters>(JSON.parse(JSON.stringify(defaultParams)))
|
||||
const calculating = ref(false)
|
||||
const result = ref<{ tripping_rate: string; n_sf_phases: number[]; message: string } | null>(null)
|
||||
const result = ref<{ tripping_rate: number; n_sf_phases: number[]; message: string } | null>(null)
|
||||
const error = ref<string | null>(null)
|
||||
const logRef = ref<InstanceType<typeof LogComponent> | null>(null)
|
||||
const fileInput = ref<HTMLInputElement | null>(null)
|
||||
@@ -397,6 +398,15 @@ const currentType = computed(() => {
|
||||
return params.parameter.rated_voltage.includes('±') ? 'DC' : 'AC'
|
||||
})
|
||||
|
||||
// 监听电压等级变化,同步更新 ac_or_dc 字段
|
||||
watch(
|
||||
() => params.parameter.rated_voltage,
|
||||
(newVoltage) => {
|
||||
params.parameter.ac_or_dc = newVoltage.includes('±') ? 'DC' : 'AC'
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
// 雷暴日与地闪密度相互转换,公式:ng = 0.023 * td^3
|
||||
// 标志位避免循环更新
|
||||
let isUpdatingFromWatch = false
|
||||
@@ -495,7 +505,7 @@ const calculate = async () => {
|
||||
logRef.value?.addLog('info', '参数: 额定电压=750kV, 雷暴日=20d, 海拔=1000m')
|
||||
logRef.value?.addLog('info', '计算完成')
|
||||
result.value = {
|
||||
tripping_rate: '0.0581 次/(100km·a)',
|
||||
tripping_rate: 0.0581,
|
||||
n_sf_phases: [0.0421, 0.0581, 0.0392],
|
||||
message: '计算完成'
|
||||
}
|
||||
@@ -731,7 +741,7 @@ onMounted(() => {
|
||||
calculating.value = false
|
||||
if (res.success && res.data) {
|
||||
result.value = {
|
||||
tripping_rate: res.data.tripping_rate || '',
|
||||
tripping_rate: res.data.avr_n_sf || 0,
|
||||
n_sf_phases: res.data.n_sf_phases || [],
|
||||
message: res.message || '计算完成'
|
||||
}
|
||||
@@ -749,4 +759,8 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.result-text {
|
||||
user-select: text;
|
||||
cursor: text;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user