This commit is contained in:
chenjianxing 2021-02-02 16:14:45 +08:00
commit f70995e175
7 changed files with 107 additions and 95 deletions

View File

@ -179,9 +179,8 @@ public class TestPlanService {
else if (res.getStatus().equals(TestPlanStatus.Completed.name())) { else if (res.getStatus().equals(TestPlanStatus.Completed.name())) {
res.setActualEndTime(null); res.setActualEndTime(null);
} // 已完成->进行中结束时间置空 } // 已完成->进行中结束时间置空
} } else if (!StringUtils.equals(res.getStatus(), TestPlanStatus.Prepare.name()) &&
else if (!res.getStatus().equals(TestPlanStatus.Prepare.name()) && StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name())) {
testPlan.getStatus().equals(TestPlanStatus.Prepare.name())) {
res.setActualStartTime(null); res.setActualStartTime(null);
res.setActualEndTime(null); res.setActualEndTime(null);
} // 非未开始->未开始时间都置空 } // 非未开始->未开始时间都置空
@ -190,8 +189,10 @@ public class TestPlanService {
//已完成写入实际完成时间 //已完成写入实际完成时间
res.setActualEndTime(System.currentTimeMillis()); res.setActualEndTime(System.currentTimeMillis());
} }
if(StringUtils.isNotEmpty(testPlan.getStatus())){
res.setStatus(testPlan.getStatus()); res.setStatus(testPlan.getStatus());
} }
}
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
userIds.add(testPlan.getPrincipal()); userIds.add(testPlan.getPrincipal());
@ -339,7 +340,7 @@ public class TestPlanService {
testPlanScenarioCaseService.deleteByPlanId(planId); testPlanScenarioCaseService.deleteByPlanId(planId);
//删除定时任务 //删除定时任务
scheduleService.deleteScheduleAndJobByResourceId(planId,ScheduleGroup.TEST_PLAN_TEST.name()); scheduleService.deleteScheduleAndJobByResourceId(planId, ScheduleGroup.TEST_PLAN_TEST.name());
int num = testPlanMapper.deleteByPrimaryKey(planId); int num = testPlanMapper.deleteByPrimaryKey(planId);
List<String> relatedUsers = new ArrayList<>(); List<String> relatedUsers = new ArrayList<>();
@ -438,7 +439,7 @@ public class TestPlanService {
} }
public List<TestPlanDTOWithMetric> listTestPlanByProject(QueryTestPlanRequest request) { public List<TestPlanDTOWithMetric> listTestPlanByProject(QueryTestPlanRequest request) {
List<TestPlanDTOWithMetric> testPlans=extTestPlanMapper.list(request); List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.list(request);
return testPlans; return testPlans;
} }
@ -785,7 +786,8 @@ public class TestPlanService {
} }
return issues; return issues;
} }
public List<TestPlanDTO> selectTestPlanByRelevancy(QueryTestPlanRequest params){
public List<TestPlanDTO> selectTestPlanByRelevancy(QueryTestPlanRequest params) {
return extTestPlanMapper.selectTestPlanByRelevancy(params); return extTestPlanMapper.selectTestPlanByRelevancy(params);
} }
@ -878,23 +880,23 @@ public class TestPlanService {
return request.getId(); return request.getId();
} }
public void run(String testPlanID,String projectID,String userId,String triggerMode){ public void run(String testPlanID, String projectID, String userId, String triggerMode) {
Map<String,String> planScenarioIdMap; Map<String, String> planScenarioIdMap;
Map<String,String> apiTestCaseIdMap; Map<String, String> apiTestCaseIdMap;
Map<String,String> performanceIdMap; Map<String, String> performanceIdMap;
planScenarioIdMap = new LinkedHashMap<>(); planScenarioIdMap = new LinkedHashMap<>();
apiTestCaseIdMap = new LinkedHashMap<>(); apiTestCaseIdMap = new LinkedHashMap<>();
performanceIdMap = new LinkedHashMap<>(); performanceIdMap = new LinkedHashMap<>();
List<TestPlanApiScenario> testPlanApiScenarioList = testPlanScenarioCaseService.getCasesByPlanId(testPlanID); List<TestPlanApiScenario> testPlanApiScenarioList = testPlanScenarioCaseService.getCasesByPlanId(testPlanID);
for (TestPlanApiScenario model :testPlanApiScenarioList) { for (TestPlanApiScenario model : testPlanApiScenarioList) {
planScenarioIdMap.put(model.getApiScenarioId(),model.getId()); planScenarioIdMap.put(model.getApiScenarioId(), model.getId());
} }
List<TestPlanApiCase> testPlanApiCaseList = testPlanApiCaseService.getCasesByPlanId(testPlanID); List<TestPlanApiCase> testPlanApiCaseList = testPlanApiCaseService.getCasesByPlanId(testPlanID);
for (TestPlanApiCase model : for (TestPlanApiCase model :
testPlanApiCaseList) { testPlanApiCaseList) {
apiTestCaseIdMap.put(model.getApiCaseId(),model.getId()); apiTestCaseIdMap.put(model.getApiCaseId(), model.getId());
} }
LoadCaseRequest loadCaseRequest = new LoadCaseRequest(); LoadCaseRequest loadCaseRequest = new LoadCaseRequest();
@ -902,24 +904,24 @@ public class TestPlanService {
loadCaseRequest.setProjectId(projectID); loadCaseRequest.setProjectId(projectID);
List<TestPlanLoadCaseDTO> testPlanLoadCaseDTOList = testPlanLoadCaseService.list(loadCaseRequest); List<TestPlanLoadCaseDTO> testPlanLoadCaseDTOList = testPlanLoadCaseService.list(loadCaseRequest);
for (TestPlanLoadCaseDTO dto : testPlanLoadCaseDTOList) { for (TestPlanLoadCaseDTO dto : testPlanLoadCaseDTOList) {
performanceIdMap.put(dto.getId(),dto.getLoadCaseId()); performanceIdMap.put(dto.getId(), dto.getLoadCaseId());
} }
LogUtil.info("-------------- start testplan schedule ----------"); LogUtil.info("-------------- start testplan schedule ----------");
TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class); TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class);
//首先创建testPlanReport然后返回的ID重新赋值为resourceID作为后续的参数 //首先创建testPlanReport然后返回的ID重新赋值为resourceID作为后续的参数
TestPlanReport testPlanReport = testPlanReportService.genTestPlanReport(testPlanID,userId,triggerMode); TestPlanReport testPlanReport = testPlanReportService.genTestPlanReport(testPlanID, userId, triggerMode);
//执行接口案例任务 //执行接口案例任务
for (Map.Entry<String,String> entry: apiTestCaseIdMap.entrySet()) { for (Map.Entry<String, String> entry : apiTestCaseIdMap.entrySet()) {
String apiCaseID = entry.getKey(); String apiCaseID = entry.getKey();
String planCaseID = entry.getValue(); String planCaseID = entry.getValue();
ApiTestCaseWithBLOBs blobs = apiTestCaseService.get(apiCaseID); ApiTestCaseWithBLOBs blobs = apiTestCaseService.get(apiCaseID);
//需要更新这里来保证PlanCase的状态能正常更改 //需要更新这里来保证PlanCase的状态能正常更改
apiTestCaseService.run(blobs,UUID.randomUUID().toString(),testPlanReport.getId(),testPlanID,ApiRunMode.SCHEDULE_API_PLAN.name()); apiTestCaseService.run(blobs, UUID.randomUUID().toString(), testPlanReport.getId(), testPlanID, ApiRunMode.SCHEDULE_API_PLAN.name());
} }
//执行场景执行任务 //执行场景执行任务
if(!planScenarioIdMap.isEmpty()){ if (!planScenarioIdMap.isEmpty()) {
LogUtil.info("-------------- testplan schedule ---------- api case over -----------------"); LogUtil.info("-------------- testplan schedule ---------- api case over -----------------");
SchedulePlanScenarioExecuteRequest scenarioRequest = new SchedulePlanScenarioExecuteRequest(); SchedulePlanScenarioExecuteRequest scenarioRequest = new SchedulePlanScenarioExecuteRequest();
String senarionReportID = UUID.randomUUID().toString(); String senarionReportID = UUID.randomUUID().toString();
@ -928,7 +930,7 @@ public class TestPlanService {
scenarioRequest.setProjectId(projectID); scenarioRequest.setProjectId(projectID);
scenarioRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); scenarioRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
scenarioRequest.setExecuteType(ExecuteType.Saved.name()); scenarioRequest.setExecuteType(ExecuteType.Saved.name());
Map<String, Map<String,String>> testPlanScenarioIdMap = new HashMap<>(); Map<String, Map<String, String>> testPlanScenarioIdMap = new HashMap<>();
testPlanScenarioIdMap.put(testPlanID, planScenarioIdMap); testPlanScenarioIdMap.put(testPlanID, planScenarioIdMap);
scenarioRequest.setTestPlanScenarioIDMap(testPlanScenarioIdMap); scenarioRequest.setTestPlanScenarioIDMap(testPlanScenarioIdMap);
scenarioRequest.setReportUserID(userId); scenarioRequest.setReportUserID(userId);
@ -940,7 +942,7 @@ public class TestPlanService {
} }
//执行性能测试任务 //执行性能测试任务
List<String> performaneReportIDList = new ArrayList<>(); List<String> performaneReportIDList = new ArrayList<>();
for (Map.Entry<String,String> entry: performanceIdMap.entrySet()) { for (Map.Entry<String, String> entry : performanceIdMap.entrySet()) {
String id = entry.getKey(); String id = entry.getKey();
String caseID = entry.getValue(); String caseID = entry.getValue();
RunTestPlanRequest performanceRequest = new RunTestPlanRequest(); RunTestPlanRequest performanceRequest = new RunTestPlanRequest();
@ -950,7 +952,7 @@ public class TestPlanService {
String reportId = null; String reportId = null;
try { try {
reportId = performanceTestService.run(performanceRequest); reportId = performanceTestService.run(performanceRequest);
if(reportId!=null){ if (reportId != null) {
performaneReportIDList.add(reportId); performaneReportIDList.add(reportId);
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase(); TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
@ -958,7 +960,7 @@ public class TestPlanService {
testPlanLoadCase.setLoadReportId(reportId); testPlanLoadCase.setLoadReportId(reportId);
testPlanLoadCaseService.update(testPlanLoadCase); testPlanLoadCaseService.update(testPlanLoadCase);
} }
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//更新关联处的报告 //更新关联处的报告
@ -968,9 +970,9 @@ public class TestPlanService {
testPlanLoadCaseService.update(loadCase); testPlanLoadCaseService.update(loadCase);
} }
if(!performaneReportIDList.isEmpty()){ if (!performaneReportIDList.isEmpty()) {
//性能测试时保存性能测试报告ID在结果返回时用于捕捉并进行 //性能测试时保存性能测试报告ID在结果返回时用于捕捉并进行
testPlanReportService.updatePerformanceInfo(testPlanReport,performaneReportIDList,ReportTriggerMode.SCHEDULE.name()); testPlanReportService.updatePerformanceInfo(testPlanReport, performaneReportIDList, ReportTriggerMode.SCHEDULE.name());
} }
} }
} }

View File

@ -10,6 +10,7 @@
@sort-change="sort" @sort-change="sort"
@filter-change="filter" @filter-change="filter"
@select-all="select" @select="select" @select-all="select" @select="select"
@header-dragend="headerDragend"
v-loading="loading"> v-loading="loading">
<el-table-column type="selection" width="50"/> <el-table-column type="selection" width="50"/>
@ -20,7 +21,7 @@
@selectPageAll="isSelectDataAll(false)" @selectPageAll="isSelectDataAll(false)"
@selectAll="isSelectDataAll(true)"/> @selectAll="isSelectDataAll(true)"/>
<el-table-column v-if="!referenced" width="30" min-width="30" :render-header="labelHead" :resizable="false" align="center"> <el-table-column v-if="!referenced" width="30" min-width="30" :resizable="false" align="center">
<template v-slot:default="scope"> <template v-slot:default="scope">
<show-more-btn :is-show="isSelect(scope.row)" :buttons="buttons" :size="selectDataCounts"/> <show-more-btn :is-show="isSelect(scope.row)" :buttons="buttons" :size="selectDataCounts"/>
</template> </template>
@ -28,7 +29,7 @@
<el-table-column prop="num" label="ID" <el-table-column prop="num" label="ID"
sortable="custom" sortable="custom"
min-width="120px" :render-header="labelHead" min-width="120px"
show-overflow-tooltip> show-overflow-tooltip>
<template slot-scope="scope"> <template slot-scope="scope">
<el-tooltip content="编辑"> <el-tooltip content="编辑">
@ -40,14 +41,13 @@
sortable="custom" sortable="custom"
:label="$t('api_test.automation.scenario_name')" :label="$t('api_test.automation.scenario_name')"
show-overflow-tooltip show-overflow-tooltip
:render-header="labelHead"
min-width="120px"/> min-width="120px"/>
<el-table-column prop="level" <el-table-column prop="level"
sortable="custom" sortable="custom"
column-key="level" column-key="level"
:filters="levelFilters" :filters="levelFilters"
min-width="120px" min-width="120px"
:render-header="labelHead"
:label="$t('api_test.automation.case_level')" :label="$t('api_test.automation.case_level')"
show-overflow-tooltip> show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
@ -58,14 +58,14 @@
sortable="custom" sortable="custom"
column-key="status" column-key="status"
:filters="statusFilters" :filters="statusFilters"
:render-header="labelHead"
show-overflow-tooltip min-width="120px"> show-overflow-tooltip min-width="120px">
<template v-slot:default="scope"> <template v-slot:default="scope">
<plan-status-table-item :value="scope.row.status"/> <plan-status-table-item :value="scope.row.status"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="tags" min-width="120px" <el-table-column prop="tags" min-width="120px"
:render-header="labelHead" :label="$t('api_test.automation.tag')"> :label="$t('api_test.automation.tag')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<div v-for="(itemName,index) in scope.row.tags" :key="index"> <div v-for="(itemName,index) in scope.row.tags" :key="index">
<ms-tag type="success" effect="plain" :content="itemName"/> <ms-tag type="success" effect="plain" :content="itemName"/>
@ -73,22 +73,22 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="userId" min-width="120px" <el-table-column prop="userId" min-width="120px"
:render-header="labelHead" :label="$t('api_test.automation.creator')" :label="$t('api_test.automation.creator')"
:filters="userFilters" :filters="userFilters"
column-key="user_id" column-key="user_id"
sortable="custom" sortable="custom"
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column prop="updateTime" :label="$t('api_test.automation.update_time')" sortable="custom" min-width="180px" <el-table-column prop="updateTime" :label="$t('api_test.automation.update_time')" sortable="custom" min-width="180px"
:render-header="labelHead"> >
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="stepTotal" :label="$t('api_test.automation.step')" min-width="80px" <el-table-column prop="stepTotal" :label="$t('api_test.automation.step')" min-width="80px"
:render-header="labelHead" show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column prop="lastResult" :label="$t('api_test.automation.last_result')" <el-table-column prop="lastResult" :label="$t('api_test.automation.last_result')"
:filters="resultFilters" :filters="resultFilters"
:render-header="labelHead"
sortable="custom" column-key="last_result" min-width="120px"> sortable="custom" column-key="last_result" min-width="120px">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<el-link type="success" @click="showReport(row)" v-if="row.lastResult === 'Success'"> <el-link type="success" @click="showReport(row)" v-if="row.lastResult === 'Success'">
@ -101,7 +101,7 @@
</el-table-column> </el-table-column>
<el-table-column prop="passRate" :label="$t('api_test.automation.passing_rate')" <el-table-column prop="passRate" :label="$t('api_test.automation.passing_rate')"
min-width="120px" min-width="120px"
:render-header="labelHead"
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column fixed="right" :label="$t('commons.operating')" width="190px" v-if="!referenced"> <el-table-column fixed="right" :label="$t('commons.operating')" width="190px" v-if="!referenced">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
@ -609,12 +609,13 @@
_filter(filters, this.condition); _filter(filters, this.condition);
this.search(); this.search();
}, },
labelHead(h,{column,index}){ headerDragend(newWidth,oldWidth,column,event){
if(column.minWidth>column.realWidth){ let finalWidth = newWidth;
column.realWidth = column.minWidth; if(column.minWidth>finalWidth){
column.width = column.minWidth; finalWidth = column.minWidth;
} }
return column.label; column.width = finalWidth;
column.realWidth = finalWidth;
}, },
openScenario(item) { openScenario(item) {
this.$emit('openScenario', item) this.$emit('openScenario', item)

View File

@ -203,8 +203,9 @@
confirm() { confirm() {
if (this.selection.length==0) { if (this.selection.length==0) {
this.$warning(this.$t("api_test.definition.request.test_plan_select")); this.$warning(this.$t("api_test.definition.request.test_plan_select"));
} }else{
this.$emit('addTestPlan', this.selection); this.$emit('addTestPlan', this.selection);
}
}, },
cancel(){ cancel(){
this.$emit('cancel'); this.$emit('cancel');

View File

@ -15,6 +15,7 @@
@select-all="handleSelectAll" @select-all="handleSelectAll"
@filter-change="filter" @filter-change="filter"
@sort-change="sort" @sort-change="sort"
@header-dragend="headerDragend"
@select="handleSelect" :height="screenHeight"> @select="handleSelect" :height="screenHeight">
<el-table-column type="selection" width="50"/> <el-table-column type="selection" width="50"/>
@ -25,13 +26,13 @@
@selectPageAll="isSelectDataAll(false)" @selectPageAll="isSelectDataAll(false)"
@selectAll="isSelectDataAll(true)"/> @selectAll="isSelectDataAll(true)"/>
<el-table-column width="30" :resizable="false" min-width="30px" :render-header="labelHead" align="center"> <el-table-column width="30" :resizable="false" min-width="30px" align="center">
<template v-slot:default="scope"> <template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts"/> <show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="num" label="ID" min-width="120px" :render-header="labelHead" show-overflow-tooltip> <el-table-column prop="num" label="ID" min-width="120px" show-overflow-tooltip>
<template slot-scope="scope"> <template slot-scope="scope">
<el-tooltip content="编辑"> <el-tooltip content="编辑">
<a style="cursor:pointer" @click="handleTestCase(scope.row)"> {{ scope.row.num }} </a> <a style="cursor:pointer" @click="handleTestCase(scope.row)"> {{ scope.row.num }} </a>
@ -39,14 +40,14 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="name" min-width="160px" :render-header="labelHead" :label="$t('test_track.case.name')" show-overflow-tooltip/> <el-table-column prop="name" min-width="160px" :label="$t('test_track.case.name')" show-overflow-tooltip/>
<el-table-column <el-table-column
prop="priority" prop="priority"
:filters="priorityFilters" :filters="priorityFilters"
column-key="priority" column-key="priority"
min-width="120px" min-width="120px"
:render-header="labelHead"
:label="$t('test_track.case.priority')" :label="$t('test_track.case.priority')"
show-overflow-tooltip> show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
@ -59,10 +60,10 @@
prop="path" prop="path"
min-width="180px" min-width="180px"
:label="$t('api_test.definition.api_path')" :label="$t('api_test.definition.api_path')"
:render-header="labelHead"
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column prop="tags" min-width="120px" :render-header="labelHead" :label="$t('commons.tag')"> <el-table-column prop="tags" min-width="120px" :label="$t('commons.tag')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<div v-for="(itemName,index) in scope.row.tags" :key="index"> <div v-for="(itemName,index) in scope.row.tags" :key="index">
<ms-tag type="success" effect="plain" :content="itemName"/> <ms-tag type="success" effect="plain" :content="itemName"/>
@ -73,14 +74,14 @@
<el-table-column <el-table-column
prop="createUser" prop="createUser"
:label="'创建人'" :label="'创建人'"
:render-header="labelHead"
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column <el-table-column
sortable="custom" sortable="custom"
min-width="160" min-width="160"
:label="$t('api_test.definition.api_last_time')" :label="$t('api_test.definition.api_last_time')"
:render-header="labelHead"
prop="updateTime"> prop="updateTime">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
@ -507,12 +508,13 @@ export default {
this.clickRow = row; this.clickRow = row;
this.$refs.setEnvironment.open(row); this.$refs.setEnvironment.open(row);
}, },
labelHead(h,{column,index}){ headerDragend(newWidth,oldWidth,column,event){
if(column.minWidth>column.realWidth){ let finalWidth = newWidth;
column.realWidth = column.minWidth; if(column.minWidth>finalWidth){
column.width = column.minWidth; finalWidth = column.minWidth;
} }
return column.label; column.width = finalWidth;
column.realWidth = finalWidth;
}, },
createPerformance(row, environment) { createPerformance(row, environment) {
/** /**

View File

@ -17,6 +17,7 @@
@filter-change="filter" @filter-change="filter"
:data="tableData" row-key="id" class="test-content adjust-table ms-select-all-fixed" :data="tableData" row-key="id" class="test-content adjust-table ms-select-all-fixed"
@select-all="handleSelectAll" @select-all="handleSelectAll"
@header-dragend="headerDragend"
@select="handleSelect" :height="screenHeight"> @select="handleSelect" :height="screenHeight">
<el-table-column width="50" type="selection"/> <el-table-column width="50" type="selection"/>
@ -34,7 +35,7 @@
<el-table-column prop="num" label="ID" show-overflow-tooltip <el-table-column prop="num" label="ID" show-overflow-tooltip
min-width="80px" min-width="80px"
:render-header="labelHead"
sortable="custom"> sortable="custom">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tooltip content="编辑"> <el-tooltip content="编辑">
@ -44,14 +45,14 @@
</el-table-column> </el-table-column>
<el-table-column prop="name" :label="$t('api_test.definition.api_name')" <el-table-column prop="name" :label="$t('api_test.definition.api_name')"
show-overflow-tooltip show-overflow-tooltip
:render-header="labelHead"
sortable="custom" min-width="120px"/> sortable="custom" min-width="120px"/>
<el-table-column <el-table-column
prop="status" prop="status"
column-key="status" column-key="status"
sortable="custom" sortable="custom"
:filters="statusFilters" :filters="statusFilters"
:render-header="labelHead"
:label="$t('api_test.definition.api_status')" min-width="120px"> :label="$t('api_test.definition.api_status')" min-width="120px">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
@ -65,7 +66,7 @@
sortable="custom" sortable="custom"
column-key="method" column-key="method"
:filters="methodFilters" :filters="methodFilters"
:render-header="labelHead"
:label="$t('api_test.definition.api_type')" :label="$t('api_test.definition.api_type')"
show-overflow-tooltip min-width="120px"> show-overflow-tooltip min-width="120px">
<template v-slot:default="scope" class="request-method"> <template v-slot:default="scope" class="request-method">
@ -82,19 +83,19 @@
sortable="custom" sortable="custom"
:filters="userFilters" :filters="userFilters"
column-key="user_id" column-key="user_id"
:render-header="labelHead"
:label="$t('api_test.definition.api_principal')" :label="$t('api_test.definition.api_principal')"
show-overflow-tooltip min-width="100px"/> show-overflow-tooltip min-width="100px"/>
<el-table-column <el-table-column
prop="path" prop="path"
min-width="120px" min-width="120px"
:render-header="labelHead"
:label="$t('api_test.definition.api_path')" :label="$t('api_test.definition.api_path')"
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column prop="tags" :label="$t('commons.tag')" min-width="80px" <el-table-column prop="tags" :label="$t('commons.tag')" min-width="80px"
:render-header="labelHead"> >
<template v-slot:default="scope"> <template v-slot:default="scope">
<div v-for="(itemName,index) in scope.row.tags" :key="index"> <div v-for="(itemName,index) in scope.row.tags" :key="index">
<ms-tag type="success" effect="plain" :content="itemName"/> <ms-tag type="success" effect="plain" :content="itemName"/>
@ -107,7 +108,7 @@
:label="$t('api_test.definition.api_last_time')" :label="$t('api_test.definition.api_last_time')"
sortable="custom" sortable="custom"
min-width="160px" min-width="160px"
:render-header="labelHead"
prop="updateTime"> prop="updateTime">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
@ -117,14 +118,14 @@
<el-table-column <el-table-column
prop="caseTotal" prop="caseTotal"
min-width="80px" min-width="80px"
:render-header="labelHead"
:label="$t('api_test.definition.api_case_number')" :label="$t('api_test.definition.api_case_number')"
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column <el-table-column
prop="caseStatus" prop="caseStatus"
min-width="80px" min-width="80px"
:render-header="labelHead"
:label="$t('api_test.definition.api_case_status')" :label="$t('api_test.definition.api_case_status')"
show-overflow-tooltip/> show-overflow-tooltip/>
@ -132,7 +133,7 @@
prop="casePassingRate" prop="casePassingRate"
:width="100" :width="100"
min-width="100px" min-width="100px"
:render-header="labelHead"
:label="$t('api_test.definition.api_case_passing_rate')" :label="$t('api_test.definition.api_case_passing_rate')"
show-overflow-tooltip/> show-overflow-tooltip/>
@ -693,12 +694,13 @@ export default {
_filter(filters, this.condition); _filter(filters, this.condition);
this.initTable(); this.initTable();
}, },
labelHead(h,{column,index}){ headerDragend(newWidth,oldWidth,column,event){
if(column.minWidth>column.realWidth){ let finalWidth = newWidth;
column.realWidth = column.minWidth; if(column.minWidth>finalWidth){
column.width = column.minWidth; finalWidth = column.minWidth;
} }
return column.label; column.width = finalWidth;
column.realWidth = finalWidth;
}, },
open() { open() {
this.$refs.searchBar.open(); this.$refs.searchBar.open();

View File

@ -29,6 +29,7 @@
@filter-change="filter" @filter-change="filter"
@select-all="handleSelectAll" @select-all="handleSelectAll"
@select="handleSelect" @select="handleSelect"
@header-dragend="headerDragend"
@cell-mouse-enter="showPopover" @cell-mouse-enter="showPopover"
row-key="id" row-key="id"
class="test-content adjust-table ms-select-all-fixed" class="test-content adjust-table ms-select-all-fixed"
@ -562,12 +563,13 @@ export default {
this.selectDataCounts = this.selectRows.size; this.selectDataCounts = this.selectRows.size;
} }
}, },
labelHead(h,{column,index}){ headerDragend(newWidth,oldWidth,column,event){
if(column.minWidth>column.realWidth){ let finalWidth = newWidth;
column.realWidth = column.minWidth; if(column.minWidth>finalWidth){
column.width = column.minWidth; finalWidth = column.minWidth;
} }
return column.label; column.width = finalWidth;
column.realWidth = finalWidth;
}, },
moveSave(param) { moveSave(param) {
param.condition = this.condition; param.condition = this.condition;

View File

@ -35,6 +35,7 @@
@select="handleSelectionChange" @select="handleSelectionChange"
row-key="id" row-key="id"
@row-click="showDetail" @row-click="showDetail"
@header-dragend="headerDragend"
:data="tableData"> :data="tableData">
<el-table-column <el-table-column
@ -49,14 +50,14 @@
sortable="custom" sortable="custom"
:label="$t('commons.id')" :label="$t('commons.id')"
min-width="120px" min-width="120px"
:render-header="labelHead"
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="name" prop="name"
:label="$t('commons.name')" :label="$t('commons.name')"
min-width="120px" min-width="120px"
:render-header="labelHead"
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -64,7 +65,7 @@
:filters="priorityFilters" :filters="priorityFilters"
column-key="priority" column-key="priority"
min-width="100px" min-width="100px"
:render-header="labelHead"
:label="$t('test_track.case.priority')"> :label="$t('test_track.case.priority')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<priority-table-item :value="scope.row.priority" ref="priority"/> <priority-table-item :value="scope.row.priority" ref="priority"/>
@ -77,7 +78,7 @@
column-key="type" column-key="type"
:label="$t('test_track.case.type')" :label="$t('test_track.case.type')"
min-width="80px" min-width="80px"
:render-header="labelHead"
show-overflow-tooltip> show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
<type-table-item :value="scope.row.type"/> <type-table-item :value="scope.row.type"/>
@ -85,7 +86,7 @@
</el-table-column> </el-table-column>
<el-table-column prop="tags" :label="$t('commons.tag')" min-width="120px" <el-table-column prop="tags" :label="$t('commons.tag')" min-width="120px"
:render-header="labelHead"> >
<template v-slot:default="scope"> <template v-slot:default="scope">
<div v-for="(tag, index) in scope.row.showTags" :key="tag + '_' + index"> <div v-for="(tag, index) in scope.row.showTags" :key="tag + '_' + index">
<ms-tag type="success" effect="plain" :content="tag"/> <ms-tag type="success" effect="plain" :content="tag"/>
@ -99,7 +100,7 @@
column-key="method" column-key="method"
:label="$t('test_track.case.method')" :label="$t('test_track.case.method')"
min-width="100px" min-width="100px"
:render-header="labelHead"
show-overflow-tooltip> show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
<method-table-item :value="scope.row.method"/> <method-table-item :value="scope.row.method"/>
@ -110,7 +111,7 @@
prop="nodePath" prop="nodePath"
:label="$t('test_track.case.module')" :label="$t('test_track.case.module')"
min-width="120px" min-width="120px"
:render-header="labelHead"
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
@ -118,14 +119,14 @@
prop="projectName" prop="projectName"
:label="$t('test_track.plan.plan_project')" :label="$t('test_track.plan.plan_project')"
min-width="120px" min-width="120px"
:render-header="labelHead"
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:label="$t('test_track.issue.issue')" :label="$t('test_track.issue.issue')"
min-width="80px" min-width="80px"
:render-header="labelHead"
show-overflow-tooltip> show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-popover <el-popover
@ -159,7 +160,7 @@
prop="executorName" prop="executorName"
:filters="executorFilters" :filters="executorFilters"
min-width="100px" min-width="100px"
:render-header="labelHead"
column-key="executor" column-key="executor"
:label="$t('test_track.plan_view.executor')"> :label="$t('test_track.plan_view.executor')">
</el-table-column> </el-table-column>
@ -169,7 +170,7 @@
:filters="statusFilters" :filters="statusFilters"
column-key="status" column-key="status"
min-width="100px" min-width="100px"
:render-header="labelHead"
:label="$t('test_track.plan_view.execute_result')"> :label="$t('test_track.plan_view.execute_result')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span @click.stop="clickt = 'stop'"> <span @click.stop="clickt = 'stop'">
@ -203,7 +204,7 @@
prop="updateTime" prop="updateTime"
:label="$t('commons.update_time')" :label="$t('commons.update_time')"
min-width="120px" min-width="120px"
:render-header="labelHead"
show-overflow-tooltip> show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
@ -595,12 +596,13 @@ export default {
_sort(column, this.condition); _sort(column, this.condition);
this.initTableData(); this.initTableData();
}, },
labelHead(h,{column,index}){ headerDragend(newWidth,oldWidth,column,event){
if(column.minWidth>column.realWidth){ let finalWidth = newWidth;
column.realWidth = column.minWidth; if(column.minWidth>finalWidth){
column.width = column.minWidth; finalWidth = column.minWidth;
} }
return column.label; column.width = finalWidth;
column.realWidth = finalWidth;
}, },
batchEdit(form) { batchEdit(form) {
let param = {}; let param = {};