index.4ca3083a.js 8.1 KB

1
  1. var R=Object.defineProperty,O=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var L=(l,e,t)=>e in l?R(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,v=(l,e)=>{for(var t in e||(e={}))K.call(e,t)&&L(l,t,e[t]);if(_)for(var t of _(e))D.call(e,t)&&L(l,t,e[t]);return l},h=(l,e)=>O(l,z(e));import{Z as M,s as $,e as I,r as q,bq as Z,br as x,h as m,C as H,$ as X,a0 as Y,c as i,T as G,R as J,n as P,aR as B,bs as Q,bt as b,bu as E,ac as F,bv as W,aX as ee,d as le,b1 as te,b as ae,bw as se,E as T,bx as A,a as oe}from"./index.1d0cc84f.js";import{E as ne,i as ie}from"./icon_upload.a3b9dc82.js";function re(l){let e;const t=$("loading"),s=I(!1),a=q(h(v({},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()):(x(n,t.bm("parent","relative")),n.removeAttribute("loading-number")),x(n,t.bm("parent","hidden"))}f(),g.unmount()}function f(){var n,d;(d=(n=r.$el)==null?void 0:n.parentNode)==null||d.removeChild(r.$el)}function C(){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=Z({name:"ElLoading",setup(){return()=>{const n=a.spinner||a.svg,d=m("svg",v({class:"circular",viewBox:a.svgViewBox?a.svgViewBox:"25 25 50 50"},n?{innerHTML:n}:{}),[m("circle",{class:"path",cx:"50",cy:"50",r:"20",fill:"none"})]),j=a.text?m("p",{class:t.b("text")},[a.text]):void 0;return m(G,{name:t.b("fade"),onAfterLeave:u},{default:H(()=>[X(i("div",{style:{backgroundColor:a.background||""},class:[t.b("mask"),a.customClass,a.fullscreen?"is-fullscreen":""]},[m("div",{class:t.b("spinner")},[d,j])]),[[Y,a.visible]])])})}}}),r=g.mount(document.createElement("div"));return h(v({},M(a)),{setText:o,removeElLoadingChild:f,close:C,handleAfterLeave:u,vm:r,get $el(){return r.$el}})}let y;const w=function(l={}){if(!J)return;const e=de(l);if(e.fullscreen&&y)return y;const t=re(h(v({},e),{closed:()=>{var a;(a=e.closed)==null||a.call(e),e.fullscreen&&(y=void 0)}}));ce(e,e.parent,t),U(e,e.parent,t),e.parent.vLoadingAddClassList=()=>U(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),P(()=>t.visible.value=e.visible),e.fullscreen&&(y=t),t},de=l=>{var e,t,s,a;let o;return B(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}},ce=async(l,e,t)=>{const{nextZIndex:s}=Q(),a={};if(l.fullscreen)t.originalPosition.value=b(document.body,"position"),t.originalOverflow.value=b(document.body,"overflow"),a.zIndex=s();else if(l.parent===document.body){t.originalPosition.value=b(document.body,"position"),await P();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(b(document.body,`margin-${o}`),10)}px`}for(const o of["height","width"])a[o]=`${l.target.getBoundingClientRect()[o]}px`}else t.originalPosition.value=b(e,"position");for(const[o,c]of Object.entries(a))t.$el.style[o]=c},U=(l,e,t)=>{const s=$("loading");t.originalPosition.value!=="absolute"&&t.originalPosition.value!=="fixed"?E(e,s.bm("parent","relative")):x(e,s.bm("parent","relative")),l.fullscreen&&l.lock?E(e,s.bm("parent","hidden")):x(e,s.bm("parent","hidden"))},S=Symbol("ElLoading"),V=(l,e)=>{var t,s,a,o;const c=e.instance,f=r=>F(e.value)?e.value[r]:void 0,C=r=>{const n=B(r)&&(c==null?void 0:c[r])||r;return n&&I(n)},u=r=>C(f(r)||l.getAttribute(`element-loading-${W(r)}`)),k=(t=f("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:k,target:(s=f("target"))!=null?s:k?void 0:l,body:(a=f("body"))!=null?a:e.modifiers.body,lock:(o=f("lock"))!=null?o:e.modifiers.lock};l[S]={options:g,instance:w(g)}},ue=(l,e)=>{for(const t of Object.keys(e))ee(e[t])&&(e[t].value=l[t])},N={mounted(l,e){e.value&&V(l,e)},updated(l,e){const t=l[S];e.oldValue!==e.value&&(e.value&&!e.oldValue?V(l,e):e.value&&e.oldValue?F(e.value)&&ue(e.value,t.options):t==null||t.instance.close())},unmounted(l){var e;(e=l[S])==null||e.instance.close()}},fe={install(l){l.directive("loading",N),l.config.globalProperties.$loading=w},directive:N,service:w},pe="_uploadSection_sa9wk_1",ge="_uploadFile_sa9wk_11",ve="_fileUpload_sa9wk_25",me="_uploadClass_sa9wk_40";var p={uploadSection:pe,uploadFile:ge,fileUpload:ve,uploadClass:me},xe=le({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:"images/*"},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 te.error(`\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7${this.size}M!`),!1;this.loading=fe.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 ae.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:[p.colUpload,"w-full"]},[i(ne,{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"?p.fileUpload:""},{default:()=>[i("div",{ref:"uploadDom",class:[p.uploadClass,"w-full"],style:{height:this.uploadType==="image"?"85px":"38px"}},[this.modelValue?this.uploadType==="image"?i(se,{src:this.modelValue,fit:"cover",class:p.uploadSection},null):i("div",{class:p.uploadFile},[i(T,null,{default:()=>[i(A,null,null)]}),i("span",{class:"whitespace-nowrap overflow-hidden text-ellipsis"},[this.fileName(this.modelValue)])]):this.uploadType==="image"?i("div",{class:[p.uploadSection,"flex items-center flex-col justify-center"]},[i("img",{src:ie,class:"w-8 h-7 mb-3"},null),i("p",null,[this.tips])]):i("div",{class:p.uploadFile},[i(T,null,{default:()=>[i(A,null,null)]}),oe("\u4E0A\u4F20\u6587\u4EF6")])])]}),i("p",{class:"text-3 text-[#999999] leading-6 pt-1"},[this.extraTips])])}});export{xe as C,fe as E};