Commit 65da478489b534c14ad01fc2a0fd74684e258da4
1 parent
8fe2b761
Exists in
master
and in
1 other branch
修复Scheme全局配置别名逻辑
Showing
2 changed files
with
13 additions
and
10 deletions
Show diff stats
packages/index.js
| ... | ... | @@ -66,6 +66,9 @@ const install = function (Vue, opts = {}) { |
| 66 | 66 | if (opts.totalCountAlias) { |
| 67 | 67 | component.computed.totalCountAlias = () => opts.totalCountAlias; |
| 68 | 68 | } |
| 69 | + if (opts.searchMethod) { | |
| 70 | + component.computed.searchMethod = () => opts.searchMethod; | |
| 71 | + } | |
| 69 | 72 | if (opts.getMethod) { |
| 70 | 73 | component.computed.getMethod = () => opts.getMethod; |
| 71 | 74 | } | ... | ... |
packages/scheme/index.vue
| ... | ... | @@ -471,7 +471,7 @@ export default { |
| 471 | 471 | } |
| 472 | 472 | } else if (_$http && this.option.url) { // 给定了http的情况 |
| 473 | 473 | this.tableLoading = true; |
| 474 | - _$http.get(`${this.option.url.trim('/')}/${this.option.searchMethod || 'page'}?${stringify(param)}`) | |
| 474 | + _$http.get(`${this.option.url.trim('/')}/${this.option.searchMethod || this.searchMethod || 'page'}?${stringify(param)}`) | |
| 475 | 475 | .then((response) => { |
| 476 | 476 | // 预留 支持全局配置filter |
| 477 | 477 | const responseFilter = this.option.searchFilter || this.searchFilter; |
| ... | ... | @@ -550,10 +550,10 @@ export default { |
| 550 | 550 | this.dialogLoading = true; |
| 551 | 551 | const defaultDetailMethod = `info/${detailPrimaryKey || primaryKey}/${param[detailPrimaryKey] || param[primaryKey]}`; |
| 552 | 552 | let detailMethodFormat = ''; |
| 553 | - if (this.detailMethod) { | |
| 554 | - detailMethodFormat = `${this.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}`; | |
| 555 | - } else if (this.option.detailMethod) { | |
| 553 | + if (this.option.detailMethod) { | |
| 556 | 554 | detailMethodFormat = `${this.option.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}`; |
| 555 | + } else if (this.detailMethod) { | |
| 556 | + detailMethodFormat = `${this.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}`; | |
| 557 | 557 | } |
| 558 | 558 | _$http.get(`${this.option.url.trim('/')}/${detailMethodFormat || defaultDetailMethod}`) |
| 559 | 559 | .then(response => { |
| ... | ... | @@ -617,10 +617,10 @@ export default { |
| 617 | 617 | this.dialogLoading = true; |
| 618 | 618 | const defaultGetMethod = `get/${getPrimaryKey || primaryKey}/${param[getPrimaryKey] || param[primaryKey]}`; |
| 619 | 619 | let getMethodFormat = ''; |
| 620 | - if (this.getMethod) { | |
| 621 | - getMethodFormat = `${this.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}`; | |
| 622 | - } else if (this.option.getMethod) { | |
| 620 | + if (this.option.getMethod) { | |
| 623 | 621 | getMethodFormat = `${this.option.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}`; |
| 622 | + } else if (this.getMethod) { | |
| 623 | + getMethodFormat = `${this.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}`; | |
| 624 | 624 | } |
| 625 | 625 | _$http.get(`${this.option.url.trim('/')}/${getMethodFormat || defaultGetMethod}`) |
| 626 | 626 | .then(response => { |
| ... | ... | @@ -683,7 +683,7 @@ export default { |
| 683 | 683 | } else if (_$http && this.option.url) { // 给定了http的情况 |
| 684 | 684 | this.dialogLoading = true; |
| 685 | 685 | const postData = param; |
| 686 | - _$http.post(`${this.option.url.trim('/')}/${this.option.deleteMethod || 'delete'}`, postData) | |
| 686 | + _$http.post(`${this.option.url.trim('/')}/${this.option.deleteMethod || this.deleteMethod || 'delete'}`, postData) | |
| 687 | 687 | .then(response => { |
| 688 | 688 | // 预留 支持全局配置filter |
| 689 | 689 | const responseFilter = this.option.deleteFilter || this.deleteFilter || this.option.successFilter || this.successFilter; |
| ... | ... | @@ -779,7 +779,7 @@ export default { |
| 779 | 779 | this.dialogLoading = true; |
| 780 | 780 | const postData = { ...param }; |
| 781 | 781 | delete postData[formPrimaryKey || primaryKey]; |
| 782 | - _$http.post(`${this.option.url.trim('/')}/${this.option.newMethod || 'add'}`, postData) | |
| 782 | + _$http.post(`${this.option.url.trim('/')}/${this.option.newMethod || this.newMethod || 'add'}`, postData) | |
| 783 | 783 | .then(response => { |
| 784 | 784 | // 预留 支持全局配置filter |
| 785 | 785 | const responseFilter = this.option.newFilter || this.newFilter || this.option.successFilter || this.successFilter; |
| ... | ... | @@ -828,7 +828,7 @@ export default { |
| 828 | 828 | } |
| 829 | 829 | } else if (_$http && this.option.url) { // 给定了http的情况 |
| 830 | 830 | this.dialogLoading = true; |
| 831 | - _$http.post(`${this.option.url.trim('/')}/${this.option.editMethod || 'update'}`, param) | |
| 831 | + _$http.post(`${this.option.url.trim('/')}/${this.option.editMethod || this.editMethod || 'update'}`, param) | |
| 832 | 832 | .then(response => { |
| 833 | 833 | const responseFilter = this.option.editFilter || this.editFilter || this.option.successFilter || this.successFilter; |
| 834 | 834 | if (responseFilter) { | ... | ... |