1 line
17 KiB
JavaScript
1 line
17 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,c as D,k as O,r as k,t as A,u as te}from"./index-BPUhS8CY.js";import{t as ne}from"./IconChevronBack-DytWz6TD.js";import{t as re}from"./PageSkeleton-DYdjm4l9.js";import{a as ie,o as ae,t as oe}from"./crm-BKPKhzCX.js";import{t as se}from"./useGoBack-BkqOD93C.js";import{n as ce,r as le,t as ue}from"./IconWeave-CTypFxhM.js";import{t as j}from"./IconHeart-CvzbNH_T.js";import{n as de,t as fe}from"./AddressCompletionModal-BQQfvcHU.js";import{n as M,t as pe}from"./colorSwatch-BgOH1LE5.js";import{r as me,t as he}from"./useStockNotify-DeMc7Vja.js";var ge=[`width`,`height`],_e=[`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,_e),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,ge))}}),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`},ve={key:0},Y={key:1},X={key:2},Z={key:0,class:`product-order-modal__hint`},ye=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 O(e,t){let n=[...C.value];n[e]=Math.max(0,(n[e]??0)+t),C.value=n}function A(){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(M)(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=>O(n,-1)},` − `,8,U),h(`s
|