import"./index-sxX6oYqj.js";/* empty css                  */import{d as $,b as f,r as V,V as B,W as r,u as x,n as I,N as y,a1 as u,O as n,aq as N,_ as p,M as T,Y as M,$ as a,a5 as q}from"./vue-ChXMuCsz.js";import{e as L,M as F,w as S,y as P}from"./common-controller-tool-CauSZAqV.js";import{f as A}from"./request-yGlVfSRy.js";import{k as D}from"./add-or-edit.vue_vue_type_style_index_0_lang-DU4oKO67.js";import{b as O,k as Y,U as G,d as R,o as d}from"./element-plus-xvP3-5Ws.js";const W={class:"el-upload__text"},j={style:{color:"#f00"}},z={class:"el-upload__tip"},le=$({__name:"Upload",setup(H,{expose:b}){const U=f("选择上传文件"),o=f(!1);function c(t){L.emit("done_Upload",t)}function g(t){console.log("助兴free"),L.emit("free_Upload","取消")}const l=V({fileList:[],max:10,target_url:"",directly:!1,tip:"上传文件限",accept:"",tip_file_url:""}),m=f({}),w=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){I(()=>{_()});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 k(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=F[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 k(t){if(l.target_url)return await A({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 S(t,m.value,e)}function C(t){P({url:t,method:"get",responseType:"blob"}).then(e=>{D(e.data,"模板文件.xls")})}return b({call_UI:w}),(t,e)=>{const s=N("upload-filled"),E=O,v=Y;return y(),B(x(R),{width:"450px",modelValue:o.value,"onUpdate:modelValue":e[3]||(e[3]=i=>o.value=i),title:U.value,"close-on-click-modal":!1,"close-on-press-escape":!1,center:"","show-close":!1},{default:r(()=>[u(x(G),{accept:l.accept,class:"upload-demo",drag:"",multiple:"","list-type":"picture","file-list":l.fileList,"onUpdate:fileList":e[2]||(e[2]=i=>l.fileList=i),limit:l.max,"auto-upload":!1},{tip:r(()=>[n("div",z,[u(v,{class:"ml-3",type:"success",onClick:_},{default:r(()=>[...e[8]||(e[8]=[p(a("确定上传"),-1)])]),_:1}),u(v,{class:"ml-3",type:"info",onClick:e[1]||(e[1]=i=>{o.value=!1,g()})},{default:r(()=>[...e[9]||(e[9]=[p(a("取消上传"),-1)])]),_:1})])]),default:r(()=>[u(E,{class:"el-icon--upload"},{default:r(()=>[u(s)]),_:1}),n("div",W,[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",j,a(l.max),1),e[7]||(e[7]=p(" "+a("个")+" ",-1)),l.tip_file_url?(y(),T("em",{key:0,onClick:e[0]||(e[0]=q(i=>C(l.tip_file_url),["stop","prevent"]))},a("点此下载模板"))):M("",!0)])]),_:1},8,["accept","file-list","limit"])]),_:1},8,["modelValue","title"])}}});export{le as _};
