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,mn as h,w as g}from"./_plugin-vue_export-helper-C0lsYS1a.js";import{cn as _}from"./GxPagination-DaT0MOF0.js";import{t as v}from"./upload-BJUylRjO.js";import{t as y}from"./message-Bn2oVZM9.js";import{t as b}from"./button-CTBy3KbX.js";import{t as x}from"./dialog-C-zlcBiu.js";import{Ga as S,fr as C,ur as w,za as T}from"./stores-PVUTfPb_.js";import{h as E}from"./useStructurizedVersionDialog-ByTgs9AA.js";import{t as D}from"./request-B9wfR4zJ.js";var O={class:`el-upload__text`},k={style:{color:`#f00`}},A={class:`el-upload__tip`},j=r({__name:`Upload`,setup(r,{expose:h}){let j=i(`选择上传文件`),M=i(!1);function N(e){S.emit(`done_Upload`,e)}function P(e){console.log(`助兴free`),S.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,y({message:`${t.name} 上传完毕`,type:`success`}),e||(console.log(`upload done! `,F.fileList),N(F.fileList),M.value=!1,F.fileList=[])):(t.status=`fail`,y.error(`${t.name} 上传失败! ${n?.message||n}`))}).catch(e=>{t.status=`fail`,y.error(`${t.name} 上传失败! ${e?.message||e}`)})}catch(e){t.status=`fail`,y.error(`${t.name} 上传失败! ${e?.message||e}`)}})};async function z(e){if(F.target_url)return await D({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){T({url:e,method:`get`,responseType:`blob`}).then(e=>{E(e.data,`模板文件.xls`)})}return h({call_UI:L}),(r,i)=>{let o=d(`upload-filled`),c=_,h=b;return s(),g(m(x),{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(v),{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`,A,[e(h,{class:`ml-3`,type:`success`,onClick:R},{default:u(()=>[...i[8]||=[p(l(`确定上传`),-1)]]),_:1}),e(h,{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`,O,[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`,k,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{j as t};