import{gv as a,t as e,V as t,b as o}from"./utils-lib.js?v=1761009159";import{c as s,r as l,w as r,o as p,k as c,l as i,e as u,x as n,y as m,p as d,q as f,v,I as h,J as w,C as _,D as b,z as y,A as D,b4 as g,at as k,b7 as E,au as F,av as z,bj as x}from"./base-lib.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const j={class:"p-[2rem]"},C={class:"h-[40rem] border border-[#EBEEF5] mt-[1rem]"},P={class:"ml-[0.5rem]"},U=s({__name:"upload-app",props:{compData:{default:()=>({path:"",accept:"",params:void 0,api:window.location.protocol+"//"+window.location.host+"/files?action=upload",beforeUploadEvent:void 0,refreshEvent:()=>{},help:[],useEmptyPlaceholder:!0})}},emits:["showFooterFun"],setup(s,{expose:U,emit:q}){const A=s,{proxy:B}=x(),H=a(B),I=q,J=o(),M=l(),R=l(window.location.protocol+"//"+window.location.host+"/files?action=upload"),T=l({f_size:0,f_path:"",f_name:"",f_start:0}),V=l([]),G=l(""),K={"x-http-token":window.vite_public_request_token};let L=!0;const N=()=>{J.success("导入成功"),A.compData.refreshEvent&&A.compData.refreshEvent()},O=(a,e,t)=>{t.push(e),J.error("导入失败")},Q=async a=>A.compData.beforeUploadEvent?await A.compData.beforeUploadEvent(T.value,a,S):(A.compData.params||(T.value.f_size=a.size,T.value.f_name=a.name,T.value.f_start=0),Promise.resolve(!0)),S=a=>{T.value=a},W=(a,e)=>{V.value=e||[]},X=(a,e,t)=>{T.value.f_start&&(T.value.f_start=a.percent),V.value=t.map((t=>(t.uid===e.uid&&(t.percentage=a.percent),t)))};r((()=>V.value),(()=>{if(0===V.value.length)return void I("showFooterFun",!1);const a=["success","fail","ready"];for(let e=0;e<V.value.length;e++)if(!a.includes(V.value[e].status))return void I("showFooterFun",!1);V.value.some((a=>"success"!==a.status))&&(H.confirmText=L?"开始上传":"重新上传",I("showFooterFun",!0))}),{immediate:!0});return p((()=>{var a;A.compData.path&&(T.value.f_path=A.compData.path),A.compData.accept&&(G.value=A.compData.accept),A.compData.params&&(T.value=A.compData.params),R.value=(null==(a=A.compData)?void 0:a.api)||""})),U({onConfirm:()=>{V.value.map((a=>{"success"!==a.status&&(a.status="ready")})),L=!1,M.value.submit(),I("showFooterFun",!1)}}),(a,o)=>{var s;const l=D,r=g,p=k,x=E,U=F,q=z,B=t;return c(),i("div",j,[u(r,{class:"upload-demo",ref_key:"uploadRef",ref:M,name:"blob",data:d(T),action:d(R),headers:K,accept:d(G),"on-error":O,multiple:!0,"show-file-list":!1,"auto-upload":!1,"on-success":N,"on-progress":X,"file-list":d(V),"on-change":W,"before-upload":Q},{default:n((()=>[u(l,{type:"primary"},{default:n((()=>o[0]||(o[0]=[m("导入")]))),_:1})])),_:1},8,["data","action","accept","file-list"]),f("div",C,[u(q,{height:"400",data:d(V),style:{width:"100%"}},{empty:n((()=>[u(U,{description:a.compData.accept&&a.compData.useEmptyPlaceholder?"只支持".concat(a.compData.accept,"文件格式导入"):"暂无文件"},null,8,["description"])])),default:n((()=>[u(p,{prop:"name","show-overflow-tooltip":!0,label:"名称"},{default:n((a=>[o[1]||(o[1]=f("i",{style:{color:"#409eff"},class:"svgtofont-el-document"},null,-1)),f("span",P,v(a.row.name),1)])),_:1}),u(p,{prop:"name",label:"是否成功",width:"300"},{default:n((a=>["success"===a.row.status?(c(),i(h,{key:0},[m(" 上传成功！ ")],64)):"fail"===a.row.status?(c(),i(h,{key:1},[m(" 上传失败! ")],64)):"ready"===a.row.status?(c(),i(h,{key:2},[m(" 等待上传 ")],64)):(c(),w(x,{key:3,percentage:Math.floor(a.row.percentage)},null,8,["percentage"]))])),_:1}),u(p,{width:"120",prop:"size",label:"大小"},{default:n((a=>[m(v(d(e)(a.row.size)),1)])),_:1}),u(p,{prop:"name",width:"180",align:"right","show-overflow-tooltip":!0,label:"操作"},{default:n((a=>[_(u(l,{type:"default",size:"small",onClick:e=>{return t=a.row,void(V.value=V.value.filter((a=>a.name!==t.name)));var t}},{default:n((()=>o[2]||(o[2]=[m(" 删除 ")]))),_:2},1032,["onClick"]),[[b,"ready"===a.row.status||"fail"===a.row.status]])])),_:1})])),_:1},8,["data"])]),(null==(s=a.compData.help)?void 0:s.length)?(c(),w(B,{key:0,options:A.compData.help,class:"list-disc mt-[1rem] ml-[2rem]"},null,8,["options"])):y("",!0)])}}});export{U as default};
