import{$ as e,B as t,C as n,O as r,S as i,St as a,T as o,Y as s,bt as c,cn as l,dt as u,j as d,k as f,kt as p,m,w as h}from"./vue.runtime.esm-bundler-DpGzKKN4.js";import"./GxPagination-DOexUzbO.js";import{Ot as g}from"./vnode-DU8g6Rf7.js";import{t as _}from"./upload-CxV36kXa.js";import{t as v}from"./message-XPlwcXDH.js";import{t as y}from"./button-CHjzS7b0.js";import{t as b}from"./dialog-BLJqz3g4.js";import"./GxDialog-BUqY5Fq3.js";import{ai as x,es as S,is as C,si as w}from"./stores-BWYw2E2w.js";import"./css-DunA3L7q.js";import{t as T}from"./request-CWxGgYu0.js";import{r as E}from"./utils-cLZb83du.js";var D={class:`el-upload__text`},O={style:{color:`#f00`}},k={class:`el-upload__tip`},A=d({__name:`Upload`,setup(d,{expose:A}){let j=a(`选择上传文件`),M=a(!1);function N(e){C.emit(`done_Upload`,e)}function P(e){console.log(`助兴free`),C.emit(`free_Upload`,`取消`)}let F=c({fileList:[],max:10,target_url:``,directly:!1,tip:`上传文件限`,accept:``,tip_file_url:``}),I=a({}),L=e=>{if(console.log(`执行 call_UI`),e&&(console.log(e),F.fileList=e.fileList===void 0?F.fileList:Array.from(e.fileList),F.directly=e.directly===void 0?F.directly:e.directly,F.max=e.max===void 0?1:e.max,F.target_url=e.target_url===void 0?``:e.target_url,F.accept=e.accept===void 0?``:e.accept,F.base_url=e.base_url===void 0?``:e.base_url,F.tip=e.tip||`上传文件限`+(F.accept+(F.accept&&`,`)),F.tip_file_url=e.tip_file_url,I.value=e.extra||{},F.ex_config=e.ex_config||{}),F.directly){t(()=>{R()});return}else M.value=!0},R=()=>{var e=F.fileList.length;console.log(`文件`,F),F.fileList.forEach(async t=>{if(t.status===`success`){--e,e||(N(F.fileList),M.value=!1,F.fileList=[]);return}t.status=`uploading`;try{await z(t).then(n=>{console.log(`uploading`,n,t),n.errorCode===0||n.resultType===`SUCCESS`?(t.status=`success`,t.url=n.url,t.res=n,t.miniType=x[t.name.slice(t.name.lastIndexOf(`.`)+1)]||``,--e,v({message:`${t.name} 上传完毕`,type:`success`}),e||(console.log(`upload done! `,F.fileList),N(F.fileList),M.value=!1,F.fileList=[])):(t.status=`fail`,v.error(`${t.name} 上传失败! ${n?.message||n}`))}).catch(e=>{t.status=`fail`,v.error(`${t.name} 上传失败! ${e?.message||e}`)})}catch(e){t.status=`fail`,v.error(`${t.name} 上传失败! ${e?.message||e}`)}})};async function z(e){if(F.target_url)return await T({url:F.target_url,method:`post`,data:{upFile:e.raw}}),{errorCode:0};var t={...F.ex_config};return F.base_url&&(t.baseURL=F.base_url),await w(e,I.value,t)}function B(e){S({url:e,method:`get`,responseType:`blob`}).then(e=>{E(e.data,`模板文件.xls`)})}return A({call_UI:L}),(t,a)=>{let c=e(`upload-filled`),d=g,v=y;return s(),n(p(b),{width:`450px`,modelValue:M.value,"onUpdate:modelValue":a[3]||=e=>M.value=e,title:j.value,"close-on-click-modal":!1,"close-on-press-escape":!1,center:``,"show-close":!1},{default:u(()=>[f(p(_),{accept:F.accept,class:`upload-demo`,drag:``,multiple:``,"list-type":`picture`,"file-list":F.fileList,"onUpdate:fileList":a[2]||=e=>F.fileList=e,limit:F.max,"auto-upload":!1},{tip:u(()=>[i(`div`,k,[f(v,{class:`ml-3`,type:`success`,onClick:R},{default:u(()=>[...a[8]||=[r(l(`确定上传`),-1)]]),_:1}),f(v,{class:`ml-3`,type:`info`,onClick:a[1]||=e=>{M.value=!1,P()}},{default:u(()=>[...a[9]||=[r(l(`取消上传`),-1)]]),_:1})])]),default:u(()=>[f(d,{class:`el-icon--upload`},{default:u(()=>[f(c)]),_:1}),i(`div`,D,[a[4]||=r(l(`拖拽文件到此`)+` `+l(`或`)+` `,-1),a[5]||=i(`em`,null,l(`点此选择文件`),-1),a[6]||=i(`br`,null,null,-1),r(` `+l(F.tip)+` `,1),i(`span`,O,l(F.max),1),a[7]||=r(` `+l(`个`)+` `,-1),F.tip_file_url?(s(),o(`em`,{key:0,onClick:a[0]||=m(e=>B(F.tip_file_url),[`stop`,`prevent`])},l(`点此下载模板`))):h(``,!0)])]),_:1},8,[`accept`,`file-list`,`limit`])]),_:1},8,[`modelValue`,`title`])}}});export{A as t};