From 4bd10ee8b051bc361bc56b46c876ed875628605d Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Sat, 24 Apr 2021 11:38:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0=20showClos?= =?UTF-8?q?e=E3=80=81=E5=A2=9E=E5=8A=A0=E6=8F=92=E6=A7=BD=20prefix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/api/input.ts | 21 ++++++++++++++++++++- examples/api/modal.ts | 9 +++++++++ examples/api/select.ts | 12 +++++++++++- examples/i18n/lang/en-US.ts | 2 +- examples/i18n/lang/zh-CN.ts | 2 +- examples/i18n/lang/zh-TC.ts | 2 +- examples/views/table/edit/Status.vue | 8 ++++---- package.json | 8 ++++---- packages/form/src/form.ts | 2 +- packages/input/src/input.ts | 10 ++++++---- packages/modal/src/modal.ts | 19 +++++++++++-------- packages/select/src/select.ts | 5 ++++- packages/table/src/table.ts | 6 +++--- packages/v-x-e-table/src/conf.ts | 1 + packages/validator/src/hook.ts | 2 +- public/issues.html | 14 ++++++++++---- types/modal.d.ts | 2 ++ vue.config.js | 2 +- 18 files changed, 91 insertions(+), 36 deletions(-) diff --git a/examples/api/input.ts b/examples/api/input.ts index 5488f4ea3..4e6821cb6 100644 --- a/examples/api/input.ts +++ b/examples/api/input.ts @@ -288,7 +288,26 @@ const apis = [ type: '', enum: '', defVal: '', - list: [] + list: [ + { + name: 'prefix', + desc: '前缀图标模板', + version: '', + type: '', + enum: '', + defVal: '', + list: [] + }, + { + name: 'suffix', + desc: '后缀图标模板', + version: '', + type: '', + enum: '', + defVal: '', + list: [] + } + ] }, { name: 'Events', diff --git a/examples/api/modal.ts b/examples/api/modal.ts index f72cc7c54..40a16a2f8 100644 --- a/examples/api/modal.ts +++ b/examples/api/modal.ts @@ -197,6 +197,15 @@ const apis = [ defVal: 'false', list: [] }, + { + name: 'show-close', + desc: '是否显示关闭按钮', + version: '4.0.14', + type: 'Boolean', + enum: '', + defVal: 'true', + list: [] + }, { name: 'resize', descKey: 'app.api.modal.desc.resize', diff --git a/examples/api/select.ts b/examples/api/select.ts index 07a8dbe54..67e1a8a4c 100644 --- a/examples/api/select.ts +++ b/examples/api/select.ts @@ -178,7 +178,17 @@ const apis = [ type: '', enum: '', defVal: '', - list: [] + list: [ + { + name: 'prefix', + desc: '前缀图标模板', + version: '4.0.14', + type: '', + enum: '', + defVal: '', + list: [] + } + ] }, { name: 'Events', diff --git a/examples/i18n/lang/en-US.ts b/examples/i18n/lang/en-US.ts index a472fc56d..f0375d055 100644 --- a/examples/i18n/lang/en-US.ts +++ b/examples/i18n/lang/en-US.ts @@ -320,7 +320,7 @@ export default { v2: '2.0+ (vue 2.6+ Old) ~ 2021-12 Stop', v3: '3.0+ (vue 2.6+ Stable)', v3d5: '3.5+ (vue 2.6+ Sticky)', - v4: '4.0+ (vue 3.0+ next)', + v4: '4.0+ (vue 3.0+ Latest)', v4d5: '4.5+ (vue 3.0+ Sticky)', plan: { v1: 'v1 Based on vue2.6+, Support for all major browsers', diff --git a/examples/i18n/lang/zh-CN.ts b/examples/i18n/lang/zh-CN.ts index 75ddec4a8..245269ac8 100644 --- a/examples/i18n/lang/zh-CN.ts +++ b/examples/i18n/lang/zh-CN.ts @@ -319,7 +319,7 @@ export default { v2: '2.0+ (vue 2.6+ 旧版本) ~ 2021-12 停止更新', v3: '3.0+ (vue 2.6+ 稳定版)', v3d5: '3.5+ (vue 2.6+ 粘性表格)', - v4: '4.0+ (vue 3.0+ next)', + v4: '4.0+ (vue 3.0+ 最新版)', v4d5: '4.5+ (vue 3.0+ 粘性表格)', plan: { v1: 'v1 基于 vue2.6+,支持所有主流的浏览器,实现表格的一切实用的功能', diff --git a/examples/i18n/lang/zh-TC.ts b/examples/i18n/lang/zh-TC.ts index 4126a9953..d308c5799 100644 --- a/examples/i18n/lang/zh-TC.ts +++ b/examples/i18n/lang/zh-TC.ts @@ -319,7 +319,7 @@ export default { v2: '2.0+ (vue 2.6+ 旧版本) ~ 2021-12 停止更新', v3: '3.0+ (vue 2.6+ 稳定版)', v3d5: '3.5+ (vue 2.6+ 粘性表格)', - v4: '4.0+ (vue 3.0+ next)', + v4: '4.0+ (vue 3.0+ 最新版)', v4d5: '4.5+ (vue 3.0+ 粘性表格)', plan: { v1: 'v1 基於 vue2.6+,支持所有主流的瀏覽器,實現表格的一切實用的功能', diff --git a/examples/views/table/edit/Status.vue b/examples/views/table/edit/Status.vue index 89fd2b9c9..e8e740f30 100644 --- a/examples/views/table/edit/Status.vue +++ b/examples/views/table/edit/Status.vue @@ -120,13 +120,13 @@ export default defineComponent({ } } - const saveEvent2 = async (row: any, field?: string) => { + const saveEvent2 = async (row: any) => { const $table = xTable.value if ($table.isUpdateByRow(row)) { row.loading = true const data = await submitSave(row) // 局部保存,并更新本地数据 - await $table.reloadRow(row, data, field) + await $table.reloadRow(row, data) VXETable.modal.message({ content: '保存成功!', status: 'success' }) row.loading = false } else { @@ -268,13 +268,13 @@ export default defineComponent({ } } - const saveEvent2 = async (row: any, field?: string) => { + const saveEvent2 = async (row: any) => { const $table = xTable.value if ($table.isUpdateByRow(row)) { row.loading = true const data = await submitSave(row) // 局部保存,并更新本地数据 - await $table.reloadRow(row, data, field) + await $table.reloadRow(row, data) VXETable.modal.message({ content: '保存成功!', status: 'success' }) row.loading = false } else { diff --git a/package.json b/package.json index 6c1a73d54..172bfc206 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vxe-table", - "version": "4.0.13", + "version": "4.0.14", "description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟滚动、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、虚拟列表、模态窗口、自定义模板、渲染器、贼灵活的配置项、扩展接口等...", "scripts": { "serve": "vue-cli-service serve", @@ -78,8 +78,8 @@ "vue-i18n": "^9.0.0", "vue-router": "^4.0.4", "vuex": "^4.0.0", - "vxe-table-plugin-antd": "^3.0.2", - "vxe-table-plugin-element": "^3.0.2", + "vxe-table-plugin-antd": "^3.0.3", + "vxe-table-plugin-element": "^3.0.3", "vxe-table-plugin-export-pdf": "^3.0.2", "vxe-table-plugin-export-xlsx": "^3.0.2", "vxe-table-plugin-menus": "^3.0.1", @@ -87,7 +87,7 @@ "vxe-table-plugin-shortcut-key": "^3.0.1", "xe-ajax": "^4.0.5", "xe-clipboard": "^1.10.1", - "xe-utils": "^3.1.14", + "xe-utils": "^3.2.0", "xlsx": "^0.16.9" }, "peerDependencies": { diff --git a/packages/form/src/form.ts b/packages/form/src/form.ts index f21adfdfa..b9c50fe05 100644 --- a/packages/form/src/form.ts +++ b/packages/form/src/form.ts @@ -48,7 +48,7 @@ const validErrorRuleValue = (rule: VxeFormDefines.FormRule, val: any) => { } // 如果存在 pattern,正则校验 if (pattern) { - return (XEUtils.isRegExp(pattern) ? pattern : new RegExp(pattern)).test(val) + return !(XEUtils.isRegExp(pattern) ? pattern : new RegExp(pattern)).test(val) } return false } diff --git a/packages/input/src/input.ts b/packages/input/src/input.ts index 193fb5af8..83a7363f7 100644 --- a/packages/input/src/input.ts +++ b/packages/input/src/input.ts @@ -1896,12 +1896,13 @@ export default defineComponent({ const rendePrefixIcon = () => { const { prefixIcon } = props + const prefixSlot = slots.prefix const icons = [] - if (slots.prefix) { + if (prefixSlot) { icons.push( h('span', { class: 'vxe-input--prefix-icon' - }, slots.prefix({})) + }, prefixSlot({})) ) } else if (prefixIcon) { icons.push( @@ -1919,13 +1920,14 @@ export default defineComponent({ const renderSuffixIcon = () => { const { disabled, suffixIcon } = props const { inputValue } = reactData + const suffixSlot = slots.suffix const isClearable = computeIsClearable.value const icons = [] - if (slots.suffix) { + if (suffixSlot) { icons.push( h('span', { class: 'vxe-input--suffix-icon' - }, slots.suffix({})) + }, suffixSlot({})) ) } else if (suffixIcon) { icons.push( diff --git a/packages/modal/src/modal.ts b/packages/modal/src/modal.ts index 3df835373..b81de94f3 100644 --- a/packages/modal/src/modal.ts +++ b/packages/modal/src/modal.ts @@ -39,6 +39,7 @@ export default defineComponent({ showHeader: { type: Boolean as PropType, default: () => GlobalConfig.modal.showHeader }, showFooter: { type: Boolean as PropType, default: () => GlobalConfig.modal.showFooter }, showZoom: Boolean as PropType, + showClose: { type: Boolean as PropType, default: () => GlobalConfig.modal.showClose }, dblclickZoom: { type: Boolean as PropType, default: () => GlobalConfig.modal.dblclickZoom }, width: [Number, String] as PropType, height: [Number, String] as PropType, @@ -669,7 +670,7 @@ export default defineComponent({ } const renderTitles = () => { - const { slots: propSlots = {}, showZoom, title } = props + const { slots: propSlots = {}, showClose, showZoom, title } = props const { zoomLocat } = reactData const titleSlot = slots.title || propSlots.title const titVNs: VNode[] = titleSlot ? titleSlot({ $modal: $xemodal }) as VNode[] : [ @@ -686,13 +687,15 @@ export default defineComponent({ }) ) } - titVNs.push( - h('i', { - class: ['vxe-modal--close-btn', 'trigger--btn', GlobalConfig.icon.MODAL_CLOSE], - title: GlobalConfig.i18n('vxe.modal.close'), - onClick: closeEvent - }) - ) + if (showClose) { + titVNs.push( + h('i', { + class: ['vxe-modal--close-btn', 'trigger--btn', GlobalConfig.icon.MODAL_CLOSE], + title: GlobalConfig.i18n('vxe.modal.close'), + onClick: closeEvent + }) + ) + } return titVNs } diff --git a/packages/select/src/select.ts b/packages/select/src/select.ts index 026121ebe..db6fb7a58 100644 --- a/packages/select/src/select.ts +++ b/packages/select/src/select.ts @@ -733,6 +733,7 @@ export default defineComponent({ const { inited, isActivated, visiblePanel } = reactData const vSize = computeSize.value const selectLabel = computeSelectLabel.value + const prefixSlot = slots.prefix return h('div', { ref: refElem, class: ['vxe-select', className ? (XEUtils.isFunction(className) ? className({ $select: $xeselect }) : className) : '', { @@ -761,7 +762,9 @@ export default defineComponent({ onFocus: focusEvent, onBlur: blurEvent, onSuffixClick: togglePanelEvent - }), + }, prefixSlot ? { + prefix: () => prefixSlot({}) + } : {}), h(Teleport, { to: 'body', disabled: transfer ? !inited : true diff --git a/packages/table/src/table.ts b/packages/table/src/table.ts index b1a1e7873..a3808afe9 100644 --- a/packages/table/src/table.ts +++ b/packages/table/src/table.ts @@ -732,7 +732,7 @@ export default defineComponent({ rowspan = XEUtils.toNumber(rowspan) || 1 colspan = XEUtils.toNumber(colspan) || 1 if (rowspan > 1 || colspan > 1) { - const mcIndex = XEUtils.findIndexOf(mList, item => item._row === row && item._col === col) + const mcIndex = XEUtils.findIndexOf(mList, item => (item._row === row || getRowid($xetable, item._row) === getRowid($xetable, row)) && (item._col.id === col || item._col.id === col.id)) const mergeItem = mList[mcIndex] if (mergeItem) { mergeItem.rowspan = rowspan @@ -741,7 +741,7 @@ export default defineComponent({ mergeItem._colspan = colspan } else { const mergeRowIndex = rowList ? $xetable.findRowIndexOf(rowList, row) : row - const mergeColIndex = visibleColumn.indexOf(col) + const mergeColIndex = tableMethods.getVTColumnIndex(col) mList.push({ row: mergeRowIndex, col: mergeColIndex, @@ -778,7 +778,7 @@ export default defineComponent({ if (XEUtils.isNumber(col)) { col = visibleColumn[col] } - const mcIndex = XEUtils.findIndexOf(mList, item => item._row === row && item._col === col) + const mcIndex = XEUtils.findIndexOf(mList, item => (item._row === row || getRowid($xetable, item._row) === getRowid($xetable, row)) && (item._col.id === col || item._col.id === col.id)) if (mcIndex > -1) { const rItems = mList.splice(mcIndex, 1) rest.push(rItems[0]) diff --git a/packages/v-x-e-table/src/conf.ts b/packages/v-x-e-table/src/conf.ts index 3f725a391..9964a8f14 100644 --- a/packages/v-x-e-table/src/conf.ts +++ b/packages/v-x-e-table/src/conf.ts @@ -308,6 +308,7 @@ const GlobalConfig: VXETableGlobalConfig = { dblclickZoom: true, showTitleOverflow: true, animat: true, + showClose: true, // storage: false, storageKey: 'VXE_MODAL_POSITION' }, diff --git a/packages/validator/src/hook.ts b/packages/validator/src/hook.ts index ea3232396..b58584190 100644 --- a/packages/validator/src/hook.ts +++ b/packages/validator/src/hook.ts @@ -243,7 +243,7 @@ const validatorHook: VxeGlobalHooksHandles.HookOptions = { } // 如果存在 pattern,正则校验 if (pattern) { - return (XEUtils.isRegExp(pattern) ? pattern : new RegExp(pattern)).test(val) + return !(XEUtils.isRegExp(pattern) ? pattern : new RegExp(pattern)).test(val) } return false } diff --git a/public/issues.html b/public/issues.html index 0a87e96ba..b4c7b2303 100644 --- a/public/issues.html +++ b/public/issues.html @@ -27,11 +27,17 @@
1.将代码示例放到以下任意一个在线链接中,运行起来(点击 fork,确保能复现问题,最后点击保存,将链接发群里即可)
(注:提供可复现问题简化demo即可,不需要提供其他无关的代码)
    +
  • + v3 codesandbox(支持jsx) +
  • v3 jsrun
  • @@ -51,9 +60,6 @@
  • v3 jsrun(集成 ant-design-vue)
  • -
  • - v3 codesandbox(支持jsx) -
  • v3 jsfiddle
  • diff --git a/types/modal.d.ts b/types/modal.d.ts index 180564140..95be3bd3c 100644 --- a/types/modal.d.ts +++ b/types/modal.d.ts @@ -133,6 +133,7 @@ export namespace VxeModalPropTypes { export type ShowHeader = boolean; export type ShowFooter = boolean; export type ShowZoom = boolean; + export type ShowClose = boolean; export type DblclickZoom = boolean; export type Width = number | string; export type Height = number | string; @@ -182,6 +183,7 @@ export type VxeModalProps = { showHeader?: VxeModalPropTypes.ShowHeader; showFooter?: VxeModalPropTypes.ShowFooter; showZoom?: VxeModalPropTypes.ShowZoom; + showClose?: VxeModalPropTypes.ShowClose; dblclickZoom?: VxeModalPropTypes.DblclickZoom; width?: VxeModalPropTypes.Width; height?: VxeModalPropTypes.Height; diff --git a/vue.config.js b/vue.config.js index c717e08e0..450bb6943 100644 --- a/vue.config.js +++ b/vue.config.js @@ -16,7 +16,7 @@ module.exports = { entry: 'examples/main.ts', template: 'public/index.html', filename: 'index.html', - title: 'vxe-table 4.0+ (Next)' + title: 'vxe-table 4.0+ (Latest)' } }, transpileDependencies: ['highlight.js'],