SkuList-bab44545.js 11 KB

1
  1. import{d as Q,ac as P,r as x,aM as F,o as u,c as V,x as h,w as r,a as m,a0 as w,F as v,f as t,v as N,g as S,t as p,y as f,J as A,aC as X,bu as Y,I as Z,R as ee,bw as le,G as ae,_ as te,__tla as ie}from"./index-62b7dfb7.js";import{E as re,__tla as oe}from"./el-image-17267435.js";import{__tla as ne}from"./el-image-viewer-5030a371.js";import{__tla as se}from"./SPuUploadImg.vue_vue_type_style_index_0_scoped_ba706063_lang-77c89ab0.js";import{_ as ce,__tla as de}from"./UploadImg-e9e2c1af.js";import{__tla as ue}from"./UploadImgs.vue_vue_type_style_index_0_scoped_9d666400_lang-0e9051b2.js";import{__tla as me}from"./UploadFile.vue_vue_type_style_index_0_scoped_436eca1b_lang-06de7e15.js";import{c as pe,__tla as fe}from"./index-a48fef3e.js";import{u as he,__tla as we}from"./useMessage-727ba3da.js";let R,ge=Promise.all([(()=>{try{return ie}catch{}})(),(()=>{try{return oe}catch{}})(),(()=>{try{return ne}catch{}})(),(()=>{try{return se}catch{}})(),(()=>{try{return de}catch{}})(),(()=>{try{return ue}catch{}})(),(()=>{try{return me}catch{}})(),(()=>{try{return fe}catch{}})(),(()=>{try{return we}catch{}})()]).then(async()=>{let T,z,D;T={style:{"font-weight":"bold",color:"#40aaff"}},z={style:{"font-weight":"bold",color:"#40aaff"}},D={style:{"font-weight":"bold",color:"#40aaff"}},R=te(Q({name:"SkuList",__name:"SkuList",props:{propFormData:{type:Object,default:()=>{}},propertyList:{type:Array,default:()=>[]},ruleConfig:{type:Array,default:()=>[]},isBatch:P.bool.def(!1),isDetail:P.bool.def(!1),isComponent:P.bool.def(!1),isActivityComponent:P.bool.def(!1)},emits:["selectionChange"],setup(g,{expose:j,emit:$}){const M=he(),b=g,c=x(),B=x([{price:0,marketPrice:0,costPrice:0,barCode:"",picUrl:"",stock:0,weight:0,volume:0,firstBrokeragePrice:0,secondBrokeragePrice:0}]),L=i=>{pe({zIndex:9999999,urlList:[i]})},G=()=>{c.value.skus.forEach(i=>{Y(i,B.value[0])})},U=x([]),W=(i,d)=>{const e=d.split(".");let o=i;for(const n of e){if(!o||typeof o!="object"||!(n in o)){o=void 0;break}o=o[n]}return o},q=$,H=i=>{q("selectionChange",i)};F(()=>b.propFormData,i=>{i&&(c.value=i)},{deep:!0,immediate:!0});const O=i=>{const d=i.map(o=>o.values.map(n=>({propertyId:o.id,propertyName:o.name,valueId:n.id,valueName:n.name}))),e=J(d);E(i)||(c.value.skus=[]);for(const o of e){const n={properties:Array.isArray(o)?o:[o],price:0,marketPrice:0,costPrice:0,barCode:"",picUrl:"",stock:0,weight:0,volume:0,firstBrokeragePrice:0,secondBrokeragePrice:0};c.value.skus.findIndex(k=>JSON.stringify(k.properties)===JSON.stringify(n.properties))===-1&&c.value.skus.push(n)}},E=i=>{const d=[];c.value.skus.forEach(o=>{var n,k;return(k=(n=o.properties)==null?void 0:n.map(y=>y.propertyId))==null?void 0:k.forEach(y=>{d.indexOf(y)===-1&&d.push(y)})});const e=i.map(o=>o.id);return d.length===e.length},J=i=>{if(i.length===0)return[];if(i.length===1)return i[0];{const d=[],e=J(i.slice(1));for(let o=0;o<i[0].length;o++)for(let n=0;n<e.length;n++)Array.isArray(e[n])?d.push([i[0][o],...e[n]]):d.push([i[0][o],e[n]]);return d}};F(()=>b.propertyList,i=>{c.value.specType&&(b.isBatch&&(B.value=[{price:0,marketPrice:0,costPrice:0,barCode:"",picUrl:"",stock:0,weight:0,volume:0,firstBrokeragePrice:0,secondBrokeragePrice:0}]),JSON.stringify(i)!=="[]"&&(U.value=[],i.forEach((d,e)=>{U.value.push({prop:`name${e}`,label:d.name})}),E(i)||i.some(d=>d.values.length===0)||O(i)))},{deep:!0,immediate:!0});const I=x();return j({generateTableData:O,validateSku:()=>{let i="\u8BF7\u68C0\u67E5\u5546\u54C1\u5404\u884C\u76F8\u5173\u5C5E\u6027\u914D\u7F6E\uFF0C",d=!0;for(const e of c.value.skus){for(const o of b==null?void 0:b.ruleConfig){const n=W(e,o.name);if(!o.rule(n)){d=!1,i+=o.message;break}}if(!d)throw M.warning(i),new Error(i)}},getSkuTableRef:()=>I.value}),(i,d)=>{const e=Z,o=ee,n=le,k=ae,y=re;return u(),V(v,null,[g.isDetail||g.isActivityComponent?w("",!0):(u(),h(m(A),{key:0,data:g.isBatch?m(B):m(c).skus,border:"",class:"tabNumWidth","max-height":"500",size:"small"},{default:r(()=>{var l;return[t(e,{align:"center",label:"\u56FE\u7247","min-width":"65"},{default:r(({row:a})=>[t(m(ce),{modelValue:a.picUrl,"onUpdate:modelValue":s=>a.picUrl=s,height:"50px",width:"50px"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),m(c).specType&&!g.isBatch?(u(!0),V(v,{key:0},N(m(U),(a,s)=>(u(),h(e,{key:s,label:a.label,align:"center","min-width":"120"},{default:r(({row:_})=>{var C;return[S("span",T,p((C=_.properties[s])==null?void 0:C.valueName),1)]}),_:2},1032,["label"]))),128)):w("",!0),t(e,{align:"center",label:"\u5546\u54C1\u6761\u7801","min-width":"168"},{default:r(({row:a})=>[t(o,{modelValue:a.barCode,"onUpdate:modelValue":s=>a.barCode=s,class:"w-100%"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),t(e,{align:"center",label:"\u9500\u552E\u4EF7","min-width":"168"},{default:r(({row:a})=>[t(n,{modelValue:a.price,"onUpdate:modelValue":s=>a.price=s,min:0,precision:2,step:.1,class:"w-100%","controls-position":"right"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),t(e,{align:"center",label:"\u5E02\u573A\u4EF7","min-width":"168"},{default:r(({row:a})=>[t(n,{modelValue:a.marketPrice,"onUpdate:modelValue":s=>a.marketPrice=s,min:0,precision:2,step:.1,class:"w-100%","controls-position":"right"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),t(e,{align:"center",label:"\u6210\u672C\u4EF7","min-width":"168"},{default:r(({row:a})=>[t(n,{modelValue:a.costPrice,"onUpdate:modelValue":s=>a.costPrice=s,min:0,precision:2,step:.1,class:"w-100%","controls-position":"right"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),t(e,{align:"center",label:"\u5E93\u5B58","min-width":"168"},{default:r(({row:a})=>[t(n,{modelValue:a.stock,"onUpdate:modelValue":s=>a.stock=s,min:0,class:"w-100%","controls-position":"right"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),t(e,{align:"center",label:"\u91CD\u91CF(kg)","min-width":"168"},{default:r(({row:a})=>[t(n,{modelValue:a.weight,"onUpdate:modelValue":s=>a.weight=s,min:0,precision:2,step:.1,class:"w-100%","controls-position":"right"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),t(e,{align:"center",label:"\u4F53\u79EF(m^3)","min-width":"168"},{default:r(({row:a})=>[t(n,{modelValue:a.volume,"onUpdate:modelValue":s=>a.volume=s,min:0,precision:2,step:.1,class:"w-100%","controls-position":"right"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),m(c).subCommissionType?(u(),V(v,{key:1},[t(e,{align:"center",label:"\u4E00\u7EA7\u8FD4\u4F63(\u5143)","min-width":"168"},{default:r(({row:a})=>[t(n,{modelValue:a.firstBrokeragePrice,"onUpdate:modelValue":s=>a.firstBrokeragePrice=s,min:0,precision:2,step:.1,class:"w-100%","controls-position":"right"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),t(e,{align:"center",label:"\u4E8C\u7EA7\u8FD4\u4F63(\u5143)","min-width":"168"},{default:r(({row:a})=>[t(n,{modelValue:a.secondBrokeragePrice,"onUpdate:modelValue":s=>a.secondBrokeragePrice=s,min:0,precision:2,step:.1,class:"w-100%","controls-position":"right"},null,8,["modelValue","onUpdate:modelValue"])]),_:1})],64)):w("",!0),(l=m(c))!=null&&l.specType?(u(),h(e,{key:2,align:"center",fixed:"right",label:"\u64CD\u4F5C",width:"80"},{default:r(({row:a})=>[g.isBatch?(u(),h(k,{key:0,link:"",size:"small",type:"primary",onClick:G},{default:r(()=>[f(" \u6279\u91CF\u6DFB\u52A0 ")]),_:1})):(u(),h(k,{key:1,link:"",size:"small",type:"primary",onClick:s=>(_=>{const C=c.value.skus.findIndex(K=>JSON.stringify(K.properties)===JSON.stringify(_.properties));c.value.skus.splice(C,1)})(a)},{default:r(()=>[f("\u5220\u9664")]),_:2},1032,["onClick"]))]),_:1})):w("",!0)]}),_:1},8,["data"])),g.isDetail?(u(),h(m(A),{key:1,ref_key:"activitySkuListRef",ref:I,data:m(c).skus,border:"","max-height":"500",size:"small",style:{width:"99%"},onSelectionChange:H},{default:r(()=>[g.isComponent?(u(),h(e,{key:0,type:"selection",width:"45"})):w("",!0),t(e,{align:"center",label:"\u56FE\u7247","min-width":"80"},{default:r(({row:l})=>[l.picUrl?(u(),h(y,{key:0,src:l.picUrl,class:"h-50px w-50px",onClick:a=>L(l.picUrl)},null,8,["src","onClick"])):w("",!0)]),_:1}),m(c).specType&&!g.isBatch?(u(!0),V(v,{key:1},N(m(U),(l,a)=>(u(),h(e,{key:a,label:l.label,align:"center","min-width":"80"},{default:r(({row:s})=>{var _;return[S("span",z,p((_=s.properties[a])==null?void 0:_.valueName),1)]}),_:2},1032,["label"]))),128)):w("",!0),t(e,{align:"center",label:"\u5546\u54C1\u6761\u7801","min-width":"100"},{default:r(({row:l})=>[f(p(l.barCode),1)]),_:1}),t(e,{align:"center",label:"\u9500\u552E\u4EF7(\u5143)","min-width":"80"},{default:r(({row:l})=>[f(p(l.price),1)]),_:1}),t(e,{align:"center",label:"\u5E02\u573A\u4EF7(\u5143)","min-width":"80"},{default:r(({row:l})=>[f(p(l.marketPrice),1)]),_:1}),t(e,{align:"center",label:"\u6210\u672C\u4EF7(\u5143)","min-width":"80"},{default:r(({row:l})=>[f(p(l.costPrice),1)]),_:1}),t(e,{align:"center",label:"\u5E93\u5B58","min-width":"80"},{default:r(({row:l})=>[f(p(l.stock),1)]),_:1}),t(e,{align:"center",label:"\u91CD\u91CF(kg)","min-width":"80"},{default:r(({row:l})=>[f(p(l.weight),1)]),_:1}),t(e,{align:"center",label:"\u4F53\u79EF(m^3)","min-width":"80"},{default:r(({row:l})=>[f(p(l.volume),1)]),_:1}),m(c).subCommissionType?(u(),V(v,{key:2},[t(e,{align:"center",label:"\u4E00\u7EA7\u8FD4\u4F63(\u5143)","min-width":"80"},{default:r(({row:l})=>[f(p(l.firstBrokeragePrice),1)]),_:1}),t(e,{align:"center",label:"\u4E8C\u7EA7\u8FD4\u4F63(\u5143)","min-width":"80"},{default:r(({row:l})=>[f(p(l.secondBrokeragePrice),1)]),_:1})],64)):w("",!0)]),_:1},8,["data"])):w("",!0),g.isActivityComponent?(u(),h(m(A),{key:2,data:m(c).skus,border:"","max-height":"500",size:"small",style:{width:"99%"}},{default:r(()=>[g.isComponent?(u(),h(e,{key:0,type:"selection",width:"45"})):w("",!0),t(e,{align:"center",label:"\u56FE\u7247","min-width":"80"},{default:r(({row:l})=>[t(y,{src:l.picUrl,class:"h-60px w-60px",onClick:a=>L(l.picUrl)},null,8,["src","onClick"])]),_:1}),m(c).specType?(u(!0),V(v,{key:1},N(m(U),(l,a)=>(u(),h(e,{key:a,label:l.label,align:"center","min-width":"80"},{default:r(({row:s})=>{var _;return[S("span",D,p((_=s.properties[a])==null?void 0:_.valueName),1)]}),_:2},1032,["label"]))),128)):w("",!0),t(e,{align:"center",label:"\u5546\u54C1\u6761\u7801","min-width":"100"},{default:r(({row:l})=>[f(p(l.barCode),1)]),_:1}),t(e,{align:"center",label:"\u9500\u552E\u4EF7(\u5143)","min-width":"80"},{default:r(({row:l})=>[f(p(l.price),1)]),_:1}),t(e,{align:"center",label:"\u5E02\u573A\u4EF7(\u5143)","min-width":"80"},{default:r(({row:l})=>[f(p(l.marketPrice),1)]),_:1}),t(e,{align:"center",label:"\u6210\u672C\u4EF7(\u5143)","min-width":"80"},{default:r(({row:l})=>[f(p(l.costPrice),1)]),_:1}),t(e,{align:"center",label:"\u5E93\u5B58","min-width":"80"},{default:r(({row:l})=>[f(p(l.stock),1)]),_:1}),X(i.$slots,"extension")]),_:3},8,["data"])):w("",!0)],64)}}}),[["__file","D:/zhongxing/mall-newfeifan-zx-admin/src/views/mall/product/spu/components/SkuList.vue"]])});export{ge as __tla,R as default};