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