import{A as e,C as t,E as n,M as r,St as i,T as a,V as o,X as s,bt as c,cn as l,dt as u,et as d,h as f,k as p,kt as m,w as h}from"./_plugin-vue_export-helper-9JxOV_6y.js";import{cn as g}from"./GxPagination-CS4FI5Lo.js";import{t as _}from"./upload-BTV2Ilmc.js";import{t as v}from"./message-ClNpdsVP.js";import{t as y}from"./button-BmZH_xSR.js";import{t as b}from"./dialog-0MPkyu-c.js";import{$a as x,Ja as S,hr as C,pr as w}from"./stores-DGGArz7t.js";import{g as T}from"./useStructurizedVersionDialog-Bub-H4iG.js";import{t as E}from"./request-BvcjdDug.js";var D={class:`el-upload__text`},O={style:{color:`#f00`}},k={class:`el-upload__tip`},A=r({__name:`Upload`,setup(r,{expose:A}){let j=i(`选择上传文件`),M=i(!1);function N(e){x.emit(`done_Upload`,e)}function P(e){console.log(`助兴free`),x.emit(`free_Upload`,`取消`)}let F=c({fileList:[],max:10,target_url:``,directly:!1,tip:`上传文件限`,accept:``,tip_file_url:``}),I=i({}),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){o(()=>{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=w[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 E({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 C(e,I.value,t)}function B(e){S({url:e,method:`get`,responseType:`blob`}).then(e=>{T(e.data,`模板文件.xls`)})}return A({call_UI:L}),(r,i)=>{let o=d(`upload-filled`),c=g,v=y;return s(),h(m(b),{width:`450px`,modelValue:M.value,"onUpdate:modelValue":i[3]||=e=>M.value=e,title:j.value,"close-on-click-modal":!1,"close-on-press-escape":!1,center:``,"show-close":!1},{default:u(()=>[e(m(_),{accept:F.accept,class:`upload-demo`,drag:``,multiple:``,"list-type":`picture`,"file-list":F.fileList,"onUpdate:fileList":i[2]||=e=>F.fileList=e,limit:F.max,"auto-upload":!1},{tip:u(()=>[t(`div`,k,[e(v,{class:`ml-3`,type:`success`,onClick:R},{default:u(()=>[...i[8]||=[p(l(`确定上传`),-1)]]),_:1}),e(v,{class:`ml-3`,type:`info`,onClick:i[1]||=e=>{M.value=!1,P()}},{default:u(()=>[...i[9]||=[p(l(`取消上传`),-1)]]),_:1})])]),default:u(()=>[e(c,{class:`el-icon--upload`},{default:u(()=>[e(o)]),_:1}),t(`div`,D,[i[4]||=p(l(`拖拽文件到此`)+` `+l(`或`)+` `,-1),i[5]||=t(`em`,null,l(`点此选择文件`),-1),i[6]||=t(`br`,null,null,-1),p(` `+l(F.tip)+` `,1),t(`span`,O,l(F.max),1),i[7]||=p(` `+l(`个`)+` `,-1),F.tip_file_url?(s(),n(`em`,{key:0,onClick:i[0]||=f(e=>B(F.tip_file_url),[`stop`,`prevent`])},l(`点此下载模板`))):a(``,!0)])]),_:1},8,[`accept`,`file-list`,`limit`])]),_:1},8,[`modelValue`,`title`])}}});export{A as t};