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