|
@@ -15,32 +15,32 @@
|
|
|
required
|
|
|
label="数据服务名称"
|
|
|
label-width="120px"
|
|
|
- v-model:param="state.form.themeName"
|
|
|
+ v-model:param="state.form.serviceName"
|
|
|
/>
|
|
|
<CusFormColumn
|
|
|
:span="8"
|
|
|
required
|
|
|
label="归属插件"
|
|
|
- v-model:param="state.form.themeType"
|
|
|
+ v-model:param="state.form.affiliationPlugin"
|
|
|
link="select"
|
|
|
- :options="DictionaryStore.themeTypeList"
|
|
|
+ :options="DictionaryStore.gsPlugList"
|
|
|
+ @change="onChangeGsPlug"
|
|
|
/>
|
|
|
<CusFormColumn
|
|
|
:span="8"
|
|
|
required
|
|
|
label="插件类型"
|
|
|
- v-model:param="state.form.themeState"
|
|
|
- link="select"
|
|
|
- :options="DictionaryStore.themeStatusList"
|
|
|
+ v-model:param="state.form.pluginType"
|
|
|
:disabled="true"
|
|
|
/>
|
|
|
<CusFormColumn
|
|
|
+ v-if="state.form.pluginType === 'http'"
|
|
|
:span="24"
|
|
|
required
|
|
|
- v-model:param="state.form.themeName"
|
|
|
+ v-model:param="state.form.requestUrl"
|
|
|
>
|
|
|
<template #prepend>
|
|
|
- <el-select v-model="state.form.xx" placeholder="Select" style="width: 115px">
|
|
|
+ <el-select v-model="state.form.requestType" placeholder="请求类型" style="width: 115px">
|
|
|
<template v-for="item in DictionaryStore.requestTypeList">
|
|
|
<el-option :label="item.dictLabel" :value="item.dictValue" />
|
|
|
</template>
|
|
@@ -48,7 +48,15 @@
|
|
|
</template>
|
|
|
</CusFormColumn>
|
|
|
</CusForm>
|
|
|
- <CusTab :tabs="state.params.options" type="type1" v-model:param="state.params.tab"/>
|
|
|
+ <CusTab :tabs="state.form.pluginType === 'http' ? [
|
|
|
+ {name: 'Request Params', value: 1},
|
|
|
+ {name: 'Request Headers', value: 2},
|
|
|
+ {name: 'Request Body', value: 3},
|
|
|
+ {name: 'Response Body', value: 4},
|
|
|
+ ] : [
|
|
|
+ {name: 'Request Params', value: 1},
|
|
|
+ {name: 'Response Body', value: 4},
|
|
|
+ ]" type="type1" v-model:param="state.params.tab"/>
|
|
|
<div class="params-content">
|
|
|
<template v-if="state.params.tab == 1">
|
|
|
<div class="request-params">
|
|
@@ -93,7 +101,7 @@
|
|
|
/>
|
|
|
</template>
|
|
|
<template #do-column-value="{scope}">
|
|
|
- <CusButton v-if="state.params.requestParams.data.length > 1" type="table-del" @click="state.params.requestParams.data.splice(scope.$index, 1)"/>
|
|
|
+ <CusButton type="table-del" @click="state.params.requestParams.data.splice(scope.$index, 1)"/>
|
|
|
</template>
|
|
|
</CusTable>
|
|
|
</div>
|
|
@@ -141,7 +149,7 @@
|
|
|
/>
|
|
|
</template>
|
|
|
<template #do-column-value="{scope}">
|
|
|
- <CusButton v-if="state.params.requestHeaders.data.length > 1" type="table-del" @click="state.params.requestHeaders.data.splice(scope.$index, 1)"/>
|
|
|
+ <CusButton type="table-del" @click="state.params.requestHeaders.data.splice(scope.$index, 1)"/>
|
|
|
</template>
|
|
|
</CusTable>
|
|
|
</div>
|
|
@@ -153,7 +161,7 @@
|
|
|
:span="24"
|
|
|
v-model:param="state.params.requestBody.type"
|
|
|
link="radio"
|
|
|
- :options="DictionaryStore.RequestBodyList"
|
|
|
+ :options="DictionaryStore.requestBodyList"
|
|
|
@change="onChangeRequestBodyType"
|
|
|
/>
|
|
|
<CusFormColumn
|
|
@@ -182,6 +190,9 @@
|
|
|
<div style="margin-bottom: 10px; display: flex">
|
|
|
<CusButton type="main" title="新增" style="margin-right: auto;" @click="state.params.requestBody.data.push({key: '', type: '1', value: '', valueTable: []})"/>
|
|
|
<template v-if="['RAW_JSON', 'RAW_TEXT', 'RAW_XML', 'RAW_HTML'].includes(state.params.requestBody.type)">
|
|
|
+ <div class="tips" style="margin: 0 10px">
|
|
|
+ 为了保证数据结构准确,提交时将默认触发“<span style="color: var(--cus-main-color)">逆向生成JSON结构</span>”
|
|
|
+ </div>
|
|
|
<CusButton type="main" title="正向解析JSON结构" style="margin-left: auto" @click="jsonToTable"/>
|
|
|
<CusButton type="main" title="逆向生成JSON结构" @click="tableToJson"/>
|
|
|
</template>
|
|
@@ -232,12 +243,282 @@
|
|
|
</template>
|
|
|
</div>
|
|
|
</template>
|
|
|
- <template v-else-if="state.params.tab == 4"></template>
|
|
|
+ <template v-else-if="state.params.tab == 4">
|
|
|
+ <div class="response-body">
|
|
|
+ <CusForm label-width="80px">
|
|
|
+ <CusFormColumn
|
|
|
+ :span="24"
|
|
|
+ v-model:param="state.params.responseBody.type"
|
|
|
+ link="radio"
|
|
|
+ :options="DictionaryStore.responseBodyList"
|
|
|
+ />
|
|
|
+ <template v-if="state.params.responseBody.type == 1 || state.params.responseBody.type == 2">
|
|
|
+ <el-col :span="24">
|
|
|
+ <div class="tips">
|
|
|
+ @代表返回的数据,如下返回结果,匹配总数为"<span style="color: var(--cus-main-color)">@.data.total</span>"
|
|
|
+ <br/>
|
|
|
+ {code: 200,data: {pageNum: 1, pageSize: 10, data: [], total: 0},msg: ''}
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </template>
|
|
|
+ <template v-if="state.params.responseBody.type == 1">
|
|
|
+ <CusFormColumn
|
|
|
+ :span="6"
|
|
|
+ required
|
|
|
+ v-model:param="state.params.responseBody.json.pathForm.pageNum"
|
|
|
+ label="当前页"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="6"
|
|
|
+ required
|
|
|
+ v-model:param="state.params.responseBody.json.pathForm.pageSize"
|
|
|
+ label="每页数"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="6"
|
|
|
+ v-model:param="state.params.responseBody.json.pathForm.pageTotal"
|
|
|
+ label="总页数"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="6"
|
|
|
+ required
|
|
|
+ v-model:param="state.params.responseBody.json.pathForm.total"
|
|
|
+ label="总数"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="6"
|
|
|
+ required
|
|
|
+ v-model:param="state.params.responseBody.json.pathForm.data"
|
|
|
+ label="结果集"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </CusForm>
|
|
|
+ <template v-if="state.params.responseBody.type == 1">
|
|
|
+ <div style="margin-bottom: 10px; display: flex">
|
|
|
+ <CusButton type="main" title="新增" style="margin-right: auto;" @click="state.params.responseBody.json.data.push({label: '', key: '', valueType: '1', value: '', formatType: '1', formatRule: ''})"/>
|
|
|
+ <div class="tips" style="margin-left: 10px">
|
|
|
+ 取值类型为JsonPath时,@代表返回的数据(逻辑同上),也可以直接写字段名进行匹配
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <CusTable
|
|
|
+ :data="state.params.responseBody.json.data"
|
|
|
+ :table-head="state.params.responseBody.json.tableHead"
|
|
|
+ :no-page="true"
|
|
|
+ >
|
|
|
+ <template #label-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.label"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #key-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.key"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #valueType-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.valueType"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.qzTypeList"
|
|
|
+ :clearable="false"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #value-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.value"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #formatType-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.formatType"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.formatTypeList"
|
|
|
+ :clearable="false"
|
|
|
+ @change="scope.row.formatRule = ''"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #formatRule-column-value="{scope}">
|
|
|
+ <template v-if="scope.row.formatType == 1">
|
|
|
+<!-- <CusFormColumn-->
|
|
|
+<!-- class="__cus-table-form-column"-->
|
|
|
+<!-- :span="24"-->
|
|
|
+<!-- v-model:param="scope.row.formatRule"-->
|
|
|
+<!-- />-->
|
|
|
+ </template>
|
|
|
+ <template v-else-if="scope.row.formatType == 2">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.formatRule"
|
|
|
+ link="select"
|
|
|
+ static
|
|
|
+ :options="[
|
|
|
+ {dictLabel: 'yyyy', dictValue: 'yyyy'},
|
|
|
+ {dictLabel: 'yyyy-MM', dictValue: 'yyyy-MM'},
|
|
|
+ {dictLabel: 'yyyy-MM-dd', dictValue: 'yyyy-MM-dd'},
|
|
|
+ {dictLabel: 'yyyy-MM-dd HH', dictValue: 'yyyy-MM-dd HH'},
|
|
|
+ {dictLabel: 'yyyy-MM-dd HH:mm', dictValue: 'yyyy-MM-dd HH:mm'},
|
|
|
+ {dictLabel: 'yyyy-MM-dd HH:mm:ss', dictValue: 'yyyy-MM-dd HH:mm:ss'},
|
|
|
+ ]"
|
|
|
+ :clearable="false"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template v-else-if="scope.row.formatType == 3">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.formatRule"
|
|
|
+ :readonly="true"
|
|
|
+ @click="onClickFormatRuleDictJson(scope.row, scope.$index)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ <template #do-column-value="{scope}">
|
|
|
+ <CusButton type="table-del" @click="state.params.responseBody.json.data.splice(scope.$index, 1)"/>
|
|
|
+ </template>
|
|
|
+ </CusTable>
|
|
|
+ </template>
|
|
|
+ <template v-if="state.params.responseBody.type == 2">
|
|
|
+ <CusTable
|
|
|
+ :data="state.params.responseBody.text.data"
|
|
|
+ :table-head="state.params.responseBody.text.tableHead"
|
|
|
+ :no-page="true"
|
|
|
+ >
|
|
|
+ <template #label-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.label"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #key-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.key"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #valueType-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.valueType"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.qzTypeList"
|
|
|
+ :clearable="false"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #value-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.value"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #formatType-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.formatType"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.formatTypeList"
|
|
|
+ :clearable="false"
|
|
|
+ @change="scope.row.formatRule = ''"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #formatRule-column-value="{scope}">
|
|
|
+ <template v-if="scope.row.formatType == 1">
|
|
|
+ <!-- <CusFormColumn-->
|
|
|
+ <!-- class="__cus-table-form-column"-->
|
|
|
+ <!-- :span="24"-->
|
|
|
+ <!-- v-model:param="scope.row.formatRule"-->
|
|
|
+ <!-- />-->
|
|
|
+ </template>
|
|
|
+ <template v-else-if="scope.row.formatType == 2">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.formatRule"
|
|
|
+ link="select"
|
|
|
+ static
|
|
|
+ :options="[
|
|
|
+ {dictLabel: 'yyyy', dictValue: 'yyyy'},
|
|
|
+ {dictLabel: 'yyyy-MM', dictValue: 'yyyy-MM'},
|
|
|
+ {dictLabel: 'yyyy-MM-dd', dictValue: 'yyyy-MM-dd'},
|
|
|
+ {dictLabel: 'yyyy-MM-dd HH', dictValue: 'yyyy-MM-dd HH'},
|
|
|
+ {dictLabel: 'yyyy-MM-dd HH:mm', dictValue: 'yyyy-MM-dd HH:mm'},
|
|
|
+ {dictLabel: 'yyyy-MM-dd HH:mm:ss', dictValue: 'yyyy-MM-dd HH:mm:ss'},
|
|
|
+ ]"
|
|
|
+ :clearable="false"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template v-else-if="scope.row.formatType == 3">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.formatRule"
|
|
|
+ :readonly="true"
|
|
|
+ @click="onClickFormatRuleDictText(scope.row, scope.$index)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </CusTable>
|
|
|
+ </template>
|
|
|
+ <template v-if="state.params.responseBody.type == 3">
|
|
|
+ <div style="margin-bottom: 10px; display: flex">
|
|
|
+ <CusButton type="main" title="新增" style="margin-right: 10px;" @click="state.params.responseBody.other.data.push({label: '', key: ''})"/>
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="6"
|
|
|
+ v-model:param="state.params.responseBody.other.plug"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.jxPlugList"
|
|
|
+ :clearable="false"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <CusTable
|
|
|
+ :data="state.params.responseBody.other.data"
|
|
|
+ :table-head="state.params.responseBody.other.tableHead"
|
|
|
+ :no-page="true"
|
|
|
+ >
|
|
|
+ <template #label-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.label"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #key-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.key"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #do-column-value="{scope}">
|
|
|
+ <CusButton type="table-del" @click="state.params.requestBody.other.data.splice(scope.$index, 1)"/>
|
|
|
+ </template>
|
|
|
+ </CusTable>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
</div>
|
|
|
</div>
|
|
|
<complexRequestParams v-model:show="state.complexRequestParams.show" :transfer="state.complexRequestParams.transfer" @complex="getComplexRequestParams"/>
|
|
|
<complexRequestParams v-model:show="state.complexRequestHeaders.show" :transfer="state.complexRequestHeaders.transfer" @complex="getComplexRequestHeaders"/>
|
|
|
<complexRequestParams v-model:show="state.complexRequestBody.show" :transfer="state.complexRequestBody.transfer" @complex="getComplexRequestBody"/>
|
|
|
+ <formatRuleDict v-model:show="state.formatRuleDictJson.show" :transfer="state.formatRuleDictJson.transfer" @dict="getDictJson"/>
|
|
|
+ <formatRuleDict v-model:show="state.formatRuleDictText.show" :transfer="state.formatRuleDictText.transfer" @dict="getDictText"/>
|
|
|
</CusDialog>
|
|
|
</template>
|
|
|
|
|
@@ -246,6 +527,8 @@ import {computed, getCurrentInstance, nextTick, reactive, ref, watch} from "vue"
|
|
|
import {useDictionaryStore} from "@/stores";
|
|
|
import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
import complexRequestParams from './complex-params.vue'
|
|
|
+import formatRuleDict from './format-rule-dict.vue'
|
|
|
+import {outsideServiceSaveOrUpdate} from "@/api/modules/manage/service";
|
|
|
|
|
|
const emit = defineEmits(['update:show', 'refresh'])
|
|
|
const {proxy} = getCurrentInstance()
|
|
@@ -255,16 +538,12 @@ const props = defineProps({
|
|
|
transfer: {}
|
|
|
})
|
|
|
const state: any = reactive({
|
|
|
- form: {},
|
|
|
+ form: {
|
|
|
+ requestType: 'GET'
|
|
|
+ },
|
|
|
loading: false,
|
|
|
params: {
|
|
|
tab: 1,
|
|
|
- options: [
|
|
|
- {name: 'Request Params', value: 1},
|
|
|
- {name: 'Request Headers', value: 2},
|
|
|
- {name: 'Request Body', value: 3},
|
|
|
- {name: 'Response Body', value: 4},
|
|
|
- ],
|
|
|
requestParams: {
|
|
|
tableHead: [
|
|
|
{value: "key", label: "键名"},
|
|
@@ -296,6 +575,40 @@ const state: any = reactive({
|
|
|
{value: "do", label: "操作", width: 120, fixed: 'right'},
|
|
|
],
|
|
|
data: []
|
|
|
+ },
|
|
|
+ responseBody: {
|
|
|
+ type: '1',
|
|
|
+ json: {
|
|
|
+ pathForm: {},
|
|
|
+ tableHead: [
|
|
|
+ {value: "label", label: "列名"},
|
|
|
+ {value: "key", label: "键名"},
|
|
|
+ {value: "valueType", label: "取值类型", width: 160},
|
|
|
+ {value: "value", label: "取值规则"},
|
|
|
+ {value: "formatType", label: "格式类型", width: 160},
|
|
|
+ {value: "formatRule", label: "格式转换规则"},
|
|
|
+ {value: "do", label: "操作", width: 120, fixed: 'right'},
|
|
|
+ ],
|
|
|
+ data: []
|
|
|
+ },
|
|
|
+ text: {
|
|
|
+ tableHead: [
|
|
|
+ {value: "label", label: "列名"},
|
|
|
+ {value: "key", label: "键名"},
|
|
|
+ {value: "formatType", label: "格式类型", width: 160},
|
|
|
+ {value: "formatRule", label: "格式转换规则"},
|
|
|
+ ],
|
|
|
+ data: [{label: '', key: '', formatType: '1', formatRule: ''}]
|
|
|
+ },
|
|
|
+ other: {
|
|
|
+ plug: '',
|
|
|
+ tableHead: [
|
|
|
+ {value: "label", label: "列名"},
|
|
|
+ {value: "key", label: "键名"},
|
|
|
+ {value: "do", label: "操作", width: 120, fixed: 'right'},
|
|
|
+ ],
|
|
|
+ data: []
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
complexRequestParams: {
|
|
@@ -312,6 +625,16 @@ const state: any = reactive({
|
|
|
show: false,
|
|
|
transfer: {},
|
|
|
index: 0
|
|
|
+ },
|
|
|
+ formatRuleDictJson: {
|
|
|
+ show: false,
|
|
|
+ transfer: {},
|
|
|
+ index: 0
|
|
|
+ },
|
|
|
+ formatRuleDictText: {
|
|
|
+ show: false,
|
|
|
+ transfer: {},
|
|
|
+ index: 0
|
|
|
}
|
|
|
})
|
|
|
const ref_form = ref()
|
|
@@ -326,46 +649,99 @@ const titleCpt = computed(() => {
|
|
|
return t
|
|
|
})
|
|
|
const onSubmit = () => {
|
|
|
- if (!state.params.requestParams.data.every(v => proxy.$util.isValue(v.key) && proxy.$util.isValue(v.value))) {
|
|
|
- ElMessage.error('请完善Request Params参数信息!')
|
|
|
- state.params.tab = 1
|
|
|
- return
|
|
|
- }
|
|
|
- if (!state.params.requestHeaders.data.every(v => proxy.$util.isValue(v.key) && proxy.$util.isValue(v.value))) {
|
|
|
- ElMessage.error('请完善Request Headers参数信息!')
|
|
|
- state.params.tab = 2
|
|
|
- return
|
|
|
- }
|
|
|
ref_form.value.submit().then(() => {
|
|
|
+ const params = {...state.form}
|
|
|
+ // requestParams
|
|
|
+ if (!state.params.requestParams.data.every(v => proxy.$util.isValue(v.key) && proxy.$util.isValue(v.value))) {
|
|
|
+ ElMessage.error('请完善Request Params参数信息!')
|
|
|
+ state.params.tab = 1
|
|
|
+ return
|
|
|
+ }
|
|
|
+ params.requestParams = state.params.requestParams.data.length > 0 ? JSON.stringify(state.params.requestParams.data) : null
|
|
|
+ if (state.form.pluginType === 'http') {
|
|
|
+ // requestHeaders
|
|
|
+ if (!state.params.requestHeaders.data.every(v => proxy.$util.isValue(v.key) && proxy.$util.isValue(v.value))) {
|
|
|
+ ElMessage.error('请完善Request Headers参数信息!')
|
|
|
+ state.params.tab = 2
|
|
|
+ return
|
|
|
+ }
|
|
|
+ params.requestHeaders = state.params.requestHeaders.data.length > 0 ? JSON.stringify(state.params.requestHeaders.data) : null
|
|
|
+ // requestBody
|
|
|
+ if (!state.params.requestBody.data.every(v => proxy.$util.isValue(v.key) && proxy.$util.isValue(v.value) && proxy.$util.isValue(v.type) && (v.type != 3 || v.type == 3 && v.valueTable.length > 0))) {
|
|
|
+ ElMessage.error('请完善Request Body参数信息!')
|
|
|
+ state.params.tab = 3
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (['RAW_JSON', 'RAW_TEXT', 'RAW_XML', 'RAW_HTML'].includes(state.params.requestBody.type) && state.params.requestBody.data.length > 0) {
|
|
|
+ try {
|
|
|
+ tableToJson()
|
|
|
+ } catch (e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ state.params.requestBody.str = ''
|
|
|
+ }
|
|
|
+ params.requestBody = JSON.stringify({
|
|
|
+ type: state.params.requestBody.type,
|
|
|
+ str: state.params.requestBody.str,
|
|
|
+ data: state.params.requestBody.data.length > 0 ? state.params.requestBody.data : null
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // responseBody
|
|
|
+ if (state.params.responseBody.type == '1') {
|
|
|
+ if (
|
|
|
+ !proxy.$util.isValue(state.params.responseBody.json.pathForm.pageNum) ||
|
|
|
+ !proxy.$util.isValue(state.params.responseBody.json.pathForm.pageSize) ||
|
|
|
+ !proxy.$util.isValue(state.params.responseBody.json.pathForm.total) ||
|
|
|
+ !proxy.$util.isValue(state.params.responseBody.json.pathForm.data) ||
|
|
|
+ !state.params.responseBody.json.data.every(v => proxy.$util.isValue(v.label) && proxy.$util.isValue(v.key) && proxy.$util.isValue(v.valueType) && proxy.$util.isValue(v.value) && proxy.$util.isValue(v.formatType) && (v.formatType == 1 || v.formatType != 1 && proxy.$util.isValue(v.formatRule)))
|
|
|
+ ) {
|
|
|
+ ElMessage.error('请完善Response Body参数信息!')
|
|
|
+ state.params.tab = 4
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else if (state.params.responseBody.type == '2') {
|
|
|
+ if (!state.params.responseBody.text.data.every(v => proxy.$util.isValue(v.label) && proxy.$util.isValue(v.key) && proxy.$util.isValue(v.valueType) && proxy.$util.isValue(v.value) && proxy.$util.isValue(v.formatType) && (v.formatType != 1 && proxy.$util.isValue(v.formatRule)))) {
|
|
|
+ ElMessage.error('请完善Response Body参数信息!')
|
|
|
+ state.params.tab = 4
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else if (state.params.responseBody.type == '3') {
|
|
|
+ if (!state.params.responseBody.other.plug || !state.params.responseBody.other.data.every(v => proxy.$util.isValue(v.label) && proxy.$util.isValue(v.key))) {
|
|
|
+ ElMessage.error('请完善Response Body参数信息!')
|
|
|
+ state.params.tab = 4
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ params.responseBody = JSON.stringify({
|
|
|
+ type: state.params.responseBody.type,
|
|
|
+ json: {
|
|
|
+ pathForm: state.params.responseBody.json.pathForm,
|
|
|
+ data: state.params.responseBody.json.data.length > 0 ? state.params.responseBody.json.data : null
|
|
|
+ },
|
|
|
+ text: {
|
|
|
+ data: state.params.responseBody.text.data.length > 0 ? state.params.responseBody.text.data : null
|
|
|
+ },
|
|
|
+ other: {
|
|
|
+ plug: state.params.responseBody.other.plug,
|
|
|
+ data: state.params.responseBody.other.data.length > 0 ? state.params.responseBody.other.data : null
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log(params)
|
|
|
ElMessageBox.confirm("是否提交?", "提示", {
|
|
|
confirmButtonText: "确定",
|
|
|
cancelButtonText: "取消",
|
|
|
type: "warning",
|
|
|
} as any).then(() => {
|
|
|
state.loading = true
|
|
|
- // const params = JSON.parse(JSON.stringify(state.form))
|
|
|
- // if (params.themeType == '2') {
|
|
|
- // params.themeParam = params.themeParam.join(',')
|
|
|
- // }
|
|
|
- // if (props.transfer.mode === 'add') {
|
|
|
- // sysThemeAdd(params).then(res => {
|
|
|
- // ElMessage.success('新增成功!')
|
|
|
- // emit('update:show', false)
|
|
|
- // emit('refresh')
|
|
|
- // state.loading = false
|
|
|
- // }).catch(() => {
|
|
|
- // state.loading = false
|
|
|
- // })
|
|
|
- // } else if (props.transfer.mode === 'edit') {
|
|
|
- // sysThemeUpdate(params).then(res => {
|
|
|
- // ElMessage.success('编辑成功!')
|
|
|
- // emit('update:show', false)
|
|
|
- // emit('refresh')
|
|
|
- // state.loading = false
|
|
|
- // }).catch(() => {
|
|
|
- // state.loading = false
|
|
|
- // })
|
|
|
- // }
|
|
|
+ outsideServiceSaveOrUpdate(params).then(res => {
|
|
|
+ ElMessage.success(props.transfer.mode === 'add' ? '新增成功!' : '编辑成功!')
|
|
|
+ emit('update:show', false)
|
|
|
+ emit('refresh')
|
|
|
+ state.loading = false
|
|
|
+ }).catch(() => {
|
|
|
+ state.loading = false
|
|
|
+ })
|
|
|
}).catch(() => {})
|
|
|
}).catch((e) => {
|
|
|
ElMessage({
|
|
@@ -385,6 +761,9 @@ const initDetail = () => {
|
|
|
// state.loading = false
|
|
|
// })
|
|
|
}
|
|
|
+const onChangeGsPlug = (val) => {
|
|
|
+ state.form.pluginType = DictionaryStore.gsPlugObjMap.get(val)?.type
|
|
|
+}
|
|
|
const onClickComplexRequestParams = (row, index) => {
|
|
|
if (row.type == 3) {
|
|
|
state.complexRequestParams.transfer = {
|
|
@@ -456,15 +835,49 @@ const onChangeRequestBodyType = (val) => {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+const onClickFormatRuleDictJson = (row, index) => {
|
|
|
+ state.formatRuleDictJson.transfer = {
|
|
|
+ formatRule: row.formatRule,
|
|
|
+ index: index
|
|
|
+ }
|
|
|
+ state.formatRuleDictJson.show = true
|
|
|
+}
|
|
|
+const getDictJson = (dict) => {
|
|
|
+ state.params.responseBody.json.data[state.formatRuleDictJson.transfer.index].formatRule = [...dict]
|
|
|
+}
|
|
|
+const onClickFormatRuleDictText = (row, index) => {
|
|
|
+ state.formatRuleDictText.transfer = {
|
|
|
+ formatRule: row.formatRule,
|
|
|
+ index: index
|
|
|
+ }
|
|
|
+ state.formatRuleDictText.show = true
|
|
|
+}
|
|
|
+const getDictText = (dict) => {
|
|
|
+ state.params.responseBody.text.data[state.formatRuleDictText.transfer.index].formatRule = [...dict]
|
|
|
+}
|
|
|
watch(() => props.show, (n) => {
|
|
|
if (n) {
|
|
|
state.loading = false
|
|
|
initDictionary()
|
|
|
- // if (props.transfer.mode === 'add') {
|
|
|
- // state.form = {}
|
|
|
- // } else {
|
|
|
- // initDetail()
|
|
|
- // }
|
|
|
+ if (props.transfer.mode === 'add') {
|
|
|
+ state.form = {
|
|
|
+ requestType: 'GET'
|
|
|
+ }
|
|
|
+ state.params.tab = 1
|
|
|
+ state.params.requestParams.data = []
|
|
|
+ state.params.requestHeaders.data = []
|
|
|
+ state.params.requestBody.type = 'NONE'
|
|
|
+ state.params.requestBody.str = 'NONE'
|
|
|
+ state.params.requestBody.data = []
|
|
|
+ state.params.responseBody.type = '1'
|
|
|
+ state.params.responseBody.json.pathForm = {}
|
|
|
+ state.params.responseBody.json.data = []
|
|
|
+ state.params.responseBody.text.data = [{label: '', key: '', formatType: '1', formatRule: ''}]
|
|
|
+ state.params.responseBody.other.plug = ''
|
|
|
+ state.params.responseBody.other.data = []
|
|
|
+ } else {
|
|
|
+ initDetail()
|
|
|
+ }
|
|
|
nextTick(() => {
|
|
|
ref_form.value.reset()
|
|
|
})
|
|
@@ -474,6 +887,9 @@ const initDictionary = () => {
|
|
|
DictionaryStore.initDict('request_type')
|
|
|
DictionaryStore.initDict('request_params')
|
|
|
DictionaryStore.initDict('request_body')
|
|
|
+ DictionaryStore.initDict('response_body')
|
|
|
+ DictionaryStore.initDict('qz_type')
|
|
|
+ DictionaryStore.initDict('format_type')
|
|
|
}
|
|
|
</script>
|
|
|
|
|
@@ -487,11 +903,18 @@ const initDictionary = () => {
|
|
|
flex: 1;
|
|
|
margin-top: 20px;
|
|
|
overflow: hidden;
|
|
|
- .request-params, .request-headers, .request-body {
|
|
|
+ .request-params, .request-headers, .request-body, .response-body {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
}
|
|
|
}
|
|
|
+.tips {
|
|
|
+ background-color: rgba(var(--cus-main-color-rgb), 0.1);
|
|
|
+ border-radius: 6px;
|
|
|
+ padding: 7px;
|
|
|
+ margin-bottom: 10px;
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
</style>
|