From 65da478489b534c14ad01fc2a0fd74684e258da4 Mon Sep 17 00:00:00 2001 From: Aaron <427787340@qq.com> Date: Fri, 6 Dec 2019 17:56:49 +0800 Subject: [PATCH] 修复Scheme全局配置别名逻辑 --- packages/index.js | 3 +++ packages/scheme/index.vue | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/index.js b/packages/index.js index bde96d4..cc16372 100644 --- a/packages/index.js +++ b/packages/index.js @@ -66,6 +66,9 @@ const install = function (Vue, opts = {}) { if (opts.totalCountAlias) { component.computed.totalCountAlias = () => opts.totalCountAlias; } + if (opts.searchMethod) { + component.computed.searchMethod = () => opts.searchMethod; + } if (opts.getMethod) { component.computed.getMethod = () => opts.getMethod; } diff --git a/packages/scheme/index.vue b/packages/scheme/index.vue index 805bca8..26f9a07 100644 --- a/packages/scheme/index.vue +++ b/packages/scheme/index.vue @@ -471,7 +471,7 @@ export default { } } else if (_$http && this.option.url) { // 给定了http的情况 this.tableLoading = true; - _$http.get(`${this.option.url.trim('/')}/${this.option.searchMethod || 'page'}?${stringify(param)}`) + _$http.get(`${this.option.url.trim('/')}/${this.option.searchMethod || this.searchMethod || 'page'}?${stringify(param)}`) .then((response) => { // 预留 支持全局配置filter const responseFilter = this.option.searchFilter || this.searchFilter; @@ -550,10 +550,10 @@ export default { this.dialogLoading = true; const defaultDetailMethod = `info/${detailPrimaryKey || primaryKey}/${param[detailPrimaryKey] || param[primaryKey]}`; let detailMethodFormat = ''; - if (this.detailMethod) { - detailMethodFormat = `${this.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}`; - } else if (this.option.detailMethod) { + if (this.option.detailMethod) { detailMethodFormat = `${this.option.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}`; + } else if (this.detailMethod) { + detailMethodFormat = `${this.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}`; } _$http.get(`${this.option.url.trim('/')}/${detailMethodFormat || defaultDetailMethod}`) .then(response => { @@ -617,10 +617,10 @@ export default { this.dialogLoading = true; const defaultGetMethod = `get/${getPrimaryKey || primaryKey}/${param[getPrimaryKey] || param[primaryKey]}`; let getMethodFormat = ''; - if (this.getMethod) { - getMethodFormat = `${this.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}`; - } else if (this.option.getMethod) { + if (this.option.getMethod) { getMethodFormat = `${this.option.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}`; + } else if (this.getMethod) { + getMethodFormat = `${this.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}`; } _$http.get(`${this.option.url.trim('/')}/${getMethodFormat || defaultGetMethod}`) .then(response => { @@ -683,7 +683,7 @@ export default { } else if (_$http && this.option.url) { // 给定了http的情况 this.dialogLoading = true; const postData = param; - _$http.post(`${this.option.url.trim('/')}/${this.option.deleteMethod || 'delete'}`, postData) + _$http.post(`${this.option.url.trim('/')}/${this.option.deleteMethod || this.deleteMethod || 'delete'}`, postData) .then(response => { // 预留 支持全局配置filter const responseFilter = this.option.deleteFilter || this.deleteFilter || this.option.successFilter || this.successFilter; @@ -779,7 +779,7 @@ export default { this.dialogLoading = true; const postData = { ...param }; delete postData[formPrimaryKey || primaryKey]; - _$http.post(`${this.option.url.trim('/')}/${this.option.newMethod || 'add'}`, postData) + _$http.post(`${this.option.url.trim('/')}/${this.option.newMethod || this.newMethod || 'add'}`, postData) .then(response => { // 预留 支持全局配置filter const responseFilter = this.option.newFilter || this.newFilter || this.option.successFilter || this.successFilter; @@ -828,7 +828,7 @@ export default { } } else if (_$http && this.option.url) { // 给定了http的情况 this.dialogLoading = true; - _$http.post(`${this.option.url.trim('/')}/${this.option.editMethod || 'update'}`, param) + _$http.post(`${this.option.url.trim('/')}/${this.option.editMethod || this.editMethod || 'update'}`, param) .then(response => { const responseFilter = this.option.editFilter || this.editFilter || this.option.successFilter || this.successFilter; if (responseFilter) { -- libgit2 0.21.0