<template>
  <div class="alarmdetail">
    <el-table
      ref="multipleTable"
      :data="getMachinmeAlarmDetails"
      tooltip-effect="light"
      max-height="605"
      style="width: 100%"
      border
      @row-click="singleElection"
    >
      <el-table-column label width="65">
        <template slot-scope="scope">
          <el-radio class="radio" v-model="templateSelection" :label="scope.$index">&nbsp;</el-radio>
        </template>
      </el-table-column>
      <el-table-column header-align="center" label="时间" width="170">
        <template slot-scope="scope">{{ scope.row.lastUpdateTime | timeFilter}}</template>
      </el-table-column>
      <el-table-column header-align="center" prop="alertText" label="报警信息" width="250"></el-table-column>
      <el-table-column header-align="center" prop="rankName" label="级别" width="50"></el-table-column>
      <el-table-column header-align="center" prop="categoryName" label="报警类型" width="80"></el-table-column>
      <el-table-column header-align="center" prop="haltType" label="停机类型" width="80"></el-table-column>
      <el-table-column header-align="center" prop="faultCategory" label="故障类型" width="80"></el-table-column>
      <el-table-column header-align="center" prop="faultCause" label="故障原因" show-overflow-tooltip></el-table-column>
    </el-table>
  </div>
</template>
<script>
import { dateFormat } from "@/assets/js/common";
export default {
  props: ["objectid", "faultInfo"],
  data()
  {
    return {
      templateSelection: "",
      templateRadio: ""
    };
  },

  methods: {
    singleElection(row)
    {
      this.templateSelection = this.getMachinmeAlarmDetails.indexOf(row);
      this.templateRadio = row.id;
    },
    openDialog()
    {
      this.devicealarmdetails = true;
    },
    /** 生成缺陷单 / 确认
     * @param confirmType { Number } 1-确认 2-复位  3-生成缺陷单
     */
    createOrConfirm(confirmType, userName)
    {
      let requestData = {
        confirmType: confirmType, //
        faultHistoryId: this.faultInfo.id, //故障id View_faultHistory中 snapid  即FaultSnap表Id  faulrInformation.id;
        userName: userName,
        alertSnapId: this.templateRadio, //报警编号 (确认时选择的首出报警) alarmSnap id
        alertText: this.faultInfo.alertText, //
        alertValue: this.faultInfo.alertValue, //
        stationId: this.faultInfo.stationId, //
        category1: this.faultInfo.category1, //
        objectId: this.faultInfo.objectId, //
        alertTime: this.faultInfo.alertTime // yyyy-MM-dd HH:mm:ss
      };
      //
      let headers = {};
      let jsonText = JSON.stringify(requestData);
      headers["confirm"] = jsonText;
    }
  },
  computed: {
    getMachinmeAlarmDetails()
    {
      return this.$store.state.alarm.machinmeAlarmDetails;
    }
  },
  filters: {
    timeFilter(value)
    {
      if (value) return dateFormat("yyyy-MM-dd HH:mm:ss", new Date(value));
      else return "";
    }
  }
};
</script>
<style lang="less">
.alarmdetail {
  width: 1180px;
  height: 605px;
  .el-table {
    font-size: 12px !important;
  }
}
.el-table--scrollable-x .el-table__body-wrapper {
  overflow-x: hidden !important;
}
.el-table td,
.el-table th {
  padding: 1px 0 !important;
}
</style>
