<template>
  <div class="gl-page-content">
    <BaseTable
      v-if="currentModel === '仿真工况'"
      ref="tableRef"
      :searchItems="searchItems"
      :searchParams="{model:'仿真工况'}"
      :api="getTaskListFun"
      :searchLimitNum="3"
      tableName="SIMULATION_TASK_ANALYSIS"
      showIndex
      showCheckbox
      @searchChange="searchChangeFun"
      :checkboxConfig= "{
        checkMethod: ({ row }:any) => {
          return !compareListIds.includes(row.id)
        }
      }"
    >
      <template #leftOptions>
        <el-button type="primary" @click="addCompareListFun">加入对比池</el-button>
        <el-button type="primary" @click="showCompareListFun">查看对比池</el-button>
        <el-button type="primary" @click="compareFun('仿真工况')">对比</el-button>
      </template>
      <template #tableActions>
        <el-link type="primary">查看详情</el-link>
      </template>
    </BaseTable>
    <BaseTable
      v-if="currentModel === '仿真算例'"
      ref="tableRef"
      :searchItems="searchItems"
      :searchParams="{model:'仿真算例'}"
      :api="getRunListFun"
      :searchLimitNum="3"
      tableName="SIMULATION_RUN_ANALYSIS"
      showIndex
      showCheckbox
      @searchChange="searchChangeFun"
      :checkboxConfig= "{
        checkMethod: ({ row }:any) => {
          return !compareListIds.includes(row.id)
        }
      }"
    >
      <template #leftOptions>
        <el-button type="primary" @click="addCompareListFun">加入对比池</el-button>
        <el-button type="primary" @click="showCompareListFun">查看对比池</el-button>
        <el-button type="primary" @click="compareFun('仿真算例')">对比</el-button>
      </template>
      <template #tableActions>
        <el-link type="primary">查看详情</el-link>
      </template>
    </BaseTable>
    <BaseTable
      v-if="currentModel === '数据指标'"
      ref="tableRef"
      :searchItems="searchItems"
      :searchParams="{model:'数据指标'}"
      :api="getPerformanceListFun"
      :searchLimitNum="3"
      tableName="SIMULATION_PERFORMANCE_ANALYSIS"
      showIndex
      showCheckbox
      @searchChange="searchChangeFun"
      :checkboxConfig= "{
        checkMethod: ({ row }:any) => {
          return !compareListIds.includes(row.id)
        }
      }"
    >
      <template #leftOptions>
        <el-button type="primary" @click="addCompareListFun">加入对比池</el-button>
        <el-button type="primary" @click="showCompareListFun">查看对比池</el-button>
        <el-button type="primary" @click="compareFun('数据指标')">对比</el-button>
      </template>
    </BaseTable>
    <BaseTable
      v-if="currentModel === '模型文件'"
      ref="tableRef"
      :searchItems="searchItems"
      :searchParams="{model:'模型文件'}"
      :params="{ fileBizType:1}"
      :api="getSimulationTaskFileFun"
      :searchLimitNum="3"
      tableName="RESULT_MODEL"
      showIndex
      showCheckbox
      @searchChange="searchChangeFun"
      :checkboxConfig= "{
        checkMethod: ({ row }:any) => {
          return !compareListIds.includes(row.id)
        }
      }"
    >
      <template #leftOptions>
        <el-button type="primary" @click="addCompareListFun">加入对比池</el-button>
        <el-button type="primary" @click="showCompareListFun">查看对比池</el-button>
        <el-button type="primary" @click="compareFun('模型文件')">对比</el-button>
      </template>
      <template #tableActions="{row}">
        <el-space>
          <el-link type="primary">预览</el-link>
          <UploadFile v-model="row.id" :name="$t('知识库.下载')" />
        </el-space>
      </template>
    </BaseTable>
    <BaseTable
      v-if="currentModel === '仿真报告'"
      ref="tableRef"
      :searchItems="searchItems"
      :searchParams="{model:'仿真报告'}"
      :params="{ fileBizType:2}"
      :api="getSimulationTaskFileFun"
      :searchLimitNum="3"
      tableName="RESULT_REPORT"
      showIndex
      showCheckbox
      @searchChange="searchChangeFun"
      :checkboxConfig= "{
        checkMethod: ({ row }:any) => {
          return !compareListIds.includes(row.id)
        }
      }"
    >
      <template #leftOptions>
        <el-button type="primary" @click="addCompareListFun">加入对比池</el-button>
        <el-button type="primary" @click="showCompareListFun">查看对比池</el-button>
        <el-button type="primary" @click="compareFun('仿真报告')">对比</el-button>
      </template>
      <template #tableActions="{row}">
        <el-space>
          <el-link type="primary">预览</el-link>
          <UploadFile v-model="row.id" :name="$t('知识库.下载')" />
        </el-space>
      </template>
    </BaseTable>
    <BaseTable
      v-if="currentModel === '计算文件'"
      ref="tableRef"
      :searchItems="searchItems"
      :searchParams="{model:'计算文件'}"
      :params="{ fileBizType:3}"
      :api="getSimulationTaskFileFun"
      :searchLimitNum="3"
      tableName="RESULT_FILE"
      showIndex
      showCheckbox
      @searchChange="searchChangeFun"
      :checkboxConfig= "{
        checkMethod: ({ row }:any) => {
          return !compareListIds.includes(row.id)
        }
      }"
    >
      <template #leftOptions>
        <el-button type="primary" @click="addCompareListFun">加入对比池</el-button>
        <el-button type="primary" @click="showCompareListFun">查看对比池</el-button>
        <el-button type="primary" @click="compareFun('计算文件')">对比</el-button>
      </template>
      <template #tableActions="{row}">
        <el-space>
          <UploadFile v-model="row.id" :name="$t('知识库.下载')" />
        </el-space>
      </template>
    </BaseTable>
    <BaseTable
      v-if="currentModel === '结果曲线'"
      ref="tableRef"
      :searchItems="searchItems"
      :searchParams="{model:'结果曲线'}"
      :params="{ fileBizType:4}"
      :api="getSimulationTaskFileFun"
      :searchLimitNum="3"
      tableName="RESULT_CURVE"
      showIndex
      showCheckbox
      @searchChange="searchChangeFun"
      :checkboxConfig= "{
        checkMethod: ({ row }:any) => {
          return !compareListIds.includes(row.id)
        }
      }"
    >
      <template #leftOptions>
        <el-button type="primary" @click="addCompareListFun">加入对比池</el-button>
        <el-button type="primary" @click="showCompareListFun">查看对比池</el-button>
        <el-button type="primary" @click="compareFun('结果曲线') ">对比</el-button>
      </template>
      <template #tableActions="{row}">
        <el-space>
          <el-link type="primary">预览</el-link>
          <UploadFile v-model="row.id" :name="$t('知识库.下载')" />
        </el-space>
      </template>
    </BaseTable>
    <BaseTable
      v-if="currentModel === '结果云图'"
      ref="tableRef"
      :searchItems="searchItems"
      :searchParams="{model:'结果云图'}"
      :params="{ fileBizType:5}"
      :api="getSimulationTaskFileFun"
      :searchLimitNum="3"
      tableName="RESULT_PNG"
      showIndex
      showCheckbox
      @searchChange="searchChangeFun"
      :checkboxConfig= "{
        checkMethod: ({ row }:any) => {
          return !compareListIds.includes(row.id)
        }
      }"
    >
      <template #leftOptions>
        <el-button type="primary" @click="addCompareListFun">加入对比池</el-button>
        <el-button type="primary" @click="showCompareListFun">查看对比池</el-button>
        <el-button type="primary" @click="compareFun('结果云图') ">对比</el-button>
      </template>
      <template #tableActions="{row}">
        <el-space>
          <el-link type="primary">预览</el-link>
          <UploadFile v-model="row.id" :name="$t('知识库.下载')" />
        </el-space>
      </template>
    </BaseTable>
    <Dialog
      v-model="diaVisible"
      diaTitle="曲线对比"
      :width="'90%'"
      :height="'90%'"
      :confirm-closable="false"
      :zIndex="3000"
    >
      <div class="compare-container">
        <div class="compare-container-left">
          <BaseTable
            ref="tableCompareRef"
            tableName="COMPARE_CURVE"
            showIndex
            showCheckbox
            hidePagination
            :render="renderFun"
            @checkbox-change="checkBoxChangeFun"
            @checkbox-all="checkBoxChangeFun"
            @searchChange="searchChangeFun"
          >
            <template #leftOptions>
              <div class="compare-container-left-options">
                <span>设置列数据：</span>

                <el-input-number v-model="columnData" :min="1" :max="10" />
              </div>

            </template>
            <template #tableActions="{row}">
              <span>图：</span>
              <el-input class="image-number-input" v-model="row.imageNumber" @blur="changeImageNumberFun" />
            </template>
          </BaseTable>
        </div>
        <div class="compare-container-right">
          <div
            class="chart-container"
            :style="{
              gridTemplateColumns: `repeat(${columnData} ,${100 / columnData}%)`

            }"
          >
            <div class="chart-box" v-for="(value,key) in compareData" :key="key" >
              <EchartCard
                :title="`图${key}`"
                :ref="(el) => (projectStorageSpaceStatisticsRef[`chart-${key}`] = el)"
                :charts-id="'chart-' + key"
                :bar-type="'lineChart'"
              >
              </EchartCard>
            </div>
          </div>
        </div>
      </div>
      <template #footer>
        <div>
          <el-button @click="closeFun">关闭</el-button>
        </div>
      </template>
    </Dialog>
    <Dialog
      v-model="diaPngVisible"
      diaTitle="云图对比"
      :width="'90%'"
      :height="'90%'"
      :confirm-closable="false"
      :zIndex="3000"
    >
      <div class="compare-container">
        <div class="compare-container-left">
          <BaseTable
            ref="tableComparePngRef"
            tableName="COMPARE_PNG"
            showIndex
            showCheckbox
            hidePagination
            :render="renderPngFun"
            @checkbox-change="checkBoxPngChangeFun"
          >
            <template #leftOptions>
              <div class="compare-container-left-options">
                <span>设置列数据：</span>

                <el-input-number v-model="columnPngData" :min="1" :max="10" />
              </div>

            </template>

          </BaseTable>
        </div>
        <div class="compare-container-right">
          <div
            class="chart-container"
            :style="{
              gridTemplateColumns: `repeat(${columnPngData} ,${100 / columnPngData}%)`
            }"
          >
            <div class="chart-box-png" v-for="(item,index) in comparePngData" :key="index" >
              <div class="png-container">
                <div class="png-title">{{ item.originalName }}</div>
                <div class="png-image">
                  <el-image :src="item.url" fit="scale-down" />
                </div>
              </div>

            </div>
          </div>
        </div>
      </div>
      <template #footer>
        <div>
          <el-button @click="closePngFun">关闭</el-button>
        </div>
      </template>
    </Dialog>

    <Dialog
      v-model="compareListVisible"
      diaTitle="对比池信息"
      :width="'50%'"
      :height="'50%'"
      :confirm-closable="false"
      :zIndex="3000"
      @close="closeCompareListFun"
    >
      <div class="compare-content">
        <BaseTable
          ref="compareTableRef"
          showIndex
          showCheckbox
          :head="compareListHead"
          :table-name="''"
          :hide-pagination="true"
        >

          <template #operate="{row}">
            <el-button type="danger" link @click="deleteCompareDataFun(row)">删除</el-button>
          </template>
        </BaseTable>
      </div>
    </Dialog>

    <analysisDataDialog v-if="loadcaseAnalysisVisable" @close="closeAnalysisFun" :analysis-data="selectAnalysisData"></analysisDataDialog>

  </div>
</template>
<script setup lang="ts">
import { ref, onMounted, nextTick } from 'vue';
import BaseTable from '@/components/common/table/baseTable.vue';
import { queryNodeListApi, getChildrenNodeListApi } from '@/api/project/node';
import { getSimulationTaskFileApi, getCSVDataApi } from '@/api/data/dataAnalysis';
import { NODE_TYPE } from '@/utils/enum/node';
import { getTaskListApi, getPerformanceListApi, getRunListApi } from '@/api/project/analysis';
import { ElMessage } from 'element-plus';
import Dialog from '@/components/common/dialog/index.vue';
import EchartCard from '@/components/common/echartCard/index.vue';
import { groupBy } from 'lodash-es';
import UploadFile from '@/components/common/uploadFile/index.vue';
import analysisDataDialog from './components/analysisDataDialog.vue';

const tableRef = ref();
const searchChangeFun = ({ data, key, val }:any) => {
  console.log('1740', data, key, val );
  compareList.value = [];
  compareListIds.value = [];
  if (key === 'model') {
    compareList.value = [];
    currentModel.value = val;
  }
  if (val) {
    if (key === 'project') {
      getPhaseOptionsFun();
    }
    if (key === 'phase') {
      getDisciplineOptionsFun();
    }
  } else {
    if (key === 'project') {
      tableRef.value?.setSearchParamByKeyFun('phase', '');
      tableRef.value?.setOptionsFun('phase', []);
    }
    if (key === 'phase') {
      tableRef.value?.setSearchParamByKeyFun('discipline', '');
      tableRef.value?.setOptionsFun('discipline', []);
    }
  }
};

const currentModel = ref('仿真工况');

const projectOptions = ref<any[]>([]);
const phaseOptions = ref<any[]>([]);
const disciplineOptions = ref<any[]>([]);
const searchItems = [
  {
    title: '模块', key: 'model', type: 'select', inputMode: 'select', clearable: false, options: [
      { label: '仿真工况', value: '仿真工况' },
      { label: '仿真算例', value: '仿真算例' },
      { label: '数据指标', value: '数据指标' },
      { label: '模型文件', value: '模型文件' },
      { label: '仿真报告', value: '仿真报告' },
      { label: '计算文件', value: '计算文件' },
      { label: '结果曲线', value: '结果曲线' },
      { label: '结果云图', value: '结果云图' },
    ],

  },

  {
    title: '项目', key: 'project', type: 'select', inputMode: 'select', clearable: true, options: [],
  },
  {
    title: '阶段', key: 'phase', type: 'select', inputMode: 'select', clearable: true, options: [],
  },
  {
    title: '学科', key: 'discipline', type: 'select', inputMode: 'select', clearable: true, options: [],
  },
  { title: '名称', key: 'name', clearable: true, type: 'input', inputMode: 'input' },
  { title: '时间范围', key: 'dateRange', clearable: true, inputMode: 'daterange' },

];

const getProjectOptionsFun = () => {
  queryNodeListApi({ current: 1, size: 999, nodeType: NODE_TYPE.PROJECT }).then((res: any) => {
    console.log(res);
    if (res.code === 200) {
      projectOptions.value = res.data.data.map((item: any) => {
        return {
          label: item.nodeName,
          value: item.uuid,
          uuid: item.uuid,
        };
      });
      tableRef.value?.setOptionsFun( NODE_TYPE.PROJECT, projectOptions.value );
    }
  });
};
const getPhaseOptionsFun = () => {
  const projectId = tableRef.value?.getSearchParamByKeyFun('project');
  console.log('1440', projectId);
  getChildrenNodeListApi({ current: 1, size: 999, nodeType: NODE_TYPE.PHASE, nodeId: projectId }).then((res: any) => {
    console.log(res);
    if (res.code === 200) {
      phaseOptions.value = res.data?.map((item: any) => {
        return {
          label: item.nodeName,
          value: item.uuid,
          uuid: item.uuid,
        };
      });
      tableRef.value?.setOptionsFun( NODE_TYPE.PHASE, phaseOptions.value );
    }
  });
};
const getDisciplineOptionsFun = () => {
  const phaseId = tableRef.value?.getSearchParamByKeyFun('phase');
  queryNodeListApi({ current: 1, size: 999, nodeType: 'discipline', pid: phaseId }).then((res: any) => {
    console.log(res);
    if (res.code === 200) {
      disciplineOptions.value = res.data.data.map((item: any) => {
        return {
          label: item.nodeName,
          value: item.uuid,
          uuid: item.uuid,
        };
      });
      tableRef.value?.setOptionsFun( 'discipline', disciplineOptions.value );
    }
  });
};
const compareList = ref<any[]>([]);
const addCompareListFun = () => {
  const selectedRows = tableRef.value?.tableRef?.getCheckboxRecords();
  if (selectedRows && selectedRows.length > 0) {
    selectedRows.forEach((item: any) => {
      if (!compareList.value.some((val: any) => val.id === item.id)) {
        compareList.value.push(item);
      }
    });
    ElMessage.success('添加成功');
  } else {
    ElMessage.warning('请先选择要对比的数据');
  }

  compareListIds.value = compareList.value.map((item:any) => {return item.id;});
  tableRef.value?.tableRef?.clearCheckboxRow();
};

const diaVisible = ref<boolean>(false);
const closeFun = () => {
  diaVisible.value = false;
};
const displayCompareFun = (flag:any) => {
  if (!compareList.value.length) {
    ElMessage.warning('请先加入对比池');
    return;
  }
  if (flag === '结果曲线') {
    diaVisible.value = true;
  } else {
    diaPngVisible.value = true;

  }
};
const columnData = ref<number>(1);
const renderFun = (data: any, render: (cbData: any) => void) => {
  render(compareList.value.map((item:any) => {
    return {
      ...item,
      name: item.originalName,
      imageNumber: 1,
    };
  }));
};
const tableCompareRef = ref();
const compareData = ref<any>({});
const projectStorageSpaceStatisticsRef = ref<any>({});
// 初始化图表chart-1
const initProjectTaskAchievementStatistics = async ({ dom, seriesData, titleList, key }:any) => {
  dom.commonChartRef.disposeEchartsByKey('chart-' + key);
  dom.commonChartRef.option = {
    title: {
      show: false,
    },
    tooltip: {
      trigger: 'axis',
    },
    legend: {
      top: '0%',
      left: 'center',
      data: titleList,
    },
    grid: {
      top: '10%',
      bottom: '10%',
      left: '5%',
      right: '5%',
    },
    xAxis: {
      type: 'category',
    },
    yAxis: {
      type: 'value',
    },
    series: seriesData,
    // dataZoom:
    //   projectNames.length > 4
    //     ? [
    //       {
    //         type: 'slider',
    //         show: true,
    //         xAxisIndex: [0],
    //         start: 0,
    //         end: 100,
    //         textStyle: {
    //           color: 'transparent',
    //         },
    //         maxValueSpan: 4,
    //         minValueSpan: 4,
    //         moveHandleSize: 10,
    //         height: 0,
    //         filterMode: 'empty',
    //         bottom: 15,
    //       },
    //     ]
    //     : null,

  };
  dom.commonChartRef.initChart();
};
const setChartFun = () => {
  const selectedRows = tableCompareRef.value?.tableRef?.getCheckboxRecords();
  if (selectedRows.length) {
    compareData.value = groupBy(selectedRows, 'imageNumber');
    nextTick(() => {
      for (const key in compareData.value) {
        getCSVDataApi({ fileId: compareData.value[key].map((item:any) => item.id).join(',') }).then((res:any) => {
          const seriesData:any = [];
          const titleList:any = [];
          if (res.code === 200) {
            res.data.xData.forEach((item:any, index:number) => {
              const data = res.data.xData[index].map((item_1:any, index_1:number) => {
                return [item_1, res.data.yData[index][index_1]];
              });
              const title = compareData.value[key][index].originalName;
              titleList.push(title);
              seriesData.push({
                name: title,
                type: 'line',
                stack: 'Total',
                data,
              });
            });
          }
          console.log('1030', res);

          initProjectTaskAchievementStatistics({ dom: projectStorageSpaceStatisticsRef.value[`chart-${key}`], seriesData, titleList, key });
        });
      }
    });
  }
};
const checkBoxChangeFun = () => {
  setChartFun();
};
const changeImageNumberFun = () => {
  setChartFun();
};
const tableComparePngRef = ref();

const diaPngVisible = ref<boolean>(false);
const compareListIds = ref<any[]>([]);
const columnPngData = ref<number>(1);
const comparePngData = ref<any>([]);
const closePngFun = () => {
  diaPngVisible.value = false;
};

// const displayComparePngFun = () => {
//   if (!compareList.value.length) {
//     ElMessage.warning('请先加入对比池');
//     return;
//   }
//   diaPngVisible.value = true;
// };
const renderPngFun = (data: any, render: (cbData: any) => void) => {
  render(compareList.value.map((item:any) => {
    return {
      ...item,
      name: item.originalName,
    };
  }));
};
const env = import.meta.env;
const checkBoxPngChangeFun = () => {
  comparePngData.value = tableComparePngRef.value?.tableRef?.getCheckboxRecords();
  comparePngData.value.forEach((item:any) => {
    item.url = `${env.VITE_API_IMAGE_PREVIEW_URL}/data/previewImage?fileId=${item.id}`;
  });
};

const loadcaseAnalysisVisable = ref(false);

const selectAnalysisData = ref<any>({});

const openDataAnalysisFun = (flag:any, tableName:any) => {
  selectAnalysisData.value = {
    flag,
    data: compareList.value,
    tableName,
  };
  loadcaseAnalysisVisable.value = true;
};

const closeAnalysisFun = () => {
  loadcaseAnalysisVisable.value = false;

};

const compareFun = (flag:any) => {

  if (!compareList.value.length) {
    ElMessage.warning('对比池为空，无法对比');
    return;
  }
  if (flag === '仿真工况') {
    openDataAnalysisFun( flag, 'SIMULATION_TASK_ANALYSIS');
  }
  if (flag === '仿真算例') {
    openDataAnalysisFun( flag, 'SIMULATION_RUN_ANALYSIS');

  }
  if (flag === '数据指标') {
    openDataAnalysisFun( flag, 'SIMULATION_PERFORMANCE_ANALYSIS');

  }
  if (flag === '模型文件') {
    openDataAnalysisFun( flag, 'RESULT_MODEL');

  }
  if (flag === '仿真报告') {
    openDataAnalysisFun( flag, 'RESULT_REPORT');

  }
  if (flag === '计算文件') {
    openDataAnalysisFun( flag, 'RESULT_FILE');

  }
  if (flag === '结果曲线') {
    // openDataAnalysisFun( flag, 'RESULT_CURVE');

    displayCompareFun('结果曲线');
  }
  if (flag === '结果云图') {
    // openDataAnalysisFun( flag, 'RESULT_PNG');

    displayCompareFun('结果云图');
  }
};

const compareListHead = ref([
  {
    title: '对比名称',
    key: 'compareName',
    isShow: true,
  },
  {
    title: '对比类型',
    key: 'compareType',
    isShow: true,
  },
  {
    title: '操作',
    key: 'operate',
    isShow: true,
  },
]);

const compareListVisible = ref(false);
const compareTableRef = ref();
// 查看对比池
const showCompareListFun = () => {

  for (let i = 0;i < compareList.value.length;i++) {

    let compareName:any = '';
    if (currentModel.value === '仿真工况') {
      compareName = compareList.value[i].taskName;
    }
    else if (currentModel.value === '仿真算例') {
      compareName = compareList.value[i].runName;
    }
    else if (currentModel.value === '数据指标') {
      compareName = compareList.value[i].performanceName;
    }
    else if (currentModel.value === '模型文件') {
      compareName = compareList.value[i].performanceName;
    } else {
      compareName = compareList.value[i].fileName;

    }

    compareList.value[i].compareName = compareName;
    compareList.value[i].compareType = currentModel.value;

  }

  console.log(compareList.value, 'compareList.value');

  compareListVisible.value = true;
  nextTick(() => {
    compareTableRef.value?.setDataFun(compareList.value);
  });
};

const closeCompareListFun = () => {
  compareListVisible.value = false;

};

// 删除对比元素
const deleteCompareDataFun = (data:any) => {
  compareList.value = compareList.value.filter((item:any) => {
    return item.id != data.id;
  });
  compareListIds.value = compareList.value.map((item:any) => {return item.id;});
  nextTick(() => {
    compareTableRef.value?.setDataFun(compareList.value);
  });
};

const getSimulationTaskFileFun = async (param:any) => {
  const params:any = {
    ...param,
  };

  if (params?.project) {
    params.uuid = projectOptions.value.find((item:any) => {
      return item.value === params.project;
    })?.uuid;
  }

  if (params?.phase) {
    params.uuid = phaseOptions.value.find((item:any) => {
      return item.value === params.phase;
    })?.uuid;
  }

  if (params?.discipline) {
    params.uuid = disciplineOptions.value.find((item:any) => {
      return item.value === params.discipline;
    })?.uuid;
  }

  // if (params?.dateRange) {
  //   params.beginTime = params?.dateRange[0];
  //   params.endTime = params?.dateRange[1];
  //   delete params?.dateRange;
  // }

  const res:any = await getSimulationTaskFileApi(params);
  if (res && res.code === 200) {
    return res;
  }

};

const getTaskListFun = async (param:any) => {

  console.log(param, 'param');

  const params:any = {
    ...param,
  };
  setParamFun(params);
  const res:any = await getTaskListApi(params);
  return res;

};

const getRunListFun = async (param:any) => {
  const params:any = {
    ...param,
  };
  setParamFun(params);
  const res:any = await getRunListApi(params);
  return res;

};

const getPerformanceListFun = async (param:any) => {
  const params:any = {
    ...param,
  };
  setParamFun(params);
  const res:any = await getPerformanceListApi(params);
  return res;

};

const setParamFun = (params:any) => {
  if (params?.project) {
    params.projectNodeId = params?.project;
    delete params.project;
  }
  if (params?.phase) {
    params.phaseNodeId = params?.phase;
    delete params.phase;
  }
  if (params?.discipline) {
    params.disciplineNodeId = params?.discipline;
    delete params.discipline;
  }
  if (params?.dateRange) {
    params.beginTime = params?.dateRange[0];
    params.endTime = params?.dateRange[1];
    delete params?.dateRange;
  }
};

onMounted(() => {
  getProjectOptionsFun();
});
</script>
<style lang="scss" scoped>
.gl-page-content {

  .content {
    height: 100%;
  }
}
:deep(.compare-container){
  height: 100%;
  width: 100%;
  display:flex;
  justify-content: space-between;
  .compare-container-left{
    height: 100%;
    width: 49%;
    .compare-container-left-options{
      display:flex;
      align-items: center;
      &>span{
        white-space: nowrap;
      }
    }
  }
  .compare-container-right{
    height: 100%;
    width: 50%;
    .image-number-input{
      width: 50px;
    }
    .chart-container{
      height: 100%;
      width: 100%;
      overflow-y: auto;
      display: grid;
      .chart-box{
        height: 350px;
        width:100%;

      }
      .chart-box-png{
        height: 50%;
        width:100%;
       .png-container{
        height: 100%;
        width: 100%;
        display: flex;
        flex-direction: column;
        .png-title{
          margin-bottom: 12px;
          width: 100%;
        }
        .png-image{
          flex:1;
          width: 100%;
          .el-image{
            height: 100%;
            width: 100%;
          }
        }
       }
      }
    }
  }
}

.compare-content{
  width: 100%;
  height: 100%;
}
</style>
