<template>
  <div>
    <el-row>
      <el-col :span="24">
        <el-table
          class="tableClass"
          stripe
          border
          ref="multipleTable"
          :data="tableData"
          tooltip-effect="dark"
          style="width: 100%"
          height="510"
          max-height="520"
          size="small"
          :header-cell-style="{ background: '#EFEFEF', color: '#000000' }"
        >
          <el-table-column label="序号" type="index" width="60" align="center"></el-table-column>
          <!--          <el-table-column prop="warnType" label="报警类别" width="100" align="center"> </el-table-column>-->
          <el-table-column prop="warnTime" label="报警时间" width="130" align="center">
            <template slot-scope="scope">
              <span :style="{ fontWeight: 'border', color: 'red' }">{{ scope.row.warnTime }}</span></template
            >
          </el-table-column>
          <el-table-column prop="warnTime" label="报警总池体积(m³)" width="100" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.warnWoh.toFixed(2) }}</span></template
            >
          </el-table-column>
          <el-table-column prop="pitStartTime" label="起点时间" width="130" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.pitStartTime }}</span></template
            >
          </el-table-column>
          <el-table-column prop="pitStart" label="起点总池体积(m³)" width="100" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.pitStart.toFixed(2) }}</span></template
            >
          </el-table-column>
          <el-table-column prop="pitSub" label="起点总池体积差值(m³)" width="120" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.pitSub.toFixed(2) }}</span></template
            >
          </el-table-column>
          <!-- <el-table-column prop="wholeCondition" label="整体工况" width="120" align="center">
          </el-table-column> -->
          <el-table-column prop="warnTime" label="异常描述详情" align="center">
            <template slot-scope="scope">
<!--              <span>{{ scope.row.jh + '在' + scope.row.warnTime + '发生' }}</span>-->
<!--              <span>{{ scope.row.warnDes }}</span>-->
              <div style="white-space: pre-wrap;text-align: left" v-html='scope.row.warnDes'></div>

            </template>
          </el-table-column>
          <el-table-column label="详情" width="120" align="center">
            <template slot-scope="scope">
              <el-button size="mini" @click="openWarnTemplte(scope.row)" type="text" icon="el-icon-setting"
                >模板</el-button
              >
              <el-button size="mini" @click="openWarnData(scope.row)" type="text" icon="el-icon-tickets"
                >数据</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </el-col>
      <el-col :span="24">
        <el-pagination
          background
          style="padding: 10px 12px 13px 12px"
          @size-change="showSizeChange"
          @current-change="change"
          :current-page="query.pageNo"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="query.pageSize"
          layout="->, total, sizes, prev, pager, next,jumper"
          :total="total"
        ></el-pagination>
      </el-col>
    </el-row>
    <el-dialog title="预警模板" append-to-body :visible.sync="dialogVisible" width="500px">
      <el-form
        :model="templateData"
        disabled
        label-position="left"
        label-width="200px"
        style="margin-top: -10px; margin-bottom: -10px"
      >
        <el-form-item label="报警阈值(立方米 m³)：">
          <el-input v-model="templateData.pitValue" size="mini"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false" size="mini">关 闭</el-button>
      </span>
    </el-dialog>
    <el-dialog title="时刻数据" append-to-body :visible.sync="dialogVisibleWarn" width="500px">
      <el-form :model="templateData1" disabled label-position="left" label-width="200px" style="margin-top: -10px">
        <el-form-item label="报警类别：">
          <el-input v-model="templateData1.warnType" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="报警点时间：">
          <el-input v-model="templateData1.warnTime" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="报警点总池体积(立方米 m³)：">
          <el-input v-model="templateData1.warnWoh" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="报警点钻头位置(m)：">
          <el-input v-model="templateData1.warnBitdepth" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="起点时间：">
          <el-input v-model="templateData1.pitStartTime" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="起点总池体积(立方米 m³)：">
          <el-input v-model="templateData1.pitStart" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="总池体积差值：">
          <el-input v-model="templateData1.pitSub" size="mini"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibleWarn = false" size="mini">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
  <!--  <div style='position: relative;display: none'>
    <a-table
      size="small"
      :scroll="{ y: 500 }"
      bordered
      :pagination="false"
      :columns="detailColumns"
      :dataSource="tableData"
      :loading="detailLoading">
    </a-table>
    <a-pagination
      size="small"
      :current="query.pageNo"
      :pageSize="query.pageSize"
      :total="total"
      style='position: absolute;bottom: 0px;right: 0px'
      show-size-changer
      @change="change"
      @showSizeChange="showSizeChange"
    />
  </div>-->
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import newWarnApi from '@/api/newWarnApi'
import vue from 'vue'

export default {
  name: 'jlWarnHistory',
  mixins: [JeecgListMixin],
  props: {
    jh: {
      type: String,
      default: ''
    },
    date: {
      type: String,
      default: ''
    },
    startime: {
      type: String,
      default: ''
    },
    endTime: {
      type: String,
      default: ''
    },
  },
  data() {
    return {
      query: {
        jh: '',
        warnType: '总池体积变化异常',
        warnTime: '',
        pageSize: 10,
        pageNo: 1,
        starTime: '',
        endTime: ''
      },
      dialogVisible: false,
      dialogVisibleWarn: false,
      total: 0,
      templateData: {},
      templateData1: {},
      tableData: [],
      /* table加载状态 */
      detailLoading: false,
      tabOption: []
    }
  },
  watch: {
  },
  created() {
    //this.getWarningJhOption()
    console.log('井号' + this.jh)
    console.log('时间' + this.date)
    this.query.jh = this.jh
    // this.query.warnTime = this.date
    this.query.starTime = this.startime
    this.query.endTime = this.endTime
    this.init()
  },
  mounted() {
    console.log('新模型')
  },
  methods: {
    init() {
      this.getNewWarnHistoryPage()
      //this.getNewWarnHistoryPage()
    },
    getNewWarnHistoryPage() {
      this.detailLoading = true
      newWarnApi.getNewWarnHistory(this.query).then(res => {
        console.log('历史数据', res)
        this.detailLoading = false
        this.total = res.result.total
        this.current = res.result.current
        this.tableData = res.result.records

      })
    },
    openWarnTemplte(row) {
      this.templateData = row
      this.dialogVisible = true
    },
    openWarnData(row) {
      this.templateData1 = row
      this.dialogVisibleWarn = true
    },
    showSizeChange(val) {
      this.query.pageSize = val
      this.query.pageNo = 1
      this.getNewWarnHistoryPage()
    },
    change(val) {
      this.query.pageNo = val
      this.getNewWarnHistoryPage()
    }
  },
  beforeDestroy() {
  }
}
</script>

<style lang="less" scoped>
/deep/ .ant-card-body {
  padding: 7px;
}

.fixHeight {
  height: 100%;
  /deep/ .ant-spin-nested-loading {
    height: calc(100% - 35px);
    .ant-spin-container {
      height: 100%;
      .ant-table {
        height: 100%;
        .ant-table-content {
          height: 100%;
          .ant-table-scroll {
            height: 100%;
            overflow: hidden;
          }
        }
      }
    }
  }
}

/deep/ .high-light-row {
  background: yellow;
  td {
    color: red;
  }
}
.tableClass .cell {
  padding: 0 !important;
  height: 40px;
  line-height: 30px !important;
  text-align: center;
}
/deep/ .el-dialog__body {
  padding: 10px 30px;
}
/deep/ .el-form-item {
  margin-bottom: 0px;
}
</style>
