From 79ef20f2de9fa409ef81005df8d08f76d8995749 Mon Sep 17 00:00:00 2001 From: suxiaoxin Date: Tue, 22 Aug 2017 20:44:33 +0800 Subject: [PATCH] fix: add cat bug --- .../InterfaceList/InterfaceEditForm.js | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js b/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js index 81b3c48c..3ba0ff6f 100644 --- a/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js +++ b/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js @@ -51,22 +51,28 @@ class InterfaceEditForm extends Component { path: '', status: 'undone', method: 'get', + req_params: [], + req_query: [{ name: '', desc: '', required: "1" }], - req_body_type: 'form', + req_headers: [{ name: '', value: '', required: "1" }], + + req_body_type: 'form', req_body_form: [{ name: '', type: 'text', required: '1' }], + req_body_other: '', + res_body_type: 'json', res_body: '', desc: '', @@ -83,7 +89,7 @@ class InterfaceEditForm extends Component { if (!err) { if (values.res_body_type === 'json') values.res_body = this.state.res_body; values.req_params = this.state.req_params; - values.req_body_json = this.state.res_body; + values.req_body_other = this.state.req_body_other; values.method = this.state.method; let isfile = false, isHavaContentType = false; if (values.req_body_type === 'form') { @@ -105,6 +111,19 @@ class InterfaceEditForm extends Component { value: isfile ? 'multipart/form-data' : 'application/x-www-form-urlencoded' }) } + }else if(values.req_body_type === 'json'){ + values.req_headers.map((item) => { + if (item.name === 'Content-Type') { + item.value = 'application/json' + isHavaContentType = true; + } + }) + if(isHavaContentType === false){ + values.req_headers.unshift({ + name: 'Content-Type', + value: 'application/json' + }) + } } values.req_headers = values.req_headers ?values.req_headers.filter((item) => item.name !== '') : [] values.req_body_form = values.req_body_form ? values.req_body_form.filter((item) => item.name !== ''): [] @@ -123,11 +142,11 @@ class InterfaceEditForm extends Component { let that = this, mockPreview, resBodyEditor; mockEditor({ container: 'req_body_json', - data: that.state.req_body_json, + data: that.state.req_body_other, onChange: function (d) { if (d.format !== true) return false; that.setState({ - req_body_json: d.text + req_body_other: d.text }) } }) @@ -374,7 +393,7 @@ class InterfaceEditForm extends Component { })} - + { }} style={{ width: '25%' }} /> {getFieldDecorator('path', { @@ -577,9 +596,9 @@ class InterfaceEditForm extends Component { - + );