Files
nademitex_user/dist/assets/ProductDetailView-DeWz9Sq6.js
T
2026-09-10 21:52:48 +03:30

1 line
9.2 KiB
JavaScript

import{$ as e,Ct as t,E as n,F as r,G as i,I as a,L as o,M as s,O as c,Y as l,_ as ee,bt as u,ft as d,g as te,j as f,k as p,n as m,q as h,wt as g,xt as _}from"./BasicIcon-CjTTsi6o.js";import{o as v}from"./format-BHJptHdF.js";import{t as ne}from"./catalog-Dd554brK.js";import{C as re,T as ie,b as ae,l as oe}from"./index-D3Z8WOeX.js";import{t as se}from"./IconChevronBack-B10eZjCQ.js";import{t as ce}from"./PageSkeleton-CyATkHE1.js";import{a as le,i as ue,t as de}from"./crm-l0KpZ2AN.js";import{t as fe}from"./IconShoppingBag-B7WsCtZ4.js";import{t as pe}from"./useGoBack-D3aJ73Q-.js";import{t as me}from"./IconHeart-BmvFB3Xr.js";var y=[`width`,`height`],b=[`stroke`],x=[`stroke`],S=[`stroke`],he=o({__name:`IconShare`,props:{size:{default:20},color:{default:`#9AA3AF`}},setup(e){return(t,n)=>(h(),s(`svg`,{width:e.size,height:e.size,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`},[p(`path`,{d:`M12 3.5v11`,stroke:e.color,"stroke-width":`1.5`,"stroke-linecap":`round`},null,8,b),p(`path`,{d:`M8.25 7 12 3.25 15.75 7`,stroke:e.color,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`},null,8,x),p(`path`,{d:`M6.5 11.5v7.25c0 .97.78 1.75 1.75 1.75h7.5c.97 0 1.75-.78 1.75-1.75V11.5`,stroke:e.color,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`},null,8,S)],8,y))}}),C={key:0,class:`page product-detail`},w={class:`pd-header`},T={class:`pd-header__actions`},E=[`aria-label`,`aria-pressed`],D={class:`page__scroll pd-scroll`},O={class:`gallery`},k={class:`gallery__count`},A={class:`gallery__thumbs`},j=[`onClick`],M={class:`pd-body`},N={class:`title-row`},P={key:0,class:`new-badge`},F={class:`code`},I={class:`specs`},L={class:`spec-cell`},R={class:`spec-cell`},ge={class:`spec-cell`},_e={class:`spec-icon`,"aria-hidden":`true`},ve={class:`spec-cell`},ye={key:0,class:`specs-extra`},be={class:`pd-section pd-section--boxed`},xe={class:`section-head`},Se={class:`colors`},Ce=[`onClick`],we={class:`pd-section`},Te={class:`tags`,role:`list`},Ee=[`onClick`],De={class:`pd-section`},Oe={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`},z=m(o({__name:`ProductDetailView`,setup(o){let m={suit:`پارچه کت‌شلواری`,trousers:`پارچه شلواری`,shirt:`پارچه پیراهنی`},y={summer:`پارچه تابستانه`,winter:`پارچه زمستانه`,all_season:`پارچه چهارفصل`},b=te(),x=ee(),{goBack:S}=pe(`/products`),z=de(),B=oe(),Fe=ie(),Ie=ne(),V=c(()=>String(b.query.id??``)),H=d(null),U=d(!0),W=d(null),G=d(0),K=d(1),q=d(!1),J=d(!1),Y=c(()=>H.value?.rollMeters??50),X=c(()=>K.value*Y.value),Le=c(()=>{let e=H.value?.minMeterage;return e&&e>0?e:Y.value}),Z=c(()=>Math.max(1,Math.ceil(Le.value/Y.value))),Re=c(()=>m[H.value?.categoryId??``]||`—`),Q=c(()=>y[H.value?.season??``]||`—`),ze=c(()=>{let e=H.value;if(!e)return[];let t=[],n=le.some(t=>t.id===e.categoryId)?e.categoryId:``,r=n?m[n]:``;r&&t.push({key:`usage-${n}`,label:r,to:{path:`/products`,query:{categoryId:n}}});let i=ue.some(t=>t.id===e.season)?e.season:``,a=i?y[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 z.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($),e(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(e,i)=>H.value?(h(),s(`div`,C,[p(`header`,w,[p(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:i[0]||=(...e)=>u(S)&&u(S)(...e)},[a(se,{size:20})]),p(`div`,T,[p(`button`,{type:`button`,class:`icon-btn`,"aria-label":u(B).isFavorite(H.value.id)?`حذف از علاقه‌مندی‌ها`:`افزودن به علاقه‌مندی‌ها`,"aria-pressed":u(B).isFavorite(H.value.id),onClick:Ue},[a(me,{size:20,filled:u(B).isFavorite(H.value.id),color:u(B).isFavorite(H.value.id)?`#0a353c`:void 0},null,8,[`filled`,`color`])],8,E),p(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اشتراک‌گذاری`,onClick:We},[a(he,{size:20})])])]),p(`div`,D,[p(`div`,O,[p(`div`,{class:`gallery__main`,style:t(H.value.imageUrl?{backgroundImage:`url(${H.value.imageUrl})`,backgroundSize:`cover`,backgroundPosition:`center`}:{background:H.value.colors[G.value]||`#6b7280`})},[p(`span`,k,g(u(v)(G.value+1))+`/`+g(u(v)(Math.max(H.value.colors.length,1))),1)],4),p(`div`,A,[(h(!0),s(n,null,l(H.value.colors,(e,n)=>(h(),s(`button`,{key:n,type:`button`,class:_([`thumb`,{"thumb--active":G.value===n}]),onClick:e=>G.value=n},[p(`span`,{class:`thumb__swatch`,style:t({background:e})},null,4)],10,j))),128))])]),p(`div`,M,[p(`div`,N,[p(`h1`,null,g(H.value.name),1),H.value.isNew?(h(),s(`span`,P,`جدید`)):f(``,!0)]),p(`p`,F,`کد محصول: `+g(H.value.code),1),p(`div`,I,[p(`div`,L,[i[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),i[5]||=p(`span`,null,`عرض`,-1),p(`strong`,null,g(u(v)(H.value.widthCm))+` سانتی‌متر`,1)]),p(`div`,R,[i[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),i[7]||=p(`span`,null,`جنس`,-1),p(`strong`,null,g(H.value.composition||`—`),1)]),p(`div`,ge,[p(`span`,_e,[a(fe,{size:22,color:`#98a2ad`})]),i[8]||=p(`span`,null,`وزن`,-1),p(`strong`,null,g(H.value.weightGrams?`${u(v)(H.value.weightGrams)} گرم`:`—`),1)]),p(`div`,ve,[i[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),i[10]||=p(`span`,null,`نوع بافت`,-1),p(`strong`,null,g(H.value.weaveType||`—`),1)])]),p(`button`,{type:`button`,class:`specs-more`,onClick:i[1]||=e=>J.value=!J.value},[r(g(J.value?`بستن مشخصات`:`مشاهده همه مشخصات`)+` `,1),(h(),s(`svg`,{class:_([`specs-more__chevron`,{"is-open":J.value}]),viewBox:`0 0 12 12`,"aria-hidden":`true`},[...i[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?(h(),s(`div`,ye,[p(`p`,null,`فصل: `+g(Q.value),1),p(`p`,null,`دسته: `+g(Re.value),1),p(`p`,null,`جمع سفارش: `+g(u(v)(X.value))+` متر`,1)])):f(``,!0),p(`section`,be,[p(`div`,xe,[i[12]||=p(`h2`,null,`رنگ‌بندی`,-1),p(`span`,null,`(`+g(u(v)(H.value.colors.length))+` رنگ موجود)`,1)]),p(`div`,Se,[(h(!0),s(n,null,l(H.value.colors,(e,n)=>(h(),s(`button`,{key:n,type:`button`,class:_([`color-dot`,{"color-dot--active":G.value===n}]),style:t({background:e}),onClick:e=>G.value=n},null,14,Ce))),128))])]),p(`section`,we,[i[13]||=p(`h2`,{class:`section-title`},`دسته‌بندی`,-1),p(`div`,Te,[(h(!0),s(n,null,l(ze.value,e=>(h(),s(`button`,{key:e.key,type:`button`,class:_([`tag`,{"tag--link":!!e.to}]),role:`listitem`,onClick:t=>e.to&&u(x).push(e.to)},g(e.label),11,Ee))),128))])]),p(`section`,De,[i[14]||=p(`h2`,{class:`section-title`},`متراژ هر ساقه (طاقه)`,-1),p(`div`,Oe,g(u(v)(H.value.rollMeters))+` متر`,1)])])]),p(`footer`,ke,[p(`div`,Ae,[p(`button`,{type:`button`,class:`btn-primary`,disabled:q.value,onClick:He},[a(re,{size:18,color:`#ffffff`}),r(` `+g(q.value?`در حال افزودن...`:`افزودن به سفارش`),1)],8,je),p(`p`,Me,`حداقل سفارش: `+g(u(v)(Z.value))+` طاقه`,1)]),p(`button`,{type:`button`,class:`btn-secondary`,onClick:i[2]||=e=>u(x).push({path:`/catalog-request`,query:{productId:H.value.id}})},[a(ae,{size:18}),i[15]||=r(` درخواست کالیته `,-1)])])])):U.value?(h(),s(`div`,Ne,[a(ce,{variant:`detail`})])):(h(),s(`div`,Pe,[p(`p`,null,g(W.value||`محصول یافت نشد.`),1),p(`button`,{type:`button`,onClick:i[3]||=e=>u(x).push(`/products`)},`بازگشت به لیست`)]))}}),[[`__scopeId`,`data-v-1eb99089`]]);export{z as default};