Skip to content

Commit

Permalink
增加 radio、checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Feb 14, 2020
1 parent dc9da2c commit cefd3e6
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ VXETable.use(VXETablePluginAntd)

| 属性 | 描述 | 类型 | 可选值 | 默认值 |
|------|------|-----|-----|-----|
| name | 支持的渲染组件 | String | AInput, AAutocomplete, AInputNumber, ASelect, ASwitch, ARate ||
| name | 支持的渲染组件 | String | AInput, AAutocomplete, AInputNumber, ASelect, ASwitch, ARate, ARadio, ACheckbox ||
| props | 渲染组件附加属性,参数请查看被渲染的 Component props | Object || {} |
| options | 只对 name=ASelect 有效,下拉组件选项列表 | Array || [] |
| optionProps | 只对 name=ASelect 有效,下拉组件选项属性参数配置 | Object || { value: 'value', label: 'label', disabled: 'disabled' } |
Expand Down
54 changes: 47 additions & 7 deletions dist/index.common.js

Large diffs are not rendered by default.

52 changes: 46 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,40 @@
return valueMethod(params.column[renderProperty], params);
};
}

function createFormItemRadioAndCheckboxRender() {
return function (h, renderOpts, params, context) {
var name = renderOpts.name,
options = renderOpts.options,
_renderOpts$optionPro2 = renderOpts.optionProps,
optionProps = _renderOpts$optionPro2 === void 0 ? {} : _renderOpts$optionPro2;
var data = params.data,
property = params.property;
var attrs = renderOpts.attrs;
var props = getFormProps(context, renderOpts);
var labelProp = optionProps.label || 'label';
var valueProp = optionProps.value || 'value';
var disabledProp = optionProps.disabled || 'disabled';
return [h("".concat(name, "Group"), {
props: props,
attrs: attrs,
model: {
value: _xeUtils["default"].get(data, property),
callback: function callback(cellValue) {
_xeUtils["default"].set(data, property, cellValue);
}
},
on: getFormEvents(renderOpts, params, context)
}, options.map(function (option) {
return h(name, {
props: {
value: option[valueProp],
disabled: option[disabledProp]
}
}, option[labelProp]);
}))];
};
}
/**
* 渲染函数
*/
Expand Down Expand Up @@ -445,8 +479,8 @@
renderEdit: function renderEdit(h, renderOpts, params) {
var options = renderOpts.options,
optionGroups = renderOpts.optionGroups,
_renderOpts$optionPro2 = renderOpts.optionProps,
optionProps = _renderOpts$optionPro2 === void 0 ? {} : _renderOpts$optionPro2,
_renderOpts$optionPro3 = renderOpts.optionProps,
optionProps = _renderOpts$optionPro3 === void 0 ? {} : _renderOpts$optionPro3,
_renderOpts$optionGro2 = renderOpts.optionGroupProps,
optionGroupProps = _renderOpts$optionGro2 === void 0 ? {} : _renderOpts$optionGro2;
var row = params.row,
Expand Down Expand Up @@ -494,8 +528,8 @@
renderFilter: function renderFilter(h, renderOpts, params, context) {
var options = renderOpts.options,
optionGroups = renderOpts.optionGroups,
_renderOpts$optionPro3 = renderOpts.optionProps,
optionProps = _renderOpts$optionPro3 === void 0 ? {} : _renderOpts$optionPro3,
_renderOpts$optionPro4 = renderOpts.optionProps,
optionProps = _renderOpts$optionPro4 === void 0 ? {} : _renderOpts$optionPro4,
_renderOpts$optionGro3 = renderOpts.optionGroupProps,
optionGroupProps = _renderOpts$optionGro3 === void 0 ? {} : _renderOpts$optionGro3;
var column = params.column;
Expand Down Expand Up @@ -587,8 +621,8 @@
renderItem: function renderItem(h, renderOpts, params, context) {
var options = renderOpts.options,
optionGroups = renderOpts.optionGroups,
_renderOpts$optionPro4 = renderOpts.optionProps,
optionProps = _renderOpts$optionPro4 === void 0 ? {} : _renderOpts$optionPro4,
_renderOpts$optionPro5 = renderOpts.optionProps,
optionProps = _renderOpts$optionPro5 === void 0 ? {} : _renderOpts$optionPro5,
_renderOpts$optionGro4 = renderOpts.optionGroupProps,
optionGroupProps = _renderOpts$optionGro4 === void 0 ? {} : _renderOpts$optionGro4;
var data = params.data,
Expand Down Expand Up @@ -701,6 +735,12 @@
renderFilter: createFilterRender(),
filterMethod: defaultFilterMethod,
renderItem: createFormItemRender()
},
ARadio: {
renderItem: createFormItemRadioAndCheckboxRender()
},
ACheckbox: {
renderItem: createFormItemRadioAndCheckboxRender()
}
};
/**
Expand Down
Loading

0 comments on commit cefd3e6

Please sign in to comment.