vxe-table 4.19.4 → 4.19.6
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/dist/all.esm.js +188 -31
- package/dist/style.css +1 -1
- package/es/style.css +1 -1
- package/es/table/module/export/hook.js +3 -3
- package/es/table/src/cell.js +8 -7
- package/es/table/src/columnInfo.js +1 -4
- package/es/table/src/emits.js +1 -0
- package/es/table/src/table.js +135 -12
- package/es/table/src/util.js +28 -8
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/index.umd.js +65 -43
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/export/hook.js +3 -3
- package/lib/table/module/export/hook.min.js +1 -1
- package/lib/table/src/cell.js +8 -8
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/columnInfo.js +1 -5
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/emits.js +1 -1
- package/lib/table/src/emits.min.js +1 -1
- package/lib/table/src/table.js +17 -14
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +31 -7
- package/lib/table/src/util.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/module/export/hook.ts +3 -3
- package/packages/table/src/cell.ts +8 -7
- package/packages/table/src/columnInfo.ts +1 -5
- package/packages/table/src/emits.ts +1 -0
- package/packages/table/src/table.ts +137 -13
- package/packages/table/src/util.ts +27 -8
- /package/es/{iconfont.1779936744129.ttf → iconfont.1780293024194.ttf} +0 -0
- /package/es/{iconfont.1779936744129.woff → iconfont.1780293024194.woff} +0 -0
- /package/es/{iconfont.1779936744129.woff2 → iconfont.1780293024194.woff2} +0 -0
- /package/lib/{iconfont.1779936744129.ttf → iconfont.1780293024194.ttf} +0 -0
- /package/lib/{iconfont.1779936744129.woff → iconfont.1780293024194.woff} +0 -0
- /package/lib/{iconfont.1779936744129.woff2 → iconfont.1780293024194.woff2} +0 -0
package/lib/table/src/table.js
CHANGED
|
@@ -47,19 +47,20 @@ if(reactData.scrollYLoad&&!(internalData.customHeight||internalData.customMinHei
|
|
|
47
47
|
* 支持动态列表调整分配
|
|
48
48
|
* 支持自动分配偏移量
|
|
49
49
|
* 支持 width=60 width=60px width=10% min-width=60 min-width=60px min-width=10%
|
|
50
|
-
*/const autoCellWidth=()=>{const{elemStore}=internalData;const bodyWrapperElem=(0,_util.getRefElem)(elemStore['main-body-wrapper']);if(!bodyWrapperElem){return;}const yHandleEl=refScrollYHandleElem.value;if(!yHandleEl){return;}const xHandleEl=refScrollXHandleElem.value;if(!xHandleEl){return;}let tWidth=0;const minCellWidth=40;// 列宽最少限制 40px
|
|
51
|
-
const bodyWidth=bodyWrapperElem.clientWidth;let remainWidth=bodyWidth;let meanWidth=remainWidth/100;const{fit}=props;const{columnStore}=reactData;const{resizeList,pxMinList,autoMinList,pxList,scaleList,scaleMinList,autoList,remainList}=columnStore;// 最小宽
|
|
52
|
-
pxMinList.forEach(column=>{
|
|
53
|
-
autoMinList.forEach(column=>{
|
|
54
|
-
scaleMinList.forEach(column=>{
|
|
55
|
-
scaleList.forEach(column=>{
|
|
56
|
-
pxList.forEach(column=>{
|
|
57
|
-
autoList.forEach(column=>{
|
|
58
|
-
resizeList.forEach(column=>{const reWidth=_xeUtils.default.toInteger(column.resizeWidth);tWidth+=reWidth;column.renderWidth=reWidth;});remainWidth-=tWidth;meanWidth=remainWidth>0?Math.floor(remainWidth/(
|
|
50
|
+
*/const autoCellWidth=()=>{const{elemStore}=internalData;const bodyWrapperElem=(0,_util.getRefElem)(elemStore['main-body-wrapper']);if(!bodyWrapperElem){return;}const yHandleEl=refScrollYHandleElem.value;if(!yHandleEl){return;}const xHandleEl=refScrollXHandleElem.value;if(!xHandleEl){return;}const columnOpts=computeColumnOpts.value;let tWidth=0;const minCellWidth=40;// 列宽最少限制 40px
|
|
51
|
+
const bodyWidth=bodyWrapperElem.clientWidth;let remainWidth=bodyWidth;let meanWidth=remainWidth/100;const{fit}=props;const{columnStore}=reactData;const{resizeList,pxMinList,autoMinList,pxList,scaleList,scaleMinList,autoList,remainList}=columnStore;const parseColumnMaxWidth=column=>{const maxWidth=column.maxWidth||columnOpts.maxWidth;if(maxWidth&&maxWidth!=='auto'){if((0,_dom.isScale)(maxWidth)){return Math.floor(_xeUtils.default.toInteger(maxWidth)*meanWidth);}return _xeUtils.default.toInteger(maxWidth);}return 0;};// 最小宽
|
|
52
|
+
pxMinList.forEach(column=>{let miWidth=_xeUtils.default.toInteger(column.minWidth);const mxWidth=parseColumnMaxWidth(column);if(mxWidth){miWidth=Math.min(miWidth,mxWidth);}tWidth+=miWidth;column.renderWidth=miWidth;});// 最小自适应
|
|
53
|
+
autoMinList.forEach(column=>{let caWidth=Math.max(60,_xeUtils.default.toInteger(column.renderAutoWidth));const mxWidth=parseColumnMaxWidth(column);if(mxWidth){caWidth=Math.min(caWidth,mxWidth);}tWidth+=caWidth;column.renderWidth=caWidth;});// 最小百分比
|
|
54
|
+
scaleMinList.forEach(column=>{let smWidth=Math.floor(_xeUtils.default.toInteger(column.minWidth)*meanWidth);const mxWidth=parseColumnMaxWidth(column);if(mxWidth){smWidth=Math.min(smWidth,mxWidth);}tWidth+=smWidth;column.renderWidth=smWidth;});// 固定百分比
|
|
55
|
+
scaleList.forEach(column=>{let sfWidth=Math.floor(_xeUtils.default.toInteger(column.width)*meanWidth);const mxWidth=parseColumnMaxWidth(column);if(mxWidth){sfWidth=Math.min(sfWidth,mxWidth);}tWidth+=sfWidth;column.renderWidth=sfWidth;});// 固定宽
|
|
56
|
+
pxList.forEach(column=>{let pWidth=_xeUtils.default.toInteger(column.width);const mxWidth=parseColumnMaxWidth(column);if(mxWidth){pWidth=Math.min(pWidth,mxWidth);}tWidth+=pWidth;column.renderWidth=pWidth;});// 自适应宽
|
|
57
|
+
autoList.forEach(column=>{let aWidth=Math.max(60,_xeUtils.default.toInteger(column.renderAutoWidth));const mxWidth=parseColumnMaxWidth(column);if(mxWidth){aWidth=Math.min(aWidth,mxWidth);}tWidth+=aWidth;column.renderWidth=aWidth;});// 调整了列宽
|
|
58
|
+
resizeList.forEach(column=>{const reWidth=_xeUtils.default.toInteger(column.resizeWidth);tWidth+=reWidth;column.renderWidth=reWidth;});const zoomColumnList=scaleMinList.concat(pxMinList).concat(autoMinList).filter(column=>!parseColumnMaxWidth(column));remainWidth-=tWidth;meanWidth=remainWidth>0?Math.floor(remainWidth/(zoomColumnList.length+remainList.length)):0;if(fit){if(remainWidth>0){zoomColumnList.forEach(column=>{tWidth+=meanWidth;column.renderWidth+=meanWidth;});}}else{meanWidth=minCellWidth;}// 剩余均分
|
|
59
59
|
remainList.forEach(column=>{const width=Math.max(meanWidth,minCellWidth);column.renderWidth=width;tWidth+=width;});if(fit){/**
|
|
60
60
|
* 偏移量算法
|
|
61
61
|
* 如果所有列足够放的情况下,从最后动态列开始分配
|
|
62
|
-
|
|
62
|
+
* 排除已设置 max-width
|
|
63
|
+
*/const dynamicList=scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList).filter(column=>!parseColumnMaxWidth(column));let dynamicSize=dynamicList.length-1;if(dynamicSize>0){let i=bodyWidth-tWidth;if(i>0){while(i>0&&dynamicSize>=0){i--;dynamicList[dynamicSize--].renderWidth++;}tWidth=bodyWidth;}}}reactData.scrollXWidth=tWidth;reactData.resizeWidthFlag++;updateColumnOffsetLeft();updateHeight();};/**
|
|
63
64
|
* 计算自适应行高
|
|
64
65
|
*/const calcCellAutoHeight=(rowRest,wrapperEl)=>{const{scrollXLoad}=reactData;const wrapperElemList=wrapperEl.querySelectorAll(`.vxe-cell--wrapper[rowid="${rowRest.rowid}"]`);let colHeight=0;let firstCellStyle=null;let topBottomPadding=0;for(let i=0;i<wrapperElemList.length;i++){const wrapperElem=wrapperElemList[i];const cellElem=wrapperElem.parentElement;const cellStyle=cellElem.style;const orHeight=cellStyle.height;if(!scrollXLoad){cellStyle.height='';}if(!firstCellStyle){firstCellStyle=getComputedStyle(cellElem);topBottomPadding=firstCellStyle?Math.ceil(_xeUtils.default.toNumber(firstCellStyle.paddingTop)+_xeUtils.default.toNumber(firstCellStyle.paddingBottom)):0;}if(!scrollXLoad){cellStyle.height=orHeight;}const cellHeight=wrapperElem?wrapperElem.clientHeight:0;colHeight=Math.max(colHeight,Math.ceil(cellHeight+topBottomPadding));}if(scrollXLoad){colHeight=Math.max(colHeight,rowRest.height);}return colHeight;};/**
|
|
65
66
|
* 自适应行高
|
|
@@ -217,7 +218,7 @@ tableFullColumn.forEach(column=>{if(column.visible){if(column.fixed==='left'){le
|
|
|
217
218
|
// }
|
|
218
219
|
if(props.spanMethod){(0,_log.warnLog)('vxe.error.scrollErrProp',['span-method']);}if(props.footerSpanMethod){(0,_log.warnLog)('vxe.error.scrollErrProp',['footer-span-method']);}if(isReset){const{visibleSize}=handleVirtualXVisible();scrollXStore.startIndex=0;scrollXStore.endIndex=visibleSize;scrollXStore.visibleSize=visibleSize;scrollXStore.visibleStartIndex=0;scrollXStore.visibleEndIndex=visibleSize;}}// 如果列被显示/隐藏,则清除合并状态
|
|
219
220
|
// 如果列被设置为固定,则清除合并状态
|
|
220
|
-
if(visibleColumn.length!==internalData.visibleColumn.length||!internalData.visibleColumn.every((column,index)=>column===visibleColumn[index])){$xeTable.clearMergeCells();$xeTable.clearMergeFooterItems();}visibleColumn.forEach((column,index)=>{const colid=column.id;const colRest=fullColumnIdData[colid];if(colRest){colRest._index=index;}});handleTableColumn();handleUpdateAggValues();if(isReset){updateColumnOffsetLeft();return $xeTable.updateFooter().then(()=>{return $xeTable.recalculate();}).then(()=>{$xeTable.updateCellAreas();return $xeTable.recalculate();});}return $xeTable.updateFooter();};const initColumnHierarchy=()=>{const{collectColumn}=internalData;const fullColIdData={};const fullColFieldData={};let sortIndex=1;_xeUtils.default.eachTree(collectColumn,(column,index,items,path,parentColumn)=>{const{id:colid,field}=column;const parentId=parentColumn?parentColumn.id:null;const rest={$index:-1,_index:-1,column,colid,index,items,parent:parentColumn||null,width:0,oLeft:0};column.parentId=parentId;column.defaultParentId=parentId;column.sortNumber=sortIndex;column.renderSortNumber=sortIndex;sortIndex++;if(field){if(fullColFieldData[field]){(0,_log.errLog)('vxe.error.colRepet',['field',field]);}fullColFieldData[field]=rest;}fullColIdData[colid]=rest;});internalData.fullColumnIdData=fullColIdData;internalData.fullColumnFieldData=fullColFieldData;};const handleInitColumn=collectColumn=>{const expandOpts=computeExpandOpts.value;internalData.collectColumn=collectColumn;const tFullColumn=(0,_util.getColumnList)(collectColumn);internalData.tableFullColumn=tFullColumn;reactData.updateColFlag++;reactData.isColLoading=true;initColumnHierarchy();return Promise.resolve(restoreCustomStorage()).then(()=>{const{scrollXLoad,scrollYLoad,expandColumn}=reactData;cacheColumnMap();parseColumns(true).then(()=>{if(reactData.scrollXLoad){loadScrollXData();}});$xeTable.clearMergeCells();$xeTable.clearMergeFooterItems();$xeTable.handleTableData(true);$xeTable.handleAggregateSummaryData();if((scrollXLoad||scrollYLoad)&&expandColumn&&expandOpts.mode!=='fixed'){(0,_log.warnLog)('vxe.error.scrollErrProp',['column.type=expand']);}return(0,_vue.nextTick)().then(()=>{if($xeToolbar){$xeToolbar.syncUpdate({collectColumn:internalData.collectColumn,$table:$xeTable});}if($xeTable.handleUpdateCustomColumn){$xeTable.handleUpdateCustomColumn();}const columnOpts=computeColumnOpts.value;if(props.showCustomHeader&&reactData.isGroup&&(columnOpts.resizable||props.resizable)){(0,_log.warnLog)('vxe.error.notConflictProp',['show-custom-header & colgroup','column-config.resizable=false']);}reactData.isColLoading=false;return handleLazyRecalculate(false,true,true);});});};const updateScrollXStatus=fullColumn=>{const virtualXOpts=computeVirtualXOpts.value;const allCols=fullColumn||internalData.tableFullColumn;// 如果gt为0,则总是启用
|
|
221
|
+
if(visibleColumn.length!==internalData.visibleColumn.length||!internalData.visibleColumn.every((column,index)=>column===visibleColumn[index])){$xeTable.clearMergeCells();$xeTable.clearMergeFooterItems();}visibleColumn.forEach((column,index)=>{const colid=column.id;const colRest=fullColumnIdData[colid];if(colRest){colRest._index=index;}});handleTableColumn();handleUpdateAggValues();if(isReset){updateColumnOffsetLeft();return $xeTable.updateFooter().then(()=>{return $xeTable.recalculate();}).then(()=>{$xeTable.updateCellAreas();return $xeTable.recalculate();});}return $xeTable.updateFooter();};const initColumnHierarchy=()=>{const{collectColumn}=internalData;const fullColIdData={};const fullColFieldData={};let sortIndex=1;_xeUtils.default.eachTree(collectColumn,(column,index,items,path,parentColumn)=>{const{id:colid,field}=column;const parentId=parentColumn?parentColumn.id:null;const rest={$index:-1,_index:-1,column,colid,index,items,parent:parentColumn||null,width:0,oLeft:0};column.parentId=parentId;column.defaultParentId=parentId;column.sortNumber=sortIndex;column.renderSortNumber=sortIndex;sortIndex++;if(field){if(fullColFieldData[field]){(0,_log.errLog)('vxe.error.colRepet',['field',field]);}fullColFieldData[field]=rest;}fullColIdData[colid]=rest;});internalData.fullColumnIdData=fullColIdData;internalData.fullColumnFieldData=fullColFieldData;};const handleInitColumn=collectColumn=>{const expandOpts=computeExpandOpts.value;internalData.collectColumn=collectColumn;const tFullColumn=(0,_util.getColumnList)(collectColumn);internalData.tableFullColumn=tFullColumn;reactData.updateColFlag++;reactData.isColLoading=true;initColumnHierarchy();return Promise.resolve(restoreCustomStorage()).then(()=>{const{scrollXLoad,scrollYLoad,expandColumn}=reactData;cacheColumnMap();parseColumns(true).then(()=>{if(reactData.scrollXLoad){loadScrollXData();}});$xeTable.clearHeaderFormatterCache();$xeTable.clearMergeCells();$xeTable.clearMergeFooterItems();$xeTable.handleTableData(true);$xeTable.handleAggregateSummaryData();if((scrollXLoad||scrollYLoad)&&expandColumn&&expandOpts.mode!=='fixed'){(0,_log.warnLog)('vxe.error.scrollErrProp',['column.type=expand']);}return(0,_vue.nextTick)().then(()=>{if($xeToolbar){$xeToolbar.syncUpdate({collectColumn:internalData.collectColumn,$table:$xeTable});}if($xeTable.handleUpdateCustomColumn){$xeTable.handleUpdateCustomColumn();}const columnOpts=computeColumnOpts.value;if(props.showCustomHeader&&reactData.isGroup&&(columnOpts.resizable||props.resizable)){(0,_log.warnLog)('vxe.error.notConflictProp',['show-custom-header & colgroup','column-config.resizable=false']);}reactData.isColLoading=false;return handleLazyRecalculate(false,true,true);});});};const updateScrollXStatus=fullColumn=>{const virtualXOpts=computeVirtualXOpts.value;const allCols=fullColumn||internalData.tableFullColumn;// 如果gt为0,则总是启用
|
|
221
222
|
const scrollXLoad=!!virtualXOpts.enabled&&virtualXOpts.gt>-1&&(virtualXOpts.gt===0||virtualXOpts.gt<allCols.length);reactData.scrollXLoad=scrollXLoad;return scrollXLoad;};const updateScrollYStatus=fullData=>{const{treeConfig}=props;const $xeGanttView=internalData.xeGanttView;const virtualYOpts=computeVirtualYOpts.value;const treeOpts=computeTreeOpts.value;const{transform}=treeOpts;const allList=fullData||internalData.tableFullData;// 如果gt为0,则总是启用
|
|
222
223
|
const scrollYLoad=(transform||!treeConfig)&&!!virtualYOpts.enabled&&virtualYOpts.gt>-1&&(virtualYOpts.gt===0||virtualYOpts.gt<allList.length);reactData.scrollYLoad=scrollYLoad;if($xeGanttView&&$xeGanttView.handleUpdateSYStatus){$xeGanttView.handleUpdateSYStatus(scrollYLoad);}return scrollYLoad;};/**
|
|
223
224
|
* 展开与收起树节点
|
|
@@ -337,7 +338,7 @@ if(virtualXOpts.scrollToLeftOnChange){targetScrollLeft=0;}if(virtualYOpts.scroll
|
|
|
337
338
|
* @param {Array/Row} rows 行数据
|
|
338
339
|
* @param {String} field 字段名
|
|
339
340
|
*/clearData(rows,field){const{tableFullData,visibleColumn}=internalData;if(!arguments.length){rows=tableFullData;}else if(rows&&!_xeUtils.default.isArray(rows)){rows=[rows];}if(field){rows.forEach(row=>_xeUtils.default.set(row,field,null));}else{rows.forEach(row=>{visibleColumn.forEach(column=>{if(column.field){(0,_util.setCellValue)(row,column,null);}});});}return(0,_vue.nextTick)();},getCellElement(row,fieldOrColumn){const{elemStore}=internalData;const column=(0,_util.handleFieldOrColumn)($xeTable,fieldOrColumn);if(!column){return null;}const rowid=(0,_util.getRowid)($xeTable,row);const bodyScrollElem=(0,_util.getRefElem)(elemStore['main-body-scroll']);const leftScrollElem=(0,_util.getRefElem)(elemStore['left-body-scroll']);const rightScrollElem=(0,_util.getRefElem)(elemStore['right-body-scroll']);let bodyElem;if(column){if(column.fixed){if(column.fixed==='left'){if(leftScrollElem){bodyElem=leftScrollElem;}}else{if(rightScrollElem){bodyElem=rightScrollElem;}}}if(!bodyElem){bodyElem=bodyScrollElem;}if(bodyElem){return bodyElem.querySelector(`.vxe-body--row[rowid="${rowid}"] .${column.id}`);}}return null;},getCellLabel(row,fieldOrColumn){const column=(0,_util.handleFieldOrColumn)($xeTable,fieldOrColumn);if(!column){return null;}const{editConfig}=props;const{formatter,editRender,cellRender}=column;// formatter > tableCellFormatter
|
|
340
|
-
const renderOpts=formatter?null:editConfig&&(0,_utils.isEnableConf)(editRender)?editRender:(0,_utils.isEnableConf)(cellRender)?cellRender:null;const compConf=renderOpts?renderer.get(renderOpts.name):null;const tcFormatter=compConf?compConf.tableCellFormatter:null;const cellValue=(0,_util.getCellValue)(row,column);let cellLabel=cellValue;if(formatter||tcFormatter){let formatData;const{fullAllDataRowIdData}=internalData;const rowid=(0,_util.getRowid)($xeTable,row);const colid=column.id;const rowRest=fullAllDataRowIdData[rowid];if(rowRest){formatData=rowRest.formatData;if(!formatData){formatData=fullAllDataRowIdData[rowid].formatData={};}if(rowRest&&formatData[colid]){if(formatData[colid].value===cellValue){return formatData[colid].label;}}}const formatParams={$table:$xeTable,cellValue,row,rowIndex:$xeTable.getRowIndex(row),column,columnIndex:$xeTable.getColumnIndex(column)};if(formatter){if(_xeUtils.default.isString(formatter)){const gFormatOpts=formats.get(formatter);const tcFormatMethod=gFormatOpts?gFormatOpts.tableCellFormatMethod||gFormatOpts.cellFormatMethod:null;cellLabel=tcFormatMethod?tcFormatMethod(formatParams):'';}else if(_xeUtils.default.isArray(formatter)){const gFormatOpts=formats.get(formatter[0]);const tcFormatMethod=gFormatOpts?gFormatOpts.tableCellFormatMethod||gFormatOpts.cellFormatMethod:null;cellLabel=tcFormatMethod?tcFormatMethod(formatParams,...formatter.slice(1)):'';}else{cellLabel=formatter(formatParams);}}else if(renderOpts&&tcFormatter){cellLabel=tcFormatter(renderOpts,formatParams);}if(formatData){formatData[colid]={value:cellValue,label:cellLabel};}}return cellLabel;},updateCellLabel(row,fieldOrColumn){const column=(0,_util.handleFieldOrColumn)($xeTable,fieldOrColumn);if(!column){return null;}const{fullAllDataRowIdData}=internalData;const rowid=(0,_util.getRowid)($xeTable,row);if(rowid){const colid=column.id;const rowid=(0,_util.getRowid)($xeTable,row);const rowRest=fullAllDataRowIdData[rowid];if(rowRest){const formatData=rowRest.formatData;if(formatData){delete formatData[colid];}}}return $xeTable.getFooterCellLabel(row,column);},clearFormatterCache(isUpdate){const{tableData,tableColumn}=reactData;const{fullAllDataRowIdData}=internalData;_xeUtils.default.each(fullAllDataRowIdData,rowRest=>{if(rowRest.formatData){rowRest.formatData=undefined;}});if(isUpdate){tableData.forEach(row=>{tableColumn.forEach(column=>{$xeTable.getCellLabel(row,column);});});}return(0,_vue.nextTick)();},getFooterCellLabel(row,fieldOrColumn){const column=(0,_util.handleFieldOrColumn)($xeTable,fieldOrColumn);if(!column){return null;}const{footerFormatter}=column;const _columnIndex=$xeTable.getVTColumnIndex(column);let itemValue='';// 兼容老模式
|
|
341
|
+
const renderOpts=formatter?null:editConfig&&(0,_utils.isEnableConf)(editRender)?editRender:(0,_utils.isEnableConf)(cellRender)?cellRender:null;const compConf=renderOpts?renderer.get(renderOpts.name):null;const tcFormatter=compConf?compConf.tableCellFormatter:null;const cellValue=(0,_util.getCellValue)(row,column);let cellLabel=cellValue;if(formatter||tcFormatter){let formatData;const{fullAllDataRowIdData}=internalData;const rowid=(0,_util.getRowid)($xeTable,row);const colid=column.id;const rowRest=fullAllDataRowIdData[rowid];if(rowRest){formatData=rowRest.formatData;if(!formatData){formatData=fullAllDataRowIdData[rowid].formatData={};}if(rowRest&&formatData[colid]){if(formatData[colid].value===cellValue){return formatData[colid].label;}}}const formatParams={$table:$xeTable,cellValue,row,rowIndex:$xeTable.getRowIndex(row),column,columnIndex:$xeTable.getColumnIndex(column)};if(formatter){if(_xeUtils.default.isString(formatter)){const gFormatOpts=formats.get(formatter);const tcFormatMethod=gFormatOpts?gFormatOpts.tableCellFormatMethod||gFormatOpts.cellFormatMethod:null;cellLabel=tcFormatMethod?tcFormatMethod(formatParams):'';}else if(_xeUtils.default.isArray(formatter)){const gFormatOpts=formats.get(formatter[0]);const tcFormatMethod=gFormatOpts?gFormatOpts.tableCellFormatMethod||gFormatOpts.cellFormatMethod:null;cellLabel=tcFormatMethod?tcFormatMethod(formatParams,...formatter.slice(1)):'';}else{cellLabel=formatter(formatParams);}}else if(renderOpts&&tcFormatter){cellLabel=tcFormatter(renderOpts,formatParams);}if(formatData){formatData[colid]={value:cellValue,label:cellLabel};}}return cellLabel;},updateCellLabel(row,fieldOrColumn){const column=(0,_util.handleFieldOrColumn)($xeTable,fieldOrColumn);if(!column){return null;}const{fullAllDataRowIdData}=internalData;const rowid=(0,_util.getRowid)($xeTable,row);if(rowid){const colid=column.id;const rowid=(0,_util.getRowid)($xeTable,row);const rowRest=fullAllDataRowIdData[rowid];if(rowRest){const formatData=rowRest.formatData;if(formatData){delete formatData[colid];}}}return $xeTable.getFooterCellLabel(row,column);},clearFormatterCache(isUpdate){const{tableData,tableColumn}=reactData;const{fullAllDataRowIdData}=internalData;_xeUtils.default.each(fullAllDataRowIdData,rowRest=>{if(rowRest.formatData){rowRest.formatData=undefined;}});if(isUpdate){tableData.forEach(row=>{tableColumn.forEach(column=>{$xeTable.getCellLabel(row,column);});});}return(0,_vue.nextTick)();},getHeaderCellLabel(fieldOrColumn){const column=(0,_util.handleFieldOrColumn)($xeTable,fieldOrColumn);if(!column){return null;}const{headerFormatter}=column;const _columnIndex=$xeTable.getVTColumnIndex(column);let cellLabel=column.getTitle();if(headerFormatter){let formatData;const{headerFullDataColData}=internalData;const colid=column.id;let colRest=headerFullDataColData[colid];if(!colRest){colRest=headerFullDataColData[colid]={};}const formatObj=colRest.formatObj;if(formatObj&&formatObj.value===cellLabel){return formatObj.label;}const headFormatParams={$table:$xeTable,cellTitle:cellLabel,cellValue:cellLabel,column,_columnIndex,columnIndex:$xeTable.getColumnIndex(column)};if(_xeUtils.default.isString(headerFormatter)){const gFormatOpts=formats.get(headerFormatter);const fcFormatMethod=gFormatOpts?gFormatOpts.tableHeaderCellFormatMethod:null;cellLabel=_xeUtils.default.toValueString(fcFormatMethod?fcFormatMethod(headFormatParams):'');}else if(_xeUtils.default.isArray(headerFormatter)){const gFormatOpts=formats.get(headerFormatter[0]);const fcFormatMethod=gFormatOpts?gFormatOpts.tableHeaderCellFormatMethod:null;cellLabel=_xeUtils.default.toValueString(fcFormatMethod?fcFormatMethod(headFormatParams,...headerFormatter.slice(1)):'');}else{cellLabel=_xeUtils.default.toValueString(headerFormatter(headFormatParams));}if(formatData){colRest.formatObj={value:cellLabel,label:cellLabel};}}return cellLabel;},updateHeaderCellLabel(fieldOrColumn){const column=(0,_util.handleFieldOrColumn)($xeTable,fieldOrColumn);if(!column){return'';}const{headerFullDataColData}=internalData;const colid=column.id;const colRest=headerFullDataColData[colid];if(colRest){colRest.formatObj=undefined;}return $xeTable.getHeaderCellLabel(column);},clearHeaderFormatterCache(isUpdate){const{tableColumn}=reactData;const{headerFullDataColData}=internalData;_xeUtils.default.each(headerFullDataColData,colRest=>{if(colRest.formatObj){colRest.formatObj=undefined;}});if(isUpdate){tableColumn.forEach(column=>{$xeTable.getHeaderCellLabel(column);});}return(0,_vue.nextTick)();},getFooterCellLabel(row,fieldOrColumn){const column=(0,_util.handleFieldOrColumn)($xeTable,fieldOrColumn);if(!column){return null;}const{footerFormatter}=column;const _columnIndex=$xeTable.getVTColumnIndex(column);let itemValue='';// 兼容老模式
|
|
341
342
|
if(_xeUtils.default.isArray(row)){itemValue=row[_columnIndex];}else{itemValue=_xeUtils.default.get(row,column.field);}let cellLabel=itemValue;if(footerFormatter){let formatData;const{footerTableData}=reactData;const{footerFullDataRowData}=internalData;const colid=column.id;const $rowIndex=footerTableData.indexOf(row);let rowRest=null;if($rowIndex>-1){rowRest=footerFullDataRowData[$rowIndex];if(!rowRest){rowRest=footerFullDataRowData[$rowIndex]={};}formatData=rowRest.formatData;if(!formatData){formatData=footerFullDataRowData[$rowIndex].formatData={};}if(rowRest&&formatData[colid]){if(formatData[colid].value===itemValue){return formatData[colid].label;}}}const footerFormatParams={$table:$xeTable,cellValue:itemValue,itemValue,row,items:row,$rowIndex,column,_columnIndex,columnIndex:$xeTable.getColumnIndex(column)};if(_xeUtils.default.isString(footerFormatter)){const gFormatOpts=formats.get(footerFormatter);const fcFormatMethod=gFormatOpts?gFormatOpts.tableFooterCellFormatMethod:null;cellLabel=fcFormatMethod?fcFormatMethod(footerFormatParams):'';}else if(_xeUtils.default.isArray(footerFormatter)){const gFormatOpts=formats.get(footerFormatter[0]);const fcFormatMethod=gFormatOpts?gFormatOpts.tableFooterCellFormatMethod:null;cellLabel=fcFormatMethod?fcFormatMethod(footerFormatParams,...footerFormatter.slice(1)):'';}else{cellLabel=footerFormatter(footerFormatParams);}if(formatData){formatData[colid]={value:itemValue,label:cellLabel};}}return cellLabel;},updateFooterCellLabel(row,fieldOrColumn){const column=(0,_util.handleFieldOrColumn)($xeTable,fieldOrColumn);if(!column){return null;}const{footerTableData}=reactData;const{footerFullDataRowData}=internalData;const colid=column.id;const $rowIndex=footerTableData.indexOf(row);const rowRest=footerFullDataRowData[$rowIndex];if(rowRest){const formatData=rowRest.formatData;if(formatData){delete formatData[colid];}}return $xeTable.getFooterCellLabel(row,column);},clearFooterFormatterCache(isUpdate){const{tableData,tableColumn}=reactData;const{footerFullDataRowData}=internalData;_xeUtils.default.each(footerFullDataRowData,rowRest=>{if(rowRest.formatData){rowRest.formatData=undefined;}});if(isUpdate){tableData.forEach(row=>{tableColumn.forEach(column=>{$xeTable.getFooterCellLabel(row,column);});});}return(0,_vue.nextTick)();},/**
|
|
342
343
|
* 检查是否为临时行数据
|
|
343
344
|
*/isInsertByRow(row){const rowid=(0,_util.getRowid)($xeTable,row);return!!reactData.insertRowFlag&&!!internalData.insertRowMaps[rowid];},isRemoveByRow(row){const rowid=(0,_util.getRowid)($xeTable,row);return!!reactData.removeRowFlag&&!!internalData.removeRowMaps[rowid];},/**
|
|
@@ -553,7 +554,7 @@ internalData._sToTime=setTimeout(()=>{internalData._sToTime=undefined;if(scrollY
|
|
|
553
554
|
* 手动清除滚动相关信息,还原到初始状态
|
|
554
555
|
*/clearScroll(){const{elemStore,scrollXStore,scrollYStore}=internalData;const headerScrollElem=(0,_util.getRefElem)(elemStore['main-header-scroll']);const bodyScrollElem=(0,_util.getRefElem)(elemStore['main-body-scroll']);const footerScrollElem=(0,_util.getRefElem)(elemStore['main-footer-scroll']);const leftScrollElem=(0,_util.getRefElem)(elemStore['left-body-scroll']);const rightScrollElem=(0,_util.getRefElem)(elemStore['right-body-scroll']);const xHandleEl=refScrollXHandleElem.value;const yHandleEl=refScrollYHandleElem.value;internalData.intoRunScroll=true;(0,_dom.setScrollLeft)(xHandleEl,0);(0,_dom.setScrollLeft)(bodyScrollElem,0);(0,_dom.setScrollLeft)(headerScrollElem,0);(0,_dom.setScrollLeft)(footerScrollElem,0);(0,_dom.setScrollTop)(yHandleEl,0);(0,_dom.setScrollTop)(bodyScrollElem,0);(0,_dom.setScrollTop)(leftScrollElem,0);(0,_dom.setScrollTop)(rightScrollElem,0);scrollXStore.startIndex=0;scrollXStore.visibleStartIndex=0;scrollXStore.endIndex=scrollXStore.visibleSize;scrollXStore.visibleEndIndex=scrollXStore.visibleSize;scrollYStore.startIndex=0;scrollYStore.visibleStartIndex=0;scrollYStore.endIndex=scrollYStore.visibleSize;scrollYStore.visibleEndIndex=scrollYStore.visibleSize;return(0,_vue.nextTick)().then(()=>{internalData.lastScrollLeft=0;internalData.lastScrollTop=0;internalData.intoRunScroll=false;});},/**
|
|
555
556
|
* 更新表尾合计
|
|
556
|
-
*/updateFooter(){const{showFooter,footerData,footerMethod}=props;const{visibleColumn,afterFullData}=internalData;let footData=[];if(showFooter&&footerData&&footerData.length){footData=footerData.slice(0);}else if(showFooter&&footerMethod){footData=visibleColumn.length?footerMethod({columns:visibleColumn,data:afterFullData,$table:$xeTable,$grid:$xeGrid,$gantt:$xeGantt}):[];}reactData.footerTableData=footData;$xeTable.handleUpdateFooterMerge();$xeTable.dispatchEvent('footer-data-change',{visibleColumn:internalData.visibleColumn,footData},null);return(0,_vue.nextTick)();},/**
|
|
557
|
+
*/updateFooter(){const{showFooter,footerData,footerMethod}=props;const{visibleColumn,afterFullData}=internalData;let footData=[];if(showFooter&&footerData&&footerData.length){footData=footerData.slice(0);}else if(showFooter&&footerMethod){footData=visibleColumn.length?footerMethod({columns:visibleColumn,data:afterFullData,$table:$xeTable,$grid:$xeGrid,$gantt:$xeGantt}):[];}reactData.footerTableData=footData;$xeTable.clearFooterFormatterCache();$xeTable.handleUpdateFooterMerge();$xeTable.dispatchEvent('footer-data-change',{visibleColumn:internalData.visibleColumn,footData},null);return(0,_vue.nextTick)();},/**
|
|
557
558
|
* 更新列状态 updateStatus({ row, column }, cellValue)
|
|
558
559
|
* 如果组件值 v-model 发生 change 时,调用改函数用于更新某一列编辑状态
|
|
559
560
|
* 如果单元格配置了校验规则,则会进行校验
|
|
@@ -691,8 +692,10 @@ if(selectCheckboxMaps[rowid]){selectCheckboxMaps[rowid]=row;}if(rowExpandedMaps[
|
|
|
691
692
|
if(treeConfig){const childrenField=treeOpts.children||treeOpts.childrenField;_xeUtils.default.eachTree(sourceData,handleSourceRow,{children:treeOpts.transform?treeOpts.mapChildrenField:childrenField});}else{sourceData.forEach(handleSourceRow);}internalData.sourceDataRowIdData=sourceRowIdData;internalData.tableSourceData=sourceData;},/**
|
|
692
693
|
* 指定列宽的列进行拆分
|
|
693
694
|
*/analyColumnWidth(){const{tableFullColumn}=internalData;const columnOpts=computeColumnOpts.value;const{width:defaultWidth,minWidth:defaultMinWidth}=columnOpts;const resizeList=[];const pxList=[];const pxMinList=[];const autoMinList=[];const scaleList=[];const scaleMinList=[];const autoList=[];const remainList=[];tableFullColumn.forEach(column=>{if(defaultWidth&&!column.width){column.width=defaultWidth;}if(defaultMinWidth&&!column.minWidth){column.minWidth=defaultMinWidth;}if(column.visible){if(column.resizeWidth){resizeList.push(column);}else if(column.width==='auto'){autoList.push(column);}else if((0,_dom.isPx)(column.width)){pxList.push(column);}else if((0,_dom.isScale)(column.width)){scaleList.push(column);}else if((0,_dom.isPx)(column.minWidth)){pxMinList.push(column);}else if(column.minWidth==='auto'){autoMinList.push(column);}else if((0,_dom.isScale)(column.minWidth)){scaleMinList.push(column);}else{remainList.push(column);}}});Object.assign(reactData.columnStore,{resizeList,pxList,pxMinList,autoMinList,scaleList,scaleMinList,autoList,remainList});},handleColResizeMousedownEvent(evnt,fixedType,params){const isLeftBtn=evnt.button===0;if(!isLeftBtn){return;}evnt.stopPropagation();evnt.preventDefault();const{column}=params;const{columnStore,overflowX,scrollbarHeight}=reactData;const{visibleColumn}=internalData;const{leftList,rightList}=columnStore;const resizableOpts=computeResizableOpts.value;const osbHeight=overflowX?scrollbarHeight:0;const tableEl=refElem.value;const leftContainerElem=refLeftContainer.value;const rightContainerElem=refRightContainer.value;const resizeBarElem=refColResizeBar.value;if(!resizeBarElem){return;}const isLeftFixed=fixedType==='left';const isRightFixed=fixedType==='right';const resizeTipElem=resizeBarElem.firstElementChild;const scrollbarXToTop=computeScrollbarXToTop.value;const{clientX:dragClientX}=evnt;const dragBtnElem=evnt.target;let cell=dragBtnElem.parentElement;let resizeColumn=column;const isDragGroupCol=column.children&&column.children.length;if(isDragGroupCol){resizeColumn=(0,_util.getLastChildColumn)(column);if(isDragGroupCol){const trEl=cell?cell.parentElement:null;const theadEl=trEl?trEl.parentElement:null;cell=theadEl?theadEl.querySelector(`.vxe-header--column[colid="${resizeColumn.id}"]`):null;}}if(!cell){return;}const cellParams=_xeUtils.default.assign(params,{cell,$table:$xeTable});let dragLeft=0;const tableRect=tableEl.getBoundingClientRect();const rightContainerRect=rightContainerElem?rightContainerElem.getBoundingClientRect():null;const cellRect=cell.getBoundingClientRect();const dragBtnRect=dragBtnElem.getBoundingClientRect();const dragBtnWidth=dragBtnElem.clientWidth;const dragBtnOffsetWidth=_xeUtils.default.floor(dragBtnWidth/2);const dragPosLeft=dragBtnRect.x-tableRect.x+dragBtnOffsetWidth;const minInterval=(0,_util.getColReMinWidth)(cellParams)-dragBtnOffsetWidth;// 列之间的最小间距
|
|
695
|
+
const maxInterval=(0,_util.getColReMaxWidth)(cellParams);// 列之间的最大间距
|
|
694
696
|
const dragMinLeft=isRightFixed?0:cellRect.x-tableRect.x+dragBtnWidth+minInterval;const dragMaxLeft=cellRect.x-tableRect.x+cell.clientWidth-minInterval;let fixedLeftRemainWidth=0;let fixedRightRemainWidth=0;if(isLeftFixed||isRightFixed){let isMach=false;const fixedColumn=isLeftFixed?leftList:rightList;for(let i=0;i<fixedColumn.length;i++){const item=fixedColumn[i];if(isMach){fixedLeftRemainWidth+=item.renderWidth;}else{isMach=item.id===resizeColumn.id;if(!isMach){fixedRightRemainWidth+=item.renderWidth;}}}}// 处理拖动事件
|
|
695
|
-
const updateEvent=evnt=>{evnt.stopPropagation();evnt.preventDefault();const tableHeight=tableEl.clientHeight;const offsetX=evnt.clientX-dragClientX;let left=dragPosLeft+offsetX;if(isLeftFixed){if(rightContainerRect){left=Math.min(left,rightContainerRect.x-tableRect.x-fixedLeftRemainWidth-minInterval);}}else if(isRightFixed){if(leftContainerElem){left=Math.max(left,leftContainerElem.clientWidth+fixedRightRemainWidth+minInterval);}left=Math.min(left,dragMaxLeft);}dragLeft=Math.max(left,dragMinLeft)
|
|
697
|
+
const updateEvent=evnt=>{evnt.stopPropagation();evnt.preventDefault();const tableHeight=tableEl.clientHeight;const offsetX=evnt.clientX-dragClientX;let left=dragPosLeft+offsetX;if(isLeftFixed){if(rightContainerRect){left=Math.min(left,rightContainerRect.x-tableRect.x-fixedLeftRemainWidth-minInterval);}}else if(isRightFixed){if(leftContainerElem){left=Math.max(left,leftContainerElem.clientWidth+fixedRightRemainWidth+minInterval);}left=Math.min(left,dragMaxLeft);}dragLeft=Math.max(left,dragMinLeft);// 最大宽
|
|
698
|
+
if(maxInterval>1){dragLeft=Math.min(dragLeft,maxInterval+dragMinLeft-minInterval);}const resizeBarLeft=Math.max(1,dragLeft);resizeBarElem.style.left=`${resizeBarLeft}px`;resizeBarElem.style.top=`${scrollbarXToTop?osbHeight:0}px`;resizeBarElem.style.height=`${scrollbarXToTop?tableHeight-osbHeight:tableHeight}px`;if(resizableOpts.showDragTip&&resizeTipElem){resizeTipElem.textContent=getI18n('vxe.table.resizeColTip',[Math.floor(resizeColumn.renderWidth+(isRightFixed?dragPosLeft-dragLeft:dragLeft-dragPosLeft))]);const tableWrapperWidth=tableEl.clientWidth;const resizeBarWidth=resizeBarElem.clientWidth;const resizeTipWidth=resizeTipElem.clientWidth;const resizeTipHeight=resizeTipElem.clientHeight;let resizeTipLeft=-resizeTipWidth;if(resizeBarLeft<resizeTipWidth+resizeBarWidth){resizeTipLeft=0;}else if(resizeBarLeft>tableWrapperWidth){resizeTipLeft+=tableWrapperWidth-resizeBarLeft;}resizeTipElem.style.left=`${resizeTipLeft}px`;resizeTipElem.style.top=`${Math.min(tableHeight-resizeTipHeight,Math.max(0,evnt.clientY-tableRect.y-resizeTipHeight/2))}px`;}reactData.isDragResize=true;};reactData.isDragResize=true;(0,_dom.addClass)(tableEl,'col-drag--resize');resizeBarElem.style.display='block';document.onmousemove=updateEvent;document.onmouseup=function(evnt){document.onmousemove=null;document.onmouseup=null;resizeBarElem.style.display='none';internalData._lastResizeTime=Date.now();setTimeout(()=>{reactData.isDragResize=false;},50);const resizeWidth=resizeColumn.renderWidth+(isRightFixed?dragPosLeft-dragLeft:dragLeft-dragPosLeft);const resizeParams=Object.assign(Object.assign({},params),{resizeWidth,resizeColumn});if(resizableOpts.dragMode==='fixed'){visibleColumn.forEach(item=>{if(item.id!==resizeColumn.id){if(!item.resizeWidth){item.resizeWidth=item.renderWidth;}}});}if($xeTable.handleColResizeCellAreaEvent){$xeTable.handleColResizeCellAreaEvent(evnt,resizeParams);}else{resizeColumn.resizeWidth=resizeWidth;handleUpdateColResize(evnt,resizeParams);}(0,_dom.removeClass)(tableEl,'col-drag--resize');};updateEvent(evnt);if($xeTable.closeMenu){$xeTable.closeMenu();}},handleColResizeDblclickEvent(evnt,params){const resizableOpts=computeResizableOpts.value;const{isDblclickAutoWidth}=resizableOpts;const el=refElem.value;if(isDblclickAutoWidth&&el){evnt.stopPropagation();evnt.preventDefault();const{fullColumnIdData}=internalData;const{column}=params;let resizeColumn=column;if(column.children&&column.children.length){_xeUtils.default.eachTree(column.children,childColumn=>{resizeColumn=childColumn;});}const colid=resizeColumn.id;const colRest=fullColumnIdData[colid];const dragBtnElem=evnt.target;const cell=dragBtnElem.parentNode;const cellParams=Object.assign(params,{cell,$table:$xeTable});const colMinWidth=(0,_util.getColReMinWidth)(cellParams);const colMaxWidth=(0,_util.getColReMaxWidth)(cellParams);el.setAttribute('data-calc-col','Y');let resizeWidth=calcColumnAutoWidth(resizeColumn,el);el.removeAttribute('data-calc-col');if(colRest){resizeWidth=Math.max(resizeWidth,colRest.width);}resizeWidth=Math.max(colMinWidth,resizeWidth);if(colMaxWidth>1){resizeWidth=Math.min(colMaxWidth,resizeWidth);}const resizeParams=Object.assign(Object.assign({},params),{resizeWidth,resizeColumn});reactData.isDragResize=false;internalData._lastResizeTime=Date.now();if($xeTable.handleColResizeDblclickCellAreaEvent){$xeTable.handleColResizeDblclickCellAreaEvent(evnt,resizeParams);}else{resizeColumn.resizeWidth=resizeWidth;handleUpdateColResize(evnt,resizeParams);}}},handleRowResizeMousedownEvent(evnt,params){evnt.stopPropagation();evnt.preventDefault();const{row}=params;const{showOverflow}=props;const{overflowX,scrollbarWidth,overflowY,scrollbarHeight}=reactData;const{elemStore,fullAllDataRowIdData}=internalData;const osbWidth=overflowY?scrollbarWidth:0;const osbHeight=overflowX?scrollbarHeight:0;const scrollbarYToLeft=computeScrollbarYToLeft.value;const resizableOpts=computeResizableOpts.value;const rowOpts=computeRowOpts.value;const cellOpts=computeCellOpts.value;let tableEl=refElem.value;if($xeGantt){const{refGanttContainerElem}=$xeGantt.getRefMaps();const ganttContainerElem=refGanttContainerElem.value;if(ganttContainerElem){tableEl=ganttContainerElem;}}const resizeBarElem=refRowResizeBar.value;if(!resizeBarElem){return;}const{clientY:dragClientY}=evnt;const resizeTipElem=resizeBarElem.firstElementChild;const dragBtnElem=evnt.currentTarget;const tdEl=dragBtnElem.parentNode;const trEl=tdEl.parentNode;const bodyScrollElem=(0,_util.getRefElem)(elemStore['main-body-scroll']);if(!bodyScrollElem){return;}const rowid=(0,_util.getRowid)($xeTable,row);const rowRest=fullAllDataRowIdData[rowid];if(!rowRest){return;}const defaultRowHeight=computeDefaultRowHeight.value;let currCellHeight=rowRest.resizeHeight||cellOpts.height||rowOpts.height||rowRest.height||defaultRowHeight;if(!showOverflow){currCellHeight=tdEl.clientHeight;}const tableRect=tableEl.getBoundingClientRect();const trRect=trEl.getBoundingClientRect();const targetOffsetY=dragClientY-trRect.y-trEl.clientHeight;let resizeHeight=currCellHeight;const cellEl=tdEl.querySelector('.vxe-cell');let cellMinHeight=0;if(cellEl){const cellStyle=getComputedStyle(cellEl);cellMinHeight=Math.max(1,Math.ceil(_xeUtils.default.toNumber(cellStyle.paddingTop)+_xeUtils.default.toNumber(cellStyle.paddingBottom)));}const minTop=trRect.y-tableRect.y+cellMinHeight;// 处理拖动事件
|
|
696
699
|
const updateEvent=evnt=>{evnt.stopPropagation();evnt.preventDefault();const rtWidth=tableEl.clientWidth-osbWidth;const tableHeight=tableEl.clientHeight-osbHeight;let dragTop=evnt.clientY-tableRect.y-targetOffsetY;if(dragTop<minTop){dragTop=minTop;}else{resizeHeight=Math.max(cellMinHeight,currCellHeight+evnt.clientY-dragClientY);}resizeBarElem.style.left=`${scrollbarYToLeft?osbWidth:0}px`;resizeBarElem.style.top=`${dragTop}px`;resizeBarElem.style.width=`${rtWidth}px`;if(resizableOpts.showDragTip&&resizeTipElem){resizeTipElem.textContent=getI18n('vxe.table.resizeRowTip',[resizeHeight]);const resizeTipWidth=resizeTipElem.clientWidth;const resizeTipHeight=resizeTipElem.clientHeight;let resizeBarLeft=Math.max(2,evnt.clientX-tableRect.x);let resizeBarTop=0;if(resizeBarLeft+resizeTipWidth>=rtWidth-2){resizeBarLeft=rtWidth-resizeTipWidth-2;}if(dragTop+resizeTipHeight>=tableHeight){resizeBarTop=tableHeight-(dragTop+resizeTipHeight);}resizeTipElem.style.left=`${resizeBarLeft}px`;resizeTipElem.style.top=`${resizeBarTop}px`;}reactData.isDragResize=true;};reactData.isDragResize=true;(0,_dom.addClass)(tableEl,'row-drag--resize');resizeBarElem.style.display='block';document.onmousemove=updateEvent;document.onmouseup=function(evnt){document.onmousemove=null;document.onmouseup=null;resizeBarElem.style.display='none';internalData._lastResizeTime=Date.now();setTimeout(()=>{reactData.isDragResize=false;},50);if(resizeHeight!==currCellHeight){const resizeParams=Object.assign(Object.assign({},params),{resizeHeight,resizeRow:row});internalData.isResizeCellHeight=true;if($xeTable.handleRowResizeCellAreaEvent){$xeTable.handleRowResizeCellAreaEvent(evnt,resizeParams);}else{rowRest.resizeHeight=resizeHeight;handleUpdateRowResize(evnt,resizeParams);updateRowOffsetTop();}}(0,_dom.removeClass)(tableEl,'row-drag--resize');};updateEvent(evnt);},handleRowResizeDblclickEvent(evnt,params){const resizableOpts=computeResizableOpts.value;const{isDblclickAutoHeight}=resizableOpts;const el=refElem.value;if(isDblclickAutoHeight&&el){evnt.stopPropagation();evnt.preventDefault();const{editStore}=reactData;const{fullAllDataRowIdData}=internalData;const{actived}=editStore;const{row}=params;const rowid=(0,_util.getRowid)($xeTable,row);const rowRest=fullAllDataRowIdData[rowid];if(!rowRest){return;}const handleRsHeight=()=>{el.setAttribute('data-calc-row','Y');const resizeHeight=calcCellAutoHeight(rowRest,el);el.removeAttribute('data-calc-row');const resizeParams=Object.assign(Object.assign({},params),{resizeHeight,resizeRow:row});reactData.isDragResize=false;internalData._lastResizeTime=Date.now();if($xeTable.handleRowResizeDblclickCellAreaEvent){$xeTable.handleRowResizeDblclickCellAreaEvent(evnt,resizeParams);}else{rowRest.resizeHeight=resizeHeight;handleUpdateRowResize(evnt,resizeParams);}};if(actived.row||actived.column){$xeTable.clearEdit().then(handleRsHeight);}else{handleRsHeight();}}},saveCustomStore(type){const{customConfig}=props;const tableId=computeTableId.value;const customOpts=computeCustomOpts.value;const{updateStore,storage,storeOptions}=customOpts;const isAllCustom=storage===true;const storageOpts=Object.assign({},isAllCustom?{}:storage||{},storeOptions);const isCustomResizable=hangleStorageDefaultValue(storageOpts.resizable,isAllCustom);const isCustomVisible=hangleStorageDefaultValue(storageOpts.visible,isAllCustom);const isCustomFixed=hangleStorageDefaultValue(storageOpts.fixed,isAllCustom);const isCustomSort=hangleStorageDefaultValue(storageOpts.sort,isAllCustom);const isCustomAggGroup=hangleStorageDefaultValue(storageOpts.aggGroup,isAllCustom);const isCustomAggFunc=hangleStorageDefaultValue(storageOpts.aggFunc,isAllCustom);if(type!=='reset'){// fix:修复拖动列宽,重置按钮无法点击的问题
|
|
697
700
|
reactData.isCustomStatus=true;}if(storage&&(customConfig?(0,_utils.isEnableConf)(customOpts):customOpts.enabled)&&(isCustomResizable||isCustomVisible||isCustomFixed||isCustomSort||isCustomAggGroup||isCustomAggFunc)){if(!tableId){(0,_log.errLog)('vxe.error.reqProp',['id']);return(0,_vue.nextTick)();}const storeData=type==='reset'?{resizableData:{},sortData:[],visibleData:{},fixedData:{},aggGroupData:{},aggFuncData:{}}:$xeTable.getCustomStoreData();if(updateStore){return updateStore({$table:$xeTable,id:tableId,type,storeData});}else{setCustomStorageMap(tableId,type==='reset'?null:storeData);}}return(0,_vue.nextTick)();},handleCustom(){const{mouseConfig}=props;if(mouseConfig){if($xeTable.clearSelected){$xeTable.clearSelected();}if($xeTable.clearCellAreas){$xeTable.clearCellAreas();$xeTable.clearCopyCellArea();}}$xeTable.analyColumnWidth();return $xeTable.refreshColumn(true);},handleUpdateDataQueue(){reactData.upDataFlag++;},handleRefreshColumnQueue(){reactData.reColumnFlag++;},handleFilterOptions(column){if(column){const{filterStore}=reactData;const{filterRender,filters}=column;const filterOptions=filters||[];const compConf=(0,_utils.isEnableConf)(filterRender)?renderer.get(filterRender.name):null;const frMethod=column.filterRecoverMethod||(compConf?compConf.tableFilterRecoverMethod||compConf.filterRecoverMethod:null);filterStore.column=column;// 复原状态
|
|
698
701
|
filterOptions.forEach(option=>{const{_checked,checked}=option;option._checked=checked;if(!checked&&_checked!==checked){if(frMethod){frMethod({option,column,$table:$xeTable});}}});$xeTable.checkFilterOptions();}},preventEvent(evnt,type,args,next,end){let evntList=interceptor.get(type);// 兼容老版本
|