WokerTask/public/admin/assets/picker.ffe50cdd.js

2 lines
4.2 KiB
JavaScript

import{P}from"./index.000b2a9c.js";import{E as T}from"./element-plus.ff90c99c.js";import{F as N,_ as B,a as M}from"./index.5098f7f9.js";import{u as J,d as K,b as Q}from"./index.87cea444.js";import{_ as W}from"./index.4cdb7b3d.js";import{D as X}from"./vuedraggable.99ce9db3.js";import{d as j,r as i,a0 as q,b as S,w as G,I as $,n as H,ag as U,o as O,c as Y,W as n,ab as Z,Q as p,a as s,a4 as k,K as I,U as x,R as ee,J as le,L as ae,X as oe,bg as te,bf as se}from"./@vue.f8dfc830.js";import{e as ie}from"./@vueuse.a2e59ee9.js";const ne=j({components:{Popup:P,Draggable:X,FileItem:N,Material:B,Preview:M},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:o}){const g=i(),h=i(),_=i(""),w=i(!1),a=i([]),m=i([]),r=i(!0),c=i(-1),{disabled:y,limit:u,modelValue:C}=q(e),{getImageUrl:b}=J(),t=S(()=>{switch(e.type){case"image":return"\u56FE\u7247";case"video":return"\u89C6\u9891";default:return""}}),f=S(()=>e.limit-a.value.length>0),v=S(()=>r.value?u.value==-1?null:u.value-a.value.length:1),D=ie(()=>{const l=m.value.map(d=>e.excludeDomain?d.url:d.uri);r.value?a.value=[...a.value,...l]:a.value.splice(c.value,1,l.shift()),z()},1e3,!1),A=l=>{var d;y.value||(l>=0?(r.value=!1,c.value=l):r.value=!0,(d=g.value)==null||d.open())},F=l=>{m.value=l},z=()=>{const l=u.value!=1?a.value:a.value[0]||"";o("update:modelValue",l),o("change",l),V()},L=l=>{a.value.splice(l,1),z()},R=l=>{_.value=l,w.value=!0},V=()=>{H(()=>{var l;e.hiddenUpload&&(a.value=[]),(l=h.value)==null||l.clearSelect()})};return G(C,l=>{a.value=Array.isArray(l)?l:l==""?[]:[l]},{immediate:!0}),$("limit",e.limit),$("hiddenUpload",e.hiddenUpload),{popupRef:g,materialRef:h,fileList:a,tipsText:t,handleConfirm:D,meterialLimit:v,showUpload:f,showPopup:A,selectChange:F,deleteImg:L,previewUrl:_,showPreview:w,handlePreview:R,handleClose:V,getImageUrl:b}}});const E=e=>(te("data-v-116a188b"),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,o,g,h,_,w){const a=U("file-item"),m=W,r=U("draggable"),c=Q,y=B,u=T,C=P,b=U("preview");return O(),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(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(()=>[s("div",{class:"material-select__trigger clearfix",onClick:o[2]||(o[2]=k(()=>{},["stop"]))},[n(r,{class:"draggable",modelValue:e.fileList,"onUpdate:modelValue":o[0]||(o[0]=t=>e.fileList=t),animation:"300","item-key":"id"},{item:p(({element:t,index:f})=>[s("div",{class:I(["material-preview",{"is-disabled":e.disabled,"is-one":e.limit==1}]),onClick:v=>e.showPopup(f)},[n(m,{onClose:v=>e.deleteImg(f)},{default:p(()=>[n(a,{uri:e.excludeDomain?e.getImageUrl(t):t,"file-size":e.size,type:e.type},null,8,["uri","file-size","type"])]),_:2},1032,["onClose"]),s("div",de,[pe,x(" | "),s("span",{onClick:k(v=>e.handlePreview(t),["stop"])},"\u67E5\u770B",8,me)])],10,ue)]),_:1},8,["modelValue"]),ee(s("div",{class:I(["material-upload",{"is-disabled":e.disabled,"is-one":e.limit==1,[e.uploadClass]:!0}]),onClick:o[1]||(o[1]=t=>e.showPopup(-1))},[le(e.$slots,"upload",{},()=>[s("div",{class:"upload-btn",style:ae({width:e.size,height:e.size})},[n(c,{size:25,name:"el-icon-Plus"}),ce],4)],!0)],2),[[oe,e.showUpload]])])]),key:"0"}]),1032,["title","onConfirm","onClose"]),n(b,{modelValue:e.showPreview,"onUpdate:modelValue":o[3]||(o[3]=t=>e.showPreview=t),url:e.previewUrl,type:e.type},null,8,["modelValue","url","type"])])}const Ue=K(ne,[["render",ve],["__scopeId","data-v-116a188b"]]);export{Ue as _};