diff --git a/packages/table/editor.vue b/packages/table/editor.vue index 5db97db..f3c0171 100644 --- a/packages/table/editor.vue +++ b/packages/table/editor.vue @@ -99,6 +99,12 @@ function editorRender(h, context, item) { const contentProps = context.props || {}; return function(scope) { const value = get(scope.row, item.prop); + if (item.if && typeof item.if === 'function') { + const showEditor = item.if({ item, value, index: scope.$index, ...scope }); + if (!showEditor) { + return cellRender(h, context, item)(scope); + } + } let vnode = {}; // 默认 const setValue = val => { @@ -138,12 +144,19 @@ function editorRender(h, context, item) { } }; // 编辑表单项配置 - const itemProps = item.props || {}; + let itemProps = item.props || {}; + if (typeof item.props === 'function') { + itemProps = item.props({ item, value, index: scope.$index, ...scope, onInput: inputEvent }); + } + let itemAttrs = item.attrs || {}; + if (typeof item.attrs === 'function') { + itemAttrs = item.attrs({ item, value, index: scope.$index, ...scope, onInput: inputEvent }); + } // 编辑器统一配置 const editorProps = get(contentProps, 'editor') || {}; // 生成虚拟节点 vnode = h(item.is, { - attrs: item.attrs, + attrs: itemAttrs, props: { ...editorProps, ...itemProps, value }, on: { input: inputEvent, blur: blurEvent }, }); -- libgit2 0.21.0