import{u as F}from"./api.BPEftIz6.js";import{h as p}from"./hasPermission.lEsua58A.js";/* empty css                   */import{J as b,h as d}from"./elementPlus.CqHltQSO.js";import{d as C,a1 as E,B as S,r as m,ai as f,o as h,c as V,U as I,O as y,u as a,M as U,H as D,K as M,R as N}from"./vue.1RczIYhx.js";const J=C({__name:"index",props:{uploadFunction:{type:Function},size:{},type:{},icon:{},nativeType:{},loadingIcon:{},plain:{type:Boolean},text:{type:Boolean},link:{type:Boolean},bg:{type:Boolean},autofocus:{type:Boolean},round:{type:Boolean},circle:{type:Boolean},dark:{type:Boolean},autoInsertSpace:{type:Boolean},tag:{}},emits:["handel-error"],setup(g,{emit:_}){const t=E(),r=S("refreshView"),i=g,n=m(),l=m(!1),B=_;function w(e){n.value.clearFiles();const o=e[0];o.uid=b(),n.value.handleStart(o),n.value.submit()}async function x(e){l.value=!0;try{const{file:o}=e,s=new FormData;s.append("file",o);const k=(await F(s)).data.url,u=await i.uploadFunction({url:k});v(u),e.onSuccess(u)}catch(o){console.log("==Error==",o),e.onError(o)}finally{l.value=!1}}function v(e){if(e.data&&e.data.length!==0){B("handel-error",e.data);return}e.code===2e3?(d.success({message:e.msg,plain:!0}),r&&r()):d.error({message:"上传失败",plain:!0})}return(e,o)=>{const s=f("el-button"),c=f("el-upload");return h(),V("div",null,[I(c,{ref_key:"upload",ref:n,"auto-upload":!0,"http-request":x,limit:1,"on-exceed":w,"show-file-list":!1,accept:".xls,.xlsx",action:"#"},{trigger:y(()=>[!a(t).show||a(p)(a(t).show)?(h(),U(s,M({key:0,color:a(t).myColor,disabled:a(t).permissions?!a(p)(a(t).permissions):!1,loading:a(l)},i),{default:y(()=>[D(e.$slots,"default")]),_:3},16,["color","disabled","loading"])):N("",!0)]),_:3},512)])}}});export{J as _};
