<!--
 * @Author: your name
 * @Date: 2024-12-09 16:24:28
 * @LastEditTime: 2025-06-25 15:30:18
 * @LastEditors: bogon
 * @Description: In User Settings Edit
 * @FilePath: /performance-test/src/views/laserRangeFinder/components/descrBox.vue
-->
<template>
  <div class="data-origin">
    <div class="descrBox">
      <el-descriptions
        class="margin-top"
        title="叶片角度偏差"
        :column="2"
        border
      >
        <el-descriptions-item label="叶片1" label-width="120" width="100px">
          <template #label>
            <div>叶片1</div>
            <div>角度偏差(°)</div>
          </template>

          {{
            currentRow &&
            currentRow.pitch_angle_diff &&
            currentRow.pitch_angle_diff.blade_1.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="叶片2" label-width="120" width="100px">
          <template #label>
            <div>叶片2</div>
            <div>角度偏差(°)</div>
          </template>
          {{
            currentRow &&
            currentRow.pitch_angle_diff &&
            currentRow.pitch_angle_diff.blade_2.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="叶片3" label-width="120" width="100px">
          <template #label>
            <div>叶片3</div>
            <div>角度偏差(°)</div>
          </template>
          {{
            currentRow &&
            currentRow.pitch_angle_diff &&
            currentRow.pitch_angle_diff.blade_3.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="相对" label-width="120" width="100px">
          <template #label>
            <div>相对</div>
            <div>角度偏差(°)</div>
          </template>
          {{
            currentRow &&
            currentRow.pitch_angle_diff &&
            currentRow.pitch_angle_diff.blade_relate.toFixed(2)
          }}
        </el-descriptions-item>
      </el-descriptions>
      <el-descriptions
        class="margin-top aero"
        title="叶片净空值"
        :column="2"
        border
      >
        <el-descriptions-item label="叶片1" label-width="120" :rowspan="4">
          <template #label>
            <div class="sss">叶片1</div>
            <div>净空值(m)</div>
          </template>
        </el-descriptions-item>
        <el-descriptions-item label="最小值/对应转速" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.first_blade &&
            currentRow.aero_dist.first_blade.y_min.toFixed(2)
          }}
          /
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.first_blade &&
            currentRow.aero_dist.first_blade.x_min.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="最大值/对应转速" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.first_blade &&
            currentRow.aero_dist.first_blade.y_max.toFixed(2)
          }}
          /
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.first_blade &&
            currentRow.aero_dist.first_blade.x_max.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="差值" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.first_blade &&
            currentRow.aero_dist.first_blade.y_diff.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="平均值" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.first_blade &&
            currentRow.aero_dist.first_blade.y_ava.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="叶片2" label-width="120" :rowspan="4">
          <template #label>
            <div>叶片2</div>
            <div>净空值(m)</div>
          </template>
          <!-- {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.blade_2.toFixed(2)
          }} -->
        </el-descriptions-item>
        <el-descriptions-item label="最小值/对应转速" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.second_blade &&
            currentRow.aero_dist.second_blade.y_min.toFixed(2)
          }}
          /
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.second_blade &&
            currentRow.aero_dist.second_blade.x_min.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="最大值/对应转速" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.second_blade &&
            currentRow.aero_dist.second_blade.y_max.toFixed(2)
          }}
          /
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.second_blade &&
            currentRow.aero_dist.second_blade.x_max.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="差值" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.second_blade &&
            currentRow.aero_dist.second_blade.y_diff.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="平均值" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.second_blade &&
            currentRow.aero_dist.second_blade.y_ava.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="叶片3" label-width="120" :rowspan="4">
          <template #label>
            <div>叶片3</div>
            <div>净空值(m)</div>
          </template>
          <!-- {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.blade_3.toFixed(2)
          }} -->
        </el-descriptions-item>
        <el-descriptions-item label="最小值/对应转速" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.third_blade &&
            currentRow.aero_dist.third_blade.y_min.toFixed(2)
          }}
          /
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.third_blade &&
            currentRow.aero_dist.third_blade.x_min.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="最大值/对应转速" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.third_blade &&
            currentRow.aero_dist.third_blade.y_max.toFixed(2)
          }}
          /
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.third_blade &&
            currentRow.aero_dist.third_blade.x_max.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="差值" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.third_blade &&
            currentRow.aero_dist.third_blade.y_diff.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="平均值" label-width="140">
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.third_blade &&
            currentRow.aero_dist.third_blade.y_ava.toFixed(2)
          }}
        </el-descriptions-item>
        <!-- <el-descriptions-item label="平均" label-width="120" >
          <template #label>
            <div>平均</div>
            <div>净空值(m)</div>
          </template>
          {{
            currentRow &&
            currentRow.aero_dist &&
            currentRow.aero_dist.blade_avg.toFixed(2)
          }}
        </el-descriptions-item> -->
      </el-descriptions>
      <el-descriptions
        class="margin-top"
        title="叶片扭转变形"
        :column="2"
        border
      >
        <el-descriptions-item label="叶片1" label-width="120" width="10px">
          <template #label class="label-row">
            <div class="label-row">叶片1</div>
            <div>扭转角(°)</div>
          </template>
          {{
            currentRow &&
            currentRow.blade_twist &&
            currentRow.blade_twist.blade_1.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="叶片2" label-width="120">
          <template #label>
            <div>叶片2</div>
            <div>扭转角(°)</div>
          </template>
          {{
            currentRow &&
            currentRow.blade_twist &&
            currentRow.blade_twist.blade_2.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="叶片3" label-width="120" width="100px">
          <template #label>
            <div>叶片3</div>
            <div>扭转角(°)</div>
          </template>
          {{
            currentRow &&
            currentRow.blade_twist &&
            currentRow.blade_twist.blade_3.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="平均" label-width="120" width="100px">
          <template #label>
            <div>平均</div>
            <div>扭转角(°)</div>
          </template>
          {{
            currentRow &&
            currentRow.blade_twist &&
            currentRow.blade_twist.blade_avg.toFixed(2)
          }}
        </el-descriptions-item>
      </el-descriptions>
      <el-descriptions class="margin-top" title="塔筒振动" :column="2" border>
        <el-descriptions-item label="塔筒" label-width="120" width="100px">
          <template #label>
            <div>塔筒</div>
            <div>振动幅值(mm)</div>
          </template>
          {{
            currentRow &&
            currentRow.tower_vibration &&
            currentRow.tower_vibration.max_vibration.toFixed(2)
          }}
        </el-descriptions-item>
        <el-descriptions-item label="叶片2" label-width="120" width="100px">
          <template #label>
            <div>塔筒</div>
            <div>振动主频(Hz)</div>
          </template>
          {{
            currentRow &&
            currentRow.tower_vibration &&
            currentRow.tower_vibration.main_vibration_freq.toFixed(2)
          }}
        </el-descriptions-item>
      </el-descriptions>
    </div>
    <!-- <el-table
      ref="singleTable"
      :data="tableData"
      :current-row-key="currentIndex"
      @current-change="handleCurrentChange"
      highlight-current-row
      style="width: 100%"
      :max-height="type === 'init' ? '570' : '900'"
    >
      <el-table-column type="index" label="序号" width="60"> </el-table-column>
      <el-table-column prop="address" label="场站" min-width="120">
        <template slot-scope="scope">
          {{ windName }}
        </template>
      </el-table-column>
      <el-table-column prop="address" label="风机">
        <template slot-scope="scope">
          {{ windTurbineName }}
        </template>
      </el-table-column>
      <el-table-column min-width="160" prop="acquisitionTime" label="时间">
      </el-table-column>
      <el-table-column
        min-width="160"
        prop="bladeCollectionFrequency"
        label="叶片采集频率Hz"
      >
      </el-table-column>
      <el-table-column
        min-width="160"
        prop="towerCollectionFrequency"
        label="塔筒采集频率Hz"
      >
      </el-table-column>
    </el-table> -->
  </div>
</template>
<script>
export default {
  props: {
    type: "",
    tableData: [],
    currentRow: {
      type: Object,
      default: () => ({}), // 用于存储当前选中的行
    },
    currentIndex: 0,
    windName: "",
    windTurbineName: "",
  },
  data() {
    return {};
  },
  watch: {
    windName(newVal, oldVal) {
      console.log(newVal, oldVal, "newVal,oldVal");
    },
    windTurbineName(newVal, oldVal) {
      console.log(newVal, oldVal, "newVal,oldVal");
    },
  },
  methods: {
    setCurrent(row) {
      this.$nextTick(() => {
        if (this.$refs.singleTable) {
          this.$refs.singleTable.setCurrentRow(row); // 设置当前行
        } else {
          console.warn("Cannot access $refs.singleTable: it's undefined.");
        }
      });
    },
    handleCurrentChange(val) {
      const index = this.tableData.indexOf(val); // 获取当前选中行的索引
      if (this.type === "init") {
        this.$emit("handleInitCurrentChange", val, index);
      } else if (this.type === "copy") {
        this.$emit("handleCopyCurrentChange", val, index);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.data-origin {
  width: 100%;
  //   box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  .descrBox {
    margin: 20px;
    ::v-deep .el-descriptions__header {
      margin: 10px !important;
    }
    ::v-deep .el-descriptions-item__cell {
      color: #666 !important;
    }
  }
}

:deep(
    .aero .el-descriptions__table > tbody > tr:first-child > td:nth-child(2)
  ) {
  display: none;
}
:deep(
    .aero .el-descriptions__table > tbody > tr:nth-child(5) > td:nth-child(2)
  ) {
  display: none;
}
:deep(
    .aero .el-descriptions__table > tbody > tr:nth-child(9) > td:nth-child(2)
  ) {
  display: none;
}
</style>
