fix(测试跟踪): 测试计划关联用例列表筛选后未重置当前页码

--bug=1029816 --user=宋昌昌 【测试跟踪】测试计划-关联功能用例-执行结果切换-显示异常 https://www.tapd.cn/55049933/s/1413553
This commit is contained in:
song-cc-rock 2023-09-06 18:16:55 +08:00 committed by 刘瑞斌
parent cebeb1003a
commit ace43fd93f
1 changed files with 217 additions and 212 deletions

View File

@ -21,141 +21,141 @@
</ms-table-header> </ms-table-header>
<ms-table <ms-table
v-loading="result.loading" v-loading="result.loading"
:field-key="tableHeaderKey" :field-key="tableHeaderKey"
:data="tableData" :data="tableData"
:condition="condition" :condition="condition"
:total="total" :total="total"
:operators="operators" :operators="operators"
:page-size.sync="pageSize" :page-size.sync="pageSize"
:screen-height="screenHeight" :screen-height="screenHeight"
:batch-operators="buttons" :batch-operators="buttons"
:fields.sync="fields" :fields.sync="fields"
:remember-order="true" :remember-order="true"
:row-order-group-id="planId" :row-order-group-id="planId"
:row-order-func="editTestPlanTestCaseOrder" :row-order-func="editTestPlanTestCaseOrder"
:enable-order-drag="enableOrderDrag" :enable-order-drag="enableOrderDrag"
:custom-fields="testCaseTemplate.customFields" :custom-fields="testCaseTemplate.customFields"
@filter="search" @filter="search"
@order="initTableData" @order="initTableData"
@handlePageChange="initTableData" @handlePageChange="initTableData"
@handleRowClick="handleEdit" @handleRowClick="handleEdit"
row-key="id" row-key="id"
ref="table"> ref="table">
<span v-for="item in fields" :key="item.key"> <span v-for="item in fields" :key="item.key">
<ms-table-column <ms-table-column
v-if="item.id == 'num'" v-if="item.id == 'num'"
prop="customNum" prop="customNum"
sortable="custom" sortable="custom"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('commons.id')" :label="$t('commons.id')"
min-width="120px"/> min-width="120px"/>
<ms-table-column <ms-table-column
prop="name" prop="name"
sortable="custom" sortable="custom"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('commons.name')" :label="$t('commons.name')"
min-width="120px"/> min-width="120px"/>
<ms-table-column <ms-table-column
v-if="versionEnable" v-if="versionEnable"
prop="versionId" prop="versionId"
:field="item" :field="item"
:filters="versionFilters" :filters="versionFilters"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('commons.version')" :label="$t('commons.version')"
min-width="120px"> min-width="120px">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.versionName }}</span> <span>{{ scope.row.versionName }}</span>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
prop="priority" prop="priority"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:filters="priorityOptions" :filters="priorityOptions"
sortable="custom" sortable="custom"
min-width="120px" min-width="120px"
: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 <priority-table-item
:value="scope.row.priority" :value="scope.row.priority"
:priority-options="priorityOptions" :priority-options="priorityOptions"
ref="priority"/> ref="priority"/>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
prop="tags" prop="tags"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('commons.tag')" :label="$t('commons.tag')"
min-width="120px" min-width="120px"
:show-overflow-tooltip="false" :show-overflow-tooltip="false"
> >
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-tooltip class="item" effect="dark" placement="top"> <el-tooltip class="item" effect="dark" placement="top">
<div v-html="getTagToolTips(scope.row.tags)" slot="content"></div> <div v-html="getTagToolTips(scope.row.tags)" slot="content"></div>
<div class="oneLine"> <div class="oneLine">
<ms-tag <ms-tag
v-for="(itemName, index) in scope.row.tags" v-for="(itemName, index) in scope.row.tags"
:key="index" :key="index"
type="success" type="success"
effect="plain" effect="plain"
:show-tooltip="scope.row.tags.length === 1 && itemName.length * 12 <= 100" :show-tooltip="scope.row.tags.length === 1 && itemName.length * 12 <= 100"
:content="itemName" :content="itemName"
style="margin-left: 0px; margin-right: 2px" /> style="margin-left: 0px; margin-right: 2px"/>
</div> </div>
</el-tooltip> </el-tooltip>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
sortable="custom" sortable="custom"
prop="createTime" prop="createTime"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('commons.create_time')" :label="$t('commons.create_time')"
min-width="140px"> min-width="140px">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.createTime | datetimeFormat }}</span> <span>{{ scope.row.createTime | datetimeFormat }}</span>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
prop="nodePath" prop="nodePath"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('test_track.case.module')" :label="$t('test_track.case.module')"
min-width="120px"/> min-width="120px"/>
<ms-table-column <ms-table-column
prop="projectName" prop="projectName"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('test_track.plan.plan_project')" :label="$t('test_track.plan.plan_project')"
min-width="120px"/> min-width="120px"/>
<ms-table-column <ms-table-column
prop="issuesContent" prop="issuesContent"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('test_track.issue.issue')" :label="$t('test_track.issue.issue')"
min-width="80px"> min-width="80px">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-popover <el-popover
placement="right" placement="right"
width="400" width="400"
trigger="hover"> trigger="hover">
<test-plan-case-issue-item <test-plan-case-issue-item
v-if="scope.row.issuesSize && scope.row.issuesSize > 0" v-if="scope.row.issuesSize && scope.row.issuesSize > 0"
:data="scope.row"/> :data="scope.row"/>
<el-button <el-button
slot="reference" slot="reference"
type="text"> type="text">
<span @mouseover="loadIssue(scope.row)"> <span @mouseover="loadIssue(scope.row)">
{{ scope.row.issuesSize }} {{ scope.row.issuesSize }}
</span> </span>
@ -165,12 +165,12 @@
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
prop="executor" prop="executor"
:filters="userFilters" :filters="userFilters"
min-width="100px" min-width="100px"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('test_track.plan_view.executor')"> :label="$t('test_track.plan_view.executor')">
<template v-slot:default="scope"> <template v-slot:default="scope">
{{ scope.row.executorName }} {{ scope.row.executorName }}
</template> </template>
@ -178,20 +178,20 @@
<!-- 责任人(创建该用例时所关联的责任人) --> <!-- 责任人(创建该用例时所关联的责任人) -->
<ms-table-column <ms-table-column
prop="maintainerName" prop="maintainerName"
:filters="userFilters" :filters="userFilters"
min-width="100px" min-width="100px"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('test_track.plan.plan_principal')"/> :label="$t('test_track.plan.plan_principal')"/>
<ms-table-column <ms-table-column
prop="status" prop="status"
:filters="statusFilters" :filters="statusFilters"
min-width="100px" min-width="100px"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
: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'">
<el-dropdown class="test-case-status" @command="statusChange"> <el-dropdown class="test-case-status" @command="statusChange">
@ -222,12 +222,12 @@
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
sortable="custom" sortable="custom"
prop="updateTime" prop="updateTime"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('commons.update_time')" :label="$t('commons.update_time')"
min-width="140px"> min-width="140px">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.updateTime | datetimeFormat }}</span> <span>{{ scope.row.updateTime | datetimeFormat }}</span>
</template> </template>
@ -244,7 +244,7 @@
<template v-slot="scope"> <template v-slot="scope">
<span v-if="field.name === '用例等级'"> <span v-if="field.name === '用例等级'">
<priority-table-item <priority-table-item
:value="getCustomFieldValue(scope.row, field)" :priority-options="priorityOptions"/> :value="getCustomFieldValue(scope.row, field)" :priority-options="priorityOptions"/>
</span> </span>
<span v-else-if="field.name === '用例状态'"> <span v-else-if="field.name === '用例状态'">
{{ getCustomFieldValue(scope.row, field, scope.row.caseStatus) }} {{ getCustomFieldValue(scope.row, field, scope.row.caseStatus) }}
@ -262,19 +262,19 @@
:total="total"/> :total="total"/>
<functional-test-case-edit <functional-test-case-edit
ref="testPlanTestCaseEdit" ref="testPlanTestCaseEdit"
:search-param.sync="condition" :search-param.sync="condition"
:page-num="currentPage" :page-num="currentPage"
:page-size="pageSize" :page-size="pageSize"
:next-page-data="nextPageData" :next-page-data="nextPageData"
:pre-page-data="prePageData" :pre-page-data="prePageData"
@nextPage="nextPage" @nextPage="nextPage"
@prePage="prePage" @prePage="prePage"
@refresh="initTableData" @refresh="initTableData"
:test-cases="tableData" :test-cases="tableData"
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
:total="total" :total="total"
@refreshTable="initTableData"/> @refreshTable="initTableData"/>
<batch-edit ref="batchEdit" @batchEdit="batchEdit" <batch-edit ref="batchEdit" @batchEdit="batchEdit"
:type-arr="typeArr" :value-arr="valueArr" :dialog-title="$t('test_track.case.batch_edit_case')"/> :type-arr="typeArr" :value-arr="valueArr" :dialog-title="$t('test_track.case.batch_edit_case')"/>
@ -304,12 +304,12 @@ import BatchEdit from "../../../../case/components/BatchEdit";
import MsTag from "metersphere-frontend/src/components/MsTag"; import MsTag from "metersphere-frontend/src/components/MsTag";
import { import {
buildBatchParam, buildBatchParam,
getCustomFieldFilter,
getCustomTableHeader, getCustomTableHeader,
getCustomTableWidth, getCustomTableWidth,
getLastTableSortField, getLastTableSortField,
getTableHeaderWithCustomFields, getTableHeaderWithCustomFields,
initCondition, initCondition,
getCustomFieldFilter,
parseCustomFilesForList, parseCustomFilesForList,
} from "metersphere-frontend/src/utils/tableUtils"; } from "metersphere-frontend/src/utils/tableUtils";
import MsTable from "metersphere-frontend/src/components/table/MsTable"; import MsTable from "metersphere-frontend/src/components/table/MsTable";
@ -319,16 +319,20 @@ import {getTestTemplateForList} from "@/api/custom-field-template";
import { import {
editTestPlanTestCaseOrder, editTestPlanTestCaseOrder,
testPlanAutoCheck, testPlanAutoCheck,
testPlanEditStatus, testPlanFresh, testPlanEditStatus,
testPlanFresh,
testPlanGet testPlanGet
} from "@/api/remote/plan/test-plan"; } from "@/api/remote/plan/test-plan";
import {SYSTEM_FIELD_NAME_MAP} from "metersphere-frontend/src/utils/table-constants"; import {SYSTEM_FIELD_NAME_MAP} from "metersphere-frontend/src/utils/table-constants";
import {getTestPlanTestCase} from "@/api/testCase"; import {getTestPlanTestCase} from "@/api/testCase";
import TestPlanCaseIssueItem from "@/business/plan/view/comonents/functional/TestPlanCaseIssueItem"; import TestPlanCaseIssueItem from "@/business/plan/view/comonents/functional/TestPlanCaseIssueItem";
import { import {
generateColumnKey,
getAdvSearchCustomField,
getCustomFieldValueForTrack,
getProjectMemberOption, getProjectMemberOption,
getProjectVersions, getProjectVersions,
getAdvSearchCustomField, parseTag, getCustomFieldValueForTrack, generateColumnKey parseTag
} from "@/business/utils/sdk-utils"; } from "@/business/utils/sdk-utils";
import { import {
testPlanTestCaseBatchDelete, testPlanTestCaseBatchDelete,
@ -552,10 +556,10 @@ export default {
loadIssue(row) { loadIssue(row) {
if (row.issuesSize && !row.hasLoadIssue) { if (row.issuesSize && !row.hasLoadIssue) {
getOriginIssuesByCaseId('PLAN_FUNCTIONAL', row.id) getOriginIssuesByCaseId('PLAN_FUNCTIONAL', row.id)
.then(r => { .then(r => {
this.$set(row, "issuesContent", r.data); this.$set(row, "issuesContent", r.data);
this.$set(row, "hasLoadIssue", true); this.$set(row, "hasLoadIssue", true);
}); });
} }
}, },
handleOpenFailureTestCase(row) { handleOpenFailureTestCase(row) {
@ -578,9 +582,9 @@ export default {
getTemplateField() { getTemplateField() {
this.result.loading = true; this.result.loading = true;
let p1 = getProjectMember() let p1 = getProjectMember()
.then((response) => { .then((response) => {
this.members = response.data; this.members = response.data;
}); });
let p2 = getTestTemplateForList(); let p2 = getTestTemplateForList();
Promise.all([p1, p2]).then((data) => { Promise.all([p1, p2]).then((data) => {
let template = data[1]; let template = data[1];
@ -626,6 +630,7 @@ export default {
return value ? value : defaultVal; return value ? value : defaultVal;
}, },
initTableData(callback) { initTableData(callback) {
this.currentPage = 1;
initCondition(this.condition, this.condition.selectAll); initCondition(this.condition, this.condition.selectAll);
this.enableOrderDrag = this.condition.orders.length > 0 ? false : true; this.enableOrderDrag = this.condition.orders.length > 0 ? false : true;
@ -655,59 +660,59 @@ export default {
this.condition.projectId = getCurrentProjectID(); this.condition.projectId = getCurrentProjectID();
if (this.planId) { if (this.planId) {
this.result = getTestPlanTestCase(this.currentPage, this.pageSize, this.condition) this.result = getTestPlanTestCase(this.currentPage, this.pageSize, this.condition)
.then((r) => { .then((r) => {
this.total = r.data.itemCount; this.total = r.data.itemCount;
this.pageCount = Math.ceil(this.total / this.pageSize); this.pageCount = Math.ceil(this.total / this.pageSize);
this.tableData = r.data.listObject; this.tableData = r.data.listObject;
parseTag(this.tableData); parseTag(this.tableData);
parseCustomFilesForList(this.tableData); parseCustomFilesForList(this.tableData);
for (let i = 0; i < this.tableData.length; i++) { for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i]) { if (this.tableData[i]) {
if (this.tableData[i].customFields) { if (this.tableData[i].customFields) {
this.tableData[i].customFields = JSON.parse(this.tableData[i].customFields); this.tableData[i].customFields = JSON.parse(this.tableData[i].customFields);
}
this.$set(this.tableData[i], "showTags", this.tableData[i].tags);
this.$set(this.tableData[i], "issuesSize", this.tableData[i].issuesCount);
this.$set(this.tableData[i], "hasLoadIssue", false);
this.$set(this.tableData[i], "issuesContent", []);
} }
this.$set(this.tableData[i], "showTags", this.tableData[i].tags);
this.$set(this.tableData[i], "issuesSize", this.tableData[i].issuesCount);
this.$set(this.tableData[i], "hasLoadIssue", false);
this.$set(this.tableData[i], "issuesContent", []);
} }
}
// tableData // tableData
this.getPreData(); this.getPreData();
if (typeof callback === "function") { if (typeof callback === "function") {
callback(); callback();
} }
}); });
this.getNexPageData(); this.getNexPageData();
} }
}, },
getNexPageData() { getNexPageData() {
getTestPlanTestCase(this.currentPage * this.pageSize + 1, 1, this.condition) getTestPlanTestCase(this.currentPage * this.pageSize + 1, 1, this.condition)
.then((r) => { .then((r) => {
if (r.data.listObject && r.data.listObject.length > 0) { if (r.data.listObject && r.data.listObject.length > 0) {
this.nextPageData = { this.nextPageData = {
name: r.data.listObject[0].name name: r.data.listObject[0].name
}
} else {
this.nextPageData = null;
} }
} else { });
this.nextPageData = null;
}
});
}, },
getPreData() { getPreData() {
// //
if (this.currentPage > 1 && this.tableData.length === 1) { if (this.currentPage > 1 && this.tableData.length === 1) {
getTestPlanTestCase((this.currentPage - 1) * this.pageSize, 1, this.condition) getTestPlanTestCase((this.currentPage - 1) * this.pageSize, 1, this.condition)
.then((r) => { .then((r) => {
if (r.data.listObject && r.data.listObject.length > 0) { if (r.data.listObject && r.data.listObject.length > 0) {
this.prePageData = { this.prePageData = {
name: r.data.listObject[0].name name: r.data.listObject[0].name
}
} else {
this.prePageData = null;
} }
} else { });
this.prePageData = null;
}
});
} }
}, },
autoCheckStatus() { autoCheckStatus() {
@ -764,10 +769,10 @@ export default {
if (action === 'confirm') { if (action === 'confirm') {
let param = buildBatchParam(this, this.$refs.table.selectIds); let param = buildBatchParam(this, this.$refs.table.selectIds);
testPlanTestCaseBatchDelete(param) testPlanTestCaseBatchDelete(param)
.then(() => { .then(() => {
this.refresh(); this.refresh();
this.$success(this.$t('test_track.cancel_relevance_success')); this.$success(this.$t('test_track.cancel_relevance_success'));
}); });
} }
} }
}); });
@ -775,10 +780,10 @@ export default {
_handleDelete(testCase) { _handleDelete(testCase) {
let testCaseId = testCase.id; let testCaseId = testCase.id;
testPlanTestCaseDelete(testCaseId) testPlanTestCaseDelete(testCaseId)
.then(() => { .then(() => {
this.refresh(); this.refresh();
this.$success(this.$t('test_track.cancel_relevance_success')); this.$success(this.$t('test_track.cancel_relevance_success'));
}); });
}, },
searchMyTestCase() { searchMyTestCase() {
this.showMyTestCase = !this.showMyTestCase; this.showMyTestCase = !this.showMyTestCase;
@ -792,15 +797,15 @@ export default {
}, },
statusChange(param) { statusChange(param) {
testPlanTestCaseEdit(param) testPlanTestCaseEdit(param)
.then(() => { .then(() => {
for (let i = 0; i < this.tableData.length; i++) { for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i].id == param.id) { if (this.tableData[i].id == param.id) {
this.tableData[i].status = param.status; this.tableData[i].status = param.status;
break; break;
}
} }
} this.updatePlanStatus();
this.updatePlanStatus(); });
});
}, },
updatePlanStatus() { updatePlanStatus() {
testPlanAutoCheck(this.planId); testPlanAutoCheck(this.planId);
@ -808,10 +813,10 @@ export default {
getTestPlanById() { getTestPlanById() {
if (this.planId) { if (this.planId) {
testPlanGet(this.planId) testPlanGet(this.planId)
.then(response => { .then(response => {
this.testPlan = response.data; this.testPlan = response.data;
testPlanFresh(this.planId); testPlanFresh(this.planId);
}); });
} }
}, },
batchEdit(form) { batchEdit(form) {
@ -822,12 +827,12 @@ export default {
} }
param.ids = this.$refs.table.selectIds; param.ids = this.$refs.table.selectIds;
testPlanTestCaseBatchEdit(param) testPlanTestCaseBatchEdit(param)
.then(() => { .then(() => {
this.status = ''; this.status = '';
testPlanEditStatus(this.planId); testPlanEditStatus(this.planId);
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.refresh(); this.refresh();
}); });
}, },
handleBatchEdit() { handleBatchEdit() {
this.getMaintainerOptions(); this.getMaintainerOptions();
@ -835,22 +840,22 @@ export default {
}, },
getMaintainerOptions() { getMaintainerOptions() {
getProjectMemberOption() getProjectMemberOption()
.then(response => { .then(response => {
this.valueArr.executor = response.data; this.valueArr.executor = response.data;
this.userFilters = response.data.map(u => { this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id}; return {text: u.name, value: u.id};
});
}); });
});
}, },
getVersionOptions() { getVersionOptions() {
if (hasLicense()) { if (hasLicense()) {
getProjectVersions(getCurrentProjectID()) getProjectVersions(getCurrentProjectID())
.then((response) => { .then((response) => {
this.versionOptions = response.data; this.versionOptions = response.data;
this.versionFilters = response.data.map(u => { this.versionFilters = response.data.map(u => {
return {text: u.name, value: u.id}; return {text: u.name, value: u.id};
});
}); });
});
} }
}, },
getTagToolTips(tags) { getTagToolTips(tags) {