<template>
  <div class="upload-demo" :style="{
    'border': `1px dashed ${borderColor}`,
    'background-color': `${backgroundColor}`
  }">
    <div class="h-200 flex-center flex-col" v-if="fileList.length > 0">
      <div class="flex-align-center rounded-6 px-10 py-6 file">
        <el-icon size="36" color="#3461f3"><Document /></el-icon>
        <div class="ml-4">
          <div>文件名文件名文件名</div>
          <div class="text-999 fs-12 mt-6">pdf</div>
        </div>
      </div>
      <el-button class="mt-20" round :icon="Upload" @click="fileList=[]">重新上传</el-button>
    </div>
    <el-upload v-else :show-file-list="false" :accept="accept" drag
      action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15">
      <slot />
    </el-upload>
  </div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { Document, Upload } from '@element-plus/icons-vue'

const emit = defineEmits(['changeFiles'])
const props = defineProps({
  borderColor: {
    type: String,
    default: '#ddd'
  },
  backgroundColor: {
    type: String,
    default: '#fff'
  },
  showFileList: {
    type: Boolean,
    default: false
  },
  accept: {
    type: String,
    default: 'img'
  }
})

const fileList = ref([])

</script>
<style scoped lang="scss">
.upload-demo {
  border-radius: 16px;
  transition: all 0.2s;

  &:hover {
    border-color: #5337C7 !important;
  }

  :deep(.el-upload-dragger) {
    background-color: transparent;
    border: none;
  }

  .el-upload__text {
    color: #00000063;
  }
  .file {
    border: 1px solid #eee;
    background-color: #f9f9f9;
  }
}
</style>