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