SpuShowcase-06a087be.js 2.6 KB

1
  1. import{d as E,dV as R,af as V,e as U,r as h,M,aZ as _,o as n,c as b,k as d,i as s,w as r,B as j,a4 as q,a as c,P as F,j as N,l as B,F as I,_ as L,aR as P}from"./index-6d906b8a.js";import{E as T}from"./el-image-9aeecfea.js";import"./el-image-viewer-3eb20b9c.js";import{V as X}from"./vuedraggable.umd-f8121945.js";import{f as Z}from"./spu-8c99daaf.js";import{_ as z}from"./SpuTableSelect.vue_vue_type_script_setup_true_lang-108f3879.js";import{_ as D}from"./_plugin-vue_export-helper-1b428a4d.js";import"./Dialog-7d76582a.js";import"./ContentWrap.vue_vue_type_script_setup_true_lang-3e2a4d47.js";import"./el-card-dcb0121c.js";import"./index.vue_vue_type_script_setup_true_lang-7766ce4b.js";import"./index-06db4b5a.js";import"./el-tree-select-73d9f90b.js";import"./tree-fd3a041e.js";import"./category-f41ddfc2.js";const G={class:"flex flex-wrap items-center gap-2"},H={class:"relative h-full w-full"},J=D(E({name:"SpuShowcase",__name:"SpuShowcase",props:{modelValue:R([Number,Array]).isRequired,limit:V.number.def(Number.MAX_VALUE),disabled:V.bool.def(!1)},emits:["update:modelValue","change"],setup(u,{emit:g}){const a=u,k=U(()=>!a.disabled&&(!a.limit||l.value.length<a.limit)),l=h([]);M(()=>a.modelValue,async()=>{const e=_(a.modelValue)?a.modelValue:a.modelValue?[a.modelValue]:[];e.length!==0?(l.value.length===0||l.value.some(o=>!e.includes(o.id)))&&(l.value=await Z(e)):l.value=[]},{immediate:!0});const p=h(),x=()=>{p.value.open(l.value)},w=e=>{l.value=_(e)?e:[e],m()},y=e=>{m()},t=g,m=()=>{if(a.limit===1){const e=l.value.length>0?l.value[0]:null;t("update:modelValue",(e==null?void 0:e.id)||0),t("change",e)}else t("update:modelValue",l.value.map(e=>e.id)),t("change",l.value)};return(e,o)=>{const S=T,f=L,v=P;return n(),b(I,null,[d("div",G,[s(c(X),{modelValue:c(l),"onUpdate:modelValue":o[0]||(o[0]=i=>F(l)?l.value=i:null),disabled:!1,class:"flex flex-wrap items-center gap-2",onEnd:y},{item:r(({element:i,index:A})=>[(n(),b("div",{key:i.id,class:"select-box spu-pic"},[s(v,{content:i.name},{default:r(()=>[d("div",H,[s(S,{src:i.picUrl,class:"h-full w-full"},null,8,["src"]),j(s(f,{class:"del-icon",icon:"ep:circle-close-filled",onClick:K=>(C=>{l.value.splice(C,1),m()})(A)},null,8,["onClick"]),[[q,!u.disabled]])])]),_:2},1032,["content"])]))]),_:1},8,["modelValue"]),c(k)?(n(),N(v,{key:0,content:"\u9009\u62E9\u5546\u54C1"},{default:r(()=>[d("div",{class:"select-box spu-pic flex-shrink-0",onClick:x},[s(f,{icon:"ep:plus"})])]),_:1})):B("",!0)]),s(z,{ref_key:"spuTableSelectRef",ref:p,multiple:u.limit!=1,onChange:w},null,8,["multiple"])],64)}}}),[["__scopeId","data-v-969e8722"]]);export{J as default};