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 3ae7752 commit f61ccfa
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 18 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
[![gzip size: CSS](http://img.badgesize.io/https://unpkg.com/vxe-table-plugin-iview/dist/style.min.css?compression=gzip&label=gzip%20size:%20CSS)](https://unpkg.com/vxe-table-plugin-iview/dist/style.min.css)
[![npm license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/xuliangzhan/vxe-table-plugin-iview/blob/master/LICENSE)

该插件用于在 vxe-table 表格中适配 iview 组件的渲染
该插件用于在 [vxe-table](https://github.com/xuliangzhan/vxe-table) 的渲染器中适配 [iview](https://www.npmjs.com/package/iview)

## Installing

```shell
npm install xe-utils vxe-table vxe-table-plugin-iview
npm install xe-utils vxe-table vxe-table-plugin-iview iview
```

```javascript
Expand Down Expand Up @@ -42,7 +42,7 @@ VXETable.use(VXETablePluginIView)

| 属性 | 描述 | 类型 | 可选值 | 默认值 |
|------|------|-----|-----|-----|
| name | 支持的渲染组件 | String | Input, AutoComplete, InputNumber, Select ||
| name | 支持的渲染组件 | String | Input, AutoComplete, InputNumber, Select, Rate, iSwitch ||
| props | 渲染组件附加属性,参数请查看被渲染的 Component props | Object || {} |
| options | 只对 name=Select 有效,下拉组件选项列表 | Array || [] |
| optionProps | 只对 name=Select 有效,下拉组件选项属性参数配置 | Object || { value: 'value', label: 'label' } |
Expand Down
22 changes: 19 additions & 3 deletions dist/index.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ function getCellEvents(editRender, params) {
function defaultCellRender(h, editRender, params) {
var row = params.row,
column = params.column;
var attrs = editRender.attrs;
var props = getProps(params, editRender);
return [h(editRender.name, {
props: props,
attrs: attrs,
model: {
value: _xeUtils["default"].get(row, column.property),
callback: function callback(value) {
Expand All @@ -99,12 +101,14 @@ function getFilterEvents(on, filterRender, params) {

function defaultFilterRender(h, filterRender, params, context) {
var column = params.column;
var name = filterRender.name;
var name = filterRender.name,
attrs = filterRender.attrs;
var type = 'on-change';
var props = getProps(params, filterRender);
return column.filters.map(function (item) {
return h(name, {
props: props,
attrs: attrs,
model: {
value: item.data,
callback: function callback(optionValue) {
Expand Down Expand Up @@ -184,13 +188,15 @@ var renderMap = {
optionGroupProps = _editRender$optionGro === void 0 ? {} : _editRender$optionGro;
var row = params.row,
column = params.column;
var attrs = editRender.attrs;
var props = getProps(params, editRender);

if (optionGroups) {
var groupOptions = optionGroupProps.options || 'options';
var groupLabel = optionGroupProps.label || 'label';
return [h('Select', {
props: props,
attrs: attrs,
model: {
value: _xeUtils["default"].get(row, column.property),
callback: function callback(cellValue) {
Expand All @@ -210,6 +216,7 @@ var renderMap = {

return [h('Select', {
props: props,
attrs: attrs,
model: {
value: _xeUtils["default"].get(row, column.property),
callback: function callback(cellValue) {
Expand Down Expand Up @@ -270,6 +277,7 @@ var renderMap = {
_filterRender$optionG = filterRender.optionGroupProps,
optionGroupProps = _filterRender$optionG === void 0 ? {} : _filterRender$optionG;
var column = params.column;
var attrs = filterRender.attrs;
var props = getProps(params, filterRender);

if (optionGroups) {
Expand All @@ -278,6 +286,7 @@ var renderMap = {
return column.filters.map(function (item) {
return h('Select', {
props: props,
attrs: attrs,
model: {
value: item.data,
callback: function callback(optionValue) {
Expand All @@ -303,6 +312,7 @@ var renderMap = {
return column.filters.map(function (item) {
return h('Select', {
props: props,
attrs: attrs,
model: {
value: item.data,
callback: function callback(optionValue) {
Expand Down Expand Up @@ -401,10 +411,12 @@ var renderMap = {
},
renderFilter: function renderFilter(h, filterRender, params, context) {
var column = params.column;
var attrs = filterRender.attrs;
var props = getProps(params, filterRender);
return column.filters.map(function (item) {
return h(filterRender.name, {
props: props,
attrs: attrs,
model: {
value: item.data,
callback: function callback(optionValue) {
Expand Down Expand Up @@ -450,10 +462,14 @@ var renderMap = {
renderEdit: defaultCellRender
},
Rate: {
renderEdit: defaultCellRender
renderEdit: defaultCellRender,
renderFilter: defaultFilterRender,
filterMethod: defaultFilterMethod
},
iSwitch: {
renderEdit: defaultCellRender
renderEdit: defaultCellRender,
renderFilter: defaultFilterRender,
filterMethod: defaultFilterMethod
}
/**
* 事件兼容性处理
Expand Down
22 changes: 19 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@
function defaultCellRender(h, editRender, params) {
var row = params.row,
column = params.column;
var attrs = editRender.attrs;
var props = getProps(params, editRender);
return [h(editRender.name, {
props: props,
attrs: attrs,
model: {
value: _xeUtils["default"].get(row, column.property),
callback: function callback(value) {
Expand All @@ -111,12 +113,14 @@

function defaultFilterRender(h, filterRender, params, context) {
var column = params.column;
var name = filterRender.name;
var name = filterRender.name,
attrs = filterRender.attrs;
var type = 'on-change';
var props = getProps(params, filterRender);
return column.filters.map(function (item) {
return h(name, {
props: props,
attrs: attrs,
model: {
value: item.data,
callback: function callback(optionValue) {
Expand Down Expand Up @@ -196,13 +200,15 @@
optionGroupProps = _editRender$optionGro === void 0 ? {} : _editRender$optionGro;
var row = params.row,
column = params.column;
var attrs = editRender.attrs;
var props = getProps(params, editRender);

if (optionGroups) {
var groupOptions = optionGroupProps.options || 'options';
var groupLabel = optionGroupProps.label || 'label';
return [h('Select', {
props: props,
attrs: attrs,
model: {
value: _xeUtils["default"].get(row, column.property),
callback: function callback(cellValue) {
Expand All @@ -222,6 +228,7 @@

return [h('Select', {
props: props,
attrs: attrs,
model: {
value: _xeUtils["default"].get(row, column.property),
callback: function callback(cellValue) {
Expand Down Expand Up @@ -282,6 +289,7 @@
_filterRender$optionG = filterRender.optionGroupProps,
optionGroupProps = _filterRender$optionG === void 0 ? {} : _filterRender$optionG;
var column = params.column;
var attrs = filterRender.attrs;
var props = getProps(params, filterRender);

if (optionGroups) {
Expand All @@ -290,6 +298,7 @@
return column.filters.map(function (item) {
return h('Select', {
props: props,
attrs: attrs,
model: {
value: item.data,
callback: function callback(optionValue) {
Expand All @@ -315,6 +324,7 @@
return column.filters.map(function (item) {
return h('Select', {
props: props,
attrs: attrs,
model: {
value: item.data,
callback: function callback(optionValue) {
Expand Down Expand Up @@ -413,10 +423,12 @@
},
renderFilter: function renderFilter(h, filterRender, params, context) {
var column = params.column;
var attrs = filterRender.attrs;
var props = getProps(params, filterRender);
return column.filters.map(function (item) {
return h(filterRender.name, {
props: props,
attrs: attrs,
model: {
value: item.data,
callback: function callback(optionValue) {
Expand Down Expand Up @@ -462,10 +474,14 @@
renderEdit: defaultCellRender
},
Rate: {
renderEdit: defaultCellRender
renderEdit: defaultCellRender,
renderFilter: defaultFilterRender,
filterMethod: defaultFilterMethod
},
iSwitch: {
renderEdit: defaultCellRender
renderEdit: defaultCellRender,
renderFilter: defaultFilterRender,
filterMethod: defaultFilterMethod
}
/**
* 事件兼容性处理
Expand Down
Loading

0 comments on commit f61ccfa

Please sign in to comment.