Skip to content

Commit

Permalink
增加参数 showClose、增加插槽 prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Apr 24, 2021
1 parent 393e07b commit 4bd10ee
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 36 deletions.
21 changes: 20 additions & 1 deletion examples/api/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 9 additions & 0 deletions examples/api/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 11 additions & 1 deletion examples/api/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,17 @@ const apis = [
type: '',
enum: '',
defVal: '',
list: []
list: [
{
name: 'prefix',
desc: '前缀图标模板',
version: '4.0.14',
type: '',
enum: '',
defVal: '',
list: []
}
]
},
{
name: 'Events',
Expand Down
2 changes: 1 addition & 1 deletion examples/i18n/lang/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion examples/i18n/lang/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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+,支持所有主流的浏览器,实现表格的一切实用的功能',
Expand Down
2 changes: 1 addition & 1 deletion examples/i18n/lang/zh-TC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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+,支持所有主流的瀏覽器,實現表格的一切實用的功能',
Expand Down
8 changes: 4 additions & 4 deletions examples/views/table/edit/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table",
"version": "4.0.13",
"version": "4.0.14",
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟滚动、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、虚拟列表、模态窗口、自定义模板、渲染器、贼灵活的配置项、扩展接口等...",
"scripts": {
"serve": "vue-cli-service serve",
Expand Down Expand Up @@ -78,16 +78,16 @@
"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",
"vxe-table-plugin-renderer": "^3.0.1",
"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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/form/src/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 6 additions & 4 deletions packages/input/src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
19 changes: 11 additions & 8 deletions packages/modal/src/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default defineComponent({
showHeader: { type: Boolean as PropType<VxeModalPropTypes.ShowHeader>, default: () => GlobalConfig.modal.showHeader },
showFooter: { type: Boolean as PropType<VxeModalPropTypes.ShowFooter>, default: () => GlobalConfig.modal.showFooter },
showZoom: Boolean as PropType<VxeModalPropTypes.ShowZoom>,
showClose: { type: Boolean as PropType<VxeModalPropTypes.ShowClose>, default: () => GlobalConfig.modal.showClose },
dblclickZoom: { type: Boolean as PropType<VxeModalPropTypes.DblclickZoom>, default: () => GlobalConfig.modal.dblclickZoom },
width: [Number, String] as PropType<VxeModalPropTypes.Width>,
height: [Number, String] as PropType<VxeModalPropTypes.Height>,
Expand Down Expand Up @@ -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[] : [
Expand All @@ -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
}

Expand Down
5 changes: 4 additions & 1 deletion packages/select/src/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) : '', {
Expand Down Expand Up @@ -761,7 +762,9 @@ export default defineComponent({
onFocus: focusEvent,
onBlur: blurEvent,
onSuffixClick: togglePanelEvent
}),
}, prefixSlot ? {
prefix: () => prefixSlot({})
} : {}),
h(Teleport, {
to: 'body',
disabled: transfer ? !inited : true
Expand Down
6 changes: 3 additions & 3 deletions packages/table/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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])
Expand Down
1 change: 1 addition & 0 deletions packages/v-x-e-table/src/conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ const GlobalConfig: VXETableGlobalConfig = {
dblclickZoom: true,
showTitleOverflow: true,
animat: true,
showClose: true,
// storage: false,
storageKey: 'VXE_MODAL_POSITION'
},
Expand Down
2 changes: 1 addition & 1 deletion packages/validator/src/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 10 additions & 4 deletions public/issues.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,27 @@
<div>1.将代码示例放到以下任意一个在线链接中,运行起来(点击 fork,确保能复现问题,最后点击保存,将链接发群里即可)</div>
<div style="color:red">(注:提供可复现问题简化demo即可,不需要提供其他无关的代码)</div>
<ul>
<li>
<a href="https://codesandbox.io/s/vxe-table-wentiyanshi-forked-54v2j" target="_blank">v4 codesandbox(支持jsx)</a>
</li>
<li>
<a href="https://jsrun.net/K5IKp/edit" target="_blank">v4 jsrun</a>
</li>
<li>
<a href="https://codesandbox.io/s/vxe-table-wentiyanshi-forked-54v2j" target="_blank">v4 codesandbox(支持jsx)</a>
<a href="https://jsrun.net/CT3Kp/edit" target="_blank">v4 jsrun(集成 element-plus)</a>
</li>
<li>
<a href="https://jsrun.net/nT3Kp/edit" target="_blank">v4 jsrun(集成 ant-design-vue)</a>
</li>
<li>
<a href="https://jsfiddle.net/9qoghkbj/" target="_blank">v4 jsfiddle</a>
</li>
</ul>

<ul>
<li>
<a href="https://codesandbox.io/s/vue-template-916h0" target="_blank">v3 codesandbox(支持jsx)</a>
</li>
<li>
<a href="https://jsrun.pro/vIyKp/edit" target="_blank">v3 jsrun</a>
</li>
Expand All @@ -51,9 +60,6 @@
<li>
<a href="https://jsrun.net/pRLKp/edit" target="_blank">v3 jsrun(集成 ant-design-vue)</a>
</li>
<li>
<a href="https://codesandbox.io/s/vue-template-916h0" target="_blank">v3 codesandbox(支持jsx)</a>
</li>
<li>
<a href="https://jsfiddle.net/qsmtja6x/" target="_blank">v3 jsfiddle</a>
</li>
Expand Down
2 changes: 2 additions & 0 deletions types/modal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down

0 comments on commit 4bd10ee

Please sign in to comment.