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 lines
12 KiB
1 lines
12 KiB
import{p as Ee,d as Fe,B as Q,c as P,s as he,D as de,t as V,v as ge,x as Ie,o as T,b as k,n as W,F as q,r as U,g as ue,Q as Be}from"./index-bVOhw2NF.js";function Oe(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 E(e){const a=Oe(e);let o;if(a==="array")o=[];else if(a==="object")o={};else return e;if(a==="array")for(let l=0;l<e.length;l++)o.push(E(e[l]));else if(a==="object")for(const l in e)o[l]=E(e[l]);return o}function A(e,a){for(const o in a){if(e[o]&&typeof e[o]=="object"){A(e[o],a[o]);continue}if(typeof a[o]=="object"){e[o]=E(a[o]);continue}e[o]=a[o]}return e}function Pe(e,a,o){let l;function m(){const g=this,r=arguments;function h(){l&&clearTimeout(l)}function n(){e.apply(g,r)}h(),l=setTimeout(n,a)}return m}function fe(e,a){return Pe(e,a)}function qe(e,a,o){const l=he(null),m=de({width:0,height:0});let g=null;function r(h=!0){Be().then(()=>{const n=l.value;m.width=n?n.clientWidth:0,m.height=n?n.clientHeight:0,n?(!m.width||!m.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"&&h&&o()})}return V([e,a],()=>{g&&g()}),ge(()=>{setTimeout(()=>{r()},500),g=fe(r,100)}),{domRef:l,...Q(m),resize:r}}const Ue=["列1","列2","列3"],Qe=[["行1列1","行1列2","行1列3"],["行2列1","行2列2","行2列3"],["行3列1","行3列2","行3列3"],["行4列1","行4列2","行4列3"],["行5列1","行5列2","行5列3"],["行6列1","行6列2","行6列3"],["行7列1","行7列2","行7列3"],["行8列1","行8列2","行8列3"],["行9列1","行9列2","行9列3"],["行10列1","行10列2","行10列3"]],Ve=Fe({name:"EsScrollTable",props:{options:{type:Object,default:()=>({})},datasets:{type:[Object,Array],default:()=>[]},element:{type:Object,default:()=>({})}},emits:["mouseover","itemClick"],setup(e,{emit:a}){const{rowNum:o,headerBGC:l,oddRowBGC:m,evenRowBGC:g,waitTime:r,headerHeight:h,columnWidth:n,align:v,index:f,carousel:y,hoverPause:H,fontColor:R,headerFontColor:$,oddRowGradBG:b,evenRowGradBG:w,enableBorder:M,borderColor:L,enableCarousel:X,fontSize:ce,headerFontSize:me,onlyHeaderHoriBorder:pe,onlyOuterBorder:ve,onlyHeaderBorder:be,onlyBodyBorder:$e,bodyBorderStyle:we,onlyHoriBorder:Ce,tableBGC:He,clickHighlight:Y,highlightBGC:ye,highlightGradBG:Ge,highlightNumber:J,highlightFontColor:je}=Q(e.options),F=P(()=>{var u,p;const t=n.value.map(c=>c.colW),s=v.value.map(c=>c.align);return{header:((u=e.datasets)==null?void 0:u.headerDatas)||Ue,data:((p=e.datasets)==null?void 0:p.tableDatas)||Qe,rowNum:o.value,waitTime:r.value,headerBGC:l.value,oddRowBGC:m.value||b.value,evenRowBGC:g.value||w.value,headerHeight:h.value,columnWidth:t,align:s,index:f.value,carousel:y.value,hoverPause:H.value}}),K=P(()=>Number.parseInt(e.element.width)||0),Z=P(()=>Number.parseInt(e.element.height)||0),_=he({header:[],data:[],rowNum:5,headerBGC:"#00BAFF",oddRowBGC:"#003B51",evenRowBGC:"#0A2732",waitTime:2e3,headerHeight:35,columnWidth:[],align:[],index:!1,indexHeader:"#",carousel:"single",hoverPause:!0});function ee(){D(),Ne(),De(),Me(),ie(),oe(),Se(),N(!0)}const{domRef:Re,width:te,height:ne,resize:Te}=qe(K,Z,ee),i=de({mergedConfig:null,header:[],rowsData:[],rows:[],widths:[],heights:[],avgHeight:0,aligns:[],animationIndex:0,animationHandler:"",updater:0,needCalc:!1});function ke(t,s,u,p,c){t&&se("mouseover",s,u,p,c),i.mergedConfig.hoverPause&&(t?D():N(!0))}function xe(){i.mergedConfig&&(D(),ie(),oe(!0),N(!0))}function Ne(){i.mergedConfig=A(E(_.value),F.value||{})}function De(){let{header:t,index:s,indexHeader:u}=i.mergedConfig;if(!t.length){i.header=[];return}t=[...t],s&&t.unshift(u),i.header=t}function Me(){let{data:t,index:s,headerBGC:u,rowNum:p}=i.mergedConfig;s&&(t=t.map((d,C)=>{d=[...d];const G=`<span class="index" style="background-color: ${u};">${C+1}</span>`;return d.unshift(G),d})),t=t.map((d,C)=>({cells:d,rowIndex:C}));const c=t.length;c>p&&c<2*p&&(t=[...t,...t]),t=t.map((d,C)=>({...d,scroll:C})),i.rowsData=t,i.rows=t}function ie(){const{mergedConfig:t,rowsData:s}=i,{columnWidth:u,header:p}=t,c=u.reduce((S,j)=>S+j,0);let d=0;s[0]?d=s[0].cells.length:p.length&&(d=p.length);const C=(te.value-c)/(d-u.length),G=Array.from({length:d}).fill(C);i.widths=A(G,u)}function oe(t=!1){const{mergedConfig:s,header:u}=i,{headerHeight:p,rowNum:c,data:d}=s;let C=ne.value;u.length&&(C-=p);const G=C/c;i.avgHeight=G,t||(i.heights=Array.from({length:d.length}).fill(G))}function Se(){const{header:t,mergedConfig:s}=i,u=t.length,p=Array.from({length:u}).fill("left"),{align:c}=s;i.aligns=A(p,c)}async function N(t=!1){if(!X.value)return;const{needCalc:s,calcHeights:u,calcRowsData:p}=i;s&&(p(),u(),i.needCalc=!1);let{avgHeight:c,animationIndex:d,mergedConfig:C,rowsData:G,updater:S}=i;const{waitTime:j,carousel:x,rowNum:z}=C,I=G.length;if(z>=I||t&&(await new Promise(O=>setTimeout(O,j)),S!==i.updater))return;const B=x==="single"?1:z,le=G.slice(d);if(le.push(...G.slice(0,d)),i.rows=le.slice(0,x==="page"?z*2:z+1),i.heights=Array.from({length:I}).fill(c),await new Promise(O=>setTimeout(O,300)),S!==i.updater)return;i.heights.splice(0,B,...Array.from({length:B}).fill(0)),d+=B;const re=d-I;re>=0&&(d=re),i.animationIndex=d,i.animationHandler=setTimeout(N,j-300)}function D(){const{animationHandler:t,updater:s}=i;i.updater=(s+1)%999999,t&&clearTimeout(t)}function se(t,s,u,p,c){a(t,s,u,p,c)}const We=(t,s,u,p,c)=>{Y.value&&i.rows.forEach((d,C)=>{C===s?d.isHighlight=!0:d.isHighlight=!1}),a(t,s,u,p,c)};function Le(t,s){const{animationHandler:u}={...mergedConfig,data:[...t]};i.needCalc=!0,typeof s=="number"&&(i.animationIndex=s),u||N(!0)}V(()=>F.value,()=>{D(),i.animationIndex=0,ee()},{deep:!0}),V(J,t=>{t>-1&&(i.animationIndex=t,N(!1),i.rows.length<=F.value.rowNum?i.rows.forEach((s,u)=>{u===t?s.isHighlight=!0:s.isHighlight=!1}):i.rows.forEach((s,u)=>{u===0?s.isHighlight=!0:s.isHighlight=!1}),D(),setTimeout(()=>{D(),N(!0)},3e3))});const ae=t=>{if(!t.target.closest(".bv-scroll-table")){const p=document.querySelector(".scroll-table-tooltip");p&&p.remove()}},ze=fe((t,s,u,p,c)=>{const d=t.pageX,C=t.pageY,G=t.target.offsetWidth,S=t.target.scrollWidth;if(G<S){const j=document.querySelector(".scroll-table-tooltip");if(j)j.innerHTML=c.val||c,j.style.top=`${C+10}px`,j.style.left=`${d+15}px`;else{const x=document.createElement("span");x.className="scroll-table-tooltip",x.innerHTML=c.val||c,x.style.top=`${C+10}px`,x.style.left=`${d+15}px`,document.body.appendChild(x)}}else{const j=document.querySelector(".scroll-table-tooltip");j&&j.remove()}},200);ge(()=>{document.body.addEventListener("mousemove",ae)}),Ie(()=>{D(),document.body.removeEventListener("mousemove",ae)});const Ae=t=>typeof t=="object"?t.val:t;return{defaultConfig:_,...Q(i),containerWidth:K,containerHeight:Z,domRef:Re,width:te,height:ne,resize:Te,updateRows:Le,handleHover:ke,onResize:xe,emitEvent:se,clickHandler:We,handleMove:ze,getCellContent:Ae,headerBGC:l,oddRowBGC:m,evenRowBGC:g,waitTime:r,headerHeight:h,columnWidth:n,align:v,index:f,carousel:y,hoverPause:H,fontColor:R,headerFontColor:$,oddRowGradBG:b,evenRowGradBG:w,enableBorder:M,borderColor:L,enableCarousel:X,fontSize:ce,headerFontSize:me,onlyHeaderHoriBorder:pe,onlyOuterBorder:ve,onlyHeaderBorder:be,onlyBodyBorder:$e,bodyBorderStyle:we,onlyHoriBorder:Ce,tableBGC:He,clickHighlight:Y,highlightBGC:ye,highlightGradBG:Ge,highlightNumber:J,highlightFontColor:je}},computed:{tableStyle(){const e={};return this.tableBGC&&(e.background=this.tableBGC),this.enableBorder||this.onlyOuterBorder?{border:`1px solid ${this.borderColor}`,"box-sizing":"border-box",...e}:e},getHeaderItemStyle:()=>(e,a,o,l,m,g,r,h,n,v,f,y,H)=>{const R=o===l.length-1,$={};m&&!R&&($["border-right"]=`1px solid ${g}`),!m&&!n&&v&&!f&&($["border-top"]=`1px solid ${g}`,$["border-bottom"]=`1px solid ${g}`,$["border-right"]=`1px solid ${g}`,o===0&&($["border-left"]=`1px solid ${g}`)),!m&&!n&&v&&f&&($["border-top"]=`1px solid ${g}`,$["border-bottom"]=`1px solid ${g}`,o===0&&($["border-left"]=`1px solid ${g}`),R&&($["border-right"]=`1px solid ${g}`)),!m&&n&&v&&!f&&($["border-bottom"]=`1px solid ${g}`,!R&&($["border-right"]=`1px solid ${g}`)),!m&&n&&v&&f&&($["border-bottom"]=`1px solid ${g}`);let b={};return y.style&&(b={...y.style}),{height:`${a.headerHeight}px`,width:`${e[o]}px`,"font-size":`${r}px`,color:h,...$,...b,display:"flex","justify-content":H==="center"?"center":H==="left"?"flex-start":H==="right"?"flex-end":"left","align-items":"center","text-align":H==="center"?"center":H==="left"?"left":H==="right"?"right":"left"}},getCellStyle:()=>(e,a,o,l,m,g,r,h,n,v,f,y,H,R)=>{const $=a===o.length-1,b={};l&&!$&&(b["border-right"]=`1px ${n} ${m}`),!l&&!f&&h&&!v&&(b["border-right"]=`1px ${n} ${m}`,a===0&&(b["border-left"]=`1px ${n} ${m}`)),!l&&f&&h&&!v&&!$&&(b["border-right"]=`1px ${n} ${m}`);let w={};y.style&&(w={...y.style});const M=H.isHighlight;let L=w.color||r;return M&&(L=R),{width:`${e[a]}px`,"font-size":`${g}px`,...b,...w,color:L}},getRowsHeight(){const{height:e,header:a,mergedConfig:o,enableCarousel:l}=this;return{height:`${e-(a.length?o.headerHeight:0)}px`,overflow:l?"hidden":"auto"}},getRowItemStyle:()=>(e,a,o,l,m,g,r,h,n,v,f,y,H)=>{const R=e[l],$=o.isHighlight;let b=a[o.rowIndex%2===0?"evenRowBGC":"oddRowBGC"];b.includes("http")&&!b.includes("url")&&(b=`url(${b})`),$&&(b=m||g,b.includes("http")&&!b.includes("url")&&(b=`url(${b})`));const w={},M=l===r.length-1;return h&&(l===0&&(w["border-top"]=`1px ${f} ${n}`),w["border-bottom"]=`1px ${f} ${n}`),!h&&!H&&v&&!y&&(l===0&&(w["border-top"]=`1px ${f} ${n}`),w["border-bottom"]=`1px ${f} ${n}`),!h&&!H&&v&&y&&(l===0&&(w["border-top"]=`1px ${f} ${n}`),w["border-bottom"]=`1px ${f} ${n}`),!h&&H&&v&&!y&&(l===0&&(w["border-top"]=`1px ${f} ${n}`),!M&&(w["border-bottom"]=`1px ${f} ${n}`)),!h&&H&&v&&y&&(l===0&&(w["border-top"]=`1px ${f} ${n}`),!M&&(w["border-bottom"]=`1px ${f} ${n}`)),{height:`${R}px`,"line-height":`${R}px`,background:b,"background-size":"100% 100%",...w}}}}),Xe=["align","innerHTML"],Ye=["align","onClick","onMouseenter","onMousemove","innerHTML"];function Je(e,a,o,l,m,g){return T(),k("div",{ref:"domRef",class:"bv-scroll-table",style:W(e.tableStyle)},[e.header.length&&e.mergedConfig?(T(),k("div",{key:0,class:"header",style:W({"background-color":e.mergedConfig.headerBGC})},[(T(!0),k(q,null,U(e.header,(r,h)=>(T(),k("div",{key:`${r.val||r}-${h}`,class:"header-item",style:W(e.getHeaderItemStyle(e.widths,e.mergedConfig,h,e.header,e.enableBorder,e.borderColor,e.headerFontSize,e.headerFontColor,e.onlyOuterBorder,e.onlyHeaderBorder,e.onlyHeaderHoriBorder,r,e.aligns[h])),align:e.aligns[h],innerHTML:r.val||r},null,12,Xe))),128))],4)):ue("",!0),e.mergedConfig?(T(),k("div",{key:1,class:"rows",style:W(e.getRowsHeight)},[(T(!0),k(q,null,U(e.rows,(r,h)=>(T(),k("div",{key:`${r.toString()}-${r.scroll}`,class:"row-item",style:W(e.getRowItemStyle(e.heights,e.mergedConfig,r,h,e.highlightGradBG,e.highlightBGC,e.rows,e.enableBorder,e.borderColor,e.onlyBodyBorder,e.bodyBorderStyle,e.onlyHoriBorder,e.onlyOuterBorder))},[(T(!0),k(q,null,U(r.cells,(n,v)=>(T(),k("div",{key:`${n.val||n}-${h}-${v}`,class:"cell",style:W(e.getCellStyle(e.widths,v,r.cells,e.enableBorder,e.borderColor,e.fontSize,e.fontColor,e.onlyBodyBorder,e.bodyBorderStyle,e.onlyHoriBorder,e.onlyOuterBorder,n,r,e.highlightFontColor)),align:e.aligns[v],onClick:f=>e.clickHandler("itemClick",h,v,r,n),onMouseenter:f=>e.handleHover(!0,h,v,r,n),onMouseleave:a[0]||(a[0]=f=>e.handleHover(!1)),onMousemove:f=>e.handleMove(f,h,v,r,n),innerHTML:e.getCellContent(n)},null,44,Ye))),128))],4))),128))],4)):ue("",!0)],4)}const Ze=Ee(Ve,[["render",Je]]);export{Ze as default};
|