Files
nademitex_user/dist/assets/ProductDetailView-DUs0ddFz.js
T

1 line
9.2 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-DDi4iM2C.js";import{t as ce}from"./IconChevronBack-BXRfc2bX.js";import{t as le}from"./PageSkeleton-BImjuI6S.js";import{a as ue,i as de,t as fe}from"./crm-DbcoqKAF.js";import{t as pe}from"./IconShoppingBag-DW_Of8if.js";import{t as me}from"./useGoBack-yePcdjuj.js";import{t as he}from"./IconHeart-DjMqqdO0.js";var v=[`width`,`height`],y=[`stroke`],b=[`stroke`],x=[`stroke`],S=c({__name:`IconShare`,props:{size:{default:20},color:{default:`#9AA3AF`}},setup(t){return(n,i)=>(r(),s(`svg`,{width:t.size,height:t.size,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`},[e(`path`,{d:`M12 3.5v11`,stroke:t.color,"stroke-width":`1.5`,"stroke-linecap":`round`},null,8,y),e(`path`,{d:`M8.25 7 12 3.25 15.75 7`,stroke:t.color,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`},null,8,b),e(`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:t.color,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`},null,8,x)],8,v))}}),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=p(c({__name:`ProductDetailView`,setup(c){let p={suit:`پارچه کت‌شلواری`,trousers:`پارچه شلواری`,shirt:`پارچه پیراهنی`},v={summer:`پارچه تابستانه`,winter:`پارچه زمستانه`,all_season:`پارچه چهارفصل`},y=ne(),b=ee(),{goBack:x}=me(`/products`),z=fe(),B=ae(),Fe=ie(),Ie=re(),V=f(()=>String(y.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(()=>v[H.value?.season??``]||`—`),ze=f(()=>{let e=H.value;if(!e)return[];let t=[],n=ue.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=de.some(t=>t.id===e.season)?e.season:``,a=i?v[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($),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.value?(r(),s(`div`,C,[e(`header`,w,[e(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:c[0]||=(...e)=>g(x)&&g(x)(...e)},[a(ce,{size:20})]),e(`div`,T,[e(`button`,{type:`button`,class:`icon-btn`,"aria-label":g(B).isFavorite(H.value.id)?`حذف از علاقه‌مندی‌ها`:`افزودن به علاقه‌مندی‌ها`,"aria-pressed":g(B).isFavorite(H.value.id),onClick:Ue},[a(he,{size:20,filled:g(B).isFavorite(H.value.id),color:g(B).isFavorite(H.value.id)?`#0a353c`:void 0},null,8,[`filled`,`color`])],8,E),e(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اشتراک‌گذاری`,onClick:We},[a(S,{size:20})])])]),e(`div`,D,[e(`div`,O,[e(`div`,{class:`gallery__main`,style:h(H.value.imageUrl?{backgroundImage:`url(${H.value.imageUrl})`,backgroundSize:`cover`,backgroundPosition:`center`}:{background:H.value.colors[G.value]||`#6b7280`})},[e(`span`,k,u(g(_)(G.value+1))+`/`+u(g(_)(Math.max(H.value.colors.length,1))),1)],4),e(`div`,A,[(r(!0),s(t,null,d(H.value.colors,(t,n)=>(r(),s(`button`,{key:n,type:`button`,class:l([`thumb`,{"thumb--active":G.value===n}]),onClick:e=>G.value=n},[e(`span`,{class:`thumb__swatch`,style:h({background:t})},null,4)],10,j))),128))])]),e(`div`,M,[e(`div`,N,[e(`h1`,null,u(H.value.name),1),H.value.isNew?(r(),s(`span`,P,`جدید`)):o(``,!0)]),e(`p`,F,`کد محصول: `+u(H.value.code),1),e(`div`,I,[e(`div`,L,[c[4]||=e(`span`,{class:`spec-icon`,"aria-hidden":`true`},[e(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.6`},[e(`rect`,{x:`4`,y:`8`,width:`16`,height:`8`,rx:`2`})])],-1),c[5]||=e(`span`,null,`عرض`,-1),e(`strong`,null,u(g(_)(H.value.widthCm))+` سانتی‌متر`,1)]),e(`div`,R,[c[6]||=e(`span`,{class:`spec-icon`,"aria-hidden":`true`},[e(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.6`},[e(`path`,{d:`M12 3.5 20 8v8l-8 4.5L4 16V8l8-4.5Z`})])],-1),c[7]||=e(`span`,null,`جنس`,-1),e(`strong`,null,u(H.value.composition||`—`),1)]),e(`div`,ge,[e(`span`,_e,[a(pe,{size:22,color:`#98a2ad`})]),c[8]||=e(`span`,null,`وزن`,-1),e(`strong`,null,u(H.value.weightGrams?`${g(_)(H.value.weightGrams)} گرم`:`—`),1)]),e(`div`,ve,[c[9]||=e(`span`,{class:`spec-icon`,"aria-hidden":`true`},[e(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.6`},[e(`circle`,{cx:`12`,cy:`12`,r:`8`}),e(`path`,{d:`M12 8a6 6 0 0 1 0 8`})])],-1),c[10]||=e(`span`,null,`نوع بافت`,-1),e(`strong`,null,u(H.value.weaveType||`—`),1)])]),e(`button`,{type:`button`,class:`specs-more`,onClick:c[1]||=e=>J.value=!J.value},[n(u(J.value?`بستن مشخصات`:`مشاهده همه مشخصات`)+` `,1),(r(),s(`svg`,{class:l([`specs-more__chevron`,{"is-open":J.value}]),viewBox:`0 0 12 12`,"aria-hidden":`true`},[...c[11]||=[e(`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?(r(),s(`div`,ye,[e(`p`,null,`فصل: `+u(Q.value),1),e(`p`,null,`دسته: `+u(Re.value),1),e(`p`,null,`جمع سفارش: `+u(g(_)(X.value))+` متر`,1)])):o(``,!0),e(`section`,be,[e(`div`,xe,[c[12]||=e(`h2`,null,`رنگ‌بندی`,-1),e(`span`,null,`(`+u(g(_)(H.value.colors.length))+` رنگ موجود)`,1)]),e(`div`,Se,[(r(!0),s(t,null,d(H.value.colors,(e,t)=>(r(),s(`button`,{key:t,type:`button`,class:l([`color-dot`,{"color-dot--active":G.value===t}]),style:h({background:e}),onClick:e=>G.value=t},null,14,Ce))),128))])]),e(`section`,we,[c[13]||=e(`h2`,{class:`section-title`},`دسته‌بندی`,-1),e(`div`,Te,[(r(!0),s(t,null,d(ze.value,e=>(r(),s(`button`,{key:e.key,type:`button`,class:l([`tag`,{"tag--link":!!e.to}]),role:`listitem`,onClick:t=>e.to&&g(b).push(e.to)},u(e.label),11,Ee))),128))])]),e(`section`,De,[c[14]||=e(`h2`,{class:`section-title`},`متراژ هر ساقه (طاقه)`,-1),e(`div`,Oe,u(g(_)(H.value.rollMeters))+` متر`,1)])])]),e(`footer`,ke,[e(`div`,Ae,[e(`button`,{type:`button`,class:`btn-primary`,disabled:q.value,onClick:He},[a(oe,{size:18,color:`#ffffff`}),n(` `+u(q.value?`در حال افزودن...`:`افزودن به سفارش`),1)],8,je),e(`p`,Me,`حداقل سفارش: `+u(g(_)(Z.value))+` طاقه`,1)]),e(`button`,{type:`button`,class:`btn-secondary`,onClick:c[2]||=e=>g(b).push({path:`/catalog-request`,query:{productId:H.value.id}})},[a(se,{size:18}),c[15]||=n(` درخواست کالیته `,-1)])])])):U.value?(r(),s(`div`,Ne,[a(le,{variant:`detail`})])):(r(),s(`div`,Pe,[e(`p`,null,u(W.value||`محصول یافت نشد.`),1),e(`button`,{type:`button`,onClick:c[3]||=e=>g(b).push(`/products`)},`بازگشت به لیست`)]))}}),[[`__scopeId`,`data-v-1eb99089`]]);export{z as default};