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

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

parent eaa4a276
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
:columns="tableHeaders" :columns="tableHeaders"
:dataSource="tableSourceData" :dataSource="tableSourceData"
> >
<template slot="network" slot-scope="text, record, index"> <template slot="network" slot-scope="text">
<span <span
v-for="(item, idx) of dict.network" v-for="(item, idx) of dict.network"
v-show="text.indexOf(idx) != -1" v-show="text.indexOf(idx) != -1"
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
</span> </span>
</template> </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-button type="link" @click="openDetails(record)">编辑</a-button>
<a-popconfirm <a-popconfirm
title="确定要删除此应用吗?" title="确定要删除此应用吗?"
......
<template> <template>
<a-drawer :destroyOnClose="true" :title="modalInfo.title" :width="modalInfo.width" :visible="modalInfo.visible" <a-drawer
@close="resetForm"> :destroyOnClose="true"
<a-form-model ref="ruleForm" :model="detailsForm" :rules="detailsRules" :label-col="{ span: 4 }" :title="modalInfo.title"
:wrapper-col="{ span: 20 }"> :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-row :gutter="16">
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="接口名称" prop="interfaceName"> <a-form-model-item label="接口名称" prop="interfaceName">
<a-input v-model="detailsForm.interfaceName" placeholder="请输入" allowClear /> <a-input
v-model="detailsForm.interfaceName"
placeholder="请输入"
allowClear
/>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="版本号" prop="versionNumber"> <a-form-model-item label="版本号" prop="versionNumber">
<a-input v-model="detailsForm.versionNumber" placeholder="请输入" allowClear /> <a-input
v-model="detailsForm.versionNumber"
placeholder="请输入"
allowClear
/>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="请求类型" prop="requestType"> <a-form-model-item label="请求类型" prop="requestType">
<a-select v-model="detailsForm.requestType" placeholder="请选择" allowClear> <a-select
v-model="detailsForm.requestType"
placeholder="请选择"
allowClear
>
<a-select-option value="1"> POST </a-select-option> <a-select-option value="1"> POST </a-select-option>
<a-select-option value="2"> GET </a-select-option> <a-select-option value="2"> GET </a-select-option>
</a-select> </a-select>
...@@ -24,7 +46,11 @@ ...@@ -24,7 +46,11 @@
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="请求协议" prop="requestProtocol"> <a-form-model-item label="请求协议" prop="requestProtocol">
<a-select v-model="detailsForm.requestProtocol" placeholder="请选择" allowClear> <a-select
v-model="detailsForm.requestProtocol"
placeholder="请选择"
allowClear
>
<a-select-option value="1"> HTTP </a-select-option> <a-select-option value="1"> HTTP </a-select-option>
<a-select-option value="2"> HTTPS </a-select-option> <a-select-option value="2"> HTTPS </a-select-option>
</a-select> </a-select>
...@@ -33,36 +59,65 @@ ...@@ -33,36 +59,65 @@
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="content-type" prop="contentType"> <a-form-model-item label="content-type" prop="contentType">
<a-select v-model="detailsForm.contentType" placeholder="请选择" allowClear> <a-select
<a-select-option v-for="item, index in ctList" :key="index" :value="item">{{ item v-model="detailsForm.contentType"
}}</a-select-option> placeholder="请选择"
allowClear
>
<a-select-option
v-for="(item, index) in ctList"
:key="index"
:value="item"
>{{ item }}</a-select-option
>
</a-select> </a-select>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="超时时长" prop="timeoutValue"> <a-form-model-item label="超时时长" prop="timeoutValue">
<a-input v-model="detailsForm.timeoutValue" placeholder="请输入" allowClear> <a-input
v-model="detailsForm.timeoutValue"
placeholder="请输入"
allowClear
>
<template slot="suffix"></template> <template slot="suffix"></template>
</a-input> </a-input>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="限流策略" prop="limitStrategy"> <a-form-model-item label="限流策略" prop="limitStrategy">
<a-select v-model="detailsForm.limitStrategy" placeholder="请选择" allowClear> <a-select
<a-select-option value="1"> 分钟 </a-select-option> v-model="detailsForm.limitStrategy"
<a-select-option value="2"> 小时 </a-select-option> 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-select>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="访问网络" prop="network"> <a-form-model-item label="访问网络" prop="network">
<a-checkbox-group v-model="detailsForm.network" :options="options" /> <a-checkbox-group
v-model="detailsForm.network"
:options="options"
/>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="接口标签" prop="interfaceTag"> <a-form-model-item label="接口标签" prop="interfaceTag">
<a-select v-model="detailsForm.interfaceTag" placeholder="请选择" allowClear> <a-select
<a-select-option v-for="(item, index) of dict.interfaceTag" :key="index" :value="index"> v-model="detailsForm.interfaceTag"
placeholder="请选择"
allowClear
>
<a-select-option
v-for="(item, index) of dict.interfaceTag"
:key="index"
:value="index"
>
{{ item }} {{ item }}
</a-select-option> </a-select-option>
</a-select> </a-select>
...@@ -71,7 +126,11 @@ ...@@ -71,7 +126,11 @@
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="接口来源" prop="interfaceSource"> <a-form-model-item label="接口来源" prop="interfaceSource">
<a-select v-model="detailsForm.interfaceSource" placeholder="请选择" allowClear> <a-select
v-model="detailsForm.interfaceSource"
placeholder="请选择"
allowClear
>
<a-select-option value="1"> 自建发布 </a-select-option> <a-select-option value="1"> 自建发布 </a-select-option>
<a-select-option value="2"> 对接转化 </a-select-option> <a-select-option value="2"> 对接转化 </a-select-option>
</a-select> </a-select>
...@@ -79,20 +138,31 @@ ...@@ -79,20 +138,31 @@
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="请求路径" prop="requestUrl"> <a-form-model-item label="请求路径" prop="requestUrl">
<a-input v-model="detailsForm.requestUrl" placeholder="请输入" allowClear /> <a-input
v-model="detailsForm.requestUrl"
placeholder="请输入"
allowClear
/>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-model-item label="描述" prop="description"> <a-form-model-item label="描述" prop="description">
<a-textarea v-model="detailsForm.description" placeholder="请输入" :rows="4" /> <a-textarea
v-model="detailsForm.description"
placeholder="请输入"
:rows="4"
/>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
</a-row> </a-row>
<h1 class="title_">请求参数</h1> <h1 class="title_">请求参数</h1>
<div class="flex aic jcb mb10"> <div class="flex aic jcb mb10">
<a-radio-group v-model="requestPam.type" button-style="solid" @change="onReqType('new')"> <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="path"> 路径参数 </a-radio-button>
<a-radio-button value="headers"> headers </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="query"> query </a-radio-button>
...@@ -107,13 +177,25 @@ ...@@ -107,13 +177,25 @@
</div> </div>
</div> </div>
<a-table size="middle" bordered :row-key="(record) => record.id" :locale="{ emptyText: '无' }" <a-table
:pagination="false" :columns="table_columns" :dataSource="requestPam.table"> size="middle"
<template slot="参数名" slot-scope="text, record, index"> 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 /> <a-input v-model="record.name" placeholder="请输入" allowClear />
</template> </template>
<template slot="参数值类型" slot-scope="text, record, index"> <template slot="参数值类型" slot-scope="text, record">
<a-select v-model="record.type" placeholder="请选择" allowClear :disabled="record.isType"> <a-select
v-model="record.type"
placeholder="请选择"
allowClear
:disabled="record.isType"
>
<a-select-option value="String"> String </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="Int"> Int </a-select-option>
<a-select-option value="Object"> Object </a-select-option> <a-select-option value="Object"> Object </a-select-option>
...@@ -122,25 +204,32 @@ ...@@ -122,25 +204,32 @@
<a-select-option value="[Object]"> [Object] </a-select-option> <a-select-option value="[Object]"> [Object] </a-select-option>
</a-select> </a-select>
</template> </template>
<template slot="默认值" slot-scope="text, record, index"> <template slot="默认值" slot-scope="text, record">
<a-input v-model="record.default" placeholder="请输入" allowClear /> <a-input v-model="record.default" placeholder="请输入" allowClear />
</template> </template>
<template slot="是否必填" slot-scope="text, record, index"> <template slot="是否必填" slot-scope="text, record">
<a-select v-model="record.isMust" placeholder="请选择" allowClear> <a-select v-model="record.isMust" placeholder="请选择" allowClear>
<a-select-option value="1"></a-select-option> <a-select-option value="1"></a-select-option>
<a-select-option value="0"></a-select-option> <a-select-option value="0"></a-select-option>
</a-select> </a-select>
</template> </template>
<template slot="描述" slot-scope="text, record, index"> <template slot="描述" slot-scope="text, record">
<a-input v-model="record.describe" placeholder="请输入" allowClear /> <a-input v-model="record.describe" placeholder="请输入" allowClear />
</template> </template>
<template slot="operation" slot-scope="text, record, index"> <template slot="operation" slot-scope="text, record, index">
<a-button type="link" @click="delTabRow('requestPam', index)" style="color: #ff4420">删除</a-button> <a-button
type="link"
@click="delTabRow('requestPam', index)"
style="color: #ff4420"
>删除</a-button
>
</template> </template>
</a-table> </a-table>
<div class="table_footer" v-if="requestPam.type != 'path'"> <div class="table_footer" v-if="requestPam.type != 'path'">
<a-button type="primary" class="addclass" @click="onReqType('add')"> 添加参数 </a-button> <a-button type="primary" class="addclass" @click="onReqType('add')">
添加参数
</a-button>
</div> </div>
<div class="flex aic jcb mt20"> <div class="flex aic jcb mt20">
...@@ -154,12 +243,19 @@ ...@@ -154,12 +243,19 @@
</div> </div>
</div> </div>
<a-table size="middle" bordered :row-key="(record) => record.id" :locale="{ emptyText: '无' }" <a-table
:pagination="false" :columns="table_columns" :dataSource="responsePam.table"> size="middle"
<template slot="参数名" slot-scope="text, record, index"> 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 /> <a-input v-model="record.name" placeholder="请输入" allowClear />
</template> </template>
<template slot="参数值类型" slot-scope="text, record, index"> <template slot="参数值类型" slot-scope="text, record">
<a-select v-model="record.type" placeholder="请选择" allowClear> <a-select v-model="record.type" placeholder="请选择" allowClear>
<a-select-option value="String"> String </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="Int"> Int </a-select-option>
...@@ -169,28 +265,37 @@ ...@@ -169,28 +265,37 @@
<a-select-option value="[Object]"> [Object] </a-select-option> <a-select-option value="[Object]"> [Object] </a-select-option>
</a-select> </a-select>
</template> </template>
<template slot="默认值" slot-scope="text, record, index"> <template slot="默认值" slot-scope="text, record">
<a-input v-model="record.default" placeholder="请输入" allowClear /> <a-input v-model="record.default" placeholder="请输入" allowClear />
</template> </template>
<template slot="是否必填" slot-scope="text, record, index"> <template slot="是否必填" slot-scope="text, record">
<a-select v-model="record.isMust" placeholder="请选择" allowClear> <a-select v-model="record.isMust" placeholder="请选择" allowClear>
<a-select-option value="1"></a-select-option> <a-select-option value="1"></a-select-option>
<a-select-option value="0"></a-select-option> <a-select-option value="0"></a-select-option>
</a-select> </a-select>
</template> </template>
<template slot="描述" slot-scope="text, record, index"> <template slot="描述" slot-scope="text, record">
<a-input v-model="record.describe" placeholder="请输入" allowClear /> <a-input v-model="record.describe" placeholder="请输入" allowClear />
</template> </template>
<template slot="operation" slot-scope="text, record, index"> <template slot="operation" slot-scope="text, record, index">
<a-button type="link" @click="delTabRow('responsePam', index)" style="color: #ff4420">删除</a-button> <a-button
type="link"
@click="delTabRow('responsePam', index)"
style="color: #ff4420"
>删除</a-button
>
</template> </template>
</a-table> </a-table>
<div class="table_footer"> <div class="table_footer">
<a-button type="primary" class="addclass" @click="addResPam"> 添加参数 </a-button> <a-button type="primary" class="addclass" @click="addResPam">
添加参数
</a-button>
</div> </div>
<div class="drawer_footer"> <div class="drawer_footer">
<a-button type="primary" class="addclass" @click="modalSubmit"> 保存 </a-button> <a-button type="primary" class="addclass" @click="modalSubmit">
保存
</a-button>
<a-button @click="resetForm"> 取消 </a-button> <a-button @click="resetForm"> 取消 </a-button>
</div> </div>
</a-form-model> </a-form-model>
...@@ -199,9 +304,7 @@ ...@@ -199,9 +304,7 @@
<script> <script>
import modal from "../mixins/modal"; import modal from "../mixins/modal";
import { import { getInterfaceSave, getInterfaceInfo } from "@/api/thePlatformIsSet.js";
getInterfaceSave, getInterfaceInfo
} from '@/api/thePlatformIsSet.js'
export default { export default {
mixins: [modal], mixins: [modal],
name: "PortalAdminVuePicWorks", name: "PortalAdminVuePicWorks",
...@@ -224,17 +327,20 @@ export default { ...@@ -224,17 +327,20 @@ export default {
contentType: undefined, contentType: undefined,
interfaceTag: undefined, interfaceTag: undefined,
inEncrypt: 0, inEncrypt: 0,
outEncrypt: 0 outEncrypt: 0,
}, },
detailsRules: { detailsRules: {
interfaceName: [{ required: true, message: "请输入", trigger: "blur" }], interfaceName: [{ required: true, message: "请输入", trigger: "blur" }],
versionNumber: [{ required: true, message: "请输入", trigger: "blur" }], versionNumber: [{ required: true, message: "请输入", trigger: "blur" }],
requestType: [{ required: true, message: "请选择", trigger: "change" }], requestType: [{ required: true, message: "请选择", trigger: "change" }],
requestProtocol: [{ required: true, message: "请选择", trigger: "change" }], requestProtocol: [
{ required: true, message: "请选择", trigger: "change" },
],
requestUrl: [{ required: true, message: "请输入", trigger: "blur" }], requestUrl: [{ required: true, message: "请输入", trigger: "blur" }],
timeoutValue: [{ required: true, message: "请输入", trigger: "blur" }], timeoutValue: [{ required: true, message: "请输入", trigger: "blur" }],
}, },
options: [{ options: [
{
label: "互联网", label: "互联网",
value: "1", value: "1",
}, },
...@@ -243,7 +349,8 @@ export default { ...@@ -243,7 +349,8 @@ export default {
value: "2", value: "2",
}, },
], ],
table_columns: [{ table_columns: [
{
title: "参数名", title: "参数名",
align: "center", align: "center",
dataIndex: "name", dataIndex: "name",
...@@ -282,7 +389,7 @@ export default { ...@@ -282,7 +389,7 @@ export default {
scopedSlots: { scopedSlots: {
customRender: "描述", customRender: "描述",
}, },
width: 200 width: 200,
}, },
{ {
...@@ -296,25 +403,28 @@ export default { ...@@ -296,25 +403,28 @@ export default {
}, },
], ],
requestPam: { requestPam: {
type: 'path', type: "path",
table: [] table: [],
}, },
responsePam: { responsePam: {
table: [{ table: [
{
name: ``, name: ``,
type: undefined, type: undefined,
default: ``, default: ``,
isMust: undefined, isMust: undefined,
describe: ``, describe: ``,
}]
}, },
errorCode_columns: [{ ],
},
errorCode_columns: [
{
title: "Http Code", title: "Http Code",
align: "center", align: "center",
dataIndex: "httpCode", dataIndex: "httpCode",
scopedSlots: { scopedSlots: {
customRender: "Http Code", customRender: "Http Code",
} },
}, },
{ {
title: "Error Code", title: "Error Code",
...@@ -340,20 +450,23 @@ export default { ...@@ -340,20 +450,23 @@ export default {
scopedSlots: { scopedSlots: {
customRender: "operation", customRender: "operation",
}, },
} },
], ],
errorCode: [{ errorCode: [
{
httpCode: ``, httpCode: ``,
errorCode: ``, errorCode: ``,
errorMessage: `` errorMessage: ``,
}], },
changeHistory_columns: [{ ],
changeHistory_columns: [
{
title: "变更时间", title: "变更时间",
align: "center", align: "center",
dataIndex: "time", dataIndex: "time",
scopedSlots: { scopedSlots: {
customRender: "变更时间", customRender: "变更时间",
} },
}, },
{ {
title: "变更内容概要", title: "变更内容概要",
...@@ -362,45 +475,54 @@ export default { ...@@ -362,45 +475,54 @@ export default {
scopedSlots: { scopedSlots: {
customRender: "变更内容概要", customRender: "变更内容概要",
}, },
} },
],
changeHistory: [
{
time: "",
content: "",
},
],
ctList: [
"text/html",
"text/xml",
"application/json",
"application/xml",
"application/x-www-form-urlencoded",
"multipart/form-data",
], ],
changeHistory: [{
time: '',
content: ''
}],
ctList: ["text/html", "text/xml", "application/json", "application/xml", "application/x-www-form-urlencoded", "multipart/form-data"]
}; };
}, },
mounted() { }, mounted() {},
methods: { methods: {
getInfo(id) { getInfo(id) {
getInterfaceInfo({ id: id }).then(res => { getInterfaceInfo({ id: id }).then((res) => {
res.data.network = res.data.network.split(',') res.data.network = res.data.network.split(",");
this.detailsForm = res.data this.detailsForm = res.data;
this.requestPam = JSON.parse(res.data.requestParameters) this.requestPam = JSON.parse(res.data.requestParameters);
this.responsePam = JSON.parse(res.data.responseParameters) this.responsePam = JSON.parse(res.data.responseParameters);
}) });
}, },
modalSubmit() { modalSubmit() {
this.$refs.ruleForm.validate(valid => { this.$refs.ruleForm.validate((valid) => {
if (valid) { if (valid) {
let json = JSON.parse(JSON.stringify(this.detailsForm)) let json = JSON.parse(JSON.stringify(this.detailsForm));
if (json.network.length) json.network = json.network.join(',') if (json.network.length) json.network = json.network.join(",");
json.requestParameters = JSON.stringify(this.requestPam) json.requestParameters = JSON.stringify(this.requestPam);
json.responseParameters = JSON.stringify(this.responsePam) json.responseParameters = JSON.stringify(this.responsePam);
getInterfaceSave(json).then(res => { getInterfaceSave(json).then((res) => {
let { code, msg } = res let { code, msg } = res;
if (code == 1) { if (code == 1) {
this.$message.success('保存成功'); this.$message.success("保存成功");
this.resetForm(); this.resetForm();
this.modalInfo.visible = false this.modalInfo.visible = false;
this.$parent.getList() this.$parent.getList();
} else { } else {
this.$message.error(msg); this.$message.error(msg);
} }
}) });
} else { } else {
return false; return false;
} }
...@@ -408,25 +530,25 @@ export default { ...@@ -408,25 +530,25 @@ export default {
}, },
//type //type
onReqType(type) { onReqType(type) {
let index = this.requestPam.type let index = this.requestPam.type;
if (index == 'path') { if (index == "path") {
this.requestPam.table = [] this.requestPam.table = [];
} else { } else {
let obj = { let obj = {
name: ``, name: ``,
type: 'String', type: "String",
default: ``, default: ``,
isMust: undefined, isMust: undefined,
describe: ``, describe: ``,
isType: true isType: true,
} };
if (index == 'body') { if (index == "body") {
obj.isType = false obj.isType = false;
} }
if (type == 'new') { if (type == "new") {
this.requestPam.table = [obj] this.requestPam.table = [obj];
} else { } else {
this.requestPam.table.push(obj) this.requestPam.table.push(obj);
} }
} }
}, },
...@@ -437,31 +559,33 @@ export default { ...@@ -437,31 +559,33 @@ export default {
default: ``, default: ``,
isMust: undefined, isMust: undefined,
describe: ``, describe: ``,
}) });
}, },
delTabRow(key, index) { delTabRow(key, index) {
this[key].table.splice(index, 1) this[key].table.splice(index, 1);
}, },
resetForm() { resetForm() {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.ruleForm.resetFields(); this.$refs.ruleForm.resetFields();
this.detailsForm.id="" this.detailsForm.id = "";
this.requestPam = { this.requestPam = {
type: 'path', type: "path",
table: [] table: [],
} };
this.responsePam = { this.responsePam = {
table: [{ table: [
{
name: ``, name: ``,
type: undefined, type: undefined,
default: ``, default: ``,
isMust: undefined, isMust: undefined,
describe: ``, describe: ``,
}] },
} ],
};
this.modalInfo.visible = false; this.modalInfo.visible = false;
}); });
} },
}, },
}; };
</script> </script>
......
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