Files
nademitex_user/dist/assets/ProductDetailView-DoM4C5Ou.js
T
2026-09-29 22:01:22 +03:30

1 line
16 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{At as e,D as t,F as n,G as r,M as i,Nt as a,Pt as o,U as s,_ as c,c as l,d as u,f as d,g as f,i as p,k as m,l as h,nt as g,o as _,t as v,u as y,ut as b,v as x}from"./_plugin-vue_export-helper-1xMDlcEE.js";import{u as ee}from"./BasicIcon-ba1FsUKx.js";import{o as S}from"./format-C72AoJ2H.js";import{t as C}from"./catalog-DvXpKfLO.js";import{A as w,E as T,O as E,k as D,r as O,u as k}from"./index-BSpFi5xB.js";import{t as te}from"./IconChevronBack-DytWz6TD.js";import{t as ne}from"./PageSkeleton-DYdjm4l9.js";import{a as re,o as ie,t as ae}from"./crm-Bj4T2PId.js";import{t as oe}from"./useGoBack-aBY3TtNx.js";import{n as se,r as ce,t as le}from"./IconWeave-CTypFxhM.js";import{t as A}from"./IconHeart-CvzbNH_T.js";import{n as ue,t as de}from"./AddressCompletionModal-CtP8_RSJ.js";import{n as j,t as fe}from"./colorSwatch-BgOH1LE5.js";var pe=[`width`,`height`],M=[`stroke`],N=[`stroke`],P=[`stroke`],F=x({__name:`IconShare`,props:{size:{default:20},color:{default:`#9AA3AF`}},setup(e){return(t,n)=>(i(),d(`svg`,{width:e.size,height:e.size,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`},[h(`path`,{d:`M12 3.5v11`,stroke:e.color,"stroke-width":`1.5`,"stroke-linecap":`round`},null,8,M),h(`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,N),h(`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,P)],8,pe))}}),I={class:`dialog card product-order-modal`},L={class:`product-order-modal__head`},R={class:`product-order-modal__rows`},z={class:`product-order-row__color`},B=[`title`],V={key:0,class:`product-order-row__label`},H={class:`product-order-row__stepper`},U=[`disabled`,`onClick`],W={class:`product-order-row__qty`},G=[`disabled`,`onClick`],K={key:0,class:`product-order-modal__error`},q={class:`product-order-modal__footer`},J={class:`product-order-modal__price`},Y={key:0},X={key:1},Z={key:2},me={key:0,class:`product-order-modal__hint`},he=v(x({__name:`ProductOrderModal`,props:{open:{type:Boolean},product:{},rollMeters:{},minRolls:{},basePrice:{},loading:{type:Boolean},error:{}},emits:[`close`,`submit`],setup(e,{emit:m}){let v=e,x=m,C=g([]);s(()=>[v.open,v.product?.colors.length],([e])=>{!e||!v.product||(C.value=v.product.colors.map(()=>0))});let w=l(()=>C.value.reduce((e,t)=>e+(t>0?t:0),0)),T=l(()=>w.value*v.rollMeters),E=l(()=>!v.basePrice||T.value<=0?null:v.basePrice*T.value);function D(e){e.key===`Escape`&&v.open&&x(`close`)}s(()=>v.open,e=>{document.body.style.overflow=e?`hidden`:``,e?window.addEventListener(`keydown`,D):window.removeEventListener(`keydown`,D)},{immediate:!0}),t(()=>{document.body.style.overflow=``,window.removeEventListener(`keydown`,D)});function k(e,t){let n=[...C.value];n[e]=Math.max(0,(n[e]??0)+t),C.value=n}function te(){x(`submit`,[...C.value])}return(t,s)=>(i(),y(_,{to:`body`},[e.open&&e.product?(i(),d(`div`,{key:0,class:`dialog-overlay product-order-overlay`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`product-order-title`,onClick:s[1]||=ee(e=>x(`close`),[`self`])},[h(`div`,I,[h(`header`,L,[s[2]||=h(`h3`,{id:`product-order-title`,class:`product-order-modal__title`},`ثبت سفارش`,-1),h(`button`,{type:`button`,class:`product-order-modal__close`,"aria-label":`بستن`,onClick:s[0]||=e=>x(`close`)},` × `)]),s[4]||=h(`div`,{class:`product-order-modal__table-head`,"aria-hidden":`true`},[h(`span`,null,`رنگ`),h(`span`,null,`تعداد`)],-1),h(`ul`,R,[(i(!0),d(p,null,n(e.product.colors,(t,n)=>(i(),d(`li`,{key:n,class:`product-order-row`},[h(`div`,z,[h(`span`,{class:`product-order-row__swatch`,style:a(b(j)(t,e.product.colorImages?.[n]||e.product.imageUrls?.[n])),title:t},null,12,B),t?(i(),d(`span`,V,o(t),1)):u(``,!0)]),h(`div`,H,[h(`button`,{type:`button`,class:`product-order-row__btn`,"aria-label":`کاهش`,disabled:e.loading||(C.value[n]??0)<=0,onClick:e=>k(n,-1)},` − `,8,U),h(`span`,W,o(b(S)(C.value[n]??0)),1),h(`button`,{type:`button`,class:`product-order-row__btn`,"aria-label":`افزایش`,disabled:e.loading,onClick:e=>k(n,1)},` + `,8,G)])]))),128))]),e.error?(i(),d(`p`,K,o(e.error),1)):u(``,!0),h(`footer`,q,[h(`div`,J,[s[3]||=h(`span`,null,`قیمت`,-1),E.value==null?w.value>0?(i(),d(`strong`,X,o(b(S)(T.value))+` متر `,1)):(i(),d(`strong`,Z,`—`)):(i(),d(`strong`,Y,o(b(S)(E.value))+` تومان `,1))]),e.minRolls>0?(i(),d(`p`,me,` حداقل سفارش: `+o(b(S)(e.minRolls))+` طاقه `,1)):u(``,!0),c(O,{class:`product-order-modal__submit`,disabled:e.loading,onClick:te},{default:r(()=>[f(o(e.loading?`در حال ثبت...`:`ثبت`),1)]),_:1},8,[`disabled`])])])])):u(``,!0)]))}}),[[`__scopeId`,`data-v-9e750bcd`]]),ge={key:0,class:`page product-detail product-page`},_e={class:`pd-header mobile-only`},ve={class:`pd-header__actions`},ye=[`aria-label`,`aria-pressed`],be={class:`desktop-page__head desktop-only pd-desk-head`},xe={class:`desktop-page__title`},Se={class:`desktop-page__subtitle`},Ce={class:`pd-desk-head__actions`},we=[`aria-label`,`aria-pressed`],Te={class:`page__scroll pd-scroll product-page__scroll`},Ee={class:`product-page__layout`},De={class:`product-page__main`},Oe={class:`gallery`},ke={class:`gallery__stage`},Ae={key:0,class:`gallery__dots`,role:`tablist`,"aria-label":`تصاویر محصول`},je=[`aria-label`,`aria-selected`,`onClick`],Me={class:`gallery__thumbs`},Ne=[`onClick`],Pe={class:`pd-body`},Fe={class:`title-row`},Ie={key:0,class:`new-badge`},Le={class:`code`},Re={class:`specs`},ze={class:`spec-cell`},Be={class:`spec-icon`,"aria-hidden":`true`},Ve={class:`spec-cell`},He={class:`spec-cell`},Ue={class:`spec-icon`,"aria-hidden":`true`},We={class:`spec-cell`},Ge={class:`spec-icon`,"aria-hidden":`true`},Ke={key:0,class:`specs-extra`},qe={class:`pd-section pd-section--boxed`},Je={class:`section-head`},Ye={class:`colors`},Xe=[`onClick`],Ze={class:`pd-section`},Qe={class:`tags`,role:`list`},$e=[`onClick`],et={class:`pd-section`},tt={class:`roll-field`},nt={class:`product-page__sidebar desktop-only`},rt={class:`cart-summary-panel`},it={class:`cart-summary-panel__row`},at={class:`cart-summary-panel__row`},ot={class:`cart-summary-panel__btn`},st=[`disabled`],ct={class:`pd-footer mobile-only sticky-footer`},lt={class:`pd-footer__primary`},ut={class:`min-note`},dt=[`disabled`],ft={key:1,class:`page empty`},pt={key:2,class:`page empty`},Q=v(x({__name:`ProductDetailView`,setup(t){let r={suit:`پارچه کت‌شلواری`,trousers:`پارچه شلواری`,shirt:`پارچه پیراهنی`},_={summer:`پارچه تابستانه`,winter:`پارچه زمستانه`,all_season:`پارچه چهارفصل`},v=D(),y=w(),{goBack:x}=oe(`/products`),ee=ae(),O=k(),pe=E(),M=C(),N=l(()=>String(v.query.id??``)),P=g(null),I=g(!0),L=g(null),R=g(0),z=g(1),B=g(!1),V=g(!1),H=g(!1),U=g(``),{requesting:W,addressModalOpen:G,addressError:K,requestCatalog:q,submitAddressAndRequest:J,closeAddressModal:Y}=ue(),X=l(()=>P.value?.rollMeters??50),Z=l(()=>{let e=P.value;return e?fe(e.colors,e.colorImages,e.imageUrls,R.value,e.imageUrl):``}),me=l(()=>P.value?.colors[R.value]??``),Q=l(()=>z.value*X.value),mt=l(()=>{let e=P.value?.minMeterage;return e&&e>0?e:X.value}),$=l(()=>Math.max(1,Math.ceil(mt.value/X.value))),ht=l(()=>r[P.value?.categoryId??``]||`—`),gt=l(()=>_[P.value?.season??``]||`—`),_t=l(()=>{let e=P.value;if(!e)return[];let t=[],n=ie.some(t=>t.id===e.categoryId)?e.categoryId:``,i=n?r[n]:``;i&&t.push({key:`usage-${n}`,label:i,to:{path:`/products`,query:{categoryId:n}}});let a=re.some(t=>t.id===e.season)?e.season:``,o=a?_[a]:``;o&&t.push({key:`season-${a}`,label:o,to:{path:`/products`,query:{season:a}}});let s=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||s.has(e)||t.some(t=>t.label.includes(e)))continue;let r=n.startsWith(`پارچه`)?n:`پارچه ${e}`;s.add(e),t.push({key:`tag-${n}`,label:r})}return t});async function vt(){if(!N.value){P.value=null,I.value=!1;return}I.value=!0,L.value=null;try{await Promise.all([O.hydrate(),M.loadCompanies()]),P.value=await ee.loadProductById(N.value),R.value=0,z.value=$.value}catch(e){P.value=null,L.value=e instanceof Error?e.message:`محصول یافت نشد.`}finally{I.value=!1}}m(vt),s(N,vt);function yt(e,t=R.value){let n=e.rollMeters||50,r=e.orderMultiplier&&e.orderMultiplier>0?e.orderMultiplier:n,i=e.minMeterage&&e.minMeterage>0?e.minMeterage:n;return{id:e.id,companyId:e.companyId||``,catalogId:e.catalogId||``,name:e.name,code:e.code,color:e.color||e.colors[t]||`—`,minMeterage:i,orderMultiplier:r,basePrice:e.basePrice,isActive:!0}}function bt(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)}function xt(){P.value&&(U.value=``,H.value=!0)}function St(){H.value=!1,U.value=``}async function Ct(e){let t=P.value;if(!t)return;let n=t.colors.map((t,n)=>({color:t,idx:n,rolls:e[n]??0})).filter(e=>e.rolls>0);if(!n.length){U.value=`حداقل یک رنگ با تعداد انتخاب کنید.`;return}let r=n.reduce((e,t)=>e+t.rolls,0)*X.value;if(r<mt.value){U.value=`حداقل سفارش ${S($.value)} طاقه است.`;return}let i=n[0],a=yt(t,i.idx),o=bt(r,a.orderMultiplier,a.minMeterage),s=n.map(e=>`${e.color||`رنگ ${e.idx+1}`}: ${S(e.rolls)} طاقه`).join(`، `);B.value=!0,U.value=``;try{let e=await pe.addItem(a,t.catalogCode||t.code,o,s,!0);if(!e.success){U.value=e.message??`افزودن به سفارش ناموفق بود.`;return}St()}finally{B.value=!1}}function wt(){P.value&&O.toggle(P.value.id)}function Tt(){let e=window.location.href;if(navigator.share){navigator.share({title:P.value?.name,url:e}).catch(()=>void 0);return}navigator.clipboard?.writeText(e)}function Et(){!P.value||W.value||q(P.value)}function Dt(e){J(e)}return(t,r)=>P.value?(i(),d(`div`,ge,[h(`header`,_e,[h(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:r[0]||=(...e)=>b(x)&&b(x)(...e)},[c(te,{size:20})]),h(`div`,ve,[h(`button`,{type:`button`,class:`icon-btn`,"aria-label":b(O).isFavorite(P.value.id)?`حذف از علاقه‌مندی‌ها`:`افزودن به علاقه‌مندی‌ها`,"aria-pressed":b(O).isFavorite(P.value.id),onClick:wt},[c(A,{size:20,filled:b(O).isFavorite(P.value.id),color:b(O).isFavorite(P.value.id)?`var(--color-primary)`:void 0},null,8,[`filled`,`color`])],8,ye),h(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اشتراک‌گذاری`,onClick:Tt},[c(F,{size:20})])])]),h(`header`,be,[h(`div`,null,[h(`h1`,xe,o(P.value.name),1),h(`p`,Se,`کد محصول: `+o(P.value.code),1)]),h(`div`,Ce,[h(`button`,{type:`button`,class:`icon-btn`,"aria-label":b(O).isFavorite(P.value.id)?`حذف از علاقه‌مندی‌ها`:`افزودن به علاقه‌مندی‌ها`,"aria-pressed":b(O).isFavorite(P.value.id),onClick:wt},[c(A,{size:20,filled:b(O).isFavorite(P.value.id),color:b(O).isFavorite(P.value.id)?`var(--color-primary)`:void 0},null,8,[`filled`,`color`])],8,we),h(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اشتراک‌گذاری`,onClick:Tt},[c(F,{size:20})])])]),h(`div`,Te,[h(`div`,Ee,[h(`div`,De,[h(`div`,Oe,[h(`div`,ke,[h(`div`,{class:`gallery__main`,style:a(Z.value?{backgroundImage:`url(${Z.value})`,backgroundSize:`cover`,backgroundPosition:`center`}:b(j)(me.value))},null,4),P.value.colors.length>1?(i(),d(`div`,Ae,[(i(!0),d(p,null,n(P.value.colors,(t,n)=>(i(),d(`button`,{key:n,type:`button`,class:e([`gallery__dot`,{"gallery__dot--active":R.value===n}]),"aria-label":t||`تصویر ${n+1}`,"aria-selected":R.value===n,onClick:e=>R.value=n},null,10,je))),128))])):u(``,!0)]),h(`div`,Me,[(i(!0),d(p,null,n(P.value.colors,(t,n)=>(i(),d(`button`,{key:n,type:`button`,class:e([`thumb`,{"thumb--active":R.value===n}]),onClick:e=>R.value=n},[h(`span`,{class:`thumb__swatch`,style:a(b(j)(t,P.value.colorImages?.[n]||P.value.imageUrls?.[n]))},null,4)],10,Ne))),128))])]),h(`div`,Pe,[h(`div`,Fe,[h(`h1`,null,o(P.value.name),1),P.value.isNew?(i(),d(`span`,Ie,`جدید`)):u(``,!0)]),h(`p`,Le,`کد محصول: `+o(P.value.code),1),h(`div`,Re,[h(`div`,ze,[h(`span`,Be,[c(se,{color:`#98a2ad`})]),r[3]||=h(`span`,null,`عرض`,-1),h(`strong`,null,o(b(S)(P.value.widthCm))+` سانتی‌متر`,1)]),h(`div`,Ve,[r[4]||=h(`span`,{class:`spec-icon`,"aria-hidden":`true`},[h(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.6`},[h(`path`,{d:`M12 3.5 20 8v8l-8 4.5L4 16V8l8-4.5Z`})])],-1),r[5]||=h(`span`,null,`جنس`,-1),h(`strong`,null,o(P.value.composition||`—`),1)]),h(`div`,He,[h(`span`,Ue,[c(ce,{size:22,color:`#98a2ad`})]),r[6]||=h(`span`,null,`وزن`,-1),h(`strong`,null,o(P.value.weightGrams?`${b(S)(P.value.weightGrams)} گرم`:`—`),1)]),h(`div`,We,[h(`span`,Ge,[c(le,{color:`#98a2ad`})]),r[7]||=h(`span`,null,`نوع بافت`,-1),h(`strong`,null,o(P.value.weaveType||`—`),1)])]),h(`button`,{type:`button`,class:`specs-more`,onClick:r[1]||=e=>V.value=!V.value},[f(o(V.value?`بستن مشخصات`:`مشاهده همه مشخصات`)+` `,1),(i(),d(`svg`,{class:e([`specs-more__chevron`,{"is-open":V.value}]),viewBox:`0 0 12 12`,"aria-hidden":`true`},[...r[8]||=[h(`path`,{d:`M3 4.5 6 8l3-3.5`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.4`,"stroke-linecap":`round`},null,-1)]],2))]),V.value?(i(),d(`div`,Ke,[h(`p`,null,`فصل: `+o(gt.value),1),h(`p`,null,`دسته: `+o(ht.value),1),h(`p`,null,`جمع سفارش: `+o(b(S)(Q.value))+` متر`,1)])):u(``,!0),h(`section`,qe,[h(`div`,Je,[r[9]||=h(`h2`,null,`رنگ‌بندی`,-1),h(`span`,null,`(`+o(b(S)(P.value.colors.length))+` رنگ موجود)`,1)]),h(`div`,Ye,[(i(!0),d(p,null,n(P.value.colors,(t,n)=>(i(),d(`button`,{key:n,type:`button`,class:e([`color-dot`,{"color-dot--active":R.value===n}]),style:a(b(j)(t,P.value.colorImages?.[n]||P.value.imageUrls?.[n])),onClick:e=>R.value=n},null,14,Xe))),128))])]),h(`section`,Ze,[r[10]||=h(`h2`,{class:`section-title`},`دسته‌بندی`,-1),h(`div`,Qe,[(i(!0),d(p,null,n(_t.value,t=>(i(),d(`button`,{key:t.key,type:`button`,class:e([`tag`,{"tag--link":!!t.to}]),role:`listitem`,onClick:e=>t.to&&b(y).push(t.to)},o(t.label),11,$e))),128))])]),h(`section`,et,[r[11]||=h(`h2`,{class:`section-title`},`متراژ هر طاقه`,-1),h(`div`,tt,o(b(S)(P.value.rollMeters))+` متر`,1)])])]),h(`aside`,nt,[h(`div`,rt,[r[15]||=h(`h2`,{class:`cart-summary-panel__title`},`ثبت سفارش`,-1),h(`div`,it,[r[12]||=h(`span`,null,`متراژ سفارش`,-1),h(`strong`,null,o(b(S)(Q.value))+` متر`,1)]),h(`div`,at,[r[13]||=h(`span`,null,`حداقل سفارش`,-1),h(`strong`,null,o(b(S)($.value))+` طاقه`,1)]),h(`div`,ot,[h(`button`,{type:`button`,class:`btn-primary`,onClick:xt},[c(T,{size:18,color:`#ffffff`}),r[14]||=f(` افزودن به سفارش `,-1)])]),h(`button`,{type:`button`,class:`btn-secondary pd-desk-catalog-btn`,disabled:b(W),onClick:Et},o(b(W)?`در حال ثبت...`:`درخواست کالیته`),9,st)])])])]),h(`footer`,ct,[h(`div`,lt,[h(`button`,{type:`button`,class:`btn-primary`,onClick:xt},[c(T,{size:18,color:`#ffffff`}),r[16]||=f(` افزودن به سفارش `,-1)]),h(`p`,ut,`حداقل سفارش: `+o(b(S)($.value))+` طاقه`,1)]),h(`button`,{type:`button`,class:`btn-secondary`,disabled:b(W),onClick:Et},o(b(W)?`در حال ثبت...`:`درخواست کالیته`),9,dt)]),c(de,{open:b(G),loading:b(W),error:b(K),onClose:b(Y),onSubmit:Dt},null,8,[`open`,`loading`,`error`,`onClose`]),c(he,{open:H.value,product:P.value,"roll-meters":X.value,"min-rolls":$.value,"base-price":P.value.basePrice,loading:B.value,error:U.value,onClose:St,onSubmit:Ct},null,8,[`open`,`product`,`roll-meters`,`min-rolls`,`base-price`,`loading`,`error`])])):I.value?(i(),d(`div`,ft,[c(ne,{variant:`detail`})])):(i(),d(`div`,pt,[h(`p`,null,o(L.value||`محصول یافت نشد.`),1),h(`button`,{type:`button`,onClick:r[2]||=e=>b(y).push(`/products`)},`بازگشت به لیست`)]))}}),[[`__scopeId`,`data-v-9e36151f`]]);export{Q as default};