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