"use strict";(globalThis["webpackChunkbaggisowtfaresystem"]=globalThis["webpackChunkbaggisowtfaresystem"]||[]).push([[755],{2755:(e,r,t)=>{t.r(r),t.d(r,{default:()=>A});var a=t(1347),n=t(4187),o=t(7763),l=t(455),s=t(3022),i=t(8557),c=t(588);const u={key:0,class:"draft-card q-pa-lg rounded-borders shadow-2 bg-white"},d={class:"q-mt-sm"},y={key:0},g={key:1,class:"text-grey-7"},m={class:"row q-gutter-lg q-mt-xl"},v={key:1,class:"text-negative text-subtitle1 q-mt-xl"},p={__name:"OrderGateway",setup(e){const{canRead:r,canWrite:t,canUpdate:p}=(0,c.J)(),k=r("order"),f=t("order"),h=p("order"),b=(0,l.rd)(),w=(0,s.A)(),A=(0,i.Bm)(),O=((0,a.EW)(()=>{try{return localStorage.getItem(A.getLastTxnKey)}catch{return null}}),(0,a.EW)(()=>{try{return localStorage.getItem(A.getDraftKey)}catch{return null}})),S=(0,a.EW)(()=>{if(!O.value)return!1;try{const e=JSON.parse(O.value);return"new"===e?.mode}catch{return!1}}),x=(0,a.EW)(()=>{if(!S.value)return null;try{return JSON.parse(O.value)?.header?.OrderNumber||null}catch{return null}});function N(){if(!f.value)return void w.notify({type:"negative",message:"Taslak güncelleme yetkiniz yok"});let e=A.getActiveNewHeaderId?.();if(!e)try{const r=localStorage.getItem(A.getDraftKey),t=r?JSON.parse(r):null;e=t?.header?.OrderHeaderID||null}catch{}if(!e)return void w.notify({type:"warning",message:"Devam edecek taslak bulunamadı"});const r={name:"order-entry",params:{orderHeaderID:String(e)},query:{mode:"new",source:"draft"}};console.log("➡️ continueDraft resolve:",b.resolve(r)),b.push(r).catch(r=>{console.warn("❌ continueDraft push failed, fallback to path:",r),b.push({path:`/app/order-entry/${encodeURIComponent(String(e))}`,query:{mode:"new",source:"draft"}})})}function E(){b.push({name:"order-list"})}function I(){b.push({name:"order-bulk-close"})}function q(){try{localStorage.removeItem(A.getDraftKey),A.getLastTxnKey&&localStorage.removeItem(A.getLastTxnKey)}catch{}}function D(){f.value?S.value?w.dialog({title:"Yeni Sipariş",message:"Önceki NEW taslak silinecek. Onaylıyor musun?",ok:{label:"Evet",color:"negative"},cancel:{flat:!0,label:"Hayır"},persistent:!0}).onOk(()=>{q(),R()}):R():w.notify({type:"negative",message:"Yeni sipariş yetkiniz yok"})}async function R(){try{A.preventPersist=!0,A.resetForNewOrder(),A.preventPersist=!1;const e=await A.startNewOrder({$q:w}),r=e?.OrderHeaderID;if(!r)return console.error("❌ startNewOrder OrderHeaderID üretmedi:",e),void w.notify({type:"negative",message:"OrderHeaderID üretilemedi!"});const t={name:"order-entry",params:{orderHeaderID:String(r)},query:{mode:"new",source:"new"}};console.log("➡️ goNewOrder resolve:",b.resolve(t)),await b.push(t).catch(async e=>{console.warn("❌ router.push failed, fallback to path:",e),await b.push({path:`/app/order-entry/${encodeURIComponent(String(r))}`,query:{mode:"new",source:"new"}})})}catch(e){console.error("❌ goNewOrder hata:",e),w.notify({type:"negative",message:"Yeni sipariş oluşturulamadı!"})}}return(e,r)=>{const t=(0,a.g2)("q-btn"),l=(0,a.g2)("q-page");return(0,n.R1)(k)?((0,a.uX)(),(0,a.Wv)(l,{key:0,class:"order-gateway flex flex-center column"},{default:(0,a.k6)(()=>[r[2]||(r[2]=(0,a.Lk)("div",{class:"text-h5 text-primary q-mb-xl"}," 🧾 Sipariş Modülü ",-1)),S.value&&(0,n.R1)(f)?((0,a.uX)(),(0,a.CE)("div",u,[r[1]||(r[1]=(0,a.Lk)("div",{class:"text-subtitle1 text-bold text-negative"}," 📌 Devam Eden Taslak Bulundu ",-1)),(0,a.Lk)("div",d,[x.value?((0,a.uX)(),(0,a.CE)("div",y,[r[0]||(r[0]=(0,a.Lk)("b",null,"No:",-1)),(0,a.eW)(" "+(0,o.v_)(x.value),1)])):((0,a.uX)(),(0,a.CE)("div",g," Numara alınamadı "))]),(0,a.bF)(t,{class:"q-mt-md",color:"primary",icon:"login",label:"TASLAĞA DEVAM ET",disable:!(0,n.R1)(f),onClick:N},null,8,["disable"])])):(0,a.Q3)("",!0),(0,a.Lk)("div",m,[(0,n.R1)(f)?((0,a.uX)(),(0,a.Wv)(t,{key:0,color:"primary",icon:"add_circle",label:"YENİ SİPARİŞ OLUŞTUR",onClick:D})):(0,a.Q3)("",!0),(0,n.R1)(k)?((0,a.uX)(),(0,a.Wv)(t,{key:1,color:"secondary",icon:"folder_open",label:"MEVCUT SİPARİŞİ AÇ",onClick:E})):(0,a.Q3)("",!0),(0,n.R1)(h)?((0,a.uX)(),(0,a.Wv)(t,{key:2,color:"negative",icon:"task_alt",label:"TAMAMLANANLARI TOPLU KAPAT",onClick:I})):(0,a.Q3)("",!0)]),(0,n.R1)(k)?(0,a.Q3)("",!0):((0,a.uX)(),(0,a.CE)("div",v," Bu modüle erişim yetkiniz yok. "))]),_:1})):(0,a.Q3)("",!0)}}};var k=t(5013),f=t(2677),h=t(272),b=t.n(h);const w=p,A=w;b()(p,"components",{QPage:k.A,QBtn:f.A})}}]);