重构渲染器
This commit is contained in:
@@ -39,7 +39,7 @@ Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
|
||||
* [x] Table with border
|
||||
* [x] Cell style
|
||||
* [x] Column resizing
|
||||
* [x] Maximum table height
|
||||
* [x] Minimum/maximum height
|
||||
* [x] Resize height & width
|
||||
* [x] Fixed column
|
||||
* [x] Grouping table header
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
* [x] 多种边框
|
||||
* [x] 单元格样式
|
||||
* [x] 列宽拖动
|
||||
* [x] 最大高度
|
||||
* [x] 最小/最大高度
|
||||
* [x] 自适应宽高
|
||||
* [x] 固定列
|
||||
* [x] 多级表头
|
||||
@@ -151,6 +151,12 @@ const tableData = ref([
|
||||
|
||||
💡 [官网文档源码](https://github.com/x-extends/vxe-table-docs)
|
||||
|
||||
## QQ 交流群
|
||||
|
||||
该群供大家交流問題,如果群人数已满,将会不定期剔除不活跃的。
|
||||
|
||||

|
||||
|
||||
## 运行项目
|
||||
|
||||
安装依赖
|
||||
|
||||
@@ -39,7 +39,7 @@ Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
|
||||
* [x] 多種邊框
|
||||
* [x] 儲存格樣式
|
||||
* [x] 列寬拖動
|
||||
* [x] 最大高度
|
||||
* [x] 最小/最大高度
|
||||
* [x] 自我調整寬高
|
||||
* [x] 固定列
|
||||
* [x] 多級表頭
|
||||
|
||||
@@ -33,10 +33,10 @@ export default defineComponent({
|
||||
const allAlign = ref('')
|
||||
|
||||
const tableData1 = ref([
|
||||
{ id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },
|
||||
{ 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: 24, address: 'Shanghai' }
|
||||
// { id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },
|
||||
// { 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: 24, address: 'Shanghai' }
|
||||
])
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vxe-table",
|
||||
"version": "4.5.0-beta.13",
|
||||
"version": "4.5.0-beta.15",
|
||||
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、JSON 配置式为零代码而设计...",
|
||||
"scripts": {
|
||||
"update": "npm install --legacy-peer-deps",
|
||||
|
||||
@@ -10,9 +10,9 @@ const tableFilterMethodKeys: (keyof TableFilterMethods)[] = ['setFilter', 'clear
|
||||
|
||||
const tableFilterHook: VxeGlobalHooksHandles.HookOptions = {
|
||||
setupTable ($xetable) {
|
||||
const { reactData, internalData } = $xetable
|
||||
const { props, reactData, internalData } = $xetable
|
||||
const { refTableBody, refTableFilter } = $xetable.getRefMaps()
|
||||
const { computeFilterOpts } = $xetable.getComputeMaps()
|
||||
const { computeFilterOpts, computeMouseOpts } = $xetable.getComputeMaps()
|
||||
|
||||
const filterPrivateMethods: TableFilterPrivateMethods = {
|
||||
checkFilterOptions () {
|
||||
@@ -137,8 +137,10 @@ const tableFilterHook: VxeGlobalHooksHandles.HookOptions = {
|
||||
* @param {Event} evnt 事件
|
||||
*/
|
||||
confirmFilterEvent (evnt: Event) {
|
||||
const { mouseConfig } = props
|
||||
const { filterStore, scrollXLoad: oldScrollXLoad, scrollYLoad: oldScrollYLoad } = reactData
|
||||
const filterOpts = computeFilterOpts.value
|
||||
const mouseOpts = computeMouseOpts.value
|
||||
const { column } = filterStore
|
||||
const { field } = column
|
||||
const values: any[] = []
|
||||
@@ -150,12 +152,16 @@ const tableFilterHook: VxeGlobalHooksHandles.HookOptions = {
|
||||
}
|
||||
})
|
||||
const filterList = $xetable.getCheckedFilters()
|
||||
const params = { $table: $xetable, $event: evnt, column, field, property: field, values, datas, filters: filterList, filterList }
|
||||
// 如果是服务端筛选,则跳过本地筛选处理
|
||||
if (!filterOpts.remote) {
|
||||
$xetable.handleTableData(true)
|
||||
$xetable.checkSelectionStatus()
|
||||
}
|
||||
$xetable.dispatchEvent('filter-change', { column, field, property: field, values, datas, filters: filterList, filterList }, evnt)
|
||||
if (mouseConfig && mouseOpts.area && $xetable.handleFilterEvent) {
|
||||
$xetable.handleFilterEvent(evnt, params)
|
||||
}
|
||||
$xetable.dispatchEvent('filter-change', params, evnt)
|
||||
$xetable.closeFilter()
|
||||
$xetable.updateFooter().then(() => {
|
||||
const { scrollXLoad, scrollYLoad } = reactData
|
||||
|
||||
@@ -977,9 +977,15 @@ export default defineComponent({
|
||||
break
|
||||
}
|
||||
default: {
|
||||
const btnMethod = VXETable.commands.get(code)
|
||||
if (btnMethod) {
|
||||
btnMethod({ code, button, $grid: $xegrid, $table: $xetable }, ...args)
|
||||
const gCommandOpts = VXETable.commands.get(code)
|
||||
if (gCommandOpts) {
|
||||
if (gCommandOpts.commandMethod) {
|
||||
gCommandOpts.commandMethod({ code, button, $grid: $xegrid, $table: $xetable }, ...args)
|
||||
} else {
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
errLog('vxe.error.notCommands', [code])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1028,6 +1034,24 @@ export default defineComponent({
|
||||
}
|
||||
return null
|
||||
}
|
||||
// setProxyInfo (options) {
|
||||
// if (props.proxyConfig && options) {
|
||||
// const { pager, form } = options
|
||||
// const proxyOpts = computeProxyOpts.value
|
||||
// if (pager) {
|
||||
// if (pager.currentPage) {
|
||||
// reactData.tablePage.currentPage = Number(pager.currentPage)
|
||||
// }
|
||||
// if (pager.pageSize) {
|
||||
// reactData.tablePage.pageSize = Number(pager.pageSize)
|
||||
// }
|
||||
// }
|
||||
// if (proxyOpts.form && form) {
|
||||
// Object.assign(reactData.formData, form)
|
||||
// }
|
||||
// }
|
||||
// return nextTick()
|
||||
// }
|
||||
}
|
||||
|
||||
// 检查插槽
|
||||
|
||||
@@ -23,6 +23,9 @@ export default {
|
||||
errProp: 'Unsupported parameter "{0}", possibly "{1}".',
|
||||
colRepet: 'column.{0}="{0}" is duplicated, which may make some features unusable',
|
||||
notFunc: 'method "{0}" not exist.',
|
||||
notValidators: 'Global validators "{0}" no existe.',
|
||||
notFormats: 'Global formats "{0}" no existe.',
|
||||
notCommands: 'Global commands "{0}" no existe.',
|
||||
notSlot: 'slot "{0}" does not exist',
|
||||
noTree: 'The tree structure does not support "{0}".',
|
||||
notProp: 'Unsupported parameters "{0}"',
|
||||
|
||||
@@ -24,6 +24,8 @@ export default {
|
||||
colRepet: 'columna.{0}="{0}" está duplicado, lo que puede hacer que algunas funciones sean inutilizables',
|
||||
notFunc: 'El método "{0}" no existe.',
|
||||
notValidators: 'Global validators "{0}" no existe.',
|
||||
notFormats: 'Global formats "{0}" no existe.',
|
||||
notCommands: 'Global commands "{0}" no existe.',
|
||||
notSlot: 'La ranura "{0}" no existe.',
|
||||
noTree: 'La estructura de árbol no soporta "{0}".',
|
||||
notProp: 'Parámetros no compatibles "{0}"',
|
||||
|
||||
@@ -24,6 +24,8 @@ export default {
|
||||
colRepet: 'column.{0}="{0}" が重複しているため、機能が使えなくなることがあります。',
|
||||
notFunc: 'method "{0}" はありません',
|
||||
notValidators: 'Global validators "{0}" no existe.',
|
||||
notFormats: 'Global formats "{0}" no existe.',
|
||||
notCommands: 'Global commands "{0}" no existe.',
|
||||
notSlot: 'slot "{0}" はありません',
|
||||
noTree: 'Tree structureは "{0}" をサポートしていません',
|
||||
notProp: 'サポートされていないパラメータ "{0}"',
|
||||
|
||||
@@ -24,6 +24,8 @@ export default {
|
||||
colRepet: 'column.{0}="{1}" 重复了,这可能会导致某些功能无法使用',
|
||||
notFunc: '方法 "{0}" 不存在',
|
||||
notValidators: '全局校验 "{0}" 不存在',
|
||||
notFormats: '全局格式化 "{0}" 不存在',
|
||||
notCommands: '全局指令 "{0}" 不存在',
|
||||
notSlot: '插槽 "{0}" 不存在',
|
||||
noTree: '树结构不支持 "{0}"',
|
||||
notProp: '不支持的参数 "{0}"',
|
||||
|
||||
@@ -24,6 +24,8 @@ export default {
|
||||
colRepet: 'column.{0}="{1}" 重複了,這可能會導致某些功能無法使用',
|
||||
notFunc: '方法 "{0}" 不存在',
|
||||
notValidators: '全局校验 "{0}" 不存在',
|
||||
notFormats: '全局格式化 "{0}" 不存在',
|
||||
notCommands: '全局指令 "{0}" 不存在',
|
||||
notSlot: '插槽 "{0}" 不存在',
|
||||
noTree: '樹狀結構不支援 {0}',
|
||||
notProp: '不支持的參數 "{0}"',
|
||||
|
||||
@@ -674,6 +674,7 @@ export const Cell = {
|
||||
}],
|
||||
title: GlobalConfig.i18n('vxe.table.sortAsc'),
|
||||
onClick (evnt: Event) {
|
||||
evnt.stopPropagation()
|
||||
$table.triggerSortEvent(evnt, column, 'asc')
|
||||
}
|
||||
}),
|
||||
@@ -683,6 +684,7 @@ export const Cell = {
|
||||
}],
|
||||
title: GlobalConfig.i18n('vxe.table.sortDesc'),
|
||||
onClick (evnt: Event) {
|
||||
evnt.stopPropagation()
|
||||
$table.triggerSortEvent(evnt, column, 'desc')
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import XEUtils from 'xe-utils'
|
||||
import GlobalConfig from '../../v-x-e-table/src/conf'
|
||||
import { VXETable } from '../../v-x-e-table'
|
||||
import { formats } from '../../v-x-e-table/src/formats'
|
||||
import { toFilters } from './util'
|
||||
import { getFuncText } from '../../tools/utils'
|
||||
import { warnLog, errLog } from '../../tools/log'
|
||||
@@ -43,14 +43,14 @@ export class ColumnInfo {
|
||||
}
|
||||
if (formatter) {
|
||||
if (XEUtils.isString(formatter)) {
|
||||
const globalFunc = VXETable.formats.get(formatter) || XEUtils[formatter]
|
||||
if (!XEUtils.isFunction(globalFunc)) {
|
||||
errLog('vxe.error.notFunc', [formatter])
|
||||
const gFormatOpts = formats.get(formatter) || XEUtils[formatter]
|
||||
if (!gFormatOpts || !XEUtils.isFunction(gFormatOpts.formatMethod)) {
|
||||
errLog('vxe.error.notFormats', [formatter])
|
||||
}
|
||||
} else if (XEUtils.isArray(formatter)) {
|
||||
const globalFunc = VXETable.formats.get(formatter[0]) || XEUtils[formatter[0]]
|
||||
if (!XEUtils.isFunction(globalFunc)) {
|
||||
errLog('vxe.error.notFunc', [formatter[0]])
|
||||
const gFormatOpts = formats.get(formatter[0]) || XEUtils[formatter[0]]
|
||||
if (!gFormatOpts || !XEUtils.isFunction(gFormatOpts.formatMethod)) {
|
||||
errLog('vxe.error.notFormats', [formatter[0]])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ export default {
|
||||
data: Array as PropType<any[]>,
|
||||
// 表格的高度
|
||||
height: [Number, String] as PropType<VxeTablePropTypes.Height>,
|
||||
// 表格的最小高度
|
||||
minHeight: { type: [Number, String] as PropType<VxeTablePropTypes.MinHeight>, default: () => GlobalConfig.table.minHeight },
|
||||
// 表格的最大高度
|
||||
maxHeight: [Number, String] as PropType<VxeTablePropTypes.MaxHeight>,
|
||||
// 已废弃,被 column-config.resizable 替换
|
||||
|
||||
@@ -257,6 +257,7 @@ export default defineComponent({
|
||||
// 表尾高度
|
||||
footerHeight: 0,
|
||||
customHeight: 0,
|
||||
customMinHeight: 0,
|
||||
customMaxHeight: 0,
|
||||
// 当前 hover 行
|
||||
hoverRow: null,
|
||||
@@ -848,7 +849,7 @@ export default defineComponent({
|
||||
})
|
||||
}
|
||||
|
||||
const calcHeight = (key: 'height' | 'maxHeight') => {
|
||||
const calcHeight = (key: 'height' | 'minHeight' | 'maxHeight') => {
|
||||
const { parentHeight } = reactData
|
||||
const val = props[key]
|
||||
let num = 0
|
||||
@@ -1099,6 +1100,7 @@ export default defineComponent({
|
||||
|
||||
const updateHeight = () => {
|
||||
internalData.customHeight = calcHeight('height')
|
||||
internalData.customMinHeight = calcHeight('minHeight')
|
||||
internalData.customMaxHeight = calcHeight('maxHeight')
|
||||
}
|
||||
|
||||
@@ -1459,7 +1461,7 @@ export default defineComponent({
|
||||
const updateStyle = () => {
|
||||
const { border, showFooter, showOverflow: allColumnOverflow, showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, mouseConfig, spanMethod, footerSpanMethod, keyboardConfig } = props
|
||||
const { isGroup, currentRow, tableColumn, scrollXLoad, scrollYLoad, scrollbarWidth, scrollbarHeight, columnStore, editStore, mergeList, mergeFooterList, isAllOverflow } = reactData
|
||||
let { visibleColumn, fullColumnIdData, tableHeight, tableWidth, headerHeight, footerHeight, elemStore, customHeight, customMaxHeight } = internalData
|
||||
let { visibleColumn, fullColumnIdData, tableHeight, tableWidth, headerHeight, footerHeight, elemStore, customHeight, customMinHeight, customMaxHeight } = internalData
|
||||
const containerList = ['main', 'left', 'right']
|
||||
const emptyPlaceholderElem = refEmptyPlaceholder.value
|
||||
const cellOffsetWidth = computeCellOffsetWidth.value
|
||||
@@ -1551,15 +1553,22 @@ export default defineComponent({
|
||||
const emptyBlockRef = elemStore[`${name}-${layout}-emptyBlock`]
|
||||
const emptyBlockElem = emptyBlockRef ? emptyBlockRef.value : null
|
||||
if (isNodeElement(wrapperElem)) {
|
||||
const bodyMinHeight = fixedType ? ((customMinHeight - headerHeight - footerHeight) - (showFooter ? 0 : scrollbarHeight)) : (customMinHeight - headerHeight - footerHeight)
|
||||
let bodyMaxHeight = 0
|
||||
if (customMaxHeight) {
|
||||
wrapperElem.style.maxHeight = `${fixedType ? customMaxHeight - headerHeight - (showFooter ? 0 : scrollbarHeight) : customMaxHeight - headerHeight - footerHeight}px`
|
||||
} else {
|
||||
if (customHeight > 0) {
|
||||
wrapperElem.style.height = `${fixedType ? (customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) - (showFooter ? 0 : scrollbarHeight) : customHeight - headerHeight - footerHeight}px`
|
||||
} else {
|
||||
wrapperElem.style.height = ''
|
||||
}
|
||||
bodyMaxHeight = Math.max(bodyMinHeight, fixedType ? (customMaxHeight - headerHeight - (showFooter ? 0 : scrollbarHeight)) : (customMaxHeight - headerHeight - footerHeight))
|
||||
wrapperElem.style.maxHeight = `${bodyMaxHeight}px`
|
||||
}
|
||||
if (customHeight > 0) {
|
||||
let bodyHeight = fixedType ? ((customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) - (showFooter ? 0 : scrollbarHeight)) : (customHeight - headerHeight - footerHeight)
|
||||
if (bodyMaxHeight) {
|
||||
bodyHeight = Math.min(bodyMaxHeight, bodyHeight)
|
||||
}
|
||||
wrapperElem.style.height = `${Math.max(bodyMinHeight, bodyHeight)}px`
|
||||
} else {
|
||||
wrapperElem.style.height = ''
|
||||
}
|
||||
wrapperElem.style.minHeight = `${bodyMinHeight}px`
|
||||
}
|
||||
|
||||
// 如果是固定列
|
||||
@@ -5628,7 +5637,9 @@ export default defineComponent({
|
||||
* 点击排序事件
|
||||
*/
|
||||
triggerSortEvent (evnt, column, order) {
|
||||
const { mouseConfig } = props
|
||||
const sortOpts = computeSortOpts.value
|
||||
const mouseOpts = computeMouseOpts.value
|
||||
const { field, sortable } = column
|
||||
if (sortable) {
|
||||
if (!order || column.order === order) {
|
||||
@@ -5636,7 +5647,10 @@ export default defineComponent({
|
||||
} else {
|
||||
tableMethods.sort({ field, order })
|
||||
}
|
||||
const params = { column, field, property: field, order: column.order, sortList: tableMethods.getSortColumns() }
|
||||
const params = { $table: $xetable, $event: evnt, column, field, property: field, order: column.order, sortList: tableMethods.getSortColumns(), sortTime: column.sortTime }
|
||||
if (mouseConfig && mouseOpts.area && $xetable.handleSortEvent) {
|
||||
return $xetable.handleSortEvent(evnt, params)
|
||||
}
|
||||
tableMethods.dispatchEvent('sort-change', params, evnt)
|
||||
}
|
||||
},
|
||||
@@ -5871,11 +5885,11 @@ export default defineComponent({
|
||||
}
|
||||
const formatParams = { cellValue, row, rowIndex: tableMethods.getRowIndex(row), column, columnIndex: tableMethods.getColumnIndex(column) }
|
||||
if (XEUtils.isString(formatter)) {
|
||||
const globalFunc = VXETable.formats.get(formatter)
|
||||
cellLabel = globalFunc ? globalFunc(formatParams) : ''
|
||||
const gFormatOpts = VXETable.formats.get(formatter)
|
||||
cellLabel = gFormatOpts && gFormatOpts.formatMethod ? gFormatOpts.formatMethod(formatParams) : ''
|
||||
} else if (XEUtils.isArray(formatter)) {
|
||||
const globalFunc = VXETable.formats.get(formatter[0])
|
||||
cellLabel = globalFunc ? globalFunc(formatParams, ...formatter.slice(1)) : ''
|
||||
const gFormatOpts = VXETable.formats.get(formatter[0])
|
||||
cellLabel = gFormatOpts && gFormatOpts.formatMethod ? gFormatOpts.formatMethod(formatParams, ...formatter.slice(1)) : ''
|
||||
} else {
|
||||
cellLabel = formatter(formatParams)
|
||||
}
|
||||
|
||||
@@ -300,10 +300,16 @@ export default defineComponent({
|
||||
if ($xegrid) {
|
||||
$xegrid.triggerToolbarBtnEvent(item, evnt)
|
||||
} else {
|
||||
const commandMethod = VXETable.commands.get(code)
|
||||
const gCommandOpts = VXETable.commands.get(code)
|
||||
const params = { code, button: item, $table: $xetable, $grid: $xegrid, $event: evnt }
|
||||
if (commandMethod) {
|
||||
commandMethod(params, evnt)
|
||||
if (gCommandOpts) {
|
||||
if (gCommandOpts.commandMethod) {
|
||||
gCommandOpts.commandMethod(params)
|
||||
} else {
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
errLog('vxe.error.notCommands', [code])
|
||||
}
|
||||
}
|
||||
}
|
||||
$xetoolbar.dispatchEvent('button-click', params, evnt)
|
||||
}
|
||||
@@ -316,10 +322,16 @@ export default defineComponent({
|
||||
if ($xegrid) {
|
||||
$xegrid.triggerToolbarTolEvent(item, evnt)
|
||||
} else {
|
||||
const commandMethod = VXETable.commands.get(code)
|
||||
const gCommandOpts = VXETable.commands.get(code)
|
||||
const params = { code, tool: item, $table: $xetable, $grid: $xegrid, $event: evnt }
|
||||
if (commandMethod) {
|
||||
commandMethod(params, evnt)
|
||||
if (gCommandOpts) {
|
||||
if (gCommandOpts.commandMethod) {
|
||||
gCommandOpts.commandMethod(params)
|
||||
} else {
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
errLog('vxe.error.notCommands', [code])
|
||||
}
|
||||
}
|
||||
}
|
||||
$xetoolbar.dispatchEvent('tool-click', params, evnt)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,59 @@
|
||||
import VXEStore from './store'
|
||||
import XEUtils from 'xe-utils'
|
||||
import { warnLog } from '../../tools/log'
|
||||
|
||||
import { VxeGlobalCommands } from '../../../types/v-x-e-table'
|
||||
|
||||
export const commands = new VXEStore() as VxeGlobalCommands
|
||||
class VXECommandsStore {
|
||||
private store: any = {}
|
||||
|
||||
mixin (options: any): VXECommandsStore {
|
||||
XEUtils.each(options, (item, key) => {
|
||||
this.add(key, item)
|
||||
})
|
||||
return this
|
||||
}
|
||||
|
||||
has (name: string): boolean {
|
||||
return !!this.get(name)
|
||||
}
|
||||
|
||||
get (name: string): any {
|
||||
return this.store[name]
|
||||
}
|
||||
|
||||
add (name: string, render: any): VXECommandsStore {
|
||||
const conf = this.store[name]
|
||||
// 兼容
|
||||
if (XEUtils.isFunction(render)) {
|
||||
// warnLog('vxe.error.delProp', ['callback', 'commandMethod'])
|
||||
render = {
|
||||
commandMethod: render
|
||||
}
|
||||
}
|
||||
|
||||
// 检测是否覆盖
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
const confKeys = XEUtils.keys(conf)
|
||||
XEUtils.each(render, (item, key) => {
|
||||
if (confKeys.includes(key)) {
|
||||
warnLog('vxe.error.coverProp', [name, key])
|
||||
}
|
||||
})
|
||||
}
|
||||
this.store[name] = conf ? XEUtils.merge(conf, render) : render
|
||||
return this
|
||||
}
|
||||
|
||||
delete (name: string): void {
|
||||
delete this.store[name]
|
||||
}
|
||||
|
||||
forEach (callback: any): void {
|
||||
XEUtils.objectEach(this.store, callback)
|
||||
}
|
||||
}
|
||||
|
||||
export const commands = new VXECommandsStore() as VxeGlobalCommands
|
||||
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
Object.assign(commands, { _name: 'Commands' })
|
||||
|
||||
@@ -15,6 +15,7 @@ const GlobalConfig: VXETableGlobalConfig = {
|
||||
animat: true,
|
||||
delayHover: 250,
|
||||
autoResize: true,
|
||||
minHeight: 144,
|
||||
// keepSource: false,
|
||||
// showOverflow: null,
|
||||
// showHeaderOverflow: null,
|
||||
@@ -49,7 +50,7 @@ const GlobalConfig: VXETableGlobalConfig = {
|
||||
validConfig: {
|
||||
showMessage: true,
|
||||
autoClear: true,
|
||||
message: 'default',
|
||||
message: 'inline',
|
||||
msgMode: 'single'
|
||||
},
|
||||
columnConfig: {
|
||||
|
||||
@@ -1,8 +1,59 @@
|
||||
import VXEStore from './store'
|
||||
import XEUtils from 'xe-utils'
|
||||
import { warnLog } from '../../tools/log'
|
||||
|
||||
import { VxeGlobalFormats } from '../../../types/v-x-e-table'
|
||||
|
||||
export const formats = new VXEStore() as VxeGlobalFormats
|
||||
class VXEFormatsStore {
|
||||
private store: any = {}
|
||||
|
||||
mixin (options: any): VXEFormatsStore {
|
||||
XEUtils.each(options, (item, key) => {
|
||||
this.add(key, item)
|
||||
})
|
||||
return this
|
||||
}
|
||||
|
||||
has (name: string): boolean {
|
||||
return !!this.get(name)
|
||||
}
|
||||
|
||||
get (name: string): any {
|
||||
return this.store[name]
|
||||
}
|
||||
|
||||
add (name: string, render: any): VXEFormatsStore {
|
||||
const conf = this.store[name]
|
||||
// 兼容
|
||||
if (XEUtils.isFunction(render)) {
|
||||
// warnLog('vxe.error.delProp', ['callback', 'formatMethod'])
|
||||
render = {
|
||||
formatMethod: render
|
||||
}
|
||||
}
|
||||
|
||||
// 检测是否覆盖
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
const confKeys = XEUtils.keys(conf)
|
||||
XEUtils.each(render, (item, key) => {
|
||||
if (confKeys.includes(key)) {
|
||||
warnLog('vxe.error.coverProp', [name, key])
|
||||
}
|
||||
})
|
||||
}
|
||||
this.store[name] = conf ? XEUtils.merge(conf, render) : render
|
||||
return this
|
||||
}
|
||||
|
||||
delete (name: string): void {
|
||||
delete this.store[name]
|
||||
}
|
||||
|
||||
forEach (callback: any): void {
|
||||
XEUtils.objectEach(this.store, callback)
|
||||
}
|
||||
}
|
||||
|
||||
export const formats = new VXEFormatsStore() as VxeGlobalFormats
|
||||
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
Object.assign(formats, { _name: 'Formats' })
|
||||
|
||||
@@ -25,6 +25,7 @@ class VXEMenusStore {
|
||||
const conf = this.store[name]
|
||||
// 兼容
|
||||
if (XEUtils.isFunction(render)) {
|
||||
// warnLog('vxe.error.delProp', ['callback', 'menuMethod'])
|
||||
render = {
|
||||
menuMethod: render
|
||||
}
|
||||
|
||||
@@ -1213,6 +1213,11 @@
|
||||
.vxe-cell--valid {
|
||||
bottom: calc(100%);
|
||||
}
|
||||
&:first-child {
|
||||
.vxe-cell--valid {
|
||||
bottom: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
types/grid.d.ts
vendored
22
types/grid.d.ts
vendored
@@ -134,6 +134,28 @@ export interface GridPublicMethods<D = VxeTableDataRow> {
|
||||
}
|
||||
pendingRecords: D[]
|
||||
} | null
|
||||
/**
|
||||
* 设置数据代理信息
|
||||
*/
|
||||
// setProxyInfo(options: {
|
||||
// /**
|
||||
// * 修改表格数据
|
||||
// */
|
||||
// data?: any[]
|
||||
// /**
|
||||
// * 修改表单数据
|
||||
// */
|
||||
// form?: {
|
||||
// [key: string]: any
|
||||
// },
|
||||
// /**
|
||||
// * 修改分页数据
|
||||
// */
|
||||
// pager?: {
|
||||
// pageSize?: number
|
||||
// currentPage?: number
|
||||
// }
|
||||
// }): Promise<any>
|
||||
}
|
||||
|
||||
export interface VxeGridMethods<D = VxeTableDataRow> extends GridMethods<D>, TablePublicMethods<D> { }
|
||||
|
||||
2
types/plugins/pro.d.ts
vendored
2
types/plugins/pro.d.ts
vendored
@@ -74,6 +74,8 @@ export interface VxeTableProPrivateMethods<D = VxeTableDataRow> {
|
||||
handleKeyboardEvent(evnt: KeyboardEvent): void
|
||||
handleHeaderCellAreaEvent(evnt: KeyboardEvent, params: VxeTableDefines.HeaderCellClickEventParams<D>): void
|
||||
handleCellAreaEvent(evnt: MouseEvent, params: VxeTableDefines.CellClickEventParams<D>): void
|
||||
handleFilterEvent(evnt: Event, params: VxeTableDefines.FilterChangeEventParams<D>): any
|
||||
handleSortEvent(evnt: Event, params: VxeTableDefines.SortChangeEventParams<D>): any
|
||||
handleUpdateCellAreas(): any
|
||||
handleCopyCellAreaEvent(evnt: ClipboardEvent): void
|
||||
handlePasteCellAreaEvent(evnt: ClipboardEvent): void
|
||||
|
||||
7
types/table.d.ts
vendored
7
types/table.d.ts
vendored
@@ -1019,6 +1019,7 @@ export interface TableInternalData<D = VxeTableDataRow> {
|
||||
// 表尾高度
|
||||
footerHeight: number
|
||||
customHeight: number
|
||||
customMinHeight: number
|
||||
customMaxHeight: number
|
||||
// 当前 hover 行
|
||||
hoverRow: any
|
||||
@@ -1131,6 +1132,7 @@ export namespace VxeTablePropTypes {
|
||||
export type ID = string
|
||||
export type Data<T = any> = T[]
|
||||
export type Height = number | string
|
||||
export type MinHeight = number | string
|
||||
export type MaxHeight = number | string
|
||||
export type Resizable = boolean
|
||||
export type Stripe = boolean
|
||||
@@ -2036,10 +2038,10 @@ export namespace VxeTablePropTypes {
|
||||
maxWidth?: number
|
||||
|
||||
/**
|
||||
* 不建议使用,后续废弃
|
||||
* 不建议使用,已废弃
|
||||
* @deprecated
|
||||
*/
|
||||
message?: string
|
||||
message?: 'inline' | 'default' | 'tooltip' | '' | null
|
||||
}
|
||||
export interface ValidOpts extends ValidConfig { }
|
||||
|
||||
@@ -2102,6 +2104,7 @@ export type VxeTableProps<D = VxeTableDataRow> = {
|
||||
id?: VxeTablePropTypes.ID
|
||||
data?: VxeTablePropTypes.Data<D>
|
||||
height?: VxeTablePropTypes.Height
|
||||
minHeight?: VxeTablePropTypes.MinHeight
|
||||
maxHeight?: VxeTablePropTypes.MaxHeight
|
||||
/**
|
||||
* 不建议使用,被 column-config.resizable 替换
|
||||
|
||||
28
types/v-x-e-table/commands.d.ts
vendored
28
types/v-x-e-table/commands.d.ts
vendored
@@ -1,29 +1,31 @@
|
||||
import { VxeGridConstructor } from '../grid'
|
||||
import { VxeToolbarPropTypes } from '../toolbar'
|
||||
import { VxeTableConstructor } from '../table'
|
||||
import { VxeTableConstructor, VxeTableDataRow } from '../table'
|
||||
|
||||
/* eslint-disable no-use-before-define */
|
||||
|
||||
export namespace VxeGlobalCommandsHandles {
|
||||
export type CommandsCallback = (params: CommandsOptions, ...args: any[]) => any
|
||||
export interface CommandsOptions {
|
||||
$grid: VxeGridConstructor | null
|
||||
$table: VxeTableConstructor
|
||||
export interface CommandsOptions<D = VxeTableDataRow> {
|
||||
commandMethod?: (params: CommandMethodParams<D>, ...args: any[]) => void
|
||||
}
|
||||
export interface CommandMethodParams<D = VxeTableDataRow> {
|
||||
$grid: VxeGridConstructor<D> | null
|
||||
$table: VxeTableConstructor<D>
|
||||
code: string
|
||||
button?: VxeToolbarPropTypes.ButtonConfig | null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局指令
|
||||
* 全局格式化
|
||||
*/
|
||||
export interface VxeGlobalCommands {
|
||||
mixin(options: {
|
||||
[code: string]: VxeGlobalCommandsHandles.CommandsCallback
|
||||
mixin(opts: {
|
||||
[name: string]: VxeGlobalCommandsHandles.CommandsOptions<any> | ((params: VxeGlobalCommandsHandles.CommandMethodParams<any>, ...args: any[]) => void)
|
||||
}): VxeGlobalCommands
|
||||
has(code: string): boolean
|
||||
get(code: string): VxeGlobalCommandsHandles.CommandsCallback
|
||||
add(code: string, callback: VxeGlobalCommandsHandles.CommandsCallback): VxeGlobalCommands
|
||||
delete(code: string): void
|
||||
forEach(callback: (options: VxeGlobalCommandsHandles.CommandsCallback, code: string) => void): void
|
||||
has(name: string): boolean
|
||||
get(name: string): VxeGlobalCommandsHandles.CommandsOptions<any>
|
||||
add(name: string, options: VxeGlobalCommandsHandles.CommandsOptions<any> | ((params: VxeGlobalCommandsHandles.CommandMethodParams<any>, ...args: any[]) => void)): VxeGlobalCommands
|
||||
delete(name: string): void
|
||||
forEach(callback: (options: VxeGlobalCommandsHandles.CommandsOptions<any>, name: string) => void): void
|
||||
}
|
||||
|
||||
22
types/v-x-e-table/formats.d.ts
vendored
22
types/v-x-e-table/formats.d.ts
vendored
@@ -1,13 +1,15 @@
|
||||
import { VxeTableDefines } from '../table'
|
||||
import { VxeTableDefines, VxeTableDataRow } from '../table'
|
||||
|
||||
/* eslint-disable no-use-before-define */
|
||||
|
||||
export namespace VxeGlobalFormatsHandles {
|
||||
export type FormatsCallback = (params: FormatsParams, ...args: any[]) => string | number
|
||||
export interface FormatsParams {
|
||||
export interface FormatsOptions<D = VxeTableDataRow> {
|
||||
formatMethod?: (params: FormatMethodParams<D>, ...args: any[]) => string | number
|
||||
}
|
||||
export interface FormatMethodParams<D = VxeTableDataRow> {
|
||||
cellValue: any
|
||||
row: any,
|
||||
column: VxeTableDefines.ColumnInfo
|
||||
row: D
|
||||
column: VxeTableDefines.ColumnInfo<D>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +17,12 @@ export namespace VxeGlobalFormatsHandles {
|
||||
* 全局格式化
|
||||
*/
|
||||
export interface VxeGlobalFormats {
|
||||
mixin(options: {
|
||||
[name: string]: VxeGlobalFormatsHandles.FormatsCallback
|
||||
mixin(opts: {
|
||||
[name: string]: VxeGlobalFormatsHandles.FormatsOptions<any> | ((params: VxeGlobalFormatsHandles.FormatMethodParams<any>, ...args: any[]) => string | number)
|
||||
}): VxeGlobalFormats
|
||||
has(name: string): boolean
|
||||
get(name: string): VxeGlobalFormatsHandles.FormatsCallback
|
||||
add(name: string, callback: VxeGlobalFormatsHandles.FormatsCallback): VxeGlobalFormats
|
||||
get(name: string): VxeGlobalFormatsHandles.FormatsOptions<any>
|
||||
add(name: string, options: VxeGlobalFormatsHandles.FormatsOptions<any> | ((params: VxeGlobalFormatsHandles.FormatMethodParams<any>, ...args: any[]) => string | number)): VxeGlobalFormats
|
||||
delete(name: string): void
|
||||
forEach(callback: (callback: VxeGlobalFormatsHandles.FormatsCallback, name: string) => void): void
|
||||
forEach(callback: (options: VxeGlobalFormatsHandles.FormatsOptions<any>, name: string) => void): void
|
||||
}
|
||||
|
||||
19
types/v-x-e-table/menus.d.ts
vendored
19
types/v-x-e-table/menus.d.ts
vendored
@@ -8,34 +8,19 @@ export namespace VxeGlobalMenusHandles {
|
||||
export type MenusOption<D = VxeTableDataRow> = {
|
||||
menuMethod?: (params: MenuMethodParams<D>, event: Event) => any
|
||||
}
|
||||
interface MenusParams<D = VxeTableDataRow> {
|
||||
$grid: VxeGridConstructor<D> | null
|
||||
$table: VxeTableConstructor<D> & VxeTablePrivateMethods<D>
|
||||
}
|
||||
export interface MenuMethodParams<D = VxeTableDataRow> extends MenusParams<D>, VxeGlobalRendererHandles.RenderCellParams<D> {
|
||||
export interface MenuMethodParams<D = VxeTableDataRow> extends VxeGlobalRendererHandles.RenderCellParams<D> {
|
||||
$grid: VxeGridConstructor<D> | null
|
||||
$table: VxeTableConstructor<D> & VxeTablePrivateMethods<D>
|
||||
$event: MouseEvent
|
||||
menu: VxeTableDefines.MenuFirstOption | VxeTableDefines.MenuChildOption
|
||||
}
|
||||
|
||||
/**
|
||||
* 请使用 MenusOption
|
||||
* @deprecated
|
||||
*/
|
||||
export type MenusCallback = MenusOption
|
||||
/**
|
||||
* 请使用 MenuMethodParams
|
||||
* @deprecated
|
||||
*/
|
||||
export interface MenusCallbackParams<D = VxeTableDataRow> extends MenuMethodParams<D> {}
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局快捷菜单
|
||||
*/
|
||||
export interface VxeGlobalMenus {
|
||||
mixin(options: {
|
||||
mixin(opts: {
|
||||
[code: string]: VxeGlobalMenusHandles.MenusOption<any> | ((params: VxeGlobalMenusHandles.MenuMethodParams<any>, event: Event) => any)
|
||||
}): VxeGlobalMenus
|
||||
has(code: string): boolean
|
||||
|
||||
Reference in New Issue
Block a user