<template>
  <el-dialog v-model="visible" width="600">
    <template #header="{ close, titleId, titleClass }">
      <div class="flex-align-center gap-8 mb-10">
        <div class="cirir flex-center w-48 h-48 rounded-8">
          <IconType :modalType="modalType" />
        </div>
        <span class="fs-18">{{ title }}选择</span>
      </div>
    </template>
    <template #footer>
      <div class="flex-align-center justify-end">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="close">确定</el-button>
      </div>
    </template>
    <UploadSingleImg @changeFiles="changeFiles">
      <div class="flex-center flex-col line-h24 fs-12">
        <el-icon size="20">
          <Plus />
        </el-icon>
        <span class="mt-10 text-333"> 点击或拖拽图片到此处上传 </span>
        <span>仅支持 JPG, PNG 格式</span>
        <span>最大文件限制在 20MB 内</span>
      </div>
    </UploadSingleImg>
    <div class="text-center mt-20 mb-40">支持 JPG、PNG 格式，单个文件不超过 20MB</div>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { Plus } from '@element-plus/icons-vue'
import IconType from './IconType.vue';
import UploadSingleImg from '@/components/UploadSingleImg.vue';

const props = defineProps({
  title: {
    type: String,
    default: '新增',
  },
})

const visible = ref(false)
const imageUrl = ref('')
const modalType = ref(1) // 1:角色 2:场景 3:道具
const open = (val: number) => {
  modalType.value = val
  visible.value = true
}
const close = () => {
  visible.value = false
}
defineExpose({ open })

const changeFiles = (val: any) => {
  
}
</script>
<style lang="scss" scoped>
.cirir {
  border: 1px solid #ccc;
}

.avatar-uploader {
  width: 100%;

  :deep(.el-upload) {
    border: 2px dashed #ddd;
    width: 100%;
    height: 240px;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;

    &:hover {
      border-color: #c5c5c5;
    }
  }
}
</style>