Commit 9e0c11e6c2a208cd89c64c8bca581b7b7970bbf4
1 parent
69c46c9c
Exists in
master
and in
1 other branch
Scheme组件支持全局配置方法别名
Showing
2 changed files
with
24 additions
and
2 deletions
Show diff stats
packages/index.js
| ... | ... | @@ -66,6 +66,18 @@ const install = function (Vue, opts = {}) { |
| 66 | 66 | if (opts.totalCountAlias) { |
| 67 | 67 | component.computed.totalCountAlias = () => opts.totalCountAlias; |
| 68 | 68 | } |
| 69 | + if (opts.getMethod) { | |
| 70 | + component.computed.getMethod = () => opts.getMethod; | |
| 71 | + } | |
| 72 | + if (opts.newMethod) { | |
| 73 | + component.computed.newMethod = () => opts.newMethod; | |
| 74 | + } | |
| 75 | + if (opts.editMethod) { | |
| 76 | + component.computed.editMethod = () => opts.editMethod; | |
| 77 | + } | |
| 78 | + if (opts.deleteMethod) { | |
| 79 | + component.computed.deleteMethod = () => opts.deleteMethod; | |
| 80 | + } | |
| 69 | 81 | if (opts.searchFilter) { |
| 70 | 82 | component.methods.searchFilter = opts.searchFilter; |
| 71 | 83 | } | ... | ... |
packages/scheme/index.vue
| ... | ... | @@ -549,7 +549,12 @@ export default { |
| 549 | 549 | } else if (_$http && this.option.url && !detailRow) { // 给定了http的情况 |
| 550 | 550 | this.dialogLoading = true; |
| 551 | 551 | const defaultDetailMethod = `info/${detailPrimaryKey || primaryKey}/${param[detailPrimaryKey] || param[primaryKey]}`; |
| 552 | - const detailMethodFormat = this.option.detailMethod ? `${this.option.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}` : undefined; | |
| 552 | + let detailMethodFormat = ''; | |
| 553 | + if (this.detailMethod) { | |
| 554 | + detailMethodFormat = `${this.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}`; | |
| 555 | + } else if (this.option.detailMethod) { | |
| 556 | + detailMethodFormat = `${this.option.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}`; | |
| 557 | + } | |
| 553 | 558 | _$http.get(`${this.option.url.trim('/')}/${detailMethodFormat || defaultDetailMethod}`) |
| 554 | 559 | .then(response => { |
| 555 | 560 | // 预留 支持全局配置filter |
| ... | ... | @@ -611,7 +616,12 @@ export default { |
| 611 | 616 | } else if (_$http && this.option.url && !getRow) { // 给定了http的情况 |
| 612 | 617 | this.dialogLoading = true; |
| 613 | 618 | const defaultGetMethod = `get/${getPrimaryKey || primaryKey}/${param[getPrimaryKey] || param[primaryKey]}`; |
| 614 | - const getMethodFormat = this.option.getMethod ? `${this.option.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}` : undefined; | |
| 619 | + let getMethodFormat = ''; | |
| 620 | + if (this.getMethod) { | |
| 621 | + getMethodFormat = `${this.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}`; | |
| 622 | + } else if (this.option.getMethod) { | |
| 623 | + getMethodFormat = `${this.option.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}`; | |
| 624 | + } | |
| 615 | 625 | _$http.get(`${this.option.url.trim('/')}/${getMethodFormat || defaultGetMethod}`) |
| 616 | 626 | .then(response => { |
| 617 | 627 | // 预留 支持全局配置filter | ... | ... |