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 | 1 | <template> |
2 | 2 | <a-card :bordered="false"> |
3 | - <a-row> | |
3 | + <a-row style="margin-top: 20px"> | |
4 | 4 | <a-col :md="2" :sm="4"> |
5 | 5 | <a-select defaultValue="POST" style="width: 90px" @change="handleChange" size="large"> |
6 | 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 | 10 | </a-select> |
9 | 11 | </a-col> |
10 | 12 | <a-col :md="22" :sm="20"> |
... | ... | @@ -19,7 +21,7 @@ |
19 | 21 | |
20 | 22 | <a-tabs defaultActiveKey="2"> |
21 | 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 | 25 | </textarea> |
24 | 26 | </a-tab-pane> |
25 | 27 | </a-tabs> |
... | ... | @@ -33,7 +35,7 @@ |
33 | 35 | </a-card> |
34 | 36 | </template> |
35 | 37 | <script> |
36 | - import { postAction,getAction } from '@/api/manage' | |
38 | + import { axios } from '@/utils/request' | |
37 | 39 | import { ACCESS_TOKEN } from "@/store/mutation-types" |
38 | 40 | import Vue from 'vue' |
39 | 41 | export default { |
... | ... | @@ -49,28 +51,25 @@ |
49 | 51 | methods: { |
50 | 52 | onSearch (value) { |
51 | 53 | let that = this |
54 | + if(!value){ | |
55 | + that.$message.error("请填写路径") | |
56 | + return false | |
57 | + } | |
52 | 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 | 64 | console.log(res) |
56 | 65 | this.resultJson = res |
57 | 66 | }).catch((err) => { |
58 | 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 | 70 | changeVal(e){ |
70 | 71 | try { |
71 | 72 | let json = e.target.value; |
72 | - json = json.replace(/\n/g,""); | |
73 | - json = json.replace(/\s*/g,""); | |
74 | 73 | if(json.indexOf(",}")>0){ |
75 | 74 | json = json.replace(",}","}"); |
76 | 75 | } |
... | ... |