import{d as G,ah as H,r as v,K as J,L as N,o as f,c as k,q as z,a as m,F as B,v as D,w as c,g as K,f as n,n as _,t as L,x as V,a5 as g,P as O,S as Q,W as R,h as T,al as X,C as Y,E as Z,bB as aa,_ as sa,__tla as la}from"./index-04f8d540.js";import{E as ea,__tla as ta}from"./el-text-7e85860c.js";import{c as ua,__tla as ra}from"./property-39a7ad7a.js";import{u as oa,__tla as ca}from"./useMessage-9c37e840.js";let h,na=Promise.all([(()=>{try{return la}catch{}})(),(()=>{try{return ta}catch{}})(),(()=>{try{return ra}catch{}})(),(()=>{try{return ca}catch{}})()]).then(async()=>{h=sa(G({name:"ProductAttributes",__name:"ProductAttributes",props:{propertyList:{type:Array,default:()=>{}},isDetail:H.bool.def(!1)},emits:["success"],setup(y,{emit:E}){const{t:S}=T(),w=oa(),e=v(""),d=v(null),C=J(()=>a=>d.value!==null&&(d.value===a||void 0)),b=v([]),q=a=>{a!=null&&(b.value.some(r=>{var t,i;return((t=r.input)==null?void 0:t.attributes.id)===((i=a.input)==null?void 0:i.attributes.id)})||b.value.push(a))},u=v([]),F=y;N(()=>F.propertyList,a=>{a&&(u.value=a)},{deep:!0,immediate:!0});const I=E,A=async(a,r)=>{if(e.value)try{const t=await ua({propertyId:r,name:e.value});u.value[a].values.push({id:t,name:e.value}),w.success(S("common.createSuccess")),I("success",u.value)}catch{w.error("\u6DFB\u52A0\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5")}d.value=null,e.value=""};return(a,r)=>{const t=ea,i=X,j=Y,M=aa,U=Z;return f(!0),k(B,null,z(m(u),(p,s)=>(f(),D(U,{key:s},{default:c(()=>[K("div",null,[n(t,{class:"mx-1"},{default:c(()=>[_("\u5C5E\u6027\u540D\uFF1A")]),_:1}),n(i,{class:"mx-1",closable:!y.isDetail,type:"success",onClose:l=>(o=>{var x;(x=u.value)==null||x.splice(o,1)})(s)},{default:c(()=>[_(L(p.name),1)]),_:2},1032,["closable","onClose"])]),K("div",null,[n(t,{class:"mx-1"},{default:c(()=>[_("\u5C5E\u6027\u503C\uFF1A")]),_:1}),(f(!0),k(B,null,z(p.values,(l,o)=>(f(),D(i,{key:l.id,class:"mx-1",closable:!y.isDetail,onClose:x=>((W,$)=>{var P;(P=u.value[W].values)==null||P.splice($,1)})(s,o)},{default:c(()=>[_(L(l.name),1)]),_:2},1032,["closable","onClose"]))),128)),V(n(m(R),{id:`input${s}`,ref_for:!0,ref:q,modelValue:m(e),"onUpdate:modelValue":r[0]||(r[0]=l=>O(e)?e.value=l:null),class:"!w-20",size:"small",onBlur:l=>A(s,p.id),onKeyup:Q(l=>A(s,p.id),["enter"])},null,8,["id","modelValue","onBlur","onKeyup"]),[[g,m(C)(s)]]),V(n(j,{class:"button-new-tag ml-1",size:"small",onClick:l=>(async o=>{d.value=o,b.value[o].focus()})(s)},{default:c(()=>[_(" + \u6DFB\u52A0 ")]),_:2},1032,["onClick"]),[[g,!m(C)(s)]])]),n(M,{class:"my-10px"})]),_:2},1024))),128)}}}),[["__file","D:/zx/mall-newfeifan-zx-business/src/views/mall/product/spu/form/ProductAttributes.vue"]])});export{na as __tla,h as default};
