Commit 8b8b7b74 authored by “yiyousong”'s avatar “yiyousong”

pref:修改新增接口可以搜索限流策略

parent eaa4a276
......@@ -51,7 +51,7 @@
:columns="tableHeaders"
:dataSource="tableSourceData"
>
<template slot="network" slot-scope="text, record, index">
<template slot="network" slot-scope="text">
<span
v-for="(item, idx) of dict.network"
v-show="text.indexOf(idx) != -1"
......@@ -61,7 +61,7 @@
</span>
</template>
<template slot="operation" slot-scope="text, record, index">
<template slot="operation" slot-scope="text, record">
<a-button type="link" @click="openDetails(record)">编辑</a-button>
<a-popconfirm
title="确定要删除此应用吗?"
......
<template>
<a-drawer :destroyOnClose="true" :title="modalInfo.title" :width="modalInfo.width" :visible="modalInfo.visible"
@close="resetForm">
<a-form-model ref="ruleForm" :model="detailsForm" :rules="detailsRules" :label-col="{ span: 4 }"
:wrapper-col="{ span: 20 }">
<a-row :gutter="16">
<a-col :span="12">
<a-form-model-item label="接口名称" prop="interfaceName">
<a-input v-model="detailsForm.interfaceName" placeholder="请输入" allowClear />
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="版本号" prop="versionNumber">
<a-input v-model="detailsForm.versionNumber" placeholder="请输入" allowClear />
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="请求类型" prop="requestType">
<a-select v-model="detailsForm.requestType" placeholder="请选择" allowClear>
<a-select-option value="1"> POST </a-select-option>
<a-select-option value="2"> GET </a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="请求协议" prop="requestProtocol">
<a-select v-model="detailsForm.requestProtocol" placeholder="请选择" allowClear>
<a-select-option value="1"> HTTP </a-select-option>
<a-select-option value="2"> HTTPS </a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-drawer
:destroyOnClose="true"
:title="modalInfo.title"
:width="modalInfo.width"
:visible="modalInfo.visible"
@close="resetForm"
>
<a-form-model
ref="ruleForm"
:model="detailsForm"
:rules="detailsRules"
:label-col="{ span: 4 }"
:wrapper-col="{ span: 20 }"
>
<a-row :gutter="16">
<a-col :span="12">
<a-form-model-item label="接口名称" prop="interfaceName">
<a-input
v-model="detailsForm.interfaceName"
placeholder="请输入"
allowClear
/>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="版本号" prop="versionNumber">
<a-input
v-model="detailsForm.versionNumber"
placeholder="请输入"
allowClear
/>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="请求类型" prop="requestType">
<a-select
v-model="detailsForm.requestType"
placeholder="请选择"
allowClear
>
<a-select-option value="1"> POST </a-select-option>
<a-select-option value="2"> GET </a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="请求协议" prop="requestProtocol">
<a-select
v-model="detailsForm.requestProtocol"
placeholder="请选择"
allowClear
>
<a-select-option value="1"> HTTP </a-select-option>
<a-select-option value="2"> HTTPS </a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="content-type" prop="contentType">
<a-select v-model="detailsForm.contentType" placeholder="请选择" allowClear>
<a-select-option v-for="item, index in ctList" :key="index" :value="item">{{ item
}}</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="超时时长" prop="timeoutValue">
<a-input v-model="detailsForm.timeoutValue" placeholder="请输入" allowClear>
<template slot="suffix"></template>
</a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="限流策略" prop="limitStrategy">
<a-select v-model="detailsForm.limitStrategy" placeholder="请选择" allowClear>
<a-select-option value="1"> 分钟 </a-select-option>
<a-select-option value="2"> 小时 </a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="访问网络" prop="network">
<a-checkbox-group v-model="detailsForm.network" :options="options" />
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="接口标签" prop="interfaceTag">
<a-select v-model="detailsForm.interfaceTag" placeholder="请选择" allowClear>
<a-select-option v-for="(item, index) of dict.interfaceTag" :key="index" :value="index">
{{ item }}
</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="content-type" prop="contentType">
<a-select
v-model="detailsForm.contentType"
placeholder="请选择"
allowClear
>
<a-select-option
v-for="(item, index) in ctList"
:key="index"
:value="item"
>{{ item }}</a-select-option
>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="超时时长" prop="timeoutValue">
<a-input
v-model="detailsForm.timeoutValue"
placeholder="请输入"
allowClear
>
<template slot="suffix"></template>
</a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="限流策略" prop="limitStrategy">
<a-select
v-model="detailsForm.limitStrategy"
placeholder="请选择"
allowClear
showSearch
optionFilterProp="label"
>
<a-select-option value="1" label="分钟"> 分钟 </a-select-option>
<a-select-option value="2" label="小时"> 小时 </a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="访问网络" prop="network">
<a-checkbox-group
v-model="detailsForm.network"
:options="options"
/>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="接口标签" prop="interfaceTag">
<a-select
v-model="detailsForm.interfaceTag"
placeholder="请选择"
allowClear
>
<a-select-option
v-for="(item, index) of dict.interfaceTag"
:key="index"
:value="index"
>
{{ item }}
</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="接口来源" prop="interfaceSource">
<a-select v-model="detailsForm.interfaceSource" placeholder="请选择" allowClear>
<a-select-option value="1"> 自建发布 </a-select-option>
<a-select-option value="2"> 对接转化 </a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="请求路径" prop="requestUrl">
<a-input v-model="detailsForm.requestUrl" placeholder="请输入" allowClear />
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="描述" prop="description">
<a-textarea v-model="detailsForm.description" placeholder="请输入" :rows="4" />
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="接口来源" prop="interfaceSource">
<a-select
v-model="detailsForm.interfaceSource"
placeholder="请选择"
allowClear
>
<a-select-option value="1"> 自建发布 </a-select-option>
<a-select-option value="2"> 对接转化 </a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="请求路径" prop="requestUrl">
<a-input
v-model="detailsForm.requestUrl"
placeholder="请输入"
allowClear
/>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="描述" prop="description">
<a-textarea
v-model="detailsForm.description"
placeholder="请输入"
:rows="4"
/>
</a-form-model-item>
</a-col>
</a-row>
</a-row>
<h1 class="title_">请求参数</h1>
<div class="flex aic jcb mb10">
<a-radio-group
v-model="requestPam.type"
button-style="solid"
@change="onReqType('new')"
>
<a-radio-button value="path"> 路径参数 </a-radio-button>
<a-radio-button value="headers"> headers </a-radio-button>
<a-radio-button value="query"> query </a-radio-button>
<a-radio-button value="body"> body </a-radio-button>
</a-radio-group>
<div class="flex aic">
<div class="mr10">入参是否加密</div>
<a-radio-group v-model="detailsForm.inEncrypt">
<a-radio :value="0">不加密</a-radio>
<a-radio :value="1">加密</a-radio>
</a-radio-group>
</div>
</div>
<h1 class="title_">请求参数</h1>
<div class="flex aic jcb mb10">
<a-radio-group v-model="requestPam.type" button-style="solid" @change="onReqType('new')">
<a-radio-button value="path"> 路径参数 </a-radio-button>
<a-radio-button value="headers"> headers </a-radio-button>
<a-radio-button value="query"> query </a-radio-button>
<a-radio-button value="body"> body </a-radio-button>
</a-radio-group>
<div class="flex aic">
<div class="mr10">入参是否加密</div>
<a-radio-group v-model="detailsForm.inEncrypt">
<a-radio :value="0">不加密</a-radio>
<a-radio :value="1">加密</a-radio>
</a-radio-group>
</div>
</div>
<a-table
size="middle"
bordered
:row-key="(record) => record.id"
:locale="{ emptyText: '无' }"
:pagination="false"
:columns="table_columns"
:dataSource="requestPam.table"
>
<template slot="参数名" slot-scope="text, record">
<a-input v-model="record.name" placeholder="请输入" allowClear />
</template>
<template slot="参数值类型" slot-scope="text, record">
<a-select
v-model="record.type"
placeholder="请选择"
allowClear
:disabled="record.isType"
>
<a-select-option value="String"> String </a-select-option>
<a-select-option value="Int"> Int </a-select-option>
<a-select-option value="Object"> Object </a-select-option>
<a-select-option value="[String]"> [String] </a-select-option>
<a-select-option value="[Int]"> [Int] </a-select-option>
<a-select-option value="[Object]"> [Object] </a-select-option>
</a-select>
</template>
<template slot="默认值" slot-scope="text, record">
<a-input v-model="record.default" placeholder="请输入" allowClear />
</template>
<template slot="是否必填" slot-scope="text, record">
<a-select v-model="record.isMust" placeholder="请选择" allowClear>
<a-select-option value="1"></a-select-option>
<a-select-option value="0"></a-select-option>
</a-select>
</template>
<template slot="描述" slot-scope="text, record">
<a-input v-model="record.describe" placeholder="请输入" allowClear />
</template>
<a-table size="middle" bordered :row-key="(record) => record.id" :locale="{ emptyText: '无' }"
:pagination="false" :columns="table_columns" :dataSource="requestPam.table">
<template slot="参数名" slot-scope="text, record, index">
<a-input v-model="record.name" placeholder="请输入" allowClear />
</template>
<template slot="参数值类型" slot-scope="text, record, index">
<a-select v-model="record.type" placeholder="请选择" allowClear :disabled="record.isType">
<a-select-option value="String"> String </a-select-option>
<a-select-option value="Int"> Int </a-select-option>
<a-select-option value="Object"> Object </a-select-option>
<a-select-option value="[String]"> [String] </a-select-option>
<a-select-option value="[Int]"> [Int] </a-select-option>
<a-select-option value="[Object]"> [Object] </a-select-option>
</a-select>
</template>
<template slot="默认值" slot-scope="text, record, index">
<a-input v-model="record.default" placeholder="请输入" allowClear />
</template>
<template slot="是否必填" slot-scope="text, record, index">
<a-select v-model="record.isMust" placeholder="请选择" allowClear>
<a-select-option value="1"></a-select-option>
<a-select-option value="0"></a-select-option>
</a-select>
</template>
<template slot="描述" slot-scope="text, record, index">
<a-input v-model="record.describe" placeholder="请输入" allowClear />
</template>
<template slot="operation" slot-scope="text, record, index">
<a-button
type="link"
@click="delTabRow('requestPam', index)"
style="color: #ff4420"
>删除</a-button
>
</template>
</a-table>
<div class="table_footer" v-if="requestPam.type != 'path'">
<a-button type="primary" class="addclass" @click="onReqType('add')">
添加参数
</a-button>
</div>
<template slot="operation" slot-scope="text, record, index">
<a-button type="link" @click="delTabRow('requestPam', index)" style="color: #ff4420">删除</a-button>
</template>
</a-table>
<div class="table_footer" v-if="requestPam.type != 'path'">
<a-button type="primary" class="addclass" @click="onReqType('add')"> 添加参数 </a-button>
</div>
<div class="flex aic jcb mt20">
<h1 class="title_">响应数据</h1>
<div class="flex aic">
<div class="mr10">出参是否加密</div>
<a-radio-group v-model="detailsForm.outEncrypt">
<a-radio :value="0">不加密</a-radio>
<a-radio :value="1">加密</a-radio>
</a-radio-group>
</div>
</div>
<div class="flex aic jcb mt20">
<h1 class="title_">响应数据</h1>
<div class="flex aic">
<div class="mr10">出参是否加密</div>
<a-radio-group v-model="detailsForm.outEncrypt">
<a-radio :value="0">不加密</a-radio>
<a-radio :value="1">加密</a-radio>
</a-radio-group>
</div>
</div>
<a-table
size="middle"
bordered
:row-key="(record) => record.id"
:locale="{ emptyText: '无' }"
:pagination="false"
:columns="table_columns"
:dataSource="responsePam.table"
>
<template slot="参数名" slot-scope="text, record">
<a-input v-model="record.name" placeholder="请输入" allowClear />
</template>
<template slot="参数值类型" slot-scope="text, record">
<a-select v-model="record.type" placeholder="请选择" allowClear>
<a-select-option value="String"> String </a-select-option>
<a-select-option value="Int"> Int </a-select-option>
<a-select-option value="Object"> Object </a-select-option>
<a-select-option value="[String]"> [String] </a-select-option>
<a-select-option value="[Int]"> [Int] </a-select-option>
<a-select-option value="[Object]"> [Object] </a-select-option>
</a-select>
</template>
<template slot="默认值" slot-scope="text, record">
<a-input v-model="record.default" placeholder="请输入" allowClear />
</template>
<template slot="是否必填" slot-scope="text, record">
<a-select v-model="record.isMust" placeholder="请选择" allowClear>
<a-select-option value="1"></a-select-option>
<a-select-option value="0"></a-select-option>
</a-select>
</template>
<template slot="描述" slot-scope="text, record">
<a-input v-model="record.describe" placeholder="请输入" allowClear />
</template>
<a-table size="middle" bordered :row-key="(record) => record.id" :locale="{ emptyText: '无' }"
:pagination="false" :columns="table_columns" :dataSource="responsePam.table">
<template slot="参数名" slot-scope="text, record, index">
<a-input v-model="record.name" placeholder="请输入" allowClear />
</template>
<template slot="参数值类型" slot-scope="text, record, index">
<a-select v-model="record.type" placeholder="请选择" allowClear>
<a-select-option value="String"> String </a-select-option>
<a-select-option value="Int"> Int </a-select-option>
<a-select-option value="Object"> Object </a-select-option>
<a-select-option value="[String]"> [String] </a-select-option>
<a-select-option value="[Int]"> [Int] </a-select-option>
<a-select-option value="[Object]"> [Object] </a-select-option>
</a-select>
</template>
<template slot="默认值" slot-scope="text, record, index">
<a-input v-model="record.default" placeholder="请输入" allowClear />
</template>
<template slot="是否必填" slot-scope="text, record, index">
<a-select v-model="record.isMust" placeholder="请选择" allowClear>
<a-select-option value="1"></a-select-option>
<a-select-option value="0"></a-select-option>
</a-select>
</template>
<template slot="描述" slot-scope="text, record, index">
<a-input v-model="record.describe" placeholder="请输入" allowClear />
</template>
<template slot="operation" slot-scope="text, record, index">
<a-button type="link" @click="delTabRow('responsePam', index)" style="color: #ff4420">删除</a-button>
</template>
</a-table>
<div class="table_footer">
<a-button type="primary" class="addclass" @click="addResPam"> 添加参数 </a-button>
</div>
<div class="drawer_footer">
<a-button type="primary" class="addclass" @click="modalSubmit"> 保存 </a-button>
<a-button @click="resetForm"> 取消 </a-button>
</div>
</a-form-model>
</a-drawer>
<template slot="operation" slot-scope="text, record, index">
<a-button
type="link"
@click="delTabRow('responsePam', index)"
style="color: #ff4420"
>删除</a-button
>
</template>
</a-table>
<div class="table_footer">
<a-button type="primary" class="addclass" @click="addResPam">
添加参数
</a-button>
</div>
<div class="drawer_footer">
<a-button type="primary" class="addclass" @click="modalSubmit">
保存
</a-button>
<a-button @click="resetForm"> 取消 </a-button>
</div>
</a-form-model>
</a-drawer>
</template>
<script>
import modal from "../mixins/modal";
import {
getInterfaceSave, getInterfaceInfo
} from '@/api/thePlatformIsSet.js'
import { getInterfaceSave, getInterfaceInfo } from "@/api/thePlatformIsSet.js";
export default {
mixins: [modal],
name: "PortalAdminVuePicWorks",
props: ["dict"],
data() {
return {
detailsForm: {
productId: this.$route.query.id,
interfaceName: undefined,
versionNumber: undefined,
requestType: undefined,
requestProtocol: undefined,
requestUrl: undefined,
timeoutValue: undefined,
timeoutValue: undefined,
network: undefined,
description: undefined,
flowControl: undefined,
authorizeInfo: undefined,
contentType: undefined,
interfaceTag: undefined,
inEncrypt: 0,
outEncrypt: 0
},
detailsRules: {
interfaceName: [{ required: true, message: "请输入", trigger: "blur" }],
versionNumber: [{ required: true, message: "请输入", trigger: "blur" }],
requestType: [{ required: true, message: "请选择", trigger: "change" }],
requestProtocol: [{ required: true, message: "请选择", trigger: "change" }],
requestUrl: [{ required: true, message: "请输入", trigger: "blur" }],
timeoutValue: [{ required: true, message: "请输入", trigger: "blur" }],
},
options: [{
label: "互联网",
value: "1",
},
{
label: "政务网",
value: "2",
},
],
table_columns: [{
title: "参数名",
align: "center",
dataIndex: "name",
scopedSlots: {
customRender: "参数名",
},
},
{
title: "参数值类型",
align: "center",
dataIndex: "type",
scopedSlots: {
customRender: "参数值类型",
},
},
{
title: "默认值",
align: "center",
dataIndex: "default",
scopedSlots: {
customRender: "默认值",
},
},
{
title: "是否必填",
align: "center",
dataIndex: "isMust",
scopedSlots: {
customRender: "是否必填",
},
},
{
title: "描述",
align: "center",
dataIndex: "describe",
scopedSlots: {
customRender: "描述",
},
width: 200
},
mixins: [modal],
name: "PortalAdminVuePicWorks",
props: ["dict"],
data() {
return {
detailsForm: {
productId: this.$route.query.id,
interfaceName: undefined,
versionNumber: undefined,
requestType: undefined,
requestProtocol: undefined,
requestUrl: undefined,
timeoutValue: undefined,
timeoutValue: undefined,
network: undefined,
description: undefined,
flowControl: undefined,
authorizeInfo: undefined,
contentType: undefined,
interfaceTag: undefined,
inEncrypt: 0,
outEncrypt: 0,
},
detailsRules: {
interfaceName: [{ required: true, message: "请输入", trigger: "blur" }],
versionNumber: [{ required: true, message: "请输入", trigger: "blur" }],
requestType: [{ required: true, message: "请选择", trigger: "change" }],
requestProtocol: [
{ required: true, message: "请选择", trigger: "change" },
],
requestUrl: [{ required: true, message: "请输入", trigger: "blur" }],
timeoutValue: [{ required: true, message: "请输入", trigger: "blur" }],
},
options: [
{
label: "互联网",
value: "1",
},
{
label: "政务网",
value: "2",
},
],
table_columns: [
{
title: "参数名",
align: "center",
dataIndex: "name",
scopedSlots: {
customRender: "参数名",
},
},
{
title: "参数值类型",
align: "center",
dataIndex: "type",
scopedSlots: {
customRender: "参数值类型",
},
},
{
title: "默认值",
align: "center",
dataIndex: "default",
scopedSlots: {
customRender: "默认值",
},
},
{
title: "是否必填",
align: "center",
dataIndex: "isMust",
scopedSlots: {
customRender: "是否必填",
},
},
{
title: "描述",
align: "center",
dataIndex: "describe",
scopedSlots: {
customRender: "描述",
},
width: 200,
},
{
title: "操作",
align: "center",
width: "60px",
dataIndex: "operation",
scopedSlots: {
customRender: "operation",
},
},
],
requestPam: {
type: 'path',
table: []
},
responsePam: {
table: [{
name: ``,
type: undefined,
default: ``,
isMust: undefined,
describe: ``,
}]
},
errorCode_columns: [{
title: "Http Code",
align: "center",
dataIndex: "httpCode",
scopedSlots: {
customRender: "Http Code",
}
},
{
title: "Error Code",
align: "center",
dataIndex: "errorCode",
scopedSlots: {
customRender: "Error Code",
},
},
{
title: "错误信息",
align: "center",
dataIndex: "errorMessage",
scopedSlots: {
customRender: "错误信息",
},
},
{
title: "操作",
align: "center",
width: "60px",
dataIndex: "operation",
scopedSlots: {
customRender: "operation",
},
}
],
errorCode: [{
httpCode: ``,
errorCode: ``,
errorMessage: ``
}],
changeHistory_columns: [{
title: "变更时间",
align: "center",
dataIndex: "time",
scopedSlots: {
customRender: "变更时间",
}
},
{
title: "变更内容概要",
align: "center",
dataIndex: "content",
scopedSlots: {
customRender: "变更内容概要",
},
}
],
changeHistory: [{
time: '',
content: ''
}],
ctList: ["text/html", "text/xml", "application/json", "application/xml", "application/x-www-form-urlencoded", "multipart/form-data"]
};
},
{
title: "操作",
align: "center",
width: "60px",
dataIndex: "operation",
scopedSlots: {
customRender: "operation",
},
},
],
requestPam: {
type: "path",
table: [],
},
responsePam: {
table: [
{
name: ``,
type: undefined,
default: ``,
isMust: undefined,
describe: ``,
},
],
},
errorCode_columns: [
{
title: "Http Code",
align: "center",
dataIndex: "httpCode",
scopedSlots: {
customRender: "Http Code",
},
},
{
title: "Error Code",
align: "center",
dataIndex: "errorCode",
scopedSlots: {
customRender: "Error Code",
},
},
{
title: "错误信息",
align: "center",
dataIndex: "errorMessage",
scopedSlots: {
customRender: "错误信息",
},
},
{
title: "操作",
align: "center",
width: "60px",
dataIndex: "operation",
scopedSlots: {
customRender: "operation",
},
},
],
errorCode: [
{
httpCode: ``,
errorCode: ``,
errorMessage: ``,
},
],
changeHistory_columns: [
{
title: "变更时间",
align: "center",
dataIndex: "time",
scopedSlots: {
customRender: "变更时间",
},
},
{
title: "变更内容概要",
align: "center",
dataIndex: "content",
scopedSlots: {
customRender: "变更内容概要",
},
},
],
changeHistory: [
{
time: "",
content: "",
},
],
ctList: [
"text/html",
"text/xml",
"application/json",
"application/xml",
"application/x-www-form-urlencoded",
"multipart/form-data",
],
};
},
mounted() { },
mounted() {},
methods: {
getInfo(id) {
getInterfaceInfo({ id: id }).then(res => {
res.data.network = res.data.network.split(',')
this.detailsForm = res.data
this.requestPam = JSON.parse(res.data.requestParameters)
this.responsePam = JSON.parse(res.data.responseParameters)
})
},
modalSubmit() {
this.$refs.ruleForm.validate(valid => {
if (valid) {
let json = JSON.parse(JSON.stringify(this.detailsForm))
if (json.network.length) json.network = json.network.join(',')
json.requestParameters = JSON.stringify(this.requestPam)
json.responseParameters = JSON.stringify(this.responsePam)
getInterfaceSave(json).then(res => {
let { code, msg } = res
if (code == 1) {
this.$message.success('保存成功');
this.resetForm();
this.modalInfo.visible = false
this.$parent.getList()
} else {
this.$message.error(msg);
}
})
} else {
return false;
}
});
},
//type
onReqType(type) {
let index = this.requestPam.type
if (index == 'path') {
this.requestPam.table = []
} else {
let obj = {
name: ``,
type: 'String',
default: ``,
isMust: undefined,
describe: ``,
isType: true
}
if (index == 'body') {
obj.isType = false
}
if (type == 'new') {
this.requestPam.table = [obj]
} else {
this.requestPam.table.push(obj)
}
}
},
addResPam() {
this.responsePam.table.push({
name: ``,
type: undefined,
default: ``,
isMust: undefined,
describe: ``,
})
},
delTabRow(key, index) {
this[key].table.splice(index, 1)
},
resetForm() {
this.$nextTick(() => {
this.$refs.ruleForm.resetFields();
this.detailsForm.id=""
this.requestPam = {
type: 'path',
table: []
}
this.responsePam = {
table: [{
name: ``,
type: undefined,
default: ``,
isMust: undefined,
describe: ``,
}]
}
this.modalInfo.visible = false;
});
}
},
methods: {
getInfo(id) {
getInterfaceInfo({ id: id }).then((res) => {
res.data.network = res.data.network.split(",");
this.detailsForm = res.data;
this.requestPam = JSON.parse(res.data.requestParameters);
this.responsePam = JSON.parse(res.data.responseParameters);
});
},
modalSubmit() {
this.$refs.ruleForm.validate((valid) => {
if (valid) {
let json = JSON.parse(JSON.stringify(this.detailsForm));
if (json.network.length) json.network = json.network.join(",");
json.requestParameters = JSON.stringify(this.requestPam);
json.responseParameters = JSON.stringify(this.responsePam);
getInterfaceSave(json).then((res) => {
let { code, msg } = res;
if (code == 1) {
this.$message.success("保存成功");
this.resetForm();
this.modalInfo.visible = false;
this.$parent.getList();
} else {
this.$message.error(msg);
}
});
} else {
return false;
}
});
},
//type
onReqType(type) {
let index = this.requestPam.type;
if (index == "path") {
this.requestPam.table = [];
} else {
let obj = {
name: ``,
type: "String",
default: ``,
isMust: undefined,
describe: ``,
isType: true,
};
if (index == "body") {
obj.isType = false;
}
if (type == "new") {
this.requestPam.table = [obj];
} else {
this.requestPam.table.push(obj);
}
}
},
addResPam() {
this.responsePam.table.push({
name: ``,
type: undefined,
default: ``,
isMust: undefined,
describe: ``,
});
},
delTabRow(key, index) {
this[key].table.splice(index, 1);
},
resetForm() {
this.$nextTick(() => {
this.$refs.ruleForm.resetFields();
this.detailsForm.id = "";
this.requestPam = {
type: "path",
table: [],
};
this.responsePam = {
table: [
{
name: ``,
type: undefined,
default: ``,
isMust: undefined,
describe: ``,
},
],
};
this.modalInfo.visible = false;
});
},
},
};
</script>
<style lang="less" scoped>
/deep/.ant-drawer-content {
overflow-x: hidden !important;
overflow-x: hidden !important;
}
.drawer_footer {
z-index: 1;
text-align: left;
background: #fff;
padding: 10px 16px;
border-top: 1px solid #e9e9e9;
width: 100%;
bottom: 0;
right: 0;
position: absolute;
z-index: 1;
text-align: left;
background: #fff;
padding: 10px 16px;
border-top: 1px solid #e9e9e9;
width: 100%;
bottom: 0;
right: 0;
position: absolute;
}
.title_ {
font-size: 16px;
font-weight: bold;
color: #333;
margin-bottom: 10px;
font-size: 16px;
font-weight: bold;
color: #333;
margin-bottom: 10px;
}
.table_footer {
text-align: center;
padding-top: 10px;
text-align: center;
padding-top: 10px;
}
/deep/.ant-drawer-body {
margin-bottom: 100px;
margin-bottom: 100px;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment