fix(工作台): 测试计划列表通过率显示错误

--bug=1025720 --user=宋昌昌 【工作台】我的待办-测试计划-测试进度显示错误 https://www.tapd.cn/55049933/s/1365641
This commit is contained in:
song-cc-rock 2023-04-23 15:06:46 +08:00 committed by jianxing
parent 14c0ff4e0f
commit f108cd773c
2 changed files with 38 additions and 3 deletions

View File

@ -19,3 +19,7 @@ export function getPlanList(goPage, pageSize,param) {
export function editPlan(param) { export function editPlan(param) {
return post('/test/plan/edit',param); return post('/test/plan/edit',param);
} }
export function getTestPlanMetricDataList(ids) {
return post('/test/plan/metric', ids);
}

View File

@ -189,7 +189,7 @@ import MsDialogFooter from "metersphere-frontend/src/components/MsDialogFooter";
import MsTablePagination from 'metersphere-frontend/src/components/pagination/TablePagination'; import MsTablePagination from 'metersphere-frontend/src/components/pagination/TablePagination';
import {TEST_PLAN_CONFIGS} from "metersphere-frontend/src/components/search/search-components"; import {TEST_PLAN_CONFIGS} from "metersphere-frontend/src/components/search/search-components";
import {getCustomTableHeaderByXpack} from "@/business/component/js/table-head-util"; import {getCustomTableHeaderByXpack} from "@/business/component/js/table-head-util";
import {editPlan, getDashboardPlanList, getPlanList, getPlanStageOption, getPrincipalById} from "@/api/test-plan"; import {editPlan, getDashboardPlanList, getPlanList, getPlanStageOption, getPrincipalById, getTestPlanMetricDataList} from "@/api/test-plan";
export default { export default {
name: "PlanTableList", name: "PlanTableList",
@ -338,12 +338,12 @@ export default {
dealResponseData(data){ dealResponseData(data){
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;
let testPlanIds = [];
this.tableData.forEach(item => { this.tableData.forEach(item => {
testPlanIds.push(item.id);
if (item.tags && item.tags.length > 0) { if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags); item.tags = JSON.parse(item.tags);
} }
item.passRate = item.passRate + '%';
item.testRate = item.testRate ? item.testRate : 0;
getPrincipalById(item.id).then(res => { getPrincipalById(item.id).then(res => {
let data = res.data; let data = res.data;
let principal = ""; let principal = "";
@ -362,6 +362,37 @@ export default {
this.$set(item, "principals", principalIds); this.$set(item, "principals", principalIds);
}) })
}); });
console.log(testPlanIds)
this.getTestPlanDetailData(testPlanIds);
},
getTestPlanDetailData(testPlanIds) {
getTestPlanMetricDataList(testPlanIds)
.then((res) => {
let metricDataList = res.data;
if (metricDataList && metricDataList.length > 0) {
this.tableData.forEach((item) => {
let metricData = null;
metricDataList.forEach((metricItem) => {
if (item.id === metricItem.id) {
metricData = metricItem;
}
});
if (metricData) {
this.$set(item, "passRate", metricData['passRate'] + '%');
this.$set(item, "testRate", metricData['testRate']);
} else {
this.$set(item, "passRate", 0);
this.$set(item, "testRate", 0);
}
});
}
})
.catch(() => {
this.tableData.forEach((item) => {
this.$set(item, "passRate", 0);
this.$set(item, "testRate", 0);
});
});
}, },
statusChange(data) { statusChange(data) {
if (!hasPermission('PROJECT_TRACK_PLAN:READ+EDIT')) { if (!hasPermission('PROJECT_TRACK_PLAN:READ+EDIT')) {