import{P as I}from"./index.4107e0ad.js";import{E as M}from"./element-plus.33d6376e.js";import{F as R,_ as E,a as N}from"./index.0e683277.js";import{d as T,b as H}from"./index.80c2a703.js";import{_ as O}from"./index.ed42dcff.js";import{D as Z}from"./vuedraggable.611a2338.js";import{d as j,r as i,a3 as q,e as S,w as G,D as k,n as J,a4 as P,o as K,c as Q,U as n,af as W,L as u,a as s,P as U,Z as $,M as X,O as Y,H as x,_ as ee,S as le,b8 as te,b7 as ae}from"./@vue.230e89ba.js";const oe=j({components:{Popup:I,Draggable:Z,FileItem:R,Material:E,Preview:N},props:{modelValue:{type:[String,Array],default:()=>[]},type:{type:String,default:"image"},size:{type:String,default:"100px"},fileSize:{type:String,default:"100px"},limit:{type:Number,default:1},disabled:{type:Boolean,default:!1},hiddenUpload:{type:Boolean,default:!1}},emits:["change","update:modelValue"],setup(e,{emit:a}){const h=i(),_=i(),g=i(""),w=i(!1),t=i([]),p=i([]),r=i(!0),m=i(-1),{disabled:y,limit:d,modelValue:C}=q(e),b=S(()=>{switch(e.type){case"image":return"\u56FE\u7247";case"video":return"\u89C6\u9891";default:return""}}),o=S(()=>e.limit-t.value.length>0),c=S(()=>r.value?d.value==-1?null:d.value-t.value.length:1),f=()=>{const l=p.value.map(v=>v.uri);r.value?t.value=[...t.value,...l]:t.value.splice(m.value,1,l.shift()),z()},L=l=>{var v;y.value||(l>=0?(r.value=!1,m.value=l):r.value=!0,(v=h.value)==null||v.open())},A=l=>{p.value=l},z=()=>{const l=d.value!=1?t.value:t.value[0]||"";a("update:modelValue",l),a("change",l),V()},D=l=>{t.value.splice(l,1),z()},F=l=>{g.value=l,w.value=!0},V=()=>{J(()=>{var l;(l=_.value)==null||l.clearSelect()})};return G(C,l=>{t.value=Array.isArray(l)?l:l==""?[]:[l]},{immediate:!0}),k("limit",e.limit),k("hiddenUpload",e.hiddenUpload),{popupRef:h,materialRef:_,fileList:t,tipsText:b,handleConfirm:f,meterialLimit:c,showUpload:o,showPopup:L,selectChange:A,deleteImg:D,previewUrl:g,showPreview:w,handlePreview:F,handleClose:V}}});const B=e=>(te("data-v-31e93273"),e=e(),ae(),e),se={class:"material-select"},ie=["onClick"],ne={class:"operation-btns text-xs text-center"},re=B(()=>s("span",null,"\u4FEE\u6539",-1)),de=le(" | "),ue=["onClick"],pe=B(()=>s("span",null,"\u6DFB\u52A0",-1)),me={class:"material-wrap"};function ce(e,a,h,_,g,w){const t=P("file-item"),p=O,r=P("draggable"),m=H,y=E,d=M,C=I,b=P("preview");return K(),Q("div",se,[n(C,{ref:"popupRef",width:"830px","custom-class":"body-padding",title:`\u9009\u62E9${e.tipsText}`,onConfirm:e.handleConfirm,onClose:e.handleClose},W({default:u(()=>[n(d,null,{default:u(()=>[s("div",me,[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:u(()=>[s("div",{class:"material-select__trigger clearfix",onClick:a[2]||(a[2]=$(()=>{},["stop"]))},[n(r,{class:"draggable",modelValue:e.fileList,"onUpdate:modelValue":a[0]||(a[0]=o=>e.fileList=o),animation:"300","item-key":"id"},{item:u(({element:o,index:c})=>[s("div",{class:U(["material-preview",{"is-disabled":e.disabled,"is-one":e.limit==1}]),onClick:f=>e.showPopup(c)},[n(p,{onClose:f=>e.deleteImg(c)},{default:u(()=>[n(t,{uri:o,"file-size":e.size,type:e.type},null,8,["uri","file-size","type"])]),_:2},1032,["onClose"]),s("div",ne,[re,de,s("span",{onClick:$(f=>e.handlePreview(o),["stop"])},"\u67E5\u770B",8,ue)])],10,ie)]),_:1},8,["modelValue"]),X(s("div",{class:U(["material-upload",{"is-disabled":e.disabled,"is-one":e.limit==1}]),onClick:a[1]||(a[1]=o=>e.showPopup(-1))},[x(e.$slots,"upload",{},()=>[s("div",{class:"upload-btn",style:ee({width:e.size,height:e.size})},[n(m,{size:25,name:"el-icon-Plus"}),pe],4)],!0)],2),[[Y,e.showUpload]])])])}]),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 Ce=T(oe,[["render",ce],["__scopeId","data-v-31e93273"]]);export{Ce as M};
