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