<template>
  <div class="container">
    <div class="frist">
      <div class="input">
        {{ name }}浓度： {{ currentVls }} ppm
      </div>
      <div class="input">
        报警阀值：{{ configInfo.thresholdVol }} ppm
      </div>
      <el-button class="btnBorder" @click="showConfig">设置</el-button>
    </div>
    <div class="content">
      <div>
        <el-button type="primary" size="mini" round @click="sirenList">报警列表</el-button>
      </div>
      <div>
        <el-button v-if="istable1" type="primary" size="mini" round style="width:100px" @click="clearData">一键消警
        </el-button>
      </div>
      <div>
        <el-button type="primary" size="mini" round @click="historyData">历史数据</el-button>
      </div>
    </div>
    <div class="last">
      <slot>

      </slot>
      <div
        style="margin: 10px 0;display: flex; justify-content: flex-end;"
      >
        <el-pagination
          ref="listpage"
          background
          layout="prev, pager, next"
          :pager-count="5"
          :total="total"
          :hide-on-single-page="true"
          @next-click="nextClick"
          @prev-click="prevClick"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DataTableH2S',
  props: ['name', 'istable1', 'configInfo', 'currentVls', 'total'],
  data() {
    return {}
  },
  methods: {
    clearData() {
      this.$emit('clearData')
    },
    sirenList() {
      this.$refs.listpage.handleCurrentChange(1)
      this.$emit('sirenList')
    },
    historyData() {
      this.$refs.listpage.handleCurrentChange(1)
      this.$emit('historyData')
    },
    showConfig() {
      this.$emit('changeShow', this.configInfo)
    },
    handleSizeChange(val) {
      console.log(``)
    },
    handleCurrentChange(val) {
      if (this.istable1 === true) {
        this.$emit('handleCurrentH2S', val)
      } else {
        this.$emit('handleCurrentHistoryH2S', val)
      }
    },
    prevClick(val) {
      if (this.istable1 === true) {
        this.$emit('prevClickH2S', val)
      } else {
        this.$emit('prevClickHistoryH2S', val)
      }
    },
    nextClick(val) {
      if (this.istable1 === true) {
        this.$emit('nextClickH2S', val)
      } else {
        this.$emit('nextClickHistoryH2S', val)
      }
    }
  }
}
</script>

<style lang="scss" scoped>

.is-round {
  padding: 1px 22px;
}

.container {
  width: 35%;

}

.frist {
  display: flex;
  justify-content: space-around;
  align-items: center

}

.content {
  margin: 10px 0;
  display: flex;
  justify-content: space-around;
}

.content > div {
  flex: 1;
}

.btnBorder {
  border: 1px solid #999;
  padding: 2px;
  box-sizing: border-box;
  cursor: pointer;
}
</style>
