Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Aug 8, 2019
1 parent f61ccfa commit 2504069
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 152 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@ VXETable.use(VXETablePluginIView)

## API

### edit-render 单元格渲染配置项说明
### cell-render 默认的渲染器配置项说明

| 属性 | 描述 | 类型 | 可选值 | 默认值 |
|------|------|-----|-----|-----|
| name | 支持的渲染组件 | String | Input, AutoComplete, InputNumber, Rate, iSwitch ||
| props | 渲染组件附加属性,参数请查看被渲染的 Component props | Object || {} |
| options | 只对 name=Select 有效,下拉组件选项列表 | Array || [] |
| optionProps | 只对 name=Select 有效,下拉组件选项属性参数配置 | Object || { value: 'value', label: 'label' } |
| optionGroups | 只对 name=ElSelect 有效,下拉组件分组选项列表 | Array || [] |
| optionGroupProps | 只对 name=ElSelect 有效,下拉组件分组选项属性参数配置 | Object || { options: 'options', label: 'label' } |
| events | 渲染组件附加事件,参数为 ( {row,rowIndex,column,columnIndex}, ...Component arguments ) | Object |||

### edit-render 可编辑渲染器配置项说明

| 属性 | 描述 | 类型 | 可选值 | 默认值 |
|------|------|-----|-----|-----|
Expand All @@ -38,7 +50,7 @@ VXETable.use(VXETablePluginIView)
| optionGroupProps | 只对 name=ElSelect 有效,下拉组件分组选项属性参数配置 | Object || { options: 'options', label: 'label' } |
| events | 渲染组件附加事件,参数为 ( {row,rowIndex,column,columnIndex}, ...Component arguments ) | Object |||

### filter-render 筛选渲染配置项说明
### filter-render 筛选渲染器配置项说明

| 属性 | 描述 | 类型 | 可选值 | 默认值 |
|------|------|-----|-----|-----|
Expand Down
117 changes: 61 additions & 56 deletions dist/index.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function getProps(_ref, _ref2) {
} : {}, props);
}

function getCellEvents(editRender, params) {
var events = editRender.events;
function getCellEvents(renderOpts, params) {
var events = renderOpts.events;
var $table = params.$table;
var type = 'on-change';

Expand All @@ -67,12 +67,12 @@ function getCellEvents(editRender, params) {
return on;
}

function defaultCellRender(h, editRender, params) {
function defaultCellRender(h, renderOpts, params) {
var row = params.row,
column = params.column;
var attrs = editRender.attrs;
var props = getProps(params, editRender);
return [h(editRender.name, {
var attrs = renderOpts.attrs;
var props = getProps(params, renderOpts);
return [h(renderOpts.name, {
props: props,
attrs: attrs,
model: {
Expand All @@ -81,12 +81,12 @@ function defaultCellRender(h, editRender, params) {
_xeUtils["default"].set(row, column.property, value);
}
},
on: getCellEvents(editRender, params)
on: getCellEvents(renderOpts, params)
})];
}

function getFilterEvents(on, filterRender, params) {
var events = filterRender.events;
function getFilterEvents(on, renderOpts, params) {
var events = renderOpts.events;

if (events) {
_xeUtils["default"].assign(on, _xeUtils["default"].objectMap(events, function (cb) {
Expand All @@ -99,12 +99,12 @@ function getFilterEvents(on, filterRender, params) {
return on;
}

function defaultFilterRender(h, filterRender, params, context) {
function defaultFilterRender(h, renderOpts, params, context) {
var column = params.column;
var name = filterRender.name,
attrs = filterRender.attrs;
var name = renderOpts.name,
attrs = renderOpts.attrs;
var type = 'on-change';
var props = getProps(params, filterRender);
var props = getProps(params, renderOpts);
return column.filters.map(function (item) {
return h(name, {
props: props,
Expand All @@ -117,7 +117,7 @@ function defaultFilterRender(h, filterRender, params, context) {
},
on: getFilterEvents(_defineProperty({}, type, function () {
handleConfirmFilter(context, column, !!item.data, item);
}), filterRender, params)
}), renderOpts, params)
});
});
}
Expand Down Expand Up @@ -162,34 +162,37 @@ function cellText(h, cellValue) {
var renderMap = {
Input: {
autofocus: 'input.ivu-input',
renderDefault: defaultCellRender,
renderEdit: defaultCellRender,
renderFilter: defaultFilterRender,
filterMethod: defaultFilterMethod
},
AutoComplete: {
autofocus: 'input.ivu-input',
renderDefault: defaultCellRender,
renderEdit: defaultCellRender,
renderFilter: defaultFilterRender,
filterMethod: defaultFilterMethod
},
InputNumber: {
autofocus: 'input.ivu-input-number-input',
renderDefault: defaultCellRender,
renderEdit: defaultCellRender,
renderFilter: defaultFilterRender,
filterMethod: defaultFilterMethod
},
Select: {
renderEdit: function renderEdit(h, editRender, params) {
var options = editRender.options,
optionGroups = editRender.optionGroups,
_editRender$optionPro = editRender.optionProps,
optionProps = _editRender$optionPro === void 0 ? {} : _editRender$optionPro,
_editRender$optionGro = editRender.optionGroupProps,
optionGroupProps = _editRender$optionGro === void 0 ? {} : _editRender$optionGro;
renderEdit: function renderEdit(h, renderOpts, params) {
var options = renderOpts.options,
optionGroups = renderOpts.optionGroups,
_renderOpts$optionPro = renderOpts.optionProps,
optionProps = _renderOpts$optionPro === void 0 ? {} : _renderOpts$optionPro,
_renderOpts$optionGro = renderOpts.optionGroupProps,
optionGroupProps = _renderOpts$optionGro === void 0 ? {} : _renderOpts$optionGro;
var row = params.row,
column = params.column;
var attrs = editRender.attrs;
var props = getProps(params, editRender);
var attrs = renderOpts.attrs;
var props = getProps(params, renderOpts);

if (optionGroups) {
var groupOptions = optionGroupProps.options || 'options';
Expand All @@ -203,7 +206,7 @@ var renderMap = {
_xeUtils["default"].set(row, column.property, cellValue);
}
},
on: getCellEvents(editRender, params)
on: getCellEvents(renderOpts, params)
}, _xeUtils["default"].map(optionGroups, function (group, gIndex) {
return h('OptionGroup', {
props: {
Expand All @@ -223,18 +226,18 @@ var renderMap = {
_xeUtils["default"].set(row, column.property, cellValue);
}
},
on: getCellEvents(editRender, params)
on: getCellEvents(renderOpts, params)
}, renderOptions(h, options, optionProps))];
},
renderCell: function renderCell(h, editRender, params) {
var options = editRender.options,
optionGroups = editRender.optionGroups,
_editRender$props = editRender.props,
props = _editRender$props === void 0 ? {} : _editRender$props,
_editRender$optionPro2 = editRender.optionProps,
optionProps = _editRender$optionPro2 === void 0 ? {} : _editRender$optionPro2,
_editRender$optionGro2 = editRender.optionGroupProps,
optionGroupProps = _editRender$optionGro2 === void 0 ? {} : _editRender$optionGro2;
renderCell: function renderCell(h, renderOpts, params) {
var options = renderOpts.options,
optionGroups = renderOpts.optionGroups,
_renderOpts$props = renderOpts.props,
props = _renderOpts$props === void 0 ? {} : _renderOpts$props,
_renderOpts$optionPro2 = renderOpts.optionProps,
optionProps = _renderOpts$optionPro2 === void 0 ? {} : _renderOpts$optionPro2,
_renderOpts$optionGro2 = renderOpts.optionGroupProps,
optionGroupProps = _renderOpts$optionGro2 === void 0 ? {} : _renderOpts$optionGro2;
var row = params.row,
column = params.column;
var labelProp = optionProps.label || 'label';
Expand Down Expand Up @@ -269,16 +272,16 @@ var renderMap = {

return cellText(h, '');
},
renderFilter: function renderFilter(h, filterRender, params, context) {
var options = filterRender.options,
optionGroups = filterRender.optionGroups,
_filterRender$optionP = filterRender.optionProps,
optionProps = _filterRender$optionP === void 0 ? {} : _filterRender$optionP,
_filterRender$optionG = filterRender.optionGroupProps,
optionGroupProps = _filterRender$optionG === void 0 ? {} : _filterRender$optionG;
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$optionGro3 = renderOpts.optionGroupProps,
optionGroupProps = _renderOpts$optionGro3 === void 0 ? {} : _renderOpts$optionGro3;
var column = params.column;
var attrs = filterRender.attrs;
var props = getProps(params, filterRender);
var attrs = renderOpts.attrs;
var props = getProps(params, renderOpts);

if (optionGroups) {
var groupOptions = optionGroupProps.options || 'options';
Expand All @@ -297,7 +300,7 @@ var renderMap = {
'on-change': function onChange(value) {
handleConfirmFilter(context, column, value && value.length > 0, item);
}
}, filterRender, params)
}, renderOpts, params)
}, _xeUtils["default"].map(optionGroups, function (group, gIndex) {
return h('OptionGroup', {
props: {
Expand All @@ -323,7 +326,7 @@ var renderMap = {
'on-change': function onChange(value) {
handleConfirmFilter(context, column, value && value.length > 0, item);
}
}, filterRender, params)
}, renderOpts, params)
}, renderOptions(h, options, optionProps));
});
},
Expand All @@ -333,9 +336,9 @@ var renderMap = {
column = _ref4.column;
var data = option.data;
var property = column.property,
filterRender = column.filterRender;
var _filterRender$props = filterRender.props,
props = _filterRender$props === void 0 ? {} : _filterRender$props;
renderOpts = column.renderOpts;
var _renderOpts$props2 = renderOpts.props,
props = _renderOpts$props2 === void 0 ? {} : _renderOpts$props2;

var cellValue = _xeUtils["default"].get(row, property);

Expand Down Expand Up @@ -409,12 +412,12 @@ var renderMap = {

return cellText(h, cellValue);
},
renderFilter: function renderFilter(h, filterRender, params, context) {
renderFilter: function renderFilter(h, renderOpts, params, context) {
var column = params.column;
var attrs = filterRender.attrs;
var props = getProps(params, filterRender);
var attrs = renderOpts.attrs;
var props = getProps(params, renderOpts);
return column.filters.map(function (item) {
return h(filterRender.name, {
return h(renderOpts.name, {
props: props,
attrs: attrs,
model: {
Expand All @@ -427,7 +430,7 @@ var renderMap = {
'on-change': function onChange(value) {
handleConfirmFilter(context, column, !!value, item);
}
}, filterRender, params)
}, renderOpts, params)
});
});
},
Expand All @@ -436,9 +439,9 @@ var renderMap = {
row = _ref7.row,
column = _ref7.column;
var data = option.data;
var filterRender = column.filterRender;
var _filterRender$props2 = filterRender.props,
props = _filterRender$props2 === void 0 ? {} : _filterRender$props2;
var renderOpts = column.renderOpts;
var _renderOpts$props3 = renderOpts.props,
props = _renderOpts$props3 === void 0 ? {} : _renderOpts$props3;

var cellValue = _xeUtils["default"].get(row, column.property);

Expand All @@ -462,11 +465,13 @@ var renderMap = {
renderEdit: defaultCellRender
},
Rate: {
renderDefault: defaultCellRender,
renderEdit: defaultCellRender,
renderFilter: defaultFilterRender,
filterMethod: defaultFilterMethod
},
iSwitch: {
renderDefault: defaultCellRender,
renderEdit: defaultCellRender,
renderFilter: defaultFilterRender,
filterMethod: defaultFilterMethod
Expand Down
Loading

0 comments on commit 2504069

Please sign in to comment.