Commit 5863f00b26fb302ca64bea138908b28ff8d4601b
1 parent
54751428
接口测试支持更多请求方式
Showing
1 changed file
with
15 additions
and
16 deletions
ant-design-vue-jeecg/src/views/jeecg/InterfaceTest.vue
1 | <template> | 1 | <template> |
2 | <a-card :bordered="false"> | 2 | <a-card :bordered="false"> |
3 | - <a-row> | 3 | + <a-row style="margin-top: 20px"> |
4 | <a-col :md="2" :sm="4"> | 4 | <a-col :md="2" :sm="4"> |
5 | <a-select defaultValue="POST" style="width: 90px" @change="handleChange" size="large"> | 5 | <a-select defaultValue="POST" style="width: 90px" @change="handleChange" size="large"> |
6 | <a-select-option value="POST">POST</a-select-option> | 6 | <a-select-option value="POST">POST</a-select-option> |
7 | - <!--<a-select-option value="GET">GET</a-select-option>--> | 7 | + <a-select-option value="GET">GET</a-select-option> |
8 | + <a-select-option value="PUT">PUT</a-select-option> | ||
9 | + <a-select-option value="DELETE">DELETE</a-select-option> | ||
8 | </a-select> | 10 | </a-select> |
9 | </a-col> | 11 | </a-col> |
10 | <a-col :md="22" :sm="20"> | 12 | <a-col :md="22" :sm="20"> |
@@ -19,7 +21,7 @@ | @@ -19,7 +21,7 @@ | ||
19 | 21 | ||
20 | <a-tabs defaultActiveKey="2"> | 22 | <a-tabs defaultActiveKey="2"> |
21 | <a-tab-pane tab="params" key="2"> | 23 | <a-tab-pane tab="params" key="2"> |
22 | - <textarea style="width:100%;font-size: 16px;font-weight:500" :rows="13" @input="changeVal"> | 24 | + <textarea style="width:100%;font-size: 16px;font-weight:500" :rows="13" @blur="changeVal"> |
23 | </textarea> | 25 | </textarea> |
24 | </a-tab-pane> | 26 | </a-tab-pane> |
25 | </a-tabs> | 27 | </a-tabs> |
@@ -33,7 +35,7 @@ | @@ -33,7 +35,7 @@ | ||
33 | </a-card> | 35 | </a-card> |
34 | </template> | 36 | </template> |
35 | <script> | 37 | <script> |
36 | - import { postAction,getAction } from '@/api/manage' | 38 | + import { axios } from '@/utils/request' |
37 | import { ACCESS_TOKEN } from "@/store/mutation-types" | 39 | import { ACCESS_TOKEN } from "@/store/mutation-types" |
38 | import Vue from 'vue' | 40 | import Vue from 'vue' |
39 | export default { | 41 | export default { |
@@ -49,28 +51,25 @@ | @@ -49,28 +51,25 @@ | ||
49 | methods: { | 51 | methods: { |
50 | onSearch (value) { | 52 | onSearch (value) { |
51 | let that = this | 53 | let that = this |
54 | + if(!value){ | ||
55 | + that.$message.error("请填写路径") | ||
56 | + return false | ||
57 | + } | ||
52 | this.resultJson = {}; | 58 | this.resultJson = {}; |
53 | - if("POST"===this.requestMethod.toUpperCase()){ | ||
54 | - postAction(value,this.paramJson).then((res)=>{ | 59 | + axios({ |
60 | + url: value, | ||
61 | + method: this.requestMethod, | ||
62 | + data: this.paramJson | ||
63 | + }).then((res) => { | ||
55 | console.log(res) | 64 | console.log(res) |
56 | this.resultJson = res | 65 | this.resultJson = res |
57 | }).catch((err) => { | 66 | }).catch((err) => { |
58 | that.$message.error("请求异常:"+err) | 67 | that.$message.error("请求异常:"+err) |
59 | }) | 68 | }) |
60 | - }else { | ||
61 | - getAction(value,this.paramJson).then((res)=>{ | ||
62 | - console.log(res) | ||
63 | - this.resultJson = res; | ||
64 | - }).catch((err) => { | ||
65 | - that.$message.error("请求异常:"+err) | ||
66 | - }) | ||
67 | - } | ||
68 | }, | 69 | }, |
69 | changeVal(e){ | 70 | changeVal(e){ |
70 | try { | 71 | try { |
71 | let json = e.target.value; | 72 | let json = e.target.value; |
72 | - json = json.replace(/\n/g,""); | ||
73 | - json = json.replace(/\s*/g,""); | ||
74 | if(json.indexOf(",}")>0){ | 73 | if(json.indexOf(",}")>0){ |
75 | json = json.replace(",}","}"); | 74 | json = json.replace(",}","}"); |
76 | } | 75 | } |