index.e94fe3ee.js 7.7 KB

1
  1. import{t as T,f as A,r as P,bU as j,$ as B,h as v,D as F,a0 as O,a1 as R,c as i,T as D,bV as h,S as z,n as V,b4 as N,bW as K,bX as m,bY as _,ad as $,ba as M,bZ as H,d as Z,bi as q,b as Y,bD as W,H as S,bs as w,a as X}from"./index.cae74add.js";import{E as G,i as J}from"./index.c8071b5b.js";function Q(l){let e;const t=T("loading"),s=A(!1),a=P({...l,originalPosition:"",originalOverflow:"",visible:!1});function o(n){a.text=n}function c(){const n=a.parent;if(!n.vLoadingAddClassList){let d=n.getAttribute("loading-number");d=Number.parseInt(d)-1,d?n.setAttribute("loading-number",d.toString()):(h(n,t.bm("parent","relative")),n.removeAttribute("loading-number")),h(n,t.bm("parent","hidden"))}p(),g.unmount()}function p(){var n,d;(d=(n=r.$el)==null?void 0:n.parentNode)==null||d.removeChild(r.$el)}function y(){var n;if(l.beforeClose&&!l.beforeClose())return;const d=a.parent;d.vLoadingAddClassList=void 0,s.value=!0,clearTimeout(e),e=window.setTimeout(()=>{s.value&&(s.value=!1,c())},400),a.visible=!1,(n=l.closed)==null||n.call(l)}function u(){!s.value||(s.value=!1,c())}const g=j({name:"ElLoading",setup(){return()=>{const n=a.spinner||a.svg,d=v("svg",{class:"circular",viewBox:a.svgViewBox?a.svgViewBox:"25 25 50 50",...n?{innerHTML:n}:{}},[v("circle",{class:"path",cx:"50",cy:"50",r:"20",fill:"none"})]),I=a.text?v("p",{class:t.b("text")},[a.text]):void 0;return v(D,{name:t.b("fade"),onAfterLeave:u},{default:F(()=>[O(i("div",{style:{backgroundColor:a.background||""},class:[t.b("mask"),a.customClass,a.fullscreen?"is-fullscreen":""]},[v("div",{class:t.b("spinner")},[d,I])]),[[R,a.visible]])])})}}}),r=g.mount(document.createElement("div"));return{...B(a),setText:o,removeElLoadingChild:p,close:y,handleAfterLeave:u,vm:r,get $el(){return r.$el}}}let b;const C=function(l={}){if(!z)return;const e=ee(l);if(e.fullscreen&&b)return b;const t=Q({...e,closed:()=>{var a;(a=e.closed)==null||a.call(e),e.fullscreen&&(b=void 0)}});le(e,e.parent,t),L(e,e.parent,t),e.parent.vLoadingAddClassList=()=>L(e,e.parent,t);let s=e.parent.getAttribute("loading-number");return s?s=`${Number.parseInt(s)+1}`:s="1",e.parent.setAttribute("loading-number",s),e.parent.appendChild(t.$el),V(()=>t.visible.value=e.visible),e.fullscreen&&(b=t),t},ee=l=>{var e,t,s,a;let o;return N(l.target)?o=(e=document.querySelector(l.target))!=null?e:document.body:o=l.target||document.body,{parent:o===document.body||l.body?document.body:o,background:l.background||"",svg:l.svg||"",svgViewBox:l.svgViewBox||"",spinner:l.spinner||!1,text:l.text||"",fullscreen:o===document.body&&((t=l.fullscreen)!=null?t:!0),lock:(s=l.lock)!=null?s:!1,customClass:l.customClass||"",visible:(a=l.visible)!=null?a:!0,target:o}},le=async(l,e,t)=>{const{nextZIndex:s}=K(),a={};if(l.fullscreen)t.originalPosition.value=m(document.body,"position"),t.originalOverflow.value=m(document.body,"overflow"),a.zIndex=s();else if(l.parent===document.body){t.originalPosition.value=m(document.body,"position"),await V();for(const o of["top","left"]){const c=o==="top"?"scrollTop":"scrollLeft";a[o]=`${l.target.getBoundingClientRect()[o]+document.body[c]+document.documentElement[c]-Number.parseInt(m(document.body,`margin-${o}`),10)}px`}for(const o of["height","width"])a[o]=`${l.target.getBoundingClientRect()[o]}px`}else t.originalPosition.value=m(e,"position");for(const[o,c]of Object.entries(a))t.$el.style[o]=c},L=(l,e,t)=>{const s=T("loading");t.originalPosition.value!=="absolute"&&t.originalPosition.value!=="fixed"?_(e,s.bm("parent","relative")):h(e,s.bm("parent","relative")),l.fullscreen&&l.lock?_(e,s.bm("parent","hidden")):h(e,s.bm("parent","hidden"))},k=Symbol("ElLoading"),E=(l,e)=>{var t,s,a,o;const c=e.instance,p=r=>$(e.value)?e.value[r]:void 0,y=r=>{const n=N(r)&&(c==null?void 0:c[r])||r;return n&&A(n)},u=r=>y(p(r)||l.getAttribute(`element-loading-${H(r)}`)),x=(t=p("fullscreen"))!=null?t:e.modifiers.fullscreen,g={text:u("text"),svg:u("svg"),svgViewBox:u("svgViewBox"),spinner:u("spinner"),background:u("background"),customClass:u("customClass"),fullscreen:x,target:(s=p("target"))!=null?s:x?void 0:l,body:(a=p("body"))!=null?a:e.modifiers.body,lock:(o=p("lock"))!=null?o:e.modifiers.lock};l[k]={options:g,instance:C(g)}},te=(l,e)=>{for(const t of Object.keys(e))M(e[t])&&(e[t].value=l[t])},U={mounted(l,e){e.value&&E(l,e)},updated(l,e){const t=l[k];e.oldValue!==e.value&&(e.value&&!e.oldValue?E(l,e):e.value&&e.oldValue?$(e.value)&&te(e.value,t.options):t==null||t.instance.close())},unmounted(l){var e;(e=l[k])==null||e.instance.close()}},ae={install(l){l.directive("loading",U),l.config.globalProperties.$loading=C},directive:U,service:C},se="_colUpload_or6a6_1",oe="_uploadSection_or6a6_4",ne="_uploadFile_or6a6_14",ie="_fileUpload_or6a6_28",re="_uploadClass_or6a6_43",f={colUpload:se,uploadSection:oe,uploadFile:ne,fileUpload:ie,uploadClass:re},ue=Z({name:"col-upload",props:{modelValue:{type:String,default:""},uploadType:{type:String,default:"image"},disabled:{type:Boolean,default:!1},bucket:{type:String,default:"daya"},size:{type:Number,default:5},accept:{type:String,default:".png,.jpg,.jpeg"},tips:{type:String,default:"\u8BF7\u4E0A\u4F20\u56FE\u7247"},extraTips:{type:String,default:"\u56FE\u7247\u6700\u5927\u4E0D\u80FD\u8D85\u8FC75MB"},onChange:{type:Function,default:()=>{}}},data(){return{ossUploadUrl:"https://ks3-cn-beijing.ksyuncs.com/"+this.bucket,dataObj:{policy:"",signature:"",key:"",KSSAccessKeyId:"",acl:"public-read",name:""},fileList:[],loading:null}},methods:{handleSuccess(){var e;(e=this.loading)==null||e.close();let l=this.ossUploadUrl+"/"+this.dataObj.key;console.log(l),this.$emit("update:modelValue",l),this.onChange(l)},handleRemove(){console.log("remove")},handleChange(){console.log("handleChange")},handleProgress(){console.log("handleProgress")},handleError(){var l;(l=this.loading)==null||l.close()},async beforeUpload(l){console.log(l);let e=!0;if(this.size&&(e=l.size/1024/1024<this.size,!e))return q.error(`\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7${this.size}M!`),!1;this.loading=ae.service({target:this.$refs.uploadDom,lock:!0,fullscreen:!1,text:"\u4E0A\u4F20\u4E2D...",background:"rgba(0, 0, 0, 0.7)"}),console.log(this.loading);try{let t=l.name.replaceAll(" ","_"),s=new Date().getTime()+t,a={filename:t,bucketName:this.bucket,postData:{filename:t,acl:"public-read",key:s,unknowValueField:[]}};const{data:o}=await Y.post("/api-website/getUploadSign",{data:a});this.dataObj={policy:o.policy,signature:o.signature,key:s,KSSAccessKeyId:o.kssAccessKeyId,acl:"public-read",name:t}}catch{this.loading.close()}},fileName(l=""){return l.split("/").pop()},handleExceed(){}},render(){return i("div",{class:[f.colUpload,"w-full"]},[i(G,{disabled:this.disabled,action:this.ossUploadUrl,data:this.dataObj,onSuccess:this.handleSuccess,onRemove:this.handleRemove,onChange:this.handleChange,onProgress:this.handleProgress,onError:this.handleError,fileList:this.fileList,showFileList:!1,accept:this.accept,beforeUpload:this.beforeUpload,onExceed:this.handleExceed,ref:"uploadRef",class:this.uploadType==="file"?f.fileUpload:"",style:{lineHeight:"0"}},{default:()=>[i("div",{ref:"uploadDom",class:[f.uploadClass,"w-full"],style:{height:this.uploadType==="image"?"85px":"48px"}},[this.modelValue?this.uploadType==="image"?i(W,{src:this.modelValue,fit:"cover",class:f.uploadSection},null):i("div",{class:f.uploadFile},[i(S,null,{default:()=>[i(w,null,null)]}),i("span",{class:"whitespace-nowrap overflow-hidden text-ellipsis",style:{lineHeight:"1.2"}},[this.fileName(this.modelValue)])]):this.uploadType==="image"?i("div",{class:[f.uploadSection,"flex items-center flex-col justify-center"]},[i("img",{src:J,class:"w-8 h-7 mb-3"},null),i("p",null,[this.tips])]):i("div",{class:f.uploadFile},[i(S,null,{default:()=>[i(w,null,null)]}),X("\u4E0A\u4F20\u6587\u4EF6")])])]}),i("p",{class:"text-3 text-[#999999] leading-6 pt-1"},[this.extraTips])])}});export{ue as C,ae as E};