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,6 +66,18 @@ const install = function (Vue, opts = {}) { | ||
| 66 | if (opts.totalCountAlias) { | 66 | if (opts.totalCountAlias) { |
| 67 | component.computed.totalCountAlias = () => opts.totalCountAlias; | 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 | if (opts.searchFilter) { | 81 | if (opts.searchFilter) { |
| 70 | component.methods.searchFilter = opts.searchFilter; | 82 | component.methods.searchFilter = opts.searchFilter; |
| 71 | } | 83 | } |
packages/scheme/index.vue
| @@ -549,7 +549,12 @@ export default { | @@ -549,7 +549,12 @@ export default { | ||
| 549 | } else if (_$http && this.option.url && !detailRow) { // 给定了http的情况 | 549 | } else if (_$http && this.option.url && !detailRow) { // 给定了http的情况 |
| 550 | this.dialogLoading = true; | 550 | this.dialogLoading = true; |
| 551 | const defaultDetailMethod = `info/${detailPrimaryKey || primaryKey}/${param[detailPrimaryKey] || param[primaryKey]}`; | 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 | _$http.get(`${this.option.url.trim('/')}/${detailMethodFormat || defaultDetailMethod}`) | 558 | _$http.get(`${this.option.url.trim('/')}/${detailMethodFormat || defaultDetailMethod}`) |
| 554 | .then(response => { | 559 | .then(response => { |
| 555 | // 预留 支持全局配置filter | 560 | // 预留 支持全局配置filter |
| @@ -611,7 +616,12 @@ export default { | @@ -611,7 +616,12 @@ export default { | ||
| 611 | } else if (_$http && this.option.url && !getRow) { // 给定了http的情况 | 616 | } else if (_$http && this.option.url && !getRow) { // 给定了http的情况 |
| 612 | this.dialogLoading = true; | 617 | this.dialogLoading = true; |
| 613 | const defaultGetMethod = `get/${getPrimaryKey || primaryKey}/${param[getPrimaryKey] || param[primaryKey]}`; | 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 | _$http.get(`${this.option.url.trim('/')}/${getMethodFormat || defaultGetMethod}`) | 625 | _$http.get(`${this.option.url.trim('/')}/${getMethodFormat || defaultGetMethod}`) |
| 616 | .then(response => { | 626 | .then(response => { |
| 617 | // 预留 支持全局配置filter | 627 | // 预留 支持全局配置filter |