import{ar as x,cj as $,f as V,ck as B,bx as I,bv as T}from"./index-design-C8wrC2s6.js";import{d as N,f,r as F,ao as M,X as S,O as y,Y as i,a4 as u,u as L,R as n,ab as p,M as q,U as P,$ as a,_ as j,n as A}from"./vue-BQyCGvUQ.js";import{K as D,j as O,d as R,k as Y,E as d}from"./element-plus-DXXGg0hD.js";const G={class:"el-upload__text"},K={style:{color:"#f00"}},X={class:"el-upload__tip"},W=N({__name:"Upload",setup(z,{expose:b}){const U=f("选择上传文件"),o=f(!1);function c(t){x.emit("done_Upload",t)}function g(t){console.log("助兴free"),x.emit("free_Upload","取消")}const l=F({fileList:[],max:10,target_url:"",directly:!1,tip:"上传文件限",accept:"",tip_file_url:""}),m=f({}),k=t=>{if(console.log("执行 call_UI"),t&&(console.log(t),l.fileList=t.fileList===void 0?l.fileList:Array.from(t.fileList),l.directly=t.directly===void 0?l.directly:t.directly,l.max=t.max===void 0?1:t.max,l.target_url=t.target_url===void 0?"":t.target_url,l.accept=t.accept===void 0?"":t.accept,l.base_url=t.base_url===void 0?"":t.base_url,l.tip=t.tip||"上传文件限"+(l.accept+(l.accept&&",")),l.tip_file_url=t.tip_file_url,m.value=t.extra||{},l.ex_config=t.ex_config||{}),l.directly){A(()=>{_()});return}else o.value=!0},_=()=>{var t=l.fileList.length;console.log("文件",l),l.fileList.forEach(async e=>{if(e.status==="success"){--t,t||(c(l.fileList),o.value=!1,l.fileList=[]);return}e.status="uploading";try{await w(e).then(s=>{console.log("uploading",s,e),s.errorCode===0||s.resultType==="SUCCESS"?(e.status="success",e.url=s.url,e.res=s,e.miniType=$[e.name.slice(e.name.lastIndexOf(".")+1)]||"",--t,d({message:`${e.name} 上传完毕`,type:"success"}),t||(console.log("upload done! ",l.fileList),c(l.fileList),o.value=!1,l.fileList=[])):(e.status="fail",d.error(`${e.name} 上传失败! ${s?.message||s}`))}).catch(s=>{e.status="fail",d.error(`${e.name} 上传失败! ${s?.message||s}`)})}catch(s){e.status="fail",d.error(`${e.name} 上传失败! ${s?.message||s}`)}})};async function w(t){if(l.target_url)return await V({url:l.target_url,method:"post",data:{upFile:t.raw}}),{errorCode:0};var e={...l.ex_config};return l.base_url&&(e.baseURL=l.base_url),await B(t,m.value,e)}function C(t){I({url:t,method:"get",responseType:"blob"}).then(e=>{T(e.data,"模板文件.xls")})}return b({call_UI:k}),(t,e)=>{const s=M("upload-filled"),E=O,v=R;return y(),S(L(Y),{width:"450px",modelValue:o.value,"onUpdate:modelValue":e[3]||(e[3]=r=>o.value=r),title:U.value,"close-on-click-modal":!1,"close-on-press-escape":!1,center:"","show-close":!1},{default:i(()=>[u(L(D),{accept:l.accept,class:"upload-demo",drag:"",multiple:"","list-type":"picture","file-list":l.fileList,"onUpdate:fileList":e[2]||(e[2]=r=>l.fileList=r),limit:l.max,"auto-upload":!1},{tip:i(()=>[n("div",X,[u(v,{class:"ml-3",type:"success",onClick:_},{default:i(()=>[...e[8]||(e[8]=[p(a("确定上传"),-1)])]),_:1}),u(v,{class:"ml-3",type:"info",onClick:e[1]||(e[1]=r=>{o.value=!1,g()})},{default:i(()=>[...e[9]||(e[9]=[p(a("取消上传"),-1)])]),_:1})])]),default:i(()=>[u(E,{class:"el-icon--upload"},{default:i(()=>[u(s)]),_:1}),n("div",G,[e[4]||(e[4]=p(a("拖拽文件到此")+" "+a("或")+" ",-1)),e[5]||(e[5]=n("em",null,a("点此选择文件"),-1)),e[6]||(e[6]=n("br",null,null,-1)),p(" "+a(l.tip)+" ",1),n("span",K,a(l.max),1),e[7]||(e[7]=p(" "+a("个")+" ",-1)),l.tip_file_url?(y(),q("em",{key:0,onClick:e[0]||(e[0]=j(r=>C(l.tip_file_url),["stop","prevent"]))},a("点此下载模板"))):P("",!0)])]),_:1},8,["accept","file-list","limit"])]),_:1},8,["modelValue","title"])}}});export{W as _};
