Log-789fb40b.js 5.7 KB

1
  1. import{d as F,r as v,a as U,o as J,y as W,p as q,w as K,c as h,z as G,b,e as f,f as I,u as Q,j as y,F as X,x as Y,k as Z,t as $,s as P}from"./index-9e59d463.js";import{B as ee}from"./index-8b39e8f7.js";import{P as te}from"./index-522329b6.js";import{S as oe}from"./index-cebe9fb2.js";import{C as ne}from"./index-d3685543.js";import{C as se}from"./CusNavigation-947968be.js";import{p as le}from"./index-eb142598.js";import{t as ae}from"./index-9c8b4e4e.js";import{u as ie}from"./use-scope-id-5881aa3d.js";import{c as ce,m as de,y as S,K as re,w as ue}from"./index-706bc599.js";import{L as pe}from"./index-40a7d995.js";import"./index-97e235af.js";import"./constant-7967f80c.js";import"./on-popup-reopen-0a926119.js";import"./use-route-93ca5788.js";import"./axios-1779699b.js";import"./function-call-117cf651.js";import"./mount-component-f07cef55.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:A,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,O=()=>{const i=(c,_)=>{if(_-c<=1)return A==="end"?p.slice(0,c)+H:H+p.slice(_,w);const m=Math.round((c+_)/2);return A==="end"?e.innerText=p.slice(0,m)+H:e.innerText=H+p.slice(m,w),e.innerHTML+=j,e.offsetHeight>t?A==="end"?i(c,m):i(m,_):A==="end"?i(m,_):i(c,m)};return i(0,w)},B=(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?B([i[0],_],[m,c[1]]):B([_,i[1]],[c[0],m])};return o.position==="middle"?B([0,V],[V,w]):O()},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},R=e=>{x(),E("clickAction",e)},z=()=>{const e=n.action?n.action({expanded:l.value}):C.value;return h("span",{ref:k,class:D("action"),onClick:R},[e])};return J(()=>{g(),n.action&&W(g)}),q(()=>{M&&(M=!1,g())}),K([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?z():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=G({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",mac:C.value}}).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("");K(()=>E.currentRoute.value.params,(s,a)=>{console.log("路由参数发生了变化",s,a),s.deviceId&&(C.value=s.deviceId,k())}),J(()=>{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,R=ne,z=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(z,{style:{"background-color":"#fff","margin-bottom":"10px"}},{default:I(()=>[h(R,{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};