2 lines
4.2 KiB
JavaScript
2 lines
4.2 KiB
JavaScript
import{P as I}from"./index.1fdb40b8.js";import{E as M}from"./element-plus.9990c39e.js";import{F as T,_ as B,a as N}from"./index.f4f18b5a.js";import{u as G,d as H,b as O}from"./index.9424646f.js";import{_ as j}from"./index.08bd2556.js";import{D as q}from"./vuedraggable.11c6ad82.js";import{d as J,r as i,_ as K,b as S,w as Q,G as z,n as W,af as U,o as X,c as Y,U as n,ab as Z,L as p,a as s,a3 as P,O as $,R as x,M as ee,H as ae,a0 as le,V as te,bl as oe,bk as se}from"./@vue.18505fe0.js";import{e as ie}from"./@vueuse.fbc6a400.js";const ne=J({components:{Popup:I,Draggable:q,FileItem:T,Material:B,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},uploadClass:{type:String,default:""},excludeDomain:{type:Boolean,default:!1}},emits:["change","update:modelValue"],setup(e,{emit:t}){const g=i(),_=i(),w=i(""),y=i(!1),l=i([]),m=i([]),r=i(!0),c=i(-1),{disabled:f,limit:u,modelValue:C}=K(e),{getImageUrl:b}=G(),o=S(()=>{switch(e.type){case"image":return"\u56FE\u7247";case"video":return"\u89C6\u9891";default:return""}}),v=S(()=>e.limit-l.value.length>0),h=S(()=>r.value?u.value==-1?null:u.value-l.value.length:1),D=ie(()=>{const a=m.value.map(d=>e.excludeDomain?d.url:d.uri);r.value?l.value=[...l.value,...a]:l.value.splice(c.value,1,a.shift()),k()},1e3,!1),A=a=>{var d;f.value||(a>=0?(r.value=!1,c.value=a):r.value=!0,(d=g.value)==null||d.open())},F=a=>{m.value=a},k=()=>{const a=u.value!=1?l.value:l.value[0]||"";t("update:modelValue",a),t("change",a),V()},L=a=>{f.value||(l.value.splice(a,1),k())},R=a=>{w.value=a,y.value=!0},V=()=>{W(()=>{var a;e.hiddenUpload&&(l.value=[]),(a=_.value)==null||a.clearSelect()})};return Q(C,a=>{l.value=Array.isArray(a)?a:a==""?[]:[a]},{immediate:!0}),z("limit",e.limit),z("hiddenUpload",e.hiddenUpload),{popupRef:g,materialRef:_,fileList:l,tipsText:o,handleConfirm:D,meterialLimit:h,showUpload:v,showPopup:A,selectChange:F,deleteImg:L,previewUrl:w,showPreview:y,handlePreview:R,handleClose:V,getImageUrl:b}}});const E=e=>(oe("data-v-04a5f58e"),e=e(),se(),e),re={class:"material-select"},ue=["onClick"],de={class:"operation-btns text-xs text-center"},pe=E(()=>s("span",null,"\u4FEE\u6539",-1)),me=["onClick"],ce=E(()=>s("span",null,"\u6DFB\u52A0",-1)),fe={class:"material-wrap"};function ve(e,t,g,_,w,y){const l=U("file-item"),m=j,r=U("draggable"),c=O,f=B,u=M,C=I,b=U("preview");return X(),Y("div",re,[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(u,null,{default:p(()=>[s("div",fe,[n(f,{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(()=>[s("div",{class:"material-select__trigger clearfix",onClick:t[2]||(t[2]=P(()=>{},["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})=>[s("div",{class:$(["material-preview",{"is-disabled":e.disabled,"is-one":e.limit==1}]),onClick:h=>e.showPopup(v)},[n(m,{onClose:h=>e.deleteImg(v)},{default:p(()=>[n(l,{uri:e.excludeDomain?e.getImageUrl(o):o,"file-size":e.size,type:e.type},null,8,["uri","file-size","type"])]),_:2},1032,["onClose"]),s("div",de,[pe,x(" | "),s("span",{onClick:P(h=>e.handlePreview(o),["stop"])},"\u67E5\u770B",8,me)])],10,ue)]),_:1},8,["modelValue"]),ee(s("div",{class:$(["material-upload",{"is-disabled":e.disabled,"is-one":e.limit==1,[e.uploadClass]:!0}]),onClick:t[1]||(t[1]=o=>e.showPopup(-1))},[ae(e.$slots,"upload",{},()=>[s("div",{class:"upload-btn",style:le({width:e.size,height:e.size})},[n(c,{size:25,name:"el-icon-Plus"}),ce],4)],!0)],2),[[te,e.showUpload]])])]),key:"0"}]),1032,["title","onConfirm","onClose"]),n(b,{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 Ue=H(ne,[["render",ve],["__scopeId","data-v-04a5f58e"]]);export{Ue as M};
|