<template>
  <div class="orderbtob_details_wrapper">
    <div class="mobile-header">
      <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
      <p v-if="active === 'done'">已报价</p>
      <p v-if="active === 'end'">已失效</p>
      <p v-if="active === 'agreed'">已采纳</p>
      <p v-if="active === 'todo'">待报价</p>
    </div>
    <div class="orderbtob_details_content">
      <div class="orderbtob_details_top">
        <div class="item">
          <span class="name">供应商：</span>
          {{listInfo.enterprise && listInfo.enterprise.enName}}
        </div>
        <div class="item clearfix">
          <span class="name fl">收货地址：</span>
          <span class="fl" style="width: 5.2rem">{{listInfo.inquiry.enterprise && listInfo.inquiry.enterprise.enAddress}}</span>
        </div>
        <div class="item">
          <span class="name">单据：</span>
          {{listInfo.inquiry.code}}
        </div>
        <div class="item clearfix">
          <span class="name fl">物料：</span>
          <span class="fl" style="width: 5.2rem">
            <p>{{listInfo.product.code}}</p>
            <p style="margin:5px 0">{{listInfo.product.title}}</p>
            <p>{{listInfo.product.spec}}</p>
          </span>
        </div>
        <div class="item">
          <span class="name">币别：</span>
          {{listInfo.currency}}
        </div>
        <div class="item">
          <span class="name">税率：</span>
          {{listInfo.taxrate + '%' || '无'}}
        </div>
        <div class="item">
          <span class="name">询价类型：</span>
          {{listInfo.inquiry.inquirytype || '无'}}
        </div>
      </div>
      <div class="orderbtob_details_middle">
        <div class="list">
          <div class="item clearfix">
            <span class="name">交货周期：</span>
            <span>{{listInfo.leadtime || '-'}}天</span>
          </div>
          <div class="item clearfix">
            <span class="name">最小起订：</span>
            <span>{{listInfo.minOrderQty || '-'}}PCS</span>
          </div>
          <div class="item clearfix">
            <span class="name">最小包装：</span>
            <span>{{listInfo.minPackQty || '-'}}PCS</span>
          </div>
          <div class="item clearfix" style="position: relative">
            <span class="fl name">分段报价：</span>
            <ul class="fl table">
              <li class="li_title clearfix">
                <div class="fl fisrt">段数</div>
                <div class="fl">分段数量</div>
                <div class="fl" >分段单价</div>
              </li>
              <li class="li_content clearfix" v-for="(item, index) in listInfo.replies">
                <div class="fl fisrt">{{index + 1}}</div>
                <div class="fl" v-if="index === 0">
                  <input type="number" value="0" disabled readonly />
                </div>
                <div class="fl" v-if="index !== 0">
                  <input type="number" v-model="item.lapQty" />
                </div>
                <div class="fl" >
                  <input type="number" v-model="item.price" readonly/>
                </div>
              </li>
            </ul>
            <div style="clear:both"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'user_seek_btob_details',
    layout: 'mobileActivity',
    middleware: 'authenticated',
    data() {
      return {
        active: this.$route.query.active,
        listInfo: {
          inquiry: { },
          replies: [{
            lapQty: 0,
            price: ''
          }],
          product: {}
        }
      }
    },
    created() {
      this.getInitInfo()
    },
    methods: {
      getInitInfo() {
        this.$http.get(`/sale/inquiry/${this.$route.query.id}/info/mobile`).then(res => {
          if (!res.data.replies[0].price || res.data.replies[0].price === '') {
            res.data.replies[0].price = ''
          }
          this.listInfo = res.data
        })
      }
    },
    filters: {
      time: function(time) {
        if (typeof time === 'number') {
          if (!time) {
            return '无'
          } else {
            let d = new Date(time)
            let year = d.getFullYear()
            let month = d.getMonth() + 1 < 10 ? '0' + (d.getMonth() + 1) : '' + (d.getMonth() + 1)
            let day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
            return year + '-' + month + '-' + day
          }
        }
      }
    }
  }
</script>

<style scoped lang="scss">
  .orderbtob_details_wrapper {
    background: #f5f5f5;
    position: absolute;
    height: 100%;
    width: 100%;
    overflow-y: scroll;
    .mobile-header{
      position: fixed;
      top: 0;
      z-index: 10;
      width:100%;
      height:.88rem;
      line-height: .88rem;
      /*border-bottom:.01rem solid #ccc;*/
      background: #3e82f5;
      padding:0 .2rem 0 .1rem;
      color:#fff;
    }
    .mobile-header p{
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size:.36rem;
      text-align: center;
      margin: 0;
      width: 6rem;
      padding-left: 1rem;
    }
    .mobile-header a{
      font-size:.28rem;
      color:#fff;
      position: absolute;
    }
    .mobile-header a i{
      font-size: .48rem;
      margin-right: -.1rem;
    }
    .orderbtob_details_content {
      margin-top: 0.9rem;
      padding: 0.2rem;
      .orderbtob_details_top {
        background: #3f84f6;
        border-radius: 0.07rem;
        border: solid 0.01rem #e3e5e8;
        padding: 0.24rem 0.2rem 0.14rem;
        .item {
          color: #fff;
          font-size: 0.28rem;
          margin-bottom: 0.1rem;
        }
      }
      .orderbtob_details_middle {
        margin-top: 0.2rem;
        .list {
          border: solid 1px #e3e5e8;
          border-radius: 0.07rem;
          overflow: hidden;
          color: #333;
          font-size: 0.28rem;
          padding: 0.24rem 0.2rem;
          margin-bottom: 0.2rem;
          background: #fff;
          .item {
            margin-bottom: 0.1rem;
            line-height: 0.5rem;
          }
          .ovrflow {
            width: 5.2rem;
            line-height: 0.5rem
          }
          .name {
            color: #666;
            width: 1.6rem;
            display: inline-block;
          }
          .dateinput {
            width: 3.49rem;
            height: .5rem;
            line-height: .5rem;
            border: 1px solid #aeaeae;
            font-size: .26rem;
            vertical-align: middle;
            background: #fff;
            border-radius: 0;
            margin-right: 0.05rem;
          }
        }
        .replayBtn {
          width: 6.59rem;
          height: 0.77rem;
          background-color: #3f84f6;
          border-radius: 0.08rem;
          font-size: 0.28rem;
          line-height: 0.77rem;
          color: #ffffff;
          overflow: hidden;
          text-align: center;
          margin-top: 0.2rem
        }
        .table {
          width: 4.52rem;
          background-color: #f3f3f3;
          color: #333333;
          font-size: 0.28rem;
          .li_title {
            border: 1px solid #c5c5c5;
            div {
              width: 1.87rem;
              text-align: center;
              border-right: 1px solid #c5c5c5;
              &:last-child {
                border-right: 0
              }
            }
            .fisrt {
              width: 0.74rem;
            }
          }
          .li_content {
            border: 1px solid #c5c5c5;
            background: #fff;
            border-top: 0px;
            div {
              width: 1.87rem;
              text-align: center;
              border-right: 1px solid #c5c5c5;
              &:last-child {
                border-right: 0
              }
              input {
                text-align: center;
                width: 100%;
                height: 0.49rem;
                border: 0;
              }
            }
            .fisrt {
              width: 0.74rem;
            }
          }
        }
      }
      .bottom {
        font-size: 0.2rem;
        color: #999;
        border-top: 1px solid #aeaeae;
        padding-top: 0.1rem;
      }
      .noborder{
        border: 0
      }
    }
    .icon-add {
      color: #00d300;
      font-size: 0.4rem
    }
    .icon-minus {
      color: #cacaca;
      font-size: 0.4rem;
      display: block;
    }
    .posixicon {
      position: absolute;
      right: 0.3rem;
      width: 0.4rem;
      top: 0;
    }
  }
</style>
