import{u as e}from"./upload-f9f23203-1780912037814v=1.0.0.js";import{d as a,A as i,B as l,C as s,s as t,D as d,r as o,G as p,a as n,b as u,h as f,e as r,w as m,p as c,c as g,f as v,j as y,l as b,H as h,I as w,_}from"./index-d052b22f-1780912037814v=1.0.0.js";const x={class:"upload-box"},F=a({name:"UploadImg"}),L=_(a({...F,props:{fileList:{default:()=>[]},showFileList:{type:Boolean,default:!0},api:{},drag:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},limit:{default:5},fileSize:{default:100},fileType:{default:()=>["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","image/jpg","image/png","image/gif","image/bmp","image/jpeg"]},height:{},width:{},borderRadius:{},isFullUrl:{type:Boolean}},emits:["update:fileList","uploadFile"],setup(a,{emit:_}){const F=i(l,void 0),L=i(s,void 0),z=t((()=>B.disabled||(null==F?void 0:F.disabled))),j=t({set(e){$("update:fileList",e)},get:()=>B.fileList}),B=a,S=d(),D=o(S.default),I=o("id-"+p()),U=async a=>{var i;let l=new FormData;l.append("Filedata",a.file);try{const s=null!=(i=B.api)?i:e,{data:t}=await s(l);a.onSuccess(t)}catch(s){a.onError(s)}},T=e=>{const a=e.size/1024/1024<B.fileSize,i=B.fileType;return i.includes(e.type)||w({title:"温馨提示",message:"上传文件不符合所需的格式！",type:"warning"}),a||w({title:"温馨提示",message:`上传文件大小不能超过 ${B.fileSize}M！`,type:"warning"}),i.includes(e.type)&&a},$=_,k=(e,a)=>{e&&(a.name=e.name,a.file_path=e.file_path,a.file_url=e.file_url,a.url=e.file_path,a.size=e.size,a.suffix=e.suffix,$("update:fileList",j.value),$("uploadFile",j.value),(null==L?void 0:L.prop)&&(null==F||F.validateField([L.prop])),w({title:"温馨提示",message:"文件上传成功！",type:"success"}))},q=()=>{w({title:"温馨提示",message:"文件上传失败，请您重新上传！",type:"error"})},A=()=>{w({title:"温馨提示",message:"当前最多只能上传 1 个文件，请移除后上传！",type:"warning"})},C=e=>{};return(e,a)=>{const i=n("el-button"),l=n("el-upload");return u(),f("div",x,[r(l,{action:"#",id:I.value,multiple:!1,"show-file-list":e.showFileList,limit:e.limit,disabled:v(z),"file-list":v(j),"onUpdate:fileList":a[0]||(a[0]=e=>h(j)?j.value=e:null),"http-request":U,"before-upload":T,"on-success":k,"on-error":q,"on-exceed":A,"on-progress":C},{default:m((()=>[c(e.$slots,"default",{},void 0,!0),D.value?b("v-if",!0):(u(),g(i,{key:0,type:"primary",disabled:v(z)},{default:m((()=>a[1]||(a[1]=[y("点击上传")]))),_:1},8,["disabled"]))])),_:3},8,["id","show-file-list","limit","disabled","file-list"])])}}}),[["__scopeId","data-v-661bd7ac"]]);export{L as D};
