<template>
  <div class="alarmHandBox">
    <div class="searchMain">
      <!-- <div class="alarmButtonGroup">
        <el-button type="primary">查询</el-button>
        <el-button type="primary">今日告警</el-button>
        <el-button type="primary">最近三日告警</el-button>
        <el-button type="primary">最近一周告警</el-button>
        <el-button type="primary">批量处理</el-button>
        <el-button type="primary">查看详情</el-button>
        <el-button type="primary">导出</el-button>
        <el-button type="primary">导出处理结果</el-button>
        <el-button type="primary">导出图片</el-button>
        <el-button type="primary">手动刷新</el-button>
      </div> -->
      <div class="searchBox">
        <el-form :inline="true" :model="formdata" class="demo-form-inline">
          <el-form-item label="电压等级">
            <el-select v-model="formdata.dyid" >
              <el-option
                v-for="item in dyOptions"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="线路名称">
            <el-select v-model="formdata.lineid" >
              <el-option
                v-for="item in xlOptions"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="杆塔名称">
            <el-select v-model="formdata.towerid" >
              <el-option
                v-for="item in gtOptions"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="日期">
            <el-date-picker
              v-model="formdata.timeVal"
              type="datetimerange"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="timestamp"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="alarmContain">
        <div class="alarmTable">
          <el-table
            ref="multipleTable"
            :data="tableData"
            stripe
            border
            tooltip-effect="dark"
            style="width: 100%"
            @selection-change="handleSelectionChange"
            height="calc(100% - 40px)"
            @row-click="handleRowClick"
          >
            <el-table-column min-width="35">
              <template slot-scope="scope">
                <span>{{ (page - 1) * pageSize + scope.$index + 1 }}</span>
              </template>
            </el-table-column>
            <el-table-column type="selection" min-width="25"> </el-table-column>
            <el-table-column
              prop="alarmTime"
              label="告警时间"
              min-width="135"
              :show-overflow-tooltip="true"
              :formatter="dateFormat"
            >
            </el-table-column>
            <el-table-column prop="alarmLevel" label="告警级别" min-width="75">
            </el-table-column>
            <el-table-column
              prop="lineName"
              label="线路"
              min-width="105"
              :show-overflow-tooltip="true"
            >
            </el-table-column>
            <el-table-column
              prop="meid"
              label="杆塔"
              min-width="115"
              :show-overflow-tooltip="true"
            >
            </el-table-column>
            <el-table-column
              prop="orientationName"
              label="监拍朝向"
              min-width="95"
              :show-overflow-tooltip="true"
            >
            </el-table-column>
            <el-table-column
              prop="companyName"
              label="单位"
              min-width="75"
              :show-overflow-tooltip="true"
            >
            </el-table-column>
            <el-table-column
              prop="alarmInfo"
              label="告警原因"
              min-width="155"
              :show-overflow-tooltip="true"
            >
            </el-table-column>
            <el-table-column
              prop="source"
              label="分析来源"
              min-width="105"
              :show-overflow-tooltip="true"
            >
              <template>后端分析</template></el-table-column
            >
            <el-table-column
              prop="clearDistace"
              label="净空距离"
              min-width="105"
              :show-overflow-tooltip="true"
              ><template>未分析</template>
            </el-table-column>
            <el-table-column
              prop="distanceLevel"
              label="距离分级"
              min-width="85"
              :show-overflow-tooltip="true"
            >
            </el-table-column>
            <el-table-column
              prop="isRead"
              label="是否已读"
              min-width="95"
              fixed="right"
            >
              <template slot-scope="scope">
                <span v-if="scope.row.isRead == 0">未读</span>
                <span v-if="scope.row.isRead == 1">已读</span>
              </template>
            </el-table-column>
          </el-table>
          <div class="pageNation">
            <el-pagination
              @current-change="handleCurrentChange"
              :current-page="page"
              :page-size="pageSize"
              layout=" prev, pager, next, jumper,total"
              :total="total"
            >
            </el-pagination>
          </div>
        </div>
        <div class="alarmPic">
          <div class="imgshow"><img :src="photoPic" /></div>
          <div class="editorBtn">
            <el-button type="primary">处理</el-button>
            <el-button type="primary">查看操作详情</el-button>
            <el-button type="primary">设置非警告区域</el-button>
            <el-button type="primary">主动拍照</el-button>
            <el-button type="primary">转向GT</el-button>
            <el-button type="primary">复制</el-button>
            <el-button type="primary">历史图</el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
//import { list } from '@/utils/api/index';
import moment from "moment";
export default {
  data() {
    return {
      dyOptions: [{ id: 0, name: '全部'}], //电压数据
      xlOptions: [{ id: 0, name: '全部'}], //线路数据
      gtOptions: [{ id: 0, name: '全部'}], //杆塔数据
      zzOptions: [{ id: 0, name: '全部'}], //装置数据
      tdOptions: [{ id: 0, name: '全部'}], //通道数据
      formdata: {
        dyid: "",
        lineid: "",
        towerid: "",
        channelid: "",
        termid: "",
        timeVal: "",
      },
      photoPic: "",
      tableData: [],
      multipleSelection: [],
      page: 1, // 当前页数
      pageSize: 20, // 每页数量
      total: 0, //总条数
    };
  },
  methods: {
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.page = val;
      this.getTableList();
    },
    getTableList() {
      this.tableData = [
      {
          alarmId: "336a07658a964309855e7084013e545f",
          earlyAlarmId: null,
          companyId: "f7d966d1-f3d1-4802-946d-ad93e1ee1b9b",
          companyName: "xytest",
          teamId: null,
          teamName: null,
          lineId: "8cee6df6-46c7-4f6d-abfa-b2cfecdcf31f",
          lineName: "i1测试线路-SH",
          logicTowerId: "38fb2783-4d41-490d-8b80-806ecb4822e0",
          towerName: "XYIGQ10C221000080",
          monitorPointId: "8f0ebae8-e314-1d43-c700-2a50139f5489",
          orientation: "10",
          orientationName: "白天",
          photoName: "XYIGQ10C221000080_20230505040011_1_255_res.jpg",
          phtotUrl: "/",
          dangerCode: "0101",
          dangerName: "跨高铁(电铁)",
          alarmInfo: '["YanWu"]',
          alarmTime: 1683230415000,
          status: 0,
          outvalue: null,
          alarmFlag: null,
          collectConfigId: null,
          collectUser: null,
          analysersrc: "2",
          alarmObjects: null,
          photoPath:
            "/local/XYIGQ10C221000080/202305/backend/XYIGQ10C221000080_20230505040011_1_255_res.jpg",
          alarmLevel: "1",
          alarmSource: "1",
          isRead: 1,
          readStatus: null,
          readTime: 1683279356000,
          readUserName: null,
          ifDispatch: null,
          dispatchState: null,
          dispatchTime: null,
          channel: 1,
          deviceId: "097ba6dc-9ece-4da4-a636-00eacc39fad5",
          meid: "XYIGQ10C221000080",
          dealTime: null,
          overTimeStatus: null,
          manufacturerCode: null,
          manufacturerName: null,
          sendWechat: null,
          presettingNum: null,
          presettingName: null,
          referencepicname: null,
          photoId: null,
          weatherStatus: null,
          jingKongLength: null,
          shuiPingLength: null,
          chuiZhiLength: null,
          companyIdSelect: null,
          timeStart: null,
          timeEnd: null,
          voltageCode: "5",
          voltageName: "220kV",
          alarmLevelName: null,
          alarmInfoName: null,
          ifDispatchLocationId: null,
          userId: null,
          earlyAlarmTime: null,
          lng: null,
          lat: null,
          timeExcel: null,
          alarmTimeExcel: null,
          sendPerson: null,
          readPerson: null,
          readTimeExcel: null,
          statusName: null,
          dealTimeDeal: null,
          dealPersonDeal: null,
          statusDeal: null,
          measureDeal: null,
          ramarkDeal: null,
          analyseName: null,
          workCount: null,
          photoserver: null,
          alarmDeal: [],
          photoEarlyAlarm: null,
          companyPath: null,
        },
      ];
      this.total = 36;
      this.photoPic = "http://180.166.218.222:8104/media" + this.tableData[0].photoPath;
    },
    //查询
    onSubmit() {
      
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleRowClick(row) {
      //this.$refs.multipleTable.toggleRowSelection(row);
      console.log(row);
      this.photoPic = "http://180.166.218.222:8104/media" + row.photoPath;
    },
    dateFormat(row, column) {
      var date = row[column.property];
      if (date == undefined) {
        return "";
      }
      return moment(date).format("YYYY-MM-DD HH:mm:ss");
    },
  },
  created() {
    this.getTableList();
  },
};
</script>
<style lang="less">
.alarmHandBox {
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  padding: 16px 16px;
  background: #ffffff;
  .searchMain {
    border: 1px solid #dddddd;
    height: calc(100% - 32px);
    padding: 16px;
    border-radius: 4px;
  }
  .alarmTop {
    padding: 0px 8px 16px 8px;
  }
  .alarmContain {
    display: flex;
    height: calc(100% - 48px);
    padding: 0px 8px;
    .alarmTable {
      width: 50%;
      height: 100%;
    }
    .pageNation {
      margin-top: 8px;
    }
    .alarmPic {
      width: 50%;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .imgshow {
        width: 100%;
        height: 90%;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .editorBtn {
        margin-top: 8px;
        border: 1px solid @border-color-base;
        padding: 2%;
        border-radius: 4px;
      }
      .editorBtn {
        display: flex;
        justify-content: flex-start;
      }
    }
  }
}
</style>
