bettertend/frontend/dist/assets/InventoryTransfersView-8Dop...

2 lines
34 KiB
JavaScript

import{r as p,c as C,o as Et,m as St,i as K,w as i,s as Nt,v as Pt,g as h,b as r,d as u,e as o,j as R,F as k,h as ae,t as x,k as g,a as E,ae as ue,n as _e,aV as de,af as De,aR as Fe,l as At}from"./index-QAlcqU00.js";import{u as _t}from"./parts-imZSnlsl.js";import{T as v,c as O}from"./inventory-C_cwbKdQ.js";import{u as Dt}from"./useFormAutoSave-BrW9Wl2Q.js";import{l as Ft}from"./lodash-RqMXHFU9.js";import{F as Mt,a as Rt}from"./FPPageHeader-CFIwZZgQ.js";import{F as H}from"./FPInput-D5RURom0.js";import{F as W}from"./FPSelect-j7n_x8eB.js";import{F as qt}from"./FPStats-DOY0PQQF.js";import{F as Ot}from"./FPTable-CWvngIYd.js";import{F as ce}from"./FPModal-DMoPysvU.js";import{F as Bt}from"./FPBadge-DvOitM1C.js";import{F as Me}from"./FPTabs-qq-Tmb7J.js";import{_ as Ut}from"./FormRestoreNotification-2Wflg1mH.js";import"./_commonjsHelpers-NT8qMgGI.js";import"./FPCard-AB6NRXg5.js";function zt(){const P=_t(),w=p(!1),b=p(null),f=p(null),y=C(()=>P.inventoryTransfers),D=C(()=>P.transferStats),V=C(()=>y.value.filter(s=>s.status===v.PENDING)),$=C(()=>y.value.filter(s=>[v.PENDING,v.APPROVED,v.SHIPPED].includes(s.status))),Y=C(()=>y.value.filter(s=>s.status===v.COMPLETED)),I=C(()=>y.value.filter(s=>s.status===v.CANCELLED)),U=C(()=>{const s=y.value,l=s.reduce((n,L)=>n+(L.items||[]).reduce((A,_)=>A+(_.requestedQuantity||0)*(_.unitCost||0),0),0),d=N(s);return{totalTransfers:s.length,totalValue:l,averageProcessingTime:d,successRate:ne(s)}}),z=async(s={})=>{w.value=!0,b.value=null;try{await P.fetchInventoryTransfers(s)}catch(l){throw b.value=l.message,l}finally{w.value=!1}},G=async s=>{w.value=!0,b.value=null;try{const l=await P.createInventoryTransfer(s);return f.value=l,l}catch(l){throw b.value=l.message,l}finally{w.value=!1}},j=async(s,l)=>{var d;w.value=!0,b.value=null;try{await P.approveTransfer(s,l),((d=f.value)==null?void 0:d.id)===s&&(f.value.status=v.APPROVED,f.value.approvedBy=l.approvedBy,f.value.approvedAt=new Date().toISOString())}catch(n){throw b.value=n.message,n}finally{w.value=!1}},re=async(s,l)=>{var d;w.value=!0,b.value=null;try{P.shipTransfer&&await P.shipTransfer(s,l);const n=y.value.find(L=>L.id===s);n&&(n.status=v.SHIPPED,n.shippedBy=l.shippedBy,n.shippedAt=new Date().toISOString(),n.trackingNumber=l.trackingNumber),((d=f.value)==null?void 0:d.id)===s&&Object.assign(f.value,{status:v.SHIPPED,shippedBy:l.shippedBy,shippedAt:new Date().toISOString(),trackingNumber:l.trackingNumber})}catch(n){throw b.value=n.message,n}finally{w.value=!1}},se=async(s,l)=>{var d;w.value=!0,b.value=null;try{P.receiveTransfer&&await P.receiveTransfer(s,l);const n=y.value.find(L=>L.id===s);n&&(n.status=v.COMPLETED,n.receivedBy=l.receivedBy,n.receivedAt=new Date().toISOString(),l.items&&l.items.forEach(L=>{var _;const A=(_=n.items)==null?void 0:_.find(Q=>Q.partId===L.partId);A&&(A.receivedQuantity=L.receivedQuantity)})),((d=f.value)==null?void 0:d.id)===s&&(Object.assign(f.value,{status:v.COMPLETED,receivedBy:l.receivedBy,receivedAt:new Date().toISOString()}),l.items&&f.value.items&&l.items.forEach(L=>{const A=f.value.items.find(_=>_.partId===L.partId);A&&(A.receivedQuantity=L.receivedQuantity)}))}catch(n){throw b.value=n.message,n}finally{w.value=!1}},J=async(s,l)=>{var d;w.value=!0,b.value=null;try{P.cancelTransfer&&await P.cancelTransfer(s,l);const n=y.value.find(L=>L.id===s);n&&(n.status=v.CANCELLED,n.cancelledAt=new Date().toISOString(),n.cancellationReason=l),((d=f.value)==null?void 0:d.id)===s&&Object.assign(f.value,{status:v.CANCELLED,cancelledAt:new Date().toISOString(),cancellationReason:l})}catch(n){throw b.value=n.message,n}finally{w.value=!1}},le=s=>{f.value=s},oe=()=>{f.value=null},c=s=>y.value.find(l=>l.id===s),T=s=>{const l=[];return(!s.type||!Object.values(O).includes(s.type))&&l.push("Valid transfer type is required"),s.fromLocation||l.push("From location is required"),s.toLocation||l.push("To location is required"),s.fromLocation===s.toLocation&&l.push("From and to locations must be different"),!s.items||!Array.isArray(s.items)||s.items.length===0?l.push("At least one item is required"):s.items.forEach((d,n)=>{d.partId||l.push(`Item ${n+1}: Part ID is required`),(!d.requestedQuantity||d.requestedQuantity<=0)&&l.push(`Item ${n+1}: Valid requested quantity is required`)}),{isValid:l.length===0,errors:l}},F=s=>{const l=[];return s.approvedBy||l.push("Approver is required"),{isValid:l.length===0,errors:l}},X=s=>{const l=[];return s.shippedBy||l.push("Shipper is required"),{isValid:l.length===0,errors:l}},q=s=>{const l=[];return s.receivedBy||l.push("Receiver is required"),!s.items||!Array.isArray(s.items)||s.items.length===0?l.push("At least one received item is required"):s.items.forEach((d,n)=>{d.partId||l.push(`Item ${n+1}: Part ID is required`),(d.receivedQuantity===void 0||d.receivedQuantity<0)&&l.push(`Item ${n+1}: Valid received quantity is required`)}),{isValid:l.length===0,errors:l}},B=s=>s.items?s.items.reduce((l,d)=>l+(d.requestedQuantity||0)*(d.unitCost||0),0):0,N=s=>{const l=s.filter(n=>n.status===v.COMPLETED&&n.createdAt&&n.receivedAt);if(l.length===0)return 0;const d=l.reduce((n,L)=>{const A=new Date(L.createdAt),_=new Date(L.receivedAt);return n+(_-A)},0);return Math.round(d/l.length/(1e3*60*60*24))},ne=s=>{if(s.length===0)return 100;const l=s.filter(n=>[v.COMPLETED,v.CANCELLED].includes(n.status));if(l.length===0)return 100;const d=l.filter(n=>n.status===v.COMPLETED);return Math.round(d.length/l.length*100)};return{isLoading:w,error:b,selectedTransfer:f,inventoryTransfers:y,transferStats:D,pendingTransfers:V,activeTransfers:$,completedTransfers:Y,cancelledTransfers:I,transferMetrics:U,loadInventoryTransfers:z,createInventoryTransfer:G,approveTransfer:j,shipTransfer:re,receiveTransfer:se,cancelTransfer:J,selectTransfer:le,clearSelectedTransfer:oe,getTransferById:c,validateTransferData:T,validateApproval:F,validateShipment:X,validateReceipt:q,calculateTransferValue:B,getTransferStatusColor:s=>({[v.PENDING]:"orange",[v.APPROVED]:"blue",[v.SHIPPED]:"purple",[v.COMPLETED]:"green",[v.CANCELLED]:"red"})[s]||"gray",canApprove:s=>s.status===v.PENDING,canShip:s=>s.status===v.APPROVED,canReceive:s=>s.status===v.SHIPPED,canCancel:s=>[v.PENDING,v.APPROVED].includes(s.status),bulkApproveTransfers:async(s,l)=>{w.value=!0,b.value=null;try{const d=s.map(n=>j(n,l));await Promise.all(d)}catch(d){throw b.value=d.message,d}finally{w.value=!1}},bulkCancelTransfers:async(s,l)=>{w.value=!0,b.value=null;try{const d=s.map(n=>J(n,l));await Promise.all(d)}catch(d){throw b.value=d.message,d}finally{w.value=!1}},refreshTransfers:async()=>{await z()},clearError:()=>{b.value=null},exportTransferData:()=>({transfers:y.value,metrics:U.value,statistics:D.value,exportedAt:new Date().toISOString()})}}const jt={class:"p-6"},Qt={class:"mb-6 grid grid-cols-1 md:grid-cols-4 gap-4"},Ht={class:"bg-white shadow rounded-lg overflow-hidden"},$t={class:"flex items-center space-x-2"},Gt={class:"font-medium text-gray-900"},Kt={class:"text-sm text-gray-500"},Wt={class:"text-sm"},Yt={class:"font-medium text-gray-900"},Jt={class:"text-gray-500"},Xt={class:"text-sm font-medium text-gray-900"},Zt={class:"text-sm font-medium text-gray-900"},ea={class:"text-sm text-gray-900"},ta={class:"text-sm text-gray-900"},aa={class:"flex items-center space-x-2"},ra={class:"border-b border-gray-200 mb-6"},sa={key:0,class:"space-y-6"},la={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},oa={key:0,class:"mt-1 text-sm text-red-600"},na={key:1,class:"space-y-6"},ia={class:"flex justify-between items-center"},ua={key:0,class:"text-center py-8 text-gray-500"},da={key:1,class:"space-y-4"},ca={class:"flex justify-between items-start mb-4"},va={class:"font-medium text-gray-900"},fa={class:"grid grid-cols-1 md:grid-cols-3 gap-4"},ma={key:2,class:"text-sm text-red-600"},pa={class:"flex items-center justify-between"},ya={class:"flex items-center space-x-4"},ga={key:0,class:"flex items-center text-sm text-gray-500"},Ta={key:0,class:"w-4 h-4 mr-2 text-amber-500 animate-pulse",fill:"currentColor",viewBox:"0 0 20 20"},ha={key:1,class:"w-4 h-4 mr-2 text-green-500",fill:"currentColor",viewBox:"0 0 20 20"},ba={key:2},ka={key:3},xa={class:"flex space-x-3"},Ca={class:"space-y-4"},wa={class:"text-gray-600"},Va={class:"text-gray-900"},La={class:"flex justify-end space-x-3"},Ia={class:"space-y-4"},Ea={class:"text-gray-600"},Sa={class:"text-gray-900"},Na={class:"flex justify-end space-x-3"},Pa={class:"space-y-6"},Aa={class:"text-gray-600"},_a={class:"text-gray-900"},Da={class:"space-y-4"},Fa={class:"grid grid-cols-1 md:grid-cols-3 gap-4"},Ma={class:"text-sm text-gray-900"},Ra={class:"text-sm text-gray-900"},qa={class:"flex justify-end space-x-3"},Oa={class:"space-y-4"},Ba={class:"text-gray-600"},Ua={class:"text-gray-900"},za={key:0,class:"mt-1 text-sm text-red-600"},ja={class:"flex justify-end space-x-3"},or={__name:"InventoryTransfersView",setup(P){const w=Pt(),b=Nt(),f=zt(),{notify:y}=At(),D=p("all"),V=p({search:"",fromLocation:"",toLocation:"",type:""}),$=p(!1),Y=p("create"),I=p(null),U=p(!1),z=p(!1),G=p(!1),j=p(!1),re=p(!1),se=p(!1),J=p(!1),le=p(!1),oe=p(!1),c=p({type:"",transferNumber:"",fromLocation:"",toLocation:"",priority:"",expectedDate:"",notes:"",items:[]}),T=p({}),F=p("details"),X=p({notes:""}),q=p({trackingNumber:"",notes:""}),B=p({items:[],notes:""}),N=p({reason:"",error:""}),{hasUnsavedChanges:ne,lastSaveTime:ie,restoreFormData:he,clearSavedData:fe,hasSavedData:me,getSavedDataInfo:be,markUserInteraction:ke,finishInitialization:xe}=Dt(c,{storageKey:"atlas_inventory_transfer_form_data",saveInterval:3e3,excludeFields:[]}),Z=p(!1),pe=p(null),Ce=C(()=>f.isLoading.value),s=C(()=>f.inventoryTransfers.value),l=C(()=>f.transferStats.value),d=C(()=>f.transferMetrics.value),n=C(()=>f.pendingTransfers.value),L=C(()=>f.activeTransfers.value),A=C(()=>f.completedTransfers.value),_=C(()=>f.cancelledTransfers.value),Q=C(()=>Y.value==="edit"),ye=C(()=>{let t=[...s.value];if(D.value!=="all"&&(D.value==="pending"?t=n.value:D.value==="active"?t=L.value:D.value==="completed"?t=A.value:D.value==="cancelled"&&(t=_.value)),V.value.search){const e=V.value.search.toLowerCase();t=t.filter(a=>{var m,M,ve;return((m=a.transferNumber)==null?void 0:m.toLowerCase().includes(e))||((M=a.fromLocation)==null?void 0:M.toLowerCase().includes(e))||((ve=a.toLocation)==null?void 0:ve.toLowerCase().includes(e))})}return V.value.fromLocation&&(t=t.filter(e=>e.fromLocation===V.value.fromLocation)),V.value.toLocation&&(t=t.filter(e=>e.toLocation===V.value.toLocation)),V.value.type&&(t=t.filter(e=>e.type===V.value.type)),t}),Re=C(()=>{const t=l.value,e=d.value;return[{label:"Total Transfers",value:t.total||0,icon:"clipboard-list",color:"blue"},{label:"Pending",value:t.pending||0,icon:"clock",color:"orange"},{label:"In Transit",value:(t.approved||0)+(t.shipped||0),icon:"truck",color:"purple"},{label:"Total Value",value:Ie(e.totalValue||0),icon:"currency-dollar",color:"green"}]}),qe=C(()=>[{key:"all",label:"All Transfers",count:s.value.length},{key:"pending",label:"Pending",count:n.value.length},{key:"active",label:"Active",count:L.value.length},{key:"completed",label:"Completed",count:A.value.length},{key:"cancelled",label:"Cancelled",count:_.value.length}]),Oe=C(()=>({currentPage:1,totalPages:Math.ceil(ye.value.length/10),totalItems:ye.value.length,pageSize:10})),Be=C(()=>ie.value?new Date(ie.value).toLocaleTimeString():""),ee=[{key:"details",label:"Transfer Details",icon:"info"},{key:"items",label:"Items",icon:"cube"}],Ue=C(()=>ee.findIndex(e=>e.key===F.value)===ee.length-1),ze=[{key:"transferNumber",label:"Transfer #",sortable:!0},{key:"locations",label:"Locations",sortable:!1},{key:"itemsCount",label:"Items",sortable:!1},{key:"totalValue",label:"Value",sortable:!0},{key:"status",label:"Status",sortable:!0},{key:"requestedBy",label:"Requested By",sortable:!0},{key:"createdAt",label:"Created",sortable:!0},{key:"actions",label:"Actions",sortable:!1}],je=[{label:"All Types",value:""},{label:"Inter-Location",value:O.INTER_LOCATION},{label:"Emergency",value:O.EMERGENCY},{label:"Stock Replenishment",value:O.STOCK_REPLENISHMENT}],Qe=[{label:"Inter-Location",value:O.INTER_LOCATION},{label:"Emergency",value:O.EMERGENCY},{label:"Stock Replenishment",value:O.STOCK_REPLENISHMENT}],we=p([{label:"All Locations",value:""},{label:"Warehouse A",value:"warehouse_a"},{label:"Warehouse B",value:"warehouse_b"},{label:"Main Storage",value:"main_storage"},{label:"Service Center",value:"service_center"}]),Ve=p([{label:"Warehouse A",value:"warehouse_a"},{label:"Warehouse B",value:"warehouse_b"},{label:"Main Storage",value:"main_storage"},{label:"Service Center",value:"service_center"}]),He=p([]),{canApprove:$e,canShip:Ge,canReceive:Ke,canCancel:We,calculateTransferValue:Ye}=f,Je=t=>({[O.INTER_LOCATION]:"Inter-Location",[O.EMERGENCY]:"Emergency",[O.STOCK_REPLENISHMENT]:"Stock Replenishment"})[t]||t,Xe=t=>({[v.PENDING]:"Pending",[v.APPROVED]:"Approved",[v.SHIPPED]:"Shipped",[v.COMPLETED]:"Completed",[v.CANCELLED]:"Cancelled"})[t]||t,Le=t=>t||"N/A",Ze=t=>t||"N/A",et=t=>t?new Date(t).toLocaleDateString():"N/A",Ie=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(t||0),tt=t=>({[v.PENDING]:"warning",[v.APPROVED]:"info",[v.SHIPPED]:"purple",[v.COMPLETED]:"success",[v.CANCELLED]:"danger"})[t]||"secondary",at=t=>`Part #${t}`,rt=Ft.debounce(t=>{V.value.search=t},300),ge=()=>{},st=t=>{D.value=t},lt=t=>{console.log("Sort:",t)},ot=t=>{console.log("Page:",t)},nt=t=>{Se(t)},te=async()=>{try{await f.loadInventoryTransfers(),y("Inventory transfers refreshed successfully","success")}catch{y("Failed to refresh inventory transfers","error")}},Ee=()=>{I.value=null,Y.value="create",it(),me()||Pe(),$.value=!0},it=()=>{Y.value==="create"&&me()&&(pe.value=be(),Z.value=!0)},Se=t=>{console.log("View transfer:",t)},Ne=t=>{I.value=t,Y.value="edit",ht(t),xe(),$.value=!0},ut=t=>{I.value=t,X.value.notes="",U.value=!0},dt=t=>{I.value=t,q.value.trackingNumber="",q.value.notes="",z.value=!0},ct=t=>{I.value=t,B.value.items=(t.items||[]).map(e=>({partId:e.partId,requestedQuantity:e.requestedQuantity,receivedQuantity:e.requestedQuantity})),B.value.notes="",G.value=!0},vt=t=>{I.value=t,N.value.reason="",N.value.error="",j.value=!0},Te=()=>{$.value=!1,I.value=null,Z.value=!1},ft=async()=>{re.value=!0;try{if(!bt())return;const t=kt();Q.value?console.log("Update transfer:",t):await f.createInventoryTransfer(t),fe(),Te(),await te(),y(Q.value?"Transfer updated successfully":"Transfer created successfully","success")}catch{y(Q.value?"Failed to update transfer":"Failed to create transfer","error")}finally{re.value=!1}},mt=async()=>{se.value=!0;try{await f.approveTransfer(I.value.id,{approvedBy:"current_user",notes:X.value.notes}),U.value=!1,await te(),y("Transfer approved successfully","success")}catch{y("Failed to approve transfer","error")}finally{se.value=!1}},pt=async()=>{J.value=!0;try{await f.shipTransfer(I.value.id,{shippedBy:"current_user",trackingNumber:q.value.trackingNumber,notes:q.value.notes}),z.value=!1,await te(),y("Transfer shipped successfully","success")}catch{y("Failed to ship transfer","error")}finally{J.value=!1}},yt=async()=>{le.value=!0;try{await f.receiveTransfer(I.value.id,{receivedBy:"current_user",items:B.value.items,notes:B.value.notes}),G.value=!1,await te(),y("Transfer received successfully","success")}catch{y("Failed to receive transfer","error")}finally{le.value=!1}},gt=async()=>{var t;if(!((t=N.value.reason)!=null&&t.trim())){N.value.error="Cancellation reason is required";return}N.value.error="",oe.value=!0;try{await f.cancelTransfer(I.value.id,N.value.reason),j.value=!1,await te(),y("Transfer cancelled successfully","success")}catch{y("Failed to cancel transfer","error")}finally{oe.value=!1}},Tt=()=>{const t=f.exportTransferData();console.log("Export transfers:",t),y("Transfers exported successfully","success")},Pe=()=>{c.value={type:"",transferNumber:"",fromLocation:"",toLocation:"",priority:"",expectedDate:"",notes:"",items:[]},T.value={},F.value="details"},ht=t=>{c.value={type:t.type,transferNumber:t.transferNumber,fromLocation:t.fromLocation,toLocation:t.toLocation,priority:t.priority||"",expectedDate:t.expectedDate||"",notes:t.notes||"",items:[...t.items||[]]},T.value={}},bt=()=>{if(T.value={},c.value.type||(T.value.type="Transfer type is required"),c.value.fromLocation||(T.value.fromLocation="From location is required"),c.value.toLocation||(T.value.toLocation="To location is required"),c.value.fromLocation===c.value.toLocation&&(T.value.toLocation="From and to locations must be different"),!c.value.items||c.value.items.length===0)T.value.items="At least one item is required";else{const t=[];c.value.items.forEach((e,a)=>{e.partId||t.push(`Item ${a+1}: Part is required`),(!e.requestedQuantity||e.requestedQuantity<=0)&&t.push(`Item ${a+1}: Valid quantity is required`)}),t.length>0&&(T.value.items=t.join(", "))}return Object.keys(T.value).length===0},kt=()=>({type:c.value.type,transferNumber:c.value.transferNumber,fromLocation:c.value.fromLocation,toLocation:c.value.toLocation,priority:c.value.priority,expectedDate:c.value.expectedDate,notes:c.value.notes,items:c.value.items.map(t=>({partId:parseInt(t.partId),requestedQuantity:parseInt(t.requestedQuantity),unitCost:parseFloat(t.unitCost)||0}))}),xt=()=>{c.value.items.push({partId:"",requestedQuantity:"",unitCost:""}),S()},Ct=t=>{c.value.items.splice(t,1),S()},wt=t=>{F.value=t,S()},Vt=t=>{S();{const e=ee.findIndex(a=>a.key===F.value);e<ee.length-1&&(F.value=ee[e+1].key)}},Lt=()=>{he(),Z.value=!1},It=()=>{fe(),Z.value=!1,Pe()},S=()=>{ke()},Ae=()=>{const t=b.query.edit,e=b.query.create==="true";t?setTimeout(()=>{const a=s.value.find(m=>m.id===parseInt(t));a&&Ne(a),w.replace({path:"/inventory/transfers"})},500):e&&setTimeout(()=>{Ee(),w.replace({path:"/inventory/transfers"})},500)};return Et(async()=>{await f.loadInventoryTransfers(),Ae()}),St(()=>b.query,Ae),(t,e)=>(h(),K(Mt,null,{header:i(()=>[u(Rt,{title:"Inventory Transfers",description:"Manage inventory transfers between locations and track their status",breadcrumbs:[{text:"Inventory",to:"/inventory"},{text:"Transfers",to:null}]},{actions:i(()=>[u(o(k),{variant:"outline",size:"sm",onClick:Tt},{default:i(()=>e[28]||(e[28]=[r("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})],-1),g(" Export ",-1)])),_:1,__:[28]}),u(o(k),{variant:"outline",size:"sm",onClick:te},{default:i(()=>e[29]||(e[29]=[r("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})],-1),g(" Refresh ",-1)])),_:1,__:[29]}),u(o(k),{variant:"primary",size:"sm",onClick:Ee},{default:i(()=>e[30]||(e[30]=[r("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),g(" Create Transfer ",-1)])),_:1,__:[30]})]),stats:i(()=>[u(o(qt),{stats:Re.value},null,8,["stats"])]),tabs:i(()=>[u(o(Me),{modelValue:D.value,"onUpdate:modelValue":e[0]||(e[0]=a=>D.value=a),tabs:qe.value,onTabChange:st},null,8,["modelValue","tabs"])]),_:1})]),default:i(()=>[r("div",jt,[r("div",Qt,[u(o(H),{modelValue:V.value.search,"onUpdate:modelValue":e[1]||(e[1]=a=>V.value.search=a),placeholder:"Search transfers...",onInput:o(rt)},{prepend:i(()=>e[31]||(e[31]=[r("svg",{class:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})],-1)])),_:1},8,["modelValue","onInput"]),u(o(W),{modelValue:V.value.fromLocation,"onUpdate:modelValue":[e[2]||(e[2]=a=>V.value.fromLocation=a),ge],placeholder:"Filter by From Location",options:we.value},null,8,["modelValue","options"]),u(o(W),{modelValue:V.value.toLocation,"onUpdate:modelValue":[e[3]||(e[3]=a=>V.value.toLocation=a),ge],placeholder:"Filter by To Location",options:we.value},null,8,["modelValue","options"]),u(o(W),{modelValue:V.value.type,"onUpdate:modelValue":[e[4]||(e[4]=a=>V.value.type=a),ge],placeholder:"Filter by Transfer Type",options:je},null,8,["modelValue"])]),r("div",Ht,[u(o(Ot),{columns:ze,data:ye.value,loading:Ce.value,pagination:Oe.value,"empty-message":"No inventory transfers found",onSortChange:lt,onPageChange:ot,onRowClick:nt},{"column-transferNumber":i(({row:a})=>[r("div",$t,[e[32]||(e[32]=r("div",{class:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center"},[r("svg",{class:"w-4 h-4 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})])],-1)),r("div",null,[r("h4",Gt,x(a.transferNumber),1),r("p",Kt,x(Je(a.type)),1)])])]),"column-locations":i(({row:a})=>[r("div",Wt,[r("div",Yt,"From: "+x(Le(a.fromLocation)),1),r("div",Jt,"To: "+x(Le(a.toLocation)),1)])]),"column-itemsCount":i(({row:a})=>[r("div",Xt,x((a.items||[]).length)+" item"+x((a.items||[]).length!==1?"s":""),1)]),"column-totalValue":i(({row:a})=>[r("div",Zt,x(Ie(o(Ye)(a))),1)]),"column-status":i(({row:a})=>[u(o(Bt),{variant:tt(a.status),size:"sm"},{default:i(()=>[g(x(Xe(a.status)),1)]),_:2},1032,["variant"])]),"column-requestedBy":i(({row:a})=>[r("div",ea,x(Ze(a.requestedBy)),1)]),"column-createdAt":i(({row:a})=>[r("div",ta,x(et(a.createdAt)),1)]),"column-actions":i(({row:a})=>[r("div",aa,[u(o(k),{variant:"ghost",size:"xs",onClick:ae(m=>Se(a),["stop"]),title:"View Details"},{default:i(()=>e[33]||(e[33]=[r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})],-1)])),_:2,__:[33]},1032,["onClick"]),o($e)(a)?(h(),K(o(k),{key:0,variant:"ghost",size:"xs",onClick:ae(m=>ut(a),["stop"]),title:"Approve Transfer",class:"text-green-600 hover:text-green-700"},{default:i(()=>e[34]||(e[34]=[r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)])),_:2,__:[34]},1032,["onClick"])):R("",!0),o(Ge)(a)?(h(),K(o(k),{key:1,variant:"ghost",size:"xs",onClick:ae(m=>dt(a),["stop"]),title:"Ship Transfer",class:"text-blue-600 hover:text-blue-700"},{default:i(()=>e[35]||(e[35]=[r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})],-1)])),_:2,__:[35]},1032,["onClick"])):R("",!0),o(Ke)(a)?(h(),K(o(k),{key:2,variant:"ghost",size:"xs",onClick:ae(m=>ct(a),["stop"]),title:"Receive Transfer",class:"text-purple-600 hover:text-purple-700"},{default:i(()=>e[36]||(e[36]=[r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})],-1)])),_:2,__:[36]},1032,["onClick"])):R("",!0),o(We)(a)?(h(),K(o(k),{key:3,variant:"ghost",size:"xs",onClick:ae(m=>vt(a),["stop"]),title:"Cancel Transfer",class:"text-red-600 hover:text-red-700"},{default:i(()=>e[37]||(e[37]=[r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])),_:2,__:[37]},1032,["onClick"])):R("",!0),u(o(k),{variant:"ghost",size:"xs",onClick:ae(m=>Ne(a),["stop"]),title:"Edit Transfer"},{default:i(()=>e[38]||(e[38]=[r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)])),_:2,__:[38]},1032,["onClick"])])]),_:1},8,["data","loading","pagination"])]),u(o(ce),{modelValue:$.value,"onUpdate:modelValue":e[14]||(e[14]=a=>$.value=a),title:Q.value?"Edit Inventory Transfer":"Create Inventory Transfer",size:"xl",onCancel:Te},{footer:i(()=>[r("div",pa,[r("div",ya,[o(ne)||o(ie)?(h(),E("div",ga,[o(ne)?(h(),E("svg",Ta,e[43]||(e[43]=[r("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z","clip-rule":"evenodd"},null,-1)]))):(h(),E("svg",ha,e[44]||(e[44]=[r("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z","clip-rule":"evenodd"},null,-1)]))),o(ne)?(h(),E("span",ba,"Auto-saving...")):o(ie)?(h(),E("span",ka,"Last saved "+x(Be.value),1)):R("",!0)])):R("",!0)]),r("div",xa,[u(o(k),{variant:"secondary",onClick:Te},{default:i(()=>e[45]||(e[45]=[g(" Cancel ",-1)])),_:1,__:[45]}),Ue.value?(h(),K(o(k),{key:1,variant:"primary",loading:re.value,onClick:ft},{default:i(()=>[g(x(Q.value?"Update Transfer":"Create Transfer"),1)]),_:1},8,["loading"])):(h(),K(o(k),{key:0,variant:"primary",onClick:e[13]||(e[13]=a=>Vt("next"))},{default:i(()=>e[46]||(e[46]=[g(" Next ",-1)])),_:1,__:[46]}))])])]),default:i(()=>[u(o(Ut),{visible:Z.value,"saved-data-info":pe.value,onRestore:Lt,onDismiss:It},null,8,["visible","saved-data-info"]),r("div",ra,[u(o(Me),{modelValue:F.value,"onUpdate:modelValue":e[5]||(e[5]=a=>F.value=a),tabs:ee,onTabChange:wt},null,8,["modelValue"])]),F.value==="details"?(h(),E("div",sa,[r("div",la,[u(o(W),{modelValue:c.value.type,"onUpdate:modelValue":e[6]||(e[6]=a=>c.value.type=a),label:"Transfer Type",placeholder:"Select transfer type",options:Qe,required:"",error:T.value.type,onChange:S},null,8,["modelValue","error"]),u(o(H),{modelValue:c.value.transferNumber,"onUpdate:modelValue":e[7]||(e[7]=a=>c.value.transferNumber=a),label:"Transfer Number",placeholder:"Auto-generated",error:T.value.transferNumber,disabled:Q.value,onInput:S},null,8,["modelValue","error","disabled"]),u(o(W),{modelValue:c.value.fromLocation,"onUpdate:modelValue":e[8]||(e[8]=a=>c.value.fromLocation=a),label:"From Location",placeholder:"Select source location",options:Ve.value,required:"",error:T.value.fromLocation,onChange:S},null,8,["modelValue","options","error"]),u(o(W),{modelValue:c.value.toLocation,"onUpdate:modelValue":e[9]||(e[9]=a=>c.value.toLocation=a),label:"To Location",placeholder:"Select destination location",options:Ve.value,required:"",error:T.value.toLocation,onChange:S},null,8,["modelValue","options","error"]),u(o(H),{modelValue:c.value.priority,"onUpdate:modelValue":e[10]||(e[10]=a=>c.value.priority=a),label:"Priority",placeholder:"Select priority",error:T.value.priority,onInput:S},null,8,["modelValue","error"]),u(o(H),{modelValue:c.value.expectedDate,"onUpdate:modelValue":e[11]||(e[11]=a=>c.value.expectedDate=a),label:"Expected Date",type:"date",error:T.value.expectedDate,onInput:S},null,8,["modelValue","error"])]),r("div",null,[e[39]||(e[39]=r("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Notes",-1)),ue(r("textarea",{"onUpdate:modelValue":e[12]||(e[12]=a=>c.value.notes=a),class:_e(["w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500",{"border-red-300":T.value.notes}]),placeholder:"Additional notes or instructions...",rows:"3",onInput:S},null,34),[[de,c.value.notes]]),T.value.notes?(h(),E("p",oa,x(T.value.notes),1)):R("",!0)])])):R("",!0),F.value==="items"?(h(),E("div",na,[r("div",ia,[e[41]||(e[41]=r("h3",{class:"text-lg font-medium text-gray-900"},"Transfer Items",-1)),u(o(k),{variant:"outline",size:"sm",onClick:xt},{default:i(()=>e[40]||(e[40]=[r("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),g(" Add Item ",-1)])),_:1,__:[40]})]),c.value.items.length===0?(h(),E("div",ua,' No items added yet. Click "Add Item" to start. ')):(h(),E("div",da,[(h(!0),E(De,null,Fe(c.value.items,(a,m)=>(h(),E("div",{key:m,class:"border border-gray-200 rounded-lg p-4"},[r("div",ca,[r("h4",va,"Item "+x(m+1),1),u(o(k),{variant:"ghost",size:"xs",onClick:M=>Ct(m),class:"text-red-600 hover:text-red-700"},{default:i(()=>e[42]||(e[42]=[r("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])),_:2,__:[42]},1032,["onClick"])]),r("div",fa,[u(o(W),{modelValue:a.partId,"onUpdate:modelValue":M=>a.partId=M,label:"Part",placeholder:"Select part",options:He.value,required:"",onChange:S},null,8,["modelValue","onUpdate:modelValue","options"]),u(o(H),{modelValue:a.requestedQuantity,"onUpdate:modelValue":M=>a.requestedQuantity=M,label:"Requested Quantity",placeholder:"0",type:"number",required:"",onInput:S},null,8,["modelValue","onUpdate:modelValue"]),u(o(H),{modelValue:a.unitCost,"onUpdate:modelValue":M=>a.unitCost=M,label:"Unit Cost",placeholder:"0.00",type:"number",step:"0.01",onInput:S},null,8,["modelValue","onUpdate:modelValue"])])]))),128))])),T.value.items?(h(),E("p",ma,x(T.value.items),1)):R("",!0)])):R("",!0)]),_:1},8,["modelValue","title"]),u(o(ce),{modelValue:U.value,"onUpdate:modelValue":e[17]||(e[17]=a=>U.value=a),title:"Approve Transfer",size:"md"},{footer:i(()=>[r("div",La,[u(o(k),{variant:"secondary",onClick:e[16]||(e[16]=a=>U.value=!1)},{default:i(()=>e[50]||(e[50]=[g(" Cancel ",-1)])),_:1,__:[50]}),u(o(k),{variant:"primary",loading:se.value,onClick:mt},{default:i(()=>e[51]||(e[51]=[g(" Approve Transfer ",-1)])),_:1,__:[51]},8,["loading"])])]),default:i(()=>{var a;return[r("div",Ca,[r("p",wa,[e[47]||(e[47]=g(" Approve transfer ",-1)),r("strong",Va,"'"+x((a=I.value)==null?void 0:a.transferNumber)+"'",1),e[48]||(e[48]=g("? ",-1))]),r("div",null,[e[49]||(e[49]=r("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Approval Notes (Optional)",-1)),ue(r("textarea",{"onUpdate:modelValue":e[15]||(e[15]=m=>X.value.notes=m),class:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500",placeholder:"Add any approval notes...",rows:"3"},null,512),[[de,X.value.notes]])])])]}),_:1},8,["modelValue"]),u(o(ce),{modelValue:z.value,"onUpdate:modelValue":e[21]||(e[21]=a=>z.value=a),title:"Ship Transfer",size:"md"},{footer:i(()=>[r("div",Na,[u(o(k),{variant:"secondary",onClick:e[20]||(e[20]=a=>z.value=!1)},{default:i(()=>e[55]||(e[55]=[g(" Cancel ",-1)])),_:1,__:[55]}),u(o(k),{variant:"primary",loading:J.value,onClick:pt},{default:i(()=>e[56]||(e[56]=[g(" Ship Transfer ",-1)])),_:1,__:[56]},8,["loading"])])]),default:i(()=>{var a;return[r("div",Ia,[r("p",Ea,[e[52]||(e[52]=g(" Ship transfer ",-1)),r("strong",Sa,"'"+x((a=I.value)==null?void 0:a.transferNumber)+"'",1),e[53]||(e[53]=g(". ",-1))]),r("div",null,[u(o(H),{modelValue:q.value.trackingNumber,"onUpdate:modelValue":e[18]||(e[18]=m=>q.value.trackingNumber=m),label:"Tracking Number (Optional)",placeholder:"Enter tracking number"},null,8,["modelValue"])]),r("div",null,[e[54]||(e[54]=r("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Shipment Notes (Optional)",-1)),ue(r("textarea",{"onUpdate:modelValue":e[19]||(e[19]=m=>q.value.notes=m),class:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500",placeholder:"Add any shipment notes...",rows:"3"},null,512),[[de,q.value.notes]])])])]}),_:1},8,["modelValue"]),u(o(ce),{modelValue:G.value,"onUpdate:modelValue":e[24]||(e[24]=a=>G.value=a),title:"Receive Transfer",size:"lg"},{footer:i(()=>[r("div",qa,[u(o(k),{variant:"secondary",onClick:e[23]||(e[23]=a=>G.value=!1)},{default:i(()=>e[63]||(e[63]=[g(" Cancel ",-1)])),_:1,__:[63]}),u(o(k),{variant:"primary",loading:le.value,onClick:yt},{default:i(()=>e[64]||(e[64]=[g(" Receive Transfer ",-1)])),_:1,__:[64]},8,["loading"])])]),default:i(()=>{var a;return[r("div",Pa,[r("p",Aa,[e[57]||(e[57]=g(" Receive transfer ",-1)),r("strong",_a,"'"+x((a=I.value)==null?void 0:a.transferNumber)+"'",1),e[58]||(e[58]=g(". ",-1))]),r("div",Da,[e[61]||(e[61]=r("h4",{class:"font-medium text-gray-900"},"Received Items",-1)),(h(!0),E(De,null,Fe(B.value.items,(m,M)=>(h(),E("div",{key:M,class:"border border-gray-200 rounded-lg p-4"},[r("div",Fa,[r("div",null,[e[59]||(e[59]=r("label",{class:"block text-sm font-medium text-gray-700"},"Part",-1)),r("p",Ma,x(at(m.partId)),1)]),r("div",null,[e[60]||(e[60]=r("label",{class:"block text-sm font-medium text-gray-700"},"Requested",-1)),r("p",Ra,x(m.requestedQuantity),1)]),u(o(H),{modelValue:m.receivedQuantity,"onUpdate:modelValue":ve=>m.receivedQuantity=ve,label:"Received Quantity",placeholder:"0",type:"number",required:""},null,8,["modelValue","onUpdate:modelValue"])])]))),128))]),r("div",null,[e[62]||(e[62]=r("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Receipt Notes (Optional)",-1)),ue(r("textarea",{"onUpdate:modelValue":e[22]||(e[22]=m=>B.value.notes=m),class:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500",placeholder:"Add any receipt notes...",rows:"3"},null,512),[[de,B.value.notes]])])])]}),_:1},8,["modelValue"]),u(o(ce),{modelValue:j.value,"onUpdate:modelValue":e[27]||(e[27]=a=>j.value=a),title:"Cancel Transfer",size:"md"},{footer:i(()=>[r("div",ja,[u(o(k),{variant:"secondary",onClick:e[26]||(e[26]=a=>j.value=!1)},{default:i(()=>e[68]||(e[68]=[g(" Keep Transfer ",-1)])),_:1,__:[68]}),u(o(k),{variant:"danger",loading:oe.value,onClick:gt},{default:i(()=>e[69]||(e[69]=[g(" Cancel Transfer ",-1)])),_:1,__:[69]},8,["loading"])])]),default:i(()=>{var a;return[r("div",Oa,[r("p",Ba,[e[65]||(e[65]=g(" Are you sure you want to cancel transfer ",-1)),r("strong",Ua,"'"+x((a=I.value)==null?void 0:a.transferNumber)+"'",1),e[66]||(e[66]=g("? ",-1))]),r("div",null,[e[67]||(e[67]=r("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Cancellation Reason (Required)",-1)),ue(r("textarea",{"onUpdate:modelValue":e[25]||(e[25]=m=>N.value.reason=m),class:_e(["w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500",{"border-red-300":N.value.error}]),placeholder:"Explain why this transfer is being cancelled...",rows:"3",required:""},null,2),[[de,N.value.reason]]),N.value.error?(h(),E("p",za,x(N.value.error),1)):R("",!0)])])]}),_:1},8,["modelValue"])])]),_:1}))}};export{or as default};