mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
重构 4.0 next 版本
This commit is contained in:
@@ -1748,7 +1748,7 @@ const apis = [
|
||||
name: 'copyMethod',
|
||||
desc: '重写单元格复制取值的方法,将单元格复制到剪贴板',
|
||||
version: 'pro',
|
||||
type: '(params: { row, column }) => string',
|
||||
type: '(params: { row, column, cellValue }) => string',
|
||||
enum: '',
|
||||
defVal: '',
|
||||
list: []
|
||||
@@ -3550,12 +3550,12 @@ const apis = [
|
||||
list: []
|
||||
},
|
||||
{
|
||||
name: 'isFilter(column)',
|
||||
name: 'isFilter(fieldOrColumn)',
|
||||
desc: '判断指定列是否为筛选状态,如果为空则判断所有列',
|
||||
version: '',
|
||||
type: 'Boolean',
|
||||
enum: '',
|
||||
defVal: 'column?: string | ColumnInfo',
|
||||
defVal: 'fieldOrColumn?: string | ColumnInfo',
|
||||
list: []
|
||||
},
|
||||
{
|
||||
@@ -3577,21 +3577,21 @@ const apis = [
|
||||
list: []
|
||||
},
|
||||
{
|
||||
name: 'setActiveCell(row, field)',
|
||||
name: 'setActiveCell(row, fieldOrColumn)',
|
||||
desc: '用于 edit-config,激活单元格编辑',
|
||||
version: '',
|
||||
type: 'Promise<any>',
|
||||
enum: '',
|
||||
defVal: 'row: Row, field: string',
|
||||
defVal: 'row: Row, fieldOrColumn: string | ColumnInfo',
|
||||
list: []
|
||||
},
|
||||
{
|
||||
name: 'setSelectCell(row, field)',
|
||||
name: 'setSelectCell(row, fieldOrColumn)',
|
||||
desc: '用于 mouse-config.selected,选中指定的单元格',
|
||||
version: '',
|
||||
type: 'Promise<any>',
|
||||
enum: '',
|
||||
defVal: 'row: Row, field: string',
|
||||
defVal: 'row: Row, fieldOrColumn: string | ColumnInfo',
|
||||
list: []
|
||||
},
|
||||
{
|
||||
@@ -3852,7 +3852,7 @@ const apis = [
|
||||
version: '',
|
||||
type: 'Promise<any>',
|
||||
enum: '',
|
||||
defVal: 'fieldOrColumn?: string',
|
||||
defVal: 'fieldOrColumn?: string | ColumnConfig',
|
||||
list: []
|
||||
},
|
||||
{
|
||||
@@ -4081,12 +4081,12 @@ const apis = [
|
||||
list: []
|
||||
},
|
||||
{
|
||||
name: 'isSort(column)',
|
||||
name: 'isSort(fieldOrColumn)',
|
||||
desc: '判断指定列是否为排序状态,如果为空则判断所有列',
|
||||
version: '',
|
||||
type: 'Boolean',
|
||||
enum: '',
|
||||
defVal: 'column?: string | ColumnInfo',
|
||||
defVal: 'fieldOrColumn?: string | ColumnInfo',
|
||||
list: []
|
||||
},
|
||||
{
|
||||
|
||||
@@ -67,16 +67,16 @@ export default defineComponent({
|
||||
demo1.loading = true
|
||||
setTimeout(() => {
|
||||
demo1.tableData = [
|
||||
{ id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
|
||||
{ id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
|
||||
{ id: 10004, name: 'Test4', role: 'Designer', sex: 'Women ', age: 23, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10005, name: 'Test5', role: 'Develop', sex: 'Women ', age: 30, address: 'Shanghai' },
|
||||
{ id: 10006, name: 'Test6', role: 'Designer', sex: 'Women ', age: 21, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10007, name: 'Test7', role: 'Test', sex: 'Man ', age: 29, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10008, name: 'Test8', role: 'Develop', sex: 'Man ', age: 35, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10009, name: 'Test9', role: 'Test', sex: 'Women ', age: 21, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 100010, name: 'Test10', role: 'Develop', sex: 'Man ', age: 28, address: 'vxe-table 从入门到放弃' }
|
||||
{ id: 10001, name: 'Test1', role: 'Develop', sex: '0', age: 28, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10002, name: 'Test2', role: 'Test', sex: '1', age: 22, address: 'Guangzhou' },
|
||||
{ id: 10003, name: 'Test3', role: 'PM', sex: '0', age: 32, address: 'Shanghai' },
|
||||
{ id: 10004, name: 'Test4', role: 'Designer', sex: '1', age: 23, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10005, name: 'Test5', role: 'Develop', sex: '1', age: 30, address: 'Shanghai' },
|
||||
{ id: 10006, name: 'Test6', role: 'Designer', sex: '1', age: 21, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10007, name: 'Test7', role: 'Test', sex: '0', age: 29, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10008, name: 'Test8', role: 'Develop', sex: '0', age: 35, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10009, name: 'Test9', role: 'Test', sex: '1', age: 21, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 100010, name: 'Test10', role: 'Develop', sex: '0', age: 28, address: 'vxe-table 从入门到放弃' }
|
||||
]
|
||||
demo1.loading = false
|
||||
}, 500)
|
||||
@@ -144,16 +144,16 @@ export default defineComponent({
|
||||
demo1.loading = true
|
||||
setTimeout(() => {
|
||||
demo1.tableData = [
|
||||
{ id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
|
||||
{ id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
|
||||
{ id: 10004, name: 'Test4', role: 'Designer', sex: 'Women ', age: 23, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10005, name: 'Test5', role: 'Develop', sex: 'Women ', age: 30, address: 'Shanghai' },
|
||||
{ id: 10006, name: 'Test6', role: 'Designer', sex: 'Women ', age: 21, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10007, name: 'Test7', role: 'Test', sex: 'Man ', age: 29, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10008, name: 'Test8', role: 'Develop', sex: 'Man ', age: 35, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10009, name: 'Test9', role: 'Test', sex: 'Women ', age: 21, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 100010, name: 'Test10', role: 'Develop', sex: 'Man ', age: 28, address: 'vxe-table 从入门到放弃' }
|
||||
{ id: 10001, name: 'Test1', role: 'Develop', sex: '0', age: 28, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10002, name: 'Test2', role: 'Test', sex: '1', age: 22, address: 'Guangzhou' },
|
||||
{ id: 10003, name: 'Test3', role: 'PM', sex: '0', age: 32, address: 'Shanghai' },
|
||||
{ id: 10004, name: 'Test4', role: 'Designer', sex: '1', age: 23, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10005, name: 'Test5', role: 'Develop', sex: '1', age: 30, address: 'Shanghai' },
|
||||
{ id: 10006, name: 'Test6', role: 'Designer', sex: '1', age: 21, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10007, name: 'Test7', role: 'Test', sex: '0', age: 29, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10008, name: 'Test8', role: 'Develop', sex: '0', age: 35, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 10009, name: 'Test9', role: 'Test', sex: '1', age: 21, address: 'vxe-table 从入门到放弃' },
|
||||
{ id: 100010, name: 'Test10', role: 'Develop', sex: '0', age: 28, address: 'vxe-table 从入门到放弃' }
|
||||
]
|
||||
demo1.loading = false
|
||||
}, 500)
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
"qrcode": "^1.4.4",
|
||||
"sass-loader": "^8.0.2",
|
||||
"typescript": "~3.9.3",
|
||||
"vue": "^3.0.3",
|
||||
"vue": "^3.0.4",
|
||||
"vue-i18n": "^9.0.0-beta.7",
|
||||
"vue-router": "^4.0.0-0",
|
||||
"vuex": "^4.0.0-0",
|
||||
@@ -77,7 +77,7 @@
|
||||
"xe-ajax": "^4.0.5",
|
||||
"xe-ajax-mock": "^1.12.0",
|
||||
"xe-clipboard": "^1.10.0",
|
||||
"xe-utils": "^3.0.3",
|
||||
"xe-utils": "^3.0.4",
|
||||
"xlsx": "^0.16.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -367,22 +367,19 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
||||
*/
|
||||
setActiveRow (row) {
|
||||
const { visibleColumn } = internalData
|
||||
return $xetable.setActiveCell(row, XEUtils.find(visibleColumn, column => column.editRender).property)
|
||||
return $xetable.setActiveCell(row, XEUtils.find(visibleColumn, column => column.editRender))
|
||||
},
|
||||
/**
|
||||
* 激活单元格编辑
|
||||
*/
|
||||
setActiveCell (row, field) {
|
||||
const { visibleColumn } = internalData
|
||||
if (row && field) {
|
||||
const column = XEUtils.find(visibleColumn, column => column.property === field)
|
||||
setActiveCell (row, fieldOrColumn) {
|
||||
const column = XEUtils.isString(fieldOrColumn) ? $xetable.getColumnByField(fieldOrColumn) : fieldOrColumn
|
||||
if (row && column && column.editRender) {
|
||||
return $xetable.scrollToRow(row, column).then(() => {
|
||||
if (column && column.editRender) {
|
||||
const cell = $xetable.getCell(row, column)
|
||||
if (cell) {
|
||||
editPrivateMethods.handleActived({ row, rowIndex: $xetable.getRowIndex(row), column, columnIndex: $xetable.getColumnIndex(column), cell, $table: $xetable })
|
||||
internalData._lastCallTime = Date.now()
|
||||
}
|
||||
const cell = $xetable.getCell(row, column)
|
||||
if (cell) {
|
||||
editPrivateMethods.handleActived({ row, rowIndex: $xetable.getRowIndex(row), column, columnIndex: $xetable.getColumnIndex(column), cell, $table: $xetable })
|
||||
internalData._lastCallTime = Date.now()
|
||||
}
|
||||
return nextTick()
|
||||
})
|
||||
@@ -392,12 +389,12 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
||||
/**
|
||||
* 只对 trigger=dblclick 有效,选中单元格
|
||||
*/
|
||||
setSelectCell (row, field) {
|
||||
setSelectCell (row, fieldOrColumn) {
|
||||
const { tableData } = reactData
|
||||
const { visibleColumn } = internalData
|
||||
const editOpts = computeEditOpts.value
|
||||
if (row && field && editOpts.trigger !== 'manual') {
|
||||
const column = XEUtils.find(visibleColumn, column => column.property === field)
|
||||
const column = XEUtils.isString(fieldOrColumn) ? $xetable.getColumnByField(fieldOrColumn) : fieldOrColumn
|
||||
if (row && column && editOpts.trigger !== 'manual') {
|
||||
const rowIndex = $xetable.findRowIndexOf(tableData, row)
|
||||
if (rowIndex > -1 && column) {
|
||||
const cell = $xetable.getCell(row, column)
|
||||
|
||||
@@ -127,7 +127,7 @@ function getElementsByTagName (elem: any, qualifiedName: any) {
|
||||
return elem.getElementsByTagName(qualifiedName)
|
||||
}
|
||||
|
||||
function getTxtCellKey (now: any) {
|
||||
function getTxtCellKey (now: number) {
|
||||
return `#${now}@${XEUtils.uniqueId()}`
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ function parseCsvAndTxt (columns: any[], content: string, cellSeparator: string)
|
||||
} else {
|
||||
cells.forEach((val, colIndex) => {
|
||||
if (colIndex < fields.length) {
|
||||
item[fields[colIndex]] = getTxtCellValue(val, vMaps)
|
||||
item[fields[colIndex]] = getTxtCellValue(val.trim(), vMaps)
|
||||
}
|
||||
})
|
||||
rows.push(item)
|
||||
@@ -350,7 +350,7 @@ const tableExportHook: VxeGlobalHooksHandles.HookOptions = {
|
||||
if (opts.original) {
|
||||
cellValue = UtilTools.getCellValue(row, column)
|
||||
} else {
|
||||
cellValue = UtilTools.getCellLabel(row, column, { $table: $xetable })
|
||||
cellValue = $xetable.getCellLabel(row, column)
|
||||
if (column.type === 'html') {
|
||||
htmlCellElem.innerHTML = cellValue
|
||||
cellValue = htmlCellElem.innerText.trim()
|
||||
@@ -405,7 +405,7 @@ const tableExportHook: VxeGlobalHooksHandles.HookOptions = {
|
||||
if (opts.original) {
|
||||
cellValue = UtilTools.getCellValue(row, column)
|
||||
} else {
|
||||
cellValue = UtilTools.getCellLabel(row, column, { $table: $xetable })
|
||||
cellValue = $xetable.getCellLabel(row, column)
|
||||
if (column.type === 'html') {
|
||||
htmlCellElem.innerHTML = cellValue
|
||||
cellValue = htmlCellElem.innerText.trim()
|
||||
|
||||
@@ -123,21 +123,22 @@ const tableFilterHook: VxeGlobalHooksHandles.HookOptions = {
|
||||
/**
|
||||
* 清空指定列的筛选条件
|
||||
* 如果为空则清空所有列的筛选条件
|
||||
* @param {String} column 列或字段名
|
||||
* @param {String} fieldOrColumn 列或字段名
|
||||
*/
|
||||
clearFilter (column) {
|
||||
clearFilter (fieldOrColumn) {
|
||||
const { filterStore } = reactData
|
||||
const { tableFullColumn } = internalData
|
||||
const filterOpts = computeFilterOpts.value
|
||||
if (column && XEUtils.isString(column)) {
|
||||
column = $xetable.getColumnByField(column)
|
||||
}
|
||||
if (column) {
|
||||
filterPrivateMethods.handleClearFilter(column)
|
||||
let column
|
||||
if (fieldOrColumn) {
|
||||
column = XEUtils.isString(fieldOrColumn) ? $xetable.getColumnByField(fieldOrColumn) : fieldOrColumn
|
||||
if (column) {
|
||||
filterPrivateMethods.handleClearFilter(column)
|
||||
}
|
||||
} else {
|
||||
tableFullColumn.forEach(filterPrivateMethods.handleClearFilter)
|
||||
}
|
||||
if (!column || column !== filterStore.column) {
|
||||
if (!fieldOrColumn || column !== filterStore.column) {
|
||||
Object.assign(filterStore, {
|
||||
isAllSelected: false,
|
||||
isIndeterminate: false,
|
||||
|
||||
@@ -241,7 +241,7 @@ export default defineComponent({
|
||||
'c--tooltip': showTooltip,
|
||||
'c--ellipsis': showEllipsis
|
||||
}],
|
||||
title: showTitle ? UtilTools.getCellLabel(row, column, params) : null
|
||||
title: showTitle ? $xetable.getCellLabel(row, column) : null
|
||||
}, column.renderCell(params))
|
||||
)
|
||||
if (hasDefaultTip && hasValidError) {
|
||||
|
||||
@@ -82,8 +82,8 @@ function getFooterContent (params: any) {
|
||||
}
|
||||
|
||||
function getDefaultCellLabel (params: any) {
|
||||
const { row, column } = params
|
||||
return UtilTools.formatText(UtilTools.getCellLabel(row, column, params), 1)
|
||||
const { $table, row, column } = params
|
||||
return UtilTools.formatText($table.getCellLabel(row, column), 1)
|
||||
}
|
||||
|
||||
export const Cell = {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { defineComponent, getCurrentInstance, h, createCommentVNode, ComponentPu
|
||||
import XEUtils from 'xe-utils/ctor'
|
||||
import { UtilTools, DomTools, GlobalEvent, createResizeEvent, XEResizeObserver } from '../../tools'
|
||||
import { useSize } from '../../hooks/size'
|
||||
import formats from '../../v-x-e-table/src/formats'
|
||||
|
||||
import Cell from './cell'
|
||||
import GlobalConfig from '../../conf'
|
||||
@@ -13,7 +14,7 @@ import { eqCellNull, getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, r
|
||||
|
||||
import { VxeGridConstructor, VxeGridPrivateMethods, VxeTableConstructor, TableReactData, TableInternalData, VxeTablePropTypes, VxeToolbarConstructor, VxeTooltipInstance, TablePrivateMethods, TablePrivateRef, VxeTablePrivateComputed, VxeTablePrivateMethods, VxeTableMethods, TableMethods, VxeMenuPanelInstance } from '../../../types/vxe-table'
|
||||
|
||||
const { setCellValue, getCellLabel, hasChildrenList, getColumnList } = UtilTools
|
||||
const { setCellValue, hasChildrenList, getColumnList } = UtilTools
|
||||
const { browse, hasClass, addClass, removeClass, getEventTargetNode } = DomTools
|
||||
|
||||
const isWebkit = browse['-webkit'] && !browse.edge
|
||||
@@ -1116,13 +1117,7 @@ export default defineComponent({
|
||||
const sortRests = allSortMethod({ data: tableData, sortList: orderColumns, $table: $xetable })
|
||||
tableData = XEUtils.isArray(sortRests) ? sortRests : tableData
|
||||
} else {
|
||||
const params = { $table: $xetable }
|
||||
tableData = XEUtils.orderBy(tableData, orderColumns.map(({ column, property, order }) => {
|
||||
return {
|
||||
field: column.sortBy || (column.formatter ? (row: any) => getCellLabel(row, column, params) : property),
|
||||
order
|
||||
}
|
||||
}))
|
||||
tableData = XEUtils.orderBy(tableData, orderColumns.map(({ column, property, order }) => [column.sortBy || (column.formatter ? (row: any) => tablePrivateMethods.getCellLabel(row, column) : property), order]))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2857,15 +2852,15 @@ export default defineComponent({
|
||||
/**
|
||||
* 清空指定列的排序条件
|
||||
* 如果为空则清空所有列的排序条件
|
||||
* @param {String} columnOrField 列或字段名
|
||||
* @param {String} fieldOrColumn 列或字段名
|
||||
*/
|
||||
clearSort (columnOrField?: any) {
|
||||
clearSort (fieldOrColumn) {
|
||||
const sortOpts = computeSortOpts.value
|
||||
if (columnOrField && XEUtils.isString(columnOrField)) {
|
||||
columnOrField = tableMethods.getColumnByField(columnOrField)
|
||||
}
|
||||
if (columnOrField) {
|
||||
columnOrField.order = null
|
||||
if (fieldOrColumn) {
|
||||
const column = XEUtils.isString(fieldOrColumn) ? tableMethods.getColumnByField(fieldOrColumn) : fieldOrColumn
|
||||
if (column) {
|
||||
column.order = null
|
||||
}
|
||||
} else {
|
||||
clearAllSort()
|
||||
}
|
||||
@@ -2874,11 +2869,10 @@ export default defineComponent({
|
||||
}
|
||||
return nextTick()
|
||||
},
|
||||
isSort (columnOrField?: any) {
|
||||
let column
|
||||
if (columnOrField) {
|
||||
column = XEUtils.isString(columnOrField) ? tableMethods.getColumnByField(columnOrField) : columnOrField
|
||||
return column && column.sortable && column.order
|
||||
isSort (fieldOrColumn) {
|
||||
if (fieldOrColumn) {
|
||||
const column = XEUtils.isString(fieldOrColumn) ? tableMethods.getColumnByField(fieldOrColumn) : fieldOrColumn
|
||||
return column && column.sortable && !!column.order
|
||||
}
|
||||
return tableMethods.getSortColumns().length > 0
|
||||
},
|
||||
@@ -2909,15 +2903,14 @@ export default defineComponent({
|
||||
},
|
||||
/**
|
||||
* 判断指定列是否为筛选状态,如果为空则判断所有列
|
||||
* @param {String} field 字段名
|
||||
* @param {String} fieldOrColumn 字段名
|
||||
*/
|
||||
isFilter (columnOrField: any) {
|
||||
let column
|
||||
if (columnOrField) {
|
||||
column = XEUtils.isString(columnOrField) ? tableMethods.getColumnByField(columnOrField) : columnOrField
|
||||
return column && column.filters && column.filters.some((option: any) => option.checked)
|
||||
isFilter (fieldOrColumn) {
|
||||
const column = XEUtils.isString(fieldOrColumn) ? tableMethods.getColumnByField(fieldOrColumn) : fieldOrColumn
|
||||
if (column) {
|
||||
return column.filters && column.filters.some((option) => option.checked)
|
||||
}
|
||||
return $xetable.getCheckedFilters().length
|
||||
return $xetable.getCheckedFilters().length > 0
|
||||
},
|
||||
/**
|
||||
* 判断展开行是否懒加载完成
|
||||
@@ -4678,6 +4671,43 @@ export default defineComponent({
|
||||
}
|
||||
return null
|
||||
},
|
||||
getCellLabel (row, column) {
|
||||
const formatter = column.formatter
|
||||
const cellValue = UtilTools.getCellValue(row, column)
|
||||
let cellLabel = cellValue
|
||||
if (formatter) {
|
||||
let rest, formatData
|
||||
const { fullAllDataRowMap } = internalData
|
||||
const colid = column.id
|
||||
const cacheFormat = fullAllDataRowMap.has(row)
|
||||
const formatParams = { cellValue, row, column }
|
||||
if (cacheFormat) {
|
||||
rest = fullAllDataRowMap.get(row)
|
||||
formatData = rest.formatData
|
||||
if (!formatData) {
|
||||
formatData = fullAllDataRowMap.get(row).formatData = {}
|
||||
}
|
||||
if (rest && formatData[colid]) {
|
||||
if (formatData[colid].value === cellValue) {
|
||||
return formatData[colid].label
|
||||
}
|
||||
}
|
||||
}
|
||||
if (XEUtils.isString(formatter)) {
|
||||
const globalFunc = formats.get(formatter)
|
||||
cellLabel = globalFunc ? globalFunc(formatParams) : ''
|
||||
} else if (XEUtils.isArray(formatter)) {
|
||||
const globalFunc = formats.get(formatter[0])
|
||||
cellLabel = globalFunc ? globalFunc(formatParams, ...formatter.slice(1)) : ''
|
||||
} else {
|
||||
cellLabel = formatter(formatParams)
|
||||
}
|
||||
if (formatData) {
|
||||
formatData[colid] = { value: cellValue, label: cellLabel }
|
||||
}
|
||||
}
|
||||
return cellLabel
|
||||
},
|
||||
findRowIndexOf (list, row) {
|
||||
return row ? XEUtils.findIndexOf(list, item => $xetable.eqRow(item, row)) : -1
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import XEUtils from 'xe-utils/ctor'
|
||||
import GlobalConfig from '../../conf'
|
||||
import formats from '../../v-x-e-table/src/formats'
|
||||
|
||||
import { VxeTableConstructor } from '../../../types/vxe-table'
|
||||
|
||||
@@ -62,45 +61,6 @@ export const UtilTools = {
|
||||
getCellValue (row: any, column: any) {
|
||||
return XEUtils.get(row, column.property)
|
||||
},
|
||||
getCellLabel (row: any, column: any, params: { $table: VxeTableConstructor }) {
|
||||
const formatter: string | any[] | Function = column.formatter
|
||||
const cellValue = UtilTools.getCellValue(row, column)
|
||||
let cellLabel = cellValue
|
||||
if (params && formatter) {
|
||||
let rest, formatData
|
||||
const { $table } = params
|
||||
const { internalData } = $table
|
||||
const { fullAllDataRowMap } = internalData
|
||||
const colid = column.id
|
||||
const cacheFormat = fullAllDataRowMap.has(row)
|
||||
const formatParams = { cellValue, row, column }
|
||||
if (cacheFormat) {
|
||||
rest = fullAllDataRowMap.get(row)
|
||||
formatData = rest.formatData
|
||||
if (!formatData) {
|
||||
formatData = fullAllDataRowMap.get(row).formatData = {}
|
||||
}
|
||||
if (rest && formatData[colid]) {
|
||||
if (formatData[colid].value === cellValue) {
|
||||
return formatData[colid].label
|
||||
}
|
||||
}
|
||||
}
|
||||
if (XEUtils.isString(formatter)) {
|
||||
const globalFunc = formats.get(formatter)
|
||||
cellLabel = globalFunc ? globalFunc(formatParams) : ''
|
||||
} else if (XEUtils.isArray(formatter)) {
|
||||
const globalFunc = formats.get(formatter[0])
|
||||
cellLabel = globalFunc ? globalFunc(formatParams, ...formatter.slice(1)) : ''
|
||||
} else {
|
||||
cellLabel = formatter(formatParams)
|
||||
}
|
||||
if (formatData) {
|
||||
formatData[colid] = { value: cellValue, label: cellLabel }
|
||||
}
|
||||
}
|
||||
return cellLabel
|
||||
},
|
||||
setCellValue (row: any, column: any, value: any) {
|
||||
return XEUtils.set(row, column.property, value)
|
||||
},
|
||||
|
||||
4
types/edit.d.ts
vendored
4
types/edit.d.ts
vendored
@@ -98,13 +98,13 @@ export interface TableEditMethods {
|
||||
* @param row 指定行
|
||||
* @param field 字段名
|
||||
*/
|
||||
setActiveCell(row: RowInfo, field: string): Promise<any>;
|
||||
setActiveCell(row: RowInfo, fieldOrColumn: string | VxeTableDefines.ColumnInfo): Promise<any>;
|
||||
/**
|
||||
* 用于 mouse-config.mouse-config,选中某个单元格
|
||||
* @param row 指定行
|
||||
* @param field 字段名
|
||||
*/
|
||||
setSelectCell(row: RowInfo, field: string): Promise<any>;
|
||||
setSelectCell(row: RowInfo, fieldOrColumn: string | VxeTableDefines.ColumnInfo): Promise<any>;
|
||||
}
|
||||
|
||||
export interface TableEditPrivateMethods {
|
||||
|
||||
2
types/filter.d.ts
vendored
2
types/filter.d.ts
vendored
@@ -44,7 +44,7 @@ export interface TableFilterMethods {
|
||||
* 如果不传 column 则清空所有筛选条件,数据会恢复成未筛选的状态
|
||||
* @param column 字段名
|
||||
*/
|
||||
clearFilter(column?: VxeTableDefines.ColumnInfo | string): Promise<any>;
|
||||
clearFilter(column?: VxeTableDefines.ColumnInfo | string | null): Promise<any>;
|
||||
/**
|
||||
* 获取当前筛选的所有列信息
|
||||
*/
|
||||
|
||||
16
types/table.d.ts
vendored
16
types/table.d.ts
vendored
@@ -439,16 +439,12 @@ export interface TablePublicMethods {
|
||||
/**
|
||||
* 手动清空排序条件,数据会恢复成未排序的状态
|
||||
*/
|
||||
clearSort(): Promise<any>;
|
||||
clearSort(field: string | null): Promise<any>;
|
||||
clearSort(column: VxeTableDefines.ColumnInfo | null): Promise<any>;
|
||||
clearSort(fieldOrColumn?: string | VxeTableDefines.ColumnInfo | null): Promise<any>;
|
||||
/**
|
||||
* 判断指定列是否为排序状态,如果为空则判断所有列
|
||||
* @param columnOrField
|
||||
*/
|
||||
isSort(): boolean;
|
||||
isSort(field: string): boolean;
|
||||
isSort(column: VxeTableDefines.ColumnInfo): boolean;
|
||||
isSort(fieldOrColumn: string | VxeTableDefines.ColumnInfo): boolean;
|
||||
/**
|
||||
* 获取当前排序的列信息
|
||||
*/
|
||||
@@ -461,8 +457,7 @@ export interface TablePublicMethods {
|
||||
* 判断指定列是否为筛选状态,如果为空则判断所有列
|
||||
* @param column 列对象
|
||||
*/
|
||||
isFilter(field: string): boolean;
|
||||
isFilter(column: VxeTableDefines.ColumnInfo): boolean;
|
||||
isFilter(fieldOrColumn: string | VxeTableDefines.ColumnInfo): boolean;
|
||||
/**
|
||||
* 用于 expand-config.lazy,用于懒加载展开行,判断展开行是否懒加载完成
|
||||
* @param row 指定行
|
||||
@@ -679,7 +674,8 @@ export interface TablePrivateMethods {
|
||||
triggerHoverEvent(evnt: any, params: any): void;
|
||||
setHoverRow(row: any): void;
|
||||
clearHoverRow(): void;
|
||||
getCell(row: any, column: any): HTMLTableDataCellElement | null;
|
||||
getCell(row: any, column: VxeTableDefines.ColumnInfo): HTMLTableDataCellElement | null;
|
||||
getCellLabel (row: any, column: VxeTableDefines.ColumnInfo): any;
|
||||
findRowIndexOf(list: any[], row: any): number;
|
||||
eqRow(row1: any, row2: any): boolean;
|
||||
}
|
||||
@@ -1717,7 +1713,7 @@ export namespace VxeTableDefines {
|
||||
checked: boolean;
|
||||
halfChecked: boolean;
|
||||
disabled: boolean;
|
||||
order: string;
|
||||
order: VxeTablePropTypes.SortOrder;
|
||||
renderWidth: number;
|
||||
renderHeight: number;
|
||||
resizeWidth: number;
|
||||
|
||||
Reference in New Issue
Block a user