
<template>
    <el-upload
        accept="doc, docx, xls, xlsx, ppt, pptx, pdf, txt, zip, rar, tar, jpg, png, gif, jpeg, webp, wmv, avi, mpg, mpeg, 3gp, mov, mp4, flv, f4v, rmvb, mkv"
        class="upload-demo" :show-file-list="false" aria-hidden="true" :headers="{ Token: userStore?.token }"
        :action="base_url + '/upload/file'" :on-success="handleAvatarSuccess" ref="upload">
        <el-button type="primary">
            上传
        </el-button>
    </el-upload>
    <div>
        <div v-for="(item, index) in annex" style="margin-left: 5px;display: block;">
            <a style="margin-left: 10px; color: #4a5dff; align-self: flex-start" :href="item.uri" target="_blank">{{
                item.name }}</a>
            <span style="cursor: pointer;margin-left: 5px;" @click="delFile(index)">x</span>
        </div>
    </div>
</template>
<script setup>
import { ref, reactive, defineProps, defineEmits } from "vue"
import configs from "@/config"
import useUserStore from "@/stores/modules/user";
const userStore = useUserStore();
const base_url = ref(configs.baseUrl + configs.urlPrefix)
const props = defineProps({
    annex: Array
})

const emits = defineEmits(["handleAvatarSuccess", 'delFileFn']);
const handleAvatarSuccess = (res) => { emits("handleAvatarSuccess", res); }
const delFile = (index) => { emits("delFile", index); }

</script>