bettertend/frontend/dist/assets/AssetDetailView-BJoQpmcV.js

2 lines
14 KiB
JavaScript

import{_ as P,r as w,c as R,o as S,i as M,w as c,s as F,v as $,g as l,b as t,n as o,e as s,a as d,aX as U,d as m,k as p,t as i,af as W,aR as Z,j as G,F as k,b9 as X}from"./index-QAlcqU00.js";import{u as q}from"./useMobileOptimization-Ds6Eb1bE.js";import{F as b}from"./FPBadge-DvOitM1C.js";import{F as Y,a as J}from"./FPPageHeader-CFIwZZgQ.js";const K={key:0},Q={key:1},tt={key:0},et={key:1},st={key:0,class:"flex items-center justify-center py-12"},at={key:1,class:"space-y-6"},rt={class:"text-sm text-gray-500"},ot={class:"text-gray-600"},nt={class:"flex items-center"},it={class:"ml-4"},lt={class:"text-2xl font-bold text-gray-900"},dt={class:"flex items-center"},ct={class:"ml-4"},ut={class:"flex items-center"},mt={class:"ml-4"},vt={class:"flex items-center"},xt={class:"ml-4"},pt={class:"bg-white shadow rounded-lg"},yt={class:"border-b border-gray-200"},ft=["onClick"],gt={key:0},wt={class:"space-y-3"},kt={class:"text-sm text-gray-900"},bt={class:"text-sm text-gray-900"},ht={class:"text-sm text-gray-900"},Ct={class:"text-sm text-gray-900"},At={class:"text-sm text-gray-900"},Mt={class:"space-y-3"},_t={class:"text-sm text-gray-900"},Nt={class:"text-sm text-gray-900"},Ht={class:"text-sm text-gray-900"},Lt={class:"text-sm text-gray-900"},Vt={key:1},jt={key:2},It={key:3},Dt={key:4},Et={key:2,class:"text-center py-12"},Tt={__name:"AssetDetailView",setup(Bt){const h=$(),_=F(),{isMobile:a}=q(),y=w(!0),u=w("overview"),r=w(null),N=[{id:"overview",label:"Overview"},{id:"maintenance",label:"Maintenance"},{id:"parts",label:"Parts"},{id:"workorders",label:"Work Orders"},{id:"analytics",label:"Analytics"}],H=R(()=>r.value&&{HVAC:"fire",ELEVATOR:"arrow-up-down",SECURITY:"shield-check",ELECTRICAL:"bolt"}[r.value.category]||"cog"),L=async()=>{y.value=!0,setTimeout(()=>{const n=parseInt(_.params.id),e={1:{id:1,name:"Main HVAC Unit",category:"HVAC",model:"Carrier 30HXC",manufacturer:"Carrier",serialNumber:"HV001234",status:"OPERATIONAL",location:"Roof Level 3",criticality:"HIGH",value:45e3,installDate:"2020-03-15",lastMaintenance:"2024-01-15T10:00:00Z",nextMaintenance:"2024-04-15T10:00:00Z",description:"Primary heating and cooling system for floors 1-3",uptime:"99.2",operatingHours:12500,warrantyActive:!0},2:{id:2,name:"Passenger Elevator",category:"ELEVATOR",model:"Otis Gen2",manufacturer:"Otis",serialNumber:"EL002456",status:"MAINTENANCE",location:"Main Lobby",criticality:"CRITICAL",value:12e4,installDate:"2019-08-20",lastMaintenance:"2024-01-20T14:00:00Z",nextMaintenance:"2024-02-20T14:00:00Z",description:"Main passenger elevator serving all floors",uptime:"98.7",operatingHours:18500,warrantyActive:!1}};r.value=e[n]||null,y.value=!1},1e3)},V=()=>{h.push(`/assets?edit=${r.value.id}`)},j=()=>{h.push(`/work-orders?create=true&assetId=${r.value.id}`)},I=n=>({OPERATIONAL:"success",MAINTENANCE:"warning",DOWN:"error",DECOMMISSIONED:"secondary"})[n]||"default",D=n=>({LOW:"secondary",MEDIUM:"info",HIGH:"warning",CRITICAL:"error"})[n]||"default",E=n=>n.toLowerCase().replace(/\b\w/g,e=>e.toUpperCase()),T=n=>n.toLowerCase().replace(/\b\w/g,e=>e.toUpperCase()),B=n=>n.toLowerCase().replace(/\b\w/g,e=>e.toUpperCase()),f=n=>n?new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"N/A",O=n=>n?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0}).format(n):"N/A",z=n=>{if(!n)return"N/A";const e=new Date(n),C=Math.abs(new Date-e),A=Math.ceil(C/(1e3*60*60*24)),g=Math.floor(A/365),x=Math.floor(A%365/30);return g>0?`${g} year${g>1?"s":""}, ${x} month${x>1?"s":""}`:`${x} month${x>1?"s":""}`};return S(()=>{L()}),(n,e)=>(l(),M(Y,null,{header:c(()=>[m(J,{title:r.value?r.value.name:"Asset Details",description:r.value?r.value.description||"Asset information and details":"Loading asset details...",breadcrumbs:[{text:"Assets",to:"/assets"},{text:r.value?r.value.name:"Loading...",to:null}]},X({_:2},[r.value?{name:"actions",fn:c(()=>[m(s(k),{variant:"secondary",size:"sm",onClick:V},{default:c(()=>[(l(),d("svg",{class:o(["w-4 h-4",s(a)?"":"mr-2"]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},e[1]||(e[1]=[t("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"},null,-1)]),2)),s(a)?(l(),d("span",Q,"Edit")):(l(),d("span",K,"Edit Asset"))]),_:1}),m(s(k),{variant:"primary",size:"sm",onClick:j},{default:c(()=>[(l(),d("svg",{class:o(["w-4 h-4",s(a)?"":"mr-2"]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},e[2]||(e[2]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 6v6m0 0v6m0-6h6m-6 0H6"},null,-1)]),2)),s(a)?(l(),d("span",et,"Work Order")):(l(),d("span",tt,"Create Work Order"))]),_:1})]),key:"0"}:void 0]),1032,["title","description","breadcrumbs"])]),default:c(()=>[t("div",{class:o(s(a)?"px-4 py-6":"px-6 py-8")},[y.value?(l(),d("div",st,e[3]||(e[3]=[t("div",{class:"flex items-center space-x-2 text-gray-500"},[t("svg",{class:"w-8 h-8 animate-spin",fill:"none",viewBox:"0 0 24 24"},[t("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),t("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),t("span",null,"Loading asset details...")],-1)]))):r.value?(l(),d("div",at,[t("div",{class:o(["bg-white shadow rounded-lg",s(a)?"p-4":"p-6"])},[t("div",{class:o(s(a)?"space-y-4":"flex items-start space-x-4")},[t("div",{class:o(["w-16 h-16 bg-blue-100 rounded-lg flex items-center justify-center",s(a)?"mx-auto":""])},[(l(),M(U(H.value),{class:"w-8 h-8 text-blue-600"}))],2),t("div",{class:o(["flex-1",s(a)?"text-center":""])},[t("div",{class:o(s(a)?"flex flex-wrap justify-center gap-2 mb-2":"flex items-center space-x-4 mb-2")},[m(s(b),{variant:I(r.value.status)},{default:c(()=>[p(i(E(r.value.status)),1)]),_:1},8,["variant"]),m(s(b),{variant:D(r.value.criticality)},{default:c(()=>[p(i(T(r.value.criticality)),1)]),_:1},8,["variant"]),t("span",rt,"Asset #"+i(r.value.id),1)],2),t("p",ot,i(r.value.description||"No description available"),1)],2)],2)],2),t("div",{class:o(["grid gap-4",s(a)?"grid-cols-1":"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"])},[t("div",{class:o(["bg-white shadow rounded-lg",s(a)?"p-4":"p-6"])},[t("div",nt,[e[5]||(e[5]=t("div",{class:"flex-shrink-0"},[t("svg",{class:"w-8 h-8 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("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)),t("div",it,[e[4]||(e[4]=t("p",{class:"text-sm font-medium text-gray-500"},"Uptime",-1)),t("p",lt,i(r.value.uptime||"99.2")+"%",1)])])],2),t("div",{class:o(["bg-white shadow rounded-lg",s(a)?"p-4":"p-6"])},[t("div",dt,[e[7]||(e[7]=t("div",{class:"flex-shrink-0"},[t("svg",{class:"w-8 h-8 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})])],-1)),t("div",ct,[e[6]||(e[6]=t("p",{class:"text-sm font-medium text-gray-500"},"Last Maintenance",-1)),t("p",{class:o([s(a)?"text-base":"text-lg","font-semibold text-gray-900"])},i(f(r.value.lastMaintenance)),3)])])],2),t("div",{class:o(["bg-white shadow rounded-lg",s(a)?"p-4":"p-6"])},[t("div",ut,[e[9]||(e[9]=t("div",{class:"flex-shrink-0"},[t("svg",{class:"w-8 h-8 text-yellow-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})])],-1)),t("div",mt,[e[8]||(e[8]=t("p",{class:"text-sm font-medium text-gray-500"},"Next Maintenance",-1)),t("p",{class:o([s(a)?"text-base":"text-lg","font-semibold text-gray-900"])},i(f(r.value.nextMaintenance)),3)])])],2),t("div",{class:o(["bg-white shadow rounded-lg",s(a)?"p-4":"p-6"])},[t("div",vt,[e[11]||(e[11]=t("div",{class:"flex-shrink-0"},[t("svg",{class:"w-8 h-8 text-purple-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})])],-1)),t("div",xt,[e[10]||(e[10]=t("p",{class:"text-sm font-medium text-gray-500"},"Asset Value",-1)),t("p",{class:o([s(a)?"text-base":"text-lg","font-semibold text-gray-900"])},i(O(r.value.value)),3)])])],2)],2),t("div",pt,[t("div",yt,[t("nav",{class:o(["-mb-px flex",s(a)?"overflow-x-auto px-4":"space-x-8 px-6"]),"aria-label":"Tabs"},[(l(),d(W,null,Z(N,v=>t("button",{key:v.id,onClick:C=>u.value=v.id,class:o(["py-4 border-b-2 font-medium text-sm whitespace-nowrap",[u.value===v.id?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300",s(a)?"px-3 flex-shrink-0":"px-1"]])},i(v.label),11,ft)),64))],2)]),t("div",{class:o(s(a)?"p-4":"p-6")},[u.value==="overview"?(l(),d("div",gt,[t("div",{class:o(["grid gap-6",s(a)?"grid-cols-1":"grid-cols-1 lg:grid-cols-2"])},[t("div",null,[t("h3",{class:o([s(a)?"text-base":"text-lg","font-medium text-gray-900 mb-4"])},"Basic Information",2),t("dl",wt,[t("div",{class:o(s(a)?"space-y-1":"flex justify-between")},[e[12]||(e[12]=t("dt",{class:"text-sm font-medium text-gray-500"},"Category",-1)),t("dd",kt,i(B(r.value.category)),1)],2),t("div",{class:o(s(a)?"space-y-1":"flex justify-between")},[e[13]||(e[13]=t("dt",{class:"text-sm font-medium text-gray-500"},"Model",-1)),t("dd",bt,i(r.value.model||"N/A"),1)],2),t("div",{class:o(s(a)?"space-y-1":"flex justify-between")},[e[14]||(e[14]=t("dt",{class:"text-sm font-medium text-gray-500"},"Serial Number",-1)),t("dd",ht,i(r.value.serialNumber||"N/A"),1)],2),t("div",{class:o(s(a)?"space-y-1":"flex justify-between")},[e[15]||(e[15]=t("dt",{class:"text-sm font-medium text-gray-500"},"Location",-1)),t("dd",Ct,i(r.value.location||"N/A"),1)],2),t("div",{class:o(s(a)?"space-y-1":"flex justify-between")},[e[16]||(e[16]=t("dt",{class:"text-sm font-medium text-gray-500"},"Installation Date",-1)),t("dd",At,i(f(r.value.installDate)),1)],2)])]),t("div",null,[t("h3",{class:o([s(a)?"text-base":"text-lg","font-medium text-gray-900 mb-4"])},"Technical Details",2),t("dl",Mt,[t("div",{class:o(s(a)?"space-y-1":"flex justify-between")},[e[17]||(e[17]=t("dt",{class:"text-sm font-medium text-gray-500"},"Manufacturer",-1)),t("dd",_t,i(r.value.manufacturer||"N/A"),1)],2),t("div",{class:o(s(a)?"space-y-1":"flex justify-between")},[e[18]||(e[18]=t("dt",{class:"text-sm font-medium text-gray-500"},"Operating Hours",-1)),t("dd",Nt,i(r.value.operatingHours||"0")+" hrs",1)],2),t("div",{class:o(s(a)?"space-y-1":"flex justify-between")},[e[19]||(e[19]=t("dt",{class:"text-sm font-medium text-gray-500"},"Warranty Status",-1)),t("dd",Ht,[m(s(b),{variant:r.value.warrantyActive?"success":"secondary"},{default:c(()=>[p(i(r.value.warrantyActive?"Active":"Expired"),1)]),_:1},8,["variant"])])],2),t("div",{class:o(s(a)?"space-y-1":"flex justify-between")},[e[20]||(e[20]=t("dt",{class:"text-sm font-medium text-gray-500"},"Asset Age",-1)),t("dd",Lt,i(z(r.value.installDate)),1)],2)])])],2)])):u.value==="maintenance"?(l(),d("div",Vt,e[21]||(e[21]=[t("div",{class:"text-center py-8 text-gray-500"},[t("svg",{class:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("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"})]),t("p",{class:"text-lg font-medium"},"Maintenance History"),t("p",{class:"text-sm mt-1"},"Maintenance records and schedules will be displayed here")],-1)]))):u.value==="parts"?(l(),d("div",jt,e[22]||(e[22]=[t("div",{class:"text-center py-8 text-gray-500"},[t("svg",{class:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})]),t("p",{class:"text-lg font-medium"},"Parts & Inventory"),t("p",{class:"text-sm mt-1"},"Associated parts and spare inventory will be displayed here")],-1)]))):u.value==="workorders"?(l(),d("div",It,e[23]||(e[23]=[t("div",{class:"text-center py-8 text-gray-500"},[t("svg",{class:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})]),t("p",{class:"text-lg font-medium"},"Work Orders"),t("p",{class:"text-sm mt-1"},"Associated work orders and service history will be displayed here")],-1)]))):u.value==="analytics"?(l(),d("div",Dt,e[24]||(e[24]=[t("div",{class:"text-center py-8 text-gray-500"},[t("svg",{class:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})]),t("p",{class:"text-lg font-medium"},"Performance Analytics"),t("p",{class:"text-sm mt-1"},"Performance metrics and analytics will be displayed here")],-1)]))):G("",!0)],2)])])):(l(),d("div",Et,[e[26]||(e[26]=t("svg",{class:"w-12 h-12 mx-auto mb-4 text-red-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),e[27]||(e[27]=t("h3",{class:"text-lg font-medium text-gray-900 mb-2"},"Asset Not Found",-1)),e[28]||(e[28]=t("p",{class:"text-gray-500 mb-4"},"The requested asset could not be found.",-1)),m(s(k),{onClick:e[0]||(e[0]=v=>n.$router.push("/assets"))},{default:c(()=>e[25]||(e[25]=[p(" Back to Assets ",-1)])),_:1,__:[25]})]))],2)]),_:1}))}},St=P(Tt,[["__scopeId","data-v-13b68a20"]]);export{St as default};