| | |
| | | //cellarea.value = newElement |
| | | //添加多选列 |
| | | nextTick(() => { |
| | | window.addEventListener("keypress", (event)=>{ |
| | | window.addEventListener("keypress", ()=>{ |
| | | destroyAreaBox() |
| | | }) |
| | | window.addEventListener("mousedown", tableOutDestroyAreaBox)//给window添加鼠标按下事件,判断是否在表格外,是销毁 |
| | |
| | | |
| | | |
| | | } |
| | | const exportData = () => { |
| | | // //这里需要是visibleData |
| | | let tableData = getTablexGrid().getTableData().visibleData//获取处理条件之后的全量表体数据 |
| | | let rowStart = selectionStart.rowIndex//获取选中起始行索引 |
| | | let rowEnd = selectionEnd.rowIndex//获取选中结束行索引 |
| | | let selectRows = tableData.filter((col, index: number) => {//col参数不能改否则会获取不到数据 |
| | | //这里修改从右下往左上拖动的数据显示 |
| | | if (rowStart <= rowEnd) { |
| | | return rowStart <= index && rowEnd >= index |
| | | } else { |
| | | return rowStart >= index && rowEnd <= index |
| | | } |
| | | }) |
| | | |
| | | //这里需要是visibleColumn |
| | | let colStart = selectionStart.cellIndex//获取选中起始列索引 |
| | | let colEnd = selectionEnd.cellIndex//获取选中结束列索引 |
| | | let tableColumn = getTablexGrid().getTableColumn().visibleColumn//获取处理条件之后的全量表头列 |
| | | let selectCols = tableColumn.filter((col, index: number) => {//col参数不能改否则会获取不到数据 |
| | | //这里修改从右下往左上拖动的数据显示 |
| | | if (colStart <= colEnd) { |
| | | return colStart <= index && colEnd >= index |
| | | } else { |
| | | return colStart >= index && colEnd <= index |
| | | } |
| | | }) |
| | | let data = [] |
| | | let title = [] |
| | | selectCols.forEach((col, index) => { |
| | | title.push(col['title']) |
| | | }) |
| | | data.push(title) |
| | | |
| | | selectRows.forEach((row, index) => { |
| | | let rowData = [] |
| | | selectCols.forEach((col, index) => { |
| | | const parts = col['property'].split('.') |
| | | let result = row |
| | | for (const part of parts) { |
| | | if (result && result[part] !== undefined) { |
| | | result = result[part]; |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | rowData.push(result) |
| | | }) |
| | | data.push(rowData) |
| | | }) |
| | | return data |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | export { |
| | | addListener, |
| | | toolbarButtonClickEvent |
| | | toolbarButtonClickEvent, |
| | | exportData |
| | | } |