Upload-bceb0d3c.js 8.2 KB

1
  1. var he=Object.defineProperty;var H=Object.getOwnPropertySymbols;var we=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable;var A=(i,r,s)=>r in i?he(i,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[r]=s,q=(i,r)=>{for(var s in r||(r={}))we.call(r,s)&&A(i,s,r[s]);if(H)for(var s of H(r))be.call(r,s)&&A(i,s,r[s]);return i};var g=(i,r,s)=>new Promise((D,I)=>{var N=m=>{try{U(s.next(m))}catch(P){I(P)}},S=m=>{try{U(s.throw(m))}catch(P){I(P)}},U=m=>m.done?D(m.value):Promise.resolve(m.value).then(N,S);U((s=s.apply(i,r)).next())});import{e as w,aD as ye,d as W,r as f,o as b,c as V,w as T,a as p,b as X,P as ge,u as _,_ as Y,j as J,y as M,l as k,aL as _e,t as K,q as $,bT as Q,H as Ie,b_ as xe,be as Z,b$ as ee,aX as Te,aY as Ue,E as Pe,__tla as Re}from"./index-b5895273.js";import{g as Ce,d as ke,__tla as Oe}from"./index-c53afdf5.js";import{d as De,__tla as Ne}from"./download-801edd56.js";import{u as Se,__tla as Ee}from"./upload-887cb82a.js";import{g as je}from"./base64-912b9db4.js";import{a as Be,B as Le,u as ze,__tla as Fe}from"./index-5eb30ce0.js";let ae,Ve=Promise.all([(()=>{try{return Re}catch(i){}})(),(()=>{try{return Oe}catch(i){}})(),(()=>{try{return Ne}catch(i){}})(),(()=>{try{return Ee}catch(i){}})(),(()=>{try{return Fe}catch(i){}})()]).then(()=>g(void 0,null,function*(){var i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M400 317.7h73.9V656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V317.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 163a8 8 0 00-12.6 0l-112 141.7c-4.1 5.3-.4 13 6.3 13zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"upload",theme:"outlined"};const r=i;function s(e){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?Object(arguments[t]):{},y=Object.keys(o);typeof Object.getOwnPropertySymbols=="function"&&(y=y.concat(Object.getOwnPropertySymbols(o).filter(function(d){return Object.getOwnPropertyDescriptor(o,d).enumerable}))),y.forEach(function(d){D(e,d,o[d])})}return e}function D(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var I=function(e,t){var o=s({},e,t.attrs);return w(ye,s({},o,{icon:r}),null)};I.displayName="UploadOutlined",I.inheritAttrs=!1;const N=I,S=["src"],U=W({__name:"UploadPreview",emits:["success","register"],setup(e){const t=f({}),[o,{setModalProps:y}]=Be(d=>g(this,null,function*(){y({confirmLoading:!1,height:800}),t.value=q({},d.baseData)}));return(d,n)=>{var v;return b(),V(_(Le),ge({destroyOnClose:!0,maskClosable:!1},d.$attrs,{onRegister:_(o),title:(v=t.value)==null?void 0:v.previewTitle,width:1002,height:800,footer:null,defaultFullscreen:!0}),{default:T(()=>{var x;return[p("iframe",{src:(x=t.value)==null?void 0:x.previewFile,class:"iframe-box"},null,8,S),X("; ")]}),_:1},16,["onRegister","title"])}}}),m=Y(U,[["__scopeId","data-v-8bba6a56"]]),P=e=>(Te("data-v-1bd0a673"),e=e(),Ue(),e),le={key:0},te={class:"dragger-text"},oe=P(()=>p("div",{class:"mt-2 text-xs"},"\u70B9\u51FB\u6216\u5C06\u6587\u4EF6\u62D6\u62FD\u5230\u8FD9\u91CC\u4E0A\u4F20",-1)),se={class:"dragger-tip"},ne={key:1},ie={class:"flex flex-between mt-2"},re={class:"flex-1"},ue=["onClick"],ce=["onClick"],de={class:"ml-4"},pe=["onClick"],me=W({__name:"Upload",props:{value:String,maxNumber:Number,accept:String,name:String,disabled:Boolean,multiple:Boolean,maxSize:Number,api:Function,style:Object,listType:{type:String,default:"text"},tip:String,showPreviewIcon:{type:Boolean,default:!0},showRemoveIcon:{type:Boolean,default:!0},showDownloadIcon:{type:Boolean,default:!0}},emits:["update:value","change","click","success","reload"],setup(e,{emit:t}){const o=e,[y,{openModal:d}]=ze(),n=f([]),v=f([]),{notification:x}=Pe(),h=f(""),E=f(!1),R=f(!1);f(!1);const G=f(""),ve=f("");J(()=>o.value,a=>g(this,null,function*(){a&&(xe(a)?(n.value=[{name:a.substring(a.lastIndexOf("/")+1),download:a,url:a,thumbUrl:a,status:"done",fileUrl:a}],t("reload",n.value),h.value=""):(n.value=yield Ce({folderId:o.value}),n.value.length&&(n.value.forEach(l=>{l.name=l.fileName+l.fileType,l.download=l.name,l.url=l.fileUrl,l.thumbUrl=l.thUrl,l.status="done"}),t("reload",n.value),h.value=n.value[0].folderId))),a||(n.value=[],h.value="")}),{immediate:!0}),J(()=>v.value,a=>g(this,null,function*(){if(!E.value&&a.length){let l=a.filter(u=>!u.status);if(l.length<=0)return;try{let u=yield Se({name:"file",file:l},h.value);h.value=u[0].folderId,n.value.forEach(c=>{c.status="done",c.url=c.fileUrl,c.thumbUrl=c.thUrl}),t("success",v.value),t("update:value",h.value),t("change"),R.value=!1}catch(u){R.value=!1}}}));const j=a=>o.maxSize&&a.size/1024/1024>o.maxSize?(x.error({message:"Tip",description:`\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7${o.maxSize}MB\uFF01`}),Z.LIST_IGNORE):o.maxNumber&&n.value.length+v.value.length===o.maxNumber?(x.error({message:"Tip",description:`\u6587\u4EF6\u6570\u91CF\u4E0D\u80FD\u8D85\u8FC7${o.maxNumber}\u4E2A\uFF01`}),!1):(v.value=[...v.value,a],E.value=!1,R.value=!0,Z.LIST_IGNORE);function O(){v.value=[]}const B=a=>g(this,null,function*(){const l=a.response?a.response.data.id:a.id,u=yield ke(l);h.value=u,E.value=!0;const c=n.value.findIndex(C=>C.id===l);n.value.splice(c,1),n.value.forEach(C=>{C.folderId=u}),t("update:value",h.value),t("change"),x.success({message:"Tip",description:"\u5220\u9664\u6210\u529F\uFF01"})}),L=a=>{const l=a.response?a.response.data.fileUrl:a.fileUrl,u=a.response?a.response.data.fileName+a.response.data.fileType:a.fileName+a.fileType;De({url:l,fileName:u})},z=a=>g(this,null,function*(){var u,c;const l=((c=(u=a.response)==null?void 0:u.data)==null?void 0:c.fileUrl)||a.fileUrl;G.value=ee().VITE_GLOB_FFFILEVIEW_URL+encodeURIComponent(je.encode(l.includes("http://")||l.includes("https://")?l:ee().VITE_GLOB_API_URL+l)),d(!0,{baseData:{previewTitle:a.name||a.fileName,previewFile:G.value}}),ve.value=a.name||a.fileName});return(a,l)=>{const u=M("a-upload-dragger"),c=M("a-upload"),C=M("a-button");return b(),k("div",null,[e.listType==="dragger"?(b(),k("div",le,[w(u,{"file-list":n.value,maxCount:e.maxNumber,accept:e.accept,name:e.name,disabled:e.disabled,multiple:e.multiple,beforeUpload:j,listType:"picture","show-upload-list":{showDownloadIcon:e.showDownloadIcon,showPreviewIcon:e.showPreviewIcon,showRemoveIcon:e.showRemoveIcon},onRemove:B,onDownload:L,onPreview:z,onDrop:O,onClick:O,class:"list-upload dragger-upload",style:$(e.style)},{default:T(()=>[p("div",te,[w(_(_e),{icon:"ep:upload-filled",color:"#5e95ff",size:24}),oe]),p("div",se,K(e.tip),1)]),_:1},8,["file-list","maxCount","accept","name","disabled","multiple","show-upload-list","style"])])):e.listType==="picture"?(b(),k("div",ne,[w(c,{"file-list":n.value,maxCount:e.maxNumber,accept:e.accept,name:e.name,disabled:e.disabled,multiple:e.multiple,beforeUpload:j,listType:e.listType,"show-upload-list":{showDownloadIcon:e.showDownloadIcon,showPreviewIcon:e.showPreviewIcon,showRemoveIcon:e.showRemoveIcon},onRemove:B,onDownload:L,onPreview:z,onClick:O,class:"list-upload",style:$(e.style)},{default:T(()=>[w(_(Q))]),_:1},8,["file-list","maxCount","accept","name","disabled","multiple","listType","show-upload-list","style"])])):(b(),V(c,{key:2,"file-list":n.value,maxCount:e.maxNumber,accept:e.accept,name:e.name,disabled:e.disabled,multiple:e.multiple,beforeUpload:j,listType:e.listType,"show-upload-list":{showDownloadIcon:e.showDownloadIcon,showPreviewIcon:e.showPreviewIcon,showRemoveIcon:e.showRemoveIcon},onRemove:B,onDownload:L,onPreview:z,onClick:O},{itemRender:T(({file:fe,actions:F})=>[p("div",ie,[p("div",re,[p("a",{href:"javascript:;",onClick:F.preview},K(fe.name),9,ue)]),p("div",null,[p("a",{href:"javascript:;",onClick:F.download},"\u4E0B\u8F7D",8,ce)]),p("div",de,[e.disabled?Ie("",!0):(b(),k("a",{key:0,href:"javascript:;",onClick:F.remove},"\u5220\u9664",8,pe))])])]),default:T(()=>[e.listType=="picture-card"?(b(),V(_(Q),{key:0})):(b(),k("div",{key:1,style:$(e.style)},[w(C,{loading:R.value,disabled:R.value},{default:T(()=>[w(_(N)),X(" \u70B9\u51FB\u4E0A\u4F20 ")]),_:1},8,["loading","disabled"])],4))]),_:1},8,["file-list","maxCount","accept","name","disabled","multiple","listType","show-upload-list"])),w(m,{onRegister:_(y)},null,8,["onRegister"])])}}});ae=Y(me,[["__scopeId","data-v-1bd0a673"]])}));export{ae as U,Ve as __tla};