UNPKG

iep-ui

Version:

An enterprise-class UI design language and Vue-based implementation

58 lines (51 loc) 1.49 kB
import PropTypes from '../_util/vue-types'; import classNames from 'classnames'; import { initDefaultProps, filterEmpty, getComponentFromProp, getListeners } from '../_util/props-util'; import { ConfigConsumerProps } from '../config-provider/configConsumerProps'; export default { name: 'IepTableTabs', props: { showZero: PropTypes.bool, dataOptions: PropTypes.array, defaultActive: PropTypes.any }, data: function data() { return { activeKey: this.defaultActive }; }, inject: { configProvider: { 'default': function _default() { return ConfigConsumerProps; } } }, methods: { handleClick: function handleClick(val) { if (this.activeKey === val.id) return; this.activeKey = val.id; this.$emit('changeTab', val); } }, render: function render() { var _this = this; var h = arguments[0]; var customizePrefixCls = this.prefixCls, $slots = this.$slots; var getPrefixCls = this.configProvider.getPrefixCls; var prefixCls = getPrefixCls('table-tabs', customizePrefixCls); return h( 'div', { 'class': prefixCls }, [this.$props.dataOptions.map(function (item) { return h( 'div', { 'class': prefixCls + '-item ' + (_this.activeKey === item.id ? prefixCls + '-active' : ''), on: { 'click': _this.handleClick.bind(_this, item) } }, [item.label] ); })] ); } };