物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
7.5 KiB

  1. import{p as ge,d as he,B as A,s as L,c as R,D as P,t as z,x as U,o as w,b,F as pe,r as ye,n as g,e as C,K as V,g as M,v as ve,Q as we}from"./index-bVOhw2NF.js";function be(e){return{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regExp","[object Undefined]":"undefined","[object Null]":"null","[object Object]":"object"}[Object.prototype.toString.call(e)]}function I(e){const n=be(e);let o;if(n==="array")o=[];else if(n==="object")o={};else return e;if(n==="array")for(let i=0;i<e.length;i++)o.push(I(e[i]));else if(n==="object")for(const i in e)o[i]=I(e[i]);return o}function K(e,n){for(const o in n){if(e[o]&&typeof e[o]=="object"){K(e[o],n[o]);continue}if(typeof n[o]=="object"){e[o]=I(n[o]);continue}e[o]=n[o]}return e}function Ce(e,n,o){let i;function s(){const r=this,a=arguments;function l(){i&&clearTimeout(i)}function c(){e.apply(r,a)}l(),i=setTimeout(c,n)}return s}function ke(e,n){return Ce(e,n)}function Se(e,n,o){const i=L(null),s=P({width:0,height:0});let r=null;function a(l=!0){we().then(()=>{const c=i.value;s.width=c?c.clientWidth:0,s.height=c?c.clientHeight:0,c?(!s.width||!s.height)&&console.warn("fei-datav: Component width or height is 0px, rendering abnormality may occur!"):console.warn("fei-datav: Failed to get dom node, component rendering may be abnormal!"),typeof o=="function"&&l&&o()})}return z([e,n],()=>{r&&r()}),ve(()=>{setTimeout(()=>{a()},500),r=ke(a,100)}),{domRef:i,...A(s),resize:a}}const je=he({name:"EsScrollRankTable",props:{options:{type:Object,default:()=>({})},datasets:{type:[Object,Array],default:()=>[]},element:{type:Object,default:()=>({})}},emits:["mouseover","click"],setup(e){const{rowNum:n,waitTime:o=2e3,color:i,textColor:s,fontSize:r,rankColumnStyle:a,insideColumnStyle:l,carousel:c,unit:k,enableCarousel:T,showRank:H,nameColor:Q,valueColor:q,unitColor:G,showRatio:J,ratioColor:X,rankFormat:Y,ratioSpace:Z,divideInsideColumn:_,fontFamily:ee,fontColor:ne,fontStyle:te,gradientFontColor:oe,dividerWidth:ie,dividerSpace:re,dividerBack:ae,numberColor:le}=A(e.options),se=L([]),O=R(()=>Number.parseInt(e.element.width)||0),B=R(()=>Number.parseInt(e.element.height)||0),D=R(()=>({data:e.datasets.map(u=>({name:u.category,value:u.data1})),rowNum:n.value,waitTime:Number.parseInt(o.value),carousel:c.value,unit:k.value,sort:!0,valueFormatter:null,color:i.value,textColor:s.value,fontSize:r.value}));function N(){S(),de(),fe(),me(),x(!0)}const{domRef:ue,height:ce}=Se(O,B,N),E=L({data:[],rowNum:5,waitTime:2e3,carousel:"single",unit:"",sort:!0,valueFormatter:null,textColor:"#fff",color:"#1370fb",fontSize:13}),t=P({mergedConfig:null,rowsData:[],rows:[],heights:[],avgHeight:0,animationIndex:0,animationHandler:"",updater:0});z(D,()=>{S(),N()},{deep:!0}),U(()=>{S()});function de(){t.mergedConfig=K(I(E.value),D.value||{})}function fe(){let{data:u}=t.mergedConfig;const{rowNum:h,sort:f}=t.mergedConfig;f&&u.sort(({value:d},{value:v})=>d>v?-1:d<v?1:0);const m=u.map(({value:d})=>d),j=Math.min(...m)||0,p=Math.abs(j),$=(Math.max(...m)||0)+p;u=u.map((d,v)=>({...d,ranking:v+1,percent:(d.value+p)/$*100}));const y=u.length;y>h&&y<2*h&&(u=[...u,...u]),u=u.map((d,v)=>({...d,scroll:v})),t.rowsData=u,t.rows=u}function me(u=!1){const{rowNum:h,data:f}=t.mergedConfig,m=ce.value/h;t.avgHeight=m,u||(t.heights=Array.from({length:f.length}).fill(m))}const W=R(()=>t.mergedConfig.carousel==="single");async function x(u=!1){if(!T.value)return;const{waitTime:h,rowNum:f}=t.mergedConfig,m=t.rowsData.length;if(f>=m)return;const{updater:j}=t;if(u&&(await new Promise(y=>setTimeout(y,h)),j!==t.updater))return;const p=W.value?1:f,F=t.rowsData.slice(t.animationIndex);if(F.push(...t.rowsData.slice(0,t.animationIndex)),t.rows=F.slice(0,W.value?f+1:f*2),t.heights=Array.from({length:t.rows.length}).fill(t.avgHeight),await new Promise(y=>setTimeout(y,300)),j!==t.updater)return;t.heights.splice(0,p,...new Array(p).fill(0)),t.animationIndex+=p;const $=t.animationIndex-m;$>=0&&(t.animationIndex=$),t.animationIndex+=p,t.animationHan