Skip to content

Commit

Permalink
优化筛选事件参数
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Nov 5, 2019
1 parent ef6f8d3 commit 6bfda37
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 30 deletions.
32 changes: 22 additions & 10 deletions dist/index.common.js

Large diffs are not rendered by default.

30 changes: 21 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@
})];
}

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

if (events) {
return _xeUtils["default"].assign({}, _xeUtils["default"].objectMap(events, function (cb) {
return function () {
params = Object.assign({
context: context
}, params);

for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
Expand Down Expand Up @@ -140,9 +144,11 @@
handleConfirmFilter(context, column, !!item.data, item);

if (events && events[type]) {
events[type](params, evnt);
events[type](Object.assign({
context: context
}, params), evnt);
}
}), renderOpts, params)
}), renderOpts, params, context)
});
});
}
Expand Down Expand Up @@ -331,9 +337,11 @@
handleConfirmFilter(context, column, value && value.length > 0, item);

if (events && events[type]) {
events[type](params, value);
events[type](Object.assign({
context: context
}, params), value);
}
}), renderOpts, params)
}), renderOpts, params, context)
}, _xeUtils["default"].map(optionGroups, function (group, gIndex) {
return h('OptionGroup', {
props: {
Expand All @@ -359,9 +367,11 @@
handleConfirmFilter(context, column, value && value.length > 0, item);

if (events && events[type]) {
events[type](params, value);
events[type](Object.assign({
context: context
}, params), value);
}
}), renderOpts, params)
}), renderOpts, params, context)
}, renderOptions(h, options, optionProps));
});
},
Expand Down Expand Up @@ -469,9 +479,11 @@
handleConfirmFilter(context, column, !!value, item);

if (events && events[type]) {
events[type](params, value);
events[type](Object.assign({
context: context
}, params), value);
}
}), renderOpts, params)
}), renderOpts, params, context)
});
});
},
Expand Down
2 changes: 1 addition & 1 deletion dist/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ function defaultEditRender(h: Function, renderOpts: any, params: any) {
]
}

function getFilterEvents(on: any, renderOpts: any, params: any) {
function getFilterEvents(on: any, renderOpts: any, params: any, context: any) {
let { events } = renderOpts
if (events) {
return XEUtils.assign({}, XEUtils.objectMap(events, (cb: Function) => function (...args: any[]) {
params = Object.assign({ context }, params)
cb.apply(null, [params].concat.apply(params, args))
}), on)
}
Expand All @@ -93,10 +94,10 @@ function defaultFilterRender(h: Function, renderOpts: any, params: any, context:
[type](evnt: any) {
handleConfirmFilter(context, column, !!item.data, item)
if (events && events[type]) {
events[type](params, evnt)
events[type](Object.assign({ context }, params), evnt)
}
}
}, renderOpts, params)
}, renderOpts, params, context)
})
})
}
Expand Down Expand Up @@ -248,10 +249,10 @@ const renderMap = {
[type](value: any) {
handleConfirmFilter(context, column, value && value.length > 0, item)
if (events && events[type]) {
events[type](params, value)
events[type](Object.assign({ context }, params), value)
}
}
}, renderOpts, params)
}, renderOpts, params, context)
}, XEUtils.map(optionGroups, (group: any, gIndex: number) => {
return h('OptionGroup', {
props: {
Expand All @@ -276,10 +277,10 @@ const renderMap = {
[type](value: any) {
handleConfirmFilter(context, column, value && value.length > 0, item)
if (events && events[type]) {
events[type](params, value)
events[type](Object.assign({ context }, params), value)
}
}
}, renderOpts, params)
}, renderOpts, params, context)
}, renderOptions(h, options, optionProps))
})
},
Expand Down Expand Up @@ -359,10 +360,10 @@ const renderMap = {
[type](value: any) {
handleConfirmFilter(context, column, !!value, item)
if (events && events[type]) {
events[type](params, value)
events[type](Object.assign({ context }, params), value)
}
}
}, renderOpts, params)
}, renderOpts, params, context)
})
})
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table-plugin-iview",
"version": "1.5.5",
"version": "1.5.6",
"description": "基于 vxe-table 表格的适配插件,用于兼容 iview 组件库",
"scripts": {
"lib": "gulp build"
Expand Down

0 comments on commit 6bfda37

Please sign in to comment.