vhb-table
Version:
一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、贼灵活的配置项、扩展接口等...
101 lines (99 loc) • 3.4 kB
JavaScript
import { getFuncText } from '../../tools/utils'
export default {
name: 'VhbTableContextMenu',
props: {
ctxMenuStore: Object,
ctxMenuOpts: Object
},
mounted () {
document.body.appendChild(this.$el)
},
beforeDestroy () {
const { $el } = this
if ($el.parentNode) {
$el.parentNode.removeChild($el)
}
},
render (h) {
const $xetable = this.$parent
const { _e, ctxMenuOpts, ctxMenuStore } = this
return h('div', {
class: ['vhb-table--context-menu-wrapper', ctxMenuOpts.className],
style: ctxMenuStore.style
}, ctxMenuStore.list.map((options, gIndex) => {
return options.every(item => item.visible === false) ? _e() : h('ul', {
class: 'vhb-context-menu--option-wrapper',
key: gIndex
}, options.map((item, index) => {
const hasChildMenus = item.children && item.children.some((child) => child.visible !== false)
return item.visible === false ? null : h('li', {
class: [item.className, {
'link--disabled': item.disabled,
'link--active': item === ctxMenuStore.selected
}],
key: `${gIndex}_${index}`
}, [
h('a', {
class: 'vhb-context-menu--link',
on: {
click (evnt) {
$xetable.ctxMenuLinkEvent(evnt, item)
},
mouseover (evnt) {
$xetable.ctxMenuMouseoverEvent(evnt, item)
},
mouseout (evnt) {
$xetable.ctxMenuMouseoutEvent(evnt, item)
}
}
}, [
h('i', {
class: ['vhb-context-menu--link-prefix', item.prefixIcon]
}),
h('span', {
class: 'vhb-context-menu--link-content'
}, getFuncText(item.name)),
h('i', {
class: ['vhb-context-menu--link-suffix', hasChildMenus ? item.suffixIcon || 'suffix--haschild' : item.suffixIcon]
})
]),
hasChildMenus ? h('ul', {
class: ['vhb-table--context-menu-clild-wrapper', {
'is--show': item === ctxMenuStore.selected && ctxMenuStore.showChild
}]
}, item.children.map((child, cIndex) => {
return child.visible === false ? null : h('li', {
class: [child.className, {
'link--disabled': child.disabled,
'link--active': child === ctxMenuStore.selectChild
}],
key: `${gIndex}_${index}_${cIndex}`
}, [
h('a', {
class: 'vhb-context-menu--link',
on: {
click (evnt) {
$xetable.ctxMenuLinkEvent(evnt, child)
},
mouseover (evnt) {
$xetable.ctxMenuMouseoverEvent(evnt, item, child)
},
mouseout (evnt) {
$xetable.ctxMenuMouseoutEvent(evnt, item, child)
}
}
}, [
h('i', {
class: ['vhb-context-menu--link-prefix', child.prefixIcon]
}),
h('span', {
class: 'vhb-context-menu--link-content'
}, getFuncText(child.name))
])
])
})) : null
])
}))
}))
}
}