import{P as I}from"./index-CdmO5-Ss.js";import{s as R}from"./element-plus-z3MwpXC9.js";import{F as T,_ as B,a as N}from"./index-CUrZWbP0.js";import{u as M,d as H,b as O}from"./index-DXEGVToZ.js";import{_ as W}from"./index-BhjDDGVa.js";import{D as j}from"./vuedraggable-OYPBN08G.js";import{d as q,r as s,_ as G,b as _,n as J,w as K,H as P,ah as U,o as Q,c as X,V as n,ac as Y,M as p,a as i,a3 as $,P as k,S as Z,O as x,I as ee,a0 as le,W as te}from"./@vue-TMcuEboY.js";import{e as ae}from"./@vueuse-BQYVjZ5N.js";const oe=q({components:{Popup:I,Draggable:j,FileItem:T,Material:B,Preview:N},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:t}){const h=s(),g=s(),w=s(""),y=s(!1),a=s([]),m=s([]),r=s(!0),f=s(-1),{disabled:C,limit:u,modelValue:b}=G(e),{getImageUrl:S}=M(),o=_(()=>{switch(e.type){case"image":return"图片";case"video":return"视频";default:return""}}),v=_(()=>e.limit-a.value.length>0),c=_(()=>r.value?u.value==-1?null:u.value-a.value.length:1),D=ae(()=>{const l=m.value.map(d=>e.excludeDomain?d.uri:d.url);r.value?a.value=[...a.value,...l]:a.value.splice(f.value,1,l.shift()),V()},1e3,!1),A=l=>{var d;C.value||(l>=0?(r.value=!1,f.value=l):r.value=!0,(d=h.value)==null||d.open())},E=l=>{m.value=l},V=()=>{const l=u.value!=1?a.value:a.value[0]||"";t("update:modelValue",l),t("change",l),z()},F=l=>{a.value.splice(l,1),V()},L=l=>{w.value=l,y.value=!0},z=()=>{J(()=>{var l;e.hiddenUpload&&(a.value=[]),(l=g.value)==null||l.clearSelect()})};return K(b,l=>{a.value=Array.isArray(l)?l:l==""?[]:[l]},{immediate:!0}),P("limit",e.limit),P("hiddenUpload",e.hiddenUpload),{popupRef:h,materialRef:g,fileList:a,tipsText:o,handleConfirm:D,meterialLimit:c,showUpload:v,showPopup:A,selectChange:E,deleteImg:F,previewUrl:w,showPreview:y,handlePreview:L,handleClose:z,getImageUrl:S}}}),ie={class:"material-select"},se=["onClick"],ne={class:"operation-btns text-xs text-center"},re=["onClick"],ue={class:"material-wrap"};function de(e,t,h,g,w,y){const a=U("file-item"),m=W,r=U("draggable"),f=O,C=B,u=R,b=I,S=U("preview");return Q(),X("div",ie,[n(b,{ref:"popupRef",width:"1050px","custom-class":"body-padding",title:`选择${e.tipsText}`,onConfirm:e.handleConfirm,onClose:e.handleClose},Y({default:p(()=>[n(u,null,{default:p(()=>[i("div",ue,[n(C,{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:t[2]||(t[2]=$(()=>{},["stop"]))},[n(r,{class:"draggable",modelValue:e.fileList,"onUpdate:modelValue":t[0]||(t[0]=o=>e.fileList=o),animation:"300","item-key":"id"},{item:p(({element:o,index:v})=>[i("div",{class:k(["material-preview",{"is-disabled":e.disabled,"is-one":e.limit==1}]),onClick:c=>e.showPopup(v)},[n(m,{onClose:c=>e.deleteImg(v)},{default:p(()=>[n(a,{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",ne,[t[4]||(t[4]=i("span",null,"修改",-1)),t[5]||(t[5]=Z(" | ")),i("span",{onClick:$(c=>e.handlePreview(o),["stop"])},"查看",8,re)])],10,se)]),_:1},8,["modelValue"]),x(i("div",{class:k(["material-upload",{"is-disabled":e.disabled,"is-one":e.limit==1,[e.uploadClass]:!0}]),onClick:t[1]||(t[1]=o=>e.showPopup(-1))},[ee(e.$slots,"upload",{},()=>[i("div",{class:"upload-btn",style:le({width:e.width||e.size,height:e.height||e.size})},[n(f,{size:25,name:"el-icon-Plus"}),t[6]||(t[6]=i("span",null,"添加",-1))],4)],!0)],2),[[te,e.showUpload]])])]),key:"0"}]),1032,["title","onConfirm","onClose"]),n(S,{modelValue:e.showPreview,"onUpdate:modelValue":t[3]||(t[3]=o=>e.showPreview=o),url:e.previewUrl,type:e.type},null,8,["modelValue","url","type"])])}const ye=H(oe,[["render",de],["__scopeId","data-v-5802b9cb"]]);export{ye as _};
