/*查看发票*/
<template>
  <div>
    <transition name="marsk-fade">
      <div v-show="viewConfig.isShow" class="marsk" />
    </transition>
    <transition name="slide-fade">
      <div v-show="viewConfig.isShow" class="action-view">
        <div class="header">
          <div class="operation">
            <i class="el-icon-circle-close" @click="close" />
          </div>
          <p>
            共{{ viewConfig.total }}笔交易，合计金额￥{{ viewConfig.amount }}
          </p>
          <el-button size="mini" round plain @click.native.prevent="sure"
            >补寄发票</el-button
          >
        </div>
        <div class="content">
          <div
            v-for="(item, index) in viewConfig.dataList"
            :key="index"
            class="list"
          >
            <div class="desc">
              <p>
                {{ item.desc }}
                <span v-if="index == 0 && viewConfig.total > 1" class="target"
                  >当前</span
                >
              </p>
              <span>{{ formatTime(item.createTime) }}</span>
            </div>
            <span class="price">{{ item.money }}</span>
          </div>
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
import { parseTime } from '@/utils/index'
export default {
  name: 'ViewInvoice',
  props: {
    viewConfig: {
      isShow: {
        type: Boolean,
        default: () => false,
      },
      total: {
        type: Number,
        default: () => 0,
      },
      amount: {
        type: Number,
        default: () => 0,
      },
      dataList: {
        type: Array,
        default: () => [],
      },
    },
  },
  methods: {
    // 补寄发票
    sure() {
      this.$emit('putView', this.viewConfig.dataList[0].invoiceId)
    },
    // 点击关闭
    close() {
      this.$emit('putView', false)
    },
    formatTime(time) {
      return parseTime(time)
    },
  },
}
</script>

<style lang="scss" scoped>
@import '@/styles/variables.scss';
@import '@/styles/mixin.scss';

.marsk-fade-enter-active,
.marsk-fade-leave-active {
  transition: all 0.5s;
}
.marsk-fade-enter,
.marsk-fade-leave-to {
  opacity: 0;
}
.marsk {
  @include position(fixed, 0, 0, 0, 0, 1000);
  background: rgba(4, 112, 204, 0.05);
}

.slide-fade-enter-active {
  transition: all 0.3s ease;
}
.slide-fade-leave-active {
  transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter,
.slide-fade-leave-to {
  transform: translateY(7.48rem);
}
.action-view {
  @include position(fixed, 50%, auto, 55%, auto, 1001);
  @include w_h(400px);
  transform: translate(-50%, -50%);
  background: $color_f;
  text-align: left;
  box-shadow: 0 0 7px 7px rgba(0, 0, 0, 0.04);
  .header {
    @include w_h();
    position: relative;
    padding: 10px 30px;
    color: $color_f;
    background: #0470cc;
    .operation {
      @include position(absolute, 5px, auto, auto, 5px, 1);
      font-size: 24px;
      color: $color_d;
    }
    .operation:hover {
      cursor: pointer;
      color: $color_f5;
    }
    p {
      margin: 10px auto;
      font-size: 14px;
    }
  }
  .content {
    @include w_h(100%, 250px);
    padding: 10px 30px 30px;
    color: $color_3;
    overflow-y: auto;
    .list {
      @include flex();
      padding: 10px 0;
      border-bottom: 1px solid $color_f5;
      .desc {
        font-size: 14px;
        line-height: 22px;
        span {
          color: $color_9;
        }
        .target {
          margin-left: 10px;
          padding: 0 5px;
          font-size: 12px;
          color: #0470cc;
          border: 1px solid #0470cc;
          border-radius: 4px;
          transform: scale(0.8);
        }
      }
      .price {
        font-size: 16px;
      }
    }
  }
}
</style>

<style lang="scss">
@import '@/styles/variables.scss';
@import '@/styles/mixin.scss';
.action-view {
  .el-button {
    font-size: 12px;
    color: $color_f;
    background-color: #0470cc;
    border-color: $color_f5;
    &--mini,
    &--mini.is-round {
      padding: 5px 15px;
    }
    &:focus,
    &:hover {
      background: $color_e;
      border-color: $color_e;
    }
  }
}
</style>
