SkuList-a8090a40.js 12 KB

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