|
@@ -5,12 +5,173 @@
|
|
|
<template #header>
|
|
|
<span>迭代曲线</span>
|
|
|
</template>
|
|
|
-
|
|
|
+ <div class="content">
|
|
|
+ <div class="content-top">
|
|
|
+ <el-form class="custom-form" :label-width="Labelwidth" label-position="left">
|
|
|
+ <el-form-item :label="lineName">
|
|
|
+ <el-row :gutter="5">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-select v-model="lineOption.linetype1" size="small">
|
|
|
+ <el-option
|
|
|
+ v-for="item in option1"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-select v-model="lineOption.linetype2" size="small">
|
|
|
+ <el-option
|
|
|
+ v-for="item in option2"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div class="content-bottom">
|
|
|
+ <echartline :key="ChartKey" :chartData="chartdata" xLabel="Step" yLabel="Value" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</el-card>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
+import { request, enPassword } from "@/utils/request";
|
|
|
+import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
+import { useProjectStore } from '@/store/project'
|
|
|
|
|
|
+import echartline from "../echarts/echartline.vue";
|
|
|
|
|
|
-</script>
|
|
|
+const projectStore = useProjectStore()
|
|
|
+const pid = computed(() => projectStore.pid)
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ type: {
|
|
|
+ type: Number,
|
|
|
+ default:0
|
|
|
+ },
|
|
|
+})
|
|
|
+
|
|
|
+const Labelwidth = '90px'
|
|
|
+
|
|
|
+const lineName = ref('选择曲线数据')
|
|
|
+
|
|
|
+const lineOption = ref({
|
|
|
+ linetype1:'ScipyOptimize_SLSQP',
|
|
|
+ linetype2:'twist_cp'
|
|
|
+})
|
|
|
+
|
|
|
+const option1 = ref([
|
|
|
+ {label: 'ScipyOptimize_SLSQP',value: 'ScipyOptimize_SLSQP'},
|
|
|
+ {label: 'DOEDriver_LatinHypercube',value: 'DOEDriver_LatinHypercube'}
|
|
|
+])
|
|
|
+
|
|
|
+const option2 = ref([
|
|
|
+ {label: '扭转分布',value: 'twist_cp'},
|
|
|
+ {label: '厚度分布',value: 'thickness_cp'},
|
|
|
+ {label: '升力系数',value: 'CL'},
|
|
|
+ {label: '阻力系数',value: 'CD'},
|
|
|
+ {label: '失效应力',value: 'failure'},
|
|
|
+ {label: '结构质量',value: 'structural_mass'},
|
|
|
+ {label: '燃油消耗',value: 'fuelburn'},
|
|
|
+])
|
|
|
+
|
|
|
+const lineData = ref({})
|
|
|
+const ChartKey = ref(0)
|
|
|
+const chartdata = computed(() => {
|
|
|
+ const l1 = lineOption.value.linetype1
|
|
|
+ const l2 = lineOption.value.linetype2
|
|
|
+ if (lineData.value[l1] && lineData.value[l1][l2]) {
|
|
|
+ return lineData.value[l1][l2]
|
|
|
+ }
|
|
|
+ return []
|
|
|
+})
|
|
|
+
|
|
|
+const getlineData = () => {
|
|
|
+ const params = {
|
|
|
+ transCode: 'AC00010',
|
|
|
+ pid: pid.value,
|
|
|
+ type: props.type
|
|
|
+ }
|
|
|
+ request(params)
|
|
|
+ .then((res) => {
|
|
|
+ console.log('曲线数据', res.rankeys)
|
|
|
+
|
|
|
+ lineData.value = {}
|
|
|
+
|
|
|
+ // 遍历处理每个 rankey 数据
|
|
|
+ res.rankeys.forEach(item => {
|
|
|
+ const processed = processData(item);
|
|
|
+ // 将处理后的数据合并到 lineData.value 中
|
|
|
+ Object.assign(lineData.value, processed);
|
|
|
+ })
|
|
|
+
|
|
|
+ console.log('解析曲线数据', lineData.value)
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ ElMessage.error(err.returnMsg || "曲线数据获取失败");
|
|
|
+ console.error(err);
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 修改处理函数
|
|
|
+function processData(data) {
|
|
|
+ const result = {};
|
|
|
+ const mainKey = data.rankey;
|
|
|
+
|
|
|
+ result[mainKey] = {};
|
|
|
+
|
|
|
+ data.keys.forEach(item => {
|
|
|
+ try {
|
|
|
+ const parsedData = JSON.parse(item.svJson);
|
|
|
+ result[mainKey][item.key] = parsedData;
|
|
|
+ } catch (error) {
|
|
|
+ console.error(`解析 ${item.key} 的JSON数据时出错:`, error);
|
|
|
+ result[mainKey][item.key] = [];
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+// 监听 chartdata 的变化
|
|
|
+watch(chartdata, () => {
|
|
|
+ ChartKey.value++ // 每次数据变动,强制刷新 echartline 组件
|
|
|
+})
|
|
|
+
|
|
|
+//监听type变化
|
|
|
+watch(
|
|
|
+ () => props.type,
|
|
|
+ (newVal) => {
|
|
|
+ ChartKey.value++;
|
|
|
+ getlineData();
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getlineData();
|
|
|
+});
|
|
|
+
|
|
|
+defineExpose({getlineData})
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.content {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+}
|
|
|
+
|
|
|
+.content-bottom {
|
|
|
+ flex: 1;
|
|
|
+}
|
|
|
+
|
|
|
+</style>
|