Commit 65da478489b534c14ad01fc2a0fd74684e258da4

Authored by Aaron
1 parent 8fe2b761
Exists in master and in 1 other branch legacy

修复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,6 +66,9 @@ 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.searchMethod) {
  70 + component.computed.searchMethod = () => opts.searchMethod;
  71 + }
69 if (opts.getMethod) { 72 if (opts.getMethod) {
70 component.computed.getMethod = () => opts.getMethod; 73 component.computed.getMethod = () => opts.getMethod;
71 } 74 }
packages/scheme/index.vue
@@ -471,7 +471,7 @@ export default { @@ -471,7 +471,7 @@ export default {
471 } 471 }
472 } else if (_$http && this.option.url) { // 给定了http的情况 472 } else if (_$http && this.option.url) { // 给定了http的情况
473 this.tableLoading = true; 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 .then((response) => { 475 .then((response) => {
476 // 预留 支持全局配置filter 476 // 预留 支持全局配置filter
477 const responseFilter = this.option.searchFilter || this.searchFilter; 477 const responseFilter = this.option.searchFilter || this.searchFilter;
@@ -550,10 +550,10 @@ export default { @@ -550,10 +550,10 @@ export default {
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 let detailMethodFormat = ''; 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 detailMethodFormat = `${this.option.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}`; 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 _$http.get(`${this.option.url.trim('/')}/${detailMethodFormat || defaultDetailMethod}`) 558 _$http.get(`${this.option.url.trim('/')}/${detailMethodFormat || defaultDetailMethod}`)
559 .then(response => { 559 .then(response => {
@@ -617,10 +617,10 @@ export default { @@ -617,10 +617,10 @@ export default {
617 this.dialogLoading = true; 617 this.dialogLoading = true;
618 const defaultGetMethod = `get/${getPrimaryKey || primaryKey}/${param[getPrimaryKey] || param[primaryKey]}`; 618 const defaultGetMethod = `get/${getPrimaryKey || primaryKey}/${param[getPrimaryKey] || param[primaryKey]}`;
619 let getMethodFormat = ''; 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 getMethodFormat = `${this.option.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}`; 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 _$http.get(`${this.option.url.trim('/')}/${getMethodFormat || defaultGetMethod}`) 625 _$http.get(`${this.option.url.trim('/')}/${getMethodFormat || defaultGetMethod}`)
626 .then(response => { 626 .then(response => {
@@ -683,7 +683,7 @@ export default { @@ -683,7 +683,7 @@ export default {
683 } else if (_$http && this.option.url) { // 给定了http的情况 683 } else if (_$http && this.option.url) { // 给定了http的情况
684 this.dialogLoading = true; 684 this.dialogLoading = true;
685 const postData = param; 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 .then(response => { 687 .then(response => {
688 // 预留 支持全局配置filter 688 // 预留 支持全局配置filter
689 const responseFilter = this.option.deleteFilter || this.deleteFilter || this.option.successFilter || this.successFilter; 689 const responseFilter = this.option.deleteFilter || this.deleteFilter || this.option.successFilter || this.successFilter;
@@ -779,7 +779,7 @@ export default { @@ -779,7 +779,7 @@ export default {
779 this.dialogLoading = true; 779 this.dialogLoading = true;
780 const postData = { ...param }; 780 const postData = { ...param };
781 delete postData[formPrimaryKey || primaryKey]; 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 .then(response => { 783 .then(response => {
784 // 预留 支持全局配置filter 784 // 预留 支持全局配置filter
785 const responseFilter = this.option.newFilter || this.newFilter || this.option.successFilter || this.successFilter; 785 const responseFilter = this.option.newFilter || this.newFilter || this.option.successFilter || this.successFilter;
@@ -828,7 +828,7 @@ export default { @@ -828,7 +828,7 @@ export default {
828 } 828 }
829 } else if (_$http && this.option.url) { // 给定了http的情况 829 } else if (_$http && this.option.url) { // 给定了http的情况
830 this.dialogLoading = true; 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 .then(response => { 832 .then(response => {
833 const responseFilter = this.option.editFilter || this.editFilter || this.option.successFilter || this.successFilter; 833 const responseFilter = this.option.editFilter || this.editFilter || this.option.successFilter || this.successFilter;
834 if (responseFilter) { 834 if (responseFilter) {