Skip to content

Commit

Permalink
releases 3.12.14
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Feb 10, 2025
1 parent 3234d44 commit c068c30
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 101 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.12.13",
"version": "3.12.14",
"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.86"
"vxe-pc-ui": "^3.3.87"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.25.7",
Expand Down
11 changes: 5 additions & 6 deletions packages/table/module/edit/mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,19 +643,18 @@ export default {
}
focused.row = null
focused.column = null
$xeTable.$nextTick(() => {
if (mouseConfig && mouseOpts.area && $xeTable.handleRecalculateCellAreas) {
return $xeTable.handleRecalculateCellAreas()
}
})
if (validOpts.autoClear) {
if (validOpts.msgMode !== 'full' || getConfig().cellVaildMode === 'obsolete') {
if ($xeTable.clearValidate) {
return $xeTable.clearValidate()
}
}
}
return $xeTable.$nextTick()
return $xeTable.$nextTick().then(() => {
if (mouseConfig && mouseOpts.area && $xeTable.handleRecalculateCellAreas) {
return $xeTable.handleRecalculateCellAreas()
}
})
},
_getActiveRecord () {
if (process.env.VUE_APP_VXE_ENV === 'development') {
Expand Down
17 changes: 15 additions & 2 deletions packages/table/module/validator/mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { scrollToView } from '../../../ui/src/dom'
import { handleFieldOrColumn, getRowid } from '../../src/util'
import { warnLog, errLog } from '../../../ui/src/log'

import type { VxeTableDefines } from '../../../../types'
import type { VxeTableDefines, TableReactData, TableInternalData } from '../../../../types'

const { getConfig, validators } = VxeUI

Expand Down Expand Up @@ -154,8 +154,16 @@ export default {
* 返回 Promise 对象,或者使用回调方式
*/
beginValidate (rows: any, cols: VxeTableDefines.ColumnInfo[] | null, cb: any, isFull: any) {
const $xeTable = this
const props = $xeTable
const reactData = $xeTable as unknown as TableReactData
const internalData = $xeTable as unknown as TableInternalData

const validRest: any = {}
const { editRules, afterFullData, treeConfig, treeOpts } = this
const { editRules, treeConfig } = props
const { pendingRowMaps } = reactData
const { afterFullData } = internalData
const treeOpts = $xeTable.computeTreeOpts
const childrenField = treeOpts.children || treeOpts.childrenField
let validList
if (rows === true) {
Expand All @@ -178,6 +186,11 @@ export default {
if (editRules) {
const columns = cols && cols.length ? cols : this.getColumns()
const handleVaild = (row: any) => {
const rowid = getRowid($xeTable, row)
// 是否标记删除
if (pendingRowMaps[rowid]) {
return
}
if (isFull || !this.validRuleErr) {
const colVailds: any[] = []
columns.forEach((column: any) => {
Expand Down
171 changes: 120 additions & 51 deletions packages/table/render/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getFuncText, formatText, isEmptyValue } from '../../ui/src/utils'
import { getOnName, getModelEvent, getChangeEvent } from '../../ui/src/vn'
import { errLog } from '../../ui/src/log'

import type { VxeGlobalRendererHandles, VxeColumnPropTypes } from '../../../types'
import type { VxeGlobalRendererHandles, VxeColumnPropTypes, VxeTableConstructor, VxeTablePrivateMethods } from '../../../types'

const { getConfig, renderer, getI18n } = VxeUI

Expand Down Expand Up @@ -113,10 +113,15 @@ function getCellLabelVNs (h: CreateElement, renderOpts: any, params: any, cellLa
* @param modelFunc
* @param changeFunc
*/
function getNativeElementOns (renderOpts: any, params: any, modelFunc?: any, changeFunc?: any) {
function getNativeElementOns (renderOpts: any, params: any, eFns?: {
model: (evnt: Event) => void
change?: (evnt: Event) => void
blur?: (evnt: Event) => void
}) {
const { events } = renderOpts
const modelEvent = getModelEvent(renderOpts)
const changeEvent = getChangeEvent(renderOpts)
const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {}
const isSameEvent = changeEvent === modelEvent
const ons: any = {}
if (events) {
Expand All @@ -138,27 +143,42 @@ function getNativeElementOns (renderOpts: any, params: any, modelFunc?: any, cha
}
}
if (!isSameEvent && changeFunc) {
ons[getOnName(changeEvent)] = function (...args: any[]) {
changeFunc(...args)
ons[getOnName(changeEvent)] = function (evnt: Event) {
changeFunc(evnt)
if (events && events[changeEvent]) {
events[changeEvent](params, ...args)
events[changeEvent](params, evnt)
}
}
}
if (blurFunc) {
ons[getOnName(blurEvent)] = function (evnt: Event) {
blurFunc(evnt)
if (events && events[blurEvent]) {
events[blurEvent](params, evnt)
}
}
}
return ons
}

const blurEvent = 'blur'

/**
* 组件事件处理
* @param renderOpts
* @param params
* @param modelFunc
* @param changeFunc
*/
function getComponentOns (renderOpts: any, params: any, modelFunc?: any, changeFunc?: any) {
function getComponentOns (renderOpts: any, params: any, eFns?: {
model: (cellValue: any) => void
change?: (...args: any[]) => void
blur?: (...args: any[]) => void
}) {
const { events } = renderOpts
const modelEvent = getModelEvent(renderOpts)
const changeEvent = getChangeEvent(renderOpts)
const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {}
const ons: any = {}
XEUtils.objectEach(events, (func, key: any) => {
ons[getOnName(key)] = function (...args: any[]) {
Expand Down Expand Up @@ -186,68 +206,117 @@ function getComponentOns (renderOpts: any, params: any, modelFunc?: any, changeF
}
}
}
if (blurFunc) {
ons[getOnName(blurEvent)] = function (...args: any[]) {
blurFunc(...args)
if (events && events[blurEvent]) {
events[blurEvent](params, ...args)
}
}
}
return ons
}

function getEditOns (renderOpts: any, params: any) {
function getEditOns (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
const { $table, row, column } = params
const { name } = renderOpts
const { model } = column
const isImmediate = isImmediateCell(renderOpts, params)
return getComponentOns(renderOpts, params, (cellValue: any) => {
// 处理 model 值双向绑定
model.update = true
model.value = cellValue
if (isImmediate) {
setCellValue(row, column, cellValue)
}
}, (eventParams: any) => {
// 处理 change 事件相关逻辑
if (!isImmediate && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
const cellValue = eventParams.value
return getComponentOns(renderOpts, params, {
model (cellValue) {
// 处理 model 值双向绑定
model.update = true
model.value = cellValue
$table.updateStatus(params, cellValue)
} else {
$table.updateStatus(params)
if (isImmediate) {
setCellValue(row, column, cellValue)
}
},
change (eventParams) {
// 处理 change 事件相关逻辑
if (!isImmediate && name && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
const cellValue = eventParams.value
model.update = true
model.value = cellValue
$table.updateStatus(params, cellValue)
} else {
$table.updateStatus(params)
}
},
blur () {
if (isImmediate) {
$table.handleCellRuleUpdateStatus('blur', params)
} else {
$table.handleCellRuleUpdateStatus('blur', params, model.value)
}
}
})
}

function getFilterOns (renderOpts: any, params: any, option: any) {
return getComponentOns(renderOpts, params, (value: any) => {
// 处理 model 值双向绑定
option.data = value
}, () => {
handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
return getComponentOns(renderOpts, params, {
model (value) {
// 处理 model 值双向绑定
option.data = value
},
change () {
handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
},
blur () {
handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
}
})
}

function getNativeEditOns (renderOpts: any, params: any) {
const { $table, row, column } = params
const { model } = column
return getNativeElementOns(renderOpts, params, (evnt: any) => {
// 处理 model 值双向绑定
const cellValue = evnt.target.value
if (isImmediateCell(renderOpts, params)) {
setCellValue(row, column, cellValue)
} else {
model.update = true
model.value = cellValue
return getNativeElementOns(renderOpts, params, {
model (evnt) {
// 处理 model 值双向绑定
const targetEl = evnt.target as HTMLInputElement
if (targetEl) {
const cellValue = targetEl.value
if (isImmediateCell(renderOpts, params)) {
setCellValue(row, column, cellValue)
} else {
model.update = true
model.value = cellValue
}
}
},
change (evnt) {
// 处理 change 事件相关逻辑
const targetEl = evnt.target as HTMLInputElement
if (targetEl) {
const cellValue = targetEl.value
$table.updateStatus(params, cellValue)
}
},
blur (evnt) {
const targetEl = evnt.target as HTMLInputElement
if (targetEl) {
const cellValue = targetEl.value
$table.updateStatus(params, cellValue)
}
}
}, (evnt: any) => {
// 处理 change 事件相关逻辑
const cellValue = evnt.target.value
$table.updateStatus(params, cellValue)
})
}

function getNativeFilterOns (renderOpts: any, params: any, option: any) {
return getNativeElementOns(renderOpts, params, (evnt: any) => {
// 处理 model 值双向绑定
option.data = evnt.target.value
}, () => {
handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
return getNativeElementOns(renderOpts, params, {
model (evnt) {
// 处理 model 值双向绑定
const targetEl = evnt.target as HTMLInputElement
if (targetEl) {
option.data = targetEl.value
}
},
change () {
handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
},
blur () {
handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
}
})
}

Expand Down Expand Up @@ -280,7 +349,7 @@ function buttonCellRender (h: CreateElement, renderOpts: any, params: any) {
]
}

function defaultEditRender (h: CreateElement, renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams) {
function defaultEditRender (h: CreateElement, renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
const { row, column } = params
const cellValue = getCellValue(row, column)
return [
Expand All @@ -291,7 +360,7 @@ function defaultEditRender (h: CreateElement, renderOpts: VxeGlobalRendererHandl
]
}

function radioAndCheckboxEditRender (h: CreateElement, renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams) {
function radioAndCheckboxEditRender (h: CreateElement, renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
const { options } = renderOpts
const { row, column } = params
const cellValue = getCellValue(row, column)
Expand All @@ -310,7 +379,7 @@ function radioAndCheckboxEditRender (h: CreateElement, renderOpts: VxeGlobalRend
* 已废弃
* @deprecated
*/
function oldEditRender (h: CreateElement, renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams) {
function oldEditRender (h: CreateElement, renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
const { row, column } = params
const cellValue = getCellValue(row, column)
return [
Expand Down Expand Up @@ -776,7 +845,7 @@ renderer.mixin({
},
VxeColorPicker: {
tableAutoFocus: 'input',
renderTableEdit (h, renderOpts, params) {
renderTableEdit (h, renderOpts, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
const { row, column } = params
const { options } = renderOpts
const cellValue = getCellValue(row, column)
Expand Down Expand Up @@ -804,7 +873,7 @@ renderer.mixin({
},
VxeIconPicker: {
tableAutoFocus: 'input',
renderTableEdit (h, renderOpts, params) {
renderTableEdit (h, renderOpts, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
const { row, column } = params
const { options } = renderOpts
const cellValue = getCellValue(row, column)
Expand Down Expand Up @@ -840,7 +909,7 @@ renderer.mixin({
renderTableDefault: defaultEditRender
},
VxeImage: {
renderTableDefault (h, renderOpts, params) {
renderTableDefault (h, renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
const { row, column } = params
const { props } = renderOpts
const cellValue = getCellValue(row, column)
Expand All @@ -856,7 +925,7 @@ renderer.mixin({
}
},
VxeImageGroup: {
renderTableDefault (h, renderOpts, params) {
renderTableDefault (h, renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
const { row, column } = params
const { props } = renderOpts
const cellValue = getCellValue(row, column)
Expand All @@ -872,7 +941,7 @@ renderer.mixin({
}
},
VxeTextEllipsis: {
renderTableDefault (h, renderOpts, params) {
renderTableDefault (h, renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
const { row, column } = params
const { props } = renderOpts
const cellValue = getCellValue(row, column)
Expand Down
6 changes: 4 additions & 2 deletions packages/table/src/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')

let isVNPreEmptyStatus = false
if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
isVNPreEmptyStatus = true
if (!isGroup) {
if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
isVNPreEmptyStatus = true
}
}

const tcStyle: Record<string, string> = {}
Expand Down
Loading

0 comments on commit c068c30

Please sign in to comment.