This commit is contained in:
fit2-zhao 2020-12-10 16:49:14 +08:00
commit db0fa8a810
24 changed files with 233 additions and 159 deletions

View File

@ -12,7 +12,7 @@ public interface ExtTestCaseReviewMapper {
List<TestCaseReviewDTO> list(@Param("request") QueryCaseReviewRequest params); List<TestCaseReviewDTO> list(@Param("request") QueryCaseReviewRequest params);
List<TestCaseReviewDTO> listByWorkspaceId(@Param("workspaceId") String workspaceId, @Param("userId") String userId); List<TestCaseReviewDTO> listByWorkspaceId(@Param("workspaceId") String workspaceId, @Param("userId") String userId, @Param("projectId") String projectId);
List<TestReviewDTOWithMetric> listRelate(@Param("request") QueryTestReviewRequest request); List<TestReviewDTOWithMetric> listRelate(@Param("request") QueryTestReviewRequest request);

View File

@ -15,6 +15,9 @@
and test_case_review.name like CONCAT('%', #{request.name},'%') and test_case_review.name like CONCAT('%', #{request.name},'%')
</if> </if>
and project.workspace_id = #{request.workspaceId} and project.workspace_id = #{request.workspaceId}
<if test="request.projectId != null">
and test_case_review_project.project_id = #{request.projectId}
</if>
</where> </where>
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
order by order by
@ -32,6 +35,9 @@
test_case_review.id = test_case_review_project.review_id test_case_review.id = test_case_review_project.review_id
and test_case_review_project.project_id = project.id and test_case_review_project.project_id = project.id
and project.workspace_id = #{workspaceId} and project.workspace_id = #{workspaceId}
<if test="projectId != null">
and test_case_review_project.project_id = #{projectId}
</if>
and ( and (
(test_case_review_users.review_id = test_case_review.id (test_case_review_users.review_id = test_case_review.id
and test_case_review_users.user_id = #{userId} ) and test_case_review_users.user_id = #{userId} )
@ -51,6 +57,9 @@
<if test="request.reviewerId != null"> <if test="request.reviewerId != null">
and test_case_review_users.user_id = #{request.reviewerId} and test_case_review_users.user_id = #{request.reviewerId}
</if> </if>
<if test="request.projectId != null">
and test_case_review_project.project_id = #{request.projectId}
</if>
<if test="request.creator != null"> <if test="request.creator != null">
and (test_case_review.creator = #{request.creator} and (test_case_review.creator = #{request.creator}
<if test="request.reviewIds != null and request.reviewIds.size() > 0"> <if test="request.reviewIds != null and request.reviewIds.size() > 0">

View File

@ -114,6 +114,9 @@
<if test="request.workspaceId != null"> <if test="request.workspaceId != null">
AND test_plan.workspace_id = #{request.workspaceId} AND test_plan.workspace_id = #{request.workspaceId}
</if> </if>
<if test="request.projectId != null">
AND test_plan_project.project_id = #{request.projectId}
</if>
<if test="request.id != null"> <if test="request.id != null">
AND test_plan.id = #{request.id} AND test_plan.id = #{request.id}
</if> </if>
@ -160,16 +163,22 @@
</select> </select>
<select id="listRelate" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric"> <select id="listRelate" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric">
select test_plan.* from test_plan select distinct test_plan.* from test_plan
where test_plan.workspace_id = #{request.workspaceId} inner join test_plan_project on test_plan.id = test_plan_project.test_plan_id
and (test_plan.principal = #{request.principal} <where>
<if test="request.planIds != null and request.planIds.size() > 0"> test_plan.workspace_id = #{request.workspaceId}
or test_plan.id in <if test="request.projectId != null">
<foreach collection="request.planIds" item="planId" open="(" close=")" separator=","> and test_plan_project.project_id = #{request.projectId}
#{planId} </if>
</foreach> and (test_plan.principal = #{request.principal}
</if> <if test="request.planIds != null and request.planIds.size() > 0">
) or test_plan.id in
<foreach collection="request.planIds" item="planId" open="(" close=")" separator=",">
#{planId}
</foreach>
</if>
)
</where>
order by test_plan.update_time desc order by test_plan.update_time desc
</select> </select>

View File

@ -19,7 +19,7 @@ public interface ExtTestPlanTestCaseMapper {
List<TestPlanCaseDTO> listByNodes(@Param("request") QueryTestPlanCaseRequest request); List<TestPlanCaseDTO> listByNodes(@Param("request") QueryTestPlanCaseRequest request);
List<String> findRelateTestPlanId(@Param("userId") String userId, @Param("workspaceId") String workspaceId); List<String> findRelateTestPlanId(@Param("userId") String userId, @Param("workspaceId") String workspaceId, @Param("projectId") String projectId);
List<TestPlanCaseDTO> getRecentTestedTestCase(@Param("request") QueryTestPlanCaseRequest request); List<TestPlanCaseDTO> getRecentTestedTestCase(@Param("request") QueryTestPlanCaseRequest request);

View File

@ -270,8 +270,15 @@
select distinct plan_id from test_plan_test_case select distinct plan_id from test_plan_test_case
inner join test_plan inner join test_plan
on test_plan_test_case.plan_id = test_plan.id on test_plan_test_case.plan_id = test_plan.id
where test_plan_test_case.executor = #{userId} inner join test_plan_project
and test_plan.workspace_id = #{workspaceId} on test_plan.id = test_plan_project.test_plan_id
<where>
test_plan_test_case.executor = #{userId}
and test_plan.workspace_id = #{workspaceId}
<if test="projectId != null">
and test_plan_project.project_id = #{projectId}
</if>
</where>
</select> </select>
<select id="getRecentTestedTestCase" resultType="io.metersphere.track.dto.TestPlanCaseDTO"> <select id="getRecentTestedTestCase" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
select test_plan_test_case.*, test_case.* select test_plan_test_case.*, test_case.*

View File

@ -11,7 +11,7 @@ public interface ExtTestReviewCaseMapper {
List<TestReviewCaseDTO> list(@Param("request") QueryCaseReviewRequest request); List<TestReviewCaseDTO> list(@Param("request") QueryCaseReviewRequest request);
List<String> getStatusByReviewId(String reviewId); List<String> getStatusByReviewId(String reviewId);
List<String> findRelateTestReviewId(@Param("userId") String userId, @Param("workspaceId") String workspaceId); List<String> findRelateTestReviewId(@Param("userId") String userId, @Param("workspaceId") String workspaceId, @Param("projectId") String projectId);
/** /**
* 根据项目 ids 查询 TestReviewCaseDTO 列表 * 根据项目 ids 查询 TestReviewCaseDTO 列表

View File

@ -206,6 +206,7 @@
inner join project on project.id = test_case_review_project.project_id inner join project on project.id = test_case_review_project.project_id
where test_case_review_test_case.review_id = #{userId} where test_case_review_test_case.review_id = #{userId}
and project.workspace_id = #{workspaceId} and project.workspace_id = #{workspaceId}
and test_case_review_project.project_id = #{projectId}
</select> </select>
<select id="listTestCaseByProjectIds" resultType="io.metersphere.track.dto.TestReviewCaseDTO"> <select id="listTestCaseByProjectIds" resultType="io.metersphere.track.dto.TestReviewCaseDTO">
select distinct * from test_case_review_test_case, test_case select distinct * from test_case_review_test_case, test_case

View File

@ -68,4 +68,8 @@ public class SessionUtils {
public static String getCurrentOrganizationId() { public static String getCurrentOrganizationId() {
return Optional.ofNullable(getUser()).orElse(new SessionUser()).getLastOrganizationId(); return Optional.ofNullable(getUser()).orElse(new SessionUser()).getLastOrganizationId();
} }
public static String getCurrentProjectId() {
return Optional.ofNullable(getUser()).orElse(new SessionUser()).getLastProjectId();
}
} }

View File

@ -81,8 +81,7 @@ public class TestCaseReviewController {
@PostMapping("/list/all") @PostMapping("/list/all")
public List<TestCaseReview> listAll() { public List<TestCaseReview> listAll() {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId(); return testCaseReviewService.listCaseReviewAll();
return testCaseReviewService.listCaseReviewAll(currentWorkspaceId);
} }
@PostMapping("/relevance") @PostMapping("/relevance")

View File

@ -35,4 +35,6 @@ public class QueryCaseReviewRequest extends TestCaseReviewTestCase {
private String method; private String method;
private Map<String, Object> combine; private Map<String, Object> combine;
private String projectId;
} }

View File

@ -156,6 +156,7 @@ public class TestCaseReviewService {
public List<TestCaseReviewDTO> listCaseReview(QueryCaseReviewRequest request) { public List<TestCaseReviewDTO> listCaseReview(QueryCaseReviewRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setProjectId(SessionUtils.getCurrentProjectId());
return extTestCaseReviewMapper.list(request); return extTestCaseReviewMapper.list(request);
} }
@ -198,7 +199,7 @@ public class TestCaseReviewService {
} }
public List<TestCaseReviewDTO> recent(String currentWorkspaceId) { public List<TestCaseReviewDTO> recent(String currentWorkspaceId) {
return extTestCaseReviewMapper.listByWorkspaceId(currentWorkspaceId, SessionUtils.getUserId()); return extTestCaseReviewMapper.listByWorkspaceId(currentWorkspaceId, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId());
} }
public void editCaseReview(SaveTestCaseReviewRequest testCaseReview) { public void editCaseReview(SaveTestCaseReviewRequest testCaseReview) {
@ -346,21 +347,16 @@ public class TestCaseReviewService {
testCaseReviewTestCaseMapper.deleteByExample(testCaseReviewTestCaseExample); testCaseReviewTestCaseMapper.deleteByExample(testCaseReviewTestCaseExample);
} }
public List<TestCaseReview> listCaseReviewAll(String currentWorkspaceId) { public List<TestCaseReview> listCaseReviewAll() {
ProjectExample projectExample = new ProjectExample(); TestCaseReviewProjectExample reviewProjectExample = new TestCaseReviewProjectExample();
projectExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId); TestCaseReviewProjectExample.Criteria criteria = reviewProjectExample.createCriteria();
List<Project> projects = projectMapper.selectByExample(projectExample); if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) {
List<String> projectIds = projects.stream().map(Project::getId).collect(Collectors.toList()); criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
List<TestCaseReviewProject> testCaseReviewProjects = testCaseReviewProjectMapper.selectByExample(reviewProjectExample);
if (!CollectionUtils.isEmpty(projectIds)) { if (!CollectionUtils.isEmpty(testCaseReviewProjects)) {
TestCaseReviewProjectExample testCaseReviewProjectExample = new TestCaseReviewProjectExample(); List<String> caseReviewIds = testCaseReviewProjects.stream().map(TestCaseReviewProject::getReviewId).collect(Collectors.toList());
testCaseReviewProjectExample.createCriteria().andProjectIdIn(projectIds);
List<TestCaseReviewProject> testCaseReviewProjects = testCaseReviewProjectMapper.selectByExample(testCaseReviewProjectExample);
List<String> reviewIds = testCaseReviewProjects.stream().map(TestCaseReviewProject::getReviewId).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(reviewIds)) {
TestCaseReviewExample testCaseReviewExample = new TestCaseReviewExample(); TestCaseReviewExample testCaseReviewExample = new TestCaseReviewExample();
testCaseReviewExample.createCriteria().andIdIn(reviewIds); testCaseReviewExample.createCriteria().andIdIn(caseReviewIds);
return testCaseReviewMapper.selectByExample(testCaseReviewExample); return testCaseReviewMapper.selectByExample(testCaseReviewExample);
} }
} }
@ -481,7 +477,8 @@ public class TestCaseReviewService {
request.setReviewerId(user.getId()); request.setReviewerId(user.getId());
} }
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
request.setReviewIds(extTestReviewCaseMapper.findRelateTestReviewId(user.getId(), SessionUtils.getCurrentWorkspaceId())); request.setProjectId(SessionUtils.getCurrentProjectId());
request.setReviewIds(extTestReviewCaseMapper.findRelateTestReviewId(user.getId(), SessionUtils.getCurrentWorkspaceId(), user.getLastProjectId()));
List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(SessionUtils.getCurrentWorkspaceId()); List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(SessionUtils.getCurrentWorkspaceId());
@ -545,9 +542,11 @@ public class TestCaseReviewService {
if (userIds.size() > 0) { if (userIds.size() > 0) {
for (String id : userIds) { for (String id : userIds) {
stringBuilder.append(userMap.get(id)).append(""); if (StringUtils.isNotBlank(userMap.get(id))) {
stringBuilder.append(userMap.get(id)).append("");
}
} }
name = stringBuilder.toString().substring(0, stringBuilder.length() - 1); name = stringBuilder.substring(0, stringBuilder.length() - 1);
} }
return name; return name;
} }

View File

@ -220,27 +220,17 @@ public class TestCaseService {
public List<TestCase> recentTestPlans(QueryTestCaseRequest request, int count) { public List<TestCase> recentTestPlans(QueryTestCaseRequest request, int count) {
if (StringUtils.isBlank(request.getWorkspaceId())) {
return null;
}
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andWorkspaceIdEqualTo(request.getWorkspaceId());
List<String> projectIds = projectMapper.selectByExample(projectExample).stream()
.map(Project::getId).collect(Collectors.toList());
if (projectIds.isEmpty()) {
return null;
}
PageHelper.startPage(1, count, true); PageHelper.startPage(1, count, true);
TestCaseExample testCaseExample = new TestCaseExample(); TestCaseExample testCaseExample = new TestCaseExample();
testCaseExample.createCriteria().andProjectIdIn(projectIds).andMaintainerEqualTo(request.getUserId()); TestCaseExample.Criteria criteria = testCaseExample.createCriteria();
testCaseExample.setOrderByClause("update_time desc, sort desc"); criteria.andMaintainerEqualTo(request.getUserId());
return testCaseMapper.selectByExample(testCaseExample); String projectId = SessionUtils.getCurrentProjectId();
if (StringUtils.isNotBlank(projectId)) {
criteria.andProjectIdEqualTo(projectId);
testCaseExample.setOrderByClause("update_time desc, sort desc");
return testCaseMapper.selectByExample(testCaseExample);
}
return new ArrayList<>();
} }
public Project getProjectByTestCaseId(String testCaseId) { public Project getProjectByTestCaseId(String testCaseId) {

View File

@ -327,6 +327,10 @@ public class TestPlanService {
public List<TestPlanDTOWithMetric> listTestPlan(QueryTestPlanRequest request) { public List<TestPlanDTOWithMetric> listTestPlan(QueryTestPlanRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
String projectId = SessionUtils.getCurrentProjectId();
if (StringUtils.isNotBlank(projectId)) {
request.setProjectId(projectId);
}
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.list(request); List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.list(request);
calcTestPlanRate(testPlans); calcTestPlanRate(testPlans);
return testPlans; return testPlans;
@ -392,17 +396,41 @@ public class TestPlanService {
if (StringUtils.isBlank(currentWorkspaceId)) { if (StringUtils.isBlank(currentWorkspaceId)) {
return null; return null;
} }
TestPlanExample testPlanTestCaseExample = new TestPlanExample(); TestPlanProjectExample testPlanProjectExample = new TestPlanProjectExample();
testPlanTestCaseExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId) TestPlanProjectExample.Criteria criteria = testPlanProjectExample.createCriteria();
.andPrincipalEqualTo(SessionUtils.getUserId()); if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) {
testPlanTestCaseExample.setOrderByClause("update_time desc"); criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
return testPlanMapper.selectByExample(testPlanTestCaseExample); List<TestPlanProject> testPlanProjects = testPlanProjectMapper.selectByExample(testPlanProjectExample);
if (!CollectionUtils.isEmpty(testPlanProjects)) {
List<String> testPlanIds = testPlanProjects.stream().map(TestPlanProject::getTestPlanId).collect(Collectors.toList());
TestPlanExample testPlanTestCaseExample = new TestPlanExample();
testPlanTestCaseExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId)
.andIdIn(testPlanIds)
.andPrincipalEqualTo(SessionUtils.getUserId());
testPlanTestCaseExample.setOrderByClause("update_time desc");
return testPlanMapper.selectByExample(testPlanTestCaseExample);
}
}
return new ArrayList<>();
} }
public List<TestPlan> listTestAllPlan(String currentWorkspaceId) { public List<TestPlan> listTestAllPlan(String currentWorkspaceId) {
TestPlanExample testPlanExample = new TestPlanExample(); TestPlanProjectExample testPlanProjectExample = new TestPlanProjectExample();
testPlanExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId); TestPlanProjectExample.Criteria criteria = testPlanProjectExample.createCriteria();
return testPlanMapper.selectByExample(testPlanExample); if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) {
criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
List<TestPlanProject> testPlanProjects = testPlanProjectMapper.selectByExample(testPlanProjectExample);
if (!CollectionUtils.isEmpty(testPlanProjects)) {
List<String> testPlanIds = testPlanProjects.stream().map(TestPlanProject::getTestPlanId).collect(Collectors.toList());
TestPlanExample testPlanExample = new TestPlanExample();
TestPlanExample.Criteria testPlanCriteria = testPlanExample.createCriteria();
testPlanCriteria.andWorkspaceIdEqualTo(currentWorkspaceId);
testPlanCriteria.andIdIn(testPlanIds);
return testPlanMapper.selectByExample(testPlanExample);
}
}
return new ArrayList<>();
} }
public List<TestPlanDTOWithMetric> listRelateAllPlan() { public List<TestPlanDTOWithMetric> listRelateAllPlan() {
@ -410,7 +438,8 @@ public class TestPlanService {
QueryTestPlanRequest request = new QueryTestPlanRequest(); QueryTestPlanRequest request = new QueryTestPlanRequest();
request.setPrincipal(user.getId()); request.setPrincipal(user.getId());
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
request.setPlanIds(extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId())); request.setProjectId(SessionUtils.getCurrentProjectId());
request.setPlanIds(extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId(), SessionUtils.getCurrentProjectId()));
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.listRelate(request); List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.listRelate(request);
calcTestPlanRate(testPlans); calcTestPlanRate(testPlans);
return testPlans; return testPlans;

View File

@ -123,7 +123,7 @@ public class TestPlanTestCaseService {
public void buildQueryRequest(QueryTestPlanCaseRequest request, int count) { public void buildQueryRequest(QueryTestPlanCaseRequest request, int count) {
SessionUser user = SessionUtils.getUser(); SessionUser user = SessionUtils.getUser();
List<String> relateTestPlanIds = extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId()); List<String> relateTestPlanIds = extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId(), SessionUtils.getCurrentProjectId());
PageHelper.startPage(1, count, true); PageHelper.startPage(1, count, true);
request.setPlanIds(relateTestPlanIds); request.setPlanIds(relateTestPlanIds);
request.setExecutor(user.getId()); request.setExecutor(user.getId());

View File

@ -46,6 +46,14 @@ export default {
logoId: '_blank', logoId: '_blank',
} }
}, },
created() {
if (localStorage.getItem("store")) {
this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(localStorage.getItem("store"))))
}
window.addEventListener("beforeunload", () => {
localStorage.setItem("store", JSON.stringify(this.$store.state))
})
},
beforeCreate() { beforeCreate() {
this.$get("/isLogin").then(response => { this.$get("/isLogin").then(response => {
if (response.data.success) { if (response.data.success) {

View File

@ -52,7 +52,7 @@
</el-submenu> </el-submenu>
<el-menu-item v-show="$store.state.switch.value=='new'" <el-menu-item v-show="$store.state.switch.value=='old'"
v-permission="['test_manager','test_user','test_viewer']" :index="'/api/monitor/view'"> v-permission="['test_manager','test_user','test_viewer']" :index="'/api/monitor/view'">
{{ $t('commons.monitor') }} {{ $t('commons.monitor') }}
</el-menu-item> </el-menu-item>
@ -116,7 +116,6 @@ export default {
apiTestProjectPath: '', apiTestProjectPath: '',
} }
}, },
watch: { watch: {
'$route'(to) { '$route'(to) {
this.init(); this.init();

View File

@ -8,10 +8,10 @@
<el-dropdown-item command="personal">{{ $t('commons.personal_information') }}</el-dropdown-item> <el-dropdown-item command="personal">{{ $t('commons.personal_information') }}</el-dropdown-item>
<el-dropdown-item command="about">{{ $t('commons.about_us') }} <i class="el-icon-info"/></el-dropdown-item> <el-dropdown-item command="about">{{ $t('commons.about_us') }} <i class="el-icon-info"/></el-dropdown-item>
<el-dropdown-item command="help">{{ $t('commons.help_documentation') }}</el-dropdown-item> <el-dropdown-item command="help">{{ $t('commons.help_documentation') }}</el-dropdown-item>
<el-dropdown-item command="old" :disabled=!isReadOnly @click.native="changeBar('old')"> <el-dropdown-item command="old" :disabled=isReadOnly @click.native="changeBar('old')">
{{ $t('commons.cut_back_old_version') }} {{ $t('commons.cut_back_old_version') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="new" :disabled=isReadOnly @click.native="changeBar('new')"> <el-dropdown-item command="new" :disabled=!isReadOnly @click.native="changeBar('new')">
{{ $t('commons.cut_back_new_version') }} {{ $t('commons.cut_back_new_version') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="logout">{{ $t('commons.exit_system') }}</el-dropdown-item> <el-dropdown-item command="logout">{{ $t('commons.exit_system') }}</el-dropdown-item>
@ -32,7 +32,7 @@
components: {AboutUs}, components: {AboutUs},
data() { data() {
return { return {
isReadOnly: true isReadOnly: this.$store.state.isReadOnly.flag
} }
}, },
computed: { computed: {
@ -75,6 +75,7 @@
}, },
changeBar(item) { changeBar(item) {
this.isReadOnly = !this.isReadOnly this.isReadOnly = !this.isReadOnly
this.$store.commit('setFlag', this.isReadOnly);
this.$store.commit('setValue', item); this.$store.commit('setValue', item);
} }
} }

View File

@ -2,11 +2,6 @@
<ms-container> <ms-container>
<ms-aside-container> <ms-aside-container>
<select-menu
:data="projects"
:current-data="currentProject"
:title="$t('test_track.project')"
@dataChange="changeProject"/>
<node-tree <node-tree
class="node-tree" class="node-tree"
v-loading="result.loading" v-loading="result.loading"
@ -17,13 +12,13 @@
:draggable="nodeTreeDraggable" :draggable="nodeTreeDraggable"
:select-node.sync="selectNode" :select-node.sync="selectNode"
@refreshTable="refreshTable" @refreshTable="refreshTable"
:current-project="currentProject" :current-project="{id:currentProject}"
ref="nodeTree"/> ref="nodeTree"/>
</ms-aside-container> </ms-aside-container>
<ms-main-container> <ms-main-container>
<test-case-list <test-case-list
:current-project="currentProject" :current-project="{id:currentProject}"
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:select-parent-nodes="selectParentNodes" :select-parent-nodes="selectParentNodes"
@testCaseEdit="editTestCase" @testCaseEdit="editTestCase"
@ -41,7 +36,7 @@
:read-only="testCaseReadOnly" :read-only="testCaseReadOnly"
:tree-nodes="treeNodes" :tree-nodes="treeNodes"
:select-node="selectNode" :select-node="selectNode"
:current-project="currentProject" :current-project="{id:currentProject}"
ref="testCaseEditDialog"> ref="testCaseEditDialog">
</test-case-edit> </test-case-edit>
@ -57,7 +52,7 @@
import NodeTree from '../common/NodeTree'; import NodeTree from '../common/NodeTree';
import TestCaseEdit from './components/TestCaseEdit'; import TestCaseEdit from './components/TestCaseEdit';
import {CURRENT_PROJECT, ROLE_TEST_MANAGER, ROLE_TEST_USER} from '../../../../common/js/constants'; import {PROJECT_ID, ROLE_TEST_MANAGER, ROLE_TEST_USER} from '../../../../common/js/constants';
import TestCaseList from "./components/TestCaseList"; import TestCaseList from "./components/TestCaseList";
import SelectMenu from "../common/SelectMenu"; import SelectMenu from "../common/SelectMenu";
import TestCaseMove from "./components/TestCaseMove"; import TestCaseMove from "./components/TestCaseMove";
@ -90,11 +85,15 @@ export default {
nodeTreeDraggable: true, nodeTreeDraggable: true,
} }
}, },
activated() {
this.currentProject = localStorage.getItem(PROJECT_ID);
},
mounted() { mounted() {
this.init(this.$route); this.init(this.$route);
}, },
watch: { watch: {
'$route'(to, from) { '$route'(to, from) {
// console.log(this.$route.params.projectId)
this.init(to); this.init(to);
}, },
currentProject() { currentProject() {
@ -105,7 +104,7 @@ export default {
init(route) { init(route) {
let path = route.path; let path = route.path;
if (path.indexOf("/track/case/edit") >= 0 || path.indexOf("/track/case/create") >= 0) { if (path.indexOf("/track/case/edit") >= 0 || path.indexOf("/track/case/create") >= 0) {
this.getProjects(); // this.getProjects();
this.testCaseReadOnly = false; this.testCaseReadOnly = false;
if (!checkoutTestManagerOrTestUser()) { if (!checkoutTestManagerOrTestUser()) {
this.testCaseReadOnly = true; this.testCaseReadOnly = true;
@ -113,48 +112,49 @@ export default {
let caseId = this.$route.params.caseId; let caseId = this.$route.params.caseId;
this.openRecentTestCaseEditDialog(caseId); this.openRecentTestCaseEditDialog(caseId);
this.$router.push('/track/case/all'); this.$router.push('/track/case/all');
} else if (route.params.projectId) {
this.getProjects();
this.getProjectById(route.params.projectId);
} }
// else if (route.params.projectId) {
// this.getProjects();
// this.getProjectById(route.params.projectId);
// }
}, },
getProjects() { // getProjects() {
this.$get("/project/listAll", (response) => { // this.$get("/project/listAll", (response) => {
this.projects = response.data; // this.projects = response.data;
let lastProject = JSON.parse(localStorage.getItem(CURRENT_PROJECT)); // let lastProject = JSON.parse(localStorage.getItem(CURRENT_PROJECT));
if (lastProject) { // if (lastProject) {
let hasCurrentProject = false; // let hasCurrentProject = false;
for (let i = 0; i < this.projects.length; i++) { // for (let i = 0; i < this.projects.length; i++) {
if (this.projects[i].id == lastProject.id) { // if (this.projects[i].id == lastProject.id) {
this.currentProject = lastProject; // this.currentProject = lastProject;
hasCurrentProject = true; // hasCurrentProject = true;
break; // break;
} // }
} // }
if (!hasCurrentProject) { // if (!hasCurrentProject) {
this.setCurrentProject(this.projects[0]); // this.setCurrentProject(this.projects[0]);
} // }
} else { // } else {
if (this.projects.length > 0) { // if (this.projects.length > 0) {
this.setCurrentProject(this.projects[0]); // this.setCurrentProject(this.projects[0]);
} // }
} // }
// this.checkProject(); // // this.checkProject();
}); // });
}, // },
checkProject() { // checkProject() {
if (this.currentProject === null) { // if (this.currentProject === null) {
this.$alert(this.$t('test_track.case.no_project'), { // this.$alert(this.$t('test_track.case.no_project'), {
confirmButtonText: this.$t('project.create'), // confirmButtonText: this.$t('project.create'),
callback: action => { // callback: action => {
this.$router.push("/track/project/create"); // this.$router.push("/track/project/create");
} // }
}); // });
} // }
}, // },
changeProject(project) { // changeProject(project) {
this.setCurrentProject(project); // this.setCurrentProject(project);
}, // },
nodeChange(nodeIds, pNodes) { nodeChange(nodeIds, pNodes) {
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
this.selectParentNodes = pNodes; this.selectParentNodes = pNodes;
@ -182,21 +182,21 @@ export default {
this.testCaseReadOnly = true; this.testCaseReadOnly = true;
this.$refs.testCaseEditDialog.open(testCase); this.$refs.testCaseEditDialog.open(testCase);
}, },
getProjectByCaseId(caseId) { // getProjectByCaseId(caseId) {
return this.$get('/test/case/project/' + caseId, async response => { // return this.$get('/test/case/project/' + caseId, async response => {
this.setCurrentProject(response.data); // this.setCurrentProject(response.data);
}); // });
}, // },
refresh() { refresh() {
this.selectNodeIds = []; this.selectNodeIds = [];
this.selectParentNodes = []; this.selectParentNodes = [];
this.selectNode = {}; this.selectNode = {};
this.$refs.testCaseList.initTableData(); this.refreshTable();
this.getNodeTree(); this.getNodeTree();
}, },
openRecentTestCaseEditDialog(caseId) { openRecentTestCaseEditDialog(caseId) {
if (caseId) { if (caseId) {
this.getProjectByCaseId(caseId); // this.getProjectByCaseId(caseId);
this.$get('/test/case/get/' + caseId, response => { this.$get('/test/case/get/' + caseId, response => {
if (response.data) { if (response.data) {
this.$refs.testCaseEditDialog.open(response.data); this.$refs.testCaseEditDialog.open(response.data);
@ -206,31 +206,31 @@ export default {
this.$refs.testCaseEditDialog.open(); this.$refs.testCaseEditDialog.open();
} }
}, },
getProjectById(id) { // getProjectById(id) {
if (id && id != 'all') { // if (id && id != 'all') {
this.$get('/project/get/' + id, response => { // this.$get('/project/get/' + id, response => {
let project = response.data; // let project = response.data;
this.setCurrentProject(project); // this.setCurrentProject(project);
// this.$router.push('/track/case/all'); // // this.$router.push('/track/case/all');
}); // });
} // }
if (id === 'all') { // if (id === 'all') {
this.refresh(); // this.refresh();
} // }
}, // },
setCurrentProject(project) { // setCurrentProject(project) {
if (project) { // if (project) {
this.currentProject = project; // this.currentProject = project;
localStorage.setItem(CURRENT_PROJECT, JSON.stringify(project)); // localStorage.setItem(CURRENT_PROJECT, JSON.stringify(project));
} // }
this.refresh(); // this.refresh();
}, // },
getNodeTree() { getNodeTree() {
if (!hasRoles(ROLE_TEST_USER, ROLE_TEST_MANAGER)) { if (!hasRoles(ROLE_TEST_USER, ROLE_TEST_MANAGER)) {
this.nodeTreeDraggable = false; this.nodeTreeDraggable = false;
} }
if (this.currentProject) { if (this.currentProject) {
this.result = this.$get("/case/node/list/" + this.currentProject.id, response => { this.result = this.$get("/case/node/list/" + this.currentProject, response => {
this.treeNodes = response.data; this.treeNodes = response.data;
}); });
} }

View File

@ -489,7 +489,7 @@ export default {
param.nodePath = item.path; param.nodePath = item.path;
} }
}); });
if (this.currentProject) { if (this.currentProject.id) {
param.projectId = this.currentProject.id; param.projectId = this.currentProject.id;
} }
param.name = param.name.trim(); param.name = param.name.trim();
@ -563,7 +563,7 @@ export default {
}, },
getTestOptions() { getTestOptions() {
this.testOptions = []; this.testOptions = [];
if (this.currentProject && this.form.type != '' && this.form.type != 'functional') { if (this.currentProject.id && this.form.type != '' && this.form.type != 'functional') {
this.result = this.$get('/' + this.form.type + '/list/' + this.currentProject.id, response => { this.result = this.$get('/' + this.form.type + '/list/' + this.currentProject.id, response => {
this.testOptions = response.data; this.testOptions = response.data;
this.testOptions.unshift({id: 'other', name: this.$t('test_track.case.other')}) this.testOptions.unshift({id: 'other', name: this.$t('test_track.case.other')})

View File

@ -302,7 +302,9 @@ export default {
// param.nodeIds = this.selectNodeIds; // param.nodeIds = this.selectNodeIds;
this.condition.nodeIds = this.selectNodeIds; this.condition.nodeIds = this.selectNodeIds;
} }
this.getData(); if (this.currentProject.id) {
this.getData();
}
}, },
getData() { getData() {
if (this.currentProject) { if (this.currentProject) {

View File

@ -135,14 +135,14 @@ export default {
}, },
init() { init() {
let path = this.$route.path; let path = this.$route.path;
if (path.indexOf("/track/case") >= 0 && !!this.$route.params.projectId) { // if (path.indexOf("/track/case") >= 0 && !!this.$route.params.projectId) {
this.testCaseProjectPath = path; // this.testCaseProjectPath = path;
// // //
this.isProjectActivation = false; // this.isProjectActivation = false;
this.reload(); // this.reload();
} else { // } else {
this.isProjectActivation = true; // this.isProjectActivation = true;
} // }
if (path.indexOf("/track/plan/view") >= 0) { if (path.indexOf("/track/plan/view") >= 0) {
this.testPlanViewPath = path; this.testPlanViewPath = path;
this.reload(); this.reload();
@ -151,6 +151,10 @@ export default {
this.testCaseEditPath = path; this.testCaseEditPath = path;
this.reload(); this.reload();
} }
if (path.indexOf("/track/review/view") >= 0) {
this.testCaseReviewEditPath = path;
this.reload();
}
}, },
registerEvents() { registerEvents() {
TrackEvent.$on(LIST_CHANGE, () => { TrackEvent.$on(LIST_CHANGE, () => {

View File

@ -1,4 +1,3 @@
import MsProject from "@/business/components/settings/project/MsProject";
const TestTrack = () => import('@/business/components/track/TestTrack') const TestTrack = () => import('@/business/components/track/TestTrack')
const TrackHome = () => import('@/business/components/track/home/TrackHome') const TrackHome = () => import('@/business/components/track/home/TrackHome')

@ -1 +1 @@
Subproject commit 8a972a198775b3783ed6e4cef27197e53d1ebdc8 Subproject commit a22a3005d9bd254793fcf634d72539cbdf31be3a

View File

@ -39,10 +39,22 @@ const Switch = {
} }
} }
const IsReadOnly = {
state: {
flag: true
},
mutations: {
setFlag(state, value) {
state.flag = value;
}
}
}
export default new Vuex.Store({ export default new Vuex.Store({
modules: { modules: {
api: API, api: API,
common: Common, common: Common,
switch: Switch, switch: Switch,
isReadOnly: IsReadOnly,
} }
}) })