<template>
  <div class="icingBox">
    <div class="icingContain">
      <leftTree ref="sideTree"></leftTree>
      <div class="rightTable">
        <div class="dataBox">
          <div class="childBox">
            <div class="searchBox" ref="searchref">
              <el-form
                :inline="true"
                :model="formdata"
                class="demo-form-inline"
              >
                <el-form-item label="开始日期">
                  <el-date-picker
                    v-model="formdata.starttime"
                    type="date"
                    placeholder="开始日期"
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="结束日期">
                  <el-date-picker
                    @change="changedate"
                    v-model="formdata.endtime"
                    type="date"
                    placeholder="结束日期"
                    class="ml10"
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="onSubmit">查询</el-button>
                </el-form-item>
                <el-form-item>
                  <el-button
                    type="primary"
                    @click="exportExcl"
                    v-if="termalFlag"
                    >导出数据</el-button
                  >
                </el-form-item>
                <el-form-item v-if="termalFlag">
                  <el-button
                    v-if="!echartsShow"
                    type="primary"
                    @click="lookLineCharts"
                    >曲线图</el-button
                  >
                  <el-button
                    v-if="echartsShow"
                    type="primary"
                    @click="lookTableCharts"
                    >列表数据</el-button
                  >
                </el-form-item>
              </el-form>
            </div>
            <div class="childTableShowBox" v-if="!echartsShow">
              <el-table
                v-if="!gantatable"
                :data="tableData"
                style="width: 100%"
                v-loading="loading"
                height="calc(100% - 0px)"
              >
                <el-table-column
                  prop="cmdid"
                  label="监测终端编号"
                ></el-table-column>
                <el-table-column
                  prop="updateTime"
                  label="时间"
                  min-width="120px"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      {{
                        $moment(
                          scope.row.lastLeadPulls.updateTime * 1000
                        ).format("YYYY-MM-DD HH:mm:ss")
                      }}</span
                    >
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="funcCode" label="功能单元识别码">
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span
                        v-if="
                          scope.row.lastLeadPulls.phase !== '' &&
                          scope.row.lastLeadPulls.funcCode
                        "
                      >
                        {{ scope.row.lastLeadPulls.phase }}({{
                          scope.row.lastLeadPulls.funcCode
                        }})</span
                      ><span v-else-if="scope.row.lastLeadPulls.funcCode"
                        >({{ scope.row.lastLeadPulls.funcCode }})</span
                      >
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="maxpullPull" label="最大拉力(Kg)">
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span v-if="scope.row.lastLeadPulls.maxpullPull != 65535">
                        {{
                          scope.row.lastLeadPulls.maxpullPull.toFixed(2)
                        }}</span
                      ><span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="maxpullWind" label="最大拉力时风偏角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span v-if="scope.row.lastLeadPulls.maxpullWind != 65535">
                        {{
                          scope.row.lastLeadPulls.maxpullWind.toFixed(2)
                        }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="maxpullTilt" label="最大拉力时倾斜角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span v-if="scope.row.lastLeadPulls.maxpullTilt != 65535">
                        {{
                          scope.row.lastLeadPulls.maxpullTilt.toFixed(2)
                        }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="minpullPull" label="最小拉力(Kg)">
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span v-if="scope.row.lastLeadPulls.minpullPull != 65535">
                        {{
                          scope.row.lastLeadPulls.minpullPull.toFixed(2)
                        }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="minpullWind" label="最小拉力时风偏角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span v-if="scope.row.lastLeadPulls.minpullWind != 65535">
                        {{
                          scope.row.lastLeadPulls.minpullWind.toFixed(2)
                        }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="minpullTilt" label="最小拉力时倾斜角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span v-if="scope.row.lastLeadPulls.minpullTilt != 65535">
                        {{
                          scope.row.lastLeadPulls.minpullTilt.toFixed(2)
                        }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="maxwindWind" label="最大风偏角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span v-if="scope.row.lastLeadPulls.maxwindWind != 65535">
                        {{
                          scope.row.lastLeadPulls.maxwindWind.toFixed(2)
                        }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="maxwindTilt"
                  label="最大风偏角时倾斜角(°)"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span v-if="scope.row.lastLeadPulls.maxwindTilt != 65535">
                        {{
                          scope.row.lastLeadPulls.maxwindTilt.toFixed(2)
                        }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="maxwindPull"
                  label="最大风偏角时拉力(Kg)"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span v-if="scope.row.lastLeadPulls.maxwindPull != 65535">
                        {{
                          scope.row.lastLeadPulls.maxwindPull.toFixed(2)
                        }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="minwindWind" label="最小风偏角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span
                        v-if="
                          scope.row.lastLeadPulls.minwindWind != 65535 &&
                          scope.row.lastLeadPulls.minwindWind != 255
                        "
                      >
                        {{
                          scope.row.lastLeadPulls.minwindWind.toFixed(2)
                        }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="minwindTilt"
                  label="最小风偏角时倾斜角(°)"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span
                        v-if="
                          scope.row.lastLeadPulls.minwindTilt != 65535 &&
                          scope.row.lastLeadPulls.minwindTilt != 255
                        "
                      >
                        {{
                          scope.row.lastLeadPulls.minwindTilt.toFixed(2)
                        }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="minwindPull"
                  label="最小风偏角时拉力(Kg)"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.lastLeadPulls !== null">
                      <span
                        v-if="
                          scope.row.lastLeadPulls.minwindPull != 65535 &&
                          scope.row.lastLeadPulls.minwindPull != 255
                        "
                      >
                        {{
                          scope.row.lastLeadPulls.minwindPull.toFixed(2)
                        }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
              </el-table>
              <el-table
                v-else
                :data="tableData"
                style="width: 100%"
                v-loading="loading"
                height="calc(100% - 0px)"
              >
                <el-table-column
                  prop="cmdid"
                  label="监测终端编号"
                ></el-table-column>
                <el-table-column
                  prop="updateTime"
                  label="时间"
                  min-width="120px"
                >
                  <template slot-scope="scope">
                    {{
                      $moment(scope.row.updateTime * 1000).format(
                        "YYYY-MM-DD HH:mm:ss"
                      )
                    }}
                  </template>
                </el-table-column>
                <el-table-column prop="funcCode" label="功能单元识别码">
                  <template slot-scope="scope">
                    <span v-if="scope.row.phase !== '' && scope.row.funcCode">
                      {{ scope.row.phase }}({{ scope.row.funcCode }})</span
                    ><span v-else-if="scope.row.funcCode"
                      >({{ scope.row.funcCode }})</span
                    >

                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="maxpullPull" label="最大拉力(Kg)">
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span v-if="scope.row.maxpullPull != 65535">
                        {{ scope.row.maxpullPull.toFixed(2) }}</span
                      ><span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="maxpullWind" label="最大拉力时风偏角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span v-if="scope.row.maxpullWind != 65535">
                        {{ scope.row.maxpullWind.toFixed(2) }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="maxpullTilt" label="最大拉力时倾斜角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span v-if="scope.row.maxpullTilt != 65535">
                        {{ scope.row.maxpullTilt.toFixed(2) }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="minpullPull" label="最小拉力(Kg)">
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span v-if="scope.row.minpullPull != 65535">
                        {{ scope.row.minpullPull.toFixed(2) }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="minpullWind" label="最小拉力时风偏角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span v-if="scope.row.minpullWind != 65535">
                        {{ scope.row.minpullWind.toFixed(2) }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="minpullTilt" label="最小拉力时倾斜角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span v-if="scope.row.minpullTilt != 65535">
                        {{ scope.row.minpullTilt.toFixed(2) }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="maxwindWind" label="最大风偏角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span v-if="scope.row.maxwindWind != 65535">
                        {{ scope.row.maxwindWind.toFixed(2) }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="maxwindTilt"
                  label="最大风偏角时倾斜角(°)"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span v-if="scope.row.maxwindTilt != 65535">
                        {{ scope.row.maxwindTilt.toFixed(2) }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="maxwindPull"
                  label="最大风偏角时拉力(Kg)"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span v-if="scope.row.maxwindPull != 65535">
                        {{ scope.row.maxwindPull.toFixed(2) }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column prop="minwindWind" label="最小风偏角(°)">
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span
                        v-if="
                          scope.row.minwindWind != 65535 &&
                          scope.row.minwindWind != 255
                        "
                      >
                        {{ scope.row.minwindWind.toFixed(2) }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="minwindTilt"
                  label="最小风偏角时倾斜角(°)"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span
                        v-if="
                          scope.row.minwindTilt != 65535 &&
                          scope.row.minwindTilt != 255
                        "
                      >
                        {{ scope.row.minwindTilt.toFixed(2) }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="minwindPull"
                  label="最小风偏角时拉力(Kg)"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row !== null">
                      <span
                        v-if="
                          scope.row.minwindPull != 65535 &&
                          scope.row.minwindPull != 255
                        "
                      >
                        {{ scope.row.minwindPull.toFixed(2) }}</span
                      >
                      <span v-else> - </span>
                    </span>
                    <span v-else> - </span>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <div class="pageNation" v-if="!echartsShow">
              <el-pagination
                @current-change="handleCurrentChange"
                @size-change="handleSizeChange"
                :current-page="page"
                :page-size="pageSize"
                layout="sizes, prev, pager, next, jumper,total"
                :total="total"
              >
              </el-pagination>
            </div>
            <div class="graphBox" v-if="echartsShow">
              <div
                class="codeBox1"
                v-for="(item, index) in codeList"
                :key="index"
              >
                <h3>相位(标识): ({{ item }})</h3>
                <div class="codeBox">
                  <div :id="'lineEchart' + index" class="lineChartBox"></div>
                </div>
              </div>
              <div class="noDatabox" v-if="codeList.length == 0">
                <img src="../../../assets/img/nopic1.jpg" />
                <p>暂无图表</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import leftTree from "../components/leftTree.vue";
import {
  LeadPullJoggle,
  leadpullsListJoggle,
  exportJoggle,
} from "@/utils/api/iceApi";
export default {
  name: "icing",
  components: {
    leftTree,
  },
  data() {
    return {
      loading: false,
      tableData: [],
      formdata: {},
      page: 1, // 当前页数
      pageSize: 20, // 每页数量
      total: 0, //总条数
      qt: "",
      id: "",
      termId: "",
      paramsData: "",
      termalFlag: false, //是否是子节点显示  曲线图按钮
      echartsShow: false, //显示曲线图页面
      codeList: [], //相位码
      chartsData: [],
      dyFlag: true,
      lineFlag: false,

      gantatable: false, //点击了装置之后，显示的数据
    };
  },
  watch: {
    endtime(newVal) {
      if (newVal) {
        const date = new Date(newVal);
        date.setHours(23);
        date.setMinutes(59);
        date.setSeconds(59);
        this.formdata.endtime = date.getTime();
      }
    },
  },
  created() {
    var that = this;
    document.onkeydown = function (e) {
      var key = window.event.keyCode;
      if (key === 13) {
        that.onSubmit(); // 触发事件
      }
    };
    this.$set(
      this.formdata,
      "starttime",
      new Date(new Date().toLocaleDateString()).getTime()
    );
    const currentDate = new Date(); // 获取当前时间
    currentDate.setHours(23); // 设置小时为23
    currentDate.setMinutes(59); // 设置分钟为59
    currentDate.setSeconds(59); // 设置秒数为59
    this.$set(this.formdata, "endtime", currentDate.getTime());
  },
  mounted() {},
  methods: {
    getCurrentData(data) {
      console.log("执行父组件", data);
      this.paramsData = data;
      let pullParams;
      console.log(data);
      const sTime = Math.floor(this.formdata.starttime / 1000);
      const eTime = Math.floor(this.formdata.endtime / 1000);
      if (data.dyValue) {
        console.log("电压-公司");
        this.dyFlag = true;
        this.lineFlag = true;
        this.gantatable = false;
        pullParams = {
          devType: "2",
          dyId: data.id,
          pageNum: 1,
          pageSize: this.pageSize,
          start: sTime,
          end: eTime,
        };
        this.getIcingData(pullParams);
        this.termalFlag = false;
      } else if (data.bsManufacturer) {
        this.dyFlag = false;
        this.lineFlag = true;
        this.gantatable = false;
        console.log("线路-电压");
        pullParams = {
          devType: "2",
          lineId: data.id,
          pageNum: 1,
          pageSize: this.pageSize,
          start: sTime,
          end: eTime,
        };
        this.getIcingData(pullParams);
        this.termalFlag = false;
      } else {
        this.dyFlag = false;
        this.lineFlag = false;
        console.log("装置-杆塔");
        this.gantatable = true;
        // const sTime = Math.floor(this.formdata.starttime / 1000);
        // const eTime = Math.floor(this.formdata.endtime / 1000);
        console.log(data);

        pullParams = {
          // lineId: data.lineid,
          termId: data.id,
          towerId: data.towerid,
          start: sTime,
          end: eTime,
          pageNum: 1,
          pageSize: this.pageSize,
        };
        this.getIcingListData(pullParams);
        this.termalFlag = true;
      }
    },
    //覆冰数数据
    getIcingData(data) {
      console.log(data);
      this.loading = true;
      LeadPullJoggle(data)
        .then((res) => {
          console.log(res);

          // this.tableData = res.data.list.map((item) => item.lastLeadPulls);
          this.tableData = res.data.list;
          this.total = res.data.total;
          this.loading = false;
          this.echartsShow = false;
        })
        .catch((err) => {
          console.log(err); //代码错误、请求失败捕获
        });
    },
    getIcingListData(data) {
      console.log(data);
      this.loading = true;
      leadpullsListJoggle(data)
        .then((res) => {
          console.log(res);
          this.tableData = res.data.list;
          this.total = res.data.total;
          this.loading = false;
          this.echartsShow = false;
        })
        .catch((err) => {
          console.log(err); //代码错误、请求失败捕获
        });
    },
    lookLineCharts() {
      //获取相位码和数据
      this.echartsShow = true;
      console.log("点击了曲线");
      this.$nextTick(() => {
        this.getchartsData(this.paramsData);
      });
    },
    //获取当天的数据
    getchartsData(data) {
      console.log(data);
      const sTime = Math.floor(this.formdata.starttime / 1000);
      const eTime = Math.floor(this.formdata.endtime / 1000);
      this.loading = true;
      leadpullsListJoggle({
        lineId: data.lineId,
        termId: data.id,
        towerId: data.towerId,
        start: sTime,
        end: eTime,
        pageNum: 1,
        pageSize: 10000000,
      })
        .then((res) => {
          console.log(res);
          this.chartsData = res.data.list;
          this.$nextTick(() => {
            this.drawLine();
          });
        })
        .catch((err) => {
          console.log(err); //代码错误、请求失败捕获
        });
    },
    lookTableCharts() {
      this.echartsShow = false;
      this.loading = false;
    },
    drawLine() {
      console.log(this.chartsData);
      var timeXData = [];
      var legendData = [
        "最大拉力",
        "最大拉力时风偏角",
        "最大拉力时倾斜角",
        "最小拉力",
        "最小拉力时风偏角",
        "最小拉力时倾斜角",
        "最大风偏角",
        "最大风偏角时倾斜角",
        "最大风偏角时拉力",
        "最小风偏角",
        "最小风偏角时倾斜角",
        "最小风偏角时拉力",
      ];
      timeXData = this.chartsData.map((item) =>
        this.$moment(item.updateTime * 1000).format("YYYY-MM-DD HH:mm:ss")
      );
      timeXData = [...new Set(timeXData)];
      //console.log(timeXData);
      // var codename = [
      //   ...new Set(this.chartsData.map((item) => item.funcCodeName)),
      // ];
      var code = [...new Set(this.chartsData.map((item) => item.funcCode))];

      this.codeList = code;
      // var finalData = [];
      console.log(this.codeList);
      const groupedData = this.chartsData.reduce((acc, item) => {
        if (!acc[item.funcCode]) {
          acc[item.funcCode] = [];
        }
        acc[item.funcCode].push(item);
        return acc;
      }, []);

      const result = Object.values(groupedData)
        .map((arr) => [...arr])
        .reverse();

      console.log(result);
      this.$nextTick(() => {
        var roseCharts = document.querySelectorAll(".codeBox");
        console.log(roseCharts);
        for (var i = 0; i < roseCharts.length; i++) {
          // console.log(result[i]);
          // console.log(
          //   "最大封片叫拉力",
          //   result[i].map((item) => item.minWindPull)
          // );

          // 通过for循环，在相同class的dom内绘制元素
          var myChart = this.$echarts.init(roseCharts[i]);
          var option = {
            // toolbox: {
            //   feature: {
            //     dataZoom: {
            //       yAxisIndex: "none",
            //     },
            //     restore: {},
            //     saveAsImage: {},
            //   },
            // },
            tooltip: {
              trigger: "axis",
              axisPointer: {
                type: "cross",
                animation: false,
                label: {
                  backgroundColor: "#505765",
                },
              },
            },
            legend: {
              data: legendData,
              selected: {
                最大拉力: true,
                最大拉力时风偏角: false,
                最大拉力时倾斜角: false,
                最小拉力: false,
                最小拉力时风偏角: false,
                最小拉力时倾斜角: false,
                最大风偏角: false,
                最大风偏角时倾斜角: false,
                最大风偏角时拉力: false,
                最小风偏角: false,
                最小风偏角时倾斜角: false,
                最小风偏角时拉力: false,
              },
              // left: 10,
            },
            dataZoom: [
              {
                show: true,
                realtime: true,
                start: 0,
                end: 100,
              },
              {
                type: "inside",
                realtime: true,
                start: 0,
                end: 100,
              },
            ],
            xAxis: [
              {
                type: "category",
                boundaryGap: false,
                axisLine: { onZero: false },
                // prettier-ignore
                data: timeXData,
              },
            ],
            yAxis: [
              {
                name: "拉力(Kg)",
                type: "value",
              },
              {
                name: "偏角（°）",
                alignTicks: true,
                type: "value",
                // inverse: true
              },
            ],
            series: [
              {
                name: "最大拉力",
                type: "line",
                data: result[i].map((item) =>
                  item.maxpullPull == 65535 ? "" : item.maxpullPull
                ),
              },
              {
                name: "最小拉力",
                type: "line",
                data: result[i].map((item) =>
                  item.minpullPull == 65535 ? "" : item.minpullPull
                ),
              },
              {
                name: "最大风偏角时拉力",
                type: "line",

                data: result[i].map((item) =>
                  item.maxwindPull == 65535 ? "" : item.maxwindPull
                ),
              },
              {
                name: "最小风偏角时拉力",
                type: "line",

                data: result[i].map((item) =>
                  item.minwindPull == 65535 ? "" : item.minwindPull
                ),
              },
              {
                name: "最大拉力时风偏角",
                type: "line",
                yAxisIndex: 1,
                // prettier-ignore
                data: result[i].map((item) => item.maxpullWind),
              },
              {
                name: "最大拉力时倾斜角",
                type: "line",
                yAxisIndex: 1,
                // prettier-ignore
                data: result[i].map((item) => item.maxpullTilt),
              },
              {
                name: "最小拉力时风偏角",
                type: "line",
                yAxisIndex: 1,
                // prettier-ignore
                data: result[i].map((item) => item.minpullWind),
              },
              {
                name: "最小拉力时倾斜角",
                type: "line",
                yAxisIndex: 1,
                // prettier-ignore
                data: result[i].map((item) => item.minpullTilt),
              },
              {
                name: "最大风偏角",
                type: "line",
                yAxisIndex: 1,
                // prettier-ignore
                data:result[i].map((item) => item.maxwindWind),
              },
              {
                name: "最大风偏角时倾斜角",
                type: "line",
                yAxisIndex: 1,
                // prettier-ignore
                data:result[i].map((item) => item.maxwindTilt),
              },
              {
                name: "最小风偏角",
                type: "line",
                yAxisIndex: 1,
                // prettier-ignore
                data: result[i].map((item) => item.minwindWind),
              },
              {
                name: "最小风偏角时倾斜角",
                type: "line",
                yAxisIndex: 1,
                // prettier-ignore
                data: result[i].map((item) => item.minwindTilt),
              },
            ],
          };
          myChart.setOption(option);
          console.log("我执行了");
          window.addEventListener("resize", () => {
            myChart.resize();
          });
        }
      });
    },

    //结束日期
    changedate() {
      console.log(new Date(this.formdata.endtime));
      const currentDate = new Date(this.formdata.endtime); // 获取当前时间
      currentDate.setHours(23); // 设置小时为23
      currentDate.setMinutes(59); // 设置分钟为59
      currentDate.setSeconds(59); // 设置秒数为59
      this.formdata.endtime = currentDate;
      console.log("结束时间", this.formdata.endtime);
    },
    exportExcl() {
      const sTime = Math.floor(this.formdata.starttime / 1000);
      const eTime = Math.floor(this.formdata.endtime / 1000);
      window.location.href =
        "/api/xymanager/leadpulls/export?+" +
        "lineId=" +
        this.paramsData.lineid +
        "&termId=" +
        this.paramsData.id +
        "&towerId=" +
        this.paramsData.towerid +
        "&start=" +
        sTime +
        "&end=" +
        eTime;
    },
    onSubmit() {
      console.log(this.formdata.starttime, this.formdata.endtime);
      const sTime = Math.floor(this.formdata.starttime / 1000);
      const eTime = Math.floor(this.formdata.endtime / 1000);
      if (this.dyFlag) {
        let pullParams = {
          devType: "2",
          dyId: this.paramsData.id,
          pageNum: this.page,
          pageSize: this.pageSize,
          start: sTime,
          end: eTime,
        };
        this.getIcingData(pullParams);
      } else if (this.lineFlag) {
        let pullParams = {
          devType: "2",
          lineId: this.paramsData.id,
          pageNum: this.page,
          pageSize: this.pageSize,
          start: sTime,
          end: eTime,
        };
        this.getIcingData(pullParams);
      } else if (this.termalFlag) {
        let pullParams = {
          //lineId: this.paramsData.lineid,
          termId: this.paramsData.id,
          towerId: this.paramsData.towerid,
          start: sTime,
          end: eTime,
          pageNum: this.page,
          pageSize: this.pageSize,
        };
        this.getIcingListData(pullParams);
      }
    },

    //点击分页
    handleCurrentChange(val) {
      this.page = val;
      this.tableData = [];
      this.onSubmit();
    },
    //每页条数
    handleSizeChange(val) {
      this.pageSize = val;
      this.tableData = [];
      this.onSubmit();
    },
  },
};
</script>
<style lang="less">
.icingBox {
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  padding: 12px 12px;
  background: #fff;
  .icingContain {
    display: flex;
    height: 100%;
    box-sizing: border-box;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
  }
  .rightTable {
    display: flex;
    width: 100%;
    height: 100%;
    flex: 1;
    overflow: hidden;
    border-left: 1px solid #ddd;
    .el-table .el-table__cell {
      text-align: center;
    }
    .dataBox {
      width: calc(100% - 24px);
      height: calc(100% - 24px);
      padding: 12px 12px;
      background: #fff;
    }
    // .fatherTableShowBox {
    //   height: calc(100% - 0px);
    // }
    .childBox {
      height: calc(100% - 0px);
      .childTableShowBox {
        height: calc(100% - 91px);
      }
    }
    .graphBox {
      margin: 0 auto;
      height: calc(100% - 54px);
      overflow: auto;
      .codeBox1 {
        width: 100%;
        height: 500px;
        h3 {
          font-size: 14px;
          color: #333;
          margin-top: 8px;
          margin-bottom: 8px;
          font-weight: normal;
          text-align: center;
        }
        .codeBox {
          width: 100%;
          height: 450px;
        }
        .lineChartBox {
          width: 100%;
          height: 372px;
        }
      }
      .noDatabox {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        img {
          width: 400px;
        }
        p {
          font-size: 16px;
        }
      }
    }
  }
}
</style>
