<template>
  <div>
    <ul class="file-list" v-if="files.length">
      <li class="file-list-item" v-for="file in files" :key="file.id">
        <a :href="file.file_url" target="_blank">
          <i class="el-icon-document"></i>
          {{ file.file_name }}
        </a>
        <span v-if="file.file_size">{{ file.file_size }}</span>
        <a :href="file.file_url" :download="file.file_name" target="_blank">
          <el-tooltip effect="dark" content="下载">
            <i class="el-icon-download"></i>
          </el-tooltip>
        </a>
      </li>
    </ul>
    <div class="empty" v-else>
      <slot name="empty">暂无课程资料</slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'FilePanel',
  props: {
    // 标题
    title: { type: String, default: '课程资料' },
    // 文件列表
    files: { type: Array, default: () => [] }
  }
}
</script>

<style lang="scss" scoped>
.file-list {
  padding: 0;
}
.file-list-item {
  display: flex;
  font-size: 16px;
  padding: 20px 30px;
  margin-bottom: 10px;
  background-color: #fff;
  list-style: none;
  border-radius: 32px;
  justify-content: space-between;
  a {
    text-decoration: none;
    color: #333;
    &:hover {
      color: #b49441;
    }
  }
}
.empty {
  font-size: 18px;
  line-height: 80px;
  background-color: #fff;
  text-align: center;
  border-radius: 40px;
}
</style>
