From f02595167f8acceb9918b1e52087febf6266f64d Mon Sep 17 00:00:00 2001 From: xiawenlong Date: Tue, 19 Oct 2021 20:40:26 +0800 Subject: [PATCH] fix default body type. --- module/api/js/common.js | 2 +- module/api/js/create.js | 11 +++++++++++ module/api/js/edit.js | 12 ++++++++++++ module/api/view/create.html.php | 2 +- module/api/view/edit.html.php | 2 +- module/api/view/editstruct.html.php | 2 +- 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/module/api/js/common.js b/module/api/js/common.js index 6f915d1af2..ad641fffb1 100644 --- a/module/api/js/common.js +++ b/module/api/js/common.js @@ -295,6 +295,7 @@ try { structType: { handler(val) { this.changeType() + this.$emit('change-type', this.structType) } }, current: { @@ -312,7 +313,6 @@ try { } }, created() { - console.log(this.showType, this.structType) this.current = [this.getInitField()] if (this.attr && this.attr.length > 0) { const attr = []; diff --git a/module/api/js/create.js b/module/api/js/create.js index 8845f5bd90..8d0e441826 100644 --- a/module/api/js/create.js +++ b/module/api/js/create.js @@ -7,6 +7,7 @@ var app = new Vue({ params: "", response: "", defaultHeader: {field: '', required: '', desc: ''}, + attrType: '', }, created() { this.header.push({...this.defaultHeader}); @@ -30,12 +31,21 @@ var app = new Vue({ this.setParams(); }, deep: true + }, + attrType: { + handler() { + this.setParams() + }, + deep: true } }, methods: { changeAttr(val) { this.body = val; }, + changeType(val) { + this.attrType = val + }, changeRes(val) { val = this.filterParams(val) this.response = JSON.stringify(val); @@ -47,6 +57,7 @@ var app = new Vue({ const params = { header: header, params: body, + paramsType: this.attrType, query: queryP, } this.params = JSON.stringify(params); diff --git a/module/api/js/edit.js b/module/api/js/edit.js index 25154fa678..50ca3eb7f8 100644 --- a/module/api/js/edit.js +++ b/module/api/js/edit.js @@ -16,6 +16,7 @@ var app = new Vue({ params: "", defaultHeader: {field: '', required: '', desc: ''}, attr: [], + attrType: 'formData', api }, created() { @@ -25,6 +26,7 @@ var app = new Vue({ if(api.params.header && api.params.header.length > 0) this.header = api.params.header if(api.params.query && api.params.query.length > 0) this.queryP = api.params.query if(api.params.params && api.params.params.length > 0) this.attr = api.params.params + if(api.params.paramsType) this.attrType = api.params.paramsType this.setParams(); } }, @@ -46,12 +48,21 @@ var app = new Vue({ this.setParams() }, deep: true + }, + attrType: { + handler() { + this.setParams() + }, + deep: true } }, methods: { changeAttr(val) { this.body = val }, + changeType(val) { + this.attrType = val + }, changeRes(val) { val = this.filterParams(val) this.response = JSON.stringify(val) @@ -63,6 +74,7 @@ var app = new Vue({ const params = { header: header, params: body, + paramsType: this.attrType, query: queryP, } this.params = JSON.stringify(params); diff --git a/module/api/view/create.html.php b/module/api/view/create.html.php index eda21c1102..73a953a1f0 100644 --- a/module/api/view/create.html.php +++ b/module/api/view/create.html.php @@ -186,7 +186,7 @@ js::set('struct_paramsType', $lang->struct->paramsType); api->params;?> - + diff --git a/module/api/view/edit.html.php b/module/api/view/edit.html.php index 54cac85328..5441e6b912 100644 --- a/module/api/view/edit.html.php +++ b/module/api/view/edit.html.php @@ -187,7 +187,7 @@ js::set('api', $api); api->params;?> - + diff --git a/module/api/view/editstruct.html.php b/module/api/view/editstruct.html.php index a07f81d335..553148a5d3 100644 --- a/module/api/view/editstruct.html.php +++ b/module/api/view/editstruct.html.php @@ -48,7 +48,7 @@ js::set('struct', $struct); - +