fix(接口自动化): 修复导出文件名称-项目名称错误问题 #1005112

This commit is contained in:
fit2-zhao 2021-07-13 18:23:34 +08:00 committed by fit2-zhao
parent 13960fc9fb
commit 22e453d476
1 changed files with 50 additions and 43 deletions

View File

@ -50,7 +50,7 @@
<a style="cursor:pointer" @click="edit(scope.row)"> {{ scope.row.customNum }} </a> <a style="cursor:pointer" @click="edit(scope.row)"> {{ scope.row.customNum }} </a>
</el-tooltip> </el-tooltip>
</template> </template>
</ms-table-column > </ms-table-column>
<ms-table-column prop="name" <ms-table-column prop="name"
sortable sortable
@ -98,13 +98,13 @@
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column prop="principalName" <ms-table-column prop="principalName"
min-width="120px" min-width="120px"
:label="$t('api_test.definition.api_principal')" :label="$t('api_test.definition.api_principal')"
:filters="userFilters" :filters="userFilters"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
sortable/> sortable/>
<ms-table-column prop="userName" min-width="120px" <ms-table-column prop="userName" min-width="120px"
:label="$t('api_test.automation.creator')" :label="$t('api_test.automation.creator')"
:filters="userFilters" :filters="userFilters"
@ -120,7 +120,7 @@
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template> </template>
</ms-table-column > </ms-table-column>
<ms-table-column prop="createTime" <ms-table-column prop="createTime"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
@ -130,7 +130,7 @@
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span> <span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template> </template>
</ms-table-column > </ms-table-column>
<ms-table-column prop="stepTotal" <ms-table-column prop="stepTotal"
:field="item" :field="item"
@ -152,7 +152,7 @@
{{ $t('api_test.automation.fail') }} {{ $t('api_test.automation.fail') }}
</el-link> </el-link>
</template> </template>
</ms-table-column > </ms-table-column>
<ms-table-column prop="passRate" <ms-table-column prop="passRate"
:field="item" :field="item"
@ -213,7 +213,7 @@ import BatchMove from "../../../track/case/components/BatchMove";
import MsRunMode from "./common/RunMode"; import MsRunMode from "./common/RunMode";
import { import {
getCustomTableHeader, getCustomTableWidth,getLastTableSortField,saveLastTableSortField getCustomTableHeader, getCustomTableWidth, getLastTableSortField, saveLastTableSortField
} from "@/common/js/tableUtils"; } from "@/common/js/tableUtils";
import HeaderCustom from "@/business/components/common/head/HeaderCustom"; import HeaderCustom from "@/business/components/common/head/HeaderCustom";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate"; import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
@ -284,9 +284,9 @@ export default {
}, },
data() { data() {
return { return {
projectName:"", projectName: "",
result: {}, result: {},
tableHeaderKey:"API_SCENARIO", tableHeaderKey: "API_SCENARIO",
type: API_SCENARIO_LIST, type: API_SCENARIO_LIST,
fields: getCustomTableHeader('API_SCENARIO'), fields: getCustomTableHeader('API_SCENARIO'),
fieldsWidth: getCustomTableWidth('API_SCENARIO'), fieldsWidth: getCustomTableWidth('API_SCENARIO'),
@ -438,14 +438,14 @@ export default {
}, },
created() { created() {
this.projectId = getCurrentProjectID(); this.projectId = getCurrentProjectID();
if(!this.projectName || this.projectName === ""){ if (!this.projectName || this.projectName === "") {
this.getProjectName(); this.getProjectName();
} }
this.operators = this.unTrashOperators; this.operators = this.unTrashOperators;
this.buttons = this.unTrashButtons; this.buttons = this.unTrashButtons;
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]}; this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
let orderArr = this.getSortField(); let orderArr = this.getSortField();
if(orderArr){ if (orderArr) {
this.condition.orders = orderArr; this.condition.orders = orderArr;
} }
this.search(); this.search();
@ -483,10 +483,10 @@ export default {
}, },
}, },
methods: { methods: {
getProjectName (){ getProjectName() {
this.$get('project/get/' + this.projectId, response => { this.$get('project/get/' + this.projectId, response => {
let project = response.data; let project = response.data;
if(project){ if (project) {
this.projectName = project.name; this.projectName = project.name;
} }
}); });
@ -496,10 +496,10 @@ export default {
this.search(); this.search();
}, },
search(projectId) { search(projectId) {
if(this.needRefreshModule()){ if (this.needRefreshModule()) {
this.$emit('refreshTree'); this.$emit('refreshTree');
} }
if(this.selectProjectId){ if (this.selectProjectId) {
projectId = this.selectProjectId; projectId = this.selectProjectId;
} }
this.selectRows = new Set(); this.selectRows = new Set();
@ -810,17 +810,24 @@ export default {
}, },
exportApi() { exportApi() {
let param = {}; let param = {};
this.buildBatchParam(param); this.projectId = getCurrentProjectID();
if (param.ids === undefined || param.ids.length < 1) { this.$get('project/get/' + this.projectId, response => {
this.$warning(this.$t("api_test.automation.scenario.check_case")); let project = response.data;
return; if (project) {
} this.projectName = project.name;
this.result.loading = true; this.buildBatchParam(param);
this.result = this.$post("/api/automation/export", param, response => { if (param.ids === undefined || param.ids.length < 1) {
this.result.loading = false; this.$warning(this.$t("api_test.automation.scenario.check_case"));
let obj = response.data; return;
this.buildApiPath(obj.data); }
downloadFile("Metersphere_Scenario_" + this.projectName + ".json", JSON.stringify(obj)); this.result.loading = true;
this.result = this.$post("/api/automation/export", param, response => {
this.result.loading = false;
let obj = response.data;
this.buildApiPath(obj.data);
downloadFile("Metersphere_Scenario_" + this.projectName + ".json", JSON.stringify(obj));
});
}
}); });
}, },
exportJmx() { exportJmx() {
@ -853,18 +860,18 @@ export default {
getConditions() { getConditions() {
return this.condition; return this.condition;
}, },
needRefreshModule(){ needRefreshModule() {
if(this.initApiTableOpretion === '0'){ if (this.initApiTableOpretion === '0') {
return true; return true;
}else { } else {
this.$emit('updateInitApiTableOpretion','0'); this.$emit('updateInitApiTableOpretion', '0');
return false; return false;
} }
}, },
callBackSelectAll(selection){ callBackSelectAll(selection) {
this.$emit('selection', selection); this.$emit('selection', selection);
}, },
callBackSelect(selection){ callBackSelect(selection) {
this.$emit('selection', selection); this.$emit('selection', selection);
}, },
batchCreatePerformance() { batchCreatePerformance() {
@ -899,7 +906,7 @@ export default {
} }
}); });
}, },
batchCopy(){ batchCopy() {
this.$alert(this.$t('api_test.definition.request.batch_copy_confirm') + " ", '', { this.$alert(this.$t('api_test.definition.request.batch_copy_confirm') + " ", '', {
confirmButtonText: this.$t('commons.confirm'), confirmButtonText: this.$t('commons.confirm'),
callback: (action) => { callback: (action) => {
@ -915,16 +922,16 @@ export default {
} }
}); });
}, },
saveSortField(key,orders){ saveSortField(key, orders) {
saveLastTableSortField(key,JSON.stringify(orders)); saveLastTableSortField(key, JSON.stringify(orders));
}, },
getSortField(){ getSortField() {
let orderJsonStr = getLastTableSortField(this.tableHeaderKey); let orderJsonStr = getLastTableSortField(this.tableHeaderKey);
let returnObj = null; let returnObj = null;
if(orderJsonStr){ if (orderJsonStr) {
try { try {
returnObj = JSON.parse(orderJsonStr); returnObj = JSON.parse(orderJsonStr);
}catch (e){ } catch (e) {
return null; return null;
} }
} }