import{j as e,F as u,a as r,_ as w,L as x}from"./index-b983ad9b.js";import{R as f,r as l}from"./react-b0e0d18a.js";/* empty css                *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              */import{R as C}from"./Room-7ae51b0a.js";/* empty css              *//* empty css              *//* empty css              *//* empty css              */import{E as z,s as O,a as P,f as g}from"./index.module-32df86df.js";import{R as L,a as h,T as A,b as N}from"./antd-8ca2e36c.js";/* empty css              */function B({roomId:i,relativeTo:n}){var c,s,a,v,b,R,y,_,I;const[t,d]=f.useState(),[o,m]=f.useState();return f.useEffect(()=>{if(!i)return;let S=!0;return(async()=>{try{const p=await C.findByPk(i);let E;n&&(E=await C.findByPk(n)),S&&(d(p),n&&m(E))}catch(p){console.debug(p)}})(),()=>{S=!1}},[i,n]),t?r("div",{children:[(!o||((s=(c=o.building)==null?void 0:c.area)==null?void 0:s.id)!==((v=(a=t.building)==null?void 0:a.area)==null?void 0:v.id))&&e("div",{style:{fontSize:"80%"},children:(R=(b=t.building)==null?void 0:b.area)==null?void 0:R.name}),(!o||((y=o.building)==null?void 0:y.id)!==((_=t.building)==null?void 0:_.id))&&e("div",{style:{fontSize:"80%"},children:(I=t.building)==null?void 0:I.name}),`${t.code?t.code+(t.name?` (${t.name})`:""):t.name||""}`]}):e(u,{children:"--"})}const F=l.lazy(()=>w(()=>import("./index-b8c193a6.js"),["./index-b8c193a6.js","./index-b983ad9b.js","./react-b0e0d18a.js","./antd-8ca2e36c.js","./index-a8abcf49.css","./Room-7ae51b0a.js","./Room-74d2f679.css","./TimeoutItem-6cca4419.js","./index-154ab312.css","./default-76b7cd8d.css","./index-9368394d.css","./index-804d7e9f.css","./index-d63cb525.css","./index-8777399d.css","./index-3c2820ea.css"],import.meta.url)),M=l.lazy(()=>w(()=>import("./index-3a6ab207.js"),["./index-3a6ab207.js","./index-b983ad9b.js","./react-b0e0d18a.js","./antd-8ca2e36c.js","./index-a8abcf49.css","./Room-7ae51b0a.js","./Room-74d2f679.css","./TimeoutItem-6cca4419.js","./index-154ab312.css","./default-76b7cd8d.css","./index-9368394d.css","./index-804d7e9f.css","./index-d63cb525.css","./index-8777399d.css","./index-3c2820ea.css"],import.meta.url)),j=[{title:"编号",dataIndex:"id",key:"id",render:i=>e(N,{children:`#${i}`})},{title:"发生时间",dataIndex:"createdAt",key:"createdAt",render:i=>e(u,{children:i&&g(i)})},{title:"事件",key:"name",render:(i,{name:n,rule:t,isFalse:d})=>r(u,{children:[n," ",t," ",d&&e(N,{children:"误报"})]})},{title:"位置",dataIndex:"roomId",key:"location",render:i=>e(B,{roomId:i})},{title:"响应?",key:"isAnswered",render:(i,{responder:n,respondedAt:t})=>t?r("div",{children:[n==null?void 0:n.name,e("br",{}),e("small",{children:g(t)})]}):e("div",{children:"尚未响应"})},{title:"处置?",key:"isHandled",render:(i,{handler:n,handledAt:t})=>t?r("div",{children:[n==null?void 0:n.name,e("br",{}),e("small",{children:g(t)})]}):e("div",{children:"尚未处置"})}];function $({result:i,onPageChange:n}){const[t,d]=l.useState();return r(u,{children:[e(A,{size:"small",rowKey:"id",rowClassName:({isFalse:o})=>o?O["false-row"]:"",columns:j,dataSource:i.items,onRow:o=>({onClick:()=>{d(o)}}),pagination:{size:"small",style:{marginBottom:16},position:["topCenter","bottomCenter"],current:Math.floor(i.st/i.pp)+1,pageSize:i.pp,total:i.total,onChange:(o,m)=>{n&&n((o-1)*m,m)}}}),e(P,{event:t,onCancel:()=>d(void 0)})]})}const k=["gsen.admin","gsen.room_admin"];function oe(){const[i,n]=l.useState({}),[t,d]=l.useState({st:0,pp:15}),[o,m]=l.useState({total:0,items:[],st:0,pp:15});l.useEffect(()=>{let s=!0;return z.findAndCountAll({...i,...t,type:"expression"}).then(a=>{s&&m({st:0,pp:15,...a})}),()=>{s=!1}},[i,t]);const c=(s,a)=>{a==="room"?n({roomId:s,buildingId:i.buildingId}):a==="building"?n({buildingId:s}):s===void 0&&n({})};return e("div",{className:O.page,children:r(L,{style:{flexWrap:"nowrap"},children:[r(h,{flex:"none",className:"building-list",children:[e("div",{className:"section-title",children:"楼宇"}),e("div",{className:"section-content",children:e(l.Suspense,{fallback:e(x,{}),children:e(F,{permissions:k,value:i.buildingId,onChange:c})})})]}),i.buildingId&&r(h,{flex:"none",className:"room-list",children:[e("div",{className:"section-title",children:"房间"}),e("div",{className:"section-content",style:{maxWidth:240},children:e(l.Suspense,{fallback:e(x,{}),children:e(M,{withAll:!0,permissions:k,buildingId:i.buildingId,value:i.roomId,onChange:c})})})]}),r(h,{flex:"auto",children:[e("div",{className:"section-title",children:"事件记录"}),e("div",{className:"section-content",style:{padding:12},children:e($,{result:o,onPageChange:(s,a)=>{d({st:s,pp:a})}})})]})]})})}export{oe as default};
