import{_ as B}from"./index-49332ae1.js";import{d as R,g as U,ap as f,w as J,y as K,b6 as X,a as u,f as h,e as o,b as n,h as l,F as Z,r as A,c as y,aR as G,J as m,aX as W,ac as j,t as v,C as $,K as ee,aq as ae,M as D,a0 as te,P as oe,Y as le,aQ as re,_ as ne,Z as se,aF as ie,aH as pe,av as ce,aC as de}from"./index-3ac32eb9.js";import{b as ue,I as me,S as fe}from"./index-626b746e.js";import{Q as ye}from"./index-0be687a1.js";import{_ as ge}from"./_plugin-vue_export-helper-c27b6911.js";const _e=R({__name:"PlatformLog",setup(Pe){const e=ee({loading:!1,listData:[],paginationData:{total:0},projectOptions:[],projectMap:{},queryParams:{currentPage:1,pageSize:10,projectId:void 0,account:""}}),i=U([f().subtract(3,"day").startOf("day").format("YYYY-MM-DD HH:mm:ss"),f().endOf("day").format("YYYY-MM-DD HH:mm:ss")]),S={0:"信息",1:"告警",2:"故障"},{loading:q,listData:O,paginationData:b,projectOptions:Y,projectMap:M}=ae(e),p=e.queryParams;function k(r){return r?f(r).format("YYYY-MM-DD HH:mm:ss"):""}async function x(){try{const t=(await ye({currentPage:1,pageSize:999})).data.list||[];e.projectOptions=[];for(const s of t){const g=s.projectId??"";e.projectOptions.push({label:s.projectName,value:g}),e.projectMap[String(g)]=s.projectName}e.projectOptions.length>0&&!e.queryParams.projectId&&(e.queryParams.projectId=e.projectOptions[0].value)}catch{}}async function c(){e.loading=!0;const r={currentPage:e.queryParams.currentPage,pageSize:e.queryParams.pageSize};e.queryParams.projectId&&(r.projectId=e.queryParams.projectId),i.value&&i.value.length===2&&(r.startTime=f(i.value[0]).startOf("day").valueOf(),r.endTime=f(i.value[1]).endOf("day").valueOf());try{const s=(await ue(r)).data;e.listData=s.list||[],e.paginationData.total=s.total||0}finally{e.loading=!1}}async function C(){try{e.loading=!0,await me(),D.success("IOT数据同步已触发"),await c()}finally{e.loading=!1}}async function T(){try{e.loading=!0,await fe(),D.success("实时数据同步已触发"),await c()}finally{e.loading=!1}}function E(){e.queryParams.currentPage=1,e.queryParams.pageSize=10,e.queryParams.projectId=e.projectOptions.length>0?e.projectOptions[0].value:void 0,i.value=[],c()}function z(r){e.queryParams.pageSize=r}let I=!0;return J(()=>e.queryParams.projectId,r=>{!I&&r&&(e.queryParams.currentPage=1,c())}),K(async()=>{await x(),e.queryParams.projectId&&c(),I=!1}),(r,t)=>{const s=te,g=oe,P=le,H=re,_=ne,L=se,d=ie,V=pe,Q=B,F=ce,w=X("hasPerm"),N=de;return u(),h("div",null,[o(F,{shadow:"always","body-style":{padding:"12px"}},{default:n(()=>[o(L,{model:l(p),inline:"","label-width":"80px",class:"log-filter-form"},{default:n(()=>[o(P,{label:"项目",class:"filter-item"},{default:n(()=>[o(g,{modelValue:l(p).projectId,"onUpdate:modelValue":t[0]||(t[0]=a=>l(p).projectId=a),placeholder:"选择项目",style:{width:"180px"}},{default:n(()=>[(u(!0),h(Z,null,A(l(Y),a=>(u(),y(s,{key:a.value,label:a.label,value:a.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),o(P,{label:"日期",class:"filter-item"},{default:n(()=>[o(H,{modelValue:i.value,"onUpdate:modelValue":t[1]||(t[1]=a=>i.value=a),type:"daterange","range-separator":"至","start-placeholder":"开始日期","end-placeholder":"结束日期","value-format":"YYYY-MM-DD HH:mm:ss",style:{width:"320px"}},null,8,["modelValue"])]),_:1}),o(P,{class:"filter-actions"},{default:n(()=>[o(_,{type:"primary",icon:l(G),onClick:c},{default:n(()=>[...t[4]||(t[4]=[m("查询",-1)])]),_:1},8,["icon"]),o(_,{onClick:E,icon:l(W)},{default:n(()=>[...t[5]||(t[5]=[m("重置",-1)])]),_:1},8,["icon"]),j((u(),y(_,{type:"success",onClick:C},{default:n(()=>[...t[6]||(t[6]=[m("IOT数据同步",-1)])]),_:1})),[[w,["sys:log:edit"]]]),j((u(),y(_,{type:"success",onClick:T},{default:n(()=>[...t[7]||(t[7]=[m("实时数据同步",-1)])]),_:1})),[[w,["sys:log:edit"]]])]),_:1})]),_:1},8,["model"]),j((u(),y(V,{data:l(O),"show-overflow-tooltip":!0,border:"",stripe:"",style:{width:"100%","margin-top":"12px"}},{default:n(()=>[o(d,{label:"序号",type:"index",width:"60",align:"center"}),o(d,{prop:"projectId",label:"项目",width:"160",align:"center"},{default:n(({row:a})=>[m(v(l(M)[String(a.projectId)]??(a.projectId===""?"物联平台":a.projectId)),1)]),_:1}),o(d,{prop:"timestamp",label:"时间",width:"180",align:"center"},{default:n(({row:a})=>[m(v(k(a.timestamp)),1)]),_:1}),o(d,{prop:"type",label:"类型",width:"120",align:"center"},{default:n(({row:a})=>[m(v(S[a.type]??a.type),1)]),_:1}),o(d,{prop:"content",label:"内容","min-width":"300"}),o(d,{prop:"source",label:"来源",width:"160",align:"center"}),o(d,{prop:"remark",label:"备注","min-width":"200"})]),_:1},8,["data"])),[[N,l(q)]]),l(b).total>0?(u(),y(Q,{key:0,total:l(b).total,page:l(p).currentPage,"onUpdate:page":t[2]||(t[2]=a=>l(p).currentPage=a),limit:l(p).pageSize,"onUpdate:limit":[t[3]||(t[3]=a=>l(p).pageSize=a),z],onPagination:c},null,8,["total","page","limit"])):$("",!0)]),_:1})])}}});const he=ge(_e,[["__scopeId","data-v-7c8fd862"]]);export{he as default};
