ProductAttributes-3e71e537.js 2.6 KB

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