mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-20 03:34:06 +00:00
2 lines
6.8 KiB
JavaScript
2 lines
6.8 KiB
JavaScript
import{L as Q,e as W,a7 as X,v as Y,H as z,f as Z,a5 as ee,u as te,k as h,z as ae,P as se,r as d,o as m,m as y,w as o,a,b as l,l as n,p as E,t as p,K as B,bj as V,bk as oe,c as S,O as re,J as le,N as ne}from"./main-WMXHPsTs.js";import{u as ie}from"./estimate-j8ZruerW.js";import{u as de}from"./global-VOW0aAlU.js";import"./auth-CmUq6Ysp.js";const me={class:"mr-3 text-sm"},ce={class:"mr-3 text-sm"},ue={class:"fixed top-0 left-0 hidden h-full pt-16 pb-4 bg-white w-88 xl:block"},_e={class:"flex items-center justify-between px-4 pt-8 pb-6 border border-gray-200 border-solid"},pe={class:"flex ml-3",role:"group","aria-label":"First group"},fe={class:"px-4 py-1 pb-2 mb-2 text-sm border-b border-gray-200 border-solid"},ye={class:"px-2"},be={class:"px-2"},ge={class:"px-2"},he={class:"h-full pb-32 overflow-y-scroll border-l border-gray-200 border-solid sw-scroll"},Be={class:"flex-2"},ve={class:"mb-1 text-md not-italic font-medium leading-5 text-gray-500 capitalize"},xe={class:"flex-1 whitespace-nowrap right"},ke={class:"text-sm text-right text-gray-500 non-italic"},we={key:0,class:"flex justify-center px-4 mt-5 text-sm text-gray-600"},Ee={class:"flex flex-col min-h-0 mt-8 overflow-hidden",style:{height:"75vh"}},Ve=["src"],Ce={__name:"View",setup(Se){const c=Q(),F=W(),i=ie(),f=de(),I=X(),{tm:$,t:u}=Y.useI18n();let v=z({}),t=z({orderBy:"",orderByField:"",estimate_number:""}),x=Z(!1);ee("utils"),te();const L=h(()=>i.selectedViewEstimate),j=h(()=>t.orderBy==="asc"||t.orderBy==null);h(()=>j.value?$("general.ascending"):$("general.descending"));const C=h(()=>v.unique_hash?`/estimates/pdf/${v.unique_hash}`:!1);ae(c,()=>{D()}),R(),D(),_=se.debounce(_,500);function N(e){return c.params.id==e}async function R(){await i.fetchEstimate({limit:"all"},f.companySlug),setTimeout(()=>{T()},500)}async function D(){if(c&&c.params.id){let e=await i.fetchViewEstimate({id:c.params.id},f.companySlug);e.data&&Object.assign(v,e.data.data)}}function T(){const e=document.getElementById(`estimate-${c.params.id}`);e&&(e.scrollIntoView({behavior:"smooth"}),e.classList.add("shake"))}async function _(){let e={};t.estimate_number!==""&&t.estimate_number!==null&&t.estimate_number!==void 0&&(e.estimate_number=t.estimate_number),t.orderBy!==null&&t.orderBy!==void 0&&(e.orderBy=t.orderBy),t.orderByField!==null&&t.orderByField!==void 0&&(e.orderByField=t.orderByField),x.value=!0;try{let r=await i.searchEstimate(e,f.companySlug);x.value=!1,r.data.data&&(i.estimates=r.data.data)}catch{x.value=!1}}function A(){return t.orderBy==="asc"?(t.orderBy="desc",_(),!0):(t.orderBy="asc",_(),!0)}async function P(){I.openDialog({title:u("general.are_you_sure"),message:u("estimates.confirm_mark_as_accepted",1),yesLabel:u("general.ok"),noLabel:u("general.cancel"),variant:"primary",size:"lg",hideNoButton:!1}).then(async e=>{let r={slug:f.companySlug,id:c.params.id,status:"ACCEPTED"};e&&(i.acceptEstimate(r),F.push({name:"estimates.dashboard"}))})}async function U(){I.openDialog({title:u("general.are_you_sure"),message:u("estimates.confirm_mark_as_rejected",1),yesLabel:u("general.ok"),noLabel:u("general.cancel"),variant:"primary",size:"lg",hideNoButton:!1}).then(async e=>{let r={slug:f.companySlug,id:c.params.id,status:"REJECTED"};e&&(i.rejectEstimate(r),F.push({name:"estimates.dashboard"}))})}return(e,r)=>{const b=d("BaseButton"),G=d("BasePageHeader"),g=d("BaseIcon"),H=d("BaseInput"),k=d("BaseRadio"),w=d("BaseInputGroup"),O=d("BaseEstimateStatusBadge"),q=d("BaseFormatMoney"),J=d("router-link"),M=d("BasePage");return m(),y(M,{class:"xl:pl-96"},{default:o(()=>[a(G,{title:L.value.estimate_number},{actions:o(()=>[l("div",me,[n(i).selectedViewEstimate.status==="DRAFT"?(m(),y(b,{key:0,variant:"primary",onClick:P},{default:o(()=>[E(p(e.$t("estimates.accept_estimate")),1)]),_:1})):B("",!0)]),l("div",ce,[n(i).selectedViewEstimate.status==="DRAFT"?(m(),y(b,{key:0,variant:"primary-outline",onClick:U},{default:o(()=>[E(p(e.$t("estimates.reject_estimate")),1)]),_:1})):B("",!0)])]),_:1},8,["title"]),l("div",ue,[l("div",_e,[a(H,{modelValue:n(t).estimate_number,"onUpdate:modelValue":r[0]||(r[0]=s=>n(t).estimate_number=s),placeholder:e.$t("general.search"),type:"text",variant:"gray",onInput:_},{right:o(()=>[a(g,{name:"SearchIcon",class:"h-5 text-gray-400"})]),_:1},8,["modelValue","placeholder"]),l("div",pe,[a(oe,{position:"bottom-start","width-class":"w-50","position-class":"left-0"},{activator:o(()=>[a(b,{variant:"gray"},{default:o(()=>[a(g,{name:"FilterIcon",class:"h-5"})]),_:1})]),default:o(()=>[l("div",fe,p(e.$t("general.sort_by")),1),l("div",ye,[a(V,{class:"rounded-md pt-3 hover:rounded-md"},{default:o(()=>[a(w,{class:"-mt-3 font-normal"},{default:o(()=>[a(k,{id:"filter_estimate_date",modelValue:n(t).orderByField,"onUpdate:modelValue":r[1]||(r[1]=s=>n(t).orderByField=s),label:e.$t("reports.estimates.estimate_date"),size:"sm",name:"filter",value:"estimate_date",onChange:_},null,8,["modelValue","label"])]),_:1})]),_:1})]),l("div",be,[a(V,{class:"rounded-md pt-3 hover:rounded-md"},{default:o(()=>[a(w,{class:"-mt-3 font-normal"},{default:o(()=>[a(k,{id:"filter_due_date",modelValue:n(t).orderByField,"onUpdate:modelValue":[r[2]||(r[2]=s=>n(t).orderByField=s),_],label:e.$t("estimates.due_date"),value:"expiry_date",size:"sm",name:"filter"},null,8,["modelValue","label"])]),_:1})]),_:1})]),l("div",ge,[a(V,{class:"rounded-md pt-3 hover:rounded-md"},{default:o(()=>[a(w,{class:"-mt-3 font-normal"},{default:o(()=>[a(k,{id:"filter_estimate_number",modelValue:n(t).orderByField,"onUpdate:modelValue":[r[3]||(r[3]=s=>n(t).orderByField=s),_],label:e.$t("estimates.estimate_number"),value:"estimate_number",size:"sm",name:"filter"},null,8,["modelValue","label"])]),_:1})]),_:1})])]),_:1}),a(b,{class:"ml-1",variant:"white",onClick:A},{default:o(()=>[j.value?(m(),y(g,{key:0,name:"SortAscendingIcon",class:"h-5"})):(m(),y(g,{key:1,name:"SortDescendingIcon",class:"h-5"}))]),_:1})])]),l("div",he,[(m(!0),S(ne,null,re(n(i).estimates,(s,K)=>(m(),y(J,{id:"estimate-"+s.id,key:K,to:`/${n(f).companySlug}/customer/estimates/${s.id}/view`,class:le(["flex justify-between p-4 items-center cursor-pointer hover:bg-gray-100 border-l-4 border-transparent",{"bg-gray-100 border-l-4 border-primary-500 border-solid":N(s.id)}]),style:{"border-bottom":"1px solid rgba(185, 193, 209, 0.41)"}},{default:o(()=>[l("div",Be,[l("div",ve,p(s.estimate_number),1),a(O,{status:s.status},{default:o(()=>[E(p(s.status),1)]),_:2},1032,["status"])]),l("div",xe,[a(q,{class:"mb-2 text-xl not-italic font-semibold leading-8 text-right text-gray-900 block",amount:s.total,currency:s.currency},null,8,["amount","currency"]),l("div",ke,p(s.formatted_estimate_date),1)])]),_:2},1032,["id","to","class"]))),128)),n(i).estimates.length?B("",!0):(m(),S("p",we,p(e.$t("estimates.no_matching_estimates")),1))])]),l("div",Ee,[C.value?(m(),S("iframe",{key:0,src:C.value,class:"flex-1 border border-gray-400 border-solid rounded-md"},null,8,Ve)):B("",!0)])]),_:1})}}};export{Ce as default};
|