2 lines
26 KiB
JavaScript
2 lines
26 KiB
JavaScript
import{r as k,c as p,o as at,m as ot,i as oe,w as n,s as rt,v as st,g as V,b as r,d,e as s,j as N,F as x,h as Y,t as w,k as b,n as re,a as P,ae as se,aU as ne,l as nt}from"./index-BUdRbiwj.js";import{u as it}from"./parts-B3aeW8xP.js";import{A as ut,a as y,b as S}from"./inventory-C_cwbKdQ.js";import{u as ct}from"./useFormAutoSave-Jaawgo91.js";import{l as dt}from"./lodash-RqMXHFU9.js";import{F as vt,a as mt}from"./FPPageHeader-CTG2L28r.js";import{F as J}from"./FPInput-CzR_dWoe.js";import{F as H}from"./FPSelect-C7p47Ma2.js";import{F as ft}from"./FPStats-BGfZcDZc.js";import{F as yt}from"./FPTable-CU8C_NYc.js";import{F as ie}from"./FPModal-DWGF1LV8.js";import{F as be}from"./FPBadge-BKY5dPnL.js";import{F as pt}from"./FPTabs-R71V25QN.js";import{_ as kt}from"./FormRestoreNotification-DYBlXhOP.js";import"./_commonjsHelpers-NT8qMgGI.js";import"./FPCard-qHzcEQAE.js";function gt(){const m=it(),u=k(!1),i=k(null),h=p(()=>m.stockAlerts),C=p(()=>m.stockAdjustments),O=p(()=>m.reorderPointConfigs),f=p(()=>h.value.filter(l=>l.severity==="critical")),R=p(()=>h.value.filter(l=>!l.resolved)),F=p(()=>C.value.reduce((l,o)=>{const v=(o.quantityChange||0)*(o.unitCost||0);return l+v},0)),T=p(()=>m.parts.filter(l=>(l.currentStock||0)<(l.minimumStock||0))),L=p(()=>m.parts.filter(l=>(l.currentStock||0)<=(l.reorderPoint||0)&&l.reorderPoint>0)),M=p(()=>{const l=m.parts.length;if(l===0)return 100;const o=m.parts.filter(v=>(v.currentStock||0)>=(v.minimumStock||0)).length;return Math.round(o/l*100)}),U=p(()=>{const l=h.value,o={total:l.length,bySeverity:{critical:0,high:0,medium:0,low:0},byType:{}};return l.forEach(v=>{o.bySeverity[v.severity]!==void 0&&o.bySeverity[v.severity]++;const _=v.alertType;o.byType[_]=(o.byType[_]||0)+1}),o});return{isLoading:u,error:i,stockAlerts:h,stockAdjustments:C,reorderPointConfigs:O,criticalAlerts:f,unresolvedAlerts:R,totalAdjustmentsValue:F,lowStockParts:T,partsNeedingReorder:L,inventoryHealthScore:M,alertStatistics:U,loadStockAlerts:async(l={})=>{u.value=!0,i.value=null;try{await m.fetchStockAlerts(l)}catch(o){throw i.value=o.message,o}finally{u.value=!1}},createStockAlert:async l=>{u.value=!0,i.value=null;try{return await m.createStockAlert(l)}catch(o){throw i.value=o.message,o}finally{u.value=!1}},acknowledgeAlert:async(l,o)=>{u.value=!0,i.value=null;try{await m.acknowledgeAlert(l,o)}catch(v){throw i.value=v.message,v}finally{u.value=!1}},resolveAlert:async(l,o)=>{u.value=!0,i.value=null;try{await m.resolveAlert(l,o)}catch(v){throw i.value=v.message,v}finally{u.value=!1}},loadStockAdjustments:async(l={})=>{u.value=!0,i.value=null;try{await m.fetchStockAdjustments(l)}catch(o){throw i.value=o.message,o}finally{u.value=!1}},createStockAdjustment:async l=>{u.value=!0,i.value=null;try{return await m.createStockAdjustment(l)}catch(o){throw i.value=o.message,o}finally{u.value=!1}},getAdjustmentHistory:async l=>{u.value=!0,i.value=null;try{return await m.getAdjustmentHistory(l)}catch(o){throw i.value=o.message,o}finally{u.value=!1}},loadReorderPointConfigs:async(l={})=>{u.value=!0,i.value=null;try{await m.fetchReorderPointConfigs(l)}catch(o){throw i.value=o.message,o}finally{u.value=!1}},createReorderPointConfig:async l=>{u.value=!0,i.value=null;try{return await m.createReorderPointConfig(l)}catch(o){throw i.value=o.message,o}finally{u.value=!1}},updateReorderPointConfig:async(l,o)=>{u.value=!0,i.value=null;try{await m.updateReorderPointConfig(l,o)}catch(v){throw i.value=v.message,v}finally{u.value=!1}},getStockLevelsByLocation:async l=>{u.value=!0,i.value=null;try{return await m.getStockLevelsByLocation(l)}catch(o){throw i.value=o.message,o}finally{u.value=!1}},updateStockLevel:async(l,o,v)=>{u.value=!0,i.value=null;try{await m.updateStockLevel(l,o,v)}catch(_){throw i.value=_.message,_}finally{u.value=!1}},getInventoryAnalytics:async()=>{u.value=!0,i.value=null;try{return await m.getInventoryAnalytics()}catch(l){throw i.value=l.message,l}finally{u.value=!1}},calculateReorderPoint:(l,o,v)=>l*o+v,calculateEOQ:(l,o,v)=>{const _=Math.sqrt(2*l*o/v);return Math.ceil(_)},calculateSafetyStock:(l,o)=>{const _={.9:1.28,.95:1.64,.99:2.33}[o]||1.64;return Math.ceil(_*l)},getAlertSeverity:(l,o,v)=>l<=0?S.CRITICAL:l<=v?S.HIGH:l<=o?S.MEDIUM:S.LOW,validateStockAlert:l=>{const o=[];return l.partId||o.push("Part ID is required"),(!l.alertType||!Object.values(y).includes(l.alertType))&&o.push("Valid alert type is required"),(!l.severity||!Object.values(S).includes(l.severity))&&o.push("Valid severity is required"),(l.currentStock===void 0||l.currentStock===null)&&o.push("Current stock is required"),(l.minimumStock===void 0||l.minimumStock===null)&&o.push("Minimum stock is required"),{isValid:o.length===0,errors:o}},validateStockAdjustment:l=>{const o=[];return l.partId||o.push("Part ID is required"),l.location||o.push("Location is required"),(l.previousQuantity===void 0||l.previousQuantity===null)&&o.push("Previous quantity is required"),(l.adjustedQuantity===void 0||l.adjustedQuantity===null)&&o.push("Adjusted quantity is required"),(!l.reason||!Object.values(ut).includes(l.reason))&&o.push("Valid reason is required"),{isValid:o.length===0,errors:o}},refreshAllData:async()=>{u.value=!0,i.value=null;try{await Promise.all([m.fetchStockAlerts(),m.fetchStockAdjustments(),m.fetchReorderPointConfigs()])}catch(l){throw i.value=l.message,l}finally{u.value=!1}},clearError:()=>{i.value=null},exportStockData:()=>({alerts:h.value,adjustments:C.value,reorderConfigs:O.value,analytics:{totalAdjustmentsValue:F.value,alertStatistics:U.value,inventoryHealthScore:M.value,lowStockPartsCount:T.value.length,partsNeedingReorderCount:L.value.length},exportedAt:new Date().toISOString()})}}const ht={class:"p-6"},St={class:"mb-6 grid grid-cols-1 md:grid-cols-4 gap-4"},At={class:"bg-white shadow rounded-lg overflow-hidden"},wt={class:"flex items-center space-x-2"},bt={class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ct=["d"],xt={class:"font-medium text-gray-900"},Tt={class:"font-medium text-gray-900"},It={class:"text-sm text-gray-500"},_t={class:"text-sm"},Vt={class:"font-medium text-gray-900"},Ot={class:"text-gray-500"},Lt={class:"text-sm text-gray-900"},Mt={class:"text-sm text-gray-900"},Pt={class:"flex items-center space-x-2"},Rt={class:"space-y-6"},Ft={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},Et={key:0,class:"mt-1 text-sm text-red-600"},Ut={class:"flex items-center justify-between"},zt={class:"flex items-center space-x-4"},jt={key:0,class:"flex items-center text-sm text-gray-500"},qt={key:0,class:"w-4 h-4 mr-2 text-amber-500 animate-pulse",fill:"currentColor",viewBox:"0 0 20 20"},Nt={key:1,class:"w-4 h-4 mr-2 text-green-500",fill:"currentColor",viewBox:"0 0 20 20"},Ht={key:2},Bt={key:3},Dt={class:"flex space-x-3"},Kt={class:"space-y-4"},Wt={class:"text-gray-600"},Gt={class:"text-gray-900"},Qt={class:"flex justify-end space-x-3"},$t={class:"space-y-4"},Xt={class:"text-gray-600"},Yt={class:"text-gray-900"},Jt={key:0,class:"mt-1 text-sm text-red-600"},Zt={class:"flex justify-end space-x-3"},pl={__name:"StockAlertsView",setup(m){const u=st(),i=rt(),h=gt(),{notify:C}=nt(),O=k("all"),f=k({search:"",alertType:"",location:"",status:""}),R=k(!1),F=k("create"),T=k(null),L=k(!1),M=k(!1),U=k(!1),K=k(!1),W=k(!1),c=k({partId:"",alertType:"",severity:"",location:"",currentStock:"",minimumStock:"",notes:""}),g=k({}),B=k({notes:""}),I=k({resolution:"",error:""}),{hasUnsavedChanges:G,lastSaveTime:D,restoreFormData:ue,clearSavedData:Z,hasSavedData:ee,getSavedDataInfo:ce,markUserInteraction:de,finishInitialization:ve}=ct(c,{storageKey:"atlas_stock_alert_form_data",saveInterval:3e3,excludeFields:[]}),z=k(!1),te=k(null),me=p(()=>h.isLoading.value),Q=p(()=>h.stockAlerts.value);p(()=>h.criticalAlerts.value);const fe=p(()=>h.unresolvedAlerts.value),j=p(()=>h.alertStatistics.value),q=p(()=>F.value==="edit"),$=p(()=>{let t=[...Q.value];if(O.value!=="all"&&(t=t.filter(e=>e.severity===O.value)),f.value.search){const e=f.value.search.toLowerCase();t=t.filter(a=>{var A,Ae,we;return((A=a.partName)==null?void 0:A.toLowerCase().includes(e))||((Ae=a.partNumber)==null?void 0:Ae.toLowerCase().includes(e))||((we=a.location)==null?void 0:we.toLowerCase().includes(e))})}return f.value.alertType&&(t=t.filter(e=>e.alertType===f.value.alertType)),f.value.location&&(t=t.filter(e=>e.location===f.value.location)),f.value.status&&(f.value.status==="unresolved"?t=t.filter(e=>!e.resolved):f.value.status==="resolved"?t=t.filter(e=>e.resolved):f.value.status==="acknowledged"?t=t.filter(e=>e.acknowledged):f.value.status==="unacknowledged"&&(t=t.filter(e=>!e.acknowledged))),t}),l=p(()=>{var e,a;const t=j.value;return[{label:"Total Alerts",value:t.total||0,icon:"bell",color:"blue"},{label:"Critical",value:((e=t.bySeverity)==null?void 0:e.critical)||0,icon:"exclamation-triangle",color:"red"},{label:"High Priority",value:((a=t.bySeverity)==null?void 0:a.high)||0,icon:"exclamation",color:"orange"},{label:"Unresolved",value:fe.value.length,icon:"clock",color:"yellow"}]}),o=p(()=>{var t,e,a,A;return[{key:"all",label:"All Alerts",count:Q.value.length},{key:"critical",label:"Critical",count:((t=j.value.bySeverity)==null?void 0:t.critical)||0},{key:"high",label:"High",count:((e=j.value.bySeverity)==null?void 0:e.high)||0},{key:"medium",label:"Medium",count:((a=j.value.bySeverity)==null?void 0:a.medium)||0},{key:"low",label:"Low",count:((A=j.value.bySeverity)==null?void 0:A.low)||0}]}),v=p(()=>({currentPage:1,totalPages:Math.ceil($.value.length/10),totalItems:$.value.length,pageSize:10})),_=p(()=>D.value?new Date(D.value).toLocaleTimeString():""),Ce=[{key:"alertType",label:"Alert Type",sortable:!0},{key:"partInfo",label:"Part",sortable:!1},{key:"severity",label:"Severity",sortable:!0},{key:"stockInfo",label:"Stock Levels",sortable:!1},{key:"location",label:"Location",sortable:!0},{key:"status",label:"Status",sortable:!1},{key:"createdAt",label:"Created",sortable:!0},{key:"actions",label:"Actions",sortable:!1}],xe=[{label:"All Types",value:""},{label:"Low Stock",value:y.LOW_STOCK},{label:"Out of Stock",value:y.OUT_OF_STOCK},{label:"Expiring",value:y.EXPIRING},{label:"Overstock",value:y.OVERSTOCK}],Te=[{label:"Low Stock",value:y.LOW_STOCK},{label:"Out of Stock",value:y.OUT_OF_STOCK},{label:"Expiring",value:y.EXPIRING},{label:"Overstock",value:y.OVERSTOCK}],Ie=[{label:"Critical",value:S.CRITICAL},{label:"High",value:S.HIGH},{label:"Medium",value:S.MEDIUM},{label:"Low",value:S.LOW}],_e=[{label:"All Status",value:""},{label:"Unresolved",value:"unresolved"},{label:"Resolved",value:"resolved"},{label:"Acknowledged",value:"acknowledged"},{label:"Unacknowledged",value:"unacknowledged"}],Ve=k([{label:"All Locations",value:""},{label:"Warehouse A",value:"warehouse_a"},{label:"Warehouse B",value:"warehouse_b"},{label:"Main Storage",value:"main_storage"}]),Oe=k([]),Le=t=>({[y.LOW_STOCK]:"Low Stock",[y.OUT_OF_STOCK]:"Out of Stock",[y.EXPIRING]:"Expiring",[y.OVERSTOCK]:"Overstock"})[t]||t,Me=t=>({[S.CRITICAL]:"Critical",[S.HIGH]:"High",[S.MEDIUM]:"Medium",[S.LOW]:"Low"})[t]||t,Pe=t=>t.resolved?"Resolved":t.acknowledged?"Acknowledged":"New",ye=t=>t!=null?t.toString():"N/A",Re=t=>t||"N/A",Fe=t=>t?new Date(t).toLocaleDateString():"N/A",Ee=t=>({[S.CRITICAL]:"danger",[S.HIGH]:"warning",[S.MEDIUM]:"info",[S.LOW]:"secondary"})[t]||"secondary",Ue=t=>t.resolved?"success":t.acknowledged?"info":"warning",ze=t=>({[y.LOW_STOCK]:"bg-orange-100 text-orange-600",[y.OUT_OF_STOCK]:"bg-red-100 text-red-600",[y.EXPIRING]:"bg-yellow-100 text-yellow-600",[y.OVERSTOCK]:"bg-blue-100 text-blue-600"})[t]||"bg-gray-100 text-gray-600",je=t=>({[y.LOW_STOCK]:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",[y.OUT_OF_STOCK]:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z",[y.EXPIRING]:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z",[y.OVERSTOCK]:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})[t]||"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",qe=dt.debounce(t=>{f.value.search=t},300),le=()=>{},Ne=t=>{O.value=t},He=t=>{console.log("Sort:",t)},Be=t=>{console.log("Page:",t)},De=t=>{ke(t)},X=async()=>{try{await h.loadStockAlerts(),C("Stock alerts refreshed successfully","success")}catch{C("Failed to refresh stock alerts","error")}},pe=()=>{T.value=null,F.value="create",Ke(),ee()||he(),R.value=!0},Ke=()=>{F.value==="create"&&ee()&&(te.value=ce(),z.value=!0)},ke=t=>{console.log("View alert:",t)},ge=t=>{T.value=t,F.value="edit",Je(t),ve(),R.value=!0},We=t=>{T.value=t,B.value.notes="",L.value=!0},Ge=t=>{T.value=t,I.value.resolution="",I.value.error="",M.value=!0},ae=()=>{R.value=!1,T.value=null,z.value=!1},Qe=async()=>{U.value=!0;try{if(!Ze())return;const t=et();q.value?console.log("Update alert:",t):await h.createStockAlert(t),Z(),ae(),await X(),C(q.value?"Alert updated successfully":"Alert created successfully","success")}catch{C(q.value?"Failed to update alert":"Failed to create alert","error")}finally{U.value=!1}},$e=async()=>{K.value=!0;try{await h.acknowledgeAlert(T.value.id,{acknowledgedBy:"current_user",notes:B.value.notes}),L.value=!1,await X(),C("Alert acknowledged successfully","success")}catch{C("Failed to acknowledge alert","error")}finally{K.value=!1}},Xe=async()=>{var t;if(!((t=I.value.resolution)!=null&&t.trim())){I.value.error="Resolution is required";return}I.value.error="",W.value=!0;try{await h.resolveAlert(T.value.id,{resolvedBy:"current_user",resolution:I.value.resolution}),M.value=!1,await X(),C("Alert resolved successfully","success")}catch{C("Failed to resolve alert","error")}finally{W.value=!1}},Ye=()=>{const t=h.exportStockData();console.log("Export alerts:",t),C("Alerts exported successfully","success")},he=()=>{c.value={partId:"",alertType:"",severity:"",location:"",currentStock:"",minimumStock:"",notes:""},g.value={}},Je=t=>{c.value={partId:t.partId,alertType:t.alertType,severity:t.severity,location:t.location||"",currentStock:t.currentStock,minimumStock:t.minimumStock,notes:t.notes||""},g.value={}},Ze=()=>(g.value={},c.value.partId||(g.value.partId="Part is required"),c.value.alertType||(g.value.alertType="Alert type is required"),c.value.severity||(g.value.severity="Severity is required"),(c.value.currentStock===""||c.value.currentStock===null)&&(g.value.currentStock="Current stock is required"),(c.value.minimumStock===""||c.value.minimumStock===null)&&(g.value.minimumStock="Minimum stock is required"),Object.keys(g.value).length===0),et=()=>({partId:parseInt(c.value.partId),alertType:c.value.alertType,severity:c.value.severity,location:c.value.location,currentStock:parseInt(c.value.currentStock),minimumStock:parseInt(c.value.minimumStock),notes:c.value.notes}),tt=()=>{ue(),z.value=!1},lt=()=>{Z(),z.value=!1,he()},E=()=>{de()},Se=()=>{const t=i.query.edit,e=i.query.create==="true";t?setTimeout(()=>{const a=Q.value.find(A=>A.id===parseInt(t));a&&ge(a),u.replace({path:"/inventory/stock-alerts"})},500):e&&setTimeout(()=>{pe(),u.replace({path:"/inventory/stock-alerts"})},500)};return at(async()=>{await h.loadStockAlerts(),Se()}),ot(()=>i.query,Se),(t,e)=>(V(),oe(vt,null,{header:n(()=>[d(mt,{title:"Stock Alerts",description:"Monitor and manage inventory stock alerts and notifications",breadcrumbs:[{text:"Inventory",to:"/inventory"},{text:"Stock Alerts",to:null}]},{actions:n(()=>[d(s(x),{variant:"outline",size:"sm",onClick:Ye},{default:n(()=>e[19]||(e[19]=[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),b(" Export ",-1)])),_:1,__:[19]}),d(s(x),{variant:"outline",size:"sm",onClick:X},{default:n(()=>e[20]||(e[20]=[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),b(" Refresh ",-1)])),_:1,__:[20]}),d(s(x),{variant:"primary",size:"sm",onClick:pe},{default:n(()=>e[21]||(e[21]=[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),b(" Create Alert ",-1)])),_:1,__:[21]})]),stats:n(()=>[d(s(ft),{stats:l.value},null,8,["stats"])]),tabs:n(()=>[d(s(pt),{modelValue:O.value,"onUpdate:modelValue":e[0]||(e[0]=a=>O.value=a),tabs:o.value,onTabChange:Ne},null,8,["modelValue","tabs"])]),_:1})]),default:n(()=>[r("div",ht,[r("div",St,[d(s(J),{modelValue:f.value.search,"onUpdate:modelValue":e[1]||(e[1]=a=>f.value.search=a),placeholder:"Search alerts...",onInput:s(qe)},{prepend:n(()=>e[22]||(e[22]=[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"]),d(s(H),{modelValue:f.value.alertType,"onUpdate:modelValue":[e[2]||(e[2]=a=>f.value.alertType=a),le],placeholder:"Filter by Alert Type",options:xe},null,8,["modelValue"]),d(s(H),{modelValue:f.value.location,"onUpdate:modelValue":[e[3]||(e[3]=a=>f.value.location=a),le],placeholder:"Filter by Location",options:Ve.value},null,8,["modelValue","options"]),d(s(H),{modelValue:f.value.status,"onUpdate:modelValue":[e[4]||(e[4]=a=>f.value.status=a),le],placeholder:"Filter by Status",options:_e},null,8,["modelValue"])]),r("div",At,[d(s(yt),{columns:Ce,data:$.value,loading:me.value,pagination:v.value,"empty-message":"No stock alerts found",onSortChange:He,onPageChange:Be,onRowClick:De},{"column-alertType":n(({row:a})=>[r("div",wt,[r("div",{class:re(["w-8 h-8 rounded-lg flex items-center justify-center",ze(a.alertType)])},[(V(),P("svg",bt,[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:je(a.alertType)},null,8,Ct)]))],2),r("span",xt,w(Le(a.alertType)),1)])]),"column-partInfo":n(({row:a})=>[r("div",null,[r("h4",Tt,w(a.partName||`Part #${a.partId}`),1),r("p",It,w(a.partNumber||"N/A"),1)])]),"column-severity":n(({row:a})=>[d(s(be),{variant:Ee(a.severity),size:"sm"},{default:n(()=>[b(w(Me(a.severity)),1)]),_:2},1032,["variant"])]),"column-stockInfo":n(({row:a})=>[r("div",_t,[r("div",Vt," Current: "+w(ye(a.currentStock)),1),r("div",Ot," Min: "+w(ye(a.minimumStock)),1)])]),"column-location":n(({row:a})=>[r("div",Lt,w(Re(a.location)),1)]),"column-status":n(({row:a})=>[d(s(be),{variant:Ue(a),size:"sm"},{default:n(()=>[b(w(Pe(a)),1)]),_:2},1032,["variant"])]),"column-createdAt":n(({row:a})=>[r("div",Mt,w(Fe(a.createdAt)),1)]),"column-actions":n(({row:a})=>[r("div",Pt,[d(s(x),{variant:"ghost",size:"xs",onClick:Y(A=>ke(a),["stop"]),title:"View Details"},{default:n(()=>e[23]||(e[23]=[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,__:[23]},1032,["onClick"]),a.acknowledged?N("",!0):(V(),oe(s(x),{key:0,variant:"ghost",size:"xs",onClick:Y(A=>We(a),["stop"]),title:"Acknowledge Alert",class:"text-blue-600 hover:text-blue-700"},{default:n(()=>e[24]||(e[24]=[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,__:[24]},1032,["onClick"])),a.resolved?N("",!0):(V(),oe(s(x),{key:1,variant:"ghost",size:"xs",onClick:Y(A=>Ge(a),["stop"]),title:"Resolve Alert",class:"text-green-600 hover:text-green-700"},{default:n(()=>e[25]||(e[25]=[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:"M5 13l4 4L19 7"})],-1)])),_:2,__:[25]},1032,["onClick"])),d(s(x),{variant:"ghost",size:"xs",onClick:Y(A=>ge(a),["stop"]),title:"Edit Alert"},{default:n(()=>e[26]||(e[26]=[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,__:[26]},1032,["onClick"])])]),_:1},8,["data","loading","pagination"])]),d(s(ie),{modelValue:R.value,"onUpdate:modelValue":e[12]||(e[12]=a=>R.value=a),title:q.value?"Edit Stock Alert":"Create Stock Alert",size:"lg",onCancel:ae},{footer:n(()=>[r("div",Ut,[r("div",zt,[s(G)||s(D)?(V(),P("div",jt,[s(G)?(V(),P("svg",qt,e[28]||(e[28]=[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)]))):(V(),P("svg",Nt,e[29]||(e[29]=[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)]))),s(G)?(V(),P("span",Ht,"Auto-saving...")):s(D)?(V(),P("span",Bt,"Last saved "+w(_.value),1)):N("",!0)])):N("",!0)]),r("div",Dt,[d(s(x),{variant:"secondary",onClick:ae},{default:n(()=>e[30]||(e[30]=[b(" Cancel ",-1)])),_:1,__:[30]}),d(s(x),{variant:"primary",loading:U.value,onClick:Qe},{default:n(()=>[b(w(q.value?"Update Alert":"Create Alert"),1)]),_:1},8,["loading"])])])]),default:n(()=>[d(s(kt),{visible:z.value,"saved-data-info":te.value,onRestore:tt,onDismiss:lt},null,8,["visible","saved-data-info"]),r("div",Rt,[r("div",Ft,[d(s(H),{modelValue:c.value.partId,"onUpdate:modelValue":e[5]||(e[5]=a=>c.value.partId=a),label:"Part",placeholder:"Select part",options:Oe.value,required:"",error:g.value.partId,onChange:E},null,8,["modelValue","options","error"]),d(s(H),{modelValue:c.value.alertType,"onUpdate:modelValue":e[6]||(e[6]=a=>c.value.alertType=a),label:"Alert Type",placeholder:"Select alert type",options:Te,required:"",error:g.value.alertType,onChange:E},null,8,["modelValue","error"]),d(s(H),{modelValue:c.value.severity,"onUpdate:modelValue":e[7]||(e[7]=a=>c.value.severity=a),label:"Severity",placeholder:"Select severity",options:Ie,required:"",error:g.value.severity,onChange:E},null,8,["modelValue","error"]),d(s(J),{modelValue:c.value.location,"onUpdate:modelValue":e[8]||(e[8]=a=>c.value.location=a),label:"Location",placeholder:"Enter location",error:g.value.location,onInput:E},null,8,["modelValue","error"]),d(s(J),{modelValue:c.value.currentStock,"onUpdate:modelValue":e[9]||(e[9]=a=>c.value.currentStock=a),label:"Current Stock",placeholder:"0",type:"number",required:"",error:g.value.currentStock,onInput:E},null,8,["modelValue","error"]),d(s(J),{modelValue:c.value.minimumStock,"onUpdate:modelValue":e[10]||(e[10]=a=>c.value.minimumStock=a),label:"Minimum Stock",placeholder:"0",type:"number",required:"",error:g.value.minimumStock,onInput:E},null,8,["modelValue","error"])]),r("div",null,[e[27]||(e[27]=r("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Notes",-1)),se(r("textarea",{"onUpdate:modelValue":e[11]||(e[11]=a=>c.value.notes=a),class:re(["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":g.value.notes}]),placeholder:"Additional notes or description...",rows:"3",onInput:E},null,34),[[ne,c.value.notes]]),g.value.notes?(V(),P("p",Et,w(g.value.notes),1)):N("",!0)])])]),_:1},8,["modelValue","title"]),d(s(ie),{modelValue:L.value,"onUpdate:modelValue":e[15]||(e[15]=a=>L.value=a),title:"Acknowledge Stock Alert",size:"md"},{footer:n(()=>[r("div",Qt,[d(s(x),{variant:"secondary",onClick:e[14]||(e[14]=a=>L.value=!1)},{default:n(()=>e[34]||(e[34]=[b(" Cancel ",-1)])),_:1,__:[34]}),d(s(x),{variant:"primary",loading:K.value,onClick:$e},{default:n(()=>e[35]||(e[35]=[b(" Acknowledge Alert ",-1)])),_:1,__:[35]},8,["loading"])])]),default:n(()=>{var a;return[r("div",Kt,[r("p",Wt,[e[31]||(e[31]=b(" Acknowledging this alert for ",-1)),r("strong",Gt,"'"+w((a=T.value)==null?void 0:a.partName)+"'",1),e[32]||(e[32]=b(". ",-1))]),r("div",null,[e[33]||(e[33]=r("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Notes (Optional)",-1)),se(r("textarea",{"onUpdate:modelValue":e[13]||(e[13]=A=>B.value.notes=A),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 notes about this acknowledgment...",rows:"3"},null,512),[[ne,B.value.notes]])])])]}),_:1},8,["modelValue"]),d(s(ie),{modelValue:M.value,"onUpdate:modelValue":e[18]||(e[18]=a=>M.value=a),title:"Resolve Stock Alert",size:"md"},{footer:n(()=>[r("div",Zt,[d(s(x),{variant:"secondary",onClick:e[17]||(e[17]=a=>M.value=!1)},{default:n(()=>e[39]||(e[39]=[b(" Cancel ",-1)])),_:1,__:[39]}),d(s(x),{variant:"primary",loading:W.value,onClick:Xe},{default:n(()=>e[40]||(e[40]=[b(" Resolve Alert ",-1)])),_:1,__:[40]},8,["loading"])])]),default:n(()=>{var a;return[r("div",$t,[r("p",Xt,[e[36]||(e[36]=b(" Resolving this alert for ",-1)),r("strong",Yt,"'"+w((a=T.value)==null?void 0:a.partName)+"'",1),e[37]||(e[37]=b(". ",-1))]),r("div",null,[e[38]||(e[38]=r("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Resolution (Required)",-1)),se(r("textarea",{"onUpdate:modelValue":e[16]||(e[16]=A=>I.value.resolution=A),class:re(["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":I.value.error}]),placeholder:"Describe how this alert was resolved...",rows:"3",required:""},null,2),[[ne,I.value.resolution]]),I.value.error?(V(),P("p",Jt,w(I.value.error),1)):N("",!0)])])]}),_:1},8,["modelValue"])])]),_:1}))}};export{pl as default};
|