/*查看资源*/
<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>资源信息</p>
        </div>
        <div class="content">
          <div class="desc">
            <p>
              资源名称：<span>{{ viewConfig.data.name }}</span>
            </p>
            <p>
              资源类型：<span>{{ getType(viewConfig.data.type) }}</span>
            </p>
            <p>
              资源规格：<span>{{ viewConfig.data.capacity }}</span>
            </p>
            <p>
              购买的时段：<span
                >{{ formatTime(viewConfig.data.starttime) }} ~
                {{ formatTime(viewConfig.data.endtime) }}</span
              >
            </p>

            <p>
              资源状态：<span>{{ getState(viewConfig.data.state) }}</span>
            </p>
          </div>
          <div class="desc" v-if="viewConfig.data.state == 2">
            <p>
              分配的项目：<span>{{
                viewConfig.data.distributionProjectName
              }}</span>
            </p>
            <p>
              分配的用户:<span>{{ viewConfig.data.distributionUserName }}</span>
            </p>
            <p>
              分配的时段：<span
                >{{ formatTime(viewConfig.data.distributionStarttime) }} ~
                {{ formatTime(viewConfig.data.distributionEndtime) }}</span
              >
            </p>
          </div>
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
import { formatType, formatStatus, parseTime } from '@/utils/index'
export default {
  name: 'ViewInvoice',
  props: {
    viewConfig: {
      isShow: {
        type: Boolean,
        default: () => false,
      },
      data: {
        type: Object,
        default: () => {},
      },
    },
  },
  methods: {
    // 点击关闭
    close() {
      this.$emit('putView', false)
    },
    // 获取类型
    getType(type) {
      return formatType(type)
    },
    // 获取状态
    getState(state) {
      return formatStatus(state)
    },
    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(absolute, 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;
    overflow-y: auto;
    .desc {
      font-size: 12px;
      color: $color_3;
      font-weight: 600;
      line-height: 22px;
      span {
        color: $color_6;
      }
    }
  }
}
</style>
