<template>
  <div class="app-container">
    <el-form
      ref="queryForm"
      :model="queryParams"
      size="small"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <div class="table">
      <el-table
        v-loading="loading"
        :data="dataList"
        row-key="id"
        lazy
        :load="load"
        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
      >
        <el-table-column
          label="线路名称"
          align="center"
          prop="lineNm"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="电压等级"
          prop="voltLvlDsc"
          align="center"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          label="线路长度"
          prop="lineRunNo"
          align="center"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          label="所属县公司"
          prop="stdCountyOrgNm"
          align="center"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          label="无故障持续时间(天)"
          prop="faultFreeDuration"
          align="center"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          label="奖励金额"
          prop="rewardAmount"
          align="center"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
      </el-table>
      <pagination
        class="page-box"
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
import { getWorkPlanList } from "@/api/secure/pdm-work-plan";
import {
  selectCompleteList,
  selectBranchLineCompleteList,
} from "@/api/powerdistribution/maintenance";
export default {
  data() {
    return {
      dataList: [],
      // 显示搜索条件
      showSearch: true,
      // 遮罩层
      loading: true,
      total: 0,
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        opTypDsc: "",
        pageNum: 1,
        pageSize: 10,
      },
      // 作业类型
      workTypeList: [],
      // 专业类型
      zyTypeList: [],
      // 作业单位
      workUnitOptions: [],
      // 风险类型
      exceptionTypeList: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      selectCompleteList({ ...this.queryParams }).then((response) => {
        this.dataList = response.rows.map((ite) => {
          ite.hasChildren = true;
          return ite;
        });
        this.total = response.total;
        this.loading = false;
      });
    },
    async load(tree, treeNode, resolve) {
      const data = await selectBranchLineCompleteList({
        pageNum: 1,
        pageSize: 9999,
        blgBigFeederId: tree.feederId,
      });
      resolve(
        data.rows.map((ite) => {
          ite.id = Math.random();
          return ite;
        })
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.pageNum = 1;
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
<style lang="scss" scoped>
.table {
  height: calc(100% - 150px);
}
::v-deep {
  .el-table {
    height: 100%;
    width: 100%;
    .el-table__body-wrapper {
      width: 100% !important;
      height: calc(100% - 50px) !important; // 表格高度减去表头的高度
      overflow-y: scroll;
    }
  }
}
</style>
