<template>
  <div class="goods-item">
    <div class="img">
      <img :src="item.cover" alt="" srcset="">
      <div class="line-bar">
        <div>勾选</div>
        <div><el-checkbox v-model="checked1" @change="checkChange($event, item.id)"></el-checkbox></div>
      </div>
    </div>
    <div class="bo">
      <div class="tit">{{ item.title }}</div>
    </div>

    <div class="top">
      <div class="pp-it">
        <div>协议价</div>
        <div>￥{{ item.agreement_price | baiFil}}</div>
      </div>
      <div class="pp-it">
        <div>利润率</div>
        <div>{{ item.gross_profit_rate }}%</div>
      </div>
    </div>

    <div class="bo">
      <div class="pp-it">
        <div>指导价</div>
        <div>￥{{ item.market_price | baiFil}}</div>
      </div>
      <div class="pp-it">
        <div>最小利润</div>
        <div>￥{{ item.agreement_price | baiFil}}</div>
      </div>
      <div class="pp-it">
        <div>折扣</div>
        <div>{{ item.discount }}折</div>
      </div>
      <div class="pp-it">
        <div>毛利率</div>
        <div>{{ item.gross_profit_rate }}%</div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      item: {
        type: Object,
        default: () => {}
      },
    },
    data() {
      return {
        ppList: [
          { label: '协议价', value: 'agreement_price'},
          { label: '利润率', value: 'gross_profit_rate'},
          { label: '指导价', value: 'guide_price'},
          { label: '最小利润', value: 'agreement_price'},
          { label: '折扣', value: 'discount'},
          { label: '毛利率', value: 'agreement_price'},
        ],
        checked1: false
      }
    },
    filters: {
      baiFil: function (value) {
        if (!value) return ''
        // value = value.toString()
        let num = value
        try {
          num = Number(value)
        }
        catch(e) {
          return num
        }
        return (num / 100).toFixed(2)
      },
    },
    methods: {
      checkChange(val, id) {
        this.$emit('checkChange', { val, id});
      }
    }
  }
</script>

<style scoped lang="scss">
.goods-item {
  width: 240px;
  border-radius: 10px;
  border: 1px solid #ccc;
  height: 354px;
  overflow: hidden;
  margin-bottom: 26px;
  transition: all .3s;
  cursor: pointer;
  .img {
    width: 100%;
    height: 240px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px 10px 0px 0px;
    position: relative;
    img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .line-bar {
      position: absolute;
      width: 100%;
      bottom: 0px;
      left: 0px;
      display: flex;
      background-color: #df0f0f;
      color: #FFF;
      height: 0px;
      transition: all .3s;
      overflow: hidden;
      div {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        &:last-child {
        }
      }
    }
  }

  .bo {
    padding: 4px 8px;
    padding-bottom: 14px;
    min-height: 42px;
    .tit {
      overflow: hidden;
      word-break: break-all;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
    }
  }
  .pp-it {
    text-align: center;
    div {
      font-size: 12px;
    }
    div:last-child {
      color: rgb(255, 0, 0);
    }
  }
  .bo,
  .top {
    display: flex;
    transition: all .3s;
    .pp-it {
      flex: 1;
    }
  }
  .top {
    margin-bottom: 20px;
  }
  &:hover {
    border-color: #df0f0f;
    height: 374px;
    position: relative;
    cursor: pointer;
    margin-bottom: 0px;
    .top {
      margin-bottom: 0px;
    }
    .img .line-bar {
      height: 26px;
    }
  }
}
</style>
