fix(测试跟踪): 修复测试计划报告批量操作按钮不展示的问题

--bug=1021687 --user=宋天阳 【测试跟踪】测试计划报告批量操作按钮没了
https://www.tapd.cn/55049933/s/1324357
This commit is contained in:
song-tianyang 2023-01-09 16:08:52 +08:00 committed by 建国
parent 6f4f561aaf
commit 451663bab3
2 changed files with 252 additions and 168 deletions

View File

@ -27,9 +27,18 @@
@row-click="handleRowClick" @row-click="handleRowClick"
ref="table" ref="table"
> >
<el-table-column v-if="enableSelection && !reserveOption" width="50" type="selection"/> <el-table-column
v-if="enableSelection && !reserveOption"
width="50"
type="selection"
/>
<el-table-column v-if="enableSelection && reserveOption" width="50" type="selection" reserve-selection/> <el-table-column
v-if="enableSelection && reserveOption"
width="50"
type="selection"
reserve-selection
/>
<ms-table-header-select-popover <ms-table-header-select-popover
v-if="enableSelection && showSelectAll && !hidePopover" v-if="enableSelection && showSelectAll && !hidePopover"
@ -46,7 +55,7 @@
v-if="enableSelection && batchOperators && batchOperators.length > 0" v-if="enableSelection && batchOperators && batchOperators.length > 0"
width="15" width="15"
fixed="left" fixed="left"
column-key="batchBtnCol" class-name="padding-col"
align="center" align="center"
:resizable="false" :resizable="false"
> >
@ -565,7 +574,7 @@ export default {
this.tableActive = true; this.tableActive = true;
}); });
this.listenRowDrop(); this.listenRowDrop();
this.$emit('headChange'); this.$emit("headChange");
}, },
toggleRowSelection() { toggleRowSelection() {
this.$refs.table.toggleRowSelection(); this.$refs.table.toggleRowSelection();

View File

@ -1,13 +1,16 @@
<template> <template>
<el-card class="table-card" v-loading="loading"> <el-card class="table-card" v-loading="loading">
<template v-slot:header> <template v-slot:header>
<ms-table-header :condition.sync="condition" :show-create="false" <ms-table-header
@search="initTableData"/> :condition.sync="condition"
:show-create="false"
@search="initTableData"
/>
</template> </template>
<ms-table <ms-table
v-loading="loading" v-loading="loading"
operator-width="100px" operator-width="220px"
row-key="id" row-key="id"
:data="tableData" :data="tableData"
:condition="condition" :condition="condition"
@ -21,113 +24,148 @@
:field-key="tableHeaderKey" :field-key="tableHeaderKey"
@handlePageChange="initTableData" @handlePageChange="initTableData"
@refresh="initTableData" @refresh="initTableData"
ref="testPlanReportTable"> ref="testPlanReportTable"
>
<span v-for="item in fields" :key="item.key"> <span v-for="item in fields" :key="item.key">
<ms-table-column
prop="name"
permission="PROJECT_TRACK_REPORT:READ+DELETE"
:field="item"
:fields-width="fieldsWidth"
sortable
:label="$t('test_track.report.list.name')"
:show-overflow-tooltip="false"
:editable="true"
:edit-content="$t('report.rename_report')"
@editColumn="openReNameDialog"
min-width="200px"
>
</ms-table-column>
<ms-table-column <ms-table-column
prop="name" prop="testPlanName"
permission="PROJECT_TRACK_REPORT:READ+DELETE" :field="item"
:field="item" :fields-width="fieldsWidth"
:fields-width="fieldsWidth" :label="$t('test_track.report.list.test_plan')"
sortable min-width="100"
:label="$t('test_track.report.list.name')" />
:show-overflow-tooltip="false"
:editable="true"
:edit-content="$t('report.rename_report')"
@editColumn="openReNameDialog"
min-width="200px">
</ms-table-column>
<ms-table-column <ms-table-column
prop="testPlanName" prop="creator"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('test_track.report.list.test_plan')" :label="$t('test_track.report.list.creator')"
min-width="100"/> />
<ms-table-column <ms-table-column
prop="creator" prop="createTime"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
:label="$t('test_track.report.list.creator')"/> sortable
:label="$t('test_track.report.list.create_time')"
:show-overflow-tooltip="true"
>
<template v-slot:default="scope">
<span>{{ scope.row.createTime | datetimeFormat }}</span>
</template>
</ms-table-column>
<ms-table-column <ms-table-column
prop="createTime" prop="triggerMode"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
sortable sortable
:label="$t('test_track.report.list.create_time')" :label="$t('test_track.report.list.trigger_mode')"
:show-overflow-tooltip="true"> >
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.createTime | datetimeFormat }}</span> <report-trigger-mode-item :trigger-mode="scope.row.triggerMode" />
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
prop="triggerMode" prop="status"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
sortable sortable
:label="$t('test_track.report.list.trigger_mode')"> :label="$t('commons.status')"
<template v-slot:default="scope"> >
<report-trigger-mode-item :trigger-mode="scope.row.triggerMode"/> <template v-slot:default="scope">
</template> <ms-tag
</ms-table-column> v-if="scope.row.status == 'RUNNING'"
type="primary"
effect="plain"
:content="'Running'"
/>
<ms-tag
v-else-if="
scope.row.status == 'COMPLETED' ||
scope.row.status == 'SUCCESS' ||
scope.row.status == 'FAILED'
"
type="info"
effect="plain"
:content="'Completed'"
/>
<ms-tag
v-else
type="info"
effect="plain"
:content="scope.row.status"
/>
</template>
</ms-table-column>
<ms-table-column <ms-table-column
prop="status" prop="runTime"
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
sortable sortable="custom"
:label="$t('commons.status')"> :label="$t('test_track.report.list.run_time')"
<template v-slot:default="scope"> >
<ms-tag v-if="scope.row.status == 'RUNNING'" type="primary" effect="plain" :content="'Running'"/> <template v-slot:default="scope">
<ms-tag <span v-if="scope.row.endTime != null">{{
v-else-if="scope.row.status == 'COMPLETED'||scope.row.status == 'SUCCESS'||scope.row.status == 'FAILED'" (scope.row.runTime / 1000).toFixed(2)
type="info" effect="plain" :content="'Completed'"/> }}</span>
<ms-tag v-else type="info" effect="plain" :content="scope.row.status"/> <span v-else>/</span>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column
prop="runTime"
:field="item"
:fields-width="fieldsWidth"
sortable="custom"
:label="$t('test_track.report.list.run_time')">
<template v-slot:default="scope">
<span v-if="scope.row.endTime != null">{{ (scope.row.runTime / 1000).toFixed(2) }}</span>
<span v-else>/</span>
</template>
</ms-table-column>
<ms-table-column
prop="passRate"
:field="item"
:fields-width="fieldsWidth"
:label="$t('test_track.report.list.pass_rate')">
<template v-slot:default="scope">
<span>{{ (scope.row.passRate ? (scope.row.passRate * 100).toFixed(1) : 0) + '%' }}</span>
</template>
</ms-table-column>
<ms-table-column
prop="passRate"
:field="item"
:fields-width="fieldsWidth"
:label="$t('test_track.report.list.pass_rate')"
>
<template v-slot:default="scope">
<span>{{
(scope.row.passRate ? (scope.row.passRate * 100).toFixed(1) : 0) +
"%"
}}</span>
</template>
</ms-table-column>
</span> </span>
</ms-table> </ms-table>
<ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize" <ms-table-pagination
:total="total"/> :change="initTableData"
<test-plan-db-report ref="dbReport"/> :current-page.sync="currentPage"
<ms-rename-report-dialog ref="renameDialog" @submit="rename"></ms-rename-report-dialog> :page-size.sync="pageSize"
:total="total"
/>
<test-plan-db-report ref="dbReport" />
<ms-rename-report-dialog
ref="renameDialog"
@submit="rename"
></ms-rename-report-dialog>
</el-card> </el-card>
</template> </template>
<script> <script>
import MsTablePagination from 'metersphere-frontend/src/components/pagination/TablePagination'; import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination";
import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader"; import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader";
import MsTableOperatorButton from "metersphere-frontend/src/components/MsTableOperatorButton"; import MsTableOperatorButton from "metersphere-frontend/src/components/MsTableOperatorButton";
import MsTableOperator from "metersphere-frontend/src/components/MsTableOperator"; import MsTableOperator from "metersphere-frontend/src/components/MsTableOperator";
import {TEST_PLAN_REPORT_CONFIGS} from "metersphere-frontend/src/components/search/search-components"; import { TEST_PLAN_REPORT_CONFIGS } from "metersphere-frontend/src/components/search/search-components";
import ReportTriggerModeItem from "metersphere-frontend/src/components/tableItem/ReportTriggerModeItem"; import ReportTriggerModeItem from "metersphere-frontend/src/components/tableItem/ReportTriggerModeItem";
import MsTag from "metersphere-frontend/src/components/MsTag"; import MsTag from "metersphere-frontend/src/components/MsTag";
import ShowMoreBtn from "metersphere-frontend/src/components/table/ShowMoreBtn"; import ShowMoreBtn from "metersphere-frontend/src/components/table/ShowMoreBtn";
@ -144,19 +182,20 @@ import {
setUnSelectIds, setUnSelectIds,
toggleAllSelection, toggleAllSelection,
getCustomTableWidth, getCustomTableWidth,
getCustomTableHeader getCustomTableHeader,
} from "metersphere-frontend/src/utils/tableUtils"; } from "metersphere-frontend/src/utils/tableUtils";
import MsTableHeaderSelectPopover from "metersphere-frontend/src/components/table/MsTableHeaderSelectPopover"; import MsTableHeaderSelectPopover from "metersphere-frontend/src/components/table/MsTableHeaderSelectPopover";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token"; import { getCurrentProjectID } from "metersphere-frontend/src/utils/token";
import TestPlanDbReport from "@/business/report/components/TestPlanDbReport"; import TestPlanDbReport from "@/business/report/components/TestPlanDbReport";
import MsTable from "metersphere-frontend/src/components/table/MsTable"; import MsTable from "metersphere-frontend/src/components/table/MsTable";
import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn"; import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn";
import MsRenameReportDialog from "metersphere-frontend/src/components/report/MsRenameReportDialog"; import MsRenameReportDialog from "metersphere-frontend/src/components/report/MsRenameReportDialog";
import { import {
testPlanReportBatchDelete, testPlanReportBatchDelete,
testPlanReportDelete, testPlanReportGetDb, testPlanReportDelete,
testPlanReportGetDb,
testPlanReportList, testPlanReportList,
testPlanReportReName testPlanReportReName,
} from "@/api/remote/plan/test-plan-report"; } from "@/api/remote/plan/test-plan-report";
export default { export default {
@ -164,12 +203,17 @@ export default {
components: { components: {
TestPlanDbReport, TestPlanDbReport,
MsTableHeaderSelectPopover, MsTableHeaderSelectPopover,
MsTableOperator, MsTableOperatorButton, MsTableHeader, MsTablePagination, MsTableOperator,
ReportTriggerModeItem, MsTag, MsTableOperatorButton,
ShowMoreBtn, MsTableSelectAll, MsTableHeader,
MsTablePagination,
ReportTriggerModeItem,
MsTag,
ShowMoreBtn,
MsTableSelectAll,
MsTableColumn, MsTableColumn,
MsTable, MsTable,
MsRenameReportDialog MsRenameReportDialog,
}, },
data() { data() {
return { return {
@ -183,55 +227,69 @@ export default {
pageSize: 10, pageSize: 10,
isTestManagerOrTestUser: false, isTestManagerOrTestUser: false,
selectRows: new Set(), selectRows: new Set(),
screenHeight: 'calc(100vh - 200px)', // screenHeight: "calc(100vh - 200px)", //
total: 0, total: 0,
tableData: [], tableData: [],
statusFilters: [ statusFilters: [
{text: this.$t('test_track.plan.plan_status_prepare'), value: 'Prepare'}, {
{text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'}, text: this.$t("test_track.plan.plan_status_prepare"),
{text: this.$t('test_track.plan.plan_status_completed'), value: 'Completed'} value: "Prepare",
},
{
text: this.$t("test_track.plan.plan_status_running"),
value: "Underway",
},
{
text: this.$t("test_track.plan.plan_status_completed"),
value: "Completed",
},
], ],
stageFilters: [ stageFilters: [
{text: this.$t('test_track.plan.smoke_test'), value: 'smoke'}, { text: this.$t("test_track.plan.smoke_test"), value: "smoke" },
{text: this.$t('test_track.plan.system_test'), value: 'system'}, { text: this.$t("test_track.plan.system_test"), value: "system" },
{text: this.$t('test_track.plan.regression_test'), value: 'regression'}, {
text: this.$t("test_track.plan.regression_test"),
value: "regression",
},
], ],
buttons: [ buttons: [
{ {
name: this.$t('api_test.definition.request.batch_delete'), name: this.$t("api_test.definition.request.batch_delete"),
handleClick: this.handleDeleteBatch, handleClick: this.handleDeleteBatch,
permissions: ['PROJECT_TRACK_REPORT:READ+DELETE'] permissions: ["PROJECT_TRACK_REPORT:READ+DELETE"],
}, },
], ],
selectDataCounts: 0, selectDataCounts: 0,
fields: getCustomTableHeader('TRACK_REPORT_TABLE'), fields: getCustomTableHeader("TRACK_REPORT_TABLE"),
fieldsWidth: getCustomTableWidth('TRACK_REPORT_TABLE'), fieldsWidth: getCustomTableWidth("TRACK_REPORT_TABLE"),
operators: [], operators: [],
batchButtons: [], batchButtons: [],
publicButtons: [ publicButtons: [
{ {
name: this.$t('api_test.definition.request.batch_delete'), name: this.$t("api_test.definition.request.batch_delete"),
handleClick: this.handleDeleteBatch, handleClick: this.handleDeleteBatch,
permissions: ['PROJECT_TRACK_REPORT:READ+DELETE'], permissions: ["PROJECT_TRACK_REPORT:READ+DELETE"],
}, },
], ],
simpleOperators: [ simpleOperators: [
{ {
tip: this.$t('test_track.plan_view.view_report'), icon: "el-icon-document", tip: this.$t("test_track.plan_view.view_report"),
icon: "el-icon-document",
exec: this.openReport, exec: this.openReport,
}, },
{ {
tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger", tip: this.$t("commons.delete"),
icon: "el-icon-delete",
type: "danger",
exec: this.handleDelete, exec: this.handleDelete,
permissions: ['PROJECT_TRACK_REPORT:READ+DELETE'] permissions: ["PROJECT_TRACK_REPORT:READ+DELETE"],
}, },
], ],
}; };
}, },
watch: { watch: {
'$route'(to, from) { $route(to, from) {},
}
}, },
activated() { activated() {
this.init(); this.init();
@ -250,10 +308,9 @@ export default {
// //
if (this.$route.query.resourceId) { if (this.$route.query.resourceId) {
testPlanReportGetDb(this.$route.query.resourceId) testPlanReportGetDb(this.$route.query.resourceId).then((response) => {
.then(response => { this.$refs.dbReport.open(response.data);
this.$refs.dbReport.open(response.data); });
});
} }
}, },
initTableData() { initTableData() {
@ -272,44 +329,57 @@ export default {
} }
this.condition.projectId = getCurrentProjectID(); this.condition.projectId = getCurrentProjectID();
this.loading = true; this.loading = true;
testPlanReportList({pageNum: this.currentPage, pageSize: this.pageSize}, this.condition) testPlanReportList(
.then(response => { { pageNum: this.currentPage, pageSize: this.pageSize },
this.loading = false; this.condition
let data = response.data; ).then((response) => {
this.total = data.itemCount; this.loading = false;
this.tableData = data.listObject; let data = response.data;
}); this.total = data.itemCount;
this.tableData = data.listObject;
});
}, },
handleSelect(selection, row) { handleSelect(selection, row) {
_handleSelect(this, selection, row, this.selectRows); _handleSelect(this, selection, row, this.selectRows);
setUnSelectIds(this.tableData, this.condition, this.selectRows); setUnSelectIds(this.tableData, this.condition, this.selectRows);
this.selectDataCounts = getSelectDataCounts(this.condition, this.total, this.selectRows); this.selectDataCounts = getSelectDataCounts(
this.condition,
this.total,
this.selectRows
);
}, },
handleSelectAll(selection) { handleSelectAll(selection) {
_handleSelectAll(this, selection, this.tableData, this.selectRows); _handleSelectAll(this, selection, this.tableData, this.selectRows);
setUnSelectIds(this.tableData, this.condition, this.selectRows); setUnSelectIds(this.tableData, this.condition, this.selectRows);
this.selectDataCounts = getSelectDataCounts(this.condition, this.total, this.selectRows); this.selectDataCounts = getSelectDataCounts(
this.condition,
this.total,
this.selectRows
);
}, },
handleDelete(testPlanReport) { handleDelete(testPlanReport) {
this.$alert(this.$t('report.delete_confirm') + ' ' + testPlanReport.name + " ", '', { this.$alert(
confirmButtonText: this.$t('commons.confirm'), this.$t("report.delete_confirm") + " " + testPlanReport.name + " ",
callback: (action) => { "",
if (action === 'confirm') { {
let testPlanReportIdList = [testPlanReport.id]; confirmButtonText: this.$t("commons.confirm"),
testPlanReportDelete(testPlanReportIdList) callback: (action) => {
.then(() => { if (action === "confirm") {
this.$success(this.$t('commons.delete_success')); let testPlanReportIdList = [testPlanReport.id];
testPlanReportDelete(testPlanReportIdList).then(() => {
this.$success(this.$t("commons.delete_success"));
this.initTableData(); this.initTableData();
}); });
} }
},
} }
}); );
}, },
handleDeleteBatch() { handleDeleteBatch() {
this.$alert(this.$t('report.delete_batch_confirm') + ' ' + " ", '', { this.$alert(this.$t("report.delete_batch_confirm") + " " + " ", "", {
confirmButtonText: this.$t('commons.confirm'), confirmButtonText: this.$t("commons.confirm"),
callback: (action) => { callback: (action) => {
if (action === 'confirm') { if (action === "confirm") {
let deleteParam = {}; let deleteParam = {};
let ids = this.$refs.testPlanReportTable.selectIds; let ids = this.$refs.testPlanReportTable.selectIds;
deleteParam.dataIds = ids; deleteParam.dataIds = ids;
@ -317,19 +387,18 @@ export default {
deleteParam.selectAllDate = this.condition.selectAll; deleteParam.selectAllDate = this.condition.selectAll;
deleteParam.unSelectIds = this.condition.unSelection; deleteParam.unSelectIds = this.condition.unSelection;
deleteParam = Object.assign(deleteParam, this.condition); deleteParam = Object.assign(deleteParam, this.condition);
testPlanReportBatchDelete(deleteParam) testPlanReportBatchDelete(deleteParam).then(() => {
.then(() => { this.$success(this.$t("commons.delete_success"));
this.$success(this.$t('commons.delete_success')); this.initTableData();
this.initTableData(); this.selectRows.clear();
this.selectRows.clear(); });
});
} }
} },
}); });
}, },
getIds(rowSets) { getIds(rowSets) {
let rowArray = Array.from(rowSets); let rowArray = Array.from(rowSets);
let ids = rowArray.map(s => s.id); let ids = rowArray.map((s) => s.id);
return ids; return ids;
}, },
filter(filters) { filter(filters) {
@ -357,13 +426,21 @@ export default {
isSelectDataAll(data) { isSelectDataAll(data) {
this.condition.selectAll = data; this.condition.selectAll = data;
// //
toggleAllSelection(this.$refs.testPlanReportTable, this.tableData, this.selectRows); toggleAllSelection(
this.$refs.testPlanReportTable,
this.tableData,
this.selectRows
);
// //
_handleSelectAll(this, this.tableData, this.tableData, this.selectRows); _handleSelectAll(this, this.tableData, this.tableData, this.selectRows);
//ID() //ID()
this.condition.unSelectIds = []; this.condition.unSelectIds = [];
// //
this.selectDataCounts = getSelectDataCounts(this.condition, this.total, this.selectRows); this.selectDataCounts = getSelectDataCounts(
this.condition,
this.total,
this.selectRows
);
}, },
saveSortField(key, orders) { saveSortField(key, orders) {
saveLastTableSortField(key, JSON.stringify(orders)); saveLastTableSortField(key, JSON.stringify(orders));
@ -372,19 +449,17 @@ export default {
this.$refs.renameDialog.open($event); this.$refs.renameDialog.open($event);
}, },
rename(data) { rename(data) {
testPlanReportReName(data) testPlanReportReName(data).then(() => {
.then(() => { this.$success(this.$t("organization.integration.successful_operation"));
this.$success(this.$t("organization.integration.successful_operation")); this.initTableData();
this.initTableData(); this.$refs.renameDialog.close();
this.$refs.renameDialog.close(); });
}); },
} },
}
}; };
</script> </script>
<style scoped> <style scoped>
.table-page { .table-page {
padding-top: 20px; padding-top: 20px;
margin-right: -9px; margin-right: -9px;
@ -402,6 +477,6 @@ export default {
.request-method { .request-method {
padding: 0 5px; padding: 0 5px;
color: #1E90FF; color: #1e90ff;
} }
</style> </style>