1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
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-
|