refactor: 测试计划管理用例页面优化

This commit is contained in:
chenjianxing 2021-05-25 12:04:51 +08:00 committed by jianxing
parent 95b167e9ce
commit 9d95677c50
14 changed files with 284 additions and 342 deletions

View File

@ -4,6 +4,8 @@ import io.metersphere.base.domain.TestCase;
import io.metersphere.base.domain.TestCaseExample; import io.metersphere.base.domain.TestCaseExample;
import io.metersphere.base.domain.TestCaseWithBLOBs; import io.metersphere.base.domain.TestCaseWithBLOBs;
import java.util.List; import java.util.List;
import io.metersphere.controller.request.BaseQueryRequest;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
public interface TestCaseMapper { public interface TestCaseMapper {
@ -34,4 +36,6 @@ public interface TestCaseMapper {
int updateByPrimaryKeyWithBLOBs(TestCaseWithBLOBs record); int updateByPrimaryKeyWithBLOBs(TestCaseWithBLOBs record);
int updateByPrimaryKey(TestCase record); int updateByPrimaryKey(TestCase record);
}
List<String> selectIdsByQuery(BaseQueryRequest query);
}

View File

@ -94,8 +94,8 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, node_id, node_path, project_id, `name`, `type`, maintainer, priority, `method`, id, node_id, node_path, project_id, `name`, `type`, maintainer, priority, `method`,
create_time, update_time, test_id, sort, num, other_test_name, review_status, tags, create_time, update_time, test_id, sort, num, other_test_name, review_status, tags,
demand_id, demand_name, follow_people, `status`, custom_num, step_model, create_user demand_id, demand_name, follow_people, `status`, custom_num, step_model, create_user
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
@ -132,7 +132,7 @@
</if> </if>
</select> </select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs"> <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
, ,
<include refid="Blob_Column_List" /> <include refid="Blob_Column_List" />
@ -150,27 +150,27 @@
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs"> <insert id="insert" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs">
insert into test_case (id, node_id, node_path, insert into test_case (id, node_id, node_path,
project_id, `name`, `type`, project_id, `name`, `type`,
maintainer, priority, `method`, maintainer, priority, `method`,
create_time, update_time, test_id, create_time, update_time, test_id,
sort, num, other_test_name, sort, num, other_test_name,
review_status, tags, demand_id, review_status, tags, demand_id,
demand_name, follow_people, `status`, demand_name, follow_people, `status`,
custom_num, step_model, create_user, custom_num, step_model, create_user,
prerequisite, remark, steps, prerequisite, remark, steps,
step_description, expected_result, step_description, expected_result,
custom_fields) custom_fields)
values (#{id,jdbcType=VARCHAR}, #{nodeId,jdbcType=VARCHAR}, #{nodePath,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{nodeId,jdbcType=VARCHAR}, #{nodePath,jdbcType=VARCHAR},
#{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
#{maintainer,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{maintainer,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{testId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{testId,jdbcType=VARCHAR},
#{sort,jdbcType=INTEGER}, #{num,jdbcType=INTEGER}, #{otherTestName,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, #{num,jdbcType=INTEGER}, #{otherTestName,jdbcType=VARCHAR},
#{reviewStatus,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR}, #{demandId,jdbcType=VARCHAR}, #{reviewStatus,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR}, #{demandId,jdbcType=VARCHAR},
#{demandName,jdbcType=VARCHAR}, #{followPeople,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{demandName,jdbcType=VARCHAR}, #{followPeople,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{customNum,jdbcType=VARCHAR}, #{stepModel,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{customNum,jdbcType=VARCHAR}, #{stepModel,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR},
#{prerequisite,jdbcType=LONGVARCHAR}, #{remark,jdbcType=LONGVARCHAR}, #{steps,jdbcType=LONGVARCHAR}, #{prerequisite,jdbcType=LONGVARCHAR}, #{remark,jdbcType=LONGVARCHAR}, #{steps,jdbcType=LONGVARCHAR},
#{stepDescription,jdbcType=LONGVARCHAR}, #{expectedResult,jdbcType=LONGVARCHAR}, #{stepDescription,jdbcType=LONGVARCHAR}, #{expectedResult,jdbcType=LONGVARCHAR},
#{customFields,jdbcType=LONGVARCHAR}) #{customFields,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs">
@ -366,7 +366,10 @@
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
</select> </select>
<update id="updateByExampleSelective" parameterType="map"> <select id="selectIdsByQuery" resultType="java.lang.String">
</select>
<update id="updateByExampleSelective" parameterType="map">
update test_case update test_case
<set> <set>
<if test="record.id != null"> <if test="record.id != null">
@ -683,4 +686,4 @@
create_user = #{createUser,jdbcType=VARCHAR} create_user = #{createUser,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -90,4 +90,6 @@ public interface ExtTestCaseMapper {
List<TestCaseDTO> getTestCaseByIds(@Param("ids")List<String> ids); List<TestCaseDTO> getTestCaseByIds(@Param("ids")List<String> ids);
void updateTestCaseCustomNumByProjectId(@Param("projectId") String projectId); void updateTestCaseCustomNumByProjectId(@Param("projectId") String projectId);
List<String> selectRelateIdsByQuery(@Param("request") BaseQueryRequest query);
} }

View File

@ -116,8 +116,9 @@
</sql> </sql>
<select id="getTestCaseByNotInPlan" resultType="io.metersphere.base.domain.TestCase"> <select id="getTestCaseByNotInPlan" resultType="io.metersphere.base.domain.TestCase">
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status from test_case select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status,
as test_case test_case.num, test_case.custom_num, test_case.priority, test_case.tags, test_case.create_time, test_case.update_time
from test_case as test_case
left join test_plan_test_case as T2 on test_case.id=T2.case_id and T2.plan_id =#{request.planId} left join test_plan_test_case as T2 on test_case.id=T2.case_id and T2.plan_id =#{request.planId}
<include refid="notInQueryWhereCondition"></include> <include refid="notInQueryWhereCondition"></include>
and T2.case_id is null and T2.case_id is null
@ -438,4 +439,11 @@
</foreach> </foreach>
</where> </where>
</select> </select>
<select id="selectRelateIdsByQuery" resultType="java.lang.String">
select test_case.id as id
from test_case as test_case
left join test_plan_test_case as T2 on test_case.id=T2.case_id and T2.plan_id =#{request.planId}
<include refid="notInQueryWhereCondition"/>
and T2.case_id is null
</select>
</mapper> </mapper>

View File

@ -14,6 +14,8 @@ public class PlanCaseRelevanceRequest {
*/ */
private String planId; private String planId;
private List<String> ids;
/** /**
* 当选择关联全部用例时把加载条件送到后台从后台查询 * 当选择关联全部用例时把加载条件送到后台从后台查询
*/ */

View File

@ -1,13 +1,10 @@
package io.metersphere.track.request.testcase; package io.metersphere.track.request.testcase;
import io.metersphere.base.domain.TestCase;
import io.metersphere.controller.request.BaseQueryRequest; import io.metersphere.controller.request.BaseQueryRequest;
import io.metersphere.controller.request.OrderRequest;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List; import java.util.List;
import java.util.Map;
@Getter @Getter
@Setter @Setter

View File

@ -444,46 +444,33 @@ public class TestPlanService {
public void testPlanRelevance(PlanCaseRelevanceRequest request) { public void testPlanRelevance(PlanCaseRelevanceRequest request) {
List<String> testCaseIds = request.getTestCaseIds(); ServiceUtils.getSelectAllIds(request, request.getRequest(),
(query) -> extTestCaseMapper.selectRelateIdsByQuery(query));
List<String> testCaseIds = request.getIds();
if (testCaseIds.isEmpty()) { if (testCaseIds.isEmpty()) {
return; return;
} }
// 如果是关联全部指令则根据条件查询未关联的案例
if (testCaseIds.get(0).equals("all")) {
List<TestCase> testCases = extTestCaseMapper.getTestCaseByNotInPlan(request.getRequest());
if (!testCases.isEmpty()) {
testCaseIds = testCases.stream().map(testCase -> testCase.getId()).collect(Collectors.toList());
}
}
TestCaseExample testCaseExample = new TestCaseExample(); TestCaseExample testCaseExample = new TestCaseExample();
testCaseExample.createCriteria().andIdIn(testCaseIds); testCaseExample.createCriteria().andIdIn(testCaseIds);
Map<String, TestCaseWithBLOBs> testCaseMap =
testCaseMapper.selectByExampleWithBLOBs(testCaseExample)
.stream()
.collect(Collectors.toMap(TestCase::getId, testcase -> testcase));
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
TestPlanTestCaseMapper batchMapper = sqlSession.getMapper(TestPlanTestCaseMapper.class); TestPlanTestCaseMapper batchMapper = sqlSession.getMapper(TestPlanTestCaseMapper.class);
if (!testCaseIds.isEmpty()) { testCaseIds.forEach(caseId -> {
testCaseIds.forEach(caseId -> { TestPlanTestCaseWithBLOBs testPlanTestCase = new TestPlanTestCaseWithBLOBs();
TestCaseWithBLOBs testCase = testCaseMap.get(caseId); testPlanTestCase.setId(UUID.randomUUID().toString());
TestPlanTestCaseWithBLOBs testPlanTestCase = new TestPlanTestCaseWithBLOBs(); testPlanTestCase.setCreateUser(SessionUtils.getUserId());
testPlanTestCase.setId(UUID.randomUUID().toString()); testPlanTestCase.setExecutor(SessionUtils.getUser().getId());
testPlanTestCase.setCreateUser(SessionUtils.getUserId()); testPlanTestCase.setCaseId(caseId);
testPlanTestCase.setExecutor(SessionUtils.getUser().getId()); testPlanTestCase.setCreateTime(System.currentTimeMillis());
testPlanTestCase.setCaseId(caseId); testPlanTestCase.setUpdateTime(System.currentTimeMillis());
testPlanTestCase.setCreateTime(System.currentTimeMillis()); testPlanTestCase.setPlanId(request.getPlanId());
testPlanTestCase.setUpdateTime(System.currentTimeMillis()); testPlanTestCase.setStatus(TestPlanStatus.Prepare.name());
testPlanTestCase.setPlanId(request.getPlanId()); batchMapper.insert(testPlanTestCase);
testPlanTestCase.setStatus(TestPlanStatus.Prepare.name()); });
testPlanTestCase.setResults(testCase.getSteps());
batchMapper.insert(testPlanTestCase);
});
}
sqlSession.flushStatements(); sqlSession.flushStatements();
//同步添加关联的接口和测试用例 //同步添加关联的接口和测试用例
@ -548,11 +535,8 @@ public class TestPlanService {
if (testPlanApiScenarioMapper.countByExample(example) <= 0) { if (testPlanApiScenarioMapper.countByExample(example) <= 0) {
testPlanApiScenarioMapper.insert(t); testPlanApiScenarioMapper.insert(t);
} }
} }
}); });
}); });
} }
} }

View File

@ -77,6 +77,7 @@ export default {
return { return {
selectDataCounts: 0, selectDataCounts: 0,
selectRows: new Set(), selectRows: new Set(),
selectIds: []
}; };
}, },
props: { props: {
@ -159,11 +160,6 @@ export default {
this.selectDataCounts = 0; this.selectDataCounts = 0;
}, },
}, },
computed: {
selectIds() {
return Array.from(this.selectRows).map(o => o.id);
}
},
methods: { methods: {
openCustomHeader() { openCustomHeader() {
this.$emit("openCustomHeader"); this.$emit("openCustomHeader");
@ -177,6 +173,7 @@ export default {
_handleSelect(this, selection, row, this.selectRows); _handleSelect(this, selection, row, this.selectRows);
setUnSelectIds(this.data, this.condition, this.selectRows); setUnSelectIds(this.data, this.condition, this.selectRows);
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);
}, },
isSelectDataAll(data) { isSelectDataAll(data) {
this.condition.selectAll = data; this.condition.selectAll = data;
@ -235,23 +232,24 @@ export default {
this.$emit('pageChange'); this.$emit('pageChange');
}, },
clear() { clear() {
this.selectRows.clear(); this.clearSelectRows();
this.selectDataCounts = 0;
}, },
checkTableRowIsSelect() { checkTableRowIsSelect() {
checkTableRowIsSelect(this, this.condition, this.data, this.$refs.table, this.selectRows); checkTableRowIsSelect(this, this.condition, this.data, this.$refs.table, this.selectRows);
}, },
clearSelection() { clearSelection() {
this.selectRows = new Set(); this.clearSelectRows();
if (this.$refs.table) {
this.$refs.table.clearSelection();
}
}, },
getSelectRows() { getSelectRows() {
return this.selectRows; return this.selectRows;
}, },
clearSelectRows() { clearSelectRows() {
this.selectRows = new Set(); this.selectRows.clear();
this.selectIds = [];
this.selectDataCounts = 0;
if (this.$refs.table) {
this.$refs.table.clearSelection();
}
}, },
} }
}; };

View File

@ -337,7 +337,11 @@ export default {
this.result = this.$get('/test/plan/case/get/' + testCase.id, response => { this.result = this.$get('/test/plan/case/get/' + testCase.id, response => {
let item = {}; let item = {};
Object.assign(item, response.data); Object.assign(item, response.data);
item.results = JSON.parse(item.results); if (item.results) {
item.results = JSON.parse(item.results);
} else {
item.results = [item.steps.length];
}
if (item.issues) { if (item.issues) {
item.issues = JSON.parse(item.issues); item.issues = JSON.parse(item.issues);
} else { } else {

View File

@ -83,23 +83,8 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
v-if="item.id=='type'"
prop="type"
:filters="typeFilters"
column-key="type"
:label="$t('test_track.case.type')"
min-width="80px"
:key="index"
show-overflow-tooltip>
<template v-slot:default="scope">
<type-table-item :value="scope.row.type"/>
</template>
</el-table-column>
<el-table-column v-if="item.id=='tags'" prop="tags" :label="$t('commons.tag')" min-width="120px" <el-table-column v-if="item.id=='tags'" prop="tags" :label="$t('commons.tag')" min-width="120px"
:key="index" :key="index">
>
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(tag, index) in scope.row.showTags" :key="tag + '_' + index" type="success" effect="plain" <ms-tag v-for="(tag, index) in scope.row.showTags" :key="tag + '_' + index" type="success" effect="plain"
:content="tag" style="margin-left: 0px; margin-right: 2px"/> :content="tag" style="margin-left: 0px; margin-right: 2px"/>

View File

@ -15,55 +15,73 @@
ref="nodeTree"/> ref="nodeTree"/>
</template> </template>
<ms-table-header :condition.sync="condition" @search="search" title="" :show-create="false"/> <ms-table-header :condition.sync="page.condition" @search="search" title="" :show-create="false"/>
<el-table <ms-table
v-loading="result.loading" v-loading="page.result.loading"
:data="testCases" :data="page.data"
@filter-change="filter" :condition="page.condition"
row-key="id" :total="page.total"
@mouseleave.passive="leave" :page-size.sync="page.pageSize"
v-el-table-infinite-scroll="scrollLoading" :screen-height="null"
@select-all="handleSelectAll" @handlePageChange="search"
@select="handleSelectionChange" @refresh="search"
height="50vh"
ref="table"> ref="table">
<el-table-column <ms-table-column
type="selection"></el-table-column> v-if="!customNum"
prop="num"
sortable
:label="$t('commons.id')">
</ms-table-column>
<ms-table-column
v-if="customNum"
prop="customNum"
sortable
:label="$t('commons.id')">
</ms-table-column>
<el-table-column <ms-table-column prop="name" :label="$t('commons.name')"/>
prop="name"
:label="$t('test_track.case.name')" <ms-table-column
style="width: 100%">
<template v-slot:default="scope">
{{scope.row.name}}
</template>
</el-table-column>
<el-table-column
prop="priority" prop="priority"
:filters="priorityFilters" :filters="priorityFilters"
column-key="priority" sortable
:label="$t('test_track.case.priority')" :label="$t('test_track.case.priority')">
show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
<priority-table-item :value="scope.row.priority"/> <priority-table-item :value="scope.row.priority"/>
</template> </template>
</el-table-column> </ms-table-column>
<el-table-column
prop="type"
:filters="typeFilters"
column-key="type"
:label="$t('test_track.case.type')"
show-overflow-tooltip>
<template v-slot:default="scope">
<type-table-item :value="scope.row.type"/>
</template>
</el-table-column>
</el-table>
<div v-if="!lineStatus" style="text-align: center">{{ $t('test_track.review_view.last_page') }}</div> <ms-table-column prop="tags" :label="$t('commons.tag')">
<div style="text-align: center"> {{ total }} </div> <template v-slot:default="scope">
<ms-tag v-for="(itemName, index) in scope.row.tags" :key="index" type="success" effect="plain"
:content="itemName" style="margin-left: 0px; margin-right: 2px"/>
<span/>
</template>
</ms-table-column>
<ms-table-column
sortable
:label="$t('commons.create_time')"
prop="createTime">
<template v-slot="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template>
</ms-table-column>
<ms-table-column
sortable
:label="$t('commons.update_time')"
prop="updateTime">
<template v-slot="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</ms-table-column>
</ms-table>
<ms-table-pagination :change="search" :current-page.sync="page.currentPage" :page-size.sync="page.pageSize" :total="page.total"/>
</test-case-relevance-base> </test-case-relevance-base>
</template> </template>
@ -76,15 +94,21 @@ import TypeTableItem from "../../../../common/tableItems/planview/TypeTableItem"
import MsTableSearchBar from "../../../../../common/components/MsTableSearchBar"; import MsTableSearchBar from "../../../../../common/components/MsTableSearchBar";
import MsTableAdvSearchBar from "../../../../../common/components/search/MsTableAdvSearchBar"; import MsTableAdvSearchBar from "../../../../../common/components/search/MsTableAdvSearchBar";
import MsTableHeader from "../../../../../common/components/MsTableHeader"; import MsTableHeader from "../../../../../common/components/MsTableHeader";
import {TEST_CASE_CONFIGS} from "../../../../../common/components/search/search-components";
import elTableInfiniteScroll from 'el-table-infinite-scroll';
import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase"; import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase";
import {_filter} from "@/common/js/tableUtils"; import {buildPagePath, getPageDate, getPageInfo} from "@/common/js/tableUtils";
import MsTableColumn from "@/business/components/common/components/table/Ms-table-column";
import MsTable from "@/business/components/common/components/table/MsTable";
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import MsTag from "@/business/components/common/components/MsTag";
export default { export default {
name: "TestCaseFunctionalRelevance", name: "TestCaseFunctionalRelevance",
components: { components: {
MsTag,
MsTablePagination,
MsTable,
MsTableColumn,
TestCaseRelevanceBase, TestCaseRelevanceBase,
NodeTree, NodeTree,
PriorityTableItem, PriorityTableItem,
@ -93,212 +117,138 @@ export default {
MsTableAdvSearchBar, MsTableAdvSearchBar,
MsTableHeader, MsTableHeader,
}, },
directives: { data() {
'el-table-infinite-scroll': elTableInfiniteScroll return {
result: {},
treeNodes: [],
selectNodeIds: [],
selectNodeNames: [],
projectId: '',
projectName: '',
projects: [],
page: getPageInfo(),
customNum: false,
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'}
]
};
},
props: {
planId: {
type: String
}
},
watch: {
planId() {
this.page.condition.planId = this.planId;
}, },
data() { selectNodeIds() {
return { this.search();
result: {},
isCheckAll: false,
testCases: [],
selectIds: new Set(),
treeNodes: [],
selectNodeIds: [],
selectNodeNames: [],
projectId: '',
projectName: '',
projects: [],
pageSize: 50,
currentPage: 1,
total: 0,
lineStatus: true,
condition: {
components: TEST_CASE_CONFIGS
},
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'}
],
typeFilters: [
{text: this.$t('commons.functional'), value: 'functional'},
{text: this.$t('commons.performance'), value: 'performance'},
{text: this.$t('commons.api'), value: 'api'}
]
};
}, },
props: { projectId() {
planId: { this.page.condition.projectId = this.projectId;
type: String this.getProjectNode();
this.search();
this.getProject();
}
},
methods: {
open() {
this.$refs.baseRelevance.open();
if (this.$refs.table) {
this.$refs.table.clear();
} }
}, },
watch: { setProject(projectId) {
planId() { this.projectId = projectId;
this.condition.planId = this.planId;
},
selectNodeIds() {
this.search();
},
projectId() {
this.condition.projectId = this.projectId;
this.getProjectNode();
this.search();
}
}, },
updated() { getProject() {
this.toggleSelection(this.testCases); this.$get("/project/get/" + this.projectId, result => {
}, let data = result.data;
methods: { if (data) {
this.customNum = data.customNum;
open() {
this.$refs.baseRelevance.open();
},
setProject(projectId) {
this.projectId = projectId;
},
saveCaseRelevance(item) {
let param = {};
param.planId = this.planId;
param.testCaseIds = [...this.selectIds];
param.request = this.condition;
param.checked = item
//
if (this.testCases.length === param.testCaseIds.length) {
param.testCaseIds = ['all'];
} }
this.result = this.$post('/test/plan/relevance', param, () => { })
this.selectIds.clear(); },
this.$success(this.$t('commons.save_success')); saveCaseRelevance(item) {
let param = {};
this.$refs.baseRelevance.close(); param.planId = this.planId;
param.ids = this.$refs.table.selectIds;
this.$emit('refresh'); param.request = this.page.condition;
param.checked = item
this.result = this.$post('/test/plan/relevance', param, () => {
this.$success(this.$t('commons.save_success'));
this.$refs.baseRelevance.close();
this.$emit('refresh');
});
},
search() {
this.getTestCases();
},
getTestCases() {
let condition = this.page.condition;
if (this.planId) {
condition.planId = this.planId;
}
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
condition.nodeIds = this.selectNodeIds;
} else {
condition.nodeIds = [];
}
if (this.projectId) {
condition.projectId = this.projectId;
this.page.result = this.$post(buildPagePath('/test/case/relate', this.page), condition, response => {
getPageDate(response, this.page);
let data = this.page.data;
data.forEach(item => {
item.checked = false;
item.tags = JSON.parse(item.tags);
});
}); });
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
search() {
this.currentPage = 1;
this.testCases = [];
this.getTestCases(true);
},
getTestCases(flag) {
if (this.planId) {
this.condition.planId = this.planId;
}
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
this.condition.nodeIds = this.selectNodeIds;
} else {
this.condition.nodeIds = [];
}
if (this.projectId) {
this.condition.projectId = this.projectId;
this.result = this.$post(this.buildPagePath('/test/case/relate'), this.condition, response => {
let data = response.data;
this.total = data.itemCount;
let tableData = data.listObject;
tableData.forEach(item => {
item.checked = false;
});
flag ? this.testCases = tableData : this.testCases = this.testCases.concat(tableData);
//
let hash = {};
this.testCases = this.testCases.reduce((item, next) => {
if (!hash[next.id]) {
hash[next.id] = true
item.push(next)
}
return item
}, [])
this.lineStatus = tableData.length === 50 && this.testCases.length < this.total;
});
}
},
handleSelectAll(selection) {
if (selection.length > 0) {
this.testCases.forEach(item => {
this.selectIds.add(item.id);
});
} else {
this.testCases.forEach(item => {
if (this.selectIds.has(item.id)) {
this.selectIds.delete(item.id);
}
});
}
},
handleSelectionChange(selection, row) {
if (this.selectIds.has(row.id)) {
this.selectIds.delete(row.id);
} else {
this.selectIds.add(row.id);
}
},
nodeChange(node, nodeIds, nodeNames) {
this.selectNodeIds = nodeIds;
this.selectNodeNames = nodeNames;
},
refresh() {
this.close();
},
scrollLoading() {
if (this.lineStatus) {
this.currentPage += 1;
this.getTestCases();
}
},
getAllNodeTreeByPlanId() {
if (this.planId) {
let param = {
testPlanId: this.planId,
projectId: this.projectId
};
this.result = this.$post("/case/node/list/all/plan", param, response => {
this.treeNodes = response.data;
});
}
},
close() {
this.lineStatus = false;
this.selectIds.clear();
this.selectNodeIds = [];
this.selectNodeNames = [];
},
filter(filters) {
_filter(filters, this.condition);
this.search();
},
toggleSelection(rows) {
rows.forEach(row => {
this.selectIds.forEach(id => {
if (row.id === id) {
// true
this.$refs.table.toggleRowSelection(row, true)
}
})
})
},
getProjectNode(projectId) {
const index = this.projects.findIndex(project => project.id === projectId);
if (index !== -1) {
this.projectName = this.projects[index].name;
}
if (projectId) {
this.projectId = projectId;
}
this.$refs.nodeTree.result = this.$post("/case/node/list/all/plan",
{testPlanId: this.planId, projectId: this.projectId}, response => {
this.treeNodes = response.data;
});
this.selectNodeIds = [];
} }
},
nodeChange(node, nodeIds, nodeNames) {
this.selectNodeIds = nodeIds;
this.selectNodeNames = nodeNames;
},
refresh() {
this.close();
},
getAllNodeTreeByPlanId() {
if (this.planId) {
let param = {
testPlanId: this.planId,
projectId: this.projectId
};
this.result = this.$post("/case/node/list/all/plan", param, response => {
this.treeNodes = response.data;
});
}
},
close() {
this.selectNodeIds = [];
this.selectNodeNames = [];
this.$refs.table.clear();
},
getProjectNode(projectId) {
const index = this.projects.findIndex(project => project.id === projectId);
if (index !== -1) {
this.projectName = this.projects[index].name;
}
if (projectId) {
this.projectId = projectId;
}
this.$refs.nodeTree.result = this.$post("/case/node/list/all/plan",
{testPlanId: this.planId, projectId: this.projectId}, response => {
this.treeNodes = response.data;
});
this.selectNodeIds = [];
} }
} }
}
</script> </script>
<style scoped> <style scoped>

View File

@ -205,3 +205,13 @@ export function getPageInfo() {
condition: {}, condition: {},
} }
} }
export function buildPagePath(path, page) {
return path + "/" + page.currentPage + "/" + page.pageSize;
}
export function getPageDate(response, page) {
let data = response.data;
page.total = data.itemCount;
page.data = data.listObject;
}

View File

@ -1,7 +1,8 @@
import {post} from "@/common/js/ajax"; import {post} from "@/common/js/ajax";
import {getPageDate} from "@/network/network-utils"; import {getPageDate} from "@/common/js/tableUtils";
export function buildIssues(data, page) { export function buildIssues(page) {
let data = page.data;
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
if (data[i]) { if (data[i]) {
if (data[i].platform !== 'Local') { if (data[i].platform !== 'Local') {
@ -9,13 +10,12 @@ export function buildIssues(data, page) {
} }
} }
} }
page.data = data;
} }
export function getIssues(page) { export function getIssues(page) {
return post('issues/list/' + page.currentPage + '/' + page.pageSize, page.condition, (response) => { return post('issues/list/' + page.currentPage + '/' + page.pageSize, page.condition, (response) => {
let data = getPageDate(response, page); getPageDate(response, page);
buildIssues(data, page); buildIssues(page);
}); });
} }
@ -44,8 +44,8 @@ export function testCaseIssueRelate(param, success) {
export function getRelateIssues(page) { export function getRelateIssues(page) {
return post('issues/list/relate/' + page.currentPage + '/' + page.pageSize, page.condition, (response) => { return post('issues/list/relate/' + page.currentPage + '/' + page.pageSize, page.condition, (response) => {
let data = getPageDate(response, page); getPageDate(response, page);
buildIssues(data, page); buildIssues(page);
}); });
} }

View File

@ -1,5 +0,0 @@
export function getPageDate(response, page) {
let data = response.data;
page.total = data.itemCount;
return data.listObject;
}