/*申请资源*/
<template>
  <div>
    <transition name="marsk-fade">
      <div v-show="applyingConfig.isShow" class="marsk" />
    </transition>
    <transition name="slide-fade">
      <div v-show="applyingConfig.isShow" class="action-limit">
        <div class="title">
          <p>资源申请信息</p>
          <div class="operation">
            <i class="el-icon-circle-close" @click="close" />
          </div>
        </div>
        <div class="desc">
          <p>
            申请状态:
            <span>{{ getState(applyingConfig.resApplyState) }}</span>
          </p>
          <p>
            申请时间: <span>{{ formatTime(applyingConfig.resApplyTime) }}</span>
          </p>
          <p>
            申请类型: <span>{{ getType(applyingConfig.resType) }}</span>
          </p>
          <p>
            申请数量: <span>{{ applyingConfig.resCount }} 台</span>
          </p>
          <p>
            申请时长:
            <span>{{ applyingConfig.resApplyPeriod }} 小时</span>
          </p>

          <p v-if="applyingConfig.resAuditTime">
            审核时间:
            <span>{{ formatTime(applyingConfig.resAuditTime) }}</span>
          </p>
          <p v-if="applyingConfig.resAuditRejectInfo">
            审核信息:
            <span>{{ applyingConfig.resAuditRejectInfo }}</span>
          </p>
          <p v-if="applyingConfig.resApplyState == 2">
            可用时间:
            <span
              >{{ formatTime(applyingConfig.resStartTime) }} ~
              {{ formatTime(applyingConfig.resEndTime) }}</span
            >
          </p>
          <p v-if="applyingConfig.resApplyState == 2">
            可用资源:
            <span>{{ applyingConfig.resUseNums }}</span>
          </p>

          <p v-if="applyingConfig.resUseInfo">
            申请说明: <span>{{ applyingConfig.resUseInfo }}</span>
          </p>
        </div>
        <div class="btn-group">
          <el-button
            type="danger"
            size="small"
            class="next-btn"
            @click.native.prevent="sure"
            >确定</el-button
          >
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
import { formatType, formatState, parseTime } from '@/utils/index'
import { request } from '@/utils/request'
export default {
  name: 'ApplyResource',
  props: {
    applyingConfig: {
      isShow: {
        type: Boolean,
        default: () => false,
      },
      resApplyState: {
        type: String,
        default: () => '',
      },
      resType: {
        type: String,
        default: () => '',
      },
      resCount: {
        type: String,
        default: () => '',
      },
      resApplyPeriod: {
        type: String,
        default: () => '',
      },
      resUseInfo: {
        type: String,
        default: () => '',
      },
      resApplyTime: {
        type: String,
        default: () => '',
      },
      resApplyTime: {
        type: String,
        default: () => '',
      },
      resAuditTime: {
        type: String,
        default: () => '',
      },
      resAuditRejectInfo: {
        type: String,
        default: () => '',
      },
      resStartTime: {
        type: String,
        default: () => '',
      },
      resEndTime: {
        type: String,
        default: () => '',
      },
      resUseNums: {
        type: String,
        default: () => '',
      },
    },
  },
  data() {
    return {}
  },
  methods: {
    // 点击关闭
    close() {
      this.$emit('putApplying', false)
    },
    // 点击确定
    sure() {
      this.close()
    },
    // 获取类型
    getType(type) {
      return formatType(type)
    },
    // 获取状态
    getState(state) {
      return formatState(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-limit {
  @include position(absolute, 50%, auto, 55%, auto, 1001);
  @include w_h(480px);
  padding: 30px 40px;
  transform: translate(-50%, -50%);
  background: $color_f;
  border-radius: 4px;
  box-shadow: 0 0 7px 7px rgba(0, 0, 0, 0.04);
  .title {
    @include flex();
    font-size: 18px;
    font-weight: 700;
    color: $color_3;
    .operation {
      font-size: 24px;
      color: $color_9;
      &:hover {
        cursor: pointer;
        color: $color_b;
      }
    }
  }
  .num-list {
    @include w_h();
    @include flex(flex-start);
    flex-wrap: wrap;
    margin: 30px auto 10px;
  }
  .desc {
    margin: 20px auto;
    font-size: 14px;
    line-height: 28px;
    color: $color_6;
    word-break: break-all;
    span {
      font-weight: 700;
      color: $color_3;
    }
  }
  .btn-group {
    @include w_h();
    margin: 30px auto;
    .next-btn {
      @include w_h();
    }
  }
}
</style>

<style lang="scss">
@import '@/styles/variables.scss';
@import '@/styles/mixin.scss';
@supports (-webkit-mask: none) and (not (cater-color: $color_9)) {
  .el-input input {
    font-size: 12px;
    color: $color_6;
  }
}

.el-input {
  &__inner {
    padding: 0 5px;
  }
  &__inner:focus {
    border-color: $color_9;
  }
  &--suffix {
    line-height: 28px;
  }
  &--suffix .el-input__inner {
    padding-right: 20px;
  }
}
</style>
