<template>
  <div>
    <div class="popTitle font-bold font-16">批号</div>
    <van-row style="padding: 0 14px 10px; color: #23262a;font-weight: 600;font-size: 15px;">
      <van-col span="6">商品信息：</van-col>
      <van-col span="18">{{goodsInfo.comGoodsId}}/({{goodsInfo.goodsOpcode}}){{goodsInfo.goodsName}}/{{goodsInfo.goodsDesc}}/{{goodsInfo.productLocation}}/{{goodsInfo.packageNum}}</van-col>
    </van-row>
    <div v-if="conditionText" style="height: 20px;background: rgb(245, 248, 251);font-size: 14px;line-height: 25px;text-align: center;">未查询到数据</div>
    <div class="lotsInfo">
      <div class="item"  v-for="(item, index) in lotsList" :key="index">
        <van-row>
          <van-col span="6">批号：</van-col>
          <van-col span=18>{{splitInfo(item.lotNo,'/')[0]}}</van-col>
        </van-row>
        <van-row>
          <van-col span="6">生产日期：</van-col>
          <van-col span="18">{{item.goodsName}}</van-col>
        </van-row>
        <van-row>
          <van-col span="6">有效日期：</van-col>
          <van-col span="18">{{item.expireDate }}</van-col>
        </van-row>
        <van-row>
          <van-col span="6">批号数量：</van-col>
          <van-col span="18">{{splitInfo(item.lotNo,'/')[1]}}</van-col>
        </van-row>
      </div>
    </div>
  </div>
</template>

<script>
import {getLotData} from '@/api/saleSituation'

export default {
  name: 'Creditworthiness',
  data() {
    return {
      lotsList: [],
      conditionText: false
    }
  },
  props: {
    goodsInfo: {
      type: Object,
      default: () => {}
    },
    dbName: {
      type: String,
      default: ''
    }
  },
  watch: {
    dbName: {
      handler(data) {
        this.getData()
      }
    },
    goodsInfo: {
      deep: true,
      handler(data) {
        this.getData()
      }
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    splitInfo(res, key) {
      return res.split(key)
    },
    getData() {
      let param = {
        'orderId': this.goodsInfo.sscOrderId,
        'goodsId': this.goodsInfo.comGoodsId,
        'start': '1',
        'length': '99',
        'dbName': this.dbName // 'erp_ogg_shaphar'
      }
      getLotData(param).then(rt => {
        if (rt.code === '1' || rt.code === 1) {
          this.lotsList = rt.data
          if (this.lotsList.length === 0) {
            // this.$toast("未查询到数据")
            this.conditionText = true
          } else {
            this.conditionText = false
          }
        }
      }).catch(e => {

      })
    }
  }
}
</script>

<style lang="scss" scoped>
  .lotsInfo {
    padding-left: 7px;
    padding-right: 7px;
    overflow: scroll;
    background: #F5F8FB;
    height: calc(100vh - 140px);

    /deep/ .van-row {
      padding-top: 6px;
      padding-bottom: 6px;

      .van-col {
        font-size: 14px;
      }

      .van-col--9 {
        color: #677282;
      }
    }

    .item {
      background: #fff;
    }
  }

  .popTitle {
    width: 100%;
    height: 46px;
    line-height: 46px;
    text-align: center;
    color: #23262A;
    font-weight: bold;
    margin: 0;
    border-bottom: 1px solid #f7f8fa;
  }

  .red-tips {
    color: $bc4;
  }
</style>
