<template>
  <div>
    <el-row>
      <el-col :span="24">
        <el-button type="primary" round size="mini" @click="add">新增</el-button>
      </el-col>
      <el-col :span="24">
        <el-table v-loading="loading" :data="data" row-key="deptId" default-expand-all height="80vh">
          <el-table-column prop="jh" label="井号"></el-table-column>
          <el-table-column prop="torqueMin" label="扭矩监测最小值"></el-table-column>
          <el-table-column prop="torqueMax" label="扭矩监测最大值"></el-table-column>
          <el-table-column prop="varianceWarnValue" label="均值阈值"></el-table-column>
          <el-table-column prop="fluctuateWarn" label="波动阈值"></el-table-column>
          <el-table-column prop="bitdepth" label="钻头监测阈值"></el-table-column>
          <el-table-column prop="sortCode" label="排序码"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <!-- <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button> -->
              <el-button type="text" size="small" @click="edit(scope.row)">编辑</el-button>
            </template>
          </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="params.pageNo"
          :page-sizes="[15, 20, 50, 100]"
          :page-size="params.pageSize"
          layout="->, total, sizes, prev, pager, next,jumper"
          :total="total"
        ></el-pagination>
      </el-col>
    </el-row>
    <torqueWarnForm ref="torqueWarnFormRef" @close="loadData" />
  </div>
</template>

<script>
import realTimeLogApi from '@/api/warningThreshold/torqueWarnValueApi'
import torqueWarnForm from './forms/torqueWarnForm.vue'
import vue from 'vue'
export default {
  name: 'torqueWarnTable',
  components: { torqueWarnForm },
  data() {
    return {
      loading: false,
      searchForm: {
        jh: '',
      },
      total: 0,
      params: {
        jh: '',
        pageNo: 1,
        pageSize: 15
      },
      loading: false,
      data: [],
    }
  },
  created() {
    console.log("扭矩")
  },
  mounted() {
    this.loadData()
  },
  methods: {
    open() {
      this.loadData()
    },
    loadData() {
      this.loading = true
      this.params.jh = vue.ls.get('TOPLEFT_JH_SELECTED').JH
      realTimeLogApi.page(this.params).then(res => {
        console.log('获取的实时分页数据:', res)
        var result = res.result
        this.data = result.records
        this.params.pageNo = result.current
        this.params.pageSize = result.size
        this.total = result.total
        this.loading = false
      })
    },
    showSizeChange(val) {
      this.params.pageSize = val
      this.params.pageNo = 1
      this.loadData()
    },
    change(val) {
      this.params.pageNo = val
      this.loadData()
    },
    handleClose() {
      this.params = {
        jh: '',
        pageNo: 1,
        pageSize: 15
      }
    },
    edit(row) {
      console.log(row)
      this.$refs.torqueWarnFormRef.open(this.params.jh, row)
    },
    add() {
      this.$refs.torqueWarnFormRef.open(this.params.jh, '')
    },
    goBack() {
      this.$router.go(-1)
    }
  }
}
</script>

<style>
</style>