Skip to content

Commit

Permalink
releases 4.9.26
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 14, 2024
1 parent d2c0778 commit 6668697
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 25 deletions.
14 changes: 1 addition & 13 deletions examples/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createApp, h } from 'vue'
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'

Expand All @@ -14,18 +14,6 @@ import './style/index.scss'

VxeUI.setI18n('en-US', enUS)

VxeUI.renderer.add('CellImage', {
renderTableDefault (_renderOpts, params) {
const { props } = _renderOpts
const { column, row } = params
return h(VxeUI.VxeImage, {
width: '100%',
...props,
src: row[column.field]
})
}
})

createApp(App)
.use(router)
.use(VxeUI)
Expand Down
5 changes: 3 additions & 2 deletions examples/views/table/TableTest9.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
show-overflow
height="800"
:loading="loading"
:column-config="{resizable: true}"
:column-config="{resizable: true,drag: true}"
:row-config="{drag: true}"
:scroll-x="{enabled: true, gt: 0}"
:scroll-y="{enabled: true, gt: 0}"
:data="tableData">
<vxe-column type="checkbox" width="60"></vxe-column>
<vxe-column type="checkbox" width="60" drag-sort></vxe-column>
<vxe-column field="col0" title="列0" width="100"></vxe-column>
<vxe-column field="imgUrl" title="列1" width="80" :cell-render="imgUrlCellRender"></vxe-column>
<vxe-column field="col2" title="列2" width="90"></vxe-column>
Expand Down
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": "4.9.26-beta.1",
"version": "4.9.26",
"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": "^4.3.30"
"vxe-pc-ui": "^4.3.31"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
80 changes: 72 additions & 8 deletions packages/table/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import TableImportPanelComponent from '../module/export/import-panel'
import TableExportPanelComponent from '../module/export/export-panel'
import TableMenuPanelComponent from '../module/menu/panel'

import type { VxeLoadingComponent, VxeTooltipInstance, VxeTooltipComponent, VxeTabsConstructor, VxeTabsPrivateMethods, ValueOf, VxeComponentSlotType } from 'vxe-pc-ui'
import type { VxeLoadingComponent, VxeTooltipInstance, VxeTooltipComponent, VxeTabsConstructor, VxeTabsPrivateMethods, ValueOf, VxeComponentSlotType, VxeComponentStyleType } from 'vxe-pc-ui'
import type { VxeGridConstructor, VxeGridPrivateMethods, VxeTableConstructor, TableReactData, TableInternalData, VxeTablePropTypes, VxeToolbarConstructor, TablePrivateMethods, VxeTablePrivateRef, VxeTablePrivateComputed, VxeTablePrivateMethods, TableMethods, VxeTableMethods, VxeTableDefines, VxeTableEmits, VxeTableProps, VxeColumnPropTypes } from '../../../types'

const { getConfig, getIcon, getI18n, renderer, formats, createEvent, globalResize, interceptor, hooks, globalEvents, GLOBAL_EVENT_KEYS, useFns, renderEmptyElement } = VxeUI
Expand Down Expand Up @@ -683,6 +683,16 @@ export default defineComponent({
}
})

const computeTableStyle = computed(() => {
const { tableData } = reactData
const columnOpts = computeColumnOpts.value
const stys: VxeComponentStyleType = {}
if (columnOpts.drag) {
stys['--vxe-ui-table-drag-column-move-delay'] = `${Math.max(0.06, Math.min(0.3, tableData.length / 800))}s`
}
return stys
})

const refMaps: VxeTablePrivateRef = {
refElem,
refTooltip,
Expand Down Expand Up @@ -4203,11 +4213,25 @@ export default defineComponent({
* @param {Array/Row} rows 行数据
* @param {Boolean} value 是否选中
*/
setCheckboxRow (rows, value) {
setCheckboxRow (rows, checked) {
if (rows && !XEUtils.isArray(rows)) {
rows = [rows]
}
return handleCheckedCheckboxRow(rows, value, true)
return handleCheckedCheckboxRow(rows, checked, true)
},
setCheckboxRowKey (keys: any, checked) {
const { fullAllDataRowIdData } = internalData
if (!XEUtils.isArray(keys)) {
keys = [keys]
}
const rows: any = []
keys.forEach((rowid: string) => {
const rowRest = fullAllDataRowIdData[rowid]
if (rowRest) {
rows.push(rowRest.row)
}
})
return handleCheckedCheckboxRow(rows, checked, true)
},
isCheckedByCheckboxRow (row) {
const { selectCheckboxMaps } = reactData
Expand All @@ -4218,9 +4242,27 @@ export default defineComponent({
}
return !!selectCheckboxMaps[getRowid($xeTable, row)]
},
isCheckedByCheckboxRowKey (rowid: any) {
const { selectCheckboxMaps } = reactData
const { fullAllDataRowIdData } = internalData
const checkboxOpts = computeCheckboxOpts.value
const { checkField } = checkboxOpts
if (checkField) {
const rowRest = fullAllDataRowIdData[rowid]
if (rowRest) {
return XEUtils.get(rowRest.row, checkField)
}
return false
}
return !!selectCheckboxMaps[rowid]
},
isIndeterminateByCheckboxRow (row) {
const { treeIndeterminateMaps } = reactData
return !!treeIndeterminateMaps[getRowid($xeTable, row)] && !tableMethods.isCheckedByCheckboxRow(row)
return !!treeIndeterminateMaps[getRowid($xeTable, row)] && !$xeTable.isCheckedByCheckboxRow(row)
},
isIndeterminateByCheckboxRowKey (rowid: any) {
const { treeIndeterminateMaps } = reactData
return !!treeIndeterminateMaps[rowid] && !$xeTable.isCheckedByCheckboxRowKey(rowid)
},
/**
* 多选,切换某一行的选中状态
Expand Down Expand Up @@ -4376,7 +4418,18 @@ export default defineComponent({
return nextTick()
},
isCheckedByRadioRow (row) {
return $xeTable.eqRow(reactData.selectRadioRow, row)
const { selectRadioRow } = reactData
if (row && selectRadioRow) {
return $xeTable.eqRow(selectRadioRow, row)
}
return false
},
isCheckedByRadioRowKey (key) {
const { selectRadioRow } = reactData
if (selectRadioRow) {
return key === getRowid($xeTable, selectRadioRow)
}
return false
},
/**
* 用于单选行,设置某一行为选中状态
Expand All @@ -4385,6 +4438,18 @@ export default defineComponent({
setRadioRow (row) {
return handleCheckedRadioRow(row, true)
},
/**
* 用于单选行,设置某一行为选中状态
* @param key 行主键
*/
setRadioRowKey (rowid: any) {
const { fullAllDataRowIdData } = internalData
const rowRest = fullAllDataRowIdData[rowid]
if (rowRest) {
return handleCheckedRadioRow(rowRest.row, true)
}
return nextTick()
},
/**
* 用于当前行,手动清空当前高亮的状态
*/
Expand Down Expand Up @@ -8118,6 +8183,7 @@ export default defineComponent({
const virtualScrollBars = computeVirtualScrollBars.value
const resizableOpts = computeResizableOpts.value
const isArea = mouseConfig && mouseOpts.area
const tableStyle = computeTableStyle.value
return h('div', {
ref: refElem,
class: ['vxe-table', 'vxe-table--render-default', `tid_${xID}`, `border--${tableBorder}`, {
Expand Down Expand Up @@ -8151,9 +8217,7 @@ export default defineComponent({
'is--virtual-x': scrollXLoad,
'is--virtual-y': scrollYLoad
}],
style: {
'--vxe-ui-table-drag-column-move-delay': `${Math.max(0.05, Math.min(0.3, tableData.length / 800))}s`
},
style: tableStyle,
spellcheck: false,
onKeydown: keydownEvent
}, [
Expand Down

0 comments on commit 6668697

Please sign in to comment.