Log-9c25959b.js 5.7 KB

1
  1. import{d as F,r as v,a as U,o as O,z as q,p as G,w as W,c as h,n as K,b,e as f,f as I,u as Q,j as y,F as X,x as Y,k as Z,t as $,B as P}from"./index-ddf66cb5.js";import{B as ee}from"./index-58f6bbe0.js";import{P as te}from"./index-4290e6be.js";import{S as oe}from"./index-14ec4a94.js";import{C as ne}from"./index-e270b3af.js";import{C as se}from"./CusNavigation-52f261c8.js";import{p as le}from"./index-f5e64579.js";import{t as ae}from"./index-9c8b4e4e.js";import{u as ie}from"./use-scope-id-7611483c.js";import{c as ce,m as de,z as S,O as re,w as ue}from"./index-e9453d64.js";import{L as pe}from"./index-856231c7.js";import"./index-c1d3cef3.js";import"./on-popup-reopen-8ab517b6.js";import"./use-route-0a2b7081.js";import"./axios-1779699b.js";import"./function-call-0875a39e.js";import"./mount-component-8daea98e.js";const[me,D]=ce("text-ellipsis"),fe={rows:de(1),dots:S("..."),content:S(""),expandText:S(""),collapseText:S(""),position:S("end")};var ve=F({name:me,props:fe,emits:["clickAction"],setup(o,{emit:E,slots:n}){const r=v(o.content),l=v(!1),u=v(!1),N=v(),k=v();let M=!1;const C=U(()=>l.value?o.collapseText:o.expandText),L=e=>{if(!e)return 0;const t=e.match(/^\d*(\.\d*)?/);return t?Number(t[0]):0},s=()=>{if(!N.value||!N.value.isConnected)return;const e=window.getComputedStyle(N.value),t=document.createElement("div");return Array.prototype.slice.apply(e).forEach(d=>{t.style.setProperty(d,e.getPropertyValue(d))}),t.style.position="fixed",t.style.zIndex="-9999",t.style.top="-9999px",t.style.height="auto",t.style.minHeight="auto",t.style.maxHeight="auto",t.innerText=o.content,document.body.appendChild(t),t},a=(e,t)=>{var T,d;const{content:p,position:z,dots:H}=o,w=p.length,V=0+w>>1,j=n.action?(d=(T=k.value)==null?void 0:T.outerHTML)!=null?d:"":o.expandText,J=()=>{const i=(c,_)=>{if(_-c<=1)return z==="end"?p.slice(0,c)+H:H+p.slice(_,w);const m=Math.round((c+_)/2);return z==="end"?e.innerText=p.slice(0,m)+H:e.innerText=H+p.slice(m,w),e.innerHTML+=j,e.offsetHeight>t?z==="end"?i(c,m):i(m,_):z==="end"?i(m,_):i(c,m)};return i(0,w)},R=(i,c)=>{if(i[1]-i[0]<=1&&c[1]-c[0]<=1)return p.slice(0,i[0])+H+p.slice(c[1],w);const _=Math.floor((i[0]+i[1])/2),m=Math.ceil((c[0]+c[1])/2);return e.innerText=o.content.slice(0,_)+o.dots+o.content.slice(m,w),e.innerHTML+=j,e.offsetHeight>=t?R([i[0],_],[m,c[1]]):R([_,i[1]],[c[0],m])};return o.position==="middle"?R([0,V],[V,w]):J()},g=()=>{const e=s();if(!e){M=!0;return}const{paddingBottom:t,paddingTop:T,lineHeight:d}=e.style,p=Math.ceil((Number(o.rows)+.5)*L(d)+L(T)+L(t));p<e.offsetHeight?(u.value=!0,r.value=a(e,p)):(u.value=!1,r.value=o.content),document.body.removeChild(e)},x=(e=!l.value)=>{l.value=e},A=e=>{x(),E("clickAction",e)},B=()=>{const e=n.action?n.action({expanded:l.value}):C.value;return h("span",{ref:k,class:D("action"),onClick:A},[e])};return O(()=>{g(),n.action&&q(g)}),G(()=>{M&&(M=!1,g())}),W([re,()=>[o.content,o.rows,o.position]],g),ie({toggle:x}),()=>h("div",{ref:N,class:D()},[l.value?o.content:r.value,u.value?B():null])}});const ge=ue(ve);const _e={style:{display:"flex","flex-direction":"column",height:"100vh"}},xe={class:"container",style:{"overflow-y":"auto","flex-grow":"1"}},ye={style:{"text-align":"left"}},he={style:{display:"flex","justify-content":"space-between","margin-bottom":"5px"}},ke={style:{"font-size":"0.9rem",color:"#000","font-weight":"bold"}},Te={style:{display:"flex","align-items":"flex-end"}},we={style:{width:"100%","word-wrap":"break-word","text-align":"justify"}},be={key:0},Ne={key:1,style:{"text-align":"center",padding:"20px",color:"#ccc"}},Ce={key:2,style:{"text-align":"center",padding:"20px"}},Me={key:3,style:{"text-align":"center",padding:"20px",color:"#ccc"}},Le={key:4,style:{"text-align":"center",padding:"20px"}},Ge=F({__name:"Log",setup(o){const E=Q(),n=K({total:0,pageNum:1,pageSize:10,pages:0}),r=v([]),l=v(!1),u=v(!1),N=v(!1),k=()=>{console.log("onload....."),le({url:"/device/searchRecord",data:{size:n.pageSize,page:n.pageNum,sort:"createtime",order:"desc",keyWord:C.value,mac:""}}).then(s=>{if(console.log(s),u.value=!1,l.value=!1,s.code==0){const a=s.data,g=s.total,x=Math.ceil(g/n.pageSize);console.log(x),console.log(a),n.pageNum==1&&r.value.splice(0,r.value.length),r.value.push(...a),n.pages=x,n.total=g,console.log(r.value,x)}},s=>{console.log(s),u.value=!1,l.value=!1}).catch(s=>{console.log(s),u.value=!1,l.value=!1})},M=()=>{console.log("onrefresh..."),console.log(l.value),n.pageNum=1,N.value=!1,u.value=!0,k()},C=v("");W(()=>E.currentRoute.value.params,(s,a)=>{console.log("路由参数发生了变化",s,a),s.deviceId&&(C.value=s.deviceId,k())}),O(()=>{console.log("onMounted"),C.value=E.currentRoute.value.params.deviceId,k()});const L=()=>{console.log("clickLoading"),n.pageNum++,u.value=!0,k()};return(s,a)=>{const g=se,x=ge,A=ne,B=oe,e=pe,t=te,T=ee;return y(),b("div",_e,[h(g,{gobackabled:"",title:"设备日志("+C.value+")"},null,8,["title"]),f("div",xe,[h(t,{style:{"min-height":"100%"},modelValue:l.value,"onUpdate:modelValue":a[0]||(a[0]=d=>l.value=d),onRefresh:M},{default:I(()=>[(y(!0),b(X,null,Y(r.value,d=>(y(),Z(B,{style:{"background-color":"#fff","margin-bottom":"10px"}},{default:I(()=>[h(A,{clickable:""},{default:I(()=>[f("div",ye,[f("div",he,[f("div",ke,$(P(ae)(d.time)),1)]),f("div",Te,[f("div",we,[h(x,{rows:5,content:JSON.stringify(d)},null,8,["content"])])])])]),_:2},1024)]),_:2},1024))),256)),f("div",null,[l.value?(y(),b("div",be)):r.value.length==0?(y(),b("div",Ne,a[1]||(a[1]=[f("span",null,"暂无数据",-1)]))):u.value?(y(),b("div",Ce,[h(e,{type:"spinner",color:"#1989fa"})])):n.pages<=n.pageNum?(y(),b("div",Me,a[2]||(a[2]=[f("span",null,"没有更多了",-1)]))):(y(),b("div",Le,[f("span",{onClick:L},"点击加载")]))])]),_:1},8,["modelValue"]),h(T,{target:".container",right:"5vw",bottom:"80px"})])])}}});export{Ge as default};