<template>
  <div class="app-container">
    <van-list>
      <!-- <van-cell v-for="item in list" :key="item" :title="item" /> -->
      <div class="list boxShadow" v-for="(item,index) in list" :key="index">
        <div class="list-main">

          <div class="list-content">
            <!-- <div class="list-title">{{ item.title}}</div> -->
            <van-row class="content-1">
              <van-col span="6">设备名称: <span class="text-colorc">{{item.name}}</span></van-col>
              <van-col span="6">开启时间: <span class="text-colorc">{{item.openTime}}</span></van-col>
              <van-col span="6">设备类型: <span class="text-colorc">{{item.type}} </span></van-col>
              <van-col span="6">运行时间:<span class="text-colorc">{{item.runTime}}</span></van-col>
            </van-row>
            <van-row class="content-1">
              <van-col span="6">所在位置: <span>{{item.location }} </span></van-col>
              <van-col span="6">关闭时间: <span class="text-colorc">{{item.offTime}} </span></van-col>
              <van-col span="6">耗电量: <span class="text-colorc">{{item.hdl}} </span></van-col>
              <van-col span="6">操作人: <span class="text-colorc">{{item.gatherer}} </span></van-col>
            </van-row>
          </div>
        </div>

      </div>
    </van-list>
    <div class="pagination-container" v-if="IsEnabled">
      <el-pagination class="right" background :current-page.sync="listQuery.page" :page-size="listQuery.limit" :page-sizes="[5, 10, 20, 30]" :total="listQuery.total" @size-change="sizeChange" @current-change="pageChange" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
    </div>
  </div>
</template>

<script>
import { getLightingRecord } from '@/api/equipControl/index'

export default {
  filters: {

  },
  data () {
    return {
      notice: false,
      IsEnabled:true,
      formInline: {
        barnName: '',
        testDate: ''
      },
      list: [
        {
          name: '空调1', openTime: '2022-12-01 12:00:00', type: '空调', gatherer: '顾小明', runTime: '6h',
          location:'1号仓库', offTime:'2022-12-01 18:00:00', hdl:'2度'
        },
        {
          name: '空调1', openTime: '2022-12-01 12:00:00', type: '空调', gatherer: '顾小明', runTime: '6h',
          location:'1号仓库', offTime:'2022-12-01 18:00:00', hdl:'2度'
        },
        {
          name: '空调1', openTime: '2022-12-01 12:00:00', type: '空调', gatherer: '顾小明', runTime: '6h',
          location:'1号仓库', offTime:'2022-12-01 18:00:00', hdl:'2度'
        },
        {
          name: '空调1', openTime: '2022-12-01 12:00:00', type: '空调', gatherer: '顾小明', runTime: '6h',
          location:'1号仓库', offTime:'2022-12-01 18:00:00', hdl:'2度'
        },
        {
          name: '空调1', openTime: '2022-12-01 12:00:00', type: '空调', gatherer: '顾小明', runTime: '6h',
          location:'1号仓库', offTime:'2022-12-01 18:00:00', hdl:'2度'
        },
        {
          name: '空调1', openTime: '2022-12-01 12:00:00', type: '空调', gatherer: '顾小明', runTime: '6h',
          location:'1号仓库', offTime:'2022-12-01 18:00:00', hdl:'2度'
        },
      ],
      loading: 'false',
      finished: 'false',

      listQuery: {
        condition: "",
        page: 1,
        limit: 10,
        total: 10,
      },
    }
  },
  created () {
    // this.form = this.$route.params.data
    console.log(this.$route.params.data,'this.$route.params.data')
  },
  mounted() {
    this.getList()
  },
  methods: {
    onSubmit () {
      console.log('submit!');
    },
    handleSizeChange (val) {
      console.log(`每页 ${val} 条`);
    },
    getList() {
      let id = this.$route.params.data.equipmentTagid
      getLightingRecord(id).then(res => {
        console.log(res,'getLightingRecord')
        if(res.code == 200) {
          this.list = res.data
          if(res.data.length == 0){
            this.IsEnabled = false
            this.$message({
              type: 'info',
              message: '暂无数据!'
            });
          }
        }
        // this.list = res
      }).catch(err =>{
        console.log(err)
      })
    },
    handleHistory () {
      this.$router.push({ name: 'EnergyConsumptionAbnormalList' })
    },
    handleDetail () {
      // this.$router.push({ name: 'EnergyConsumptionDetail' })
    },
    sizeChange (v) {
      this.listQuery.limit = v
      console.log(`每页 ${v} 条`);
      this.list.splice(v, this.list.length - 1)
    },
    pageChange (v) {
      this.listQuery.page = v
      console.log(`当前页: ${v}`);
    },
  }
}
</script>
<style lang='scss' scoped>
.boxShadow {
  box-shadow: 5px -5px 10px -4px #efe3e3, -5px 5px 10px -4px #efe3e3;
}
::v-deep .van-notice-bar {
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}
.header {
  background-color: #fff;
  border-radius: 15px;
  padding: 15px;
  padding: 15px 15px 15px 20px;
  // height: 160px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  .header-title {
    font-size: 14px;
    font-weight: 600;
    padding-left: 10px;
    border-left: 4px solid #5283e7;
  }
  .van-notice-bar {
    padding: 10px 0 10px 0;
  }
  .el-form {
    .el-form-item {
      margin-bottom: 0;
    }
  }
}
.list {
  background-color: #fff;
  border-radius: 15px;
  margin-top: 10px;
  .list-main {
    padding-left: 15px;
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    .list-title {
      font-size: 15px;
      font-weight: 700;
      padding: 10px 0;
    }
    .list-content {
      width: 90%;
      padding: 10px 10px 10px 5px;
      height: 100px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .content-1 {
        font-size: 14px;

        display: flex;
        justify-content: space-between;
        margin-top: 10px;
        // padding: 5px 0;
        strong {
          color: #d24848;
        }
        .text-colorc {
          color: #b8b8b8;
        }
      }
      .content-1:nth-last-child(1) {
        padding-bottom: 10px;
      }
    }
    .list-btns {
      width: 10%;
      background-color: #edf2fd;
      display: flex;
      justify-content: space-evenly;
      align-items: center;
    }
  }
}
</style>
