2 lines
4.3 KiB
JavaScript
2 lines
4.3 KiB
JavaScript
import{P}from"./index.b76ec1c2.js";import{E as T}from"./element-plus.ab0703f2.js";import{F as N,_ as B,a as M}from"./index.27485157.js";import{u as j,d as J,b as K}from"./index.26dce67b.js";import{_ as Q}from"./index.5b716f69.js";import{D as W}from"./vuedraggable.5c3595e9.js";import{d as X,r as s,a0 as q,b as S,w as G,I as V,n as H,ah as U,o as O,c as Y,W as n,ab as Z,Q as p,a as i,a4 as $,K as I,U as x,R as ee,J as le,L as te,X as ae,bk as oe,bj as ie}from"./@vue.340249d8.js";import{e as se}from"./@vueuse.e3650918.js";const ne=X({components:{Popup:P,Draggable:W,FileItem:N,Material:B,Preview:M},props:{modelValue:{type:[String,Array],default:()=>[]},type:{type:String,default:"image"},size:{type:String,default:"100px"},width:{type:String,default:""},height:{type:String,default:""},fileSize:{type:String,default:"100px"},limit:{type:Number,default:1},disabled:{type:Boolean,default:!1},hiddenUpload:{type:Boolean,default:!1},uploadClass:{type:String,default:""},excludeDomain:{type:Boolean,default:!1}},emits:["change","update:modelValue"],setup(e,{emit:a}){const v=s(),g=s(),w=s(""),_=s(!1),t=s([]),m=s([]),d=s(!0),c=s(-1),{disabled:y,limit:r,modelValue:C}=q(e),{getImageUrl:b}=j(),o=S(()=>{switch(e.type){case"image":return"\u56FE\u7247";case"video":return"\u89C6\u9891";default:return""}}),f=S(()=>e.limit-t.value.length>0),h=S(()=>d.value?r.value==-1?null:r.value-t.value.length:1),D=se(()=>{const l=m.value.map(u=>(e.excludeDomain,u.uri));d.value?t.value=[...t.value,...l]:t.value.splice(c.value,1,l.shift()),k()},1e3,!1),A=l=>{var u;y.value||(l>=0?(d.value=!1,c.value=l):d.value=!0,(u=v.value)==null||u.open())},F=l=>{m.value=l},k=()=>{const l=r.value!=1?t.value:t.value[0]||"";a("update:modelValue",l),a("change",l),z()},L=l=>{t.value.splice(l,1),k()},R=l=>{w.value=l,_.value=!0},z=()=>{H(()=>{var l;e.hiddenUpload&&(t.value=[]),(l=g.value)==null||l.clearSelect()})};return G(C,l=>{t.value=Array.isArray(l)?l:l==""?[]:[l]},{immediate:!0}),V("limit",e.limit),V("hiddenUpload",e.hiddenUpload),{popupRef:v,materialRef:g,fileList:t,tipsText:o,handleConfirm:D,meterialLimit:h,showUpload:f,showPopup:A,selectChange:F,deleteImg:L,previewUrl:w,showPreview:_,handlePreview:R,handleClose:z,getImageUrl:b}}});const E=e=>(oe("data-v-784d730d"),e=e(),ie(),e),de={class:"material-select"},re=["onClick"],ue={class:"operation-btns text-xs text-center"},pe=E(()=>i("span",null,"\u4FEE\u6539",-1)),me=["onClick"],ce=E(()=>i("span",null,"\u6DFB\u52A0",-1)),fe={class:"material-wrap"};function he(e,a,v,g,w,_){const t=U("file-item"),m=Q,d=U("draggable"),c=K,y=B,r=T,C=P,b=U("preview");return O(),Y("div",de,[n(C,{ref:"popupRef",width:"830px","custom-class":"body-padding",title:`\u9009\u62E9${e.tipsText}`,onConfirm:e.handleConfirm,onClose:e.handleClose},Z({default:p(()=>[n(r,null,{default:p(()=>[i("div",fe,[n(y,{ref:"materialRef",type:e.type,"file-size":e.fileSize,limit:e.meterialLimit,onChange:e.selectChange},null,8,["type","file-size","limit","onChange"])])]),_:1})]),_:2},[e.hiddenUpload?void 0:{name:"trigger",fn:p(()=>[i("div",{class:"material-select__trigger clearfix",onClick:a[2]||(a[2]=$(()=>{},["stop"]))},[n(d,{class:"draggable",modelValue:e.fileList,"onUpdate:modelValue":a[0]||(a[0]=o=>e.fileList=o),animation:"300","item-key":"id"},{item:p(({element:o,index:f})=>[i("div",{class:I(["material-preview",{"is-disabled":e.disabled,"is-one":e.limit==1}]),onClick:h=>e.showPopup(f)},[n(m,{onClose:h=>e.deleteImg(f)},{default:p(()=>[n(t,{uri:e.excludeDomain?e.getImageUrl(o):o,"file-size":e.size,width:e.width,height:e.height,type:e.type},null,8,["uri","file-size","width","height","type"])]),_:2},1032,["onClose"]),i("div",ue,[pe,x(" | "),i("span",{onClick:$(h=>e.handlePreview(o),["stop"])},"\u67E5\u770B",8,me)])],10,re)]),_:1},8,["modelValue"]),ee(i("div",{class:I(["material-upload",{"is-disabled":e.disabled,"is-one":e.limit==1,[e.uploadClass]:!0}]),onClick:a[1]||(a[1]=o=>e.showPopup(-1))},[le(e.$slots,"upload",{},()=>[i("div",{class:"upload-btn",style:te({width:e.width||e.size,height:e.height||e.size})},[n(c,{size:25,name:"el-icon-Plus"}),ce],4)],!0)],2),[[ae,e.showUpload]])])]),key:"0"}]),1032,["title","onConfirm","onClose"]),n(b,{modelValue:e.showPreview,"onUpdate:modelValue":a[3]||(a[3]=o=>e.showPreview=o),url:e.previewUrl,type:e.type},null,8,["modelValue","url","type"])])}const Ue=J(ne,[["render",he],["__scopeId","data-v-784d730d"]]);export{Ue as _};
|