diff --git a/packages/index.js b/packages/index.js index be35b61..bde96d4 100644 --- a/packages/index.js +++ b/packages/index.js @@ -66,6 +66,18 @@ const install = function (Vue, opts = {}) { if (opts.totalCountAlias) { component.computed.totalCountAlias = () => opts.totalCountAlias; } + if (opts.getMethod) { + component.computed.getMethod = () => opts.getMethod; + } + if (opts.newMethod) { + component.computed.newMethod = () => opts.newMethod; + } + if (opts.editMethod) { + component.computed.editMethod = () => opts.editMethod; + } + if (opts.deleteMethod) { + component.computed.deleteMethod = () => opts.deleteMethod; + } if (opts.searchFilter) { component.methods.searchFilter = opts.searchFilter; } diff --git a/packages/scheme/index.vue b/packages/scheme/index.vue index 5f5021a..805bca8 100644 --- a/packages/scheme/index.vue +++ b/packages/scheme/index.vue @@ -549,7 +549,12 @@ export default { } else if (_$http && this.option.url && !detailRow) { // 给定了http的情况 this.dialogLoading = true; const defaultDetailMethod = `info/${detailPrimaryKey || primaryKey}/${param[detailPrimaryKey] || param[primaryKey]}`; - const detailMethodFormat = this.option.detailMethod ? `${this.option.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}` : undefined; + let detailMethodFormat = ''; + if (this.detailMethod) { + detailMethodFormat = `${this.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}`; + } else if (this.option.detailMethod) { + detailMethodFormat = `${this.option.detailMethod.trim('/')}/${param[detailPrimaryKey || primaryKey]}`; + } _$http.get(`${this.option.url.trim('/')}/${detailMethodFormat || defaultDetailMethod}`) .then(response => { // 预留 支持全局配置filter @@ -611,7 +616,12 @@ export default { } else if (_$http && this.option.url && !getRow) { // 给定了http的情况 this.dialogLoading = true; const defaultGetMethod = `get/${getPrimaryKey || primaryKey}/${param[getPrimaryKey] || param[primaryKey]}`; - const getMethodFormat = this.option.getMethod ? `${this.option.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}` : undefined; + let getMethodFormat = ''; + if (this.getMethod) { + getMethodFormat = `${this.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}`; + } else if (this.option.getMethod) { + getMethodFormat = `${this.option.getMethod.trim('/')}/${param[getPrimaryKey || primaryKey]}`; + } _$http.get(`${this.option.url.trim('/')}/${getMethodFormat || defaultGetMethod}`) .then(response => { // 预留 支持全局配置filter -- libgit2 0.21.0