mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
调整全局参数 setup 为 config
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vxe-table",
|
||||
"version": "3.7.0-beta.17",
|
||||
"version": "3.7.0-beta.19",
|
||||
"description": "一个基于 vue 的 PC 端表单/表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、JSON 配置式...",
|
||||
"scripts": {
|
||||
"update": "npm install --legacy-peer-deps",
|
||||
|
||||
@@ -858,7 +858,7 @@ function handleFileImport ($xetable, file, opts) {
|
||||
const { type, filename } = UtilTools.parseFile(file)
|
||||
|
||||
// 检查类型,如果为自定义导出,则不需要校验类型
|
||||
if (!importMethod && !XEUtils.includes(VXETable.config.importTypes, type)) {
|
||||
if (!importMethod && !XEUtils.includes(VXETable.globalConfs.importTypes, type)) {
|
||||
if (opts.message !== false) {
|
||||
// 检测弹窗模块
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
@@ -1042,7 +1042,7 @@ function handleExportAndPrint ($xetable, options, isPrint) {
|
||||
const hasTree = treeConfig
|
||||
const hasMerge = !hasTree && mergeList.length
|
||||
const defOpts = Object.assign({ message: true, isHeader: true }, options)
|
||||
const types = defOpts.types || VXETable.config.exportTypes
|
||||
const types = defOpts.types || VXETable.globalConfs.exportTypes
|
||||
const modes = defOpts.modes
|
||||
const checkMethod = customOpts.checkMethod
|
||||
const exportColumns = collectColumn.slice(0)
|
||||
@@ -1274,7 +1274,7 @@ export default {
|
||||
}
|
||||
|
||||
// 检查类型,如果为自定义导出,则不需要校验类型
|
||||
if (!opts.exportMethod && !XEUtils.includes(VXETable.config.exportTypes, type)) {
|
||||
if (!opts.exportMethod && !XEUtils.includes(VXETable.globalConfs.exportTypes, type)) {
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
errLog('vxe.error.notType', [type])
|
||||
}
|
||||
@@ -1349,7 +1349,7 @@ export default {
|
||||
},
|
||||
_importData (options) {
|
||||
const opts = Object.assign({
|
||||
types: VXETable.config.importTypes
|
||||
types: VXETable.globalConfs.importTypes
|
||||
// beforeImportMethod: null,
|
||||
// afterImportMethod: null
|
||||
}, this.importOpts, options)
|
||||
@@ -1399,7 +1399,7 @@ export default {
|
||||
})
|
||||
},
|
||||
_openImport (options) {
|
||||
const defOpts = Object.assign({ mode: 'insert', message: true, types: VXETable.config.importTypes }, options, this.importOpts)
|
||||
const defOpts = Object.assign({ mode: 'insert', message: true, types: VXETable.globalConfs.importTypes }, options, this.importOpts)
|
||||
const { types } = defOpts
|
||||
const isTree = !!this.getTreeStatus()
|
||||
if (isTree) {
|
||||
|
||||
@@ -1498,7 +1498,7 @@ const Methods = {
|
||||
*/
|
||||
showColumn (fieldOrColumn) {
|
||||
const column = handleFieldOrColumn(this, fieldOrColumn)
|
||||
if (column && column.visible) {
|
||||
if (column && !column.visible) {
|
||||
column.visible = true
|
||||
return this.handleCustom()
|
||||
}
|
||||
|
||||
@@ -803,11 +803,11 @@ export default {
|
||||
// }
|
||||
// 检查导入导出类型,如果自定义导入导出方法,则不校验类型
|
||||
const { exportConfig, exportOpts, importConfig, importOpts } = this
|
||||
if (importConfig && importOpts.types && !importOpts.importMethod && !XEUtils.includeArrays(VXETable.config.importTypes, importOpts.types)) {
|
||||
warnLog('vxe.error.errProp', [`export-config.types=${importOpts.types.join(',')}`, importOpts.types.filter(type => XEUtils.includes(VXETable.config.importTypes, type)).join(',') || VXETable.config.importTypes.join(',')])
|
||||
if (importConfig && importOpts.types && !importOpts.importMethod && !XEUtils.includeArrays(VXETable.globalConfs.importTypes, importOpts.types)) {
|
||||
warnLog('vxe.error.errProp', [`export-config.types=${importOpts.types.join(',')}`, importOpts.types.filter(type => XEUtils.includes(VXETable.globalConfs.importTypes, type)).join(',') || VXETable.globalConfs.importTypes.join(',')])
|
||||
}
|
||||
if (exportConfig && exportOpts.types && !exportOpts.exportMethod && !XEUtils.includeArrays(VXETable.config.exportTypes, exportOpts.types)) {
|
||||
warnLog('vxe.error.errProp', [`export-config.types=${exportOpts.types.join(',')}`, exportOpts.types.filter(type => XEUtils.includes(VXETable.config.exportTypes, type)).join(',') || VXETable.config.exportTypes.join(',')])
|
||||
if (exportConfig && exportOpts.types && !exportOpts.exportMethod && !XEUtils.includeArrays(VXETable.globalConfs.exportTypes, exportOpts.types)) {
|
||||
warnLog('vxe.error.errProp', [`export-config.types=${exportOpts.types.join(',')}`, exportOpts.types.filter(type => XEUtils.includes(VXETable.globalConfs.exportTypes, type)).join(',') || VXETable.globalConfs.exportTypes.join(',')])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { commands } from './src/commands'
|
||||
import { menus } from './src/menus'
|
||||
import { formats } from './src/formats'
|
||||
import { validators } from './src/validators'
|
||||
import { setup } from './src/setup'
|
||||
import { config } from './src/config'
|
||||
import { UtilTools } from '../tools/utils'
|
||||
import { errLog } from '../tools/log'
|
||||
|
||||
@@ -76,7 +76,9 @@ class VXETableConfig {
|
||||
return getExportOrImpotType(GlobalConfig.export.types, 2)
|
||||
}
|
||||
}
|
||||
export const config = new VXETableConfig()
|
||||
|
||||
// 已废弃
|
||||
export const globalConfs = new VXETableConfig()
|
||||
|
||||
export function t (key, args) {
|
||||
return GlobalConfig.i18n(key, args)
|
||||
@@ -87,6 +89,7 @@ export function _t (key, args) {
|
||||
}
|
||||
|
||||
export const v = 'v3'
|
||||
export const setup = config
|
||||
|
||||
export const VXETable = {
|
||||
v,
|
||||
@@ -94,13 +97,13 @@ export const VXETable = {
|
||||
reg,
|
||||
use,
|
||||
setup,
|
||||
config,
|
||||
interceptor,
|
||||
renderer,
|
||||
commands,
|
||||
formats,
|
||||
menus,
|
||||
validators,
|
||||
config,
|
||||
t,
|
||||
_t
|
||||
}
|
||||
@@ -110,6 +113,6 @@ export * from './src/renderer'
|
||||
export * from './src/commands'
|
||||
export * from './src/menus'
|
||||
export * from './src/formats'
|
||||
export * from './src/setup'
|
||||
export * from './src/config'
|
||||
|
||||
export default VXETable
|
||||
|
||||
@@ -21,9 +21,9 @@ class VXECommandsStore {
|
||||
const conf = this.store[name]
|
||||
// 兼容
|
||||
if (XEUtils.isFunction(render)) {
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
warnLog('vxe.error.delProp', ['commands -> callback', 'commandMethod'])
|
||||
}
|
||||
// if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
// warnLog('vxe.error.delProp', ['commands -> callback', 'commandMethod'])
|
||||
// }
|
||||
render = {
|
||||
commandMethod: render
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import GlobalConfig from '../../v-x-e-table/src/conf'
|
||||
import GlobalConfig from './conf'
|
||||
import XEUtils from 'xe-utils'
|
||||
|
||||
/**
|
||||
* 全局参数设置
|
||||
*/
|
||||
export function setup (options) {
|
||||
export function config (options) {
|
||||
return XEUtils.merge(GlobalConfig, options)
|
||||
}
|
||||
@@ -21,9 +21,9 @@ class VXEFormatsStore {
|
||||
const conf = this.store[name]
|
||||
// 兼容
|
||||
if (XEUtils.isFunction(render)) {
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
warnLog('vxe.error.delProp', ['formats -> callback', 'cellFormatMethod'])
|
||||
}
|
||||
// if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
// warnLog('vxe.error.delProp', ['formats -> callback', 'cellFormatMethod'])
|
||||
// }
|
||||
render = {
|
||||
cellFormatMethod: render
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ class VXEMenusStore {
|
||||
const conf = this.store[name]
|
||||
// 兼容
|
||||
if (XEUtils.isFunction(render)) {
|
||||
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
warnLog('vxe.error.delProp', ['menus -> callback', 'menuMethod'])
|
||||
}
|
||||
// if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
||||
// warnLog('vxe.error.delProp', ['menus -> callback', 'menuMethod'])
|
||||
// }
|
||||
render = {
|
||||
menuMethod: render
|
||||
}
|
||||
|
||||
30
types/v-x-e-table/index.d.ts
vendored
30
types/v-x-e-table/index.d.ts
vendored
@@ -9,7 +9,7 @@ import { VxeGlobalCommands } from './commands'
|
||||
import { VxeGlobalFormats } from './formats'
|
||||
import { VxeGlobalMenus } from './menus'
|
||||
import { VxeGlobalValidators } from './validators'
|
||||
import { VxeGlobalConfigMethod } from './setup'
|
||||
import { VxeGlobalConfigMethod } from './config'
|
||||
|
||||
/* eslint-disable no-use-before-define */
|
||||
|
||||
@@ -17,7 +17,7 @@ export type VxeGlobalI18n = (key: string, args?: any) => number | string;
|
||||
export type VxeGlobalTranslate = (key: string, args?: any) => string;
|
||||
export type VxeGlobalUse = (plugin: VXETablePluginObject, ...options: any[]) => VXETableCore;
|
||||
|
||||
export const setup: VxeGlobalConfigMethod
|
||||
export const config: VxeGlobalConfigMethod
|
||||
export const interceptor: VxeGlobalInterceptor
|
||||
export const renderer: VxeGlobalRenderer
|
||||
export const commands: VxeGlobalCommands
|
||||
@@ -31,6 +31,12 @@ export const t: VxeGlobalI18n
|
||||
export const _t: VxeGlobalTranslate
|
||||
export const use: VxeGlobalUse
|
||||
|
||||
/**
|
||||
* 请使用 config
|
||||
* @deprecated
|
||||
*/
|
||||
export const setup: VxeGlobalConfigMethod
|
||||
|
||||
export interface VXETablePluginObject {
|
||||
install(vxetable: VXETableCore, ...options: any[]): void;
|
||||
[key: string]: any;
|
||||
@@ -41,11 +47,6 @@ export type VXETableVersion = 'v1' | 'v2' | 'v3' | 'v4'
|
||||
export const v: VXETableVersion
|
||||
|
||||
export interface VXETableCore {
|
||||
/**
|
||||
* 已被 version 替换
|
||||
* @deprecated
|
||||
*/
|
||||
v: VXETableVersion;
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
@@ -53,7 +54,7 @@ export interface VXETableCore {
|
||||
/**
|
||||
* 设置全局参数/获取所有参数
|
||||
*/
|
||||
setup: VxeGlobalConfigMethod;
|
||||
config: VxeGlobalConfigMethod;
|
||||
/**
|
||||
* Table interceptor
|
||||
*/
|
||||
@@ -105,6 +106,17 @@ export interface VXETableCore {
|
||||
*/
|
||||
t: VxeGlobalI18n;
|
||||
_t: VxeGlobalTranslate;
|
||||
|
||||
/**
|
||||
* 已被 version 替换
|
||||
* @deprecated
|
||||
*/
|
||||
v: VXETableVersion;
|
||||
/**
|
||||
* 请使用 config
|
||||
* @deprecated
|
||||
*/
|
||||
setup: VxeGlobalConfigMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,6 +130,6 @@ export * from './commands'
|
||||
export * from './formats'
|
||||
export * from './menus'
|
||||
export * from './validators'
|
||||
export * from './setup'
|
||||
export * from './config'
|
||||
|
||||
export default VXETable
|
||||
|
||||
Reference in New Issue
Block a user