ProductAttributes-f024aca6.js 2.6 KB

1
  1. import{d as $,ag as G,r as v,K as J,L as M,o as f,c as V,q as B,a as m,F as D,v as P,w as c,g,f as n,n as _,t as z,x as K,a4 as L,O as N,R as Q,V as T,h as W,al as Y,C as Z,E as k,bB as aa,_ as sa,__tla as la}from"./index-11e4820e.js";import{E as ea,__tla as ta}from"./el-text-ff6dcf4e.js";import{c as ua,__tla as ra}from"./property-9c164d16.js";import{u as oa,__tla as ca}from"./useMessage-06ddf735.js";let E,na=Promise.all([(()=>{try{return la}catch{}})(),(()=>{try{return ta}catch{}})(),(()=>{try{return ra}catch{}})(),(()=>{try{return ca}catch{}})()]).then(async()=>{E=sa($({name:"ProductAttributes",__name:"ProductAttributes",props:{propertyList:{type:Array,default:()=>{}},isDetail:G.bool.def(!1)},emits:["success"],setup(y,{emit:R}){const{t:U}=W(),x=oa(),e=v(""),d=v(null),w=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;M(()=>F.propertyList,a=>{a&&(u.value=a)},{deep:!0,immediate:!0});const H=R,C=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}),x.success(U("common.createSuccess")),H("success",u.value)}catch{x.error("\u6DFB\u52A0\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5")}d.value=null,e.value=""};return(a,r)=>{const t=ea,i=Y,j=Z,I=aa,O=k;return f(!0),V(D,null,B(m(u),(p,s)=>(f(),P(O,{key:s},{default:c(()=>[g("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(()=>[_(z(p.name),1)]),_:2},1032,["closable","onClose"])]),g("div",null,[n(t,{class:"mx-1"},{default:c(()=>[_("\u5C5E\u6027\u503C\uFF1A")]),_:1}),(f(!0),V(D,null,B(p.values,(l,o)=>(f(),P(i,{key:l.id,class:"mx-1",closable:!y.isDetail,onClose:h=>((S,X)=>{var A;(A=u.value[S].values)==null||A.splice(X,1)})(s,o)},{default:c(()=>[_(z(l.name),1)]),_:2},1032,["closable","onClose"]))),128)),K(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=>C(s,p.id),onKeyup:Q(l=>C(s,p.id),["enter"])},null,8,["id","modelValue","onBlur","onKeyup"]),[[L,m(w)(s)]]),K(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"]),[[L,!m(w)(s)]])]),n(I,{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,E as default};