1 line
8.8 KiB
JavaScript
1 line
8.8 KiB
JavaScript
import{A as e,Ct as t,Et as n,L as r,N as i,O as a,P as o,R as s,St as c,Tt as l,Y as u,Z as d,_ as f,g as ee,j as p,mt as m,n as te,q as ne,tt as re,z as h}from"./BasicIcon-C6boaehV.js";import{o as g}from"./format-BHJptHdF.js";import{t as ie}from"./catalog-s7nVUdlj.js";import{C as ae,T as oe,b as se,l as ce}from"./index-B6MlTGUp.js";import{t as le}from"./IconChevronBack-DORV2H0q.js";import{t as ue}from"./PageSkeleton-uO-jhbNm.js";import{t as de}from"./IconShare-1kao-fAR.js";import{a as fe,i as pe,t as me}from"./crm-CtglbPsN.js";import{t as he}from"./useGoBack-CgNp0uP9.js";import{n as _,t as ge}from"./colorSwatch-BgOH1LE5.js";import{t as _e}from"./IconShoppingBag-Bq21_Txe.js";import{t as ve}from"./IconHeart-CZMe29Nz.js";var v={key:0,class:`page product-detail`},y={class:`pd-header`},b={class:`pd-header__actions`},x=[`aria-label`,`aria-pressed`],S={class:`page__scroll pd-scroll`},C={class:`gallery`},w={class:`gallery__count`},T={class:`gallery__thumbs`},E=[`onClick`],D={class:`pd-body`},O={class:`title-row`},k={key:0,class:`new-badge`},A={class:`code`},j={class:`specs`},M={class:`spec-cell`},N={class:`spec-cell`},P={class:`spec-cell`},F={class:`spec-icon`,"aria-hidden":`true`},ye={class:`spec-cell`},be={key:0,class:`specs-extra`},xe={class:`pd-section pd-section--boxed`},Se={class:`section-head`},Ce={class:`colors`},we=[`onClick`],Te={class:`pd-section`},Ee={class:`tags`,role:`list`},De=[`onClick`],Oe={class:`pd-section`},I={class:`roll-field`},ke={class:`pd-footer`},Ae={class:`pd-footer__primary`},je=[`disabled`],Me={class:`min-note`},Ne={key:1,class:`page empty`},Pe={key:2,class:`page empty`},L=te(h({__name:`ProductDetailView`,setup(te){let h={suit:`پارچه کتشلواری`,trousers:`پارچه شلواری`,shirt:`پارچه پیراهنی`},L={summer:`پارچه تابستانه`,winter:`پارچه زمستانه`,all_season:`پارچه چهارفصل`},Fe=ee(),R=f(),{goBack:z}=he(`/products`),Ie=me(),B=ce(),Le=oe(),Re=ie(),V=e(()=>String(Fe.query.id??``)),H=m(null),U=m(!0),W=m(null),G=m(0),K=m(1),q=m(!1),J=m(!1),Y=e(()=>H.value?.rollMeters??50),X=e(()=>{let e=H.value;return e?ge(e.colors,e.colorImages,e.imageUrls,G.value,e.imageUrl):``}),ze=e(()=>H.value?.colors[G.value]??``),Z=e(()=>K.value*Y.value),Be=e(()=>{let e=H.value?.minMeterage;return e&&e>0?e:Y.value}),Q=e(()=>Math.max(1,Math.ceil(Be.value/Y.value))),Ve=e(()=>h[H.value?.categoryId??``]||`—`),He=e(()=>L[H.value?.season??``]||`—`),Ue=e(()=>{let e=H.value;if(!e)return[];let t=[],n=fe.some(t=>t.id===e.categoryId)?e.categoryId:``,r=n?h[n]:``;r&&t.push({key:`usage-${n}`,label:r,to:{path:`/products`,query:{categoryId:n}}});let i=pe.some(t=>t.id===e.season)?e.season:``,a=i?L[i]:``;a&&t.push({key:`season-${i}`,label:a,to:{path:`/products`,query:{season:i}}});let o=new Set(t.flatMap(e=>[e.label,e.label.replace(/^پارچه\s*/,``)]));for(let n of e.tags){let e=n.replace(/^پارچه?های?\s*/,``).trim();if(!e||o.has(e)||t.some(t=>t.label.includes(e)))continue;let r=n.startsWith(`پارچه`)?n:`پارچه ${e}`;o.add(e),t.push({key:`tag-${n}`,label:r})}return t});async function $(){if(!V.value){H.value=null,U.value=!1;return}U.value=!0,W.value=null;try{await Promise.all([B.hydrate(),Re.loadCompanies()]),H.value=await Ie.loadProductById(V.value),G.value=0,K.value=Q.value}catch(e){H.value=null,W.value=e instanceof Error?e.message:`محصول یافت نشد.`}finally{U.value=!1}}ne($),re(V,$);function We(e){let t=e.rollMeters||50,n=e.orderMultiplier&&e.orderMultiplier>0?e.orderMultiplier:t,r=e.minMeterage&&e.minMeterage>0?e.minMeterage:t;return{id:e.id,companyId:e.companyId||``,catalogId:e.catalogId||``,name:e.name,code:e.code,color:e.color||e.colors[G.value]||`—`,minMeterage:r,orderMultiplier:n,basePrice:e.basePrice,isActive:!0}}function Ge(e,t,n){let r=t>0?t:1,i=Math.ceil(e/r)*r,a=Math.ceil(n/r)*r;return Math.max(i,a)}async function Ke(){if(!H.value)return;let e=We(H.value);q.value=!0;try{let t=Ge(Z.value,e.orderMultiplier,e.minMeterage);await Le.addItem(e,H.value.catalogCode||H.value.code,t)}finally{q.value=!1}}function qe(){H.value&&B.toggle(H.value.id)}function Je(){let e=window.location.href;if(navigator.share){navigator.share({title:H.value?.name,url:e}).catch(()=>void 0);return}navigator.clipboard?.writeText(e)}return(e,f)=>H.value?(u(),o(`div`,v,[p(`header`,y,[p(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:f[0]||=(...e)=>c(z)&&c(z)(...e)},[s(le,{size:20})]),p(`div`,b,[p(`button`,{type:`button`,class:`icon-btn`,"aria-label":c(B).isFavorite(H.value.id)?`حذف از علاقهمندیها`:`افزودن به علاقهمندیها`,"aria-pressed":c(B).isFavorite(H.value.id),onClick:qe},[s(ve,{size:20,filled:c(B).isFavorite(H.value.id),color:c(B).isFavorite(H.value.id)?`#0a353c`:void 0},null,8,[`filled`,`color`])],8,x),p(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اشتراکگذاری`,onClick:Je},[s(de,{size:20})])])]),p(`div`,S,[p(`div`,C,[p(`div`,{class:`gallery__main`,style:l(X.value?{backgroundImage:`url(${X.value})`,backgroundSize:`cover`,backgroundPosition:`center`}:c(_)(ze.value))},[p(`span`,w,n(c(g)(G.value+1))+`/`+n(c(g)(Math.max(H.value.colors.length,1))),1)],4),p(`div`,T,[(u(!0),o(a,null,d(H.value.colors,(e,n)=>(u(),o(`button`,{key:n,type:`button`,class:t([`thumb`,{"thumb--active":G.value===n}]),onClick:e=>G.value=n},[p(`span`,{class:`thumb__swatch`,style:l(c(_)(e,H.value.colorImages?.[n]||H.value.imageUrls?.[n]))},null,4)],10,E))),128))])]),p(`div`,D,[p(`div`,O,[p(`h1`,null,n(H.value.name),1),H.value.isNew?(u(),o(`span`,k,`جدید`)):i(``,!0)]),p(`p`,A,`کد محصول: `+n(H.value.code),1),p(`div`,j,[p(`div`,M,[f[4]||=p(`span`,{class:`spec-icon`,"aria-hidden":`true`},[p(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.6`},[p(`rect`,{x:`4`,y:`8`,width:`16`,height:`8`,rx:`2`})])],-1),f[5]||=p(`span`,null,`عرض`,-1),p(`strong`,null,n(c(g)(H.value.widthCm))+` سانتیمتر`,1)]),p(`div`,N,[f[6]||=p(`span`,{class:`spec-icon`,"aria-hidden":`true`},[p(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.6`},[p(`path`,{d:`M12 3.5 20 8v8l-8 4.5L4 16V8l8-4.5Z`})])],-1),f[7]||=p(`span`,null,`جنس`,-1),p(`strong`,null,n(H.value.composition||`—`),1)]),p(`div`,P,[p(`span`,F,[s(_e,{size:22,color:`#98a2ad`})]),f[8]||=p(`span`,null,`وزن`,-1),p(`strong`,null,n(H.value.weightGrams?`${c(g)(H.value.weightGrams)} گرم`:`—`),1)]),p(`div`,ye,[f[9]||=p(`span`,{class:`spec-icon`,"aria-hidden":`true`},[p(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.6`},[p(`circle`,{cx:`12`,cy:`12`,r:`8`}),p(`path`,{d:`M12 8a6 6 0 0 1 0 8`})])],-1),f[10]||=p(`span`,null,`نوع بافت`,-1),p(`strong`,null,n(H.value.weaveType||`—`),1)])]),p(`button`,{type:`button`,class:`specs-more`,onClick:f[1]||=e=>J.value=!J.value},[r(n(J.value?`بستن مشخصات`:`مشاهده همه مشخصات`)+` `,1),(u(),o(`svg`,{class:t([`specs-more__chevron`,{"is-open":J.value}]),viewBox:`0 0 12 12`,"aria-hidden":`true`},[...f[11]||=[p(`path`,{d:`M3 4.5 6 8l3-3.5`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.4`,"stroke-linecap":`round`},null,-1)]],2))]),J.value?(u(),o(`div`,be,[p(`p`,null,`فصل: `+n(He.value),1),p(`p`,null,`دسته: `+n(Ve.value),1),p(`p`,null,`جمع سفارش: `+n(c(g)(Z.value))+` متر`,1)])):i(``,!0),p(`section`,xe,[p(`div`,Se,[f[12]||=p(`h2`,null,`رنگبندی`,-1),p(`span`,null,`(`+n(c(g)(H.value.colors.length))+` رنگ موجود)`,1)]),p(`div`,Ce,[(u(!0),o(a,null,d(H.value.colors,(e,n)=>(u(),o(`button`,{key:n,type:`button`,class:t([`color-dot`,{"color-dot--active":G.value===n}]),style:l(c(_)(e,H.value.colorImages?.[n]||H.value.imageUrls?.[n])),onClick:e=>G.value=n},null,14,we))),128))])]),p(`section`,Te,[f[13]||=p(`h2`,{class:`section-title`},`دستهبندی`,-1),p(`div`,Ee,[(u(!0),o(a,null,d(Ue.value,e=>(u(),o(`button`,{key:e.key,type:`button`,class:t([`tag`,{"tag--link":!!e.to}]),role:`listitem`,onClick:t=>e.to&&c(R).push(e.to)},n(e.label),11,De))),128))])]),p(`section`,Oe,[f[14]||=p(`h2`,{class:`section-title`},`متراژ هر ساقه (طاقه)`,-1),p(`div`,I,n(c(g)(H.value.rollMeters))+` متر`,1)])])]),p(`footer`,ke,[p(`div`,Ae,[p(`button`,{type:`button`,class:`btn-primary`,disabled:q.value,onClick:Ke},[s(ae,{size:18,color:`#ffffff`}),r(` `+n(q.value?`در حال افزودن...`:`افزودن به سفارش`),1)],8,je),p(`p`,Me,`حداقل سفارش: `+n(c(g)(Q.value))+` طاقه`,1)]),p(`button`,{type:`button`,class:`btn-secondary`,onClick:f[2]||=e=>c(R).push({path:`/catalog-request`,query:{productId:H.value.id}})},[s(se,{size:18}),f[15]||=r(` درخواست کالیته `,-1)])])])):U.value?(u(),o(`div`,Ne,[s(ue,{variant:`detail`})])):(u(),o(`div`,Pe,[p(`p`,null,n(W.value||`محصول یافت نشد.`),1),p(`button`,{type:`button`,onClick:f[3]||=e=>c(R).push(`/products`)},`بازگشت به لیست`)]))}}),[[`__scopeId`,`data-v-f892ab0d`]]);export{L as default}; |