<template>
  <div class="" style="padding: 20px; height: 100%">
    <div class="title" style="height:5%; width:100%">
      <div style="
              width: 100%;
              height:100%;
              text-align: center;
              border-radius: 5px;
              padding-top: 7px;
              background-color: #ddd;
              font-size: 16px;
              font-weight: 700;
              color: #11111187;
            ">
        合同信息
      </div>
    </div>
    <div class="search">
      <div class="searchInput">
        <input v-model="searchCondition.input" placeholder="请输入机号信息">
        <button style="position:absolute;right:10px" @click="detectSearchCondition()">搜索</button>
      </div>
    </div>
    <div v-if="ListNum != 0" class="billList">
      <article v-for="(item, index) in massages" :key="item.id" class="article" style="margin-top:10px">
        <img slot="left-icon" src="../../../assets\electronicContract\contract-icon.png" class="icon">
        <div slot="name" class="text" style="width: 82%;font-size: 12px;margin-top:15px">
          <div class="cont-type" style="color: #5a5959;font-size: 14px;font-weight:bold">承租人：{{ item.customername }}
          </div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">经销商：{{ item.dealername }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">产品名称：{{ item.modelname }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">合同号：{{ item.contractno }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">机号：{{ item.serialno }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">租金总额：{{ item.contractamt }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">租赁开始日：{{ item.leasebgndt }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">状态：<span>{{ item.status }}</span></div>
        </div>
        <button @click="download(index)">账单下载</button>
        <router-link :to="{name:'CmbPolyPayDetail',query:{contractno:item.contractno}}"><span class="more">﹥</span>
        </router-link>
      </article>
    </div>
    <div v-else-if="ListNum == 0" class="billList">
      <div style="
              width: 160px;
              height: 120px;
              position: relative;
              left: 50%;
              top: 100px;
              transform: translateX(-80px);
            ">
        <img src="../../../assets\image\nobill.png" style="width: 160px; height: 120px" alt="">
        <p style="text-align: center">暂无相关合同信息</p>
      </div>
    </div>
  </div>
</template>

<script>
import { getUrlParam } from '@/scripts/utils'
export default {
  data () {
    return {
      ListNum: 0,
      massages: [],
      searchCondition: {
        input: null,
      },
    }
  },
  created () {
    if (window.localStorage.openId) {
      this.searchBill(window.localStorage.openId)
    }
  },
  mounted () { },
  methods: {
    searchBill (openId) {
      let vm = this
      let value = vm.searchCondition.input
      let url = process.env.basePath + 'getCmbConList'
      // http://sign.hitachics.com/core/r/api?sysName=HCL_UPLOAD_FILE&apiName=getCmbConList
      let params = {
        // openId: "oBdoRwAgUiwsQvNGYhBYks6JJLPE",
        openId: openId,
        serialno: value,
      }
      // console.log("请求");
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, params).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result.respCode === 'S') {
          var dataInfo = JSON.parse(res.result.json)
          console.log('请求成功', dataInfo.lists)
          vm.ListNum = dataInfo.lists.length
          vm.massages = dataInfo.lists
        } else {
          vm.ListNum = 0;
          vm.hlsPopup.showLongCenter('查询合同列表失败' + res.result.respMsg)
        }
      })
    },
    download (index) {
      console.log('下载')
    },
    detectSearchCondition(){

    }
  },
}
</script>

<style lang="less" type="text/less" scoped>
.search {
  display: flex;
  //height: 50px;
  background-color: #fff;
  margin-top: 10px;
  // margin-bottom: 10px;
  position: relative;

  .searchInput {
    margin-left: 5%;
    display: -webkit-flex;
    border: 1px solid #cccccc;
    /* margin: 0.14rem 0.2rem; */
    width: 80%;
    height: 0.56rem;
    border-radius: 20px;
    display: -webkit-box;
    display: flex;
    -webkit-box-align: center;
    align-items: center;
    -webkit-align-items: center;

    input {
      text-align: center;
      width: 90%;
      margin-left: 5%;
      font-size: 13px;
      height: 17px;
      line-height: 17px;
      border: none;
      margin-top: 3px;
      margin-bottom: 4px;
      //padding-left: 11px;
    }
  }
}
// 账单卡片列表
.billList {
  //账单卡片
  width: 100%;
  .article {
    position: relative;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    margin: 0 auto 12px;
    height: 170px;
    width: 98%;
    .text {
      margin-left: 50px;
    }
    .icon {
      //左侧图标
      position: relative;
      float: left;
      width: 50px;
      padding-left: 5px;
      top: 50%;
      transform: translateY(-20px);
      img {
        width: 40px;
        height: 40px;
      }
    }
    .left-icon {
      width: 40px;
      margin-right: 0;
    }
    button {
      position: absolute;
      top: 5px;
      right: 5px;
      width: 75px;
      height: 25px;
      font-size: 14px;
      background-color: #999999;
      border: 2px solid #999999;
      border-radius: 5px;
    }
    .more {
      font-size: 32px;
      position: absolute;
      right: 5px;
      top: 50%;
      transform: translateY(-16px);
    }
    box-shadow: 3px 3px 3px 3px #b6b6b6;
  }
  padding-bottom: 30px;
  .text {
    margin-left: 15px;
    line-height: 16px;
  }
}
</style>
