2 lines
4.4 KiB
JavaScript
2 lines
4.4 KiB
JavaScript
import{g as E,a as K}from"./BeDLJWT-.js";import{r as s,k as N,K as T,aH as b}from"./lb-BvpwA.js";const k=s(),y=s(!1),h=s(1);let c=[];const d=s(),v=s([]),f=s([]),F=s([]),A=s({url:void 0,index:0}),C=s(),G=s(),w=s([]),_=s([]),L=s([]),j=s([]),g=T({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}),O=b(g);function R(){Object.assign(g,O),f.value=[],v.value=[],_.value=[],h.value=1,A.value={url:void 0,index:0},F.value=[],d.value=void 0,k.value=void 0}const U=N(()=>{let e=b(F.value);return e==null||e.splice(0,0,A.value),e=e==null?void 0:e.map((t,a)=>t),console.log(e),e});function z(){var a,o;let e=[],t=[];(a=v.value)==null||a.forEach(r=>{r.valueId,e.push(r.valueId),t.push(r.valueName)}),console.log(e,v.value),(o=g.variants)==null||o.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:""})}function J(e,t){if(t==1)return;let a=e;h.value=1,f.value=[],v.value=[],console.log(e),console.log("why");let o=0,r=[];e==null||e.forEach((i,l)=>{var p,n,m;console.log(i,l),i.show_in_variable?(h.value=2,g.variants.length===0&&z(),f.value.push({attributeId:i.id,name:i.name,values:i.new_feature,show:i.show_in_variable,valueKey:l}),(p=i.new_feature)==null||p.forEach((u,H)=>{v.value.push({attributeName:i.name,attributeId:i.id,valueId:u.id,valueName:u.value,valueKey:o})})):(n=_.value)==null||n.forEach(u=>{console.log("val.attribute_values>",l),console.log(u.attribute_values),console.log("myAttributes.value.length "+a.length),console.log("val.attribute_values.length "+u.attribute_values.length),a.length>u.attribute_values.length&&u.attribute_values[l]!=null&&(u.attribute_values.length!=l?(u.attribute_values.splice(l,0,null),u.attribute_values_name.splice(l,0,null)):(u.attribute_values=[...u.attribute_values,null],u.attribute_values_name=[...u.attribute_values_name,null])),console.log("val.attribute_values After slice>"+l),console.log(u.attribute_values)}),o++,(m=_.value)==null||m.forEach(u=>{a.length>u.attribute_values.length&&u.attribute_values[l]!=null&&(u.attribute_values=[...u.attribute_values,null],u.attribute_values_name=[...u.attribute_values_name,null])}),r.push(l),console.log("variants+++")}),console.log("tempIndexArray"),console.log(r),D(_.value)}function D(e){console.log("444444",e),e==null||e.forEach((t,a)=>{c=b(t.attribute_values),f.value.length<=c.length&&(c==null||c.forEach((o,r)=>{var i;(i=v.value)==null||i.forEach((l,p)=>{c.find(n=>n==(l==null?void 0:l.valueId))&&t.attribute_values[l.valueKey]!=c.find(n=>n==l.valueId)&&(t.attribute_values[l.valueKey]=c.find(n=>n==l.valueId),t.attribute_values_name[l.valueKey]=l.valueName),console.log((t==null?void 0:t.attribute_values)+"AFTER CHANGE ITEM"+a)})})),a==0&&(d.value=I(t.attribute_values_name)),t.is_default&&(console.log("val.attribute_values",t.attribute_values_name),d.value=I(t.attribute_values_name),console.log("defaultVariant",d.value))})}function I(e){console.log(e,d.value);let t="";return e.forEach((a,o)=>{if(a)return t+=(o!==0?" - ":"")+a}),t}async function P(){try{y.value=!0,j.value=await K()}catch(e){console.log(e)}finally{y.value=!1}}async function Q(e){let t;e[e.length-1]!=null&&(t=await E(e[e.length-1]));let a;a=t[0],Object.assign(a,{new_feature:[],show_in_product:!1,show_in_variable:!1}),w.value.push(a)}async function S(e){var o,r;const t=await E(e),a=w.value.find(i=>i.id===e);a&&(console.log(a.attribute_values,t[0].attribute_values),a.attribute_values=[],a.attribute_values=(o=t[0])!=null&&o.attribute_values?b((r=t[0])==null?void 0:r.attribute_values):[],console.log(a.attribute_values))}const W=e=>(console.log("fsdfuygiuhguighuisdf",e),e.split("-")[0]==="edit"),X=s([]),Y=s([]);export{U as a,W as b,Y as c,C as d,k as e,X as f,j as g,P as h,w as i,S as j,Q as k,y as l,F as m,g as n,A as o,G as p,h as q,R as r,L as s,z as t,J as u,_ as v,f as w,d as x,I as y,v as z};
|