导入swagger
This commit is contained in:
@@ -39,8 +39,16 @@ export function updateApi(data) {
|
||||
// 删除接口
|
||||
export function delApi(id) {
|
||||
return request({
|
||||
url: '/test/api/del/',
|
||||
url: '/test/api/del',
|
||||
method: 'post',
|
||||
params: {id}
|
||||
data: {id}
|
||||
})
|
||||
}
|
||||
|
||||
export function importApi(url) {
|
||||
return request({
|
||||
url: '/test/api/import/swagger',
|
||||
method: 'post',
|
||||
params: url
|
||||
})
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ export default {
|
||||
this.form.header.splice(scope.$index, 1)
|
||||
},
|
||||
cancel() {
|
||||
this.$tab.closeOpenPage({ path: "/api" });
|
||||
this.$tab.closeOpenPage({path: "/api"});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,9 +158,11 @@ export default {
|
||||
::v-deep .el-collapse-item__wrap {
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
::v-deep.el-select {
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
.input-with-select ::v-deep .el-input-group__prepend {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ export default {
|
||||
contentType: this.form.contentType,
|
||||
body: this.form.body,
|
||||
}).then(res => {
|
||||
this.$message.success("新增成功");
|
||||
this.$message.success("修改成功");
|
||||
this.cancel();
|
||||
})
|
||||
},
|
||||
@@ -165,7 +165,7 @@ export default {
|
||||
this.form.header.splice(scope.$index, 1)
|
||||
},
|
||||
cancel() {
|
||||
this.$tab.closeOpenPage({ path: "/api" });
|
||||
this.$tab.closeOpenPage({path: "/api"});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,9 +180,11 @@ export default {
|
||||
::v-deep .el-collapse-item__wrap {
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
::v-deep.el-select {
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
.input-with-select ::v-deep .el-input-group__prepend {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,46 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
import
|
||||
<div>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="swagger" prop="url">
|
||||
<el-input v-model="form.url" placeholder="请输入swagger文档链接"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {importApi} from "@/api/test/api";
|
||||
|
||||
export default {
|
||||
name: "ApiImport",
|
||||
dicts: ['http_method'],
|
||||
created () {
|
||||
console.log(this.$route.query.groupId)
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {}
|
||||
rules: {
|
||||
url: [{required: true, message: "swagger文档链接不能为空", trigger: "blur"}]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
importApi({url: this.form.url}).then((res) => {
|
||||
this.$message.success("导入成功")
|
||||
this.cancel();
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
cancel() {
|
||||
this.$emit('close')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<el-table-column label="接口名称" align="center" prop="name"/>
|
||||
<el-table-column label="接口请求类型" align="center" prop="method"/>
|
||||
<el-table-column label="接口路径" align="center" prop="uri"/>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime"/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
|
||||
@@ -35,18 +36,21 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
|
||||
<el-dialog title="导入接口" :visible.sync="dialogVisible" :close-on-click-modal="false" destroy-on-close>
|
||||
<api-import @close="() => dialogVisible = false"/>
|
||||
</el-dialog>
|
||||
</folder-page>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {listApi, delApi} from "@/api/test/api";
|
||||
import FolderPage from "@/components/FolderPage/index.vue";
|
||||
import ApiImport from "@/views/test/api/import.vue";
|
||||
|
||||
export default {
|
||||
name: "Api",
|
||||
components: {FolderPage},
|
||||
components: {ApiImport, FolderPage},
|
||||
dicts: ['http_method'],
|
||||
data() {
|
||||
return {
|
||||
@@ -62,6 +66,7 @@ export default {
|
||||
method: null,
|
||||
uri: null,
|
||||
},
|
||||
dialogVisible: false,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
@@ -97,7 +102,7 @@ export default {
|
||||
this.$tab.openPage("添加接口", "/api/add", {groupId: this.queryParams.groupId});
|
||||
},
|
||||
handleImport() {
|
||||
this.$tab.openPage("导入接口", "/api/import", {groupId: this.queryParams.groupId});
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
|
||||
Reference in New Issue
Block a user