<template>
  <div class="instrumentLeisureComponentTable">
    <div class="top-title-max-ox">
      <p></p>
      <p>大仪预约排行</p>
      <p></p>
      <div class="title-button" @click="outButton">
        <img src="@/assets/ZDimages/icon_yh_fh@1x.png">
        <p>返回</p>
      </div>
    </div>
    <div class="table-title-box">
      <p class="table-title-p">数据筛选</p>
      <el-form :model="queryParams" class="form-box" ref="queryForm"
               :inline="true" style="width:100%;">
        <el-form-item label="设备：" prop="deviceName">
          <el-input
            v-model="queryParams.deviceName"
            placeholder="输入设备"
            style="width:178px;"
          />
        </el-form-item>
        <p class="form-inquire-common-style-button" @click="handleQuery">查询</p>
        <p class="form-reset-common-style-button" @click="resetQuery">重置</p>
      </el-form>
    </div>
    <div class="table-list-box">
      <p class="table-list-p">数据列表</p>
      <div class="table-list">
        <el-table class="table-box"
                  :data="dataList" @sort-change="sortChange">
          <el-table-column align="center" label="序号"  width="150"  type="index"/>
          <el-table-column align="center" label="设备名称" prop="deviceName" show-overflow-tooltip/>
          <el-table-column align="center" sortable="custom" label="预约时长" width="300" prop="orderDuration" show-overflow-tooltip/>
          <el-table-column align="center" label="预约次数" prop="orderNum" width="300" show-overflow-tooltip/>
          <el-table-column align="center" label="最后一次预约日期" width="600" prop="lastOrderTime" show-overflow-tooltip>
            <template slot-scope="scope">
              <span>{{scope.row.lastOrderTime?parseTime(scope.row.lastOrderTime,'{y}-{m}-{d} {h}:{i}'):'--'}}</span>
            </template>
          </el-table-column>
        </el-table>
        <pagination :page-sizes="[20, 30, 40, 50]"
                    v-show="total>0"
                    :total="total"
                    :page.sync="queryParams.page"
                    :limit.sync="queryParams.pageSize"
                    @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>
<script>
  import { reportReportBsEquipAppointList } from "@/api/index";
  export default {
    name: 'instrumentLeisureComponentTable',
    data () {
      return {
        //查询条件
        queryParams:{
          page:1,
          pageSize:20,
          deviceName:"",
          ascOrDesc:'',
        },
        //列表数据
        dataList:[],
        //数据数量
        total:60,
      }
    },
    created(){

    },
    mounted(){
      this.getList();
    },
    methods:{
      outButton(){
        this.$parent.checkComponentType(null)
      },
      //排序方法
      sortChange(val){
        if(val.prop == 'orderDuration'){
          this.$set(this.queryParams,'ascOrDesc',val.order=='ascending'?true:(val.order=='descending'?false:''));
          this.handleQuery();
        }else{
          this.$set(this.queryParams,'ascOrDesc','');
          this.handleQuery();
        }
      },
      //列表查询
      getList(){
        reportReportBsEquipAppointList(this.queryParams).then(response => {
          this.$set(this,'dataList',response.data.records);
          this.$set(this,'total',response.data.total);
        });
      },
      //查询按钮
      handleQuery(){
        this.$set(this.queryParams,'page',1);
        this.getList();
      },
      //重置按钮
      resetQuery(){
        this.$set(this,'queryParams',{
          page:1,
          pageSize:20,
          deviceName:"",
          ascOrDesc:'',
        });
        this.getList();
      },
    },
  }
</script>
<style scoped lang="scss">
  .instrumentLeisureComponentTable{
    padding:0 62px;
    height:1340px;
    display: flex;
    flex-direction: column;
    flex:1;
    overflow: hidden;
    .top-title-max-ox{
      display: flex;
      margin:20px 0;
      p:nth-child(1){
        width:10px;
        height:30px;
        background-color: #15827C;
        margin:5px 20px 0 0;
      }
      p:nth-child(2){
        color:#00FFFF;
        font-size:26px;
        line-height:40px;
      }
      p:nth-child(3){
        flex:1;
      }
      .title-button{
        width:120px;
        height:40px;
        background-color: #021D20;
        border:1px solid #15827C;
        display: flex;
        cursor: pointer;
        img{
          display: block;
          width:24px;
          height:24px;
          margin:8px 15px 0 12px;
        }
        p{
          font-size:18px;
          line-height:42px;
          color:#fff;
        }
      }
    }
    .table-title-box{
      height:200px;
      background-color: #002329;
      margin-bottom:20px;
      .table-title-p{
        line-height:80px;
        border-bottom:1px solid #15827C;
        padding-left:30px;
        font-size:24px;
        color:#fff;
      }
    }
    .table-list-box{
      flex:1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      background: linear-gradient(180deg, rgba(4, 117, 129, 0.2) 0%, rgba(0, 15, 22, 0) 100%);
      .table-list-p{
        line-height:80px;
        border-bottom:1px solid #15827C;
        padding-left:30px;
        font-size:24px;
        color:#fff;
      }
      .table-list{
        padding:35px 30px 0;
        flex:1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }
    }
  }
</style>
