Commit b7416b7e00c22710f9235197ad44ad9bed3baf8c
1 parent
71b9687a
Exists in
master
and in
1 other branch
组件库支持全局配置Filter
Showing
1 changed file
with
29 additions
and
3 deletions
Show diff stats
packages/index.js
| @@ -48,16 +48,42 @@ const install = function (Vue, opts = {}) { | @@ -48,16 +48,42 @@ const install = function (Vue, opts = {}) { | ||
| 48 | // 配置组件名称 | 48 | // 配置组件名称 |
| 49 | const name = prefix + component.name | 49 | const name = prefix + component.name |
| 50 | component.name = name | 50 | component.name = name |
| 51 | - const defaultI18n = () => undefined; | 51 | + const emptyMethod = () => undefined; |
| 52 | if (component.computed) { | 52 | if (component.computed) { |
| 53 | component.computed.prefix = () => { return prefix }; | 53 | component.computed.prefix = () => { return prefix }; |
| 54 | } else { | 54 | } else { |
| 55 | component.computed = { prefix: () => { return prefix } } | 55 | component.computed = { prefix: () => { return prefix } } |
| 56 | } | 56 | } |
| 57 | if (component.methods) { | 57 | if (component.methods) { |
| 58 | - component.methods.i18n = opts.i18n || defaultI18n; | 58 | + component.methods.i18n = opts.i18n || emptyMethod; |
| 59 | + if (component.name.indexOf('Scheme') > -1) { | ||
| 60 | + if (opts.searchFilter) { | ||
| 61 | + component.methods.searchFilter = opts.searchFilter; | ||
| 62 | + } | ||
| 63 | + if (opts.resultFilter) { | ||
| 64 | + component.methods.resultFilter = opts.resultFilter; | ||
| 65 | + } | ||
| 66 | + if (opts.detailFilter) { | ||
| 67 | + component.methods.detailFilter = opts.detailFilter; | ||
| 68 | + } | ||
| 69 | + if (opts.getFilter) { | ||
| 70 | + component.methods.getFilter = opts.getFilter; | ||
| 71 | + } | ||
| 72 | + if (opts.deleteFilter) { | ||
| 73 | + component.methods.deleteFilter = opts.deleteFilter; | ||
| 74 | + } | ||
| 75 | + if (opts.newFilter) { | ||
| 76 | + component.methods.newFilter = opts.newFilter; | ||
| 77 | + } | ||
| 78 | + if (opts.editFilter) { | ||
| 79 | + component.methods.editFilter = opts.editFilter; | ||
| 80 | + } | ||
| 81 | + if (opts.successFilter) { | ||
| 82 | + component.methods.successFilter = opts.successFilter; | ||
| 83 | + } | ||
| 84 | + } | ||
| 59 | } else { | 85 | } else { |
| 60 | - component.methods = { i18n: opts.i18n || defaultI18n } | 86 | + component.methods = { i18n: opts.i18n || emptyMethod } |
| 61 | } | 87 | } |
| 62 | // 给每个子组件配置install方法 | 88 | // 给每个子组件配置install方法 |
| 63 | component.install = function (Vue) { | 89 | component.install = function (Vue) { |