fix(接口测试): 列表切换模块时清空选择框的数据

--bug=1014658 --user=王孝刚 【接口测试】接口、场景列表,切换模块或者进行其他操作后,勾选数据没清空
https://www.tapd.cn/55049933/s/1196198
This commit is contained in:
wxg0103 2022-07-06 17:51:41 +08:00 committed by fit2-zhao
parent 8f3b88621a
commit 0b0780e256
7 changed files with 84 additions and 65 deletions

View File

@ -521,7 +521,7 @@ export default {
if (tab.name === targetName) { if (tab.name === targetName) {
this.diff(tab); this.diff(tab);
if (tab && this.isSave) { if (tab && this.isSave) {
message += tab.currentScenario.name ? tab.currentScenario.name : this.$t('api_test.automation.add_scenario') + ""; message += tab.currentScenario.name ? tab.currentScenario.name : this.$t('api_test.automation.add_scenario');
} }
} }
}) })
@ -707,7 +707,13 @@ export default {
gotoTurn(resource, workspaceId, isTurnSpace) { gotoTurn(resource, workspaceId, isTurnSpace) {
let automationData = this.$router.resolve({ let automationData = this.$router.resolve({
name: 'ApiAutomation', name: 'ApiAutomation',
params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id, projectId: resource.projectId, workspaceId: workspaceId} params: {
redirectID: getUUID(),
dataType: "scenario",
dataSelectRange: 'edit:' + resource.id,
projectId: resource.projectId,
workspaceId: workspaceId
}
}); });
if (isTurnSpace) { if (isTurnSpace) {
window.open(automationData.href, '_blank'); window.open(automationData.href, '_blank');

View File

@ -308,7 +308,15 @@
</template> </template>
<script> <script>
import {downloadFile, getCurrentProjectID, getUUID, hasLicense, hasPermission, objToStrMap, strMapToObj} from "@/common/js/utils"; import {
downloadFile,
getCurrentProjectID,
getUUID,
hasLicense,
hasPermission,
objToStrMap,
strMapToObj
} from "@/common/js/utils";
import {API_SCENARIO_CONFIGS} from "@/business/components/common/components/search/search-components"; import {API_SCENARIO_CONFIGS} from "@/business/components/common/components/search/search-components";
import {API_SCENARIO_LIST} from "../../../../../common/js/constants"; import {API_SCENARIO_LIST} from "../../../../../common/js/constants";
@ -753,6 +761,7 @@ export default {
} }
}); });
this.$emit('getTrashCase'); this.$emit('getTrashCase');
this.$refs.scenarioTable.clearSelection();
}); });
} }
}, },

View File

@ -618,15 +618,15 @@ export default {
id = t.api.id; id = t.api.id;
if (this.$store.state.apiMap.get(t.api.id).get("responseChange") === true || this.$store.state.apiMap.get(t.api.id).get("requestChange") === true || if (this.$store.state.apiMap.get(t.api.id).get("responseChange") === true || this.$store.state.apiMap.get(t.api.id).get("requestChange") === true ||
this.$store.state.apiMap.get(t.api.id).get("fromChange") === true) { this.$store.state.apiMap.get(t.api.id).get("fromChange") === true) {
message += t.api.name + ""; message += t.api.name;
id = t.api.id; id = t.api.id;
} }
} else if (t.type === 'ADD' && t.title === this.$t('api_test.definition.request.title')) { } else if (t.type === 'ADD' && t.title === this.$t('api_test.definition.request.title')) {
message += this.$t('api_test.definition.request.title') + ""; message += this.$t('api_test.definition.request.title');
id = t.api.id; id = t.api.id;
} }
if (t.type === 'ADD' && t.isCopy) { if (t.type === 'ADD' && t.isCopy) {
message += t.api.name + ""; message += t.api.name;
id = t.api.id; id = t.api.id;
} }
} }

View File

@ -504,7 +504,7 @@ export default {
// //
if (this.$route.query.caseId) { if (this.$route.query.caseId) {
this.$get('/api/testcase/findById/' + this.$route.query.caseId, (response) => { this.$get('/api/testcase/findById/' + this.$route.query.caseId, (response) => {
if(!response.data){ if (!response.data) {
this.$error(this.$t('api_test.case_jump_message')); this.$error(this.$t('api_test.case_jump_message'));
return; return;
} }
@ -717,6 +717,7 @@ export default {
} }
}); });
} }
this.$refs.caseTable.clearSelection();
}, },
setRunning(id) { setRunning(id) {
this.tableData.forEach(item => { this.tableData.forEach(item => {

View File

@ -640,6 +640,7 @@ export default {
item.caseTotal = parseInt(item.caseTotal); item.caseTotal = parseInt(item.caseTotal);
}); });
this.$emit('getTrashApi'); this.$emit('getTrashApi');
this.$refs.table.clearSelection();
}); });
} }
if (this.needRefreshModule()) { if (this.needRefreshModule()) {

View File

@ -23,9 +23,9 @@
ref="table"> ref="table">
<el-table-column <el-table-column
v-if="enableSelection" v-if="enableSelection"
width="50" width="50"
type="selection"/> type="selection"/>
<ms-table-header-select-popover v-if="enableSelection && showSelectAll" <ms-table-header-select-popover v-if="enableSelection && showSelectAll"
:page-size="pageSize > total ? total : pageSize" :page-size="pageSize > total ? total : pageSize"
@ -60,13 +60,13 @@
<!-- 拖拽排序 --> <!-- 拖拽排序 -->
<el-table-column <el-table-column
v-if="enableOrderDrag" v-if="enableOrderDrag"
width="20" width="20"
column-key="tableRowDropCol"> column-key="tableRowDropCol">
<template v-slot:default="scope"> <template v-slot:default="scope">
<div class="table-row-drop-bar"> <div class="table-row-drop-bar">
<i class="el-icon-more ms-icon-more"/> <i class="el-icon-more ms-icon-more"/>
<i class="el-icon-more ms-icon-more"/> <i class="el-icon-more ms-icon-more"/>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
@ -74,30 +74,30 @@
<slot></slot> <slot></slot>
<el-table-column <el-table-column
v-if="operators && operators.length > 0" v-if="operators && operators.length > 0"
:fixed="operatorFixed" :fixed="operatorFixed"
:min-width="operatorWidth" :min-width="operatorWidth"
:label="$t('commons.operating')"> :label="$t('commons.operating')">
<template slot="header"> <template slot="header">
<header-label-operate <header-label-operate
v-if="fieldKey" v-if="fieldKey"
:disable-header-config="disableHeaderConfig" :disable-header-config="disableHeaderConfig"
@exec="openCustomHeader"/> @exec="openCustomHeader"/>
</template> </template>
<template <template
v-slot:default="scope"> v-slot:default="scope">
<div> <div>
<slot <slot
name="opt-before" name="opt-before"
:row="scope.row"> :row="scope.row">
</slot> </slot>
<ms-table-operators <ms-table-operators
:buttons="operators" :buttons="operators"
:row="scope.row" :row="scope.row"
:index="scope.$index"/> :index="scope.$index"/>
<slot <slot
name="opt-behind" name="opt-behind"
:row="scope.row"> :row="scope.row">
</slot> </slot>
</div> </div>
</template> </template>
@ -105,11 +105,11 @@
</el-table> </el-table>
<ms-custom-table-header <ms-custom-table-header
v-if="fieldKey" v-if="fieldKey"
:type="fieldKey" :type="fieldKey"
:custom-fields="customFields" :custom-fields="customFields"
@reload="resetHeader" @reload="resetHeader"
ref="customTableHeader"/> ref="customTableHeader"/>
</div> </div>
</template> </template>
@ -120,15 +120,15 @@ import {
_handleSelect, _handleSelect,
_handleSelectAll, _handleSelectAll,
_sort, _sort,
getSelectDataCounts,
setUnSelectIds,
toggleAllSelection,
checkTableRowIsSelect, checkTableRowIsSelect,
clearShareDragParam,
getCustomTableHeader, getCustomTableHeader,
getSelectDataCounts,
handleRowDrop,
saveCustomTableWidth, saveCustomTableWidth,
saveLastTableSortField, saveLastTableSortField,
handleRowDrop, setUnSelectIds,
clearShareDragParam, toggleAllSelection,
} from "@/common/js/tableUtils"; } from "@/common/js/tableUtils";
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover"; import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
@ -252,8 +252,8 @@ export default {
return false; return false;
} }
}, },
tableIsLoading:{ tableIsLoading: {
type:Boolean, type: Boolean,
default() { default() {
return false; return false;
} }
@ -340,7 +340,7 @@ export default {
}); });
} }
}, },
isScrollShow(column, tableTop){ // isScrollShow(column, tableTop) { //
let columnTop = column.getBoundingClientRect().top; let columnTop = column.getBoundingClientRect().top;
return columnTop - tableTop > 30; return columnTop - tableTop > 30;
}, },
@ -366,7 +366,7 @@ export default {
this.selectDataCounts = getSelectDataCounts(this.condition, this.total, this.selectRows); this.selectDataCounts = getSelectDataCounts(this.condition, this.total, this.selectRows);
this.selectIds = Array.from(this.selectRows).map(o => o.id); this.selectIds = Array.from(this.selectRows).map(o => o.id);
// //
this.$emit('callBackSelectAll',selection); this.$emit('callBackSelectAll', selection);
this.$nextTick(function () { this.$nextTick(function () {
setTimeout(this.removeBatchPopper, 1); setTimeout(this.removeBatchPopper, 1);
}); });
@ -377,7 +377,7 @@ export default {
this.selectDataCounts = getSelectDataCounts(this.condition, this.total, this.selectRows); this.selectDataCounts = getSelectDataCounts(this.condition, this.total, this.selectRows);
this.selectIds = Array.from(this.selectRows).map(o => o.id); this.selectIds = Array.from(this.selectRows).map(o => o.id);
// //
this.$emit('callBackSelect',selection); this.$emit('callBackSelect', selection);
this.$nextTick(function () { this.$nextTick(function () {
setTimeout(this.removeBatchPopper, 1); setTimeout(this.removeBatchPopper, 1);
}); });
@ -395,10 +395,10 @@ export default {
this.selectIds = Array.from(this.selectRows).map(o => o.id); this.selectIds = Array.from(this.selectRows).map(o => o.id);
}, },
headerDragend(newWidth, oldWidth, column, event) { headerDragend(newWidth, oldWidth, column, event) {
if(column){ if (column) {
if(column.minWidth){ if (column.minWidth) {
let minWidth = column.minWidth; let minWidth = column.minWidth;
if(minWidth > newWidth){ if (minWidth > newWidth) {
column.width = minWidth; column.width = minWidth;
newWidth = minWidth; newWidth = minWidth;
} }
@ -462,6 +462,8 @@ export default {
}, },
clearSelection() { clearSelection() {
this.clearSelectRows(); this.clearSelectRows();
this.condition.selectAll = false;
this.condition.unSelectIds = [];
}, },
getSelectRows() { getSelectRows() {
return this.selectRows; return this.selectRows;
@ -469,7 +471,7 @@ export default {
clearSelectRows() { clearSelectRows() {
this.selectRows.clear(); this.selectRows.clear();
this.selectIds = []; this.selectIds = [];
if(!this.condition.selectAll){ if (!this.condition.selectAll) {
this.condition.selectAll = false; this.condition.selectAll = false;
this.condition.unSelectIds = []; this.condition.unSelectIds = [];
} }
@ -500,8 +502,8 @@ export default {
}, },
addPaddingColClass({column}) { addPaddingColClass({column}) {
if (column.columnKey === 'tableRowDropCol' if (column.columnKey === 'tableRowDropCol'
|| column.columnKey === 'selectionCol' || column.columnKey === 'selectionCol'
|| column.columnKey ==='batchBtnCol') { || column.columnKey === 'batchBtnCol') {
return 'padding-col'; return 'padding-col';
} }
}, },
@ -550,24 +552,24 @@ export default {
margin-right: -5px; margin-right: -5px;
} }
.ms-table >>> .el-table__body tr.hover-row.current-row>td, .ms-table >>> .el-table__body tr.hover-row.current-row > td,
.ms-table >>> .el-table__body tr.hover-row.el-table__row--striped.current-row>td, .ms-table >>> .el-table__body tr.hover-row.el-table__row--striped.current-row > td,
.ms-table >>> .el-table__body tr.hover-row.el-table__row--striped>td, .ms-table >>> .el-table__body tr.hover-row.el-table__row--striped > td,
.ms-table >>> .el-table__body tr.hover-row>td { .ms-table >>> .el-table__body tr.hover-row > td {
background-color: #ffffff; background-color: #ffffff;
} }
/* 解决拖拽排序后hover阴影错乱问题 */ /* 解决拖拽排序后hover阴影错乱问题 */
.ms-table >>> .el-table__body tr:hover>td .ms-table >>> .el-table__body tr:hover > td {
{
background-color: #F5F7FA; background-color: #F5F7FA;
} }
.disable-hover >>> tr:hover>td{ .disable-hover >>> tr:hover > td {
background-color: #ffffff !important; background-color: #ffffff !important;
} }
.row-click { .row-click {
cursor:pointer; cursor: pointer;
} }
</style> </style>

View File

@ -210,10 +210,10 @@ import MsContainer from "../../common/components/MsContainer";
import MsAsideContainer from "../../common/components/MsAsideContainer"; import MsAsideContainer from "../../common/components/MsAsideContainer";
import MsMainContainer from "../../common/components/MsMainContainer"; import MsMainContainer from "../../common/components/MsMainContainer";
import { import {
hasLicense,
getCurrentProjectID, getCurrentProjectID,
getCurrentWorkspaceId, getCurrentWorkspaceId,
getUUID, getUUID,
hasLicense,
hasPermission, hasPermission,
setCurTabId setCurTabId
} from "@/common/js/utils"; } from "@/common/js/utils";
@ -222,7 +222,7 @@ import TestCaseNodeTree from "../common/TestCaseNodeTree";
import MsTabButton from "@/business/components/common/components/MsTabButton"; import MsTabButton from "@/business/components/common/components/MsTabButton";
import TestCaseMinder from "@/business/components/track/common/minder/TestCaseMinder"; import TestCaseMinder from "@/business/components/track/common/minder/TestCaseMinder";
import IsChangeConfirm from "@/business/components/common/components/IsChangeConfirm"; import IsChangeConfirm from "@/business/components/common/components/IsChangeConfirm";
import {openMinderConfirm, saveMinderConfirm} from "@/business/components/track/common/minder/minderUtils"; import {openMinderConfirm} from "@/business/components/track/common/minder/minderUtils";
import TestCaseEditShow from "@/business/components/track/case/components/TestCaseEditShow"; import TestCaseEditShow from "@/business/components/track/case/components/TestCaseEditShow";
import {PROJECT_ID} from "@/common/js/constants"; import {PROJECT_ID} from "@/common/js/constants";
@ -268,7 +268,7 @@ export default {
isAsideHidden: true, isAsideHidden: true,
showPublicNode: false, showPublicNode: false,
publicTreeNodes: [], publicTreeNodes: [],
ignoreTreeNodes:false, ignoreTreeNodes: false,
}; };
}, },
created() { created() {
@ -532,13 +532,13 @@ export default {
let t = this.tabs.filter(tab => tab.name === targetName); let t = this.tabs.filter(tab => tab.name === targetName);
let message = ""; let message = "";
if (t && this.$store.state.testCaseMap.has(t[0].testCaseInfo.id) && this.$store.state.testCaseMap.get(t[0].testCaseInfo.id) > 0) { if (t && this.$store.state.testCaseMap.has(t[0].testCaseInfo.id) && this.$store.state.testCaseMap.get(t[0].testCaseInfo.id) > 0) {
message += t[0].testCaseInfo.name + ""; message += t[0].testCaseInfo.name;
} }
if (t[0].label === this.$t('test_track.case.create')) { if (t[0].label === this.$t('test_track.case.create')) {
message += this.$t('test_track.case.create') + ""; message += this.$t('test_track.case.create');
} }
if (t[0].testCaseInfo.isCopy) { if (t[0].testCaseInfo.isCopy) {
message += t[0].testCaseInfo.name + ""; message += t[0].testCaseInfo.name;
} }
if (message !== "") { if (message !== "") {
this.$alert(this.$t('commons.track') + " [ " + message + " ] " + this.$t('commons.confirm_info'), '', { this.$alert(this.$t('commons.track') + " [ " + message + " ] " + this.$t('commons.confirm_info'), '', {