From 8c410c778578b2a8d4f06d55360bfc216f33a27f Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Sat, 27 Feb 2021 18:53:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0ts=E3=80=81=E5=86=85=E9=83=A8?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E3=80=81=E4=BF=AE=E5=A4=8D=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/api/table.ts | 19 ++++++++ examples/i18n/lang/en-US.ts | 3 +- examples/i18n/lang/zh-CN.ts | 3 +- examples/i18n/lang/zh-TC.ts | 3 +- helper/vetur/attributes.json | 88 ++++++++++++++++++++++++----------- helper/vetur/tags.json | 29 ++++++++---- packages/button/src/button.ts | 6 ++- packages/conf/index.ts | 3 ++ packages/table/src/props.ts | 2 + packages/table/src/table.ts | 5 ++ types/table.d.ts | 72 +++++++++++++++++++++++++--- types/v-x-e-table/index.d.ts | 6 ++- 12 files changed, 189 insertions(+), 50 deletions(-) diff --git a/examples/api/table.ts b/examples/api/table.ts index 91bc3d7c8..026257c68 100644 --- a/examples/api/table.ts +++ b/examples/api/table.ts @@ -1974,6 +1974,25 @@ const apis = [ } ] }, + { + name: 'area-config', + descKey: 'app.api.table.desc.areaConfig', + version: 'pro', + type: 'any', + enum: '', + defVal: '继承 setup.table.areaConfig', + list: [ + { + name: 'selectCellByHeader', + desc: '只对 area 启用后有效,点击列头是否选取当前列的所有单元格', + version: 'pro', + type: 'boolean', + enum: '', + defVal: 'true', + list: [] + } + ] + }, { name: 'keyboard-config', descKey: 'app.api.table.desc.keyboardConfig', diff --git a/examples/i18n/lang/en-US.ts b/examples/i18n/lang/en-US.ts index 1c9043b54..23e73054c 100644 --- a/examples/i18n/lang/en-US.ts +++ b/examples/i18n/lang/en-US.ts @@ -328,7 +328,7 @@ export default { compatibility: 'Compatibility', releases: 'Releases', donation: '支持我们', - issuesTitle: '该群供大家交流問題,群人数已达上限,将不定期剔除不活跃的
,如果有 bug 请通过 issues 反馈', + issuesTitle: '该群供大家交流問題,如果群人数已满,将会不定期剔除不活跃的
,如果有 bug 请通过 issues 反馈', newFunc: 'Since the author is busy, there may be time to support this function later!', newDevelopment: 'this release is being refactored. Stay tuned!' }, @@ -447,6 +447,7 @@ export default { clipConfig: 'Copy and paste configuration', fnrConfig: 'find and replace configuration', mouseConfig: 'Mouse configuration', + areaConfig: 'Area selection configuration', keyboardConfig: 'Keyboard configuration', editConfig: 'Editable configuration', validConfig: 'Validate configuration', diff --git a/examples/i18n/lang/zh-CN.ts b/examples/i18n/lang/zh-CN.ts index 0e1fda5fb..e3c1954ed 100644 --- a/examples/i18n/lang/zh-CN.ts +++ b/examples/i18n/lang/zh-CN.ts @@ -327,7 +327,7 @@ export default { compatibility: '兼容性变动', releases: '更新日志', donation: '支持我们', - issuesTitle: '该群供大家交流問題,群人数已达上限,将不定期剔除不活跃的
,如果有 bug 请通过 issues 反馈', + issuesTitle: '该群供大家交流問題,如果群人数已满,将会不定期剔除不活跃的
,如果有 bug 请通过 issues 反馈', newFunc: '由于作者很忙,后续有时间可能会支持该功能!', newDevelopment: '该版本正在重构中,敬请期待!' }, @@ -446,6 +446,7 @@ export default { clipConfig: '复制/粘贴配置项', fnrConfig: '查找/替换配置项', mouseConfig: '鼠标配置项', + areaConfig: '区域选取配置项', keyboardConfig: '按键配置项', editConfig: '可编辑配置项', validConfig: '校验配置项', diff --git a/examples/i18n/lang/zh-TC.ts b/examples/i18n/lang/zh-TC.ts index be464a0f8..01b56ac73 100644 --- a/examples/i18n/lang/zh-TC.ts +++ b/examples/i18n/lang/zh-TC.ts @@ -327,7 +327,7 @@ export default { compatibility: '相容性變動', releases: '更新日誌', donation: '支持我们', - issuesTitle: '该群供大家交流問題,群人数已达上限,将不定期剔除不活跃的
,如果有 bug 请通过 issues 反馈', + issuesTitle: '该群供大家交流問題,如果群人数已满,将会不定期剔除不活跃的
,如果有 bug 请通过 issues 反馈', newFunc: '由於作者很忙,後續有時間可能會支持該功能!', newDevelopment: '該版本正在重構中,敬請期待!' }, @@ -446,6 +446,7 @@ export default { clipConfig: '复制/粘贴配置项', fnrConfig: '查找/替换配置项', mouseConfig: '鼠标配置项', + areaConfig: '区域选取配置项', keyboardConfig: '按键配置项', editConfig: '可编辑配置项', validConfig: '校验配置项', diff --git a/helper/vetur/attributes.json b/helper/vetur/attributes.json index ee69cd99e..50bbc59e1 100644 --- a/helper/vetur/attributes.json +++ b/helper/vetur/attributes.json @@ -187,6 +187,10 @@ "type": "any", "description": "列的默认参数" }, + "vxe-table/resizable-config": { + "type": "object", + "description": "列宽拖动配置项" + }, "vxe-table/seq-config": { "type": "any", "description": "序号配置项" @@ -225,11 +229,11 @@ }, "vxe-table/expand-config": { "type": "any", - "description": "展开行配置项" + "description": "展开行配置项(不能用于虚拟滚动)" }, "vxe-table/tree-config": { "type": "any", - "description": "树形结构配置项" + "description": "树形结构配置项(不能用于虚拟滚动)" }, "vxe-table/menu-config": { "type": "any", @@ -247,6 +251,10 @@ "type": "any", "description": "鼠标配置项" }, + "vxe-table/area-config": { + "type": "any", + "description": "区域选取配置项" + }, "vxe-table/keyboard-config": { "type": "any", "description": "按键配置项" @@ -277,15 +285,15 @@ }, "vxe-table/scroll-x": { "type": "any", - "description": "横向虚拟滚动配置(注:当 tree-config 启用后自动关闭该功能)" + "description": "横向虚拟滚动配置(不支持深层结构和展开行)" }, "vxe-table/scroll-y": { "type": "any", - "description": "纵向虚拟滚动配置(注:当 tree-config 启用后自动关闭该功能)" + "description": "纵向虚拟滚动配置(不支持深层结构和展开行)" }, "vxe-table/params": { "type": "any", - "description": "额外的参数(可以用来存放一些私有参数)" + "description": "自定义参数(可以用来存放一些自定义的数据)" }, "vxe-table-colgroup/field": { "type": "string", @@ -309,7 +317,7 @@ }, "vxe-table-colgroup/visible": { "type": "boolean", - "description": "列是否显示" + "description": "默认是否显示" }, "vxe-table-colgroup/fixed": { "type": "string", @@ -361,7 +369,7 @@ }, "vxe-table-column/visible": { "type": "boolean", - "description": "列是否显示" + "description": "默认是否显示" }, "vxe-table-column/fixed": { "type": "string", @@ -419,6 +427,10 @@ "type": "string | ((row) => string | number)", "description": "只对 sortable 有效,自定义排序的属性" }, + "vxe-table-column/sort-type": { + "type": "string", + "description": "排序的字段类型,比如字符串转数值等" + }, "vxe-table-column/filters": { "type": "any[]", "description": "配置筛选条件(注:筛选只能用于列表,如果是树结构则过滤根节点)" @@ -667,6 +679,10 @@ "type": "any", "description": "列的默认参数" }, + "vxe-grid/resizable-config": { + "type": "object", + "description": "列宽拖动配置项" + }, "vxe-grid/seq-config": { "type": "any", "description": "序号配置项" @@ -705,11 +721,11 @@ }, "vxe-grid/expand-config": { "type": "any", - "description": "展开行配置项" + "description": "展开行配置项(不能用于虚拟滚动)" }, "vxe-grid/tree-config": { "type": "any", - "description": "树形结构配置项" + "description": "树形结构配置项(不能用于虚拟滚动)" }, "vxe-grid/menu-config": { "type": "any", @@ -727,6 +743,10 @@ "type": "any", "description": "鼠标配置项" }, + "vxe-grid/area-config": { + "type": "any", + "description": "区域选取配置项" + }, "vxe-grid/keyboard-config": { "type": "any", "description": "按键配置项" @@ -757,15 +777,15 @@ }, "vxe-grid/scroll-x": { "type": "any", - "description": "横向虚拟滚动配置(注:当 tree-config 启用后自动关闭该功能)" + "description": "横向虚拟滚动配置(不支持深层结构和展开行)" }, "vxe-grid/scroll-y": { "type": "any", - "description": "纵向虚拟滚动配置(注:当 tree-config 启用后自动关闭该功能)" + "description": "纵向虚拟滚动配置(不支持深层结构和展开行)" }, "vxe-grid/params": { "type": "any", - "description": "额外的参数(可以用来存放一些私有参数)" + "description": "自定义参数(可以用来存放一些自定义的数据)" }, "vxe-grid/form-config": { "type": "any", @@ -895,7 +915,7 @@ "type": "string", "description": "自定义跳页显示图标" }, - "vxe-radio/v-model": { + "vxe-radio/v-model / value": { "type": "any", "description": "绑定值" }, @@ -919,14 +939,22 @@ "type": "string", "description": "原生 name 属性" }, - "vxe-radio-group/label": { - "type": "string | number", + "vxe-radio-group/v-model / value": { + "type": "any[]", "description": "绑定值" }, + "vxe-radio-group/size": { + "type": "string", + "description": "尺寸" + }, "vxe-radio-group/disabled": { "type": "boolean", "description": "是否禁用" }, + "vxe-radio-button/v-model / value": { + "type": "any", + "description": "绑定值" + }, "vxe-radio-button/label": { "type": "string | number", "description": "绑定值" @@ -939,7 +967,7 @@ "type": "boolean", "description": "是否禁用" }, - "vxe-checkbox/v-model": { + "vxe-checkbox/v-model / value": { "type": "any", "description": "绑定值" }, @@ -967,15 +995,19 @@ "type": "boolean", "description": "是否不确定状态" }, - "vxe-checkbox-group/label": { + "vxe-checkbox-group/v-model / value": { "type": "any[]", "description": "绑定值" }, + "vxe-checkbox-group/size": { + "type": "string", + "description": "尺寸" + }, "vxe-checkbox-group/disabled": { "type": "boolean", "description": "是否禁用" }, - "vxe-switch/v-model": { + "vxe-switch/v-model / value": { "type": "string | number | boolean", "description": "绑定值" }, @@ -1011,7 +1043,7 @@ "type": "string", "description": "关闭时的图标" }, - "vxe-input/v-model": { + "vxe-input/v-model / value": { "type": "any", "description": "绑定值" }, @@ -1127,7 +1159,7 @@ "type": "boolean", "description": "只对 type=date|time|datetime|week|month|year 有效,是否将弹框容器插入于 body 内(对于嵌入到表格或者弹窗中被遮挡时需要设置为 true)" }, - "vxe-select/v-model": { + "vxe-select/v-model / value": { "type": "any", "description": "绑定值" }, @@ -1291,7 +1323,7 @@ "type": "string", "description": "主题样式" }, - "vxe-tooltip/zindex": { + "vxe-tooltip/z-index": { "type": "number", "description": "自定义堆叠顺序(对于某些特殊场景,比如被遮挡时可能会用到)" }, @@ -1307,7 +1339,7 @@ "type": "number", "description": "鼠标移出后延时多少才隐藏 tooltip" }, - "vxe-modal/v-model": { + "vxe-modal/v-model / value": { "type": "any", "description": "绑定值" }, @@ -1385,11 +1417,11 @@ }, "vxe-modal/show-zoom": { "type": "boolean", - "description": "是否允许窗口最大化与还原" + "description": "标题是否标显示最大化与还原按钮" }, "vxe-modal/resize": { "type": "boolean", - "description": "是否允许拖动调整窗口大小" + "description": "是否允许窗口边缘拖动调整窗口大小" }, "vxe-modal/duration": { "type": "number | string", @@ -1419,7 +1451,7 @@ "type": "any", "description": "只对 type=modal 有效,窗口的默认位置,可以设置为 center 居中显示" }, - "vxe-modal/zindex": { + "vxe-modal/z-index": { "type": "number", "description": "自定义堆叠顺序(对于某些特殊场景,比如被遮挡时可能会用到)" }, @@ -1531,9 +1563,13 @@ "type": "string | number", "description": "标题宽度" }, + "vxe-form-item/class-name": { + "type": "string", + "description": "给表单项附加 className" + }, "vxe-form-item/visible": { "type": "boolean", - "description": "是否可视" + "description": "默认是否显示" }, "vxe-form-item/visible-method": { "type": "function", diff --git a/helper/vetur/tags.json b/helper/vetur/tags.json index 31f879b25..46dd64231 100644 --- a/helper/vetur/tags.json +++ b/helper/vetur/tags.json @@ -48,6 +48,7 @@ "row-id", "keep-source", "column-config", + "resizable-config", "seq-config", "sort-config", "filter-config", @@ -63,6 +64,7 @@ "clip-config", "fnr-config", "mouse-config", + "area-config", "keyboard-config", "edit-config", "valid-config", @@ -119,6 +121,7 @@ "seq-method", "sortable", "sort-by", + "sort-type", "filters", "filter-multiple", "filter-method", @@ -186,6 +189,7 @@ "row-id", "keep-source", "column-config", + "resizable-config", "seq-config", "sort-config", "filter-config", @@ -201,6 +205,7 @@ "clip-config", "fnr-config", "mouse-config", + "area-config", "keyboard-config", "edit-config", "valid-config", @@ -258,7 +263,7 @@ }, "vxe-radio": { "attributes": [ - "v-model", + "v-model / value", "label", "content", "size", @@ -269,13 +274,15 @@ }, "vxe-radio-group": { "attributes": [ - "label", + "v-model / value", + "size", "disabled" ], "description": "单选组" }, "vxe-radio-button": { "attributes": [ + "v-model / value", "label", "content", "disabled" @@ -284,7 +291,7 @@ }, "vxe-checkbox": { "attributes": [ - "v-model", + "v-model / value", "label", "content", "size", @@ -296,14 +303,15 @@ }, "vxe-checkbox-group": { "attributes": [ - "label", + "v-model / value", + "size", "disabled" ], "description": "复选组" }, "vxe-switch": { "attributes": [ - "v-model", + "v-model / value", "disabled", "size", "open-label", @@ -317,7 +325,7 @@ }, "vxe-input": { "attributes": [ - "v-model", + "v-model / value", "size", "type", "name", @@ -351,7 +359,7 @@ }, "vxe-select": { "attributes": [ - "v-model", + "v-model / value", "size", "multiple", "multi-char-overflow", @@ -419,7 +427,7 @@ "content", "trigger", "theme", - "zindex", + "z-index", "is-arrow", "enterable", "leave-delay" @@ -428,7 +436,7 @@ }, "vxe-modal": { "attributes": [ - "v-model", + "v-model / value", "size", "loading", "id", @@ -456,7 +464,7 @@ "min-height", "top", "position", - "zindex", + "z-index", "show-title-overflow", "transfer", "fullscreen", @@ -497,6 +505,7 @@ "align", "title-align", "title-width", + "class-name", "visible", "visible-method", "folding", diff --git a/packages/button/src/button.ts b/packages/button/src/button.ts index be25a2835..797f6b2bc 100644 --- a/packages/button/src/button.ts +++ b/packages/button/src/button.ts @@ -203,10 +203,12 @@ export default defineComponent({ const panelElem = refBtnPanel.value const { flag, targetElem } = DomTools.getEventTargetNode(evnt, dropdownElem, 'vxe-button') if (flag) { - panelElem.dataset.active = 'N' + if (panelElem) { + panelElem.dataset.active = 'N' + } reactData.showPanel = false setTimeout(() => { - if (panelElem.dataset.active !== 'Y') { + if (!panelElem || panelElem.dataset.active !== 'Y') { reactData.animatVisible = false } }, 350) diff --git a/packages/conf/index.ts b/packages/conf/index.ts index fd2d6604f..9417ebf44 100644 --- a/packages/conf/index.ts +++ b/packages/conf/index.ts @@ -89,6 +89,9 @@ export const GlobalConfig: VXETableGlobalConfig = { mouseConfig: { extension: true }, + areaConfig: { + selectCellByHeader: true + }, clipConfig: { isCopy: true, isCut: true, diff --git a/packages/table/src/props.ts b/packages/table/src/props.ts index c33137169..586e214a0 100644 --- a/packages/table/src/props.ts +++ b/packages/table/src/props.ts @@ -128,6 +128,8 @@ export default { menuConfig: Object as PropType, // 鼠标配置项 mouseConfig: Object as PropType, + // 区域配置项 + areaConfig: Object as PropType, // 按键配置项 keyboardConfig: Object as PropType, // 复制粘/贴配置项 diff --git a/packages/table/src/table.ts b/packages/table/src/table.ts index cf5644d10..0e2714c75 100644 --- a/packages/table/src/table.ts +++ b/packages/table/src/table.ts @@ -388,6 +388,10 @@ export default defineComponent({ return Object.assign({}, GlobalConfig.table.mouseConfig, props.mouseConfig) as VxeTablePropTypes.MouseOpts }) + const computeAreaOpts = computed(() => { + return Object.assign({}, GlobalConfig.table.areaConfig, props.areaConfig) as VxeTablePropTypes.AreaOpts + }) + const computeKeyboardOpts = computed(() => { return Object.assign({}, GlobalConfig.table.keyboardConfig, props.keyboardConfig) as VxeTablePropTypes.KeyboardOpts }) @@ -538,6 +542,7 @@ export default defineComponent({ computeSortOpts, computeFilterOpts, computeMouseOpts, + computeAreaOpts, computeKeyboardOpts, computeClipOpts, computeFNROpts, diff --git a/types/table.d.ts b/types/table.d.ts index 6ec4270e3..97f7718e6 100644 --- a/types/table.d.ts +++ b/types/table.d.ts @@ -61,6 +61,7 @@ export interface TablePrivateComputed { computeSortOpts: ComputedRef; computeFilterOpts: ComputedRef; computeMouseOpts: ComputedRef; + computeAreaOpts: ComputedRef; computeKeyboardOpts: ComputedRef; computeClipOpts: ComputedRef; computeFNROpts: ComputedRef; @@ -1371,6 +1372,14 @@ export namespace VxeTablePropTypes { } export interface MouseOpts extends MouseConfig { } + /** + * 区域配置项 + */ + export interface AreaConfig { + selectCellByHeader?: boolean; + } + export interface AreaOpts extends AreaConfig { } + /** * 按键配置项 */ @@ -1451,22 +1460,48 @@ export namespace VxeTablePropTypes { isCopy?: boolean; isCut?: boolean; isPaste?: boolean; - getMethod?(params: { + copyMethod?(params: { + isCut: boolean; row: any; column: VxeTableDefines.ColumnInfo; + cellValue: any; }): string; - beforeGetMethod?(params: { + beforeCopyMethod?(params: { targetAreas: any[]; + $table: VxeTableConstructor & VxeTablePrivateMethods; }): boolean; - setMethod?(params: { + cutMethod?: (params: { + row: any, + column: VxeTableDefines.ColumnInfo; + cellValue: any; + }) => void; + beforeCutMethod?: (params: { + cutAreas: { + rows: any[]; + cols: VxeTableDefines.ColumnInfo[] + }[]; + currentAreas: { + rows: any[]; + cols: VxeTableDefines.ColumnInfo[] + }[]; + $table: VxeTableConstructor & VxeTablePrivateMethods; + }) => boolean; + pasteMethod?(params: { row: any, column: VxeTableDefines.ColumnInfo; cellValue: any; }): void; - beforeSetMethod?(params: { - currentAreas: any[]; - targetAreas: any[]; - cellValues: any[][]; + beforePasteMethod?(params: { + currentAreas: { + rows: any[]; + cols: VxeTableDefines.ColumnInfo[] + }[]; + targetAreas: { + rows: any[]; + cols: VxeTableDefines.ColumnInfo[] + }[]; + cellValues: string[][]; + $table: VxeTableConstructor & VxeTablePrivateMethods; }): boolean; } export interface ClipOpts extends ClipConfig { } @@ -1476,7 +1511,29 @@ export namespace VxeTablePropTypes { */ export interface FNRConfig { isFind?: boolean; + findMethod?(params: { + cellValue: any; + isWhole: boolean; + isRE: boolean; + isSensitive: boolean; + findValue: string | null; + findRE: RegExp | null; + }): boolean; + beforeFindMethod?(params: { + findValue: string | null; + $table: VxeTableConstructor & VxeTablePrivateMethods; + }): boolean; isReplace?: boolean; + replaceMethod?: (params: { + row: any; + column: VxeTableDefines.ColumnInfo; + cellValue: any; + }) => void; + beforeReplaceMethod?: (params: { + findValue: string | null; + replaceValue: string; + $table: VxeTableConstructor & VxeTablePrivateMethods; + }) => boolean; } export interface FNROpts extends FNRConfig { } @@ -1617,6 +1674,7 @@ export interface VxeTableProps { treeConfig?: VxeTablePropTypes.TreeConfig; menuConfig?: VxeTablePropTypes.MenuConfig; mouseConfig?: VxeTablePropTypes.MouseConfig; + areaConfig?: VxeTablePropTypes.AreaConfig; fnrConfig?: VxeTablePropTypes.FNRConfig; keyboardConfig?: VxeTablePropTypes.KeyboardConfig; clipConfig?: VxeTablePropTypes.ClipConfig; diff --git a/types/v-x-e-table/index.d.ts b/types/v-x-e-table/index.d.ts index 3abf875fb..c2819b70e 100644 --- a/types/v-x-e-table/index.d.ts +++ b/types/v-x-e-table/index.d.ts @@ -11,6 +11,8 @@ import { Menus } from './menus' import { VxeGlobalHooks } from './hooks' import { VXETableSetupOptions, VxeGlobalSetup } from './setup' +type translate = (key: string, args?: any) => number | string; + export class VXETableInstance { /** * 版本号 @@ -27,7 +29,7 @@ export class VXETableInstance { /** * 读取内置国际化 */ - public t(key: string, args?: any): string; + public t: translate; /** * 设置全局参数/获取所有参数 */ @@ -97,7 +99,7 @@ export interface VXETableByVueProperty { /** * 读取内置国际化 */ - t(key: string, args?: any): string; + t: translate; /** * 全局的模态窗口 */