ProductAttributes-a03a7812.js 2.6 KB

1
  1. import{d as q,ai as G,r as v,e as H,O as J,o as f,c as k,C as D,a as m,F as P,k as z,w as c,j as B,i as n,l as _,t as V,D as g,a7 as E,R as N,U as Q,Y as T,B as W,am as X,s as Z,E as j,bg as aa,_ as sa,__tla as la}from"./index-2f799233.js";import{E as ea,__tla as ta}from"./el-text-58158748.js";import{c as ua,__tla as ra}from"./property-9f44e48e.js";import{u as oa,__tla as ca}from"./useMessage-e567ad40.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(q({name:"ProductAttributes",__name:"ProductAttributes",props:{propertyList:{type:Array,default:()=>{}},isDetail:G.bool.def(!1)},emits:["success"],setup(y,{emit:L}){const{t:U}=W(),x=oa(),e=v(""),d=v(null),w=H(()=>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([]),I=y;J(()=>I.propertyList,a=>{a&&(u.value=a)},{deep:!0,immediate:!0});const O=L,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")),O("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=X,M=Z,R=aa,S=j;return f(!0),k(P,null,D(m(u),(p,s)=>(f(),z(S,{key:s},{default:c(()=>[B("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(()=>[_(V(p.name),1)]),_:2},1032,["closable","onClose"])]),B("div",null,[n(t,{class:"mx-1"},{default:c(()=>[_("\u5C5E\u6027\u503C\uFF1A")]),_:1}),(f(!0),k(P,null,D(p.values,(l,o)=>(f(),z(i,{key:l.id,class:"mx-1",closable:!y.isDetail,onClose:h=>((Y,$)=>{var A;(A=u.value[Y].values)==null||A.splice($,1)})(s,o)},{default:c(()=>[_(V(l.name),1)]),_:2},1032,["closable","onClose"]))),128)),g(n(m(T),{id:`input${s}`,ref_for:!0,ref:F,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"]),[[E,m(w)(s)]]),g(n(M,{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(w)(s)]])]),n(R,{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,K as default};