moreShopAdmin/build/admin/assets/picker.ef5d1750.js

2 lines
4.1 KiB
JavaScript

import{P as B}from"./index.d78ce335.js";import{E as R}from"./element-plus.91c68cc0.js";import{F as T,_ as E,a as N}from"./index.2efc98a8.js";import{u as M,d as G,b as H}from"./index.e9c2eb26.js";import{_ as O}from"./index.ece4e136.js";import{D as j}from"./vuedraggable.c04c7c0c.js";import{d as q,r as i,_ as J,b as U,w as K,G as $,n as Q,af as S,o as W,c as X,U as n,ab as Y,L as p,a as s,a3 as k,O as P,R as Z,M as x,H as ee,a0 as le,V as ae}from"./@vue.76ce7aa3.js";import{e as te}from"./@vueuse.9ffef7f8.js";const oe=q({components:{Popup:B,Draggable:j,FileItem:T,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},uploadClass:{type:String,default:""},excludeDomain:{type:Boolean,default:!1}},emits:["change","update:modelValue"],setup(e,{emit:a}){const g=i(),h=i(),w=i(""),y=i(!1),t=i([]),m=i([]),r=i(!0),f=i(-1),{disabled:_,limit:u,modelValue:C}=J(e),{getImageUrl:b}=M(),o=U(()=>{switch(e.type){case"image":return"\u56FE\u7247";case"video":return"\u89C6\u9891";default:return""}}),c=U(()=>e.limit-t.value.length>0),v=U(()=>r.value?u.value==-1?null:u.value-t.value.length:1),I=te(()=>{const l=m.value.map(d=>e.excludeDomain?d.url:d.uri);r.value?t.value=[...t.value,...l]:t.value.splice(f.value,1,l.shift()),V()},1e3,!1),D=l=>{var d;_.value||(l>=0?(r.value=!1,f.value=l):r.value=!0,(d=g.value)==null||d.open())},A=l=>{m.value=l},V=()=>{const l=u.value!=1?t.value:t.value[0]||"";a("update:modelValue",l),a("change",l),z()},F=l=>{t.value.splice(l,1),V()},L=l=>{w.value=l,y.value=!0},z=()=>{Q(()=>{var l;e.hiddenUpload&&(t.value=[]),(l=h.value)==null||l.clearSelect()})};return K(C,l=>{t.value=Array.isArray(l)?l:l==""?[]:[l]},{immediate:!0}),$("limit",e.limit),$("hiddenUpload",e.hiddenUpload),{popupRef:g,materialRef:h,fileList:t,tipsText:o,handleConfirm:I,meterialLimit:v,showUpload:c,showPopup:D,selectChange:A,deleteImg:F,previewUrl:w,showPreview:y,handlePreview:L,handleClose:z,getImageUrl:b}}});const se={class:"material-select"},ie=["onClick"],ne={class:"operation-btns text-xs text-center"},re=["onClick"],ue={class:"material-wrap"};function de(e,a,g,h,w,y){const t=S("file-item"),m=O,r=S("draggable"),f=H,_=E,u=R,C=B,b=S("preview");return W(),X("div",se,[n(C,{ref:"popupRef",width:"830px","custom-class":"body-padding",title:`\u9009\u62E9${e.tipsText}`,onConfirm:e.handleConfirm,onClose:e.handleClose},Y({default:p(()=>[n(u,null,{default:p(()=>[s("div",ue,[n(_,{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:a[2]||(a[2]=k(()=>{},["stop"]))},[n(r,{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:c})=>[s("div",{class:P(["material-preview",{"is-disabled":e.disabled,"is-one":e.limit==1}]),onClick:v=>e.showPopup(c)},[n(m,{onClose:v=>e.deleteImg(c)},{default:p(()=>[n(t,{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",ne,[a[4]||(a[4]=s("span",null,"\u4FEE\u6539",-1)),a[5]||(a[5]=Z(" | ")),s("span",{onClick:k(v=>e.handlePreview(o),["stop"])},"\u67E5\u770B",8,re)])],10,ie)]),_:1},8,["modelValue"]),x(s("div",{class:P(["material-upload",{"is-disabled":e.disabled,"is-one":e.limit==1,[e.uploadClass]:!0}]),onClick:a[1]||(a[1]=o=>e.showPopup(-1))},[ee(e.$slots,"upload",{},()=>[s("div",{class:"upload-btn",style:le({width:e.size,height:e.size})},[n(f,{size:25,name:"el-icon-Plus"}),a[6]||(a[6]=s("span",null,"\u6DFB\u52A0",-1))],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 ye=G(oe,[["render",de],["__scopeId","data-v-116a188b"]]);export{ye as _};