Files
nademitex_user/dist/assets/CheckListView-C2RmOScu.js
T

1 line
9.8 KiB
JavaScript
Raw Normal View History

import{A as e,Ct as t,Dt as n,L as r,M as i,N as a,O as o,P as s,Q as c,R as l,X as u,_ as d,g as ee,ht as f,it as p,j as m,n as te,nt as ne,wt as h,z as g}from"./BasicIcon-Bnxm-DKk.js";import{d as _,n as re,o as v,r as y}from"./format-C72AoJ2H.js";import{c as ie,d as ae,f as oe,n as b,t as se}from"./index-DB4cQnln.js";import{t as x}from"./EmptyState-CsuH56HV.js";import{t as S}from"./IconChevronBack-DguSlPDK.js";import{t as ce}from"./FormErrorBanner-BahrrGfv.js";import{t as le}from"./useRequirePricedOrder-CUckkgqU.js";var C=Object.defineProperty,w=(e,t)=>{let n={};for(var r in e)C(n,r,{get:e[r],enumerable:!0});return t||C(n,Symbol.toStringTag,{value:`Module`}),n},ue={class:`check-list-page mobile-only`},de={class:`check-list-page__nav`},fe={type:`button`,class:`nav-btn nav-btn--ghost`,"aria-hidden":`true`,tabindex:`-1`},pe={key:0,class:`check-list-page__empty page__scroll page__scroll--with-nav`},me={class:`check-list-page__scroll page__scroll`},he={class:`summary-cards`},ge={class:`summary-card`},_e={class:`summary-card__value`},T={class:`summary-card`},E={class:`summary-card__value`},D={key:0,class:`summary-card__status`},O={key:1,class:`summary-card__status summary-card__status--warn`},k={class:`summary-card__value`},A={key:0,class:`summary-card__hint`},j={class:`checks-list`},M={class:`check-card__menu-wrap`},N=[`onClick`],P={key:1,class:`check-card__menu`},F=[`onClick`],I={class:`check-card__body`},ve={class:`check-card__title`},ye={class:`check-card__amount`},be={class:`check-card__date`},xe={class:`check-card__thumb-wrap`},Se=[`src`],Ce={key:1,class:`check-card__thumb check-card__thumb--empty`},we={class:`rass-panel`},Te={class:`rass-panel__days`},Ee={key:0,class:`rass-panel__date`},De={key:0,class:`check-list-page__footer`},L={key:0,class:`desktop-checkout-shell check-list-desktop desktop-only`},Oe={class:`desktop-two-col`},ke={class:`desktop-two-col__main`},Ae={class:`desktop-table-wrap`},je={class:`desktop-table-scroll`},Me={class:`desktop-table check-list-desktop__table`},Ne={key:0,scope:`col`},Pe=[`src`],Fe={key:1},Ie={class:`check-list-desktop__amount`},Le={key:0},Re=[`onClick`],ze={class:`desktop-summary-panel`},Be={class:`desktop-summary-panel__row`},Ve={class:`desktop-summary-panel__row`},He={class:`desktop-summary-panel__row`},Ue={key:0,class:`desktop-summary-panel__action`},We={key:1,class:`desktop-checkout-shell desktop-only`},R=g({__name:`CheckListView`,setup(te){let g=ee(),C=d(),w=ae(),R=ie(),z=f(``),B=f(!1),V=e(()=>g.name===`check-list`),{orderId:H}=le(),U=e(()=>H.value?w.getOrderById(H.value):void 0);ne(H,async e=>{if(!e||!V.value)return;let t=w.getOrderById(e)??await w.fetchOrder(e);t&&(w.draftChecks.length===0&&(t.checks?.length??0)>0?w.loadChecksIntoDraft(t):w.draftOrderId!==e&&w.startCheckDraft(e,t.checkMode??void 0))},{immediate:!0});let W=e(()=>w.draftChecks.length>0?w.draftChecks:V.value?U.value?.checks??[]:R.user?w.userOrders(R.user.id).filter(e=>e.settlementType===`check`&&e.checks?.length).flatMap(e=>e.checks??[]):[]),G=e(()=>w.draftChecks.length>0?w.getDraftRass():oe(W.value,new Date)),K=e(()=>U.value?.finalAmount??0),q=e(()=>Math.max(0,K.value-G.value.totalAmount)),J=e(()=>K.value>0&&G.value.totalAmount>=K.value),Y=e(()=>K.value>0&&G.value.totalAmount>K.value),X=e({get:()=>g.query.menu??``,set:e=>{C.replace({query:e?{menu:e}:{}})}});function Ge(){C.push(V.value?`/orders/${H.value}`:`/profile`)}function Z(){C.push(`/orders/${H.value}/check-form`)}async function Q(e){X.value=``,await se({title:`حذف چک`,message:`آیا از حذف این چک مطمئن هستید؟`,confirmLabel:`حذف`,cancelLabel:`انصراف`,tone:`danger`})&&w.removeDraftCheck(e)}function Ke(e){X.value=X.value===e?``:e}async function $(){if(!(!H.value||w.draftChecks.length===0||B.value)){z.value=``,B.value=!0;try{await w.updateOrderChecks(H.value,[...w.draftChecks],w.draftCheckMode??`brief`),C.replace(`/orders/${H.value}?track=1`)}catch(e){z.value=e instanceof Error?e.message:`ثبت چک‌ها ناموفق بود.`}finally{B.value=!1}}}return(e,d)=>(u(),s(o,null,[m(`div`,ue,[m(`header`,de,[m(`button`,{type:`