<template>
  <view class="contact-main">
    <view class="todo-list">
      <u-empty mode="list" v-if="list.length == 0"></u-empty>
      <view v-else v-for="(v, i) in list" :key="i">
        <view class="contact-item">
          <view class="flex_l">
            <view class="label">产品名称：</view>
            <view class="val">{{ v.prodName }}</view>
          </view>
          <view class="flex_l">
            <view class="label">产品型号：</view>
            <view class="val">{{ prodCode }}</view>
          </view>
          <view class="flex_l">
            <view class="label">单价：</view>
            <view class="val">{{ formatPrice(v.tranPrice) }}</view>
          </view>
          <view class="flex_l">
            <view class="label">产品数量：</view>
            <view class="val">{{ v.prodNum }}</view>
          </view>
          <view class="flex_l">
            <view class="label">合计：</view>
            <view class="val"> {{calculatedDiscount(v.tranPrice, v.prodNum)}}</view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  import to from 'await-to-js'
  import api from '@/api/contract'
  export default {
    name: 'OmsContractInvoice',
    props: {
      list: {
        type: Array,
        default: () => {
          return []
        },
      },
    },
    data() {
      return {
      }
    },
    mounted() {},
    methods: {
      // 计算总价
      calculatedDiscount(price, count) {
        let intPrice = null
        if (typeof price === 'string') intPrice = this.delcommafy(price) * 100
        else intPrice = price * 100
        return this.formatPrice((intPrice * count) / 100)
      },
    }
  }
</script>

<style lang="scss" scoped>
  .contact-main {
    height: 100%;

    .todo-list {
      height: 100%;
      overflow: auto;
      padding: 20rpx 20rpx 0;

      .contact-item {
        padding: 20rpx;
        margin-bottom: 20rpx;
        box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
        border-radius: 8px;

        .label,
        .val {
          font-size: 28rpx;
          padding-bottom: 14rpx;
        }

        .label {
          color: #646464;
        }
      }
    }
  }
</style>
