Skip to content

Commit

Permalink
releases 3.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 31, 2024
1 parent 182210e commit 27a9921
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 210 deletions.
2 changes: 1 addition & 1 deletion examples/views/table/TableTest2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
:row-config="{useKey: true,drag:true}"
:row-drag-config="{trigger:'row',disabledMethod:disabledRowMethod}"
:column-config="{useKey: true,drag: true}"
:column-drag-config="{isCrossDrag:true,isToChildDrag:true,isSelfToChildDrag:true,trigger:'default',disabledMethod:disabledColumnMethod}"
:column-drag-config="{isPeerDrag:true,isToChildDrag:true,isSelfToChildDrag:true,trigger:'default',disabledMethod:disabledColumnMethod}"
:custom-config="customConfig"
:loading="demo1.loading"
:import-config="{modes: importModes}"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table",
"version": "3.12.0-beta.15",
"version": "3.12.0",
"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.55"
"vxe-pc-ui": "^3.3.58"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.25.7",
Expand Down Expand Up @@ -64,7 +64,7 @@
"sass": "^1.80.4",
"sass-loader": "^14.2.1",
"typescript": "~4.5.5",
"vue": "2.6.14",
"vue": "~2.6.14",
"vue-i18n": "^8.15.1",
"vue-router": "^3.5.1",
"vue-template-compiler": "2.6.14"
Expand Down
10 changes: 5 additions & 5 deletions packages/table/module/custom/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ export default {
}
if (oldAllMaps[newColumn.id]) {
isSelfToChildStatus = true
if (!isSelfToChildDrag) {
if (!(isCrossDrag && isSelfToChildDrag)) {
if (VxeUI.modal) {
VxeUI.modal.message({
status: 'error',
Expand All @@ -1162,7 +1162,7 @@ export default {
}
if (oldAllMaps[newColumn.id]) {
isSelfToChildStatus = true
if (!isSelfToChildDrag) {
if (!(isCrossDrag && isSelfToChildDrag)) {
if (VxeUI.modal) {
VxeUI.modal.message({
status: 'error',
Expand All @@ -1179,7 +1179,7 @@ export default {
const oldewMatchRest = XEUtils.findTree(collectColumn as VxeTableDefines.ColumnInfo[], item => item.id === oldColumn.id)

// 改变层级
if (isSelfToChildStatus && isSelfToChildDrag) {
if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
if (oldewMatchRest) {
const { items: oCols, index: oIndex } = oldewMatchRest
const childList = oldColumn.children || []
Expand All @@ -1203,7 +1203,7 @@ export default {
if (newMatchRest) {
const { items: nCols, index: nIndex, parent: nParent } = newMatchRest
// 转子级
if (isToChildDrag && prevDragToChild) {
if ((isCrossDrag && isToChildDrag) && prevDragToChild) {
oldColumn.parentId = newColumn.id
newColumn.children = (newColumn.children || []).concat([oldColumn])
} else {
Expand Down Expand Up @@ -1294,7 +1294,7 @@ export default {
showDropTip(this, evnt, optEl, false, dragPos)
return
}
this.prevDragToChild = !!(isToChildDrag && hasCtrlKey && immediate)
this.prevDragToChild = !!((isCrossDrag && isToChildDrag) && hasCtrlKey && immediate)
this.prevDragCol = column
this.prevDragPos = dragPos
showDropTip(this, evnt, optEl, true, dragPos)
Expand Down
80 changes: 47 additions & 33 deletions packages/table/module/export/mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { parseFile, formatText, eqEmptyValue } from '../../../ui/src/utils'
import { createHtmlPage, getExportBlobByContent } from './util'
import { warnLog, errLog } from '../../../ui/src/log'

import type { VxeTablePropTypes, VxeGridConstructor, VxeTableDefines, VxeGridPropTypes, GridReactData } from '../../../../types'
import type { VxeTablePropTypes, VxeGridConstructor, VxeTableDefines, TableReactData, TableInternalData, GridReactData, VxeColumnPropTypes, VxeTableConstructor } from '../../../../types'

const { getI18n, renderer } = VxeUI

Expand All @@ -18,22 +18,22 @@ let fileInput: any
const csvBOM = '\ufeff'
const enterSymbol = '\r\n'

function hasTreeChildren ($xetable: any, row: any) {
const treeOpts = $xetable.treeOpts
function hasTreeChildren ($xeTable: VxeTableConstructor, row: any) {
const treeOpts = $xeTable.computeTreeOpts
const childrenField = treeOpts.children || treeOpts.childrenField
return row[childrenField] && row[childrenField].length > 0
return row[childrenField] && row[childrenField].length
}

function getSeq ($xetable: any, cellValue: any, row: any, $rowIndex: any, column: any, $columnIndex: any) {
const seqOpts = $xetable.seqOpts
function getSeq ($xeTable: VxeTableConstructor, cellValue: any, row: any, $rowIndex: any, column: any, $columnIndex: any) {
const seqOpts = $xeTable.computeSeqOpts
const seqMethod = seqOpts.seqMethod || column.seqMethod
if (seqMethod) {
return seqMethod({
row,
rowIndex: $xetable.getRowIndex(row),
rowIndex: $xeTable.getRowIndex(row),
$rowIndex,
column,
columnIndex: $xetable.getColumnIndex(column),
columnIndex: $xeTable.getColumnIndex(column),
$columnIndex
})
}
Expand Down Expand Up @@ -62,17 +62,23 @@ const toStringValue = (cellValue: any) => {
return eqEmptyValue(cellValue) ? '' : `${cellValue}`
}

function getBodyLabelData ($xeTable: any, opts: any, columns: any[], datas: any[]) {
function getBodyLabelData ($xeTable: VxeTableConstructor, opts: VxeTablePropTypes.ExportHandleOptions, columns: VxeTableDefines.ColumnInfo[], datas: any[]) {
const props = $xeTable

const { isAllExpand, mode } = opts
const { treeConfig, treeOpts, radioOpts, checkboxOpts, columnOpts } = $xeTable
const childrenField = treeOpts.children || treeOpts.childrenField
const { treeConfig } = props
const radioOpts = $xeTable.computeRadioOpts
const checkboxOpts = $xeTable.computeCheckboxOpts
const treeOpts = $xeTable.computeTreeOpts
const columnOpts = $xeTable.computeColumnOpts
if (!htmlCellElem) {
htmlCellElem = document.createElement('div')
}
if (treeConfig) {
const childrenField = treeOpts.children || treeOpts.childrenField
// 如果是树表格只允许导出数据源
const rest: any[] = []
const expandMaps = new Map()
const expandMaps: Map<any, number> = new Map()
XEUtils.eachTree(datas, (item, $rowIndex, items, path, parent, nodes) => {
const row = item._row || item
const parentRow = parent && parent._row ? parent._row : parent
Expand All @@ -85,13 +91,13 @@ function getBodyLabelData ($xeTable: any, opts: any, columns: any[], datas: any[
_expand: hasRowChild && $xeTable.isTreeExpandByRow(row)
}
columns.forEach((column, $columnIndex) => {
let cellValue = ''
let cellValue: string | number | boolean | null = ''
const renderOpts = column.editRender || column.cellRender
let bodyExportMethod = column.exportMethod
let bodyExportMethod: VxeColumnPropTypes.ExportMethod | undefined = column.exportMethod || columnOpts.exportMethod
if (!bodyExportMethod && renderOpts && renderOpts.name) {
const compConf = renderer.get(renderOpts.name)
if (compConf) {
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod || (compConf as any).cellExportMethod
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod
}
}
if (!bodyExportMethod) {
Expand All @@ -102,8 +108,8 @@ function getBodyLabelData ($xeTable: any, opts: any, columns: any[], datas: any[
} 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)
const seqVal = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
cellValue = mode === 'all' ? seqVal : getSeq($xeTable, seqVal, row, $rowIndex, column, $columnIndex)
break
}
case 'checkbox':
Expand Down Expand Up @@ -146,18 +152,15 @@ function getBodyLabelData ($xeTable: any, opts: any, columns: any[], datas: any[
_row: row
}
columns.forEach((column, $columnIndex) => {
let cellValue = ''
let cellValue: string | number | boolean | null = ''
const renderOpts = column.editRender || column.cellRender
let bodyExportMethod = column.exportMethod
let bodyExportMethod: VxeColumnPropTypes.ExportMethod | undefined = column.exportMethod || columnOpts.exportMethod
if (!bodyExportMethod && renderOpts && renderOpts.name) {
const compConf = renderer.get(renderOpts.name)
if (compConf) {
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod || (compConf as any).cellExportMethod
bodyExportMethod = compConf.tableExportMethod || compConf.exportMethod
}
}
if (!bodyExportMethod) {
bodyExportMethod = columnOpts.exportMethod
}
if (bodyExportMethod) {
cellValue = bodyExportMethod({ $table: $xeTable, row, column, options: opts })
} else {
Expand All @@ -177,7 +180,7 @@ function getBodyLabelData ($xeTable: any, opts: any, columns: any[], datas: any[
item._radioLabel = radioOpts.labelField ? XEUtils.get(row, radioOpts.labelField) : ''
item._radioDisabled = radioOpts.checkMethod && !radioOpts.checkMethod({ row })
break
default :
default:
if (opts.original) {
cellValue = getCellValue(row, column)
} else {
Expand All @@ -200,7 +203,7 @@ function getBodyLabelData ($xeTable: any, opts: any, columns: any[], datas: any[
})
}

function getExportData ($xetable: any, opts: any) {
function getExportData ($xetable: any, opts: VxeTablePropTypes.ExportHandleOptions) {
const { columns, dataFilterMethod } = opts
let datas = opts.data
if (dataFilterMethod) {
Expand Down Expand Up @@ -981,18 +984,29 @@ export function readLocalFile (options: any = {}) {
})
}

function handleExportAndPrint ($xeTable: any, options: VxeTablePropTypes.ExportOpts | VxeTablePropTypes.ExportConfig, isPrint?: any) {
function handleExportAndPrint ($xeTable: VxeTableConstructor, options: VxeTablePropTypes.ExportOpts | VxeTablePropTypes.ExportConfig, isPrint?: any) {
const props = $xeTable
const reactData = $xeTable as unknown as TableReactData
const internalData = $xeTable as unknown as TableInternalData
const $xeGrid = $xeTable.$xeGrid

const { initStore, customOpts, collectColumn, footerTableData, treeConfig, mergeList, isGroup, exportParams, exportOpts } = $xeTable
const proxyOpts = $xeGrid ? $xeGrid.computeProxyOpts : {} as VxeGridPropTypes.ProxyOpts
const { treeConfig, showHeader, showFooter } = props
const { initStore, mergeList, mergeFooterList, isGroup, footerTableData, exportStore, exportParams } = reactData
const { collectColumn } = internalData
const exportOpts = $xeTable.computeExportOpts
const hasTree = treeConfig
const customOpts = $xeTable.computeCustomOpts
const selectRecords = $xeTable.getCheckboxRecords()
const proxyOpts = $xeGrid ? $xeGrid.computeProxyOpts : {}
const hasFooter = !!footerTableData.length
const hasTree = treeConfig
const hasMerge = !hasTree && mergeList.length
const hasMerge = !!(mergeList.length || mergeFooterList.length)
const defOpts = Object.assign({
message: true,
isHeader: true,
isHeader: showHeader,
isFooter: showFooter,
isColgroup: isGroup,
isMerge: hasMerge,
useStyle: true,
current: 'current',
modes: ['current', 'selected'].concat(proxyOpts.ajax && proxyOpts.ajax.queryAll ? ['all'] : [])
}, options)
Expand Down Expand Up @@ -1027,7 +1041,7 @@ function handleExportAndPrint ($xeTable: any, options: VxeTablePropTypes.ExportO
column.checked = columns
? columns.some((item: any) => {
if (isColumnInfo(item)) {
return column === item
return column.id === (item as any).id
} else if (XEUtils.isString(item)) {
return column.field === item
} else {
Expand All @@ -1052,7 +1066,7 @@ function handleExportAndPrint ($xeTable: any, options: VxeTablePropTypes.ExportO
}
})
// 更新条件
Object.assign($xeTable.exportStore, {
Object.assign(exportStore, {
columns: exportColumns,
typeList,
modeList,
Expand Down
Loading

0 comments on commit 27a9921

Please sign in to comment.