fix: (测试计划) 修复 测试计划-修改状态后时间显示有误 (#1291)

This commit is contained in:
Coooder-X 2021-02-01 14:26:51 +08:00 committed by GitHub
parent 63d4a7ad81
commit 7aa5a6fc5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 10 deletions

View File

@ -168,20 +168,35 @@ public class TestPlanService {
public int editTestPlan(TestPlanDTO testPlan) {
editTestPlanProject(testPlan);
testPlan.setUpdateTime(System.currentTimeMillis());
checkTestPlanExist(testPlan);
//进行中状态写入实际开始时间
if (TestPlanStatus.Underway.name().equals(testPlan.getStatus())) {
testPlan.setActualStartTime(System.currentTimeMillis());
} else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus())) {
//已完成写入实际完成时间
testPlan.setActualEndTime(System.currentTimeMillis());
TestPlan res = testPlanMapper.selectByPrimaryKey(testPlan.getId()); // 先查一次库
if (!res.getStatus().equals(testPlan.getStatus())) { // 若有改变才更新时间
res.setUpdateTime(System.currentTimeMillis());
if (TestPlanStatus.Underway.name().equals(testPlan.getStatus())) {
if (res.getStatus().equals(TestPlanStatus.Prepare.name())) {
res.setActualStartTime(System.currentTimeMillis());
} // 未开始->进行中写入实际开始时间
else if (res.getStatus().equals(TestPlanStatus.Completed.name())) {
res.setActualEndTime(null);
} // 已完成->进行中结束时间置空
}
else if (!res.getStatus().equals(TestPlanStatus.Prepare.name()) &&
testPlan.getStatus().equals(TestPlanStatus.Prepare.name())) {
res.setActualStartTime(null);
res.setActualEndTime(null);
} // 非未开始->未开始时间都置空
else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus()) &&
!TestPlanStatus.Completed.name().equals(res.getStatus())) {
//已完成写入实际完成时间
res.setActualEndTime(System.currentTimeMillis());
}
res.setStatus(testPlan.getStatus());
}
List<String> userIds = new ArrayList<>();
userIds.add(testPlan.getPrincipal());
AddTestPlanRequest testPlans = new AddTestPlanRequest();
int i = testPlanMapper.updateByPrimaryKeySelective(testPlan);
int i = testPlanMapper.updateByPrimaryKey(res); // 更新
if (!StringUtils.isBlank(testPlan.getStatus())) {
BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId()));
String context = getTestPlanContext(testPlans, NoticeConstants.Event.UPDATE);

View File

@ -257,7 +257,17 @@ export default {
statusChange(param) {
this.$post('/test/plan/edit', param, () => {
for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i].id == param.id) {
if (this.tableData[i].id == param.id) { //
if (this.tableData[i].status !== "Completed" && param.status === "Completed") {
this.tableData[i].actualEndTime = new Date();
} // ->=null
else if (this.tableData[i].status !== "Underway" && param.status === "Underway") {
this.tableData[i].actualStartTime = new Date();
this.tableData[i].actualEndTime = "";
} // ->=null
else if (this.tableData[i].status !== "Prepare" && param.status === "Prepare") {
this.tableData[i].actualStartTime = this.tableData[i].actualEndTime = "";
} // ->=null
this.tableData[i].status = param.status;
break;
}