fix(接口自动化):修复部分缺陷,合并sql 脚本
This commit is contained in:
parent
41146ad7d1
commit
5b6a4ddd82
|
@ -16,7 +16,7 @@ CREATE TABLE `api_scenario` (
|
||||||
`follow_people` varchar(100) DEFAULT NULL COMMENT 'api scenario Follow people ',
|
`follow_people` varchar(100) DEFAULT NULL COMMENT 'api scenario Follow people ',
|
||||||
`schedule` varchar(255) DEFAULT NULL COMMENT 'Test schedule (cron list)',
|
`schedule` varchar(255) DEFAULT NULL COMMENT 'Test schedule (cron list)',
|
||||||
`scenario_definition` longtext COMMENT 'Test scenario_definition json',
|
`scenario_definition` longtext COMMENT 'Test scenario_definition json',
|
||||||
`description` varchar(255) DEFAULT NULL COMMENT 'api scenario description',
|
`description` longtext DEFAULT NULL COMMENT 'api scenario description',
|
||||||
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
||||||
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
||||||
`pass_rate` varchar(100) DEFAULT NULL,
|
`pass_rate` varchar(100) DEFAULT NULL,
|
||||||
|
@ -43,12 +43,13 @@ CREATE TABLE `api_scenario_report` (
|
||||||
`id` varchar(50) NOT NULL COMMENT 'Test report ID',
|
`id` varchar(50) NOT NULL COMMENT 'Test report ID',
|
||||||
`project_id` varchar(50) NOT NULL COMMENT 'scenario ID this test report belongs to',
|
`project_id` varchar(50) NOT NULL COMMENT 'scenario ID this test report belongs to',
|
||||||
`name` varchar(64) NOT NULL COMMENT 'Test report name',
|
`name` varchar(64) NOT NULL COMMENT 'Test report name',
|
||||||
`description` varchar(255) DEFAULT NULL COMMENT 'Test report name',
|
`description` longtext DEFAULT NULL COMMENT 'Test report name',
|
||||||
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
||||||
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
||||||
`status` varchar(64) NOT NULL COMMENT 'Status of this test run',
|
`status` varchar(64) NOT NULL COMMENT 'Status of this test run',
|
||||||
`user_id` varchar(64) DEFAULT NULL,
|
`user_id` varchar(64) DEFAULT NULL,
|
||||||
`trigger_mode` varchar(64) DEFAULT NULL,
|
`trigger_mode` varchar(64) DEFAULT NULL,
|
||||||
|
`execute_type` varchar(200) NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS `api_definition` (
|
||||||
`protocol` varchar(255) NOT NULL COMMENT 'request protocol',
|
`protocol` varchar(255) NOT NULL COMMENT 'request protocol',
|
||||||
`path` varchar(1000) DEFAULT NULL COMMENT 'request path',
|
`path` varchar(1000) DEFAULT NULL COMMENT 'request path',
|
||||||
`module_path` varchar(1000) COMMENT 'module path',
|
`module_path` varchar(1000) COMMENT 'module path',
|
||||||
`description` varchar(255) DEFAULT NULL COMMENT 'Test description',
|
`description` longtext DEFAULT NULL COMMENT 'Test description',
|
||||||
`environment_id` varchar(50) DEFAULT NULL COMMENT 'environment id',
|
`environment_id` varchar(50) DEFAULT NULL COMMENT 'environment id',
|
||||||
`request` longtext COMMENT 'request (JSON format)',
|
`request` longtext COMMENT 'request (JSON format)',
|
||||||
`response` longtext COMMENT 'request (JSON format)',
|
`response` longtext COMMENT 'request (JSON format)',
|
||||||
|
@ -40,7 +40,7 @@ CREATE TABLE IF NOT EXISTS `api_test_case` (
|
||||||
`name` varchar(64) NOT NULL COMMENT 'Test name',
|
`name` varchar(64) NOT NULL COMMENT 'Test name',
|
||||||
`priority` varchar(64) NOT NULL COMMENT 'priority',
|
`priority` varchar(64) NOT NULL COMMENT 'priority',
|
||||||
`api_definition_id` varchar(50) NOT NULL COMMENT 'api definition id',
|
`api_definition_id` varchar(50) NOT NULL COMMENT 'api definition id',
|
||||||
`description` varchar(255) DEFAULT NULL COMMENT 'Test description',
|
`description` longtext DEFAULT NULL COMMENT 'Test description',
|
||||||
`request` longtext COMMENT 'request (JSON format)',
|
`request` longtext COMMENT 'request (JSON format)',
|
||||||
`response` longtext COMMENT 'response (JSON format)',
|
`response` longtext COMMENT 'response (JSON format)',
|
||||||
`create_user_id` varchar(64) DEFAULT NULL COMMENT 'User ID',
|
`create_user_id` varchar(64) DEFAULT NULL COMMENT 'User ID',
|
||||||
|
@ -59,6 +59,7 @@ CREATE TABLE IF NOT EXISTS `api_definition_exec_result` (
|
||||||
`user_id` varchar(64) DEFAULT NULL COMMENT 'User ID',
|
`user_id` varchar(64) DEFAULT NULL COMMENT 'User ID',
|
||||||
`start_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
`start_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
||||||
`end_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
`end_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
||||||
|
`create_time` bigint(13) NULL COMMENT 'Create time',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
ALTER TABLE api_definition_exec_result ADD create_time BIGINT(13) NULL;
|
|
|
@ -1,5 +0,0 @@
|
||||||
ALTER TABLE api_scenario_report ADD execute_type varchar(200) NULL;
|
|
||||||
ALTER TABLE api_definition MODIFY COLUMN description LONGTEXT NULL COMMENT 'Test description';
|
|
||||||
ALTER TABLE api_test_case MODIFY COLUMN description LONGTEXT NULL COMMENT 'Test case description';
|
|
||||||
ALTER TABLE api_scenario MODIFY COLUMN description LONGTEXT NULL COMMENT 'Api scenario description';
|
|
||||||
ALTER TABLE api_scenario_report MODIFY COLUMN description LONGTEXT NULL COMMENT 'Api scenario report description';
|
|
|
@ -73,7 +73,6 @@
|
||||||
methods: {
|
methods: {
|
||||||
active() {
|
active() {
|
||||||
this.isActive = !this.isActive;
|
this.isActive = !this.isActive;
|
||||||
console.log(this.request)
|
|
||||||
//this.$emit("requestResult", {request: this.request, scenarioName: this.scenarioName});
|
//this.$emit("requestResult", {request: this.request, scenarioName: this.scenarioName});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
methods: {
|
methods: {
|
||||||
active() {
|
active() {
|
||||||
this.isActive = !this.isActive;
|
this.isActive = !this.isActive;
|
||||||
console.log(this.request)
|
|
||||||
//this.$emit("requestResult", {request: this.request, scenarioName: this.scenarioName});
|
//this.$emit("requestResult", {request: this.request, scenarioName: this.scenarioName});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,18 +2,18 @@
|
||||||
<div v-loading="loading">
|
<div v-loading="loading">
|
||||||
<el-card>
|
<el-card>
|
||||||
<el-row>
|
<el-row>
|
||||||
<div class="el-step__icon is-text ms-api-col" v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF'">
|
<div class="el-step__icon is-text ms-api-col" v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF' || request.referenced==='Copy'">
|
||||||
<div class="el-step__icon-inner">{{request.index}}</div>
|
<div class="el-step__icon-inner">{{request.index}}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="el-step__icon is-text ms-api-col-create" v-else>
|
<div class="el-step__icon is-text ms-api-col-create" v-else>
|
||||||
<div class="el-step__icon-inner">{{request.index}}</div>
|
<div class="el-step__icon-inner">{{request.index}}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-button v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF'" class="ms-left-buttion" size="small">
|
<el-button v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF' || request.referenced==='Copy'" class="ms-left-buttion" size="small">
|
||||||
{{$t('api_test.automation.api_list_import')}}
|
{{$t('api_test.automation.api_list_import')}}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
<el-button v-if="request.referenced==undefined || request.referenced==='Created' || request.referenced==='Copy'" class="ms-create-buttion" size="small">
|
<el-button v-if="request.referenced==undefined || request.referenced==='Created' " class="ms-create-buttion" size="small">
|
||||||
{{$t('api_test.automation.customize_req')}}
|
{{$t('api_test.automation.customize_req')}}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
<el-input size="small" v-model="request.name" style="width: 40%;" :placeholder="$t('commons.input_name')" v-else/>
|
<el-input size="small" v-model="request.name" style="width: 40%;" :placeholder="$t('commons.input_name')" v-else/>
|
||||||
|
|
||||||
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
|
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
|
||||||
|
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
|
||||||
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
||||||
<div style="margin-right: 20px; float: right">
|
<div style="margin-right: 20px; float: right">
|
||||||
<i class="icon el-icon-arrow-right" :class="{'is-active': request.active}"
|
<i class="icon el-icon-arrow-right" :class="{'is-active': request.active}"
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<el-button class="ms-title-buttion" size="small">{{$t('api_test.automation.scenario_import')}}</el-button>
|
<el-button class="ms-title-buttion" size="small">{{$t('api_test.automation.scenario_import')}}</el-button>
|
||||||
{{scenario.name}}
|
{{scenario.name}}
|
||||||
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
|
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
|
||||||
|
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
|
||||||
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
||||||
<div style="margin-right: 20px; float: right">
|
<div style="margin-right: 20px; float: right">
|
||||||
<el-switch v-model="scenario.enable" style="margin-left: 10px"/>
|
<el-switch v-model="scenario.enable" style="margin-left: 10px"/>
|
||||||
|
|
|
@ -134,10 +134,10 @@
|
||||||
:{{this.currentScenario.variables!=undefined?this.currentScenario.variables.length-1: 0}}
|
:{{this.currentScenario.variables!=undefined?this.currentScenario.variables.length-1: 0}}
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="3" class="ms-col-one ms-font">
|
<el-col :span="3" class="ms-col-one ms-font">
|
||||||
<el-checkbox v-model="enableCookieShare">{{ '共享cookie' }}</el-checkbox>
|
<el-checkbox v-model="enableCookieShare">共享cookie</el-checkbox>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="7" class="ms-font">
|
<el-col :span="7" class="ms-font">
|
||||||
{{$t('api_test.definition.request.run_env')}}:
|
{{$t('api_test.definition.request.run_env')}}:
|
||||||
<el-select v-model="currentEnvironmentId" size="small" class="ms-htt-width"
|
<el-select v-model="currentEnvironmentId" size="small" class="ms-htt-width"
|
||||||
:placeholder="$t('api_test.definition.request.run_env')"
|
:placeholder="$t('api_test.definition.request.run_env')"
|
||||||
clearable>
|
clearable>
|
||||||
|
@ -826,12 +826,13 @@
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
.ms-font{
|
|
||||||
|
.ms-font {
|
||||||
color: #303133;
|
color: #303133;
|
||||||
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
|
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ms-col-one {
|
.ms-col-one {
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
}
|
}
|
||||||
|
@ -921,6 +922,17 @@
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/deep/ .el-checkbox {
|
||||||
|
color: #303133;
|
||||||
|
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .el-checkbox__label {
|
||||||
|
padding-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.head {
|
.head {
|
||||||
border-bottom: 1px solid #303133;
|
border-bottom: 1px solid #303133;
|
||||||
color: #303133;
|
color: #303133;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div style="min-width: 1000px;margin-bottom: 20px">
|
||||||
<el-radio-group v-model="body.type" size="mini">
|
<el-radio-group v-model="body.type" size="mini">
|
||||||
<el-radio :disabled="isReadOnly" :label="type.FORM_DATA" @change="modeChange">
|
<el-radio :disabled="isReadOnly" :label="type.FORM_DATA" @change="modeChange">
|
||||||
{{ $t('api_test.definition.request.body_form_data') }}
|
{{ $t('api_test.definition.request.body_form_data') }}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<el-col :span="16">
|
<el-col :span="16">
|
||||||
<el-form-item :label="$t('api_report.request')" prop="path">
|
<el-form-item :label="$t('api_report.request')" prop="path">
|
||||||
<el-input :placeholder="$t('api_test.definition.request.path_info')" v-model="httpForm.path"
|
<el-input :placeholder="$t('api_test.definition.request.path_info')" v-model="httpForm.path"
|
||||||
class="ms-http-input" size="small" style="margin-top: 5px">
|
class="ms-http-input" size="small" style="margin-top: 5px" @change="urlChange">
|
||||||
<el-select v-model="httpForm.method" slot="prepend" style="width: 100px" size="small">
|
<el-select v-model="httpForm.method" slot="prepend" style="width: 100px" size="small">
|
||||||
<el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/>
|
<el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
@ -95,6 +95,7 @@
|
||||||
import {WORKSPACE_ID} from '../../../../../../common/js/constants';
|
import {WORKSPACE_ID} from '../../../../../../common/js/constants';
|
||||||
import {REQ_METHOD, API_STATUS} from "../../model/JsonData";
|
import {REQ_METHOD, API_STATUS} from "../../model/JsonData";
|
||||||
import MsJsr233Processor from "../processor/Jsr233Processor";
|
import MsJsr233Processor from "../processor/Jsr233Processor";
|
||||||
|
import {KeyValue} from "../../model/ApiTestModel";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsAddCompleteHttpApi",
|
name: "MsAddCompleteHttpApi",
|
||||||
|
@ -169,6 +170,35 @@
|
||||||
});
|
});
|
||||||
return path[0].path;
|
return path[0].path;
|
||||||
},
|
},
|
||||||
|
urlChange() {
|
||||||
|
if (!this.httpForm.path) return;
|
||||||
|
let url = this.getURL(this.addProtocol(this.httpForm.path));
|
||||||
|
if (url) {
|
||||||
|
this.httpForm.path = decodeURIComponent("/" + url.hostname + url.pathname);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
addProtocol(url) {
|
||||||
|
if (url) {
|
||||||
|
if (!url.toLowerCase().startsWith("https") && !url.toLowerCase().startsWith("http")) {
|
||||||
|
return "https://" + url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
},
|
||||||
|
getURL(urlStr) {
|
||||||
|
try {
|
||||||
|
let url = new URL(urlStr);
|
||||||
|
console.log(urlStr)
|
||||||
|
url.searchParams.forEach((value, key) => {
|
||||||
|
if (key && value) {
|
||||||
|
this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return url;
|
||||||
|
} catch (e) {
|
||||||
|
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
<span style="margin-right: 10px">
|
<span style="margin-right: 10px">
|
||||||
<el-checkbox class="follow-redirects-item" v-model="request.followRedirects">{{$t('api_test.request.follow_redirects')}}</el-checkbox>
|
<el-checkbox class="follow-redirects-item" v-model="request.followRedirects">{{$t('api_test.request.follow_redirects')}}</el-checkbox>
|
||||||
</span>
|
</span>
|
||||||
<span style="margin-right: 10px">
|
|
||||||
<el-checkbox class="do-multipart-post" v-model="request.doMultipartPost">{{$t('api_test.request.do_multipart_post')}}</el-checkbox>
|
|
||||||
</span>
|
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
<!--请求体-->
|
<!--请求体-->
|
||||||
<el-tab-pane v-if="isBodyShow" :label="$t('api_test.request.body')" name="body">
|
<el-tab-pane v-if="isBodyShow" :label="$t('api_test.request.body')" name="body" style="overflow: auto">
|
||||||
<ms-api-body @headersChange="reloadBody" :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :headers="headers" :body="request.body"/>
|
<ms-api-body @headersChange="reloadBody" :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :headers="headers" :body="request.body"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<ms-code-edit v-if="!isSqlType" :mode="mode" :read-only="true" :modes="modes" :data.sync="response.responseResult.body" ref="codeEdit"/>
|
<ms-code-edit v-if="!isSqlType" :mode="mode" :read-only="true" :modes="modes" :data.sync="response.responseResult.body" ref="codeEdit"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<!--<el-tab-pane label="Cookie" name="cookie" class="pane cookie">-->
|
<!--<el-tab-pane label="Cookie" name="cookie" class="pane cookie">-->
|
||||||
<!--<pre>{{response.cookies}}</pre>-->
|
<!--<pre>{{response.cookies}}</pre>-->
|
||||||
<!--</el-tab-pane>-->
|
<!--</el-tab-pane>-->
|
||||||
|
|
||||||
<el-tab-pane :label="$t('api_test.definition.request.console')" name="console" class="pane">
|
<el-tab-pane :label="$t('api_test.definition.request.console')" name="console" class="pane">
|
||||||
|
@ -26,17 +26,21 @@
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
<el-tab-pane :label="$t('api_report.request_body')" name="request_body" class="pane">
|
<el-tab-pane :label="$t('api_report.request_body')" name="request_body" class="pane">
|
||||||
<div>
|
<div class="ms-div">
|
||||||
{{$t('api_test.request.address')}} : {{ response.url }}
|
{{$t('api_test.request.address')}} :
|
||||||
|
<pre>{{ response.url }}</pre>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="ms-div">
|
||||||
{{$t('api_test.scenario.headers')}} : {{ response.headers }}
|
{{$t('api_test.scenario.headers')}} :
|
||||||
|
<pre>{{ response.headers }}</pre>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="ms-div">
|
||||||
Cookies : {{response.cookies}}
|
Cookies :
|
||||||
|
<pre>{{response.cookies}}</pre>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="ms-div">
|
||||||
Body : {{response.body}}
|
Body :
|
||||||
|
<pre>{{response.body}}</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
@ -45,7 +49,6 @@
|
||||||
<template v-slot:label>
|
<template v-slot:label>
|
||||||
<ms-dropdown v-if="currentProtocol==='SQL'" :commands="sqlModes" :default-command="mode" @command="sqlModeChange"/>
|
<ms-dropdown v-if="currentProtocol==='SQL'" :commands="sqlModes" :default-command="mode" @command="sqlModeChange"/>
|
||||||
<ms-dropdown v-else :commands="modes" :default-command="mode" @command="modeChange"/>
|
<ms-dropdown v-else :commands="modes" :default-command="mode" @command="modeChange"/>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
@ -139,6 +142,10 @@
|
||||||
height: 0px;
|
height: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ms-div {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,79 +24,83 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "MsSqlResultTable",
|
name: "MsSqlResultTable",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
tables: [],
|
tables: [],
|
||||||
titles: []
|
titles: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
body: String
|
body: String
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (!this.body) {
|
if (!this.body) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let rowArry = this.body.split("\n");
|
let rowArry = this.body.split("\n");
|
||||||
this.getTableData(rowArry);
|
// 过多会有性能问题
|
||||||
if (this.tables.length > 1) {
|
if (rowArry.length > 100) {
|
||||||
for (let i = 0; i < this.tables.length; i++) {
|
rowArry = rowArry.slice(0, 100);
|
||||||
if (this.tables[i].titles.length === 1 && i < this.tables.length - 1) {
|
}
|
||||||
this.tables[i].tableData.splice(this.tables[i].tableData.length - 1, 1);
|
this.getTableData(rowArry);
|
||||||
}
|
if (this.tables.length > 1) {
|
||||||
|
for (let i = 0; i < this.tables.length; i++) {
|
||||||
|
if (this.tables[i].titles.length === 1 && i < this.tables.length - 1) {
|
||||||
|
this.tables[i].tableData.splice(this.tables[i].tableData.length - 1, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let lastTable = this.tables[this.tables.length - 1];
|
let lastTable = this.tables[this.tables.length - 1];
|
||||||
if (lastTable.titles.length === 1) {
|
if (lastTable.titles.length === 1) {
|
||||||
if (lastTable.tableData.length > 4) {
|
if (lastTable.tableData.length > 4) {
|
||||||
lastTable.tableData.splice(lastTable.tableData.length - 4, 4);
|
lastTable.tableData.splice(lastTable.tableData.length - 4, 4);
|
||||||
} else {
|
|
||||||
this.tables.splice(this.tables.length - 1, 1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.tables.splice(this.tables.length - 1, 1);
|
this.tables.splice(this.tables.length - 1, 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let table = this.tables[0];
|
this.tables.splice(this.tables.length - 1, 1);
|
||||||
table.tableData.splice(table.tableData.length - 4, 4);
|
|
||||||
}
|
}
|
||||||
},
|
} else {
|
||||||
methods: {
|
let table = this.tables[0];
|
||||||
getTableData(rowArry) {
|
table.tableData.splice(table.tableData.length - 4, 4);
|
||||||
let titles;
|
}
|
||||||
let result = [];
|
},
|
||||||
for (let i = 0; i < rowArry.length; i++) {
|
methods: {
|
||||||
let colArray = rowArry[i].split("\t");
|
getTableData(rowArry) {
|
||||||
if (i === 0) {
|
let titles;
|
||||||
titles = colArray;
|
let result = [];
|
||||||
} else {
|
for (let i = 0; i < rowArry.length; i++) {
|
||||||
if (colArray.length != titles.length) {
|
let colArray = rowArry[i].split("\t");
|
||||||
// 创建新的表
|
if (i === 0) {
|
||||||
if (colArray.length === 1 && colArray[0] === '') {
|
titles = colArray;
|
||||||
this.getTableData(rowArry.slice(i + 1));
|
} else {
|
||||||
} else {
|
if (colArray.length != titles.length) {
|
||||||
this.getTableData(rowArry.slice(i));
|
// 创建新的表
|
||||||
}
|
if (colArray.length === 1 && colArray[0] === '') {
|
||||||
break;
|
this.getTableData(rowArry.slice(i + 1));
|
||||||
} else {
|
} else {
|
||||||
let item = {};
|
this.getTableData(rowArry.slice(i));
|
||||||
for (let j = 0; j < colArray.length; j++) {
|
|
||||||
item[titles[j]] = (colArray[j] ? colArray[j] : "");
|
|
||||||
}
|
|
||||||
result.push(item);
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
let item = {};
|
||||||
|
for (let j = 0; j < colArray.length; j++) {
|
||||||
|
item[titles[j]] = (colArray[j] ? colArray[j] : "");
|
||||||
|
}
|
||||||
|
result.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tables.splice(0, 0, {
|
|
||||||
titles: titles,
|
|
||||||
tableData: result
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.tables.splice(0, 0, {
|
||||||
|
titles: titles,
|
||||||
|
tableData: result
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -114,7 +118,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-container {
|
.el-container {
|
||||||
overflow:auto;
|
overflow: auto;
|
||||||
max-height: 500px;
|
max-height: 500px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue