<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="520"
          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="motion" label="预警点动作" width="100" align="center"> </el-table-column>
          <el-table-column prop="workingCondition" label="预警点工况" width="130" align="center"></el-table-column>

          <el-table-column prop="warnStartTime" label="预警取值开始时间" width="100" align="center"> </el-table-column>
          <el-table-column prop="warnEndTime" label="预警取值结束时间" width="100" align="center"> </el-table-column>
          <el-table-column prop="warnTorque" label="预警点扭矩" width="100" align="center"> </el-table-column>
          <el-table-column prop="warnMeanValue" label="预警点扭矩均值" width="100" align="center"> </el-table-column>
          <el-table-column prop="warnFluctuatedValue" label="预警点扭矩波动值" width="100" align="center"> </el-table-column>
          <el-table-column prop="warnBitdepth" label="预警点钻头位置" width="100" align="center"> </el-table-column>
          <el-table-column prop="warnDepth" label="预警点井深" width="100" align="center"> </el-table-column>
          <el-table-column prop="referenceStartTime" label="参考值起点时间" width="100" align="center"> </el-table-column>
          <el-table-column prop="referenceEndTime" label="参考值结束时间" width="100" align="center"> </el-table-column>
          <el-table-column prop="referenceMeanValue" label="参考值扭矩均值" width="100" align="center"> </el-table-column>
          <el-table-column prop="referenceFluctuatedValue" label="参考值扭矩波动值" width="100" align="center"> </el-table-column>
          <el-table-column prop="resMeanValue" label="均值计算结果值" width="100" align="center"> </el-table-column>
          <el-table-column prop="resFluctuatedValue" label="波动值计算结果值" width="100" align="center"> </el-table-column>
          <el-table-column prop="thresholdMeanValue" label="均值阈值" width="100" align="center"> </el-table-column>
          <el-table-column prop="thresholdFluctuatedValue" label="波动值阈值" width="100" align="center"> </el-table-column>
          <el-table-column prop="isMeanWarn" label="是否均值报警" width="100" align="center"> </el-table-column>
          <el-table-column prop="isFluctuatedWarn" label="是否波动报警" width="100" align="center"> </el-table-column>
          <el-table-column prop="warnDes" label="预警描述" width="100" align="center" show-overflow-tooltip> </el-table-column>
          <el-table-column prop="createTime" label="创建时间" width="100" align="center"> </el-table-column>
        </el-table>
      </el-col>
      <el-col :span="24">
        <el-pagination
          background
          style="padding: 19px 12px 0px 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="180px" style="margin-top: -10px">
        <el-form-item label="扭矩上一点井深(米 m)：">
          <el-input v-model="templateData.torquepreviousjs" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="波动取值时间范围(秒)：">
          <el-input v-model="templateData.torguetimes" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="扭矩变化量阈值(%)：">
          <el-input v-model="templateData.torgueVariationThreshold" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="扭矩波动阈值(%)：">
          <el-input v-model="templateData.torgueWaveThreshold" 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="180px" 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="报警点扭矩(KN)：">
          <el-input v-model="templateData1.warnWoh" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="报警点大钩位置(m)：">
          <el-input v-model="templateData1.warnHkh" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="报警点工况：">
          <el-input v-model="templateData1.warnCondition" 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.normalStarttime" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="基准波动幅度结束时间：">
          <el-input v-model="templateData1.normalEndtime" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="基准波动幅度：">
          <el-input v-model="templateData1.normalWoh" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="基准波动幅度平均值：">
          <el-input v-model="templateData1.njbhlPerTorBig" 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: 'warnHistoryNjCompare',
  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,
        startTime: '',
        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.startTime = this.startime
    this.query.endTime = this.endTime
    this.init()
  },
  mounted() {
    console.log('新模型')
  },
  methods: {
    init() {
      this.getNewWarnHistoryPage()
      //this.getNewWarnHistoryPage()
    },
    getNewWarnHistoryPage() {
      this.detailLoading = true
      newWarnApi.getNewWarnHistoryNJ(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) {
      if (row.warnCondition == 'DrillDown') {
        row.warnCondition = '下钻'
      } else if (row.warnCondition == 'Trip') {
        row.warnCondition = '起钻'
      } else if (row.warnCondition == 'Drilling') {
        row.warnCondition = '钻进'
      } else {
        row.warnCondition = '循环'
      }
      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>
