tomtaw-vxe-table 3.25.2 → 3.25.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/style.css +1 -1
- package/es/table/src/body.js +5 -7
- package/es/table/src/expand-height.js +108 -0
- package/es/table/src/methods.js +65 -18
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/index.umd.js +336 -21
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/src/body.js +3 -7
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/expand-height.js +118 -0
- package/lib/table/src/expand-height.min.js +1 -0
- package/lib/table/src/methods.js +13 -10
- package/lib/table/src/methods.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +2 -2
- package/packages/table/src/body.ts +5 -7
- package/packages/table/src/expand-height.ts +108 -0
- package/packages/table/src/methods.ts +66 -18
- package/types/all.d.ts +13 -0
- /package/es/{iconfont.1791960929606.ttf → iconfont.1792027709716.ttf} +0 -0
- /package/es/{iconfont.1791960929606.woff → iconfont.1792027709716.woff} +0 -0
- /package/es/{iconfont.1791960929606.woff2 → iconfont.1792027709716.woff2} +0 -0
- /package/lib/{iconfont.1791960929606.ttf → iconfont.1792027709716.ttf} +0 -0
- /package/lib/{iconfont.1791960929606.woff → iconfont.1792027709716.woff} +0 -0
- /package/lib/{iconfont.1791960929606.woff2 → iconfont.1792027709716.woff2} +0 -0
package/lib/table/src/body.js
CHANGED
|
@@ -9,6 +9,7 @@ var _ui = require("../../ui");
|
|
|
9
9
|
var _comp = require("../../ui/src/comp");
|
|
10
10
|
var _utils = require("../../ui/src/utils");
|
|
11
11
|
var _util = require("./util");
|
|
12
|
+
var _expandHeight = require("./expand-height");
|
|
12
13
|
var _dom = require("../../ui/src/dom");
|
|
13
14
|
var _vn = require("../../ui/src/vn");
|
|
14
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -685,13 +686,8 @@ function renderRows(h, _vm, fixedType, isOptimizeMode, tableData, tableColumn) {
|
|
|
685
686
|
mode: expandMode
|
|
686
687
|
} = expandOpts;
|
|
687
688
|
if (expandMode === 'fixed') {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
if (rowExpandHeightFlag) {
|
|
691
|
-
if (currExpHeight || expandHeight) {
|
|
692
|
-
expHeight = (currExpHeight || expandHeight || 0) + 1;
|
|
693
|
-
}
|
|
694
|
-
}
|
|
689
|
+
// 与位置及总高度计算共用同一规则;估算不改变展开内容的自然高度。
|
|
690
|
+
const expHeight = rowExpandHeightFlag || expandOpts.estimateHeight ? (0, _expandHeight.getRowExpandHeight)($xeTable, row, rowRest) : 0;
|
|
695
691
|
rows.push(h('tr', {
|
|
696
692
|
class: 'vxe-body--row-expanded-place',
|
|
697
693
|
key: `expand_${rowid}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_ui=require("../../ui"),_comp=require("../../ui/src/comp"),_utils=require("../../ui/src/utils"),_util=require("./util"),_dom=require("../../ui/src/dom"),_vn=require("../../ui/src/vn");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}let{getI18n,renderer,renderEmptyElement}=_ui.VxeUI,sourceType="table",renderType="body",isVMScrollProcess=e=>{var l=e.delayHover,t=e.isDragResize,e=e.lastSTime;return!!(t||e&&Date.now()<e+l)};function renderLine(o,a,i,s,d){var n=s.column,c=a.treeConfig,p=a.computeCellOpts,u=a.computeRowOpts,g=a.computeDefaultRowHeight,m=a.computeTreeOpts,{slots:n,treeNode:x}=n,v=a.fullAllDataRowIdData;if(c&&x&&(m.showLine||m.line)){if(n&&n.line)return a.callSlot(n.line,s,o);c=v[i];let e=0,l=null,t=null,r="";return(c&&(e=c.level,l=c.items[c.treeIndex-1],t=c.parent),e||m.showRootLine)?(l?(x=v[(0,_util.getRowid)(a,l)]||{},r=`${x.lineHeight||0}px`):e&&t&&(n=v[(0,_util.getRowid)(a,t)]||{},r=`calc(-1em + ${Math.floor(d/2+(0,_util.getCellRestHeight)(n,p,u,g)/2)}px)`),[o("div",{key:"tl",class:"vxe-tree--line-wrapper"},[o("div",{class:"vxe-tree--line",style:{height:r,bottom:`-${Math.floor(d/2)}px`,left:`calc(${e*m.indent}px + 1em)`}})])]):[]}return[]}function renderTdColumn(e,l,z,t,r,A,F,o,q,L,a,i,V,U,s){var d=l.$xeGrid,N=l.$xeGantt,{columnKey:G,resizable:n,showOverflow:c,border:W,height:p,treeConfig:X,cellClassName:Y,cellStyle:j,align:P,spanMethod:K,mouseConfig:J,editConfig:Q,editRules:u,tooltipConfig:g,padding:m}=l,{tableData:Z,tableColumn:ee,dragRow:le,overflowX:te,overflowY:re,scrollXLoad:oe,scrollYLoad:ae,mergeBodyFlag:ie,calcCellHeightFlag:x,resizeHeightFlag:v,resizeWidthFlag:se,editStore:de,isAllOverflow:ne,validErrorMaps:w,currColFlag:ce}=l,{fullAllDataRowIdData:pe,fullColumnIdData:h,mergeBodyCellMaps:ue,visibleColumn:ge,afterFullData:me,mergeBodyList:xe,scrollXStore:ve,scrollYStore:we,keepUpdateFieldMaps:he,currentCol:fe}=l,f=l.computeCellOpts,y=l.computeValidOpts,b=l.computeCheckboxOpts,ye=l.computeEditOpts,be=l.computeTooltipOpts,Ce=l.computeVirtualXOpts,_e=l.computeVirtualYOpts,{isAllColumnDrag:Re,isAllRowDrag:Ee}=l.resizableOpts,C=l.computeRowOpts,_=l.computeRowDragOpts,Se=l.computeDefaultRowHeight,x=x?f.height||C.height:0,{disabledMethod:R,isCrossDrag:$e,isPeerDrag:De}=_,Oe=l.computeColumnOpts,Ie=l.computeMouseOpts,Te=l.computeCellOffsetWidth,ke=l.computeAreaOpts.selectCellToRow,{field:Be,type:Me,cellRender:E,editRender:He,align:ze,showOverflow:Ae,className:Fe,treeNode:qe,rowResize:Le,padding:S,verticalAlign:$,slots:Ve}=i,{verticalAlign:D,minHeight:Ue,maxHeight:Ne}=f,de=de.actived,Ge=pe[t]||{},O=i.id,h=h[O]||{},E=He||E,E=E&&E.name?l.computeRendererOpts[E.name]||renderer.get(E.name):null,We=E?E.tableCellClassName||E.cellClassName:null,Xe=E?E.tableCellStyle||E.cellStyle:"";let Ye=be.showAll;var je=h.index,h=h._index,He=(0,_utils.isEnableConf)(He),v=v?Ge.resizeHeight:0;let I=te&&(r?i.fixed!==r:!!i.fixed);var S=(0,_utils.getDefaultConfig)(S,null===m?f.padding:m),m=!0===S,Pe=!!S&&(m||!1!==S.top),Ke=!!S&&(m||!1!==S.bottom),Je=!!S&&(m||!1!==S.left),m=!!S&&(m||!1!==S.right),S=(0,_utils.getDefaultConfig)(Ae,c),Ae="ellipsis"===S;let T="title"===S,k=!0===S?"tooltip"===be.mode:"tooltip"===S;c=ne||T||k||Ae,be=_xeUtils.default.isBoolean(i.resizable)?i.resizable:Oe.resizable||n,S=!!x,n=0<v;let Qe;x={},v=ze||(E?E.tableCellAlign:"")||P,ze=_xeUtils.default.eqNull($)?D:$,E=w[t+":"+O],P=u&&y.showErrorMessage&&("default"===y.message?p||1<Z.length:"inline"===y.message),D={colid:O};let B={$table:l,$grid:d,$gantt:N,isEdit:!1,seq:z,rowid:t,row:o,rowIndex:q,$rowIndex:L,_rowIndex:a,column:i,columnIndex:je,$columnIndex:V,_columnIndex:h,fixed:r,source:sourceType,type:renderType,isHidden:!!I,level:F,visibleData:me,data:Z,items:s},M=!1,Ze=!1,H=((M=C.drag?"row"===_.trigger||i.dragSort&&"cell"===_.trigger:M)&&(Ze=!(!R||!R(B))),(T||k||Ye||g)&&(x.mouseover=e=>{isVMScrollProcess(l)||(T?(0,_dom.updateCellTitle)(e.currentTarget,i):(k||Ye)&&l.triggerBodyTooltipEvent(e,B)),l.dispatchEvent("cell-mouseenter",Object.assign({cell:e.currentTarget},B),e)}),(k||Ye||g)&&(x.mouseleave=e=>{isVMScrollProcess(l)||(k||Ye)&&l.handleTargetLeaveEvent(e),l.dispatchEvent("cell-mouseleave",Object.assign({cell:e.currentTarget},B),e)}),(M||b.range||(0,_utils.hasEnableConf)(J,Ie))&&(x.mousedown=e=>{l.triggerCellMousedownEvent(e,B)}),M&&(x.mouseup=l.triggerCellMouseupEvent),x.click=e=>{l.triggerCellClickEvent(e,B)},!(x.dblclick=e=>{l.triggerCellDblclickEvent(e,B)})),el=1,ll=1;if(ie&&xe.length){$=ue[a+":"+h];if($){var{rowspan:w,colspan:u}=$;if(!w||!u)return renderEmptyElement(l);1<w&&(H=!0,ll=w,D.rowspan=w),1<u&&(H=!0,el=u,D.colspan=u)}}else if(K){var{rowspan:p=1,colspan:d=1}=K(B)||{};if(!p||!d)return renderEmptyElement(l);1<p&&(H=!0,ll=p,D.rowspan=p),1<d&&(H=!0,el=d,D.colspan=d)}!(I=I&&H&&(1<D.colspan||1<D.rowspan)?!1:I)&&Q&&(ye.showStatus||ye.showUpdateStatus)&&he[Be]&&(Qe=l.isUpdateByRow(o,Be));N=!c&&(ae||oe);let tl=(0,_util.getCellRestHeight)(Ge,f,C,Se);z=V===U.length-1,q=!i.resizeWidth&&("auto"===i.minWidth||"auto"===i.width);let rl=!1;H||le&&(0,_util.getRowid)(l,le)===t||(re&&ae&&!X&&16<Z.length&&!_e.immediate&&(a<we.visibleStartIndex-we.preloadSize||a>we.visibleEndIndex+we.preloadSize)||te&&oe&&10<ee.length&&!Ce.immediate&&!i.fixed&&(h<ve.visibleStartIndex-ve.preloadSize||h>ve.visibleEndIndex+ve.preloadSize))&&(rl=!0),1<ll&&(L=me[a+ll-1])&&(s=pe[(0,_util.getRowid)(l,L)])&&(tl+=s.oTop+(0,_util.getCellRestHeight)(s,f,C,Se)-Ge.oTop-(0,_util.getCellRestHeight)(Ge,f,C,Se));_={};if(Ne&&(_.maxHeight=Ne+"px"),c&&se){let l=0;if(1<el)for(let e=1;e<el;e++){var ol=ge[je+e];ol&&(l+=ol.renderWidth)}_.width=i.renderWidth+l-Te+"px"}ae||oe||c||S||n?_.height=tl+"px":_.minHeight=tl+"px",Ue&&(_.minHeight=Ue+"px");R=[];I&&ne?R.push(e("div",{key:"tc",class:["vxe-cell",{"c--title":T,"c--tooltip":k,"c--ellipsis":Ae}],style:_})):(X&&R.push(...renderLine(e,l,t,B,tl)),g=[],rl||g.push(e("div",{attrs:{colid:O,rowid:t},class:"vxe-cell--wrapper vxe-body-cell--wrapper"},i.renderCell(e,B))),R.push(e("div",{key:"tc",class:["vxe-cell",{"c--title":T,"c--tooltip":k,"c--ellipsis":Ae}],style:_,attrs:{title:T?l.getCellLabel(o,i):null}},g)),P&&E&&(b=E.rule,ie=Ve?Ve.valid:null,xe=Object.assign(Object.assign(Object.assign({},B),E),{rule:E}),R.push(e("div",{key:"tcv",class:["vxe-cell--valid-error-tip",(0,_utils.getClass)(y.className,E)],style:b&&b.maxWidth?{width:b.maxWidth+"px"}:void 0},[e("div",{class:"vxe-cell--valid-error-wrapper vxe-cell--valid-error-theme-"+(y.theme||"normal")},[ie?l.callSlot(ie,xe,e):[e("span",{class:"vxe-cell--valid-error-msg"},E.content)]])]))));let al=!1;return(0,_utils.hasEnableConf)(J,Ie)&&Ie.area&&!h&&ke&&(al=!0),!I&&be&&Re&&R.push(e("div",{key:"tcc",class:["vxe-cell--col-resizable",{"is--line":!W||"none"===W}],on:{mousedown:e=>l.handleColResizeMousedownEvent(e,r,B),dblclick:e=>l.handleColResizeDblclickEvent(e,B)}})),(Le||Ee)&&C.resizable&&R.push(e("div",{key:"tcr",class:"vxe-cell--row-resizable",on:{mousedown:e=>l.handleRowResizeMousedownEvent(e,B),dblclick:e=>l.handleRowResizeDblclickEvent(e,B)}})),e("td",{class:["vxe-table--column vxe-body--column",O,ze?"col--vertical-"+ze:"",v?"col--"+v:"",Me?"col--"+Me:"",{"col--last":z,"col--tree-node":qe,"col--edit":He,"col--ellipsis":c,"col--cs-height":S,"col--rs-height":n,"col--to-row":al,"col--auto-height":N,"col--max-height":Ne,"fixed--width":!q,"fixed--hidden":I,"is--pg-top":Pe,"is--pg-bottom":Ke,"is--pg-left":Je,"is--pg-right":m,"is--progress":I&&ne||rl,"is--drag-cell":M&&($e||De||!F),"is--drag-disabled":Ze,"col--dirty":Qe,"col--active":Q&&He&&de.row===o&&(de.column===i||"row"===ye.mode),"col--valid-error":!!E,"show--valid-bg":E&&y.showErrorBackground,"col--current":ce&&fe===i},(0,_utils.getClass)(We,B),(0,_utils.getClass)(Fe,B),(0,_utils.getClass)(Y,B)],key:G||oe||ae||Oe.useKey||C.useKey||Oe.drag?i.id:V,attrs:D,style:Object.assign({},_xeUtils.default.isFunction(Xe)?Xe(B):Xe,_xeUtils.default.isFunction(j)?j(B):j),on:x},A&&I?[]:R)}function renderRows(v,w,h,f,y,b){let C=w.$parent;var e=C,l=C,t=C;let _=C.$xeGrid,R=C.$xeGantt,{stripe:E,rowKey:S,highlightHoverRow:$,rowClassName:D,rowStyle:O,editConfig:I,treeConfig:T}=e,{hasFixedColumn:k,treeExpandedFlag:B,scrollYLoad:M,isAllOverflow:H,rowExpandedFlag:z,expandColumn:A,selectRadioRow:F,pendingRowFlag:q,rowExpandHeightFlag:L,isRowGroupStatus:V}=l,{fullAllDataRowIdData:P,fullColumnIdData:K,treeExpandedMaps:J,pendingRowMaps:Q,rowExpandedMaps:Z,currentRow:U}=t,ee=C.computeCheckboxOpts,le=C.computeRadioOpts,N=C.computeTreeOpts,G=C.computeEditOpts,W=C.computeRowOpts,te=C.computeColumnOpts,{transform:X,seqMode:Y}=N,re=N.children||N.childrenField,j=[],oe=(0,_util.createHandleGetRowId)(C).handleGetRowId,ae=T||V;return y.forEach((r,o)=>{var a={};let i=oe(r);var s=P[i]||{};let d=o,n=0,c=-1,p=-1;var u=V&&r.isAggregate,g=((W.isHover||$)&&(a.mouseover=e=>{isVMScrollProcess(C)||C.triggerHoverEvent(e,{row:r,rowIndex:d})},a.mouseleave=()=>{isVMScrollProcess(C)||C.clearHoverRow()}),s&&(d=s.index,p=s._index,n=s.level,c=s.seq,u||T&&X&&"increasing"===Y?c=s._index+1:T&&"fixed"===Y&&(c=s._tIndex+1)),{$table:C,seq:c,rowid:i,fixed:h,type:renderType,level:n,row:r,rowIndex:d,$rowIndex:o,_rowIndex:p}),m=A&&!!z&&!!Z[i];let e=!1,l=[],t=!1;I&&(t=C.isInsertByRow(r)),!T||M||X||(l=r[re],e=!!B&&l&&0<l.length&&!!J[i]),!W.drag||V||T&&!X||(a.dragstart=C.handleRowDragDragstartEvent,a.dragend=C.handleRowDragDragendEvent,a.dragover=C.handleRowDragDragoverEvent);var u=["vxe-body--row",ae?"row--level-"+n:"",{"row--stripe":E&&(p+1)%2==0,"is--new":t,"is--expand-row":m,"is--expand-tree":e,"row--new":t&&(G.showStatus||G.showInsertStatus),"row--radio":le.highlight&&F===r,"row--checked":ee.highlight&&C.isCheckedByCheckboxRow(r),"row--pending":!!q&&!!Q[i],"row--group":u,"row--current":U&&i===(0,_util.getRowid)(C,U)},D?_xeUtils.default.isFunction(D)?D(g):D:""],x=b.map((e,l)=>renderTdColumn(v,C,c,i,h,f,n,r,d,o,p,e,l,b,y));if(j.push(v("tr",{class:u,attrs:{rowid:i},style:O?_xeUtils.default.isFunction(O)?O(g):O:void 0,key:S||W.useKey||W.drag||te.drag||V||T?i:o,on:a},x)),m){var{height:u,padding:g,mode:a}=C.computeExpandOpts;if("fixed"===a){x=s.expandHeight;let e=0;L&&(x||u)&&(e=(x||u||0)+1),j.push(v("tr",{class:"vxe-body--row-expanded-place",key:"expand_"+i,attrs:{rowid:i}},[v("td",{class:"vxe-body--row-expanded-place-column",attrs:{colspan:b.length},style:{height:e+"px"}})]))}else{m={},a=(u&&(m.height=u+"px"),T&&(m.paddingLeft=n*N.indent+30+"px"),A||{}).showOverflow,s=A.id,x=K[s]||{},s=_xeUtils.default.eqNull(a)?H:a;let e=-1,l=-1,t=-1;x&&(e=x.index,l=x.$index,t=x._index);a={$grid:_,$table:C,$gantt:R,seq:c,column:A,columnIndex:e,$columnIndex:l,_columnIndex:t,fixed:h,source:sourceType,type:renderType,level:n,row:r,rowid:i,rowIndex:d,$rowIndex:o,_rowIndex:p,isHidden:!1,isEdit:!1,visibleData:[],data:[],items:[]};j.push(v("tr",{class:["vxe-body--expanded-row",{"is--padding":g}],key:"expand_"+i},[v("td",{class:["vxe-body--expanded-column",{"fixed--hidden":h&&!k,"col--ellipsis":s}],attrs:{colspan:b.length}},[v("div",{class:["vxe-body--expanded-cell",{"is--ellipsis":u}],style:m},[A.renderData(v,a)])])]))}}e&&j.push(...renderRows(v,w,h,f,l,b))}),j}var _default=exports.default=(0,_comp.defineVxeComponent)({name:"VxeTableBody",props:{tableData:Array,tableColumn:Array,fixedColumn:Array,fixedType:{type:String,default:""}},mounted(){var e=this,l=e.fixedType,t=e.$parent.elemStore,l=`${l||"main"}-body-`;t[l+"wrapper"]=e.$refs.refElem,t[l+"scroll"]=e.$refs.refBodyScroll,t[l+"table"]=e.$refs.refBodyTable,t[l+"colgroup"]=e.$refs.refBodyColgroup,t[l+"list"]=e.$refs.refBodyTBody,t[l+"xSpace"]=e.$refs.refBodyXSpace,t[l+"ySpace"]=e.$refs.refBodyYSpace,t[l+"emptyBlock"]=e.$refs.refBodyEmptyBlock},destroyed(){var e=this.fixedType,l=this.$parent.elemStore,e=`${e||"main"}-body-`;l[e+"wrapper"]=null,l[e+"scroll"]=null,l[e+"table"]=null,l[e+"colgroup"]=null,l[e+"list"]=null,l[e+"xSpace"]=null,l[e+"ySpace"]=null,l[e+"emptyBlock"]=null},render(t){let l=this.$parent;var e=l,r=l,o=l,a=l.$xeGrid,i=l.$xeGantt,s=l.$scopedSlots,d=l.xID;let{fixedColumn:n,fixedType:c,tableColumn:p}=this;var u=e.mouseConfig,{isGroup:r,tableData:g,isColLoading:m,overflowX:x,scrollXLoad:v,scrollYLoad:w,dragRow:h,dragCol:f}=r,{visibleColumn:o,fullAllDataRowIdData:y,fullColumnIdData:b}=o,C=l.computeEmptyOpts,_=l.computeMouseOpts;let R=g,E=p;g=l.computeIsBodyRenderOptimize;m||!c&&x||(E=o),c&&g&&(E=n||[]),w&&h&&2<R.length&&(m=y[(0,_util.getRowid)(l,h)])&&(x=m._index,o=R[0],w=R[R.length-1],m=y[(0,_util.getRowid)(l,o)],o=y[(0,_util.getRowid)(l,w)],m)&&o&&(y=m._index,w=o._index,x<y?R=[h].concat(R):w<x&&(R=R.concat([h]))),c||r||v&&f&&2<E.length&&(m=b[f.id])&&(o=m._index,y=E[0],w=E[E.length-1],x=b[y.id],h=b[w.id],x)&&h&&(r=x._index,v=h._index,o<r?E=[f].concat(E):v<o&&(E=E.concat([f])));let S;m=s?s.empty:null,y={$table:l,$grid:a,$gantt:i};return S=m?m.call(l,y):(b=l.computeRendererOpts,(x=(w=C.name?b[C.name]||renderer.get(C.name):null)?w.renderTableEmpty||w.renderTableEmptyView||w.renderEmpty:null)?(0,_vn.getSlotVNs)(x.call(l,t,C,y)):e.emptyText||getI18n("vxe.table.emptyText")),t("div",{ref:"refElem",class:["vxe-table--body-wrapper",c?`fixed-${c}--wrapper`:"body--wrapper"],attrs:{xid:d}},[t("div",{ref:"refBodyScroll",class:"vxe-table--body-inner-wrapper",on:{scroll(e){l.triggerBodyScrollEvent(e,c)}}},[c?renderEmptyElement(l):t("div",{ref:"refBodyXSpace",class:"vxe-body--x-space"}),t("div",{ref:"refBodyYSpace",class:"vxe-body--y-space"}),t("table",{ref:"refBodyTable",class:"vxe-table--body",attrs:{xid:d,cellspacing:0,cellpadding:0,border:0,xvm:g?"1":null}},[t("colgroup",{ref:"refBodyColgroup"},E.map((e,l)=>t("col",{attrs:{name:e.id},key:l,style:{width:e.renderWidth+"px"}}))),t("tbody",{ref:"refBodyTBody"},renderRows(t,this,c,g,R,E))]),t("div",{class:"vxe-table--checkbox-range"}),(0,_utils.hasEnableConf)(u,_)&&_.area?t("div",{class:"vxe-table--cell-area",attrs:{xid:d}},[t("span",{class:"vxe-table--cell-main-area"},_.extension?[t("span",{class:"vxe-table--cell-main-area-btn",on:{mousedown(e){l.triggerCellAreaExtendMousedownEvent&&l.triggerCellAreaExtendMousedownEvent(e,{$table:l,fixed:c,type:renderType})}}})]:null),t("span",{class:"vxe-table--cell-clip-area"}),t("span",{class:"vxe-table--cell-extend-area"}),t("span",{class:"vxe-table--cell-multi-area"}),t("span",{class:"vxe-table--cell-active-area"}),t("span",{class:"vxe-table--cell-row-status-area"})]):renderEmptyElement(l),c?renderEmptyElement(l):t("div",{class:"vxe-table--empty-block",ref:"emptyBlock"},[t("div",{class:"vxe-table--empty-content"},S)])])])}});
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_ui=require("../../ui"),_comp=require("../../ui/src/comp"),_utils=require("../../ui/src/utils"),_util=require("./util"),_expandHeight=require("./expand-height"),_dom=require("../../ui/src/dom"),_vn=require("../../ui/src/vn");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}let{getI18n,renderer,renderEmptyElement}=_ui.VxeUI,sourceType="table",renderType="body",isVMScrollProcess=e=>{var l=e.delayHover,t=e.isDragResize,e=e.lastSTime;return!!(t||e&&Date.now()<e+l)};function renderLine(o,a,i,s,d){var n=s.column,c=a.treeConfig,p=a.computeCellOpts,u=a.computeRowOpts,g=a.computeDefaultRowHeight,m=a.computeTreeOpts,{slots:n,treeNode:x}=n,v=a.fullAllDataRowIdData;if(c&&x&&(m.showLine||m.line)){if(n&&n.line)return a.callSlot(n.line,s,o);c=v[i];let e=0,l=null,t=null,r="";return(c&&(e=c.level,l=c.items[c.treeIndex-1],t=c.parent),e||m.showRootLine)?(l?(x=v[(0,_util.getRowid)(a,l)]||{},r=`${x.lineHeight||0}px`):e&&t&&(n=v[(0,_util.getRowid)(a,t)]||{},r=`calc(-1em + ${Math.floor(d/2+(0,_util.getCellRestHeight)(n,p,u,g)/2)}px)`),[o("div",{key:"tl",class:"vxe-tree--line-wrapper"},[o("div",{class:"vxe-tree--line",style:{height:r,bottom:`-${Math.floor(d/2)}px`,left:`calc(${e*m.indent}px + 1em)`}})])]):[]}return[]}function renderTdColumn(e,l,z,t,r,A,q,o,F,L,a,i,V,U,s){var d=l.$xeGrid,N=l.$xeGantt,{columnKey:G,resizable:n,showOverflow:c,border:W,height:p,treeConfig:X,cellClassName:Y,cellStyle:j,align:P,spanMethod:K,mouseConfig:J,editConfig:Q,editRules:u,tooltipConfig:g,padding:m}=l,{tableData:Z,tableColumn:ee,dragRow:le,overflowX:te,overflowY:re,scrollXLoad:oe,scrollYLoad:ae,mergeBodyFlag:ie,calcCellHeightFlag:x,resizeHeightFlag:v,resizeWidthFlag:se,editStore:de,isAllOverflow:ne,validErrorMaps:h,currColFlag:ce}=l,{fullAllDataRowIdData:pe,fullColumnIdData:w,mergeBodyCellMaps:ue,visibleColumn:ge,afterFullData:me,mergeBodyList:xe,scrollXStore:ve,scrollYStore:he,keepUpdateFieldMaps:we,currentCol:fe}=l,f=l.computeCellOpts,y=l.computeValidOpts,b=l.computeCheckboxOpts,ye=l.computeEditOpts,be=l.computeTooltipOpts,Ce=l.computeVirtualXOpts,_e=l.computeVirtualYOpts,{isAllColumnDrag:Re,isAllRowDrag:Ee}=l.resizableOpts,C=l.computeRowOpts,_=l.computeRowDragOpts,Se=l.computeDefaultRowHeight,x=x?f.height||C.height:0,{disabledMethod:R,isCrossDrag:$e,isPeerDrag:De}=_,Oe=l.computeColumnOpts,Ie=l.computeMouseOpts,Te=l.computeCellOffsetWidth,ke=l.computeAreaOpts.selectCellToRow,{field:Be,type:He,cellRender:E,editRender:Me,align:ze,showOverflow:Ae,className:qe,treeNode:Fe,rowResize:Le,padding:S,verticalAlign:$,slots:Ve}=i,{verticalAlign:D,minHeight:Ue,maxHeight:Ne}=f,de=de.actived,Ge=pe[t]||{},O=i.id,w=w[O]||{},E=Me||E,E=E&&E.name?l.computeRendererOpts[E.name]||renderer.get(E.name):null,We=E?E.tableCellClassName||E.cellClassName:null,Xe=E?E.tableCellStyle||E.cellStyle:"";let Ye=be.showAll;var je=w.index,w=w._index,Me=(0,_utils.isEnableConf)(Me),v=v?Ge.resizeHeight:0;let I=te&&(r?i.fixed!==r:!!i.fixed);var S=(0,_utils.getDefaultConfig)(S,null===m?f.padding:m),m=!0===S,Pe=!!S&&(m||!1!==S.top),Ke=!!S&&(m||!1!==S.bottom),Je=!!S&&(m||!1!==S.left),m=!!S&&(m||!1!==S.right),S=(0,_utils.getDefaultConfig)(Ae,c),Ae="ellipsis"===S;let T="title"===S,k=!0===S?"tooltip"===be.mode:"tooltip"===S;c=ne||T||k||Ae,be=_xeUtils.default.isBoolean(i.resizable)?i.resizable:Oe.resizable||n,S=!!x,n=0<v;let Qe;x={},v=ze||(E?E.tableCellAlign:"")||P,ze=_xeUtils.default.eqNull($)?D:$,E=h[t+":"+O],P=u&&y.showErrorMessage&&("default"===y.message?p||1<Z.length:"inline"===y.message),D={colid:O};let B={$table:l,$grid:d,$gantt:N,isEdit:!1,seq:z,rowid:t,row:o,rowIndex:F,$rowIndex:L,_rowIndex:a,column:i,columnIndex:je,$columnIndex:V,_columnIndex:w,fixed:r,source:sourceType,type:renderType,isHidden:!!I,level:q,visibleData:me,data:Z,items:s},H=!1,Ze=!1,M=((H=C.drag?"row"===_.trigger||i.dragSort&&"cell"===_.trigger:H)&&(Ze=!(!R||!R(B))),(T||k||Ye||g)&&(x.mouseover=e=>{isVMScrollProcess(l)||(T?(0,_dom.updateCellTitle)(e.currentTarget,i):(k||Ye)&&l.triggerBodyTooltipEvent(e,B)),l.dispatchEvent("cell-mouseenter",Object.assign({cell:e.currentTarget},B),e)}),(k||Ye||g)&&(x.mouseleave=e=>{isVMScrollProcess(l)||(k||Ye)&&l.handleTargetLeaveEvent(e),l.dispatchEvent("cell-mouseleave",Object.assign({cell:e.currentTarget},B),e)}),(H||b.range||(0,_utils.hasEnableConf)(J,Ie))&&(x.mousedown=e=>{l.triggerCellMousedownEvent(e,B)}),H&&(x.mouseup=l.triggerCellMouseupEvent),x.click=e=>{l.triggerCellClickEvent(e,B)},!(x.dblclick=e=>{l.triggerCellDblclickEvent(e,B)})),el=1,ll=1;if(ie&&xe.length){$=ue[a+":"+w];if($){var{rowspan:h,colspan:u}=$;if(!h||!u)return renderEmptyElement(l);1<h&&(M=!0,ll=h,D.rowspan=h),1<u&&(M=!0,el=u,D.colspan=u)}}else if(K){var{rowspan:p=1,colspan:d=1}=K(B)||{};if(!p||!d)return renderEmptyElement(l);1<p&&(M=!0,ll=p,D.rowspan=p),1<d&&(M=!0,el=d,D.colspan=d)}!(I=I&&M&&(1<D.colspan||1<D.rowspan)?!1:I)&&Q&&(ye.showStatus||ye.showUpdateStatus)&&we[Be]&&(Qe=l.isUpdateByRow(o,Be));N=!c&&(ae||oe);let tl=(0,_util.getCellRestHeight)(Ge,f,C,Se);z=V===U.length-1,F=!i.resizeWidth&&("auto"===i.minWidth||"auto"===i.width);let rl=!1;M||le&&(0,_util.getRowid)(l,le)===t||(re&&ae&&!X&&16<Z.length&&!_e.immediate&&(a<he.visibleStartIndex-he.preloadSize||a>he.visibleEndIndex+he.preloadSize)||te&&oe&&10<ee.length&&!Ce.immediate&&!i.fixed&&(w<ve.visibleStartIndex-ve.preloadSize||w>ve.visibleEndIndex+ve.preloadSize))&&(rl=!0),1<ll&&(L=me[a+ll-1])&&(s=pe[(0,_util.getRowid)(l,L)])&&(tl+=s.oTop+(0,_util.getCellRestHeight)(s,f,C,Se)-Ge.oTop-(0,_util.getCellRestHeight)(Ge,f,C,Se));_={};if(Ne&&(_.maxHeight=Ne+"px"),c&&se){let l=0;if(1<el)for(let e=1;e<el;e++){var ol=ge[je+e];ol&&(l+=ol.renderWidth)}_.width=i.renderWidth+l-Te+"px"}ae||oe||c||S||n?_.height=tl+"px":_.minHeight=tl+"px",Ue&&(_.minHeight=Ue+"px");R=[];I&&ne?R.push(e("div",{key:"tc",class:["vxe-cell",{"c--title":T,"c--tooltip":k,"c--ellipsis":Ae}],style:_})):(X&&R.push(...renderLine(e,l,t,B,tl)),g=[],rl||g.push(e("div",{attrs:{colid:O,rowid:t},class:"vxe-cell--wrapper vxe-body-cell--wrapper"},i.renderCell(e,B))),R.push(e("div",{key:"tc",class:["vxe-cell",{"c--title":T,"c--tooltip":k,"c--ellipsis":Ae}],style:_,attrs:{title:T?l.getCellLabel(o,i):null}},g)),P&&E&&(b=E.rule,ie=Ve?Ve.valid:null,xe=Object.assign(Object.assign(Object.assign({},B),E),{rule:E}),R.push(e("div",{key:"tcv",class:["vxe-cell--valid-error-tip",(0,_utils.getClass)(y.className,E)],style:b&&b.maxWidth?{width:b.maxWidth+"px"}:void 0},[e("div",{class:"vxe-cell--valid-error-wrapper vxe-cell--valid-error-theme-"+(y.theme||"normal")},[ie?l.callSlot(ie,xe,e):[e("span",{class:"vxe-cell--valid-error-msg"},E.content)]])]))));let al=!1;return(0,_utils.hasEnableConf)(J,Ie)&&Ie.area&&!w&&ke&&(al=!0),!I&&be&&Re&&R.push(e("div",{key:"tcc",class:["vxe-cell--col-resizable",{"is--line":!W||"none"===W}],on:{mousedown:e=>l.handleColResizeMousedownEvent(e,r,B),dblclick:e=>l.handleColResizeDblclickEvent(e,B)}})),(Le||Ee)&&C.resizable&&R.push(e("div",{key:"tcr",class:"vxe-cell--row-resizable",on:{mousedown:e=>l.handleRowResizeMousedownEvent(e,B),dblclick:e=>l.handleRowResizeDblclickEvent(e,B)}})),e("td",{class:["vxe-table--column vxe-body--column",O,ze?"col--vertical-"+ze:"",v?"col--"+v:"",He?"col--"+He:"",{"col--last":z,"col--tree-node":Fe,"col--edit":Me,"col--ellipsis":c,"col--cs-height":S,"col--rs-height":n,"col--to-row":al,"col--auto-height":N,"col--max-height":Ne,"fixed--width":!F,"fixed--hidden":I,"is--pg-top":Pe,"is--pg-bottom":Ke,"is--pg-left":Je,"is--pg-right":m,"is--progress":I&&ne||rl,"is--drag-cell":H&&($e||De||!q),"is--drag-disabled":Ze,"col--dirty":Qe,"col--active":Q&&Me&&de.row===o&&(de.column===i||"row"===ye.mode),"col--valid-error":!!E,"show--valid-bg":E&&y.showErrorBackground,"col--current":ce&&fe===i},(0,_utils.getClass)(We,B),(0,_utils.getClass)(qe,B),(0,_utils.getClass)(Y,B)],key:G||oe||ae||Oe.useKey||C.useKey||Oe.drag?i.id:V,attrs:D,style:Object.assign({},_xeUtils.default.isFunction(Xe)?Xe(B):Xe,_xeUtils.default.isFunction(j)?j(B):j),on:x},A&&I?[]:R)}function renderRows(v,h,w,f,y,b){let C=h.$parent;var e=C,l=C,t=C;let _=C.$xeGrid,R=C.$xeGantt,{stripe:E,rowKey:S,highlightHoverRow:$,rowClassName:D,rowStyle:O,editConfig:I,treeConfig:T}=e,{hasFixedColumn:k,treeExpandedFlag:B,scrollYLoad:H,isAllOverflow:M,rowExpandedFlag:z,expandColumn:A,selectRadioRow:q,pendingRowFlag:F,rowExpandHeightFlag:L,isRowGroupStatus:V}=l,{fullAllDataRowIdData:P,fullColumnIdData:K,treeExpandedMaps:J,pendingRowMaps:Q,rowExpandedMaps:Z,currentRow:U}=t,ee=C.computeCheckboxOpts,le=C.computeRadioOpts,N=C.computeTreeOpts,G=C.computeEditOpts,W=C.computeRowOpts,te=C.computeColumnOpts,{transform:X,seqMode:Y}=N,re=N.children||N.childrenField,j=[],oe=(0,_util.createHandleGetRowId)(C).handleGetRowId,ae=T||V;return y.forEach((r,o)=>{var a={};let i=oe(r);var s=P[i]||{};let d=o,n=0,c=-1,p=-1;var u=V&&r.isAggregate,g=((W.isHover||$)&&(a.mouseover=e=>{isVMScrollProcess(C)||C.triggerHoverEvent(e,{row:r,rowIndex:d})},a.mouseleave=()=>{isVMScrollProcess(C)||C.clearHoverRow()}),s&&(d=s.index,p=s._index,n=s.level,c=s.seq,u||T&&X&&"increasing"===Y?c=s._index+1:T&&"fixed"===Y&&(c=s._tIndex+1)),{$table:C,seq:c,rowid:i,fixed:w,type:renderType,level:n,row:r,rowIndex:d,$rowIndex:o,_rowIndex:p}),m=A&&!!z&&!!Z[i];let e=!1,l=[],t=!1;I&&(t=C.isInsertByRow(r)),!T||H||X||(l=r[re],e=!!B&&l&&0<l.length&&!!J[i]),!W.drag||V||T&&!X||(a.dragstart=C.handleRowDragDragstartEvent,a.dragend=C.handleRowDragDragendEvent,a.dragover=C.handleRowDragDragoverEvent);var u=["vxe-body--row",ae?"row--level-"+n:"",{"row--stripe":E&&(p+1)%2==0,"is--new":t,"is--expand-row":m,"is--expand-tree":e,"row--new":t&&(G.showStatus||G.showInsertStatus),"row--radio":le.highlight&&q===r,"row--checked":ee.highlight&&C.isCheckedByCheckboxRow(r),"row--pending":!!F&&!!Q[i],"row--group":u,"row--current":U&&i===(0,_util.getRowid)(C,U)},D?_xeUtils.default.isFunction(D)?D(g):D:""],x=b.map((e,l)=>renderTdColumn(v,C,c,i,w,f,n,r,d,o,p,e,l,b,y));if(j.push(v("tr",{class:u,attrs:{rowid:i},style:O?_xeUtils.default.isFunction(O)?O(g):O:void 0,key:S||W.useKey||W.drag||te.drag||V||T?i:o,on:a},x)),m){var u=C.computeExpandOpts,{height:g,padding:a,mode:x}=u;if("fixed"===x){m=L||u.estimateHeight?(0,_expandHeight.getRowExpandHeight)(C,r,s):0;j.push(v("tr",{class:"vxe-body--row-expanded-place",key:"expand_"+i,attrs:{rowid:i}},[v("td",{class:"vxe-body--row-expanded-place-column",attrs:{colspan:b.length},style:{height:m+"px"}})]))}else{x={},u=(g&&(x.height=g+"px"),T&&(x.paddingLeft=n*N.indent+30+"px"),A||{}).showOverflow,s=A.id,m=K[s]||{},s=_xeUtils.default.eqNull(u)?M:u;let e=-1,l=-1,t=-1;m&&(e=m.index,l=m.$index,t=m._index);u={$grid:_,$table:C,$gantt:R,seq:c,column:A,columnIndex:e,$columnIndex:l,_columnIndex:t,fixed:w,source:sourceType,type:renderType,level:n,row:r,rowid:i,rowIndex:d,$rowIndex:o,_rowIndex:p,isHidden:!1,isEdit:!1,visibleData:[],data:[],items:[]};j.push(v("tr",{class:["vxe-body--expanded-row",{"is--padding":a}],key:"expand_"+i},[v("td",{class:["vxe-body--expanded-column",{"fixed--hidden":w&&!k,"col--ellipsis":s}],attrs:{colspan:b.length}},[v("div",{class:["vxe-body--expanded-cell",{"is--ellipsis":g}],style:x},[A.renderData(v,u)])])]))}}e&&j.push(...renderRows(v,h,w,f,l,b))}),j}var _default=exports.default=(0,_comp.defineVxeComponent)({name:"VxeTableBody",props:{tableData:Array,tableColumn:Array,fixedColumn:Array,fixedType:{type:String,default:""}},mounted(){var e=this,l=e.fixedType,t=e.$parent.elemStore,l=`${l||"main"}-body-`;t[l+"wrapper"]=e.$refs.refElem,t[l+"scroll"]=e.$refs.refBodyScroll,t[l+"table"]=e.$refs.refBodyTable,t[l+"colgroup"]=e.$refs.refBodyColgroup,t[l+"list"]=e.$refs.refBodyTBody,t[l+"xSpace"]=e.$refs.refBodyXSpace,t[l+"ySpace"]=e.$refs.refBodyYSpace,t[l+"emptyBlock"]=e.$refs.refBodyEmptyBlock},destroyed(){var e=this.fixedType,l=this.$parent.elemStore,e=`${e||"main"}-body-`;l[e+"wrapper"]=null,l[e+"scroll"]=null,l[e+"table"]=null,l[e+"colgroup"]=null,l[e+"list"]=null,l[e+"xSpace"]=null,l[e+"ySpace"]=null,l[e+"emptyBlock"]=null},render(t){let l=this.$parent;var e=l,r=l,o=l,a=l.$xeGrid,i=l.$xeGantt,s=l.$scopedSlots,d=l.xID;let{fixedColumn:n,fixedType:c,tableColumn:p}=this;var u=e.mouseConfig,{isGroup:r,tableData:g,isColLoading:m,overflowX:x,scrollXLoad:v,scrollYLoad:h,dragRow:w,dragCol:f}=r,{visibleColumn:o,fullAllDataRowIdData:y,fullColumnIdData:b}=o,C=l.computeEmptyOpts,_=l.computeMouseOpts;let R=g,E=p;g=l.computeIsBodyRenderOptimize;m||!c&&x||(E=o),c&&g&&(E=n||[]),h&&w&&2<R.length&&(m=y[(0,_util.getRowid)(l,w)])&&(x=m._index,o=R[0],h=R[R.length-1],m=y[(0,_util.getRowid)(l,o)],o=y[(0,_util.getRowid)(l,h)],m)&&o&&(y=m._index,h=o._index,x<y?R=[w].concat(R):h<x&&(R=R.concat([w]))),c||r||v&&f&&2<E.length&&(m=b[f.id])&&(o=m._index,y=E[0],h=E[E.length-1],x=b[y.id],w=b[h.id],x)&&w&&(r=x._index,v=w._index,o<r?E=[f].concat(E):v<o&&(E=E.concat([f])));let S;m=s?s.empty:null,y={$table:l,$grid:a,$gantt:i};return S=m?m.call(l,y):(b=l.computeRendererOpts,(x=(h=C.name?b[C.name]||renderer.get(C.name):null)?h.renderTableEmpty||h.renderTableEmptyView||h.renderEmpty:null)?(0,_vn.getSlotVNs)(x.call(l,t,C,y)):e.emptyText||getI18n("vxe.table.emptyText")),t("div",{ref:"refElem",class:["vxe-table--body-wrapper",c?`fixed-${c}--wrapper`:"body--wrapper"],attrs:{xid:d}},[t("div",{ref:"refBodyScroll",class:"vxe-table--body-inner-wrapper",on:{scroll(e){l.triggerBodyScrollEvent(e,c)}}},[c?renderEmptyElement(l):t("div",{ref:"refBodyXSpace",class:"vxe-body--x-space"}),t("div",{ref:"refBodyYSpace",class:"vxe-body--y-space"}),t("table",{ref:"refBodyTable",class:"vxe-table--body",attrs:{xid:d,cellspacing:0,cellpadding:0,border:0,xvm:g?"1":null}},[t("colgroup",{ref:"refBodyColgroup"},E.map((e,l)=>t("col",{attrs:{name:e.id},key:l,style:{width:e.renderWidth+"px"}}))),t("tbody",{ref:"refBodyTBody"},renderRows(t,this,c,g,R,E))]),t("div",{class:"vxe-table--checkbox-range"}),(0,_utils.hasEnableConf)(u,_)&&_.area?t("div",{class:"vxe-table--cell-area",attrs:{xid:d}},[t("span",{class:"vxe-table--cell-main-area"},_.extension?[t("span",{class:"vxe-table--cell-main-area-btn",on:{mousedown(e){l.triggerCellAreaExtendMousedownEvent&&l.triggerCellAreaExtendMousedownEvent(e,{$table:l,fixed:c,type:renderType})}}})]:null),t("span",{class:"vxe-table--cell-clip-area"}),t("span",{class:"vxe-table--cell-extend-area"}),t("span",{class:"vxe-table--cell-multi-area"}),t("span",{class:"vxe-table--cell-active-area"}),t("span",{class:"vxe-table--cell-row-status-area"})]):renderEmptyElement(l),c?renderEmptyElement(l):t("div",{class:"vxe-table--empty-block",ref:"emptyBlock"},[t("div",{class:"vxe-table--empty-content"},S)])])])}});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createExpandHeightCache = createExpandHeightCache;
|
|
7
|
+
exports.getRowExpandHeight = getRowExpandHeight;
|
|
8
|
+
const estimateValues = new WeakMap();
|
|
9
|
+
/** 仅缓存当前挂载的展开区。没有完整观察能力时保留同步测量路径。 */
|
|
10
|
+
function createExpandHeightCache($table, onResize) {
|
|
11
|
+
const entries = new Map();
|
|
12
|
+
let disposed = false;
|
|
13
|
+
let queued = false;
|
|
14
|
+
const supported = typeof ResizeObserver !== 'undefined' && typeof MutationObserver !== 'undefined';
|
|
15
|
+
const observer = supported ? new ResizeObserver(records => {
|
|
16
|
+
let changed = false;
|
|
17
|
+
records.forEach(record => {
|
|
18
|
+
const entry = entries.get(record.target);
|
|
19
|
+
if (entry) {
|
|
20
|
+
entry.dirty = true;
|
|
21
|
+
changed = true;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
if (changed && !queued && !disposed) {
|
|
25
|
+
queued = true;
|
|
26
|
+
$table.$nextTick(() => {
|
|
27
|
+
queued = false;
|
|
28
|
+
if (!disposed) onResize();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}) : null;
|
|
32
|
+
// 内容/样式变化先失效,避免下一次滚动发生在 ResizeObserver 通知之前。
|
|
33
|
+
const mutations = supported ? new MutationObserver(records => {
|
|
34
|
+
entries.forEach((entry, element) => {
|
|
35
|
+
if (records.some(record => element === record.target || element.contains(record.target))) {
|
|
36
|
+
entry.dirty = true;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}) : null;
|
|
40
|
+
let container = null;
|
|
41
|
+
let width = -1;
|
|
42
|
+
$table.$once('hook:beforeDestroy', () => {
|
|
43
|
+
disposed = true;
|
|
44
|
+
if (observer) observer.disconnect();
|
|
45
|
+
if (mutations) mutations.disconnect();
|
|
46
|
+
entries.clear();
|
|
47
|
+
container = null;
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
sync(element) {
|
|
51
|
+
const nextWidth = element.clientWidth;
|
|
52
|
+
if (container !== element) {
|
|
53
|
+
if (mutations) {
|
|
54
|
+
mutations.disconnect();
|
|
55
|
+
mutations.observe(element, {
|
|
56
|
+
subtree: true,
|
|
57
|
+
childList: true,
|
|
58
|
+
attributes: true,
|
|
59
|
+
characterData: true
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
container = element;
|
|
63
|
+
width = -1;
|
|
64
|
+
}
|
|
65
|
+
entries.forEach((entry, child) => {
|
|
66
|
+
if (child.parentElement !== element) {
|
|
67
|
+
if (observer) observer.unobserve(child);
|
|
68
|
+
entries.delete(child);
|
|
69
|
+
} else if (nextWidth !== width) {
|
|
70
|
+
entry.dirty = true;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
width = nextWidth;
|
|
74
|
+
},
|
|
75
|
+
measure(element, binding, scrolling) {
|
|
76
|
+
const previous = entries.get(element);
|
|
77
|
+
if (observer && scrolling && previous && previous.binding === binding && previous.height === binding.expandHeight && !previous.dirty) {
|
|
78
|
+
return previous.height;
|
|
79
|
+
}
|
|
80
|
+
const height = element.offsetHeight;
|
|
81
|
+
entries.set(element, {
|
|
82
|
+
binding,
|
|
83
|
+
height,
|
|
84
|
+
dirty: false
|
|
85
|
+
});
|
|
86
|
+
if (observer && !previous) {
|
|
87
|
+
// 旧实现不支持 box 选项时继续使用原有同步读取,不缓存滚动测量。
|
|
88
|
+
try {
|
|
89
|
+
observer.observe(element, {
|
|
90
|
+
box: 'border-box'
|
|
91
|
+
});
|
|
92
|
+
} catch (e) {
|
|
93
|
+
entries.delete(element);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return height;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** 估算只用于未测量的占位及滚动几何,不约束展开内容的实际 CSS 高度。 */
|
|
101
|
+
function getRowExpandHeight($table, row, record) {
|
|
102
|
+
const options = $table.computeExpandOpts;
|
|
103
|
+
let estimatedHeight = 0;
|
|
104
|
+
if (!options.height && options.mode === 'fixed' && options.estimateHeight) {
|
|
105
|
+
const estimate = options.estimateHeight({
|
|
106
|
+
row,
|
|
107
|
+
$table
|
|
108
|
+
});
|
|
109
|
+
if (typeof estimate === 'number' && Number.isFinite(estimate) && estimate >= 0) {
|
|
110
|
+
// 例如未挂载子表的条数变化:不能继续使用旧条数的实测高度。
|
|
111
|
+
const previous = estimateValues.get(record);
|
|
112
|
+
if (previous !== undefined && previous !== estimate) record.expandHeight = 0;
|
|
113
|
+
estimateValues.set(record, estimate);
|
|
114
|
+
estimatedHeight = estimate;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return record.expandHeight || options.height || estimatedHeight;
|
|
118
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.createExpandHeightCache=createExpandHeightCache,exports.getRowExpandHeight=getRowExpandHeight;let estimateValues=new WeakMap;function createExpandHeightCache(i,r){let n=new Map,a=!1,o=!1;var e="undefined"!=typeof ResizeObserver&&"undefined"!=typeof MutationObserver;let s=e?new ResizeObserver(e=>{let t=!1;e.forEach(e=>{e=n.get(e.target);e&&(e.dirty=!0,t=!0)}),!t||o||a||(o=!0,i.$nextTick(()=>{o=!1,a||r()}))}):null,t=e?new MutationObserver(i=>{n.forEach((e,t)=>{i.some(e=>t===e.target||t.contains(e.target))&&(e.dirty=!0)})}):null,d=null,h=-1;return i.$once("hook:beforeDestroy",()=>{a=!0,s&&s.disconnect(),t&&t.disconnect(),n.clear(),d=null}),{sync(i){let r=i.clientWidth;d!==i&&(t&&(t.disconnect(),t.observe(i,{subtree:!0,childList:!0,attributes:!0,characterData:!0})),d=i,h=-1),n.forEach((e,t)=>{t.parentElement!==i?(s&&s.unobserve(t),n.delete(t)):r!==h&&(e.dirty=!0)}),h=r},measure(t,e,i){var r=n.get(t);if(s&&i&&r&&r.binding===e&&r.height===e.expandHeight&&!r.dirty)return r.height;i=t.offsetHeight;if(n.set(t,{binding:e,height:i,dirty:!1}),s&&!r)try{s.observe(t,{box:"border-box"})}catch(e){n.delete(t)}return i}}}function getRowExpandHeight(e,t,i){var r=e.computeExpandOpts;let n=0;return!r.height&&"fixed"===r.mode&&r.estimateHeight&&"number"==typeof(t=r.estimateHeight({row:t,$table:e}))&&Number.isFinite(t)&&0<=t&&(void 0!==(e=estimateValues.get(i))&&e!==t&&(i.expandHeight=0),estimateValues.set(i,t),n=t),i.expandHeight||r.height||n}
|
package/lib/table/src/methods.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils"));var _dom=require("../../ui/src/dom");var _utils=require("../../ui/src/utils");var _ui=require("../../ui");var _cell=_interopRequireDefault(require("./cell"));var _util=require("./util");var _vn=require("../../ui/src/vn");var _anime=require("../../ui/src/anime");var _log=require("../../ui/src/log");var _store=require("./store");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}const{warnLog,errLog}=(0,_log.createComponentLog)('table');const{getConfig,getI18n,renderer,formats,interceptor,createEvent,globalEvents,GLOBAL_EVENT_KEYS}=_ui.VxeUI;const supportMaxRow=5e6;const customStorageKey='VXE_CUSTOM_STORE';const maxYHeight=5e6;const maxXWidth=5e6;const sourceType='table';// 仅合并等待同一轮 DOM 更新的展开行位置重算,不保留表格实例。
|
|
2
|
-
const pendingExpandOffsetUpdates=new
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils"));var _dom=require("../../ui/src/dom");var _utils=require("../../ui/src/utils");var _ui=require("../../ui");var _cell=_interopRequireDefault(require("./cell"));var _util=require("./util");var _vn=require("../../ui/src/vn");var _anime=require("../../ui/src/anime");var _log=require("../../ui/src/log");var _store=require("./store");var _expandHeight=require("./expand-height");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}const{warnLog,errLog}=(0,_log.createComponentLog)('table');const{getConfig,getI18n,renderer,formats,interceptor,createEvent,globalEvents,GLOBAL_EVENT_KEYS}=_ui.VxeUI;const supportMaxRow=5e6;const customStorageKey='VXE_CUSTOM_STORE';const maxYHeight=5e6;const maxXWidth=5e6;const sourceType='table';// 仅合并等待同一轮 DOM 更新的展开行位置重算,不保留表格实例。
|
|
2
|
+
const pendingExpandOffsetUpdates=new WeakMap();const expandHeightCaches=new WeakMap();// 仅高度变化可复用前缀;排序、筛选等原有调用仍完整重建索引。
|
|
3
|
+
const rowOffsetIndexes=new WeakMap();let crossTableDragRowObj=null;function eqCellValue(newRow,oldRow,field){const val1=_xeUtils.default.get(newRow,field);const val2=_xeUtils.default.get(oldRow,field);let result=false;if((0,_utils.eqEmptyValue)(val1)&&(0,_utils.eqEmptyValue)(val2)){result=true;}else if(_xeUtils.default.isString(val1)||_xeUtils.default.isNumber(val1)){result=''+val1===''+val2;}else{result=_xeUtils.default.isEqual(val1,val2);}return{newValue:val1,oldValue:val2,result};}function getNextSortOrder($xeTable,column){const sortOpts=$xeTable.computeSortOpts;const{orders=[]}=sortOpts;const currOrder=column.order||null;const oIndex=orders.indexOf(currOrder)+1;return orders[oIndex<orders.length?oIndex:0];}const getCustomStorageMap=id=>{const version=getConfig().version;const rest=_xeUtils.default.toStringJSON(localStorage.getItem(customStorageKey)||'');const maps=rest&&rest._v===version?rest:{_v:version};return(id?maps[id]:maps)||{};};const setCustomStorageMap=(id,data)=>{const version=getConfig().version;const maps=getCustomStorageMap();maps[id]=data||undefined;maps._v=version;localStorage.setItem(customStorageKey,_xeUtils.default.toJSONString(maps));};const getRecoverRowMaps=($xeTable,keyMaps)=>{const internalData=$xeTable;const{fullAllDataRowIdData}=internalData;const restKeys={};_xeUtils.default.each(keyMaps,(row,rowid)=>{if(fullAllDataRowIdData[rowid]){restKeys[rowid]=row;}});return restKeys;};function handleReserveRow($xeTable,reserveRowMap){const internalData=$xeTable;const{fullDataRowIdData}=internalData;const reserveList=[];_xeUtils.default.each(reserveRowMap,(item,rowid)=>{if(fullDataRowIdData[rowid]&&reserveList.indexOf(fullDataRowIdData[rowid].row)===-1){reserveList.push(fullDataRowIdData[rowid].row);}});return reserveList;}function handleVirtualXVisible($xeTable){const reactData=$xeTable;const internalData=$xeTable;const{isScrollXBig,scrollXWidth}=reactData;const{elemStore,visibleColumn,fullColumnIdData}=internalData;const leftFixedWidth=$xeTable.computeLeftFixedWidth;const rightFixedWidth=$xeTable.computeRightFixedWidth;const bodyScrollElem=(0,_util.getRefElem)(elemStore['main-body-scroll']);if(bodyScrollElem){const clientWidth=bodyScrollElem.clientWidth;let scrollLeft=bodyScrollElem.scrollLeft;if(isScrollXBig){scrollLeft=Math.ceil((scrollXWidth-clientWidth)*Math.min(1,scrollLeft/(maxXWidth-clientWidth)));}const startLeft=scrollLeft+leftFixedWidth;const endLeft=scrollLeft+clientWidth-rightFixedWidth;let leftIndex=0;let rightIndex=visibleColumn.length;while(leftIndex<rightIndex){const cIndex=Math.floor((leftIndex+rightIndex)/2);const column=visibleColumn[cIndex];const colid=column.id;const colRest=fullColumnIdData[colid]||{};if(colRest.oLeft<=startLeft){leftIndex=cIndex+1;}else{rightIndex=cIndex;}}let visibleSize=0;const toVisibleIndex=leftIndex===visibleColumn.length?leftIndex:Math.max(0,leftIndex<visibleColumn.length?leftIndex-2:0);for(let cIndex=toVisibleIndex,cLen=visibleColumn.length;cIndex<cLen;cIndex++){const column=visibleColumn[cIndex];const colid=column.id;const colRest=fullColumnIdData[colid]||{};visibleSize++;if(colRest.oLeft>endLeft||visibleSize>=60){break;}}return{toVisibleIndex:Math.max(0,toVisibleIndex),visibleSize:Math.max(6,visibleSize)};}return{toVisibleIndex:0,visibleSize:6};}function handleCustomRestore($xeTable,storeData){const props=$xeTable;const reactData=$xeTable;const internalData=$xeTable;const $xeGrid=$xeTable.$xeGrid;const $xeGantt=$xeTable.$xeGantt;const $xeGGWrapper=$xeGrid||$xeGantt;const{aggregateConfig,rowGroupConfig}=props;const{collectColumn}=internalData;const{isCustomAlign,isCustomHeaderAlign,isCustomFooterAlign,isCustomResizable,isCustomVisible,isCustomFixed,isCustomSort,isCustomAggGroup,isCustomAggFunc,isCustomPager}=(0,_util.handleCustomStoreConfig)($xeTable);let{alignData,headerAlignData,footerAlignData,resizableData,sortData,visibleData,fixedData,aggGroupData,aggFuncData,pagerData}=storeData;// 处理还原
|
|
3
4
|
if(isCustomAlign&&alignData||isCustomHeaderAlign&&headerAlignData||isCustomFooterAlign&&footerAlignData||isCustomResizable&&resizableData||isCustomSort&&sortData||isCustomVisible&&visibleData||isCustomFixed&&fixedData||isCustomAggGroup&&aggGroupData||isCustomAggFunc&&aggFuncData||isCustomPager&&pagerData&&$xeGGWrapper){const sortColMaps={};if(isCustomSort&&sortData){// 转换兼容老版本数据,即将废弃兼容
|
|
4
5
|
if(!_xeUtils.default.isArray(sortData)){const sortRests=[];_xeUtils.default.each(sortData,(index,colKey)=>{sortRests.push({key:colKey,index});});sortData=_xeUtils.default.orderBy(sortRests,{field:'index',order:'asc'}).map(item=>({k:item.key}));}let colNum=1;_xeUtils.default.eachTree(sortData,(sObj,index,sOjs,path,pSObj)=>{sortColMaps[sObj.k]={key:sObj.k,sNum:colNum++,pKey:pSObj?pSObj.k:null};},{children:'c'});}const colKeyMaps={};const allCols=[];const aggGroupConfs=[];_xeUtils.default.eachTree(collectColumn,(column,index,items,path,parentColumn)=>{const colKey=column.getKey();// 支持一级
|
|
5
6
|
if(!parentColumn){if(isCustomFixed&&fixedData&&fixedData[colKey]!==undefined){column.fixed=fixedData[colKey];}}if(isCustomResizable&&resizableData&&_xeUtils.default.isNumber(resizableData[colKey])){column.resizeWidth=resizableData[colKey];}if(isCustomVisible&&visibleData&&_xeUtils.default.isBoolean(visibleData[colKey])){column.visible=visibleData[colKey];}if(isCustomAggFunc&&aggFuncData&&(aggregateConfig||rowGroupConfig)&&aggFuncData[colKey]){column.aggFunc=aggFuncData[colKey];}if(isCustomAggGroup&&aggGroupData&&aggGroupData[colKey]){aggGroupConfs.push({field:column.field});}colKeyMaps[colKey]=column;allCols.push(column);});if((aggregateConfig||rowGroupConfig)&&aggGroupConfs.length){const groupRest=handleGroupData($xeTable,internalData.tableFullData,aggGroupConfs);internalData.tableFullTreeData=[];internalData.tableFullGroupData=groupRest.treeData;reactData.isRowGroupStatus=true;reactData.rowGroupList=aggGroupConfs;$xeTable.cacheRowMap(false);}// 如果自定义了顺序
|
|
@@ -242,12 +243,13 @@ if(reactData.scrollYLoad&&!(internalData.customHeight||internalData.customMinHei
|
|
|
242
243
|
*/function calcColumnAutoWidth($xeTable,column,wrapperEl){const reactData=$xeTable;const{scrollYLoad}=reactData;const columnOpts=$xeTable.computeColumnOpts;const{autoOptions}=columnOpts;const{isCalcHeader,isCalcBody,isCalcFooter}=autoOptions||{};const querySelections=[];if(isCalcHeader){querySelections.push(`.vxe-header-cell--wrapper[colid="${column.id}"]`);}if(isCalcBody){querySelections.push(`.vxe-body-cell--wrapper[colid="${column.id}"]`);}if(isCalcFooter){querySelections.push(`.vxe-footer-cell--wrapper[colid="${column.id}"]`);}const cellElemList=querySelections.length?wrapperEl.querySelectorAll(querySelections.join(',')):[];let leftRightPadding=0;const firstCellEl=cellElemList[0];if(firstCellEl&&firstCellEl.parentElement){const cellStyle=getComputedStyle(firstCellEl.parentElement);leftRightPadding=Math.ceil(_xeUtils.default.toNumber(cellStyle.paddingLeft)+_xeUtils.default.toNumber(cellStyle.paddingRight));}let colWidth=(scrollYLoad?column.renderAutoWidth:0)-leftRightPadding;for(let i=0;i<cellElemList.length;i++){const celEl=cellElemList[i];colWidth=Math.max(colWidth,celEl?Math.ceil(celEl.scrollWidth)+4:0);}return colWidth+leftRightPadding;}/**
|
|
243
244
|
* 自适应列宽
|
|
244
245
|
*/function calcCellWidth($xeTable){const internalData=$xeTable;const autoWidthColumnList=$xeTable.computeAutoWidthColumnList;const{fullColumnIdData}=internalData;const el=$xeTable.$refs.refElem;if(el&&autoWidthColumnList.length){el.setAttribute('data-calc-col','Y');autoWidthColumnList.forEach(column=>{const colid=column.id;const colRest=fullColumnIdData[colid];const colWidth=calcColumnAutoWidth($xeTable,column,el);if(colRest){colRest.width=Math.max(colWidth,colRest.width);}column.renderAutoWidth=colWidth;});$xeTable.analyColumnWidth();el.removeAttribute('data-calc-col');}}function handleUpdateColResize($xeTable,evnt,params){$xeTable.analyColumnWidth();$xeTable.recalculate().then(()=>{$xeTable.saveCustomStore('update:width');$xeTable.refreshScroll().then(()=>{$xeTable.updateCellAreas();});$xeTable.dispatchEvent('column-resizable-change',params,evnt);// 已废弃 resizable-change
|
|
245
|
-
$xeTable.dispatchEvent('resizable-change',params,evnt);setTimeout(()=>$xeTable.recalculate(true),300);});}function handleUpdateRowResize($xeTable,evnt,params){const reactData=$xeTable;reactData.resizeHeightFlag++;$xeTable.recalculate().then(()=>{$xeTable.refreshScroll().then(()=>{$xeTable.updateCellAreas();});$xeTable.dispatchEvent('row-resizable-change',params,evnt);setTimeout(()=>$xeTable.recalculate(true),300);});}function updateColumnOffsetLeft($xeTable){const internalData=$xeTable;const{visibleColumn,fullColumnIdData}=internalData;const el=$xeTable.$refs.refElem;if(!el||!el.clientWidth){return;}let offsetLeft=0;for(let cIndex=0,rLen=visibleColumn.length;cIndex<rLen;cIndex++){const column=visibleColumn[cIndex];const colid=column.id;const colRest=fullColumnIdData[colid];if(colRest){colRest.oLeft=offsetLeft;}offsetLeft+=column.renderWidth;}}function updateRowOffsetTop($xeTable){const reactData=$xeTable;const internalData=$xeTable;const{expandColumn}=reactData;const{afterFullData,fullAllDataRowIdData,rowExpandedMaps}=internalData;const el=$xeTable.$refs.refElem;if(!el||!el.clientWidth){return;}const
|
|
246
|
-
if(expandColumn&&rowExpandedMaps[rowid]){offsetTop+=rowRest
|
|
246
|
+
$xeTable.dispatchEvent('resizable-change',params,evnt);setTimeout(()=>$xeTable.recalculate(true),300);});}function handleUpdateRowResize($xeTable,evnt,params){const reactData=$xeTable;reactData.resizeHeightFlag++;$xeTable.recalculate().then(()=>{$xeTable.refreshScroll().then(()=>{$xeTable.updateCellAreas();});$xeTable.dispatchEvent('row-resizable-change',params,evnt);setTimeout(()=>$xeTable.recalculate(true),300);});}function updateColumnOffsetLeft($xeTable){const internalData=$xeTable;const{visibleColumn,fullColumnIdData}=internalData;const el=$xeTable.$refs.refElem;if(!el||!el.clientWidth){return;}let offsetLeft=0;for(let cIndex=0,rLen=visibleColumn.length;cIndex<rLen;cIndex++){const column=visibleColumn[cIndex];const colid=column.id;const colRest=fullColumnIdData[colid];if(colRest){colRest.oLeft=offsetLeft;}offsetLeft+=column.renderWidth;}}function updateRowOffsetTop($xeTable,dirtyIndex=0){const reactData=$xeTable;const internalData=$xeTable;const{expandColumn}=reactData;const{afterFullData,fullAllDataRowIdData,rowExpandedMaps}=internalData;const el=$xeTable.$refs.refElem;if(!el||!el.clientWidth){return;}const rowOpts=$xeTable.computeRowOpts;const cellOpts=$xeTable.computeCellOpts;const defaultRowHeight=$xeTable.computeDefaultRowHeight;const{handleGetRowId}=(0,_util.createHandleGetRowId)($xeTable);const previous=rowOffsetIndexes.get($xeTable);let startIndex=previous&&previous.rows===afterFullData&&previous.cache===fullAllDataRowIdData?Math.max(0,Math.min(dirtyIndex,afterFullData.length)):0;const firstRow=afterFullData[startIndex];const firstRest=firstRow?fullAllDataRowIdData[handleGetRowId(firstRow)]:null;if(startIndex&&(!firstRest||!Number.isFinite(firstRest.oTop)))startIndex=0;const indexes=startIndex&&previous?previous.indexes:new Map();let offsetTop=startIndex&&firstRest?firstRest.oTop:0;for(let rIndex=startIndex,rLen=afterFullData.length;rIndex<rLen;rIndex++){const row=afterFullData[rIndex];const rowid=handleGetRowId(row);const rowRest=fullAllDataRowIdData[rowid]||{};if(expandColumn)indexes.set(rowid,rIndex);rowRest.oTop=offsetTop;offsetTop+=(0,_util.getCellRestHeight)(rowRest,cellOpts,rowOpts,defaultRowHeight);// 是否展开行
|
|
247
|
+
if(expandColumn&&rowExpandedMaps[rowid]){offsetTop+=(0,_expandHeight.getRowExpandHeight)($xeTable,row,rowRest);}}rowOffsetIndexes.set($xeTable,{rows:afterFullData,cache:fullAllDataRowIdData,indexes});// 完整重算也覆盖了此前排队的高度变化,避免下一轮重复计算。
|
|
248
|
+
pendingExpandOffsetUpdates.delete($xeTable);}/**
|
|
247
249
|
* 更新展开行样式
|
|
248
|
-
*/function updateRowExpandStyle($xeTable){const reactData=$xeTable;const internalData=$xeTable;const{expandColumn,scrollYLoad,scrollYTop,isScrollYBig}=reactData;const el=$xeTable.$refs.refElem;if(!el||!el.clientWidth){return;}const expandOpts=$xeTable.computeExpandOpts;const{mode}=expandOpts;if(expandColumn&&mode==='fixed'){const{elemStore,fullAllDataRowIdData}=internalData;const rowOpts=$xeTable.computeRowOpts;const cellOpts=$xeTable.computeCellOpts;const defaultRowHeight=$xeTable.computeDefaultRowHeight;const rowExpandEl=$xeTable.$refs.refRowExpandElem;const bodyScrollElem=(0,_util.getRefElem)(elemStore['main-body-scroll']);if(rowExpandEl&&bodyScrollElem){let isUpdateHeight=false;const expandStyles=[];// 先集中读取尺寸,避免每个展开区写 top 后又读取下一个展开区的布局。
|
|
249
|
-
_xeUtils.default.arrayEach(rowExpandEl.children,reEl=>{const expandEl=reEl;const rowid=expandEl.getAttribute('rowid')||'';const rowRest=fullAllDataRowIdData[rowid];if(rowRest){const expandHeight=expandEl.
|
|
250
|
-
const trEl=!scrollYLoad||isScrollYBig?bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`):null;let offsetTop=0;if(scrollYLoad){if(isScrollYBig&&trEl){offsetTop=trEl.offsetTop+trEl.offsetHeight;}else{offsetTop=rowRest.oTop+(0,_util.getCellRestHeight)(rowRest,cellOpts,rowOpts,defaultRowHeight);}}else{if(trEl){offsetTop=trEl.offsetTop+trEl.offsetHeight;}}if(isScrollYBig){offsetTop+=scrollYTop;}expandStyles.push({el:expandEl,top:(0,_dom.toCssUnit)(offsetTop)});if(
|
|
250
|
+
*/function updateRowExpandStyle($xeTable,forceMeasure=false){const reactData=$xeTable;const internalData=$xeTable;const{expandColumn,scrollYLoad,scrollYTop,isScrollYBig}=reactData;const el=$xeTable.$refs.refElem;if(!el||!el.clientWidth){return;}const expandOpts=$xeTable.computeExpandOpts;const{mode}=expandOpts;if(expandColumn&&mode==='fixed'){const{elemStore,fullAllDataRowIdData}=internalData;const rowOpts=$xeTable.computeRowOpts;const cellOpts=$xeTable.computeCellOpts;const defaultRowHeight=$xeTable.computeDefaultRowHeight;const rowExpandEl=$xeTable.$refs.refRowExpandElem;const bodyScrollElem=(0,_util.getRefElem)(elemStore['main-body-scroll']);if(rowExpandEl&&bodyScrollElem){const previousHeightCache=expandHeightCaches.get($xeTable);const heightCache=previousHeightCache||(0,_expandHeight.createExpandHeightCache)($xeTable,()=>updateRowExpandStyle($xeTable,true));if(!previousHeightCache){$xeTable.$once('hook:beforeDestroy',()=>{pendingExpandOffsetUpdates.delete($xeTable);rowOffsetIndexes.delete($xeTable);expandHeightCaches.delete($xeTable);});}expandHeightCaches.set($xeTable,heightCache);heightCache.sync(rowExpandEl);let isUpdateHeight=false;let dirtyIndex=Infinity;const offsetIndex=rowOffsetIndexes.get($xeTable);const expandStyles=[];// 先集中读取尺寸,避免每个展开区写 top 后又读取下一个展开区的布局。
|
|
251
|
+
_xeUtils.default.arrayEach(rowExpandEl.children,reEl=>{const expandEl=reEl;const rowid=expandEl.getAttribute('rowid')||'';const rowRest=fullAllDataRowIdData[rowid];if(rowRest){const expandHeight=heightCache.measure(expandEl,rowRest,!!internalData.inVirtualScroll&&!forceMeasure);// 普通虚拟滚动使用缓存位置,无需为每个展开区查询主表行 DOM。
|
|
252
|
+
const trEl=!scrollYLoad||isScrollYBig?bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`):null;let offsetTop=0;if(scrollYLoad){if(isScrollYBig&&trEl){offsetTop=trEl.offsetTop+trEl.offsetHeight;}else{offsetTop=rowRest.oTop+(0,_util.getCellRestHeight)(rowRest,cellOpts,rowOpts,defaultRowHeight);}}else{if(trEl){offsetTop=trEl.offsetTop+trEl.offsetHeight;}}if(isScrollYBig){offsetTop+=scrollYTop;}expandStyles.push({el:expandEl,top:(0,_dom.toCssUnit)(offsetTop)});if(rowRest.expandHeight!==expandHeight){isUpdateHeight=true;const index=offsetIndex&&offsetIndex.rows===internalData.afterFullData&&offsetIndex.cache===fullAllDataRowIdData?offsetIndex.indexes.get(rowid):undefined;dirtyIndex=Math.min(dirtyIndex,index===undefined?0:index);}rowRest.expandHeight=expandHeight;}});expandStyles.forEach(({el,top})=>{if(el.style.top!==top){el.style.top=top;}});if(isUpdateHeight){reactData.rowExpandHeightFlag++;const pendingIndex=pendingExpandOffsetUpdates.get($xeTable);pendingExpandOffsetUpdates.set($xeTable,Math.min(pendingIndex===undefined?Infinity:pendingIndex,dirtyIndex));if(pendingIndex===undefined){$xeTable.$nextTick(()=>{const index=pendingExpandOffsetUpdates.get($xeTable);if(index!==undefined){pendingExpandOffsetUpdates.delete($xeTable);updateRowOffsetTop($xeTable,index);updateRowExpandStyle($xeTable);$xeTable.updateScrollYSpace();if(reactData.scrollYLoad)loadScrollYData($xeTable);}});}}}}}/**
|
|
251
253
|
* 更新树连接线样式
|
|
252
254
|
*/function updateTreeLineStyle($xeTable){const props=$xeTable;const reactData=$xeTable;const internalData=$xeTable;const{treeConfig}=props;if(!treeConfig){return;}const{tableData}=reactData;const{fullAllDataRowIdData,treeExpandedMaps}=internalData;const el=$xeTable.$refs.refElem;if(!el||!el.clientWidth){return;}const cellOpts=$xeTable.computeCellOpts;const rowOpts=$xeTable.computeRowOpts;const defaultRowHeight=$xeTable.computeDefaultRowHeight;const treeOpts=$xeTable.computeTreeOpts;const{transform,mapChildrenField}=treeOpts;const childrenField=treeOpts.children||treeOpts.childrenField;const{handleGetRowId}=(0,_util.createHandleGetRowId)($xeTable);const expParentList=[];const handleNodeRow=(row,rIndex,rows)=>{const rowid=handleGetRowId(row);const rowRest=fullAllDataRowIdData[rowid]||{};const childList=row[transform?mapChildrenField:childrenField];const prevRow=rows[rIndex-1]||null;const nextRow=rows[rIndex+1]||null;if(childList&&childList.length&&treeExpandedMaps[rowid]){expParentList.push({row,prevRow,nextRow});childList.forEach((childRow,crIndex)=>{const childRowid=handleGetRowId(childRow);if(treeExpandedMaps[childRowid]){handleNodeRow(childRow,crIndex,childList);}});}else{if(nextRow){const nextRowid=handleGetRowId(nextRow);const nextRowRest=fullAllDataRowIdData[nextRowid]||{};const currCellHeight=(0,_util.getCellRestHeight)(rowRest,cellOpts,rowOpts,defaultRowHeight);const nextCellHeight=(0,_util.getCellRestHeight)(nextRowRest,cellOpts,rowOpts,defaultRowHeight);rowRest.oHeight=currCellHeight;rowRest.lineHeight=Math.floor(currCellHeight/2+nextCellHeight/2);}else{rowRest.oHeight=0;rowRest.lineHeight=0;}}};tableData.forEach((row,rIndex)=>{handleNodeRow(row,rIndex,tableData);});_xeUtils.default.lastArrayEach(expParentList,({row,nextRow})=>{const rowid=handleGetRowId(row);const childList=row[transform?mapChildrenField:childrenField];const rowRest=fullAllDataRowIdData[rowid];if(rowRest){const currCellHeight=(0,_util.getCellRestHeight)(rowRest,cellOpts,rowOpts,defaultRowHeight);let countOffsetHeight=currCellHeight;let countLineHeight=0;childList.forEach(childRow=>{const childRowid=handleGetRowId(childRow);const childRowRest=fullAllDataRowIdData[childRowid]||{};const childList=childRow[transform?mapChildrenField:childrenField];if(treeExpandedMaps[childRowid]&&childList&&childList.length){countOffsetHeight+=childRowRest.oHeight||0;countLineHeight+=childRowRest.oHeight||0;}else{const cellHeight=(0,_util.getCellRestHeight)(childRowRest,cellOpts,rowOpts,defaultRowHeight);childRowRest.oHeight=cellHeight;childRowRest.lineHeight=cellHeight;countOffsetHeight+=cellHeight;countLineHeight+=cellHeight;}});if(nextRow){const nextRowid=handleGetRowId(nextRow);const nextRowRest=fullAllDataRowIdData[nextRowid]||{};const currCellHeight=(0,_util.getCellRestHeight)(rowRest,cellOpts,rowOpts,defaultRowHeight);const nextCellHeight=(0,_util.getCellRestHeight)(nextRowRest,cellOpts,rowOpts,defaultRowHeight);countOffsetHeight+=currCellHeight;countLineHeight+=Math.floor(currCellHeight/2+nextCellHeight/2);}rowRest.lineHeight=countLineHeight;rowRest.oHeight=countOffsetHeight;}});}function handleRowExpandScroll($xeTable){const internalData=$xeTable;const{elemStore}=internalData;const rowExpandEl=$xeTable.$refs.refRowExpandElem;const bodyScrollElem=(0,_util.getRefElem)(elemStore['main-body-scroll']);if(rowExpandEl&&bodyScrollElem){rowExpandEl.scrollTop=bodyScrollElem.scrollTop;}}function handleColumnVisible(visible){return function(fieldOrColumn){const $xeTable=this;let status=false;const cols=_xeUtils.default.isArray(fieldOrColumn)?fieldOrColumn:[fieldOrColumn];cols.forEach(item=>{const column=(0,_util.handleFieldOrColumn)($xeTable,item);if(column){if(column.children&&column.children.length){_xeUtils.default.eachTree([column],item=>{item.visible=visible;item.renderVisible=visible;});}else{column.visible=visible;column.renderVisible=visible;}if(!status){status=true;}}});if(status){return $xeTable.handleCustom();}return $xeTable.$nextTick();};}function reUpdateCustomStyleEvent($xeTable,evnt){const reactData=$xeTable;const{customStore}=reactData;const customOpts=$xeTable.computeCustomOpts;const{popupOptions}=customOpts;const{transfer}=popupOptions||{};if(transfer&&customStore.visible){const tableCustom=$xeTable.$refs.refTableCustom;if(tableCustom&&$xeTable.handleCustomStyle&&!(0,_dom.checkTargetElement)(evnt.target,[tableCustom.$el],evnt.currentTarget)){$xeTable.handleCustomStyle().then(()=>{$xeTable.handleCustomStyle();});}}}function truncateStackHistory($xeTable){const internalData=$xeTable;const{stackHistoryStore}=internalData;const{undoStacks}=stackHistoryStore;const undoRedoHistoryOpts=$xeTable.computeUndoRedoHistoryOpts;const{stackSize}=undoRedoHistoryOpts;if(undoStacks.length>_xeUtils.default.toNumber(stackSize)){undoStacks.shift();}}/**
|
|
253
255
|
* 生成快照数据
|
|
@@ -494,7 +496,8 @@ setTimeout(resolve,10);});}internalData.intoRunScroll=true;// 重置
|
|
|
494
496
|
setTimeout(()=>{internalData.intoRunScroll=false;resolve();},10);});},handleResizeEvent(){const $xeTable=this;handleResizeEvent($xeTable);},/**
|
|
495
497
|
* 重新渲染布局
|
|
496
498
|
* 刷新布局
|
|
497
|
-
*/recalculate(reFull){const $xeTable=this;const isForce=!!reFull;return handleLazyRecalculate($xeTable,isForce,isForce,isForce);},
|
|
499
|
+
*/recalculate(reFull){const $xeTable=this;const isForce=!!reFull;return handleLazyRecalculate($xeTable,isForce,isForce,isForce);},refreshRowExpandHeight(){const $xeTable=this;return $xeTable.$nextTick().then(()=>{updateRowExpandStyle($xeTable,true);// 等待同一轮高度变化的位置重算及其 DOM 更新。
|
|
500
|
+
return $xeTable.$nextTick().then(()=>$xeTable.$nextTick());});},updateStyle(){const $xeTable=this;return updateStyle($xeTable);},/**
|
|
498
501
|
* 处理固定列的显示状态
|
|
499
502
|
*/checkScrolling(){const $xeTable=this;const internalData=$xeTable;const{elemStore}=internalData;const bodyScrollElem=(0,_util.getRefElem)(elemStore['main-body-scroll']);const leftContainerElem=$xeTable.$refs.refLeftContainer;const rightContainerElem=$xeTable.$refs.refRightContainer;const xHandleEl=$xeTable.$refs.refScrollXHandleElem;const bodtTargetEl=xHandleEl||bodyScrollElem;if(bodtTargetEl){if(leftContainerElem){if(bodtTargetEl.scrollLeft>0){(0,_dom.addClass)(leftContainerElem,'scrolling--middle');}else{(0,_dom.removeClass)(leftContainerElem,'scrolling--middle');}}if(rightContainerElem){if(bodtTargetEl.clientWidth<bodtTargetEl.scrollWidth-Math.ceil(bodtTargetEl.scrollLeft)){(0,_dom.addClass)(rightContainerElem,'scrolling--middle');}else{(0,_dom.removeClass)(rightContainerElem,'scrolling--middle');}}}},preventEvent(evnt,type,args,next,end){const $xeTable=this;const $xeGrid=$xeTable.$xeGrid;const $xeGantt=$xeTable.$xeGantt;let evntList=interceptor.get(type);// 兼容老版本
|
|
500
503
|
if(!evntList.length&&type==='event.clearEdit'){evntList=interceptor.get('event.clearActived');if(evntList.length){warnLog('vxe.error.delEvent',['event.clearActived','event.clearEdit']);}}// 兼容老版本
|
|
@@ -831,9 +834,9 @@ updateScrollXSpace(){const $xeTable=this;const reactData=$xeTable;const internal
|
|
|
831
834
|
let isScrollXBig=false;let ySpaceWidth=scrollXWidth;if(scrollXWidth>maxXWidth){// 触右
|
|
832
835
|
if(bodyScrollElem&&bodyTableElem&&bodyScrollElem.scrollLeft+clientWidth>=maxXWidth){xSpaceLeft=maxXWidth-bodyTableElem.clientWidth;}else{xSpaceLeft=(maxXWidth-clientWidth)*(xSpaceLeft/(scrollXWidth-clientWidth));}ySpaceWidth=maxXWidth;isScrollXBig=true;}if(!(scrollXLoad&&overflowX)){xSpaceLeft=0;}if(getConfig().scrollMarginStyle){// 已废弃方式
|
|
833
836
|
if(headerTableElem){headerTableElem.style.marginLeft=headerTableElem.getAttribute('xvm')?`${xSpaceLeft}px`:'';}if(bodyTableElem){bodyTableElem.style.marginLeft=`${xSpaceLeft}px`;}if(footerTableElem){footerTableElem.style.marginLeft=footerTableElem.getAttribute('xvm')?`${xSpaceLeft}px`:'';}}else{if(headerTableElem){headerTableElem.style.transform=headerTableElem.getAttribute('xvm')?`translate(${xSpaceLeft}px, 0px)`:'';}if(bodyTableElem){bodyTableElem.style.transform=`translate(${xSpaceLeft}px, ${reactData.scrollYTop||0}px)`;}if(footerTableElem){footerTableElem.style.transform=footerTableElem.getAttribute('xvm')?`translate(${xSpaceLeft}px, 0px)`:'';}}const containerList=['main'];containerList.forEach(name=>{const layoutList=['header','body','footer'];layoutList.forEach(layout=>{const xSpaceElem=(0,_util.getRefElem)(elemStore[`${name}-${layout}-xSpace`]);if(xSpaceElem){xSpaceElem.style.width=scrollXLoad?`${ySpaceWidth}px`:'';}});});reactData.scrollXLeft=xSpaceLeft;reactData.scrollXWidth=ySpaceWidth;reactData.isScrollXBig=isScrollXBig;const scrollXSpaceEl=$xeTable.$refs.refScrollXSpaceElem;if(scrollXSpaceEl){scrollXSpaceEl.style.width=`${ySpaceWidth}px`;}calcScrollbar($xeTable);if(isScrollXBig&&mouseOpts.area){errLog('vxe.error.notProp',['mouse-config.area']);}if($xeGanttView&&$xeGanttView.handleUpdateSXSpace){$xeGanttView.handleUpdateSXSpace();}return $xeTable.$nextTick(()=>{updateStyle($xeTable);});}},updateScrollYData(){const $xeTable=this;$xeTable.handleTableData();$xeTable.updateScrollYSpace();return $xeTable.$nextTick().then(()=>{$xeTable.handleTableData(false,true);$xeTable.updateScrollYSpace();});},// 更新纵向 Y 可视渲染上下剩余空间大小
|
|
834
|
-
updateScrollYSpace(){const $xeTable=this;const reactData=$xeTable;const internalData=$xeTable;const{isAllOverflow,overflowY,scrollYLoad,scrollYHeight,expandColumn}=reactData;const{scrollYStore,elemStore,isResizeCellHeight,afterFullData,fullAllDataRowIdData,rowExpandedMaps}=internalData;const $xeGanttView=internalData.xeGanttView;const{startIndex}=scrollYStore;const mouseOpts=$xeTable.computeMouseOpts;const
|
|
837
|
+
updateScrollYSpace(){const $xeTable=this;const reactData=$xeTable;const internalData=$xeTable;const{isAllOverflow,overflowY,scrollYLoad,scrollYHeight,expandColumn}=reactData;const{scrollYStore,elemStore,isResizeCellHeight,afterFullData,fullAllDataRowIdData,rowExpandedMaps}=internalData;const $xeGanttView=internalData.xeGanttView;const{startIndex}=scrollYStore;const mouseOpts=$xeTable.computeMouseOpts;const rowOpts=$xeTable.computeRowOpts;const cellOpts=$xeTable.computeCellOpts;const defaultRowHeight=$xeTable.computeDefaultRowHeight;const bodyScrollElem=(0,_util.getRefElem)(elemStore['main-body-scroll']);const bodyTableElem=(0,_util.getRefElem)(elemStore['main-body-table']);const leftBodyTableElem=(0,_util.getRefElem)(elemStore['left-body-table']);const rightbodyTableElem=(0,_util.getRefElem)(elemStore['right-body-table']);const containerList=['main','left','right'];let ySpaceTop=0;let sYHeight=scrollYHeight;let isScrollYBig=false;if(scrollYLoad){const isCustomCellHeight=isResizeCellHeight||cellOpts.height||rowOpts.height;if(!isCustomCellHeight&&!expandColumn&&isAllOverflow){sYHeight=afterFullData.length*defaultRowHeight;if(sYHeight>maxYHeight){isScrollYBig=true;}ySpaceTop=Math.max(0,startIndex*defaultRowHeight);}else{const firstRow=afterFullData[startIndex];if(firstRow){let rowid=(0,_util.getRowid)($xeTable,firstRow);let rowRest=fullAllDataRowIdData[rowid]||{};ySpaceTop=rowRest.oTop||0;const lastRow=afterFullData[afterFullData.length-1];rowid=(0,_util.getRowid)($xeTable,lastRow);rowRest=fullAllDataRowIdData[rowid]||{};if(rowRest){const rHeight=(0,_util.getCellRestHeight)(rowRest,cellOpts,rowOpts,defaultRowHeight);// 如果为空时还没计算完数据,保持原高度不变
|
|
835
838
|
if(rHeight){sYHeight=(rowRest.oTop||0)+rHeight;// 是否展开行
|
|
836
|
-
if(expandColumn&&rowExpandedMaps[rowid]){sYHeight+=rowRest
|
|
839
|
+
if(expandColumn&&rowExpandedMaps[rowid]){sYHeight+=(0,_expandHeight.getRowExpandHeight)($xeTable,lastRow,rowRest);}}}if(sYHeight>maxYHeight){isScrollYBig=true;}}else{sYHeight=bodyTableElem?bodyTableElem.clientHeight:0;}}}else{if(bodyTableElem){sYHeight=bodyTableElem.clientHeight;}}let clientHeight=0;if(bodyScrollElem){clientHeight=bodyScrollElem.clientHeight;}// 虚拟渲染
|
|
837
840
|
let ySpaceHeight=sYHeight;let scrollYTop=ySpaceTop;if(isScrollYBig){// 触底
|
|
838
841
|
if(bodyScrollElem&&bodyTableElem&&bodyScrollElem.scrollTop+clientHeight>=maxYHeight){scrollYTop=maxYHeight-bodyTableElem.clientHeight;}else{scrollYTop=(maxYHeight-clientHeight)*(ySpaceTop/(scrollYHeight-clientHeight));}ySpaceHeight=maxYHeight;}if(!(scrollYLoad&&overflowY)){scrollYTop=0;}if(getConfig().scrollMarginStyle){if(leftBodyTableElem){leftBodyTableElem.style.marginTop=`${scrollYTop}px`;}if(bodyTableElem){bodyTableElem.style.marginTop=`${scrollYTop}px`;}if(rightbodyTableElem){rightbodyTableElem.style.marginTop=`${scrollYTop}px`;}}else{if(leftBodyTableElem){leftBodyTableElem.style.transform=`translate(0px, ${scrollYTop}px)`;}if(bodyTableElem){bodyTableElem.style.transform=`translate(${reactData.scrollXLeft||0}px, ${scrollYTop}px)`;}if(rightbodyTableElem){rightbodyTableElem.style.transform=`translate(0px, ${scrollYTop}px)`;}}containerList.forEach(name=>{const layoutList=['header','body','footer'];layoutList.forEach(layout=>{const ySpaceElem=(0,_util.getRefElem)(elemStore[`${name}-${layout}-ySpace`]);if(ySpaceElem){ySpaceElem.style.height=ySpaceHeight?`${ySpaceHeight}px`:'';}});});const scrollYSpaceEl=$xeTable.$refs.refScrollYSpaceElem;if(scrollYSpaceEl){scrollYSpaceEl.style.height=ySpaceHeight?`${ySpaceHeight}px`:'';}const rowExpandYSpaceEl=$xeTable.$refs.refRowExpandYSpaceElem;if(rowExpandYSpaceEl){rowExpandYSpaceEl.style.height=ySpaceHeight?`${ySpaceHeight}px`:'';}reactData.scrollYTop=scrollYTop;reactData.scrollYHeight=isScrollYBig?sYHeight:ySpaceHeight;reactData.isScrollYBig=isScrollYBig;calcScrollbar($xeTable);if(isScrollYBig&&mouseOpts.area){errLog('vxe.error.notProp',['mouse-config.area']);}if($xeGanttView&&$xeGanttView.handleUpdateSYSpace){$xeGanttView.handleUpdateSYSpace();}return $xeTable.$nextTick().then(()=>{return updateStyle($xeTable);});},updateScrollYStatus(fullData){const $xeTable=this;return updateScrollYStatus($xeTable,fullData);},/**
|
|
839
842
|
* 如果有滚动条,则滚动到对应的位置
|