Files
qhmes/deploy-qhmes/frontend/js/ImportExcelProgress-DNyNrbzQ.js
2026-05-15 11:34:12 +08:00

5 lines
3.4 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{d as F,b as L,f as t,e as D,ah as p,ar as E,as as h,k as m,aF as g,aC as _,G as k,av as $,A as P,au as l}from"./vue-vendor-C7Zq48Yl.js";import{q as R,u as V,bu as I,k as q,bN as G,f as K,d as X}from"./index-BI6CMai0.js";import{ai as H}from"./antd-vue-vendor-BPnV8VqP.js";import"./vxe-table-vendor-B88kchpX.js";const W=F({name:"ImportExcelProgress",components:{LoadingOutlined:H},props:{uploadUrl:{type:String,required:!0},btnText:{type:String,default:"导入"},type:{type:String,default:"user"}},emit:["success","register"],setup(s,{emit:a}){const v=t(""),y=t({}),b=t({}),{createMessage:d,createWarningModal:i}=V(),u=t(),f=R(),c=t(!1),o=t(0),n=t(),U=t(),N=f.domainUrl,O=D(()=>N+s.uploadUrl);function T(e){var C;if(e.file.name&&(v.value=e.file.name),e.file.status==="done"){if(e.file.response.success)if(e.file.response&&e.file.response.code===201){let{message:x,result:{msg:S,fileUrl:A,fileName:M}}=e.file.response,B=f.uploadUrl+A;i({title:x,centered:!1,content:`<div>
<span>${S}</span><br/>
<span>具体详情请<a href = ${B} download = ${M}> 点击下载 </a> </span>
</div>`}),o.value=100,a("success")}else d.success("文件导入成功!"),o.value=100,a("success");else d.error(e.file.response.message||`${e.file.name} 导入失败.`);r()}else(e.file.status==="error"||e.file.response&&e.file.response.code===500)&&(r(),d.error(((C=e.file.response)==null?void 0:C.message)||"导入失败,可能原因文件超出上传大小,请查看控制台或服务端日志"))}function r(){clearInterval(u.value)}function w(){o.value=1,b.value={"X-Access-Token":q(),"X-Tenant-Id":I()?I():"0"},U.value=G(16),y.value.fileKey=U.value,c.value=!0,u.value=setInterval(()=>{K.get({url:"/sys/user/getUploadFileProgress",params:{fileKey:U.value,type:s.type}},{isTransformResponse:!1}).then(e=>{e.success&&e.result&&(o.value=Math.round(e.result),e.result==100&&r())}).catch(()=>{r()})},2e3)}return L(()=>{r()}),{fileName:v,uploadData:y,headers:b,onFileChange:T,beforeUpload:w,progressOpen:c,percent:o,uploadAction:O,uploadRef:n}}}),j={style:{display:"flex"}},z={class:"file-name"},J={style:{"margin-top":"10px",display:"flex"}};function Q(s,a,v,y,b,d){const i=p("a-button"),u=p("LoadingOutlined"),f=p("a-upload"),c=p("a-progress"),o=p("a-modal");return h(),E("div",null,[m(f,{headers:s.headers,action:s.uploadAction,showUploadList:!1,multiple:!1,maxCount:1,data:s.uploadData,accept:".xls,.xlsx",onChange:s.onFileChange,beforeUpload:s.beforeUpload,ref:"uploadRef",style:{width:"100%"}},{default:g(()=>[s.percent===0||s.percent===100?(h(),_(i,{key:0,type:"primary",preIcon:"ant-design:import-outlined"},{default:g(()=>[k($(s.btnText),1)]),_:1})):(h(),_(i,{key:1,onClick:a[0]||(a[0]=P(n=>s.progressOpen=!0,["prevent","stop"])),type:"primary"},{default:g(()=>[m(u),a[2]||(a[2]=k(" 导入中 ",-1))]),_:1}))]),_:1},8,["headers","action","data","onChange","beforeUpload"]),m(o,{open:s.progressOpen,"onUpdate:open":a[1]||(a[1]=n=>s.progressOpen=n),title:"文件上传","body-style":{padding:"20px"},destroyOnClose:!0,footer:null},{default:g(()=>[l("div",null,[l("div",j,[a[3]||(a[3]=l("div",{class:"label"},"当前上传文件",-1)),l("div",z,$(s.fileName),1)]),l("div",J,[a[4]||(a[4]=l("div",{class:"label"},"当前文件上传进度:",-1)),m(c,{percent:s.percent,style:{width:"300px","margin-left":"10px"},format:n=>`${n}%`},null,8,["percent","format"])])])]),_:1},8,["open"])])}const ae=X(W,[["render",Q],["__scopeId","data-v-4dc7d5f1"]]);export{ae as default};