bettertend/frontend/dist/assets/PartsListView-BrMDoBjw.js

2 lines
24 KiB
JavaScript

import{r as y,c as k,l as ct,o as mt,m as vt,i as ue,w as m,s as pt,v as ft,g as S,b as r,d as c,e,F as C,h as de,t as x,k as w,a as F,j as N,aV as gt,ae as ce,n as yt,aU as me}from"./index-BUdRbiwj.js";import{u as Ie}from"./parts-B3aeW8xP.js";import{u as ht}from"./useFormAutoSave-Jaawgo91.js";import{u as Ve,a as Pt}from"./usePartDisplay-D-mkc8An.js";import{l as bt}from"./lodash-RqMXHFU9.js";import{F as kt,a as St}from"./FPPageHeader-CTG2L28r.js";import{F as _}from"./FPInput-CzR_dWoe.js";import{F as E}from"./FPSelect-C7p47Ma2.js";import{F as xt}from"./FPStats-BGfZcDZc.js";import{F as wt}from"./FPTable-CU8C_NYc.js";import{F as Fe}from"./FPModal-DWGF1LV8.js";import{F as Te}from"./FPBadge-BKY5dPnL.js";import{F as _e}from"./FPTabs-R71V25QN.js";import{_ as Ct}from"./FormRestoreNotification-DYBlXhOP.js";import"./_commonjsHelpers-NT8qMgGI.js";import"./FPCard-qHzcEQAE.js";function Vt(g={}){const l=y({name:"",partNumber:"",manufacturer:"",description:"",category:"",currentStock:"",minStock:"",unitCost:"",supplier:"",location:"",parentPartId:null,...g}),i=y({}),s=y("basic"),P=[{key:"basic",label:"Basic Information"},{key:"inventory",label:"Inventory & Pricing"},{key:"details",label:"Details & Specifications"}],z=[{label:"Parts",value:"PARTS"},{label:"Tools",value:"TOOLS"},{label:"Supplies",value:"SUPPLIES"},{label:"Equipment",value:"EQUIPMENT"},{label:"Consumables",value:"CONSUMABLES"}],R=k(()=>[{label:"HVAC Supply Co",value:"HVAC Supply Co"},{label:"Elevator Parts Inc",value:"Elevator Parts Inc"},{label:"Safety Equipment Ltd",value:"Safety Equipment Ltd"},{label:"Tool Supply Co",value:"Tool Supply Co"},{label:"General Parts Supplier",value:"General Parts Supplier"}]),B=k(()=>[{label:"Warehouse A1",value:"Warehouse A1"},{label:"Warehouse B2",value:"Warehouse B2"},{label:"Storage Room C",value:"Storage Room C"},{label:"Tool Room",value:"Tool Room"},{label:"Main Storage",value:"Main Storage"}]),I=()=>{if(i.value={},!l.value.name||l.value.name.trim().length===0?i.value.name="Part name is required":l.value.name.trim().length<2&&(i.value.name="Part name must be at least 2 characters"),l.value.category||(i.value.category="Category is required"),(!l.value.location||l.value.location.trim().length===0)&&(i.value.location="Storage location is required"),l.value.currentStock!==""&&l.value.currentStock!==null&&l.value.currentStock!==void 0){const o=parseFloat(l.value.currentStock);(isNaN(o)||o<0)&&(i.value.currentStock="Current stock must be a non-negative number")}if(l.value.minStock!==""&&l.value.minStock!==null&&l.value.minStock!==void 0){const o=parseFloat(l.value.minStock);(isNaN(o)||o<0)&&(i.value.minStock="Minimum stock must be a non-negative number")}if(l.value.unitCost!==""&&l.value.unitCost!==null&&l.value.unitCost!==void 0){const o=parseFloat(l.value.unitCost);(isNaN(o)||o<0)&&(i.value.unitCost="Unit cost must be a non-negative number")}return Object.keys(i.value).length===0},M=o=>i.value[o]||null,H=()=>{i.value={}},$=o=>{i.value[o]&&delete i.value[o]},W=k(()=>I()),Q=k(()=>s.value===P[0].key),G=k(()=>s.value===P[P.length-1].key);return{formData:l,errors:i,activeTab:s,formTabs:P,categoryOptions:z,supplierOptions:R,locationOptions:B,isValid:W,isFirstTab:Q,isLastTab:G,validateForm:I,getFieldError:M,clearErrors:H,clearFieldError:$,nextTab:()=>{const o=P.findIndex(p=>p.key===s.value);o<P.length-1&&(s.value=P[o+1].key)},previousTab:()=>{const o=P.findIndex(p=>p.key===s.value);o>0&&(s.value=P[o-1].key)},resetForm:()=>{l.value={name:"",partNumber:"",manufacturer:"",description:"",category:"",currentStock:"",minStock:"",unitCost:"",supplier:"",location:"",parentPartId:null},i.value={},s.value="basic"},getFormData:()=>l.value,populateForm:o=>{var p,T,L;l.value={name:o.name||"",partNumber:o.partNumber||"",manufacturer:o.manufacturer||"",description:o.description||"",category:o.category||"",currentStock:((p=o.currentStock)==null?void 0:p.toString())||"",minStock:((T=o.minStock)==null?void 0:T.toString())||"",unitCost:((L=o.unitCost)==null?void 0:L.toString())||"",supplier:o.supplier||"",location:o.location||"",parentPartId:o.parentPartId||null},i.value={}}}}function Ft(){const g=Ie(),{showNotification:l}=ct(),i=y(!1),s=y(null),P=async(d,n=!1,o=null)=>{i.value=!0,s.value=null;try{let p;return n&&o?(p=await g.updatePart(o,d),l("success","Part updated successfully")):(p=await g.createPart(d),l("success","Part created successfully")),p}catch(p){const T=n?"Failed to update part":"Failed to create part";throw s.value=p.message,l("error",T),console.error("Part submission error:",p),p}finally{i.value=!1}},z=async d=>{i.value=!0,s.value=null;try{await g.deletePart(d),l("success","Part deleted successfully")}catch(n){throw s.value=n.message,l("error","Failed to delete part"),console.error("Part deletion error:",n),n}finally{i.value=!1}},R=async d=>{i.value=!0,s.value=null;try{return await g.getPartById(parseInt(d))}catch(n){throw s.value=n.message,l("error","Failed to load part for editing"),console.error("Part load error:",n),n}finally{i.value=!1}},B=async()=>{i.value=!0,s.value=null;try{await g.refreshParts(),l("success","Parts refreshed successfully")}catch(d){throw s.value=d.message,l("error","Failed to refresh parts"),console.error("Parts refresh error:",d),d}finally{i.value=!1}},I=async(d={})=>{i.value=!0,s.value=null;try{await g.exportParts(d),l("success","Parts exported successfully")}catch(n){throw s.value=n.message,l("error","Failed to export parts"),console.error("Part export error:",n),n}finally{i.value=!1}},M=async(d,n,o)=>{if(!d())return{isValid:!1,type:"form",message:"Please fix the validation errors before submitting"};const p=n(o);return p.isValid?{isValid:!0}:{isValid:!1,type:"business",message:p.errors.join(", ")}};return{isProcessing:i,error:s,handlePartSubmission:P,handlePartDeletion:z,handlePartLoad:R,handlePartsRefresh:B,handlePartExport:I,handleStockUpdate:async(d,n,o)=>{i.value=!0,s.value=null;try{await g.updateStock(d,n,o),l("success","Stock updated successfully")}catch(p){throw s.value=p.message,l("error","Failed to update stock"),console.error("Stock update error:",p),p}finally{i.value=!1}},handlePartsReservation:async(d,n)=>{i.value=!0,s.value=null;try{await g.reserveParts(d,n),l("success","Parts reserved successfully")}catch(o){throw s.value=o.message,l("error","Failed to reserve parts"),console.error("Parts reservation error:",o),o}finally{i.value=!1}},handlePartsRelease:async d=>{i.value=!0,s.value=null;try{await g.releaseParts(d),l("success","Parts released successfully")}catch(n){throw s.value=n.message,l("error","Failed to release parts"),console.error("Parts release error:",n),n}finally{i.value=!1}},submitPart:async({validateForm:d,validateBusinessRules:n,getFormData:o,processPartData:p,isEditMode:T=!1,partId:L=null,onSuccess:A=null,onError:U=null})=>{try{const D=o(),v=p(D),f=await M(d,n,v);if(!f.isValid)return l("error",f.message),U&&U(new Error(f.message)),{success:!1,error:f.message};const V=await P(v,T,L);return A&&A(V),{success:!0,data:V}}catch(D){return U&&U(D),{success:!1,error:D.message}}},validatePartSubmission:M,handlePartSearch:async(d,n={})=>{try{await g.updateSearchTerm(d),Object.keys(n).length>0&&await g.updateFilters(n)}catch(o){s.value=o.message,console.error("Part search error:",o)}},handlePartPagination:async d=>{try{await g.changePage(d-1)}catch(n){s.value=n.message,console.error("Part pagination error:",n)}},handlePartSorting:async d=>{try{await g.changeSorting(d.column,d.direction)}catch(n){s.value=n.message,console.error("Part sorting error:",n)}},clearError:()=>{s.value=null}}}const Tt={class:"p-6"},_t={class:"mb-6 grid grid-cols-1 md:grid-cols-4 gap-4"},It={class:"bg-white shadow rounded-lg overflow-hidden"},Mt={class:"flex items-center space-x-3"},Lt={class:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center"},Ut={class:"w-4 h-4 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Dt=["d"],Nt={class:"font-medium text-gray-900"},Et={class:"text-sm text-gray-500"},zt={class:"flex items-center space-x-2"},Rt={class:"font-medium text-gray-900"},Bt={class:"text-sm font-medium text-gray-900"},Ht={class:"text-sm font-medium text-gray-900"},At={class:"text-sm text-gray-900"},jt={class:"text-sm text-gray-900"},Ot={class:"flex items-center space-x-2"},qt={class:"border-b border-gray-200 mb-6"},$t={key:0,class:"space-y-6"},Wt={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},Qt={class:"md:col-span-2"},Gt={key:0,class:"mt-1 text-sm text-red-600"},Jt={key:1,class:"space-y-6"},Xt={class:"grid grid-cols-1 md:grid-cols-3 gap-6"},Yt={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},Zt={key:2,class:"space-y-6"},Kt={class:"space-y-4"},ea={class:"flex items-center justify-between"},ta={class:"flex items-center space-x-4"},aa={key:0,class:"flex items-center text-sm text-gray-500"},ra={key:0,class:"w-4 h-4 mr-2 text-amber-500 animate-pulse",fill:"currentColor",viewBox:"0 0 20 20"},oa={key:1,class:"w-4 h-4 mr-2 text-green-500",fill:"currentColor",viewBox:"0 0 20 20"},la={key:2},sa={key:3},na={class:"flex space-x-3"},ia={class:"space-y-4"},ua={class:"text-gray-600"},da={class:"text-gray-900"},ca={class:"flex justify-end space-x-3"},Ta={__name:"PartsListView",setup(g){const l=ft(),i=pt(),s=Ie(),{processPartData:P,validatePartBusinessRules:z}=Ve(),{getCategoryVariant:R,getStockLevelVariant:B,formatCategory:I,formatStockLevel:M,formatCurrency:H,formatPartNumber:$,formatSupplier:W,formatLocation:Q,formatStockDisplay:G,calculatePartValue:ee,formatInventoryStats:te,getCategoryTabs:ae,getPartTableColumns:d}=Pt(),{submitPart:n,handlePartDeletion:o,handlePartsRefresh:p,handlePartExport:T,handlePartLoad:L,handlePartSearch:A,handlePartPagination:U,handlePartSorting:D}=Ft(),{formData:v,errors:f,activeTab:V,formTabs:Me,categoryOptions:Le,supplierOptions:ve,locationOptions:pe,isLastTab:Ue,validateForm:De,resetForm:fe,getFormData:Ne,populateForm:Ee,nextTab:ze}=Vt(),{hasUnsavedChanges:re,lastSaveTime:J,restoreFormData:Re,clearSavedData:ge,hasSavedData:ye,getSavedDataInfo:Be,markUserInteraction:He,finishInitialization:Ae}=ht(v,{storageKey:"atlas_part_form_data",saveInterval:3e3,excludeFields:[]}),j=y(!1),he=y(null),oe=y("all"),h=y({search:"",supplier:"",location:"",stockLevel:""}),O=y(!1),X=y("create"),Y=y(null),q=y(!1),Z=y(null),le=y(!1);y(!1);const je=k(()=>s.loading),Oe=k(()=>s.filteredParts),Pe=k(()=>s.inventoryStats),se=k(()=>X.value==="edit"),qe=k(()=>te(Pe.value)),$e=k(()=>J.value?new Date(J.value).toLocaleTimeString():""),We=k(()=>ae(Pe.value)),Qe=k(()=>{var u,t;return{currentPage:(((u=s.searchCriteria)==null?void 0:u.page)||0)+1,totalPages:s.totalPages||0,totalItems:s.totalElements||0,pageSize:((t=s.searchCriteria)==null?void 0:t.size)||10}}),Ge=k(()=>d(!1)),Je=[{label:"All Levels",value:""},{label:"Low Stock",value:"low"},{label:"Normal Stock",value:"normal"},{label:"Overstocked",value:"over"}],Xe=bt.debounce(u=>{A(u,h.value)},300),K=()=>{A(h.value.search,{supplier:h.value.supplier,location:h.value.location,stockLevel:h.value.stockLevel})},Ye=u=>{oe.value=u,h.value.category=u==="all"?"":u,K()},Ze=u=>{D(u)},Ke=u=>{U(u)},et=u=>{ke(u)},ne=async()=>{await p()},be=()=>{Y.value=null,X.value="create",tt(),ye()||fe(),O.value=!0},tt=()=>{X.value==="create"&&ye()&&(he.value=Be(),j.value=!0,console.log("✅ Found saved part data, showing restore notification"))},ke=u=>{l.push(`/inventory/parts/${u.id}`)},Se=u=>{Y.value=u,X.value="edit",Ee(u),Ae(),O.value=!0},at=u=>{Z.value=u,q.value=!0},rt=async()=>{try{await o(Z.value.id),q.value=!1,Z.value=null,await ne()}catch{}},ie=()=>{O.value=!1,Y.value=null,j.value=!1},ot=async()=>{var u;le.value=!0;try{(await n({validateForm:De,validateBusinessRules:z,getFormData:Ne,processPartData:P,isEditMode:se.value,partId:(u=Y.value)==null?void 0:u.id})).success&&(ge(),ie(),await ne())}finally{le.value=!1}},lt=u=>{b(),ze()},st=()=>{Re(),j.value=!1,console.log("Part form data restored successfully")},nt=()=>{ge(),j.value=!1,fe(),console.log("Part auto-saved data dismissed")},it=async()=>{await T(h.value)},b=()=>{console.log("🔥 Part user interaction detected!"),He()},ut=u=>{V.value=u,b()},{calculateStockLevel:xe}=Ve(),dt=u=>{const t={PARTS:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z",TOOLS:"M11 4a2 2 0 114 0v1a1 1 0 001 1h3a1 1 0 011 1v3a1 1 0 01-1 1h-1a2 2 0 100 4h1a1 1 0 011 1v3a1 1 0 01-1 1h-3a1 1 0 01-1-1v-1a2 2 0 10-4 0v1a1 1 0 01-1 1H7a1 1 0 01-1-1v-3a1 1 0 00-1-1H4a1 1 0 01-1-1V9a1 1 0 011-1h1a2 2 0 100-4H4a1 1 0 01-1-1V4a1 1 0 011-1h3a1 1 0 011 1v1a2 2 0 104 0V4z",SUPPLIES:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4",EQUIPMENT:"M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"};return t[u]||t.PARTS},we=()=>{const u=i.query.edit,t=i.query.create==="true";try{u?setTimeout(async()=>{try{const a=await L(parseInt(u));Se(a),l.replace({path:"/inventory/parts"})}catch{l.replace({path:"/inventory/parts"})}},500):t&&setTimeout(()=>{be(),l.replace({path:"/inventory/parts"})},500)}catch{l.replace({path:"/inventory/parts"})}};return mt(async()=>{await s.initializeParts(),we()}),vt(()=>i.query,we),(u,t)=>(S(),ue(kt,null,{header:m(()=>[c(St,{title:"Parts & Inventory",description:"Manage parts, supplies, and inventory stock levels",breadcrumbs:[{text:"Inventory",to:"/inventory"},{text:"Parts",to:null}]},{actions:m(()=>[c(e(C),{variant:"outline",size:"sm",onClick:it},{default:m(()=>t[22]||(t[22]=[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),w(" Export ",-1)])),_:1,__:[22]}),c(e(C),{variant:"outline",size:"sm",onClick:ne},{default:m(()=>t[23]||(t[23]=[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),w(" Refresh ",-1)])),_:1,__:[23]}),c(e(C),{variant:"primary",size:"sm",onClick:be},{default:m(()=>t[24]||(t[24]=[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),w(" Add Part ",-1)])),_:1,__:[24]})]),stats:m(()=>[c(e(xt),{stats:qe.value},null,8,["stats"])]),tabs:m(()=>[c(e(_e),{modelValue:oe.value,"onUpdate:modelValue":t[0]||(t[0]=a=>oe.value=a),tabs:We.value,onTabChange:Ye},null,8,["modelValue","tabs"])]),_:1})]),default:m(()=>[r("div",Tt,[r("div",_t,[c(e(_),{modelValue:h.value.search,"onUpdate:modelValue":t[1]||(t[1]=a=>h.value.search=a),placeholder:"Search parts...",onInput:e(Xe)},{prepend:m(()=>t[25]||(t[25]=[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"]),c(e(E),{modelValue:h.value.supplier,"onUpdate:modelValue":[t[2]||(t[2]=a=>h.value.supplier=a),K],placeholder:"Filter by Supplier",options:e(ve)},null,8,["modelValue","options"]),c(e(E),{modelValue:h.value.location,"onUpdate:modelValue":[t[3]||(t[3]=a=>h.value.location=a),K],placeholder:"Filter by Location",options:e(pe)},null,8,["modelValue","options"]),c(e(E),{modelValue:h.value.stockLevel,"onUpdate:modelValue":[t[4]||(t[4]=a=>h.value.stockLevel=a),K],placeholder:"Filter by Stock Level",options:Je},null,8,["modelValue"])]),r("div",It,[c(e(wt),{columns:Ge.value,data:Oe.value,loading:je.value,pagination:Qe.value,"empty-message":"No parts found",onSortChange:Ze,onPageChange:Ke,onRowClick:et},{"column-name":m(({row:a})=>[r("div",Mt,[r("div",Lt,[(S(),F("svg",Ut,[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:dt(a.category)},null,8,Dt)]))]),r("div",null,[r("h4",Nt,x(a.name),1),r("p",Et,x(e($)(a.partNumber)),1)])])]),"column-category":m(({row:a})=>[c(e(Te),{variant:e(R)(a.category)},{default:m(()=>[w(x(e(I)(a.category)),1)]),_:2},1032,["variant"])]),"column-stock":m(({row:a})=>[r("div",zt,[r("span",Rt,x(e(G)(a)),1),c(e(Te),{variant:e(B)(e(xe)(a)),size:"sm"},{default:m(()=>[w(x(e(M)(e(xe)(a))),1)]),_:2},1032,["variant"])])]),"column-unitCost":m(({row:a})=>[r("div",Bt,x(e(H)(a.unitCost)),1)]),"column-totalValue":m(({row:a})=>[r("div",Ht,x(e(H)(e(ee)(a))),1)]),"column-supplier":m(({row:a})=>[r("div",At,x(e(W)(a.supplier)),1)]),"column-location":m(({row:a})=>[r("div",jt,x(e(Q)(a.location)),1)]),"column-actions":m(({row:a})=>[r("div",Ot,[c(e(C),{variant:"ghost",size:"xs",onClick:de(Ce=>ke(a),["stop"]),title:"View Details"},{default:m(()=>t[26]||(t[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:"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,__:[26]},1032,["onClick"]),c(e(C),{variant:"ghost",size:"xs",onClick:de(Ce=>Se(a),["stop"]),title:"Edit Part"},{default:m(()=>t[27]||(t[27]=[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,__:[27]},1032,["onClick"]),c(e(C),{variant:"ghost",size:"xs",onClick:de(Ce=>at(a),["stop"]),title:"Delete Part",class:"text-red-600 hover:text-red-700"},{default:m(()=>t[28]||(t[28]=[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,__:[28]},1032,["onClick"])])]),_:1},8,["columns","data","loading","pagination"])]),c(e(Fe),{modelValue:O.value,"onUpdate:modelValue":t[19]||(t[19]=a=>O.value=a),title:se.value?"Edit Part":"Create Part",size:"xl",onCancel:ie},{footer:m(()=>[r("div",ea,[r("div",ta,[e(re)||e(J)?(S(),F("div",aa,[e(re)?(S(),F("svg",ra,t[32]||(t[32]=[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)]))):(S(),F("svg",oa,t[33]||(t[33]=[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)]))),e(re)?(S(),F("span",la,"Auto-saving...")):e(J)?(S(),F("span",sa,"Last saved "+x($e.value),1)):N("",!0)])):N("",!0)]),r("div",na,[c(e(C),{variant:"secondary",onClick:ie},{default:m(()=>t[34]||(t[34]=[w(" Cancel ",-1)])),_:1,__:[34]}),e(Ue)?(S(),ue(e(C),{key:1,variant:"primary",loading:le.value,onClick:ot},{default:m(()=>[w(x(se.value?"Update Part":"Create Part"),1)]),_:1},8,["loading"])):(S(),ue(e(C),{key:0,variant:"primary",onClick:t[18]||(t[18]=a=>lt("next"))},{default:m(()=>t[35]||(t[35]=[w(" Next ",-1)])),_:1,__:[35]}))])])]),default:m(()=>[c(e(Ct),{visible:j.value,"saved-data-info":he.value,onRestore:st,onDismiss:nt},null,8,["visible","saved-data-info"]),r("div",qt,[c(e(_e),{modelValue:e(V),"onUpdate:modelValue":t[5]||(t[5]=a=>gt(V)?V.value=a:null),tabs:e(Me),onTabChange:ut},null,8,["modelValue","tabs"])]),e(V)==="basic"?(S(),F("div",$t,[r("div",Wt,[c(e(_),{modelValue:e(v).name,"onUpdate:modelValue":t[6]||(t[6]=a=>e(v).name=a),label:"Part Name",placeholder:"Enter part name",required:"",error:e(f).name,onInput:b},null,8,["modelValue","error"]),c(e(_),{modelValue:e(v).partNumber,"onUpdate:modelValue":t[7]||(t[7]=a=>e(v).partNumber=a),label:"Part Number",placeholder:"Enter part number",error:e(f).partNumber,onInput:b},null,8,["modelValue","error"]),c(e(E),{modelValue:e(v).category,"onUpdate:modelValue":t[8]||(t[8]=a=>e(v).category=a),label:"Category",placeholder:"Select category",options:e(Le),required:"",error:e(f).category,onChange:b},null,8,["modelValue","options","error"]),c(e(_),{modelValue:e(v).manufacturer,"onUpdate:modelValue":t[9]||(t[9]=a=>e(v).manufacturer=a),label:"Manufacturer",placeholder:"Enter manufacturer",error:e(f).manufacturer,onInput:b},null,8,["modelValue","error"]),r("div",Qt,[t[29]||(t[29]=r("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Description",-1)),ce(r("textarea",{"onUpdate:modelValue":t[10]||(t[10]=a=>e(v).description=a),class:yt(["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":e(f).description}]),placeholder:"Describe the part...",rows:"3",onInput:b},null,34),[[me,e(v).description]]),e(f).description?(S(),F("p",Gt,x(e(f).description),1)):N("",!0)])])])):N("",!0),e(V)==="inventory"?(S(),F("div",Jt,[r("div",Xt,[c(e(_),{modelValue:e(v).currentStock,"onUpdate:modelValue":t[11]||(t[11]=a=>e(v).currentStock=a),label:"Current Stock",placeholder:"0",type:"number",required:"",error:e(f).currentStock,onInput:b},null,8,["modelValue","error"]),c(e(_),{modelValue:e(v).minStock,"onUpdate:modelValue":t[12]||(t[12]=a=>e(v).minStock=a),label:"Minimum Stock",placeholder:"0",type:"number",required:"",error:e(f).minStock,onInput:b},null,8,["modelValue","error"]),c(e(_),{modelValue:e(v).unitCost,"onUpdate:modelValue":t[13]||(t[13]=a=>e(v).unitCost=a),label:"Unit Cost",placeholder:"0.00",type:"number",step:"0.01",required:"",error:e(f).unitCost,onInput:b},null,8,["modelValue","error"])]),r("div",Yt,[c(e(E),{modelValue:e(v).supplier,"onUpdate:modelValue":t[14]||(t[14]=a=>e(v).supplier=a),label:"Supplier",placeholder:"Select supplier",options:e(ve),error:e(f).supplier,onChange:b},null,8,["modelValue","options","error"]),c(e(E),{modelValue:e(v).location,"onUpdate:modelValue":t[15]||(t[15]=a=>e(v).location=a),label:"Storage Location",placeholder:"Select storage location",options:e(pe),required:"",error:e(f).location,onChange:b},null,8,["modelValue","options","error"])])])):N("",!0),e(V)==="details"?(S(),F("div",Zt,[r("div",Kt,[r("div",null,[t[30]||(t[30]=r("label",{class:"block text-sm font-medium text-gray-700 mb-2"}," Additional Specifications ",-1)),ce(r("textarea",{"onUpdate:modelValue":t[16]||(t[16]=a=>e(v).specifications=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:"Enter technical specifications, dimensions, materials, etc.",rows:"4",onInput:b},null,544),[[me,e(v).specifications]])]),r("div",null,[t[31]||(t[31]=r("label",{class:"block text-sm font-medium text-gray-700 mb-2"}," Notes ",-1)),ce(r("textarea",{"onUpdate:modelValue":t[17]||(t[17]=a=>e(v).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:"Additional notes, usage instructions, etc.",rows:"3",onInput:b},null,544),[[me,e(v).notes]])])])])):N("",!0)]),_:1},8,["modelValue","title"]),c(e(Fe),{modelValue:q.value,"onUpdate:modelValue":t[21]||(t[21]=a=>q.value=a),title:"Delete Part",size:"md"},{footer:m(()=>[r("div",ca,[c(e(C),{variant:"secondary",onClick:t[20]||(t[20]=a=>q.value=!1)},{default:m(()=>t[38]||(t[38]=[w(" Cancel ",-1)])),_:1,__:[38]}),c(e(C),{variant:"danger",onClick:rt},{default:m(()=>t[39]||(t[39]=[w(" Delete Part ",-1)])),_:1,__:[39]})])]),default:m(()=>{var a;return[r("div",ia,[r("p",ua,[t[36]||(t[36]=w(" Are you sure you want to delete ",-1)),r("strong",da,"'"+x((a=Z.value)==null?void 0:a.name)+"'",1),t[37]||(t[37]=w("? This action cannot be undone. ",-1))])])]}),_:1},8,["modelValue"])])]),_:1}))}};export{Ta as default};