Skip to content

Commit

Permalink
releases 3.11.36
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 20, 2024
1 parent a20742a commit 6225334
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 78 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table",
"version": "3.11.35",
"version": "3.11.36",
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟树、拖拽排序,懒加载、快捷菜单、数据校验、树形结构、打印、导入导出、自定义模板、渲染器、JSON 配置式...",
"scripts": {
"update": "npm install --legacy-peer-deps",
Expand Down Expand Up @@ -28,7 +28,7 @@
"style": "lib/style.css",
"typings": "types/index.d.ts",
"dependencies": {
"vxe-pc-ui": "^3.3.40"
"vxe-pc-ui": "^3.3.41"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.25.7",
Expand Down
91 changes: 58 additions & 33 deletions packages/table/module/edit/mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ function insertTreeRow (_vm: any, newRecords: any[], isAppend: any) {
})
}

function handleInsertRowAt (_vm: any, records: any[], row: any, isInsertNextRow?: any) {
const $xeTable = _vm
function handleInsertRowAt ($xeTable: any, records: any[], targetRow: any, isInsertNextRow?: any) {
const props = $xeTable
const reactData = $xeTable
const internalData = $xeTable
Expand All @@ -63,11 +62,11 @@ function handleInsertRowAt (_vm: any, records: any[], row: any, isInsertNextRow?
if (!XEUtils.isArray(records)) {
records = [records]
}
const newRecords: any[] = _vm.defineField(records.map(record => Object.assign(treeConfig && transform ? { [mapChildrenField]: [], [childrenField]: [] } : {}, record)))
if (XEUtils.eqNull(row)) {
const newRecords: any[] = $xeTable.defineField(records.map(record => Object.assign(treeConfig && transform ? { [mapChildrenField]: [], [childrenField]: [] } : {}, record)))
if (XEUtils.eqNull(targetRow)) {
// 如果为虚拟树
if (treeConfig && transform) {
insertTreeRow(_vm, newRecords, false)
insertTreeRow($xeTable, newRecords, false)
} else {
newRecords.forEach(item => {
const rowid = getRowid($xeTable, item)
Expand All @@ -86,10 +85,10 @@ function handleInsertRowAt (_vm: any, records: any[], row: any, isInsertNextRow?
})
}
} else {
if (row === -1) {
if (targetRow === -1) {
// 如果为虚拟树
if (treeConfig && transform) {
insertTreeRow(_vm, newRecords, true)
insertTreeRow($xeTable, newRecords, true)
} else {
newRecords.forEach(item => {
const rowid = getRowid($xeTable, item)
Expand All @@ -110,14 +109,14 @@ function handleInsertRowAt (_vm: any, records: any[], row: any, isInsertNextRow?
} else {
// 如果为虚拟树
if (treeConfig && transform) {
const matchMapObj = XEUtils.findTree(tableFullTreeData, (item: any) => row[rowField] === item[rowField], { children: mapChildrenField })
const matchMapObj = XEUtils.findTree(tableFullTreeData, (item: any) => targetRow[rowField] === item[rowField], { children: mapChildrenField })
if (matchMapObj) {
const { parent: parentRow } = matchMapObj as any
const parentMapChilds = parentRow ? parentRow[mapChildrenField] : tableFullTreeData
const parentRest = fullAllDataRowIdData[getRowid(_vm, parentRow)]
const parentRest = fullAllDataRowIdData[getRowid($xeTable, parentRow)]
const parentLevel = parentRest ? parentRest.level : 0
newRecords.forEach((item: any, i: any) => {
const rowid = getRowid(_vm, item)
const rowid = getRowid($xeTable, item)
if (process.env.VUE_APP_VXE_ENV === 'development') {
if (item[treeOpts.parentField]) {
if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
Expand All @@ -140,7 +139,7 @@ function handleInsertRowAt (_vm: any, records: any[], row: any, isInsertNextRow?

// 源
if (parentRow) {
const matchObj = XEUtils.findTree(tableFullTreeData, (item: any) => row[rowField] === item[rowField], { children: childrenField })
const matchObj = XEUtils.findTree(tableFullTreeData, (item: any) => targetRow[rowField] === item[rowField], { children: childrenField })
if (matchObj) {
const parentChilds = matchObj.items
let targetIndex = matchObj.index
Expand All @@ -154,20 +153,20 @@ function handleInsertRowAt (_vm: any, records: any[], row: any, isInsertNextRow?
if (process.env.VUE_APP_VXE_ENV === 'development') {
warnLog('vxe.error.unableInsert')
}
insertTreeRow(_vm, newRecords, true)
insertTreeRow($xeTable, newRecords, true)
}
} else {
if (treeConfig) {
throw new Error(getI18n('vxe.error.noTree', ['insert']))
}
let afIndex = -1
// 如果是可视索引
if (XEUtils.isNumber(row)) {
if (row < afterFullData.length) {
afIndex = row
if (XEUtils.isNumber(targetRow)) {
if (targetRow < afterFullData.length) {
afIndex = targetRow
}
} else {
afIndex = _vm.findRowIndexOf(afterFullData, row)
afIndex = $xeTable.findRowIndexOf(afterFullData, targetRow)
}
// 如果是插入指定行的下一行
if (isInsertNextRow) {
Expand All @@ -177,7 +176,7 @@ function handleInsertRowAt (_vm: any, records: any[], row: any, isInsertNextRow?
throw new Error(errLog('vxe.error.unableInsert'))
}
afterFullData.splice(afIndex, 0, ...newRecords)
tableFullData.splice(_vm.findRowIndexOf(tableFullData, row), 0, ...newRecords)
tableFullData.splice($xeTable.findRowIndexOf(tableFullData, targetRow), 0, ...newRecords)
// 刷新单元格合并
mergeList.forEach((mergeItem: any) => {
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
Expand All @@ -195,20 +194,20 @@ function handleInsertRowAt (_vm: any, records: any[], row: any, isInsertNextRow?
const rowid = getRowid($xeTable, newRow)
insertMaps[rowid] = newRow
})
_vm.cacheRowMap()
_vm.updateScrollYStatus()
_vm.handleTableData(treeConfig && transform)
$xeTable.cacheRowMap()
$xeTable.updateScrollYStatus()
$xeTable.handleTableData(treeConfig && transform)
if (!(treeConfig && transform)) {
_vm.updateAfterDataIndex()
$xeTable.updateAfterDataIndex()
}
_vm.updateFooter()
_vm.checkSelectionStatus()
if (_vm.scrollYLoad) {
_vm.updateScrollYSpace()
$xeTable.updateFooter()
$xeTable.checkSelectionStatus()
if ($xeTable.scrollYLoad) {
$xeTable.updateScrollYSpace()
}
return _vm.$nextTick().then(() => {
_vm.updateCellAreas()
return _vm.recalculate()
return $xeTable.$nextTick().then(() => {
$xeTable.updateCellAreas()
return $xeTable.recalculate()
}).then(() => {
return {
row: newRecords.length ? newRecords[newRecords.length - 1] : null,
Expand All @@ -217,6 +216,23 @@ function handleInsertRowAt (_vm: any, records: any[], row: any, isInsertNextRow?
})
}

function handleInsertChildRowAt ($xeTable: any, records: any, parentRow: any, targetRow: any, isInsertNextRow?: boolean) {
const props = $xeTable

const { treeConfig } = props
const treeOpts = $xeTable.computeTreeOpts
const { transform, rowField, parentField } = treeOpts
if (treeConfig && transform) {
if (!XEUtils.isArray(records)) {
records = [records]
}
return handleInsertRowAt($xeTable, records.map((item: any) => Object.assign({}, item, { [parentField]: parentRow[rowField] })), targetRow, isInsertNextRow)
} else {
errLog('vxe.error.errProp', ['tree-config.treeConfig=false', 'tree-config.treeConfig=true'])
}
return Promise.resolve({ row: null, rows: [] })
}

export default {
methods: {
/**
Expand All @@ -233,14 +249,23 @@ export default {
* 如果 row 为 -1 则从插入到底部
* 如果 row 为有效行则插入到该行的位置
* @param {Object/Array} records 新的数据
* @param {Row} row 指定行
* @param {Row} targetRow 指定行
* @returns
*/
_insertAt (records: any, row: any) {
return handleInsertRowAt(this, records, row)
_insertAt (records: any, targetRow: any) {
return handleInsertRowAt(this, records, targetRow)
},
_insertNextAt (records: any, targetRow: any) {
return handleInsertRowAt(this, records, targetRow, true)
},
_insertChild (records: any, parentRow: any) {
return handleInsertChildRowAt(this, records, parentRow, null)
},
_insertChildAt (records: any, parentRow: any, targetRow: any) {
return handleInsertChildRowAt(this, records, parentRow, targetRow)
},
_insertNextAt (records: any, row: any) {
return handleInsertRowAt(this, records, row, true)
_insertChildNextAt (records: any, parentRow: any, targetRow: any) {
return handleInsertChildRowAt(this, records, parentRow, targetRow, true)
},
/**
* 删除指定行数据
Expand Down
44 changes: 24 additions & 20 deletions packages/table/module/export/mixin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import XEUtils from 'xe-utils'
import { VxeUI } from '../../../ui'
import { isColumnInfo, mergeBodyMethod, getCellValue } from '../../src/util'
import { parseFile, formatText } from '../../../ui/src/utils'
import { parseFile, formatText, eqEmptyValue } from '../../../ui/src/utils'
import { browse } from '../../../ui/src/dom'
import { createHtmlPage, getExportBlobByContent } from './util'
import { warnLog, errLog } from '../../../ui/src/log'
Expand Down Expand Up @@ -66,9 +66,13 @@ function toBooleanValue (cellValue: any) {
return XEUtils.isBoolean(cellValue) ? (cellValue ? 'TRUE' : 'FALSE') : cellValue
}

function getBodyLabelData ($xetable: any, opts: any, columns: any[], datas: any[]) {
const toStringValue = (cellValue: any) => {
return eqEmptyValue(cellValue) ? '' : `${cellValue}`
}

function getBodyLabelData ($xeTable: any, opts: any, columns: any[], datas: any[]) {
const { isAllExpand, mode } = opts
const { treeConfig, treeOpts, radioOpts, checkboxOpts, columnOpts } = $xetable
const { treeConfig, treeOpts, radioOpts, checkboxOpts, columnOpts } = $xeTable
const childrenField = treeOpts.children || treeOpts.childrenField
if (!htmlCellElem) {
htmlCellElem = document.createElement('div')
Expand All @@ -80,13 +84,13 @@ function getBodyLabelData ($xetable: any, opts: any, columns: any[], datas: any[
XEUtils.eachTree(datas, (item, $rowIndex, items, path, parent, nodes) => {
const row = item._row || item
const parentRow = parent && parent._row ? parent._row : parent
if ((isAllExpand || !parentRow || (expandMaps.has(parentRow) && $xetable.isTreeExpandByRow(parentRow)))) {
const hasRowChild = hasTreeChildren($xetable, row)
if ((isAllExpand || !parentRow || (expandMaps.has(parentRow) && $xeTable.isTreeExpandByRow(parentRow)))) {
const hasRowChild = hasTreeChildren($xeTable, row)
const item: any = {
_row: row,
_level: nodes.length - 1,
_hasChild: hasRowChild,
_expand: hasRowChild && $xetable.isTreeExpandByRow(row)
_expand: hasRowChild && $xeTable.isTreeExpandByRow(row)
}
columns.forEach((column, $columnIndex) => {
let cellValue = ''
Expand All @@ -102,42 +106,42 @@ function getBodyLabelData ($xetable: any, opts: any, columns: any[], datas: any[
bodyExportMethod = columnOpts.exportMethod
}
if (bodyExportMethod) {
cellValue = bodyExportMethod({ $table: $xetable, row, column, options: opts })
cellValue = bodyExportMethod({ $table: $xeTable, row, column, options: opts })
} else {
switch (column.type) {
case 'seq': {
const seqValue = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
cellValue = mode === 'all' ? seqValue : getSeq($xetable, seqValue, row, $rowIndex, column, $columnIndex)
cellValue = mode === 'all' ? seqValue : getSeq($xeTable, seqValue, row, $rowIndex, column, $columnIndex)
break
}
case 'checkbox':
cellValue = toBooleanValue($xetable.isCheckedByCheckboxRow(row))
cellValue = toBooleanValue($xeTable.isCheckedByCheckboxRow(row))
item._checkboxLabel = checkboxOpts.labelField ? XEUtils.get(row, checkboxOpts.labelField) : ''
item._checkboxDisabled = checkboxOpts.checkMethod && !checkboxOpts.checkMethod({ row })
break
case 'radio':
cellValue = toBooleanValue($xetable.isCheckedByRadioRow(row))
cellValue = toBooleanValue($xeTable.isCheckedByRadioRow(row))
item._radioLabel = radioOpts.labelField ? XEUtils.get(row, radioOpts.labelField) : ''
item._radioDisabled = radioOpts.checkMethod && !radioOpts.checkMethod({ row })
break
default:
if (opts.original) {
cellValue = getCellValue(row, column)
} else {
cellValue = $xetable.getCellLabel(row, column)
cellValue = $xeTable.getCellLabel(row, column)
if (column.type === 'html') {
htmlCellElem.innerHTML = cellValue
cellValue = htmlCellElem.innerText.trim()
} else {
const cell = $xetable.getCellElement(row, column)
const cell = $xeTable.getCellElement(row, column)
if (cell) {
cellValue = cell.innerText.trim()
}
}
}
}
}
item[column.id] = XEUtils.toValueString(cellValue)
item[column.id] = toStringValue(cellValue)
})
expandMaps.set(row, 1)
rest.push(Object.assign(item, row))
Expand All @@ -163,42 +167,42 @@ function getBodyLabelData ($xetable: any, opts: any, columns: any[], datas: any[
bodyExportMethod = columnOpts.exportMethod
}
if (bodyExportMethod) {
cellValue = bodyExportMethod({ $table: $xetable, row, column, options: opts })
cellValue = bodyExportMethod({ $table: $xeTable, row, column, options: opts })
} else {
switch (column.type) {
case 'seq': {
const seqValue = $rowIndex + 1
cellValue = mode === 'all' ? seqValue : getSeq($xetable, seqValue, row, $rowIndex, column, $columnIndex)
cellValue = mode === 'all' ? seqValue : getSeq($xeTable, seqValue, row, $rowIndex, column, $columnIndex)
break
}
case 'checkbox':
cellValue = toBooleanValue($xetable.isCheckedByCheckboxRow(row))
cellValue = toBooleanValue($xeTable.isCheckedByCheckboxRow(row))
item._checkboxLabel = checkboxOpts.labelField ? XEUtils.get(row, checkboxOpts.labelField) : ''
item._checkboxDisabled = checkboxOpts.checkMethod && !checkboxOpts.checkMethod({ row })
break
case 'radio':
cellValue = toBooleanValue($xetable.isCheckedByRadioRow(row))
cellValue = toBooleanValue($xeTable.isCheckedByRadioRow(row))
item._radioLabel = radioOpts.labelField ? XEUtils.get(row, radioOpts.labelField) : ''
item._radioDisabled = radioOpts.checkMethod && !radioOpts.checkMethod({ row })
break
default :
if (opts.original) {
cellValue = getCellValue(row, column)
} else {
cellValue = $xetable.getCellLabel(row, column)
cellValue = $xeTable.getCellLabel(row, column)
if (column.type === 'html') {
htmlCellElem.innerHTML = cellValue
cellValue = htmlCellElem.innerText.trim()
} else {
const cell = $xetable.getCellElement(row, column)
const cell = $xeTable.getCellElement(row, column)
if (cell) {
cellValue = cell.innerText.trim()
}
}
}
}
}
item[column.id] = XEUtils.toValueString(cellValue)
item[column.id] = toStringValue(cellValue)
})
return item
})
Expand Down
2 changes: 1 addition & 1 deletion packages/table/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7442,7 +7442,7 @@ const Methods = {
} as any

// Module methods
const funcs = 'setFilter,openFilter,clearFilter,saveFilterPanel,resetFilterPanel,getCheckedFilters,updateFilterOptionStatus,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFNR,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,fullValidateField,validateField,openExport,closeExport,openPrint,closePrint,getPrintHtml,exportData,openImport,closeImport,importData,saveFile,readFile,importByFile,print,openCustom,closeCustom,saveCustom,cancelCustom,resetCustom,toggleCustomAllCheckbox,setCustomAllCheckbox'.split(',')
const funcs = 'setFilter,openFilter,clearFilter,saveFilterPanel,resetFilterPanel,getCheckedFilters,updateFilterOptionStatus,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFNR,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,insertChild,insertChildAt,insertChildNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,fullValidateField,validateField,openExport,closeExport,openPrint,closePrint,getPrintHtml,exportData,openImport,closeImport,importData,saveFile,readFile,importByFile,print,openCustom,closeCustom,saveCustom,cancelCustom,resetCustom,toggleCustomAllCheckbox,setCustomAllCheckbox'.split(',')

funcs.forEach(name => {
Methods[name] = function (...args: any[]) {
Expand Down
25 changes: 3 additions & 22 deletions styles/components/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,6 @@
.vxe-ico-picker {
width: 100%;
}
.vxe-cell--tree-node {
.vxe-input,
.vxe-textarea,
.vxe-select,
.vxe-tree-select,
.vxe-date-picker,
.vxe-number-input,
.vxe-ico-picker {
width: 100%;
}
}
}
}
}
Expand All @@ -110,6 +99,9 @@
width: 100%;
}
& > .vxe-cell--tree-node {
.vxe-default-input,
.vxe-default-textarea,
.vxe-default-select,
.vxe-input,
.vxe-textarea,
.vxe-select,
Expand Down Expand Up @@ -138,17 +130,6 @@
& > .vxe-ico-picker {
width: 100%;
}
& > .vxe-cell--tree-node {
.vxe-input,
.vxe-textarea,
.vxe-select,
.vxe-tree-select,
.vxe-date-picker,
.vxe-number-input,
.vxe-ico-picker {
width: 100%;
}
}
}
.vxe-cell,
.vxe-table--filter-template {
Expand Down

0 comments on commit 6225334

Please sign in to comment.