2 lines
4.3 KiB
JavaScript
2 lines
4.3 KiB
JavaScript
import{g as m,a as F}from"./Br3uDf8T.js";import{r as s,k as A,K,aI as f}from"./G_17LgpR.js";const N=s(),p=s(!1),b=s(1);let n=[];const d=s(),v=s([]),_=s([]),y=s([]),I=s({url:void 0,index:0}),z=s(),D=s(),E=s([]),r=s([]),q=s([]),T=s([]),g=K({title_fa:"",title:"",price:0,body:"",is_show:!0,is_active:!0,box_size:0,sell_type:"numeric",original_image:void 0,product_attributes:[],files:[],price_type:"manual",auto_calculate:!1,sku:null,created_at:void 0,updated_at:void 0,deleted_at:null,count_order:void 0,count_fav:void 0,count_view:void 0,min_price:void 0,max_price:void 0,type:"simple",owner_id:void 0,users:void 0,saved:[],variants:[],code:void 0,brand_id:void 0,collection_id:void 0,discount:void 0,discount_type:void 0,id:void 0,count:void 0,display_price:void 0,meta:void 0,seo_title:void 0,description:void 0,product_type:void 0,weight:void 0,rial_fee:void 0,percent_fee:void 0}),k=f(g);function B(){Object.assign(g,k),_.value=[],v.value=[],r.value=[],b.value=1,I.value={url:void 0,index:0},y.value=[],d.value=void 0,N.value=void 0}const C=A(()=>{let e=f(y.value);return e?.splice(0,0,I.value),e=e?.map((l,a)=>l),console.log(e),e});function j(){let e=[],l=[];v.value?.forEach(a=>{a.valueId,e.push(a.valueId),l.push(a.valueName)}),console.log(e,v.value),g.variants?.push({id:void 0,attribute_values:[],attribute_values_name:[],price:0,weight:0,stock:0,auto_calculate:!1,discount_type:void 0,discount:void 0,is_default:!1,sku:""}),console.log(r,g.variants)}function G(e,l){let a=e;b.value=1,_.value=[],v.value=[],console.log(e),console.log("why");let o=0,c=[];e?.forEach((u,i)=>{console.log(u,i),u.show_in_variable?(b.value=2,g.variants.length===0&&j(),_.value.push({attributeId:u.id,name:u.name,values:u.new_feature,show:u.show_in_variable,valueKey:i}),u.new_feature?.forEach((t,w)=>{v.value.push({attributeName:u.name,attributeId:u.id,valueId:t.id,valueName:t.value,valueKey:o})})):(c.push(i),r.value?.forEach(t=>{console.log("val.attribute_values>",i),console.log(t.attribute_values),console.log("myAttributes.value.length "+a.length),console.log("val.attribute_values.length "+t.attribute_values.length),a.length>t.attribute_values.length&&t.attribute_values[i]!=null&&(t.attribute_values.length!=i?(t.attribute_values.splice(i,0,null),t.attribute_values_name.splice(i,0,null)):(t.attribute_values=[...t.attribute_values,null],t.attribute_values_name=[...t.attribute_values_name,null])),console.log("val.attribute_values After slice>"+i),console.log(t.attribute_values)})),o++,r.value?.forEach((t,w)=>{a.length>t.attribute_values.length&&t.attribute_values[i]!=null&&(t.attribute_values=[...t.attribute_values,null],t.attribute_values_name=[...t.attribute_values_name,null])}),console.log("variants+++")}),console.log("tempIndexArray"),console.log(c),M(r.value),c.length!=0&&r.value?.forEach(u=>{c.forEach(i=>{u.attribute_values[i]=null,u.attribute_values_name[i]=null})})}function M(e){console.log("444444",e),e?.forEach((l,a)=>{n=f(l.attribute_values),_.value.length<=n.length&&n?.forEach((o,c)=>{v.value?.forEach((u,i)=>{n.find(t=>t==u?.valueId)&&l.attribute_values[u.valueKey]!=n.find(t=>t==u.valueId)&&(l.attribute_values[u.valueKey]=n.find(t=>t==u.valueId),l.attribute_values_name[u.valueKey]=u.valueName),console.log(l?.attribute_values+"AFTER CHANGE ITEM"+a)})}),a==0&&(d.value=h(l.attribute_values_name)),l.is_default&&(console.log("val.attribute_values",l.attribute_values_name),d.value=h(l.attribute_values_name),console.log("defaultVariant",d.value))})}function h(e){console.log(e,d.value);let l="";return e.forEach((a,o)=>{if(a)return l+=(o!==0?" - ":"")+a}),l}async function H(){try{p.value=!0,T.value=await F()}catch(e){console.log(e)}finally{p.value=!1}}async function L(e){let l;e[e.length-1]!=null&&(l=await m(e[e.length-1]));let a;a=l[0],Object.assign(a,{new_feature:[],show_in_product:!1,show_in_variable:!1}),console.log("gggggggggggggggggggggggggggggggg",a),E.value.push(a)}async function R(e){const l=await m(e),a=E.value.find(o=>o.id===e);a&&(console.log(a.attribute_values,l[0].attribute_values),a.attribute_values=[],a.attribute_values=l[0]?.attribute_values?f(l[0]?.attribute_values):[],console.log(a.attribute_values))}const S=e=>(console.log("fsdfuygiuhguighuisdf",e),e.split("-")[0]==="edit"),U=s([]),J=s([]);export{C as a,S as b,J as c,z as d,N as e,U as f,T as g,H as h,E as i,R as j,L as k,p as l,y as m,g as n,I as o,D as p,_ as q,B as r,q as s,b as t,G as u,r as v,j as w,d as x,h as y,v as z};
|