UNPKG

vhb-table

Version:

一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、贼灵活的配置项、扩展接口等...

96 lines (94 loc) 2.58 kB
import { getFuncText } from '../../tools/utils' import GlobalConfig from '../../v-h-b-table/src/conf' import vSize from '../../mixins/size' export default { name: 'VhbRadio', mixins: [vSize], props: { value: [String, Number, Boolean], label: [String, Number, Boolean], title: [String, Number], content: [String, Number], disabled: Boolean, name: String, strict: { type: Boolean, default: () => GlobalConfig.radio.strict }, size: { type: String, default: () => GlobalConfig.radio.size || GlobalConfig.size } }, inject: { $xeradiogroup: { default: null } }, computed: { isDisabled () { const { $xeradiogroup } = this return this.disabled || ($xeradiogroup && $xeradiogroup.disabled) }, isStrict () { const { $xeradiogroup } = this return $xeradiogroup ? $xeradiogroup.strict : this.strict } }, render (h) { const { $scopedSlots, $xeradiogroup, isDisabled, title, vSize, value, label, name, content } = this const attrs = {} if (title) { attrs.title = title } return h('label', { class: ['vhb-radio', { [`size--${vSize}`]: vSize, 'is--disabled': isDisabled }], attrs }, [ h('input', { class: 'vhb-radio--input', attrs: { type: 'radio', name: $xeradiogroup ? $xeradiogroup.name : name, disabled: isDisabled }, domProps: { checked: $xeradiogroup ? $xeradiogroup.value === label : value === label }, on: { change: this.changeEvent, click: this.clickEvent } }), h('span', { class: 'vhb-radio--icon' }), h('span', { class: 'vhb-radio--label' }, $scopedSlots.default ? $scopedSlots.default.call(this, {}) : [getFuncText(content)]) ]) }, methods: { handleValue (label, evnt) { const { $xeradiogroup } = this const params = { label, $event: evnt } if ($xeradiogroup) { $xeradiogroup.handleChecked(params) } else { this.$emit('input', label) this.$emit('change', params) } }, changeEvent (evnt) { const { isDisabled } = this if (!isDisabled) { this.handleValue(this.label, evnt) } }, clickEvent (evnt) { const { $xeradiogroup, isDisabled, isStrict } = this if (!isDisabled && !isStrict) { if (this.label === ($xeradiogroup ? $xeradiogroup.value : this.value)) { this.handleValue(null, evnt) } } } } }