1 line
8.6 KiB
JavaScript
1 line
8.6 KiB
JavaScript
import{A as e,D as t,I as n,J as r,K as i,L as a,M as o,N as s,R as c,St as l,Tt as u,X as d,_ as ee,et as te,g as ne,k as f,n as p,pt as m,wt as h,xt as g}from"./BasicIcon-B6lR-mG3.js";import{o as _}from"./format-BHJptHdF.js";import{t as re}from"./catalog-DNpqlweh.js";import{E as ie,l as ae,w as oe,x as se}from"./index-DXso6ia7.js";import{t as ce}from"./IconChevronBack-BXRfc2bX.js";import{t as le}from"./PageSkeleton-BImjuI6S.js";import{t as ue}from"./IconShare-CoOzZmBa.js";import{a as de,i as fe,t as pe}from"./crm-DbcoqKAF.js";import{t as me}from"./useGoBack-yePcdjuj.js";import{t as he}from"./IconShoppingBag-DW_Of8if.js";import{t as ge}from"./IconHeart-DjMqqdO0.js";var _e={key:0,class:`page product-detail`},v={class:`pd-header`},y={class:`pd-header__actions`},b=[`aria-label`,`aria-pressed`],x={class:`page__scroll pd-scroll`},S={class:`gallery`},C={class:`gallery__count`},w={class:`gallery__thumbs`},T=[`onClick`],E={class:`pd-body`},D={class:`title-row`},O={key:0,class:`new-badge`},k={class:`code`},A={class:`specs`},j={class:`spec-cell`},M={class:`spec-cell`},N={class:`spec-cell`},P={class:`spec-icon`,"aria-hidden":`true`},F={class:`spec-cell`},I={key:0,class:`specs-extra`},ve={class:`pd-section pd-section--boxed`},ye={class:`section-head`},be={class:`colors`},xe=[`onClick`],Se={class:`pd-section`},Ce={class:`tags`,role:`list`},we=[`onClick`],Te={class:`pd-section`},Ee={class:`roll-field`},De={class:`pd-footer`},Oe={class:`pd-footer__primary`},ke=[`disabled`],Ae={class:`min-note`},je={key:1,class:`page empty`},Me={key:2,class:`page empty`},L=p(c({__name:`ProductDetailView`,setup(c){let p={suit:`پارچه کتشلواری`,trousers:`پارچه شلواری`,shirt:`پارچه پیراهنی`},L={summer:`پارچه تابستانه`,winter:`پارچه زمستانه`,all_season:`پارچه چهارفصل`},Ne=ne(),R=ee(),{goBack:z}=me(`/products`),Pe=pe(),B=ae(),Fe=ie(),Ie=re(),V=f(()=>String(Ne.query.id??``)),H=m(null),U=m(!0),W=m(null),G=m(0),K=m(1),q=m(!1),J=m(!1),Y=f(()=>H.value?.rollMeters??50),X=f(()=>K.value*Y.value),Le=f(()=>{let e=H.value?.minMeterage;return e&&e>0?e:Y.value}),Z=f(()=>Math.max(1,Math.ceil(Le.value/Y.value))),Re=f(()=>p[H.value?.categoryId??``]||`—`),Q=f(()=>L[H.value?.season??``]||`—`),ze=f(()=>{let e=H.value;if(!e)return[];let t=[],n=de.some(t=>t.id===e.categoryId)?e.categoryId:``,r=n?p[n]:``;r&&t.push({key:`usage-${n}`,label:r,to:{path:`/products`,query:{categoryId:n}}});let i=fe.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(),Ie.loadCompanies()]),H.value=await Pe.loadProductById(V.value),G.value=0,K.value=Z.value}catch(e){H.value=null,W.value=e instanceof Error?e.message:`محصول یافت نشد.`}finally{U.value=!1}}i($),te(V,$);function Be(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 Ve(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 He(){if(!H.value)return;let e=Be(H.value);q.value=!0;try{let t=Ve(X.value,e.orderMultiplier,e.minMeterage);await Fe.addItem(e,H.value.catalogCode||H.value.code,t)}finally{q.value=!1}}function Ue(){H.value&&B.toggle(H.value.id)}function We(){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(i,c)=>H.valu
|