SpuShowcase-dfb0f0d1.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 c,B as j,a4 as q,a as r,P as F,j as N,l as B,F as I,_ as L,aR as P}from"./index-92f7a16c.js";import{E as T}from"./el-image-b5c91f66.js";import"./el-image-viewer-668f12f8.js";import{V as X}from"./vuedraggable.umd-24d8b17d.js";import{f as Z}from"./spu-7bbcf2cd.js";import{_ as z}from"./SpuTableSelect.vue_vue_type_script_setup_true_lang-a75b000c.js";import{_ as D}from"./_plugin-vue_export-helper-1b428a4d.js";import"./Dialog-524c7d28.js";import"./ContentWrap.vue_vue_type_script_setup_true_lang-93cdc892.js";import"./el-card-e60c275e.js";import"./index.vue_vue_type_script_setup_true_lang-059ec67a.js";import"./index-579dde8f.js";import"./el-tree-select-4c0548d3.js";import"./tree-0af4953a.js";import"./category-8e584cf1.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(t=>!e.includes(t.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=>{console.log(e),m()},o=g,m=()=>{if(a.limit===1){const e=l.value.length>0?l.value[0]:null;o("update:modelValue",(e==null?void 0:e.id)||0),o("change",e)}else o("update:modelValue",l.value.map(e=>e.id)),o("change",l.value)};return(e,t)=>{const S=T,f=L,v=P;return n(),b(I,null,[d("div",G,[s(r(X),{modelValue:r(l),"onUpdate:modelValue":t[0]||(t[0]=i=>F(l)?l.value=i:null),disabled:!1,class:"flex flex-wrap items-center gap-2",onEnd:y},{item:c(({element:i,index:A})=>[(n(),b("div",{key:i.id,class:"select-box spu-pic"},[s(v,{content:i.name},{default:c(()=>[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"]),r(k)?(n(),N(v,{key:0,content:"\u9009\u62E9\u5546\u54C1"},{default:c(()=>[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};