Merge remote-tracking branch 'origin/project' into project
This commit is contained in:
commit
3d2ac3efc0
@ -67,12 +67,18 @@ public class PmController {
|
||||
@PostMapping("/items/{id}/children") public Map<String,Object> child(@PathVariable long id,@RequestBody JsonNode body) { return ok(service.createChild(id,decode(body,ChildInput.class))); }
|
||||
/** 子任务列表在服务层复验项目成员权限与实时状态。 */
|
||||
@GetMapping("/items/{id}/children") public Map<String,Object> children(@PathVariable long id) { return ok(service.children(id)); }
|
||||
/** 普通编辑拒绝状态注入,省略 stageId 时保留归属;阶段迁移须走管理者专用入口,显式 null 也不能绕过。 */
|
||||
/** 普通编辑由阶段负责人操作,改期须另验排期身份;省略 stageId 保留归属,迁移和状态走独立入口。 */
|
||||
@PatchMapping("/items/{id}") public Map<String,Object> edit(@PathVariable long id,@RequestBody JsonNode body) {
|
||||
ItemInput input=decode(body,ItemInput.class);
|
||||
if(!body.has("stageId")) input=new ItemInput(input.type(),input.title(),input.description(),input.assigneeId(),input.priority(),input.plannedStartAt(),input.plannedEndAt(),input.version(),nullableStage(service.detail(id).get("stageId")),input.collaboratorIds(),input.predecessorWorkItemIds(),input.sendEmail());
|
||||
service.edit(id,input); return ok(null);
|
||||
}
|
||||
/** 未分配项由阶段负责人或迭代创建者补齐;严格请求仅允许负责人和版本,不接受正文或状态注入。 */
|
||||
@PatchMapping("/items/{id}/assignee")
|
||||
public Map<String,Object> assignAssignee(@PathVariable long id,@RequestBody JsonNode body) {
|
||||
service.assignAssignee(id,decode(body,com.ruoyi.project.manage.dto.AssigneeInput.class));
|
||||
return ok(null);
|
||||
}
|
||||
/** 带版本软删除,并保护已开始后续条件。 */
|
||||
@DeleteMapping("/items/{id}") public Map<String,Object> delete(@PathVariable long id,@RequestBody JsonNode body) { service.delete(id,decode(body,VersionInput.class)); return ok(null); }
|
||||
/** 返回实际可开始状态,不将前端禁用按钮作为安全边界。 */
|
||||
@ -100,11 +106,11 @@ public class PmController {
|
||||
public Map<String,Object> iterationBatch(@PathVariable long id,@PathVariable long iterationId,@RequestBody JsonNode body) { service.scheduleBatch(id,iterationId,decode(body,BatchInput.class)); return ok(null); }
|
||||
/** 前置工作项影响分析只返回可见项目的直接后续。 */
|
||||
@GetMapping("/items/{id}/successors") public Map<String,Object> successors(@PathVariable long id) { return ok(service.successors(id)); }
|
||||
/** 工作项评论受同一数据权限保护,并原子记录历史。 */
|
||||
/** 工作项负责人或协作人可评论,终态与已完成阶段仍只读,并原子记录历史。 */
|
||||
@PostMapping("/items/{id}/comments") public Map<String,Object> comment(@PathVariable long id,@RequestBody JsonNode body) { service.comment(id,decode(body,CommentInput.class)); return ok(null); }
|
||||
/** 在读取字节前按统一的 50MB 上限校验,文件存入 MinIO 私有对象,不产生公开上传 URL。 */
|
||||
/** 负责人或协作人上传仍受冻结保护;读取前校验 50MB 上限,存入 MinIO 私有对象且不产生公开 URL。 */
|
||||
@PostMapping("/items/{id}/attachments") public Map<String,Object> attach(@PathVariable long id,@RequestParam("file") MultipartFile file) throws java.io.IOException { if(file.getSize()>PmAttachmentStorage.MAX_BYTES) throw PmException.bad("附件不能超过 "+PmAttachmentStorage.MAX_SIZE_LABEL); return ok(service.attach(id,file.getOriginalFilename(),file.getContentType(),file.getBytes())); }
|
||||
/** 绑定工作项与附件 ID,负责人/创建者权限及软删除事务由服务统一处理,不开放存储对象删除入口。 */
|
||||
/** 绑定工作项与附件 ID,当前负责人身份及软删除事务由服务统一校验,不开放存储对象删除入口。 */
|
||||
@DeleteMapping("/items/{id}/attachments/{attachmentId}")
|
||||
public Map<String,Object> removeAttachment(@PathVariable long id,@PathVariable long attachmentId) { service.removeAttachment(id,attachmentId); return ok(null); }
|
||||
/** 下载每次重新鉴权,强制附件方式并禁止内容嗅探,避免 HTML 等主动内容执行。 */
|
||||
|
||||
@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RestController
|
||||
@RequestMapping("/project/manage")
|
||||
public class PmStageController {
|
||||
/** 结构预览不写成功记录;接口仍复验项目管理者和迭代状态。 */
|
||||
/** 结构预览不写成功记录;服务在项目锁内复验迭代创建者及生命周期。 */
|
||||
@PostMapping("/projects/{id}/iterations/{iterationId}/stage-structure/preview")
|
||||
public Map<String,Object> structurePreview(@PathVariable long id,@PathVariable long iterationId,@RequestBody JsonNode body) { return ok(service.structure(id,iterationId,decode(body,com.ruoyi.project.manage.dto.StageStructureInput.class),false)); }
|
||||
/** 提交显式最终结构并复算预览图版本,不开放跨层自动迁移。 */
|
||||
@ -36,10 +36,10 @@ public class PmStageController {
|
||||
/** 在选定迭代中新建首版阶段,不能引用其他迭代执行事实。 */
|
||||
@PostMapping("/projects/{id}/iterations/{iterationId}/stages")
|
||||
public Map<String,Object> iterationCreate(@PathVariable long id,@PathVariable long iterationId,@RequestBody JsonNode body) { return ok(service.createStage(id,iterationId,decode(body,StageInput.class))); }
|
||||
/** 阶段版本与所属迭代状态均在统一项目锁内检查。 */
|
||||
/** 阶段元数据由迭代创建者或本阶段负责人编辑;身份、版本和迭代状态均在项目锁内复查。 */
|
||||
@PatchMapping("/projects/{id}/iterations/{iterationId}/stages/{stageId}")
|
||||
public Map<String,Object> iterationEdit(@PathVariable long id,@PathVariable long iterationId,@PathVariable long stageId,@RequestBody JsonNode body) { service.editStage(id,iterationId,stageId,decode(body,StageInput.class)); return ok(null); }
|
||||
/** 快捷改名严格只接受名称和版本;身份、归属、生命周期与冻结状态仍在服务事务中复查。 */
|
||||
/** 快捷改名仅接受名称和版本,服务锁内按迭代创建者或当前阶段负责人复查身份及冻结状态。 */
|
||||
@PatchMapping("/projects/{id}/iterations/{iterationId}/stages/{stageId}/name")
|
||||
public Map<String,Object> iterationRename(@PathVariable long id,@PathVariable long iterationId,@PathVariable long stageId,@RequestBody JsonNode body) { service.renameStage(id,iterationId,stageId,decode(body,StageNameInput.class)); return ok(null); }
|
||||
/** 仅当前迭代的空阶段可软删除,保留原版本记录。 */
|
||||
@ -51,17 +51,17 @@ public class PmStageController {
|
||||
/** 按边版本断开当前迭代执行关系,不改变其他迭代。 */
|
||||
@DeleteMapping("/projects/{id}/iterations/{iterationId}/stage-edges/{edgeId}")
|
||||
public Map<String,Object> iterationDeleteEdge(@PathVariable long id,@PathVariable long iterationId,@PathVariable long edgeId,@RequestBody JsonNode body) { service.deleteEdge(id,iterationId,edgeId,decode(body,VersionInput.class)); return ok(null); }
|
||||
/** 新建组织阶段,调用者不能指定创建人或删除标记。 */
|
||||
/** 兼容旧项目级路由;缺少明确迭代时返回范围缺失错误,不隐式创建阶段。 */
|
||||
@PostMapping("/projects/{id}/stages") public Map<String,Object> create(@PathVariable long id,@RequestBody JsonNode body) { return ok(service.createStage(id,decode(body,StageInput.class))); }
|
||||
/** 阶段更新携带自身版本,不调整工作项开始或排期规则。 */
|
||||
/** 兼容旧项目级路由;缺少明确迭代时拒绝编辑阶段。 */
|
||||
@PatchMapping("/projects/{id}/stages/{stageId}") public Map<String,Object> edit(@PathVariable long id,@PathVariable long stageId,@RequestBody JsonNode body) { service.editStage(id,stageId,decode(body,StageInput.class)); return ok(null); }
|
||||
/** 非空阶段拒绝删除;空阶段采用软删除保留历史。 */
|
||||
/** 兼容旧项目级路由;缺少明确迭代时拒绝删除阶段。 */
|
||||
@DeleteMapping("/projects/{id}/stages/{stageId}") public Map<String,Object> delete(@PathVariable long id,@PathVariable long stageId,@RequestBody JsonNode body) { service.deleteStage(id,stageId,decode(body,VersionInput.class)); return ok(null); }
|
||||
/** 连线仅由项目管理者维护;执行顺序和环检测在持锁服务中统一处理。 */
|
||||
/** 兼容旧项目级路由;不根据项目管理身份隐式选择迭代建立连线。 */
|
||||
@PostMapping("/projects/{id}/stage-edges") public Map<String,Object> createEdge(@PathVariable long id,@RequestBody JsonNode body) { return ok(service.createEdge(id,decode(body,StageEdgeInput.class))); }
|
||||
/** 使用边版本删除连线,防止过期画布覆盖其他管理者的修改。 */
|
||||
/** 兼容旧项目级路由;缺少明确迭代时拒绝删除连线。 */
|
||||
@DeleteMapping("/projects/{id}/stage-edges/{edgeId}") public Map<String,Object> deleteEdge(@PathVariable long id,@PathVariable long edgeId,@RequestBody JsonNode body) { service.deleteEdge(id,edgeId,decode(body,VersionInput.class)); return ok(null); }
|
||||
/** 明确移动到阶段的业务入口,与普通画布位置拖动分离。 */
|
||||
/** 阶段负责人迁移或迭代创建者补齐缺失归属共用严格入口;只接受阶段与版本,与画布拖动分离。 */
|
||||
@PatchMapping("/items/{id}/stage") public Map<String,Object> assign(@PathVariable long id,@RequestBody JsonNode body) { service.assign(id,decode(body,StageAssignment.class)); return ok(null); }
|
||||
/** 沿用若依响应包,返回真实事务结果。 */
|
||||
private static Map<String,Object> ok(Object value) { return map("code",200,"msg","操作成功","data",value); }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.ruoyi.project.manage.domain;
|
||||
|
||||
/** 工作项协作分工的只读身份摘要,不授予额外权限,也不暴露用户资料。 */
|
||||
/** 工作项当前协作身份摘要,供评论/上传资格判断;不授予元数据维护、执行或排期权,也不暴露用户资料。 */
|
||||
public record Collaborator(long userId,String name) { }
|
||||
|
||||
@ -2,13 +2,15 @@ package com.ruoyi.project.manage.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** 事务内不可变工作项快照;时间、生命周期和父阶段变更通过重建快照校验。 */
|
||||
/** 事务内不可变工作项快照;所有候选变换保留真实创建人,时间、生命周期和父阶段通过重建快照校验。 */
|
||||
public record Item(long id, long projectId, String type, String title, String description, Long assigneeId,
|
||||
String priority, String status, Long start, Long end, Long actualStart, Long actualEnd,
|
||||
int version, boolean deleted, Long stageId, Long parentTaskId,
|
||||
Long stageRevisionId,Long originWorkItemId,Long scheduleReviewReworkId,Long referenceStart,Long referenceEnd,List<Collaborator> collaborators) {
|
||||
Long stageRevisionId,Long originWorkItemId,Long scheduleReviewReworkId,Long referenceStart,Long referenceEnd,List<Collaborator> collaborators,Long createdBy) {
|
||||
/** 协作人快照保持不可变,候选图复制不能修改原图分工。 */
|
||||
public Item {collaborators=collaborators==null?List.of():List.copyOf(collaborators);}
|
||||
/** 旧内部快照没有创建人时不推测为负责人;正式加载从数据库不可变 created_by 补齐。 */
|
||||
public Item(long id,long projectId,String type,String title,String description,Long assigneeId,String priority,String status,Long start,Long end,Long actualStart,Long actualEnd,int version,boolean deleted,Long stageId,Long parentTaskId,Long stageRevisionId,Long originWorkItemId,Long scheduleReviewReworkId,Long referenceStart,Long referenceEnd,List<Collaborator> collaborators){this(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,scheduleReviewReworkId,referenceStart,referenceEnd,collaborators,null);}
|
||||
/** 原有构造省略分工;数据库图加载通过withCollaborators批量补齐。 */
|
||||
public Item(long id,long projectId,String type,String title,String description,Long assigneeId,String priority,String status,Long start,Long end,Long actualStart,Long actualEnd,int version,boolean deleted,Long stageId,Long parentTaskId,Long stageRevisionId,Long originWorkItemId,Long scheduleReviewReworkId,Long referenceStart,Long referenceEnd){this(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,scheduleReviewReworkId,referenceStart,referenceEnd,List.of());}
|
||||
/** 既有调用不带参考日期;正式加载由 Mapper 显式提供,参考日期永不充当正常预计时间。 */
|
||||
@ -20,15 +22,21 @@ public record Item(long id, long projectId, String type, String title, String de
|
||||
/** 保持既有内部调用兼容,未指定阶段的旧工作项仍归入未分配组。 */
|
||||
public Item(long id,long projectId,String type,String title,String description,Long assigneeId,String priority,String status,Long start,Long end,Long actualStart,Long actualEnd,int version,boolean deleted) { this(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,null); }
|
||||
/** 用请求最终时间替换快照,供整批校验;不修改数据库或生命周期。 */
|
||||
public Item scheduled(Long start, Long end) { return new Item(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,scheduleReviewReworkId,referenceStart,referenceEnd,collaborators); }
|
||||
public Item scheduled(Long start, Long end) { return new Item(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,scheduleReviewReworkId,referenceStart,referenceEnd,collaborators,createdBy); }
|
||||
/** 用目标状态重建快照,供回退影响检查;实际时间在正式写入时决定。 */
|
||||
public Item transitioned(String status, boolean deleted) { return new Item(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,scheduleReviewReworkId,referenceStart,referenceEnd,collaborators); }
|
||||
public Item transitioned(String status, boolean deleted) { return new Item(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,scheduleReviewReworkId,referenceStart,referenceEnd,collaborators,createdBy); }
|
||||
/** 仅事务候选图中替换阶段归属;父子同步由服务在同一项目锁下完成。 */
|
||||
public Item inStage(Long stageId) { return new Item(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,scheduleReviewReworkId,referenceStart,referenceEnd,collaborators); }
|
||||
public Item inStage(Long stageId) { return new Item(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,scheduleReviewReworkId,referenceStart,referenceEnd,collaborators,createdBy); }
|
||||
/** 专用排期入口的候选结果,全部校验通过后才可清除复核及参考日期。 */
|
||||
public Item confirmedSchedule(Long start,Long end) { return new Item(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,null,null,null,collaborators); }
|
||||
public Item confirmedSchedule(Long start,Long end) { return new Item(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,null,null,null,collaborators,createdBy); }
|
||||
/** 转存原计划并保留执行事实,用于回退影响闭包的最终态预检。 */
|
||||
public Item pending(long reworkId) { return new Item(id,projectId,type,title,description,assigneeId,priority,status,null,null,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,reworkId,start!=null?start:referenceStart,end!=null?end:referenceEnd,collaborators); }
|
||||
public Item pending(long reworkId) { return new Item(id,projectId,type,title,description,assigneeId,priority,status,null,null,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,reworkId,start!=null?start:referenceStart,end!=null?end:referenceEnd,collaborators,createdBy); }
|
||||
/** 用单次批量查询的分工结果补齐快照,不改变状态、版本或排期。 */
|
||||
public Item withCollaborators(List<Collaborator> values){return new Item(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,scheduleReviewReworkId,referenceStart,referenceEnd,values);}
|
||||
public Item withCollaborators(List<Collaborator> values){return new Item(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,scheduleReviewReworkId,referenceStart,referenceEnd,values,createdBy);}
|
||||
/**
|
||||
* 从数据库行补齐创建人,候选图的排期、转态、分工及移动必须保留此不可变身份。
|
||||
* @param creatorId 本工作项自身的 created_by,不使用回退来源工作项的创建人
|
||||
* @return 仅补齐身份的新快照;创建人未知时不授予创建者排期资格
|
||||
*/
|
||||
public Item withCreator(Long creatorId){return new Item(id,projectId,type,title,description,assigneeId,priority,status,start,end,actualStart,actualEnd,version,deleted,stageId,parentTaskId,stageRevisionId,originWorkItemId,scheduleReviewReworkId,referenceStart,referenceEnd,collaborators,creatorId);}
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
package com.ruoyi.project.manage.dto;
|
||||
|
||||
/** 未分配工作项补分配白名单,不能借迭代创建者身份同时修改正文、排期或状态。 */
|
||||
public record AssigneeInput(Long assigneeId,Integer version) { }
|
||||
@ -94,6 +94,20 @@ public final class PmStageScheduleRules {
|
||||
||r.plannedEnd()!=null&&(item.start()!=null&&item.start()>r.plannedEnd()||item.end()!=null&&item.end()>r.plannedEnd());
|
||||
}
|
||||
|
||||
/**
|
||||
* 为新建或主动改期验证阶段计划,不能用未排期或待复核阶段承接新的工作项时间。
|
||||
* @param graph 事务内最终候选图,允许同批先确认阶段再排工作项
|
||||
* @param item 本次新建或主动改期的工作项;两个端点均为空表示尚未排期或主动清除
|
||||
* 注意:不对未修改的旧工作项强制补排,避免只编辑正文时意外改写历史计划;父子及前置另由完整图校验。
|
||||
*/
|
||||
public static void requireWorkItemPlan(Graph graph,Item item) {
|
||||
if(item.start()==null&&item.end()==null) return;
|
||||
StageRevision stage=item.stageId()==null?null:graph.stageRevisions().get(item.stageId());
|
||||
if(stage==null||stage.plannedStart()==null||stage.plannedEnd()==null||stage.scheduleReviewReworkId()!=null)
|
||||
throw PmException.conflict("STAGE_SCHEDULE_REQUIRED","请先为所属阶段确认完整的预计开始和结束,再设置工作项排期");
|
||||
if(outside(stage,item)) throw PmException.conflict("ITEM_OUTSIDE_STAGE","工作项预计时间必须在所属阶段预计范围内");
|
||||
}
|
||||
|
||||
/** 整张图只拒绝实际冲突及已有阶段计划的缺失前置;空计划仍允许按实际条件执行。 */
|
||||
public static void validate(Graph graph) {
|
||||
List<Map<String,Object>> conflicts=new ArrayList<>();
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
package com.ruoyi.project.manage.rule;
|
||||
|
||||
import com.ruoyi.project.manage.domain.Graph;
|
||||
import com.ruoyi.project.manage.domain.Item;
|
||||
import java.util.Objects;
|
||||
|
||||
/** 对象身份纯规则;成员、生命周期及冻结由服务在项目锁内先检查,不能以本类结果绕过。 */
|
||||
public final class PmWorkItemPermissions {
|
||||
/** 不保存或缓存权限,调用方必须每次传入锁内最新快照。 */
|
||||
private PmWorkItemPermissions() { }
|
||||
|
||||
/**
|
||||
* 判断当前阶段负责人,容器父级或项目管理身份均不自动继承子阶段维护权。
|
||||
* @param graph 当前完整迭代图,阶段身份由数据库加载
|
||||
* @param stageId 精确所属阶段;未分配或失效阶段默认拒绝
|
||||
* @param actor 当前已鉴权成员
|
||||
* @return 当前成员是否是该阶段当前负责人
|
||||
*/
|
||||
public static boolean ownsStage(Graph graph,Long stageId,long actor) {
|
||||
var stage=stageId==null?null:graph.hierarchy().get(stageId);
|
||||
return stage!=null&&Objects.equals(stage.ownerId(),actor);
|
||||
}
|
||||
|
||||
/** 只有工作项精确所属阶段负责人可维护元数据,不能借工作项执行或创建身份获得维护权。 */
|
||||
public static boolean canMaintain(Graph graph,Item item,long actor) {
|
||||
return ownsStage(graph,item.stageId(),actor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 排期与元数据维护独立,当前负责人或本工作项创建者可排期。
|
||||
* @param item 含数据库不可变创建人的当前快照,未知创建人不能推测为负责人
|
||||
* @param actor 当前已鉴权成员
|
||||
* @return 是否具备排期身份;最终时间仍必须通过阶段、父子及前置范围校验
|
||||
*/
|
||||
public static boolean canSchedule(Item item,long actor) {
|
||||
return Objects.equals(item.assigneeId(),actor)||Objects.equals(item.createdBy(),actor);
|
||||
}
|
||||
|
||||
/** 工作项负责人及当前协作人可讨论或上传,阶段负责人、创建者、经理身份本身不额外授予协作资格。 */
|
||||
public static boolean canCollaborate(Item item,long actor) {
|
||||
return Objects.equals(item.assigneeId(),actor)||item.collaborators().stream().anyMatch(member->member.userId()==actor);
|
||||
}
|
||||
}
|
||||
@ -35,4 +35,28 @@ public class PmIterationAccess {
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在调用方已取得项目锁后校验迭代配置资格,不将项目或系统管理身份视为创建者。
|
||||
* @param projectId 已锁定的协作项目;创建者仍须是该项目有效成员
|
||||
* @param iterationId 显式迭代范围,创建者以数据库不可变 created_by 为准
|
||||
* @param action 配置动作所需生命周期规则;不替代阶段执行、交付、审批或回退职责
|
||||
* @return 本事务内重新读取的迭代行;非创建者或范围无效返回403,只读状态沿用原冲突
|
||||
*/
|
||||
public Map<String,Object> requireCreator(long projectId,long iterationId,String action) {
|
||||
Map<String,Object> row=require(projectId,iterationId,"read");
|
||||
if(!Long.valueOf(access.actor()).equals(nullable(row,"created_by"))) throw PmAccess.denied();
|
||||
PmIterationRules.requireAction(text(row,"status"),nullable(row,"archived_at")!=null,action);
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为锁内摘要计算创建者身份,状态是否可写由调用方结合当前迭代快照判断。
|
||||
* @param projectId 已鉴权且持项目锁的协作项目
|
||||
* @param iterationId 当前迭代;不对外暴露其他项目的创建者信息
|
||||
* @return 当前有效成员是否为该迭代真实创建者,不隐式授予其他写入权限
|
||||
*/
|
||||
public boolean isCreator(long projectId,long iterationId) {
|
||||
return Long.valueOf(access.actor()).equals(nullable(require(projectId,iterationId,"read"),"created_by"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public interface IPmService {
|
||||
Map<String,Object> detail(long id);
|
||||
|
||||
/**
|
||||
* 原子创建待开始工作项、协作分工和可选前置,校验当前迭代的有效阶段、最终排期及混合执行图。
|
||||
* 所属阶段负责人原子创建已分配负责人的待开始工作项、分工和可选前置,校验有效阶段与阶段内计划。
|
||||
*
|
||||
* @param projectId 当前协作内部项目 ID(非原项目 ID);服务内重新检查成员权限
|
||||
* @param input 仅包含接口允许字段的请求对象;身份、版本及关联由对应业务入口复验
|
||||
@ -90,20 +90,28 @@ public interface IPmService {
|
||||
List<Map<String,Object>> children(long id);
|
||||
|
||||
/**
|
||||
* 普通编辑校验父子时间、阶段继承及协作成员,父阶段变化原子同步子阶段;父关系及前置须经专用入口修改。
|
||||
* 阶段负责人编辑字段及分工,主动改期还须工作项负责人或创建者;归属、父关系及前置须经专用入口修改。
|
||||
*
|
||||
* @param id 路径中的目标对象 ID;服务按当前身份校验维护或查看权限
|
||||
* @param input 仅包含接口允许字段的请求对象;身份、版本及关联由对应业务入口复验
|
||||
* <p>副作用:更新普通工作项字段、时间与阶段,父子阶段同步及历史原子提交。</p>
|
||||
* <p>副作用:普通字段、分工及历史原子提交;未主动改期保留旧时间精度,阶段转交后原阶段负责人立即失权。</p>
|
||||
*/
|
||||
void edit(long id,ItemInput input);
|
||||
|
||||
/**
|
||||
* 所有阶段调整共用父子继承校验,版本、归属和历史在同一项目锁事务中提交。
|
||||
* 所属阶段负责人或迭代创建者可为尚未分配的当前工作项补充有效成员负责人,其他字段保持不变。
|
||||
* @param id 当前有效、未冻结工作项;已分配、历史或软删除项不得使用此例外入口
|
||||
* @param input 仅目标负责人及当前工作项版本,缺失或过期则拒绝
|
||||
* 注意:创建者修复身份不开放普通编辑,已有负责人不能覆盖;审计与站内通知在同一项目锁事务保存。
|
||||
*/
|
||||
void assignAssignee(long id,com.ruoyi.project.manage.dto.AssigneeInput input);
|
||||
|
||||
/**
|
||||
* 普通迁移须同时负责原阶段与目标阶段;迭代创建者可通过同一严格入口补齐旧项缺失阶段。
|
||||
* @param id 当前有效工作项 ID;子任务不能脱离父阶段
|
||||
* @param input 目标同项目阶段及工作项版本,null 阶段代表未分配
|
||||
* 注意:父移动同步有效子任务,并推进各子版本和审计;相同阶段不产生重复更新。
|
||||
* <p>副作用:更新业务归属及子阶段,保存成功历史和待发送事件。</p>
|
||||
* @param input 同迭代有效工作阶段及工作项版本,不能清空归属;普通迁移仍须负责目标阶段
|
||||
* 注意:旧项修复只允许待开始根项及未归属、待开始的子任务,不能覆盖已有阶段或其他字段。
|
||||
* <p>副作用:原子更新父子工作项的阶段归属、图版本、成功历史和待发送事件。</p>
|
||||
*/
|
||||
void assignStage(long id,StageAssignment input);
|
||||
|
||||
@ -133,7 +141,7 @@ public interface IPmService {
|
||||
void transition(long id,TransitionInput input);
|
||||
|
||||
/**
|
||||
* 软删除工作项前检查已开始后续的工作项条件;原协作分工、历史记录及停用流程数据均保留。
|
||||
* 仅所属阶段负责人软删除工作项,检查已开始后续的条件;原协作分工、历史记录及停用流程数据均保留。
|
||||
*
|
||||
* @param id 路径中的目标对象 ID;服务按当前身份校验维护或查看权限
|
||||
* @param input 仅包含接口允许字段的请求对象;身份、版本及关联由对应业务入口复验
|
||||
@ -150,7 +158,7 @@ public interface IPmService {
|
||||
List<Map<String,Object>> dependencies(long id);
|
||||
|
||||
/**
|
||||
* 在项目锁下模拟依赖最终图,先检查循环与排期再保存;只有待开始工作项可以编辑。
|
||||
* 阶段负责人在项目锁下模拟依赖最终图,先检查循环与排期再保存;只有待开始工作项可以编辑。
|
||||
* @param id 后续工作项实例 ID
|
||||
* @param dependencyId 编辑或删除的依赖 ID;新增时为空
|
||||
* @param input 前置工作项引用及后续工作项/依赖版本;删除时仍必须提供两个版本
|
||||
@ -195,7 +203,7 @@ public interface IPmService {
|
||||
void comment(long id,CommentInput input);
|
||||
|
||||
/**
|
||||
* 附件存入 MinIO 私有对象,数据库仅保存元数据;限制为 50MB,业务回滚时补偿新对象。
|
||||
* 工作项负责人或协作人可上传附件至 MinIO 私有对象;限制为 50MB,业务回滚时补偿新对象。
|
||||
*
|
||||
* @param id 路径中的目标对象 ID;服务按当前身份校验维护或查看权限
|
||||
* @param name 附件原始文件名,服务会校验和净化
|
||||
@ -206,7 +214,7 @@ public interface IPmService {
|
||||
long attach(long id,String name,String mediaType,byte[] content);
|
||||
|
||||
/**
|
||||
* 仅工作项负责人或创建者可以软删除附件;项目写权限和当前版本可写限制仍然生效。
|
||||
* 仅当前工作项负责人可以软删除附件;项目写权限和当前版本可写限制仍然生效。
|
||||
* @param itemId 附件所属工作项,用于防止使用其它工作项的身份删除附件
|
||||
* @param attachmentId 服务端保存的附件 ID,不接受客户端指定存储对象路径
|
||||
* <p>删除标记、删除人、删除时间及操作历史/outbox 同事务保存;保留 MinIO 原文件和历史二进制内容。</p>
|
||||
|
||||
@ -11,7 +11,7 @@ import java.util.*;
|
||||
|
||||
/** 显式阶段执行图与展示布局契约;不恢复已停用的流程节点依赖。 */
|
||||
public interface IPmStageService {
|
||||
/** 项目管理者预览或提交明确阶段层级及全部连线最终态,预览不产生成功历史。 */
|
||||
/** 迭代创建者预览或提交明确阶段层级及全部连线最终态,预览不产生成功历史。 */
|
||||
Map<String,Object> structure(long projectId,long iterationId,com.ruoyi.project.manage.dto.StageStructureInput input,boolean commit);
|
||||
/**
|
||||
* 在项目锁内读取单迭代阶段、显式阶段边和工作项计数;画布不返回完整工作项。
|
||||
@ -25,7 +25,7 @@ public interface IPmStageService {
|
||||
default Map<String,Object> flowView(long projectId) { throw requiredIteration(); }
|
||||
|
||||
/**
|
||||
* 阶段经理维护入口;负责人仅代表业务责任,名称和顺序不隐式产生执行依赖。
|
||||
* 迭代创建者配置入口;阶段负责人仅代表业务责任,名称和顺序不隐式产生执行依赖。
|
||||
*
|
||||
* @param projectId 当前协作内部项目 ID(非原项目 ID);服务内重新检查成员权限
|
||||
* @param input 仅包含接口允许字段的请求对象;身份、版本及关联由对应业务入口复验
|
||||
@ -36,7 +36,7 @@ public interface IPmStageService {
|
||||
default long createStage(long projectId,StageInput input) { throw requiredIteration(); }
|
||||
|
||||
/**
|
||||
* 在统一项目锁下版本更新阶段元数据,不改变工作项状态、预计时间或有效依赖。
|
||||
* 迭代创建者或本阶段当前负责人在统一项目锁下更新元数据,不改变工作项状态、预计时间或有效依赖。
|
||||
*
|
||||
* @param projectId 当前协作内部项目 ID(非原项目 ID);服务内重新检查成员权限
|
||||
* @param id 路径中的目标对象 ID;服务按当前身份校验维护或查看权限
|
||||
@ -44,7 +44,7 @@ public interface IPmStageService {
|
||||
* <p>副作用:按阶段版本修改组织元数据并原子保存历史/outbox。</p>
|
||||
*/
|
||||
void editStage(long projectId,long iterationId,long id,StageInput input);
|
||||
/** 仅按版本更新当前有效阶段名称;沿用经理权限、迭代只读及审批冻结门禁,不覆盖交付和历史快照。 */
|
||||
/** 迭代创建者或本阶段当前负责人按版本改名;保留只读及审批冻结门禁,不覆盖交付和历史快照。 */
|
||||
void renameStage(long projectId,long iterationId,long id,StageNameInput input);
|
||||
/** 旧编辑入口缺少迭代边界时拒绝执行。 */
|
||||
default void editStage(long projectId,long id,StageInput input) { throw requiredIteration(); }
|
||||
|
||||
@ -262,6 +262,7 @@ public class PmReworkServiceImpl implements IPmReworkService {
|
||||
/**
|
||||
* 在项目锁内复验当前阶段与严格上游目标,再计算路径、已执行后继和任务依赖的影响闭包。
|
||||
* 预览和提交都调用此方法;完成、开始或另一回退提交后,旧页面不能继续沿用来源资格。
|
||||
* 自动复制保留原回退职责;人工新增另按被新增阶段的负责人复验,不能借回退管理权跨阶段新建。
|
||||
* @param projectId 已完成管理鉴权并锁定的项目
|
||||
* @param iterationId 回退操作唯一的迭代范围
|
||||
* @param input 来源、目标与补录草稿,不能通过参数指定当前阶段
|
||||
@ -309,7 +310,10 @@ public class PmReworkServiceImpl implements IPmReworkService {
|
||||
blockers.add(map("code","REWORK_DEPENDENCY_CONFLICT","dependencyId",dependency.id(),"message","前置工作项已取消或不属于当前版本,需要先处理依赖"));
|
||||
}
|
||||
for(Long id:additions(input).keySet()) if(!affected.contains(id)||PmStageHierarchyRules.info(graph,id).group()) blockers.add(map("code","ADDITION_STAGE_INVALID","stageId",id,"message","补录工作项只能归入受影响的工作阶段,阶段组不能直接放工作项"));
|
||||
for(var entry:additions(input).entrySet()) for(ReworkItemInput added:entry.getValue()) validateAddition(projectId,added);
|
||||
for(var entry:additions(input).entrySet()) {
|
||||
if(!entry.getValue().isEmpty()&&!com.ruoyi.project.manage.rule.PmWorkItemPermissions.ownsStage(graph,entry.getKey(),access.actor())) throw PmAccess.denied();
|
||||
for(ReworkItemInput added:entry.getValue()) validateAddition(projectId,added);
|
||||
}
|
||||
for(var entry:additions(input).entrySet())if("PURCHASE".equals(PmStageHierarchyRules.info(graph,entry.getKey()).nodeType())&&!entry.getValue().isEmpty())blockers.add(map("code","PURCHASE_WORK_ITEMS_FORBIDDEN","stageId",entry.getKey(),"message","采购阶段不能在回退补录中创建工作项"));
|
||||
for(Item item:copies)if("PURCHASE".equals(PmStageHierarchyRules.info(graph,item.stageId()).nodeType()))blockers.add(map("code","PURCHASE_LEGACY_WORK_ITEMS","stageId",item.stageId(),"message","请先处理采购阶段旧工作项归属,再执行回退"));
|
||||
// 空版本仍是未执行且阻塞后继,允许先回退再补工作项,不能强制生成虚假任务。
|
||||
@ -344,9 +348,10 @@ public class PmReworkServiceImpl implements IPmReworkService {
|
||||
private static Map<Long,List<ReworkItemInput>> additions(ReworkInput input) { return input.additions()==null?Map.of():input.additions(); }
|
||||
/** 幂等键绑定补录内容,按阶段 ID 固定顺序编码,避免同一键重试时悄悄丢弃新工作项。 */
|
||||
private String additionsJson(ReworkInput input) { return json.encode(new TreeMap<>(additions(input))); }
|
||||
/** 补录只允许工作项白名单字段和有效项目成员,避免回退时注入状态或排期。 */
|
||||
/** 人工补录与普通新建一样必须分配有效负责人;不影响系统复制旧项时清理失效负责人的原规则。 */
|
||||
private void validateAddition(long projectId,ReworkItemInput item) {
|
||||
if(item==null||item.title()==null||item.title().isBlank()||item.title().trim().length()>200) throw PmException.bad("补录工作项标题需为 1—200 个字符");
|
||||
if(item.assigneeId()==null) throw PmException.bad("请选择补录工作项负责人");
|
||||
if(!Set.of("TASK","REQUIREMENT","BUG").contains(item.type())) throw PmException.bad("补录工作项类型无效");
|
||||
if(item.priority()!=null&&!Set.of("LOW","MEDIUM","HIGH","URGENT").contains(item.priority())) throw PmException.bad("补录优先级无效");
|
||||
if(item.description()!=null&&item.description().length()>50000) throw PmException.bad("补录描述过长");
|
||||
|
||||
@ -51,7 +51,12 @@ public class PmScheduleServiceImpl implements IPmScheduleService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在同一锁事务中将请求转换为整日计划、验证最终图并写入审计,旧参考只在成功确认时移除。
|
||||
* 在同一锁事务中重读对象身份、转换整日计划并验证最终图,全部通过后才写入计划和审计。
|
||||
* 阶段计划逐项限迭代创建者或阶段负责人,工作项逐项限负责人或不可变创建者。
|
||||
* 混合请求分别校验身份;使用整批最终阶段计划约束工作项,任一失败整批不写。
|
||||
* @param projectId 项目成员和共享锁边界
|
||||
* @param iterationId 明确的当前迭代,沿用原可写生命周期
|
||||
* @param input 阶段及工作项最终计划;版本、冻结和依赖约束保持有效
|
||||
* @param backfill 是否由受控补录入口调用,普通请求不能自行开启
|
||||
*/
|
||||
private void apply(long projectId,long iterationId,BatchInput input,boolean backfill) {
|
||||
@ -63,11 +68,13 @@ public class PmScheduleServiceImpl implements IPmScheduleService {
|
||||
if(!stageChanges.isEmpty()&&!itemChanges.isEmpty()) access.project(projectId,"write");
|
||||
if(input.graphVersion()!=null&&input.graphVersion()!=number(revisions.selectGraphVersion(projectId,iterationId),"graph_version"))
|
||||
throw PmException.conflict("GRAPH_VERSION_CONFLICT","流程已变化,请刷新排期后重试");
|
||||
Graph before=graphs.load(projectId,iterationId),after=before.copy(); long now=PmTime.now();
|
||||
Graph before=graphs.load(projectId,iterationId),after=before.copy(); long now=PmTime.now(),actor=access.actor();
|
||||
boolean iterationCreator=!stageChanges.isEmpty()&&iterations.isCreator(projectId,iterationId);
|
||||
Set<Long> seen=new HashSet<>();
|
||||
for(StageScheduleInput change:stageChanges) {
|
||||
if(change==null||!seen.add(change.id())) throw PmException.bad("阶段排期为空或重复");
|
||||
StageRevision old=before.stageRevisions().get(change.id()); if(old==null) throw PmAccess.denied();
|
||||
if(!iterationCreator&&!PmWorkItemPermissions.ownsStage(before,change.id(),actor)) throw PmAccess.denied();
|
||||
if("PENDING".equals(old.approvalStatus())) throw PmException.conflict("STAGE_APPROVAL_PENDING","阶段待审批,请先撤回申请再改期");
|
||||
if(change.revisionId()==null||change.revisionId()!=old.id()) throw PmException.conflict("STAGE_REVISION_CHANGED","阶段已换版,请刷新后重试");
|
||||
version(change.version(),old.version()); boolean finished=finished(before,change.id());
|
||||
@ -90,7 +97,8 @@ public class PmScheduleServiceImpl implements IPmScheduleService {
|
||||
if(ref!=null&&!Objects.equals(ref.get("stage_revision_id"),ref.get("current_revision_id"))) throw PmException.conflict("HISTORICAL_WORK_ITEM","历史版本工作项只读");
|
||||
throw PmAccess.denied();
|
||||
}
|
||||
if(old.deleted()) throw PmAccess.denied(); version(change.version(),old.version());
|
||||
// 负责人及创建者以锁后完整图为准;所有对象鉴权通过前不能开始任何计划写入。
|
||||
if(old.deleted()||!PmWorkItemPermissions.canSchedule(old,actor)) throw PmAccess.denied(); version(change.version(),old.version());
|
||||
if(old.stageId()!=null) PmStageRules.requireDeliveryMutable(before,old.stageId());
|
||||
if(old.stageId()!=null&&finished(before,old.stageId())) throw PmException.conflict("STAGE_REVISION_FROZEN","已完成阶段不能修改工作项排期");
|
||||
PmTime.Plan plan=PmTime.planned(change.plannedStartAt(),change.plannedEndAt()); Long start=plan.start(),end=plan.end();
|
||||
@ -100,7 +108,10 @@ public class PmScheduleServiceImpl implements IPmScheduleService {
|
||||
if(start==null||end==null||old.stageId()!=null&&(stage==null||stage.plannedStart()==null||stage.scheduleReviewReworkId()!=null))
|
||||
throw PmException.conflict("SCHEDULE_REVIEW_REQUIRED","请先确认阶段计划,并完整填写工作项预计时间");
|
||||
}
|
||||
after.items().put(old.id(),old.confirmedSchedule(start,end));
|
||||
Item next=old.confirmedSchedule(start,end);
|
||||
// 只对本次主动排期要求有效阶段边界;阶段计划取本批最终态,旧参考值不能替代正常计划。
|
||||
PmStageScheduleRules.requireWorkItemPlan(after,next);
|
||||
after.items().put(old.id(),next);
|
||||
}
|
||||
// 已经生效的阶段边界不能直接清空来逃过包含关系;同批先取消全部受影响排期才允许清空。
|
||||
for(StageScheduleInput change:stageChanges) if(before.stageRevisions().get(change.id()).plannedStart()!=null&&after.stageRevisions().get(change.id()).plannedStart()==null
|
||||
@ -123,17 +134,35 @@ public class PmScheduleServiceImpl implements IPmScheduleService {
|
||||
revisions.advanceGraphVersion(projectId,iterationId);
|
||||
}
|
||||
|
||||
/** 同一项目锁内将参考计划按整日重新确认;不能因普通编辑或缺省时间将待复核自动视为完成。 */
|
||||
/**
|
||||
* 工作项负责人或不可变创建者在项目锁内重新确认参考计划,沿用完整排期及版本校验。
|
||||
* @param itemId 当前有效工作项;锁后重读身份,项目或阶段管理资格不能代替排期资格
|
||||
* @param input 必填当前数据版本;已无需复核的幂等请求也必须先通过排期身份检查
|
||||
* 注意:仅成功确认清除参考计划;无权调用不能借提前返回绕过对象权限。
|
||||
*/
|
||||
public void confirmItem(long itemId,VersionInput input) {
|
||||
Map<String,Object> ref=items.selectProjectReference(itemId); if(ref==null) throw PmAccess.denied();
|
||||
long projectId=number(ref,"project_id"),iterationId=number(ref,"iteration_id"); locked(projectId,iterationId,"write");
|
||||
Item item=graphs.load(projectId,iterationId).items().get(itemId); if(item==null||item.deleted()) throw PmAccess.denied();
|
||||
Item item=graphs.load(projectId,iterationId).items().get(itemId); if(item==null||item.deleted()||!PmWorkItemPermissions.canSchedule(item,access.actor())) throw PmAccess.denied();
|
||||
version(input==null?null:input.version(),item.version()); if(item.scheduleReviewReworkId()==null) return;
|
||||
apply(projectId,iterationId,new BatchInput(List.of(new ScheduleInput(itemId,item.version(),PmTime.format(item.referenceStart(),"Asia/Shanghai"),PmTime.format(item.referenceEnd(),"Asia/Shanghai")))),false);
|
||||
}
|
||||
|
||||
/** 先鉴权再锁,锁后再鉴权;所有排期和回退服务遵循相同顺序,直至事务提交才释放。 */
|
||||
private void locked(long projectId,long iterationId,String action) { access.project(projectId,action); workspace.lockProject(projectId); access.project(projectId,action); iterations.require(projectId,iterationId,action); }
|
||||
/**
|
||||
* 先校验成员边界再取得项目锁,锁后重读成员和迭代生命周期,具体对象身份由候选图逐项校验。
|
||||
* @param projectId 排期项目及共享锁边界,锁由调用方事务提交后释放
|
||||
* @param iterationId 排期所属的明确迭代
|
||||
* @param action admin 表示阶段计划或补录,仅采用成员边界;工作项仍保留原 write 门禁
|
||||
* 注意:阶段负责人不必具备项目管理身份,但任何计划写入仍受迭代只读状态保护。
|
||||
*/
|
||||
private void locked(long projectId,long iterationId,String action) {
|
||||
String permission="admin".equals(action)?"read":action;
|
||||
access.project(projectId,permission); workspace.lockProject(projectId); access.project(projectId,permission);
|
||||
if("admin".equals(action)) {
|
||||
Map<String,Object> iteration=iterations.require(projectId,iterationId,"read");
|
||||
PmIterationRules.requireAction(text(iteration,"status"),nullable(iteration,"archived_at")!=null,"write");
|
||||
} else iterations.require(projectId,iterationId,action);
|
||||
}
|
||||
/** 完成后的正常计划冻结,只有专用补录规则可以处理缺失值。 */
|
||||
private static boolean finished(Graph graph,long id) { return Set.of("COMPLETED","LEGACY_PASSED").contains(PmStageRules.executionStatus(graph,id)); }
|
||||
/** 请求必须提供数据版本,不能省略后覆盖他人的计划。 */
|
||||
|
||||
@ -22,7 +22,10 @@ import com.ruoyi.project.manage.mapper.PmUserMapper;
|
||||
import com.ruoyi.project.manage.mapper.PmWorkItemMapper;
|
||||
import com.ruoyi.project.manage.mapper.PmWorkspaceMapper;
|
||||
import com.ruoyi.project.manage.rule.PmRules;
|
||||
import com.ruoyi.project.manage.rule.PmIterationRules;
|
||||
import com.ruoyi.project.manage.rule.PmStageRules;
|
||||
import com.ruoyi.project.manage.rule.PmStageScheduleRules;
|
||||
import com.ruoyi.project.manage.rule.PmWorkItemPermissions;
|
||||
import com.ruoyi.project.manage.security.PmAccess;
|
||||
import com.ruoyi.project.manage.security.PmIterationAccess;
|
||||
import com.ruoyi.project.manage.service.IPmService;
|
||||
@ -117,17 +120,17 @@ public class PmServiceImpl implements IPmService {
|
||||
auditService.record(projectId,null,remove?"MEMBER_REMOVED":"MEMBER_CHANGED",map("userId",input.userId(),"role",input.role()),access.actor());
|
||||
}
|
||||
|
||||
/** 列表复用一次锁内身份和项目写资格,逐项计算本人执行能力,不为负责人比较重复查询用户。 */
|
||||
/** 列表复用锁内身份、迭代创建者及项目写资格,避免为每个旧项重复查询修复身份。 */
|
||||
public List<Map<String,Object>> items(long projectId,long iterationId) {
|
||||
locked(projectId,iterationId,"read"); Graph graph=graphService.load(projectId,iterationId); String zone=zone(projectId); boolean writable=access.canWrite(projectId);
|
||||
long actor=access.actor();
|
||||
return graph.items().values().stream().filter(i->!i.deleted()).map(i->view(graph,i,zone,writable,actor)).toList();
|
||||
Map<String,Object> iteration=locked(projectId,iterationId,"read"); Graph graph=graphService.load(projectId,iterationId); String zone=zone(projectId); boolean writable=access.canWrite(projectId);
|
||||
long actor=access.actor(); boolean creator=Long.valueOf(actor).equals(nullable(iteration,"created_by"));
|
||||
return graph.items().values().stream().filter(i->!i.deleted()).map(i->view(graph,i,zone,writable,actor,creator)).toList();
|
||||
}
|
||||
|
||||
/** 详情按当前身份计算负责人执行能力和既有附件删除资格;历史与冻结范围仍只读。 */
|
||||
/** 详情按锁内身份分别计算维护、执行、协作及旧项补齐能力;历史显式禁止迭代创建者修复。 */
|
||||
public Map<String,Object> detail(long id) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"read"); Graph graph=graphService.load(projectId,iterationId);
|
||||
boolean writable=access.canWrite(projectId); long actor=access.actor();
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); Map<String,Object> iteration=locked(projectId,iterationId,"read"); Graph graph=graphService.load(projectId,iterationId);
|
||||
boolean writable=access.canWrite(projectId); long actor=access.actor(); boolean creator=Long.valueOf(actor).equals(nullable(iteration,"created_by"));
|
||||
Item current=graph.items().get(id);
|
||||
Map<String,Object> result;
|
||||
if(current==null) {
|
||||
@ -138,10 +141,10 @@ public class PmServiceImpl implements IPmService {
|
||||
Item old=historicalItem(projectId,saved); oldItems.put(old.id(),old.withCollaborators(historicalParticipants.getOrDefault(old.id(),List.of())));
|
||||
}
|
||||
Graph oldGraph=new Graph(oldItems,new ArrayList<>(),new LinkedHashMap<>(),new ArrayList<>(),new LinkedHashMap<>(),graph.iteration()); Item historical=item(oldGraph,id);
|
||||
result=view(oldGraph,historical,zone(projectId),false,actor);
|
||||
result=view(oldGraph,historical,zone(projectId),false,actor,false);
|
||||
result.put("stageRevisionNo",(int)number(row,"stage_revision_no"));
|
||||
result.put("stageNameSnapshot",text(row,"stage_name_snapshot"));
|
||||
result.put("historicalChildren",PmRules.children(oldGraph,id).stream().map(child->{ Map<String,Object> childView=view(oldGraph,child,zone(projectId),false,actor); childView.put("historical",true); childView.put("canStart",false); return childView; }).toList());
|
||||
result.put("historicalChildren",PmRules.children(oldGraph,id).stream().map(child->{ Map<String,Object> childView=view(oldGraph,child,zone(projectId),false,actor,false); childView.putAll(map("historical",true,"canStart",false,"canDiscuss",false,"canUploadAttachments",false)); return childView; }).toList());
|
||||
List<Map<String,Object>> originalConditions=new ArrayList<>();
|
||||
for(Map<String,Object> dependency:dependencyMapper.selectItemDependencies(projectId,id)) {
|
||||
boolean available=!flag(dependency,"source_deleted"); String status=text(dependency,"source_status");
|
||||
@ -152,8 +155,8 @@ public class PmServiceImpl implements IPmService {
|
||||
"participatesInSchedule",nullable(dependency,"planned_end_at")!=null));
|
||||
}
|
||||
result.put("dependencyConditions",originalConditions);
|
||||
result.putAll(map("historical",true,"canStart",false,"canComplete",false,"canCreateChild",false,"blockedReasons",List.of(map("code","HISTORICAL_WORK_ITEM","message","历史版本只读"))));
|
||||
} else result=view(graph,item(graph,id),zone(projectId),writable,actor);
|
||||
result.putAll(map("historical",true,"canStart",false,"canComplete",false,"canCreateChild",false,"canDiscuss",false,"canUploadAttachments",false,"blockedReasons",List.of(map("code","HISTORICAL_WORK_ITEM","message","历史版本只读"))));
|
||||
} else result=view(graph,item(graph,id),zone(projectId),writable,actor,creator);
|
||||
result.put("comments",auditTimes(activityMapper.selectComments(id),zone(projectId)));
|
||||
result.put("attachments",activityMapper.selectAttachments(id));
|
||||
result.put("canDeleteAttachments",canDeleteAttachments(graph,id,writable));
|
||||
@ -161,14 +164,15 @@ public class PmServiceImpl implements IPmService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 创建工作项、分工、前置及本次邮件选择在同一项目锁事务保存;候选图先校验,冲突整体回滚。 */
|
||||
/** 所属阶段负责人创建工作项,初始计划必须在有效阶段范围内;分工、前置及通知同锁事务保存。 */
|
||||
public long create(long projectId,long iterationId,ItemInput input) {
|
||||
locked(projectId,iterationId,"create"); validateFields(projectId,iterationId,input);
|
||||
locked(projectId,iterationId,"create"); access.project(projectId,"write"); validateFields(projectId,iterationId,input);
|
||||
List<Long> collaboratorIds=participants.validate(projectId,input.collaboratorIds());
|
||||
PmTime.Plan plan=PmTime.planned(input.plannedStartAt(),input.plannedEndAt()); Long start=plan.start(),end=plan.end();
|
||||
Graph before=graphService.load(projectId,iterationId),proposed=before.copy(); requireStageMutable(before,input.stageId());
|
||||
Graph before=graphService.load(projectId,iterationId),proposed=before.copy(); requireOwnedStage(before,input.stageId()); requireStageMutable(before,input.stageId());
|
||||
// 先校验候选最终态,再写入,避免数据库 CHECK 抢先把业务排期冲突变成通用完整性错误。
|
||||
proposed.items().put(-1L,new Item(-1,projectId,input.type(),input.title(),input.description(),input.assigneeId(),input.priority(),"READY",start,end,null,null,0,false,input.stageId()));
|
||||
Item candidate=new Item(-1,projectId,input.type(),input.title(),input.description(),input.assigneeId(),input.priority(),"READY",start,end,null,null,0,false,input.stageId()).withCreator(access.actor());
|
||||
proposed.items().put(-1L,candidate); PmStageScheduleRules.requireWorkItemPlan(proposed,candidate);
|
||||
addInitialConditions(proposed,-1,input.predecessorWorkItemIds());
|
||||
PmRules.validateSchedules(proposed,zone(projectId)); PmRules.validateAcyclic(proposed); PmStageRules.validateRegression(before,proposed);
|
||||
long id=workItemMapper.insertWorkItem(map("project_id",projectId,"iteration_id",iterationId,"type",input.type(),"title",input.title().trim(),"description",input.description(),"assignee_id",input.assigneeId(),"priority",input.priority()==null?"MEDIUM":input.priority(),"planned_start_at",start,"planned_end_at",end,"stage_id",input.stageId(),"stage_revision_id",currentRevision(before,input.stageId()),"created_by",access.actor(),"created_at",PmTime.now()));
|
||||
@ -191,7 +195,7 @@ public class PmServiceImpl implements IPmService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一层子任务并按整日排期,项目锁覆盖父版本、终态、时间、隐式循环与历史;阶段始终继承父任务。
|
||||
* 所属阶段负责人创建一层子任务,项目锁覆盖父版本、终态、整日计划、隐式循环与历史;阶段继承父任务。
|
||||
* @param parentId 当前项目有效根任务 ID,完成、关闭、取消或子任务不能作为新父项
|
||||
* @param request 当前父版本和白名单子任务字段;未指定阶段时继承父阶段
|
||||
* 邮件选择随子任务请求保留,仅在勾选后发送;父关联事件不额外触发重复邮件。
|
||||
@ -199,7 +203,7 @@ public class PmServiceImpl implements IPmService {
|
||||
* @throws PmException 权限、版本、父范围或业务规则不满足时拒绝,整笔事务回滚
|
||||
*/
|
||||
public long createChild(long parentId,ChildInput request) {
|
||||
long projectId=projectOf(parentId),iterationId=iterationOf(parentId); locked(projectId,iterationId,"write"); Graph graph=graphService.load(projectId,iterationId); Item parent=writableItem(graph,parentId);
|
||||
long projectId=projectOf(parentId),iterationId=iterationOf(parentId); locked(projectId,iterationId,"write"); Graph graph=graphService.load(projectId,iterationId); Item parent=maintainableItem(graph,parentId);
|
||||
version(request.parentVersion(),parent.version());
|
||||
if(!"TASK".equals(parent.type())||parent.parentTaskId()!=null||PmRules.terminal(parent)) throw PmException.conflict("CHILD_CREATE_FORBIDDEN","仅未结束的根任务可以创建一层子任务");
|
||||
ItemInput input=request.item(); if(input==null) throw PmException.bad("子任务内容不能为空");
|
||||
@ -209,6 +213,7 @@ public class PmServiceImpl implements IPmService {
|
||||
validateFields(projectId,iterationId,input); PmTime.Plan plan=PmTime.planned(input.plannedStartAt(),input.plannedEndAt()); Long start=plan.start(),end=plan.end();
|
||||
Graph before=graph.copy();
|
||||
graph.items().put(-1L,new Item(-1,projectId,"TASK",input.title(),input.description(),input.assigneeId(),input.priority(),"READY",start,end,null,null,0,false,parent.stageId(),parentId));
|
||||
PmStageScheduleRules.requireWorkItemPlan(graph,graph.items().get(-1L));
|
||||
addInitialConditions(graph,-1,input.predecessorWorkItemIds());
|
||||
PmRules.validateSchedules(graph,zone(projectId)); PmRules.validateAcyclic(graph); PmStageRules.validateRegression(before,graph);
|
||||
long id=workItemMapper.insertWorkItem(map("project_id",projectId,"iteration_id",iterationId,"parent_task_id",parentId,"stage_id",parent.stageId(),"stage_revision_id",parent.stageRevisionId(),"type","TASK","title",input.title().trim(),"description",input.description(),"assignee_id",input.assigneeId(),"priority",input.priority()==null?"MEDIUM":input.priority(),"planned_start_at",start,"planned_end_at",end,"created_by",access.actor(),"created_at",PmTime.now()));
|
||||
@ -222,18 +227,18 @@ public class PmServiceImpl implements IPmService {
|
||||
/**
|
||||
* 在父项目鉴权后返回有效子任务,详情和外部客户端复用实时业务摘要。
|
||||
* @param id 有权限访问的父工作项 ID,不接受跨项目来源
|
||||
* @return 未软删除子任务的状态、排期和按各自负责人计算的能力;不继承父项执行权限
|
||||
* @return 未软删除子任务的状态、排期和独立能力;补归属仍从根任务处理,不继承父项执行权限
|
||||
*/
|
||||
public List<Map<String,Object>> children(long id) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"read"); Graph graph=graphService.load(projectId,iterationId); item(graph,id); boolean writable=access.canWrite(projectId);
|
||||
long actor=access.actor();
|
||||
return PmRules.children(graph,id).stream().map(i->view(graph,i,zone(projectId),writable,actor)).toList();
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); Map<String,Object> iteration=locked(projectId,iterationId,"read"); Graph graph=graphService.load(projectId,iterationId); item(graph,id); boolean writable=access.canWrite(projectId);
|
||||
long actor=access.actor(); boolean creator=Long.valueOf(actor).equals(nullable(iteration,"created_by"));
|
||||
return PmRules.children(graph,id).stream().map(i->view(graph,i,zone(projectId),writable,actor,creator)).toList();
|
||||
}
|
||||
|
||||
/** 普通编辑原子更新分工、字段及本次通知选择;省略协作人则保留,邮件选择省略则不发。 */
|
||||
/** 阶段负责人编辑字段及分工;改期另外核验工作项负责人/创建者,避免普通编辑隐式获得排期权限。 */
|
||||
public void edit(long id,ItemInput input) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"write"); Graph graph=graphService.load(projectId,iterationId); Item existing=writableItem(graph,id); version(input.version(),existing.version()); validateFields(projectId,iterationId,input); requireStageMutable(graph,input.stageId());
|
||||
if(!Objects.equals(existing.stageId(),input.stageId())) throw PmException.bad("请通过项目管理者的阶段归属入口移动工作项");
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"write"); Graph graph=graphService.load(projectId,iterationId); Item existing=maintainableItem(graph,id); version(input.version(),existing.version()); validateFields(projectId,iterationId,input); requireStageMutable(graph,input.stageId());
|
||||
if(!Objects.equals(existing.stageId(),input.stageId())) throw PmException.bad("请通过阶段负责人的阶段归属入口移动工作项");
|
||||
if(input.predecessorWorkItemIds()!=null) throw PmException.bad("编辑前置条件请使用依赖管理入口");
|
||||
List<Long> collaboratorIds=participants.validate(projectId,input.collaboratorIds());
|
||||
if(!existing.type().equals(input.type())) throw PmException.bad("工作项类型创建后不可直接变更");
|
||||
@ -242,7 +247,11 @@ public class PmServiceImpl implements IPmService {
|
||||
throw PmException.conflict("SCHEDULE_REVIEW_REQUIRED","排期待复核,请通过排期编辑或批量排期确认时间");
|
||||
Graph before=graph.copy();
|
||||
PmTime.Plan plan=PmTime.editedPlan(input.plannedStartAt(),input.plannedEndAt(),existing.start(),existing.end());
|
||||
boolean scheduleChanged=!Objects.equals(plan.start(),existing.start())||!Objects.equals(plan.end(),existing.end());
|
||||
if(scheduleChanged&&!PmWorkItemPermissions.canSchedule(existing,access.actor())) throw new PmException(403,"WORK_ITEM_SCHEDULER_REQUIRED","只有工作项负责人或创建者可以调整排期",Map.of());
|
||||
graph.items().put(id,existing.scheduled(plan.start(),plan.end()).inStage(input.stageId()));
|
||||
// 旧计划仅在主动改期时要求完整阶段边界,普通元数据编辑不重写或清除原时间。
|
||||
if(scheduleChanged) PmStageScheduleRules.requireWorkItemPlan(graph,graph.items().get(id));
|
||||
simulateStage(graph,existing,input.stageId());
|
||||
PmRules.validateSchedules(graph,zone(projectId)); PmRules.validateAcyclic(graph); PmStageRules.validateRegression(before,graph);
|
||||
workItemMapper.updateWorkItem(id,existing.version(),map("title",input.title().trim(),"description",input.description(),"assignee_id",input.assigneeId(),"priority",input.priority()==null?"MEDIUM":input.priority(),"planned_start_at",plan.start(),"planned_end_at",plan.end(),"stage_id",input.stageId(),"stage_revision_id",currentRevision(graph,input.stageId())));
|
||||
@ -253,20 +262,40 @@ public class PmServiceImpl implements IPmService {
|
||||
|
||||
/**
|
||||
* 所有阶段调整共用父子继承校验,版本、归属和历史在同一项目锁事务中提交。
|
||||
* 仅项目管理者可以移动待开始项,普通编辑不能清空阶段来绕过执行门禁。
|
||||
* 普通迁移须同时负责原阶段和目标阶段;迭代创建者仅可补齐旧项缺失的归属,不能覆盖已有阶段。
|
||||
* @param id 当前有效工作项 ID;子任务不能脱离父阶段
|
||||
* @param input 目标同项目阶段及工作项版本,null 阶段代表未分配
|
||||
* 注意:先校验父子整体排期是否落在目标阶段内,再同步版本和审计;相同阶段不重复更新。
|
||||
* @param input 同迭代有效工作阶段及工作项版本,不能清空所属阶段;修复不要求目标阶段由创建者负责
|
||||
* 注意:修复只允许待开始根项及其同样待开始、未归属的子任务;不重写内容、状态或排期。
|
||||
*/
|
||||
public void assignStage(long id,StageAssignment input) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"write"); Graph graph=graphService.load(projectId,iterationId); Item existing=writableItem(graph,id); version(input.version(),existing.version());
|
||||
access.project(projectId,"admin");
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id);
|
||||
Map<String,Object> iteration=locked(projectId,iterationId,"read");
|
||||
PmIterationRules.requireAction(text(iteration,"status"),nullable(iteration,"archived_at")!=null,"write");
|
||||
Graph graph=graphService.load(projectId,iterationId); Item existing=mutableItem(graph,id);
|
||||
// 创建者专用补齐只替代缺失归属的身份检查;普通迁移仍保留项目写资格和两个阶段的负责身份。
|
||||
// 身份与缺失值均在同一项目锁下重新读取,防止并发补齐后又覆盖另一人刚分配的阶段。
|
||||
boolean repair=existing.stageId()==null&&Long.valueOf(access.actor()).equals(nullable(iteration,"created_by"));
|
||||
if(!repair) { access.project(projectId,"write"); requireOwnedStage(graph,existing.stageId()); }
|
||||
if(input==null) throw PmException.bad("请选择工作项所属阶段");
|
||||
version(input.version(),existing.version());
|
||||
if(!"READY".equals(existing.status())) throw PmException.conflict("ITEM_STAGE_LOCKED","只有待开始工作项可以调整阶段");
|
||||
if(input.stageId()!=null&&stageMapper.selectActiveStageId(input.stageId(),projectId,iterationId)==null) throw PmAccess.denied();
|
||||
if(repair&&existing.parentTaskId()!=null) throw PmException.conflict("CHILD_STAGE_INHERITED","请从父任务补充所属阶段,子任务继承父任务阶段");
|
||||
if(input.stageId()==null) throw PmException.bad("请选择工作项所属阶段");
|
||||
if(stageMapper.selectActiveStageId(input.stageId(),projectId,iterationId)==null) throw PmAccess.denied();
|
||||
if(!repair) requireOwnedStage(graph,input.stageId());
|
||||
requireStageMutable(graph,input.stageId()); validateInheritedStage(graph,existing,input.stageId()); if(Objects.equals(existing.stageId(),input.stageId())) return;
|
||||
if(input.stageId()!=null&&"PURCHASE".equals(com.ruoyi.project.manage.rule.PmStageHierarchyRules.info(graph,input.stageId()).nodeType())) throw PmException.bad("采购阶段不能承载工作项");
|
||||
for(Item child:PmRules.children(graph,id)) {
|
||||
if(!repair) requireOwnedStage(graph,child.stageId());
|
||||
else {
|
||||
if(child.stageId()!=null) throw PmAccess.denied();
|
||||
if(!"READY".equals(child.status())) throw PmException.conflict("ITEM_STAGE_LOCKED","子任务已执行,不能通过旧项补齐入口迁移阶段");
|
||||
}
|
||||
}
|
||||
if("PURCHASE".equals(com.ruoyi.project.manage.rule.PmStageHierarchyRules.info(graph,input.stageId()).nodeType())) throw PmException.bad("采购阶段不能承载工作项");
|
||||
Graph before=graph.copy(); simulateStage(graph,existing,input.stageId());
|
||||
PmRules.validateSchedules(graph,zone(projectId)); PmRules.validateAcyclic(graph); PmStageRules.validateRegression(before,graph);
|
||||
// 归属、父子同步、图版本及审计必须同事务;任一校验或写入失败均不能留下半次修复。
|
||||
revisionMapper.advanceGraphVersion(projectId,iterationId);
|
||||
workItemMapper.updateWorkItem(id,existing.version(),map("stage_id",input.stageId(),"stage_revision_id",currentRevision(graph,input.stageId())));
|
||||
auditService.record(projectId,iterationId,id,"ITEM_STAGE_CHANGED",map("fromStageId",existing.stageId(),"stageId",input.stageId()),access.actor()); cascadeStage(before,existing,input.stageId());
|
||||
syncStage(projectId,iterationId,existing.stageId(),PmStageRules.executionStatus(before,existing.stageId()==null?-1:existing.stageId())); syncStage(projectId,iterationId,input.stageId(),PmStageRules.executionStatus(before,input.stageId()==null?-1:input.stageId()));
|
||||
@ -292,6 +321,30 @@ public class PmServiceImpl implements IPmService {
|
||||
for(Item child:PmRules.children(graph,parent.id())) graph.items().put(child.id(),child.inStage(stageId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 为已有未分配项补负责人,由当前阶段负责人或本迭代创建者在项目锁内执行,不授予普通编辑权。
|
||||
* @param id 当前迭代有效且未冻结的工作项,历史或已分配项均不允许覆盖负责人
|
||||
* @param input 仅负责人和乐观版本,拒绝空值及非当前项目有效成员
|
||||
* 注意:只更新 assignee_id;阶段维护权不随工作项改派转移,执行、协作与排期按新负责人重新计算。
|
||||
*/
|
||||
public void assignAssignee(long id,com.ruoyi.project.manage.dto.AssigneeInput input) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id);
|
||||
Map<String,Object> iteration=locked(projectId,iterationId,"read");
|
||||
PmIterationRules.requireAction(text(iteration,"status"),nullable(iteration,"archived_at")!=null,"write");
|
||||
Graph graph=graphService.load(projectId,iterationId); Item current=mutableItem(graph,id);
|
||||
if(current.assigneeId()!=null) throw PmAccess.denied();
|
||||
// 修复身份来自锁内不可变创建人,项目/系统管理身份不能替代;已分配后此例外立即失效。
|
||||
if(!Long.valueOf(access.actor()).equals(nullable(iteration,"created_by"))) {
|
||||
access.project(projectId,"write"); requireOwnedStage(graph,current.stageId());
|
||||
}
|
||||
if(input==null||input.assigneeId()==null) throw PmException.bad("请选择工作项负责人");
|
||||
version(input.version(),current.version());
|
||||
access.assignee(projectId,input.assigneeId());
|
||||
revisionMapper.advanceGraphVersion(projectId,iterationId);
|
||||
workItemMapper.updateWorkItem(id,current.version(),map("assignee_id",input.assigneeId()));
|
||||
auditService.record(projectId,iterationId,id,"ITEM_EDITED",map("assigneeId",input.assigneeId(),"message","为未分配工作项分配负责人"),access.actor());
|
||||
}
|
||||
|
||||
/** 返回锁内负责人、迭代及前置的实时可开始结果,不能用看板成员筛选推断执行资格。 */
|
||||
public Map<String,Object> startability(long id) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"read"); Graph graph=graphService.load(projectId,iterationId);
|
||||
@ -308,7 +361,7 @@ public class PmServiceImpl implements IPmService {
|
||||
performStart(graph,writableItem(graph,id),input.version(),zone(projectId));
|
||||
}
|
||||
|
||||
/** 进入进行中或已完成均须当前负责人;完成仍检查子终态,关闭保留实际时间,其他状态维持既有门禁。 */
|
||||
/** 所有状态转换均须当前负责人;完成、关闭及回退继续保留既有子终态、实际时间及准入门禁。 */
|
||||
public void transition(long id,TransitionInput input) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"write"); Graph graph=graphService.load(projectId,iterationId); Item existing=writableItem(graph,id);
|
||||
if("IN_PROGRESS".equals(input.status())) { performStart(graph,existing,input.version(),zone(projectId)); return; }
|
||||
@ -325,9 +378,9 @@ public class PmServiceImpl implements IPmService {
|
||||
syncStage(projectId,iterationId,existing.stageId(),PmStageRules.executionStatus(before,existing.stageId()==null?-1:existing.stageId()));
|
||||
}
|
||||
|
||||
/** 软删除工作项前检查已开始后续的任务条件;历史记录及已停用的流程数据均保留。 */
|
||||
/** 仅所属阶段负责人软删除工作项,并检查子任务和已开始后续;历史与分工数据均保留。 */
|
||||
public void delete(long id,VersionInput input) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"write"); Graph graph=graphService.load(projectId,iterationId); Item existing=writableItem(graph,id); version(input.version(),existing.version());
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"write"); Graph graph=graphService.load(projectId,iterationId); Item existing=maintainableItem(graph,id); version(input.version(),existing.version());
|
||||
if(!PmRules.children(graph,id).isEmpty()) throw PmException.conflict("PARENT_HAS_CHILDREN","请先处理并删除子任务,再删除父任务");
|
||||
Graph before=graph.copy(); graph.items().put(id,existing.transitioned(existing.status(),true));
|
||||
PmRules.validateActual(graph,zone(projectId)); PmStageRules.validateRegression(before,graph);
|
||||
@ -345,7 +398,7 @@ public class PmServiceImpl implements IPmService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在项目锁下模拟依赖最终图,先检查循环与排期再保存;只有待开始工作项可以编辑。
|
||||
* 阶段负责人在项目锁下模拟依赖最终图,先检查循环与排期再保存;只允许维护待开始工作项。
|
||||
* @param id 后续工作项实例 ID
|
||||
* @param dependencyId 编辑或删除的依赖 ID;新增时为空
|
||||
* @param input 前置工作项引用及任务/依赖版本;删除时仍必须提供两个版本
|
||||
@ -353,7 +406,7 @@ public class PmServiceImpl implements IPmService {
|
||||
* @return 已保存或删除的依赖 ID;失败时整个事务回滚且不产生成功事件
|
||||
*/
|
||||
public long dependency(long id,Long dependencyId,DependencyInput input,boolean remove) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"write"); Graph graph=graphService.load(projectId,iterationId); Item successor=writableItem(graph,id);
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"write"); Graph graph=graphService.load(projectId,iterationId); Item successor=maintainableItem(graph,id);
|
||||
if(!"READY".equals(successor.status())) throw PmException.conflict("DEPENDENCY_EDIT_FORBIDDEN","只有待开始工作项可以编辑前置依赖");
|
||||
version(input.taskVersion(),successor.version());
|
||||
Dependency existing=dependencyId==null?null:graph.dependencies().stream().filter(d->d.id()==dependencyId&&d.successorId()==id).findFirst().orElseThrow(PmAccess::denied);
|
||||
@ -414,25 +467,26 @@ public class PmServiceImpl implements IPmService {
|
||||
/** 混合批量与单项时间修改共用一个事务入口,不按对象逐次提交。 */
|
||||
public void scheduleBatch(long projectId,long iterationId,com.ruoyi.project.manage.dto.BatchInput input) { schedules.schedule(projectId,iterationId,input); }
|
||||
|
||||
/** 后续任务只返回当前有效依赖;批量共享锁内身份,各自负责人决定执行能力。 */
|
||||
/** 后续任务只返回当前有效依赖;批量共享锁内创建者及负责人身份,修复能力不扩大执行权。 */
|
||||
public List<Map<String,Object>> successors(long id) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"read"); Graph graph=graphService.load(projectId,iterationId); item(graph,id);
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); Map<String,Object> iteration=locked(projectId,iterationId,"read"); Graph graph=graphService.load(projectId,iterationId); item(graph,id);
|
||||
Set<Long> targets=new LinkedHashSet<>();
|
||||
for(Dependency d:graph.dependencies()) if(Objects.equals(d.taskId(),id)) targets.add(d.successorId());
|
||||
String zone=zone(projectId); boolean writable=access.canWrite(projectId);
|
||||
long actor=access.actor();
|
||||
return targets.stream().map(graph.items()::get).filter(i->!i.deleted()).map(i->view(graph,i,zone,writable,actor)).toList();
|
||||
long actor=access.actor(); boolean creator=Long.valueOf(actor).equals(nullable(iteration,"created_by"));
|
||||
return targets.stream().map(graph.items()::get).filter(i->!i.deleted()).map(i->view(graph,i,zone,writable,actor,creator)).toList();
|
||||
}
|
||||
|
||||
/** 待审批仍允许讨论,但历史、已完成阶段和终态迭代继续只读;评论不改写交付证据。 */
|
||||
/** 仅工作项负责人及当前协作人可评论;待审批仍可讨论,已完成阶段及终态迭代只读。 */
|
||||
public void comment(long id,CommentInput input) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"write"); Graph graph=graphService.load(projectId,iterationId); Item current=item(graph,id);
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); lockedMemberWrite(projectId,iterationId); Graph graph=graphService.load(projectId,iterationId); Item current=item(graph,id);
|
||||
requireItemParticipant(current);
|
||||
if(current.stageId()!=null&&Set.of("COMPLETED","LEGACY_PASSED").contains(PmStageRules.executionStatus(graph,current.stageId()))) throw PmException.conflict("STAGE_REVISION_FROZEN","已完成阶段保持只读");
|
||||
activityMapper.insertComment(map("work_item_id",id,"body",required(input.body(),10000,"评论"),"created_by",access.actor(),"created_at",PmTime.now())); auditService.record(projectId,iterationId,id,"COMMENT_ADDED",map("message","新增评论"),access.actor());
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作项写鉴权后保存私有 MinIO 对象及数据库元信息,限制为 50MB,不写本地目录或新二进制字段。
|
||||
* 工作项负责人及当前协作人在未冻结工作项上传私有 MinIO 附件,不以项目管理身份代替分工。
|
||||
* @param id 当前可写工作项,历史版本不能追加附件
|
||||
* @param name 原文件名,仅保留文件名部分,不作为对象路径使用
|
||||
* @param mediaType 浏览器提交的媒体类型,需满足 HTTP 媒体类型格式
|
||||
@ -440,7 +494,7 @@ public class PmServiceImpl implements IPmService {
|
||||
* @return 新附件 ID,下载继续通过同一受鉴权接口
|
||||
*/
|
||||
public long attach(long id,String name,String mediaType,byte[] content) {
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); locked(projectId,iterationId,"write"); writableItem(graphService.load(projectId,iterationId),id);
|
||||
long projectId=projectOf(id),iterationId=iterationOf(id); lockedMemberWrite(projectId,iterationId); requireItemParticipant(mutableItem(graphService.load(projectId,iterationId),id));
|
||||
if(content==null||content.length==0||content.length>com.ruoyi.project.manage.service.support.PmAttachmentStorage.MAX_BYTES) throw PmException.bad("附件需为 1 字节至 "+com.ruoyi.project.manage.service.support.PmAttachmentStorage.MAX_SIZE_LABEL);
|
||||
String safeName=required(name==null?"附件":name.replace('\\','/').substring(name.replace('\\','/').lastIndexOf('/')+1),255,"附件名称");
|
||||
String safeType=mediaType==null?"application/octet-stream":required(mediaType,120,"文件类型");
|
||||
@ -451,7 +505,7 @@ public class PmServiceImpl implements IPmService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在同一项目锁事务中软删除附件并记录审计;角色从工作项实时读取,不能用上传者身份代替。
|
||||
* 仅当前工作项负责人在同一项目锁事务中软删除附件;创建者或上传者不额外获得删除资格。
|
||||
* @param itemId 当前可写工作项;历史版本、冻结阶段及只读迭代拒绝修改
|
||||
* @param attachmentId 必须属于当前工作项的有效附件,不能借其它工作项的权限跨对象删除
|
||||
* <p>保留 MinIO 对象和旧数据库内容,删除标记、操作人/时间、成功历史与事件原子提交。</p>
|
||||
@ -629,16 +683,18 @@ public class PmServiceImpl implements IPmService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 按当前负责人返回执行能力,项目可写仍不代表可以替其他成员开始或完成工作项。
|
||||
* 分别按阶段负责人、工作项负责人/创建者及协作分工投影能力,避免编辑权隐式变为执行或排期权。
|
||||
* @param graph 已鉴权的完整迭代快照
|
||||
* @param item 当前行或明确只读的历史工作项
|
||||
* @param zone 展示时区
|
||||
* @param writable 当前项目写资格;不能用于绕过负责人或历史冻结条件
|
||||
* @param actor 本批摘要共享的认证用户
|
||||
* @param creator 锁内迭代创建者身份;历史摘要必须传 false,只用于缺失字段专用修复
|
||||
* @return 状态、能力、身份原因及前置/排期摘要;身份原因不计为依赖阻塞
|
||||
*/
|
||||
private Map<String,Object> view(Graph graph,Item item,String zone,boolean writable,long actor) {
|
||||
private Map<String,Object> view(Graph graph,Item item,String zone,boolean writable,long actor,boolean creator) {
|
||||
Map<String,Object> response=map("id",item.id(),"projectId",item.projectId(),"type",item.type(),"title",item.title(),"description",item.description(),"assigneeId",item.assigneeId(),"priority",item.priority(),"status",item.status(),"version",item.version(),"timezone",zone,"plannedStartAt",PmTime.format(item.start(),zone),"plannedEndAt",PmTime.format(item.end(),zone),"actualStartAt",PmTime.format(item.actualStart(),zone),"actualEndAt",PmTime.format(item.actualEnd(),zone));
|
||||
response.put("createdBy",item.createdBy());
|
||||
response.put("collaboratorIds",item.collaborators().stream().map(c->c.userId()).toList());
|
||||
response.put("stagePath",item.stageId()==null?"未分配":com.ruoyi.project.manage.rule.PmStageHierarchyRules.path(graph,item.stageId()));
|
||||
response.put("stageGroupId",item.stageId()==null?null:com.ruoyi.project.manage.rule.PmStageHierarchyRules.info(graph,item.stageId()).parentId());
|
||||
@ -646,6 +702,9 @@ public class PmServiceImpl implements IPmService {
|
||||
boolean mutable=graph.iteration()!=null&&graph.iteration().mutable();
|
||||
var stageRevision=item.stageId()==null?null:graph.stageRevisions().get(item.stageId());
|
||||
boolean frozen=stageRevision!=null&&("PENDING".equals(stageRevision.approvalStatus())||Set.of("COMPLETED","LEGACY_PASSED").contains(PmStageRules.executionStatus(graph,item.stageId())));
|
||||
boolean ownerWritable=writable&&mutable&&!frozen&&!item.deleted()&&Long.valueOf(actor).equals(item.assigneeId());
|
||||
boolean maintainerWritable=writable&&mutable&&!frozen&&!item.deleted()&&PmWorkItemPermissions.canMaintain(graph,item,actor);
|
||||
boolean participant=PmWorkItemPermissions.canCollaborate(item,actor);
|
||||
List<Map<String,Object>> executionReasons=PmRules.executionBlocked(item,actor);
|
||||
boolean executable=writable&&mutable&&!frozen&&executionReasons.isEmpty();
|
||||
response.put("canExecuteWorkItem",executable);
|
||||
@ -653,11 +712,21 @@ public class PmServiceImpl implements IPmService {
|
||||
response.putAll(map("iterationId",graph.iteration()==null?null:graph.iteration().id(),"iterationStatus",graph.iteration()==null?null:graph.iteration().status(),"iterationReadOnly",!mutable));
|
||||
Item parent=item.parentTaskId()==null?null:graph.items().get(item.parentTaskId());
|
||||
List<Item> children=PmRules.children(graph,item.id()); List<Map<String,Object>> unfinished=PmRules.unfinishedChildren(graph,item.id());
|
||||
boolean repairable=creator&&mutable&&!frozen&&!item.deleted();
|
||||
List<Map<String,Object>> completionReasons=new ArrayList<>(executionReasons); completionReasons.addAll(unfinished);
|
||||
boolean overdue=PmRules.overdue(item,PmTime.now());
|
||||
response.putAll(map("parentTaskId",item.parentTaskId(),"parentTaskTitle",parent==null?null:parent.title(),"parentPlannedStartAt",parent==null?null:PmTime.format(parent.start(),zone),"parentPlannedEndAt",parent==null?null:PmTime.format(parent.end(),zone),"childCount",children.size(),"childTerminalCount",children.stream().filter(PmRules::terminal).count(),"canCreateChild",writable&&"TASK".equals(item.type())&&item.parentTaskId()==null&&!PmRules.terminal(item),"canComplete",executable&&"IN_PROGRESS".equals(item.status())&&unfinished.isEmpty(),"completionBlockedReasons",completionReasons,"overdue",overdue,"displayStatus",overdue?"OVERDUE":item.status()));
|
||||
response.putAll(map("parentTaskId",item.parentTaskId(),"parentTaskTitle",parent==null?null:parent.title(),"parentPlannedStartAt",parent==null?null:PmTime.format(parent.start(),zone),"parentPlannedEndAt",parent==null?null:PmTime.format(parent.end(),zone),"childCount",children.size(),"childTerminalCount",children.stream().filter(PmRules::terminal).count(),"canCreateChild",maintainerWritable&&"TASK".equals(item.type())&&item.parentTaskId()==null&&!PmRules.terminal(item),"canComplete",executable&&"IN_PROGRESS".equals(item.status())&&unfinished.isEmpty(),"completionBlockedReasons",completionReasons,"overdue",overdue,"displayStatus",overdue?"OVERDUE":item.status()));
|
||||
response.put("stageId",item.stageId()); response.put("stageRevisionId",item.stageRevisionId()); response.put("stageRevisionNo",item.stageId()==null?null:graph.stageRevisions().get(item.stageId())==null?null:graph.stageRevisions().get(item.stageId()).revisionNo()); response.put("originWorkItemId",item.originWorkItemId()); response.put("scheduleReviewRequired",item.scheduleReviewReworkId()!=null); response.put("scheduleReviewClosed",item.scheduleReviewReworkId()!=null&&(!mutable||PmRules.completed(item)||item.stageId()!=null&&Set.of("COMPLETED","LEGACY_PASSED").contains(PmStageRules.executionStatus(graph,item.stageId())))); response.put("referencePlannedStartAt",PmTime.format(item.referenceStart(),zone)); response.put("referencePlannedEndAt",PmTime.format(item.referenceEnd(),zone));
|
||||
if(!mutable||frozen) { response.put("canCreateChild",false); response.put("canComplete",false); }
|
||||
// 配置、执行、排期与协作分别使用真实对象身份;项目管理角色不会隐式继承这些能力。
|
||||
response.putAll(map("canEditWorkItem",maintainerWritable,"canDeleteWorkItem",maintainerWritable&&children.isEmpty(),
|
||||
"canScheduleWorkItem",writable&&mutable&&!frozen&&!item.deleted()&&PmWorkItemPermissions.canSchedule(item,actor)&&!Boolean.TRUE.equals(response.get("scheduleReviewClosed")),
|
||||
"canAssignStage",maintainerWritable&&"READY".equals(item.status())&&item.parentTaskId()==null,
|
||||
"canAssignAssignee",maintainerWritable&&item.assigneeId()==null,
|
||||
"canRepairStage",repairable&&item.stageId()==null&&item.parentTaskId()==null&&"READY".equals(item.status())&&children.stream().allMatch(child->child.stageId()==null&&"READY".equals(child.status())),
|
||||
"canRepairAssignee",repairable&&item.assigneeId()==null,
|
||||
"canDiscuss",participant&&mutable&&!item.deleted()&&(item.stageId()==null||!Set.of("COMPLETED","LEGACY_PASSED").contains(PmStageRules.executionStatus(graph,item.stageId()))),
|
||||
"canUploadAttachments",participant&&mutable&&!frozen&&!item.deleted(),"canDeleteAttachments",ownerWritable));
|
||||
response.putAll(startability(graph,item,zone,writable,actor)); response.put("dependencyBlocked",!PmRules.blocked(graph,item.id(),zone).isEmpty()||!PmStageRules.blocked(graph,item.id()).isEmpty()); response.put("scheduleConstraints",PmRules.schedule(graph,item,zone)); return response;
|
||||
}
|
||||
|
||||
@ -677,11 +746,25 @@ public class PmServiceImpl implements IPmService {
|
||||
/**
|
||||
* 所有迭代写入口使用同一锁序;获取项目锁后重新校验迭代状态,防止结束或撤权与写入穿插。
|
||||
* 图版本在事务内推进,后续校验失败时随业务回滚;项目级成员事件不会推进任意迭代图。
|
||||
* @return 锁内的真实迭代行,供成员协作入口复用生命周期,不隐式授予项目写权限
|
||||
*/
|
||||
private void locked(long projectId,long iterationId,String action) {
|
||||
private Map<String,Object> locked(long projectId,long iterationId,String action) {
|
||||
locked(projectId,action);
|
||||
iterationAccess.require(projectId,iterationId,action);
|
||||
Map<String,Object> iteration=iterationAccess.require(projectId,iterationId,action);
|
||||
if(!"read".equals(action)) revisionMapper.advanceGraphVersion(projectId,iterationId);
|
||||
return iteration;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成员讨论及上传不要求普通维护的项目写资格,但保留迭代可写生命周期及原图版本推进。
|
||||
* @param projectId 成员及共享图锁边界,锁前锁后均验证当前成员
|
||||
* @param iterationId 明确的可写迭代,归档或终态不能通过讨论入口继续写入
|
||||
* 注意:调用方事务同时保护业务、历史和图版本;具体交付冻结仍由评论或附件入口校验。
|
||||
*/
|
||||
private void lockedMemberWrite(long projectId,long iterationId) {
|
||||
Map<String,Object> iteration=locked(projectId,iterationId,"read");
|
||||
PmIterationRules.requireAction(text(iteration,"status"),nullable(iteration,"archived_at")!=null,"write");
|
||||
revisionMapper.advanceGraphVersion(projectId,iterationId);
|
||||
}
|
||||
|
||||
/** 从当前图取有效阶段版本,未分配工作项保持空版本;项目锁防止切换与创建交错。 */
|
||||
@ -695,18 +778,16 @@ public class PmServiceImpl implements IPmService {
|
||||
/**
|
||||
* 按工作项身份计算附件删除资格,上传者、协作人或项目经理身份本身不授予删除权。
|
||||
* @param graph 已持有项目锁并鉴权的当前迭代快照,历史版本不在当前工作项集合内
|
||||
* @param id 附件所属工作项;创建人从数据库不可变字段读取,负责人使用锁内最新快照
|
||||
* @param id 附件所属工作项,负责人使用锁内最新快照,不查询或信任附件上传者及工作项创建人
|
||||
* @param writable 当前用户已通过项目写权限;只读迭代与已完成阶段继续禁止删除
|
||||
* @return 当前用户是负责人或工作项创建者且范围可写时为 true;不保存可过期的权限布尔值
|
||||
* @return 当前用户是负责人且范围可写时为 true;不保存可过期的权限布尔值
|
||||
*/
|
||||
private boolean canDeleteAttachments(Graph graph,long id,boolean writable) {
|
||||
Item current=graph.items().get(id);
|
||||
if(!writable||graph.iteration()==null||!graph.iteration().mutable()||current==null||current.deleted()) return false;
|
||||
if(current.stageId()!=null&&Set.of("COMPLETED","LEGACY_PASSED").contains(PmStageRules.executionStatus(graph,current.stageId()))) return false;
|
||||
if(current.stageId()!=null&&"PENDING".equals(graph.stageRevisions().get(current.stageId()).approvalStatus())) return false;
|
||||
long actor=access.actor();
|
||||
Map<String,Object> reference=workItemMapper.selectProjectReference(id);
|
||||
return Long.valueOf(actor).equals(current.assigneeId())||reference!=null&&Long.valueOf(actor).equals(nullable(reference,"created_by"));
|
||||
return Long.valueOf(access.actor()).equals(current.assigneeId());
|
||||
}
|
||||
|
||||
/** 待审批和已完成阶段统一冻结交付,所有工作项写入口必须复用此规则。 */
|
||||
@ -716,8 +797,13 @@ public class PmServiceImpl implements IPmService {
|
||||
PmStageRules.requireDeliveryMutable(graph,stageId);
|
||||
}
|
||||
|
||||
/** 所有写入口识别旧版 ID 并拒绝,避免当前图过滤后把历史项误当作可写。 */
|
||||
private Item writableItem(Graph graph,long id) {
|
||||
/**
|
||||
* 成员上传及负责人维护共用冻结、历史和软删除校验,本方法本身不授予负责人身份。
|
||||
* @param graph 已鉴权且持有项目锁的当前迭代快照
|
||||
* @param id 本次目标工作项,历史 ID 即使属于同项目也不能写入
|
||||
* @return 当前有效且交付可变的工作项;仍须由调用方校验本次动作身份
|
||||
*/
|
||||
private Item mutableItem(Graph graph,long id) {
|
||||
Item current=graph.items().get(id);
|
||||
if(current==null) {
|
||||
Map<String,Object> reference=workItemMapper.selectRevisionReference(projectOf(id),id);
|
||||
@ -729,6 +815,51 @@ public class PmServiceImpl implements IPmService {
|
||||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* 阶段负责人维护工作项字段及组织关系,冻结与历史检查仍先于本次对象写入。
|
||||
* @param graph 已鉴权且持项目锁的当前迭代完整图
|
||||
* @param id 本次维护目标,不能用本人工作项身份替代阶段维护职责
|
||||
* @return 当前可由所属阶段负责人维护的工作项
|
||||
*/
|
||||
private Item maintainableItem(Graph graph,long id) {
|
||||
Item current=mutableItem(graph,id); requireOwnedStage(graph,current.stageId()); return current;
|
||||
}
|
||||
|
||||
/** 只接受本人负责的精确阶段,未归属对象不自动继承项目或父阶段组管理权。 */
|
||||
private void requireOwnedStage(Graph graph,Long stageId) {
|
||||
if(stageId==null) throw PmException.bad("请选择本人负责的所属阶段");
|
||||
if(!PmWorkItemPermissions.ownsStage(graph,stageId,access.actor()))
|
||||
throw new PmException(403,"STAGE_OWNER_REQUIRED","只有所属阶段负责人可以维护该阶段的工作项",Map.of());
|
||||
}
|
||||
|
||||
/** 项目成员身份不足以追加工作项内容,必须是锁内最新负责人或协作人,防止撤回分工后仍能写入。 */
|
||||
private void requireItemParticipant(Item current) {
|
||||
if(!PmWorkItemPermissions.canCollaborate(current,access.actor()))
|
||||
throw new PmException(403,"WORK_ITEM_PARTICIPANT_REQUIRED","只有工作项负责人和协作人可以评论或上传附件",Map.of());
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行及附件删除从锁内快照比较真实工作项负责人,元数据维护使用独立阶段负责人入口。
|
||||
* @param graph 已完成项目及迭代鉴权的当前图
|
||||
* @param id 要执行动作的工作项,先检查历史、软删除和交付冻结
|
||||
* @return 可由当前负责人执行的有效工作项;无负责人或身份不符均拒绝
|
||||
*/
|
||||
private Item writableItem(Graph graph,long id) {
|
||||
Item current=mutableItem(graph,id);
|
||||
requireWorkItemAssignee(current);
|
||||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行及附件删除核对工作项真实负责人,阶段元数据维护身份不能用于替其他人执行。
|
||||
* @param current 项目锁内重新读取的当前对象,不接受请求中的负责人字段
|
||||
* @throws PmException 未分配或非当前负责人时返回403,不存在管理身份例外
|
||||
*/
|
||||
private void requireWorkItemAssignee(Item current) {
|
||||
if(!Long.valueOf(access.actor()).equals(current.assigneeId()))
|
||||
throw new PmException(403,"WORK_ITEM_ASSIGNEE_REQUIRED","只有工作项当前负责人可以执行此操作",Map.of());
|
||||
}
|
||||
|
||||
/** 工作项只触发阶段首次开始;同一项目锁内保存上游版本门禁证据,完成事实仍由审批服务产生。 */
|
||||
private void syncStage(long projectId,long iterationId,Long stageId,String previousStatus) {
|
||||
if(stageId==null) return;
|
||||
@ -766,7 +897,7 @@ public class PmServiceImpl implements IPmService {
|
||||
|
||||
/** 历史轮次只读重建原工作项快照,不加入当前排期与实际开始图。 */
|
||||
private static Item historicalItem(long projectId,Map<String,Object> row) {
|
||||
return new Item(number(row,"id"),projectId,text(row,"type"),text(row,"title"),text(row,"description"),nullable(row,"assignee_id"),text(row,"priority"),text(row,"status"),nullable(row,"planned_start_at"),nullable(row,"planned_end_at"),nullable(row,"actual_start_at"),nullable(row,"actual_end_at"),(int)number(row,"version"),flag(row,"deleted"),nullable(row,"stage_id"),nullable(row,"parent_task_id"),nullable(row,"stage_revision_id"),nullable(row,"origin_work_item_id"),nullable(row,"schedule_review_rework_id"),nullable(row,"reference_planned_start_at"),nullable(row,"reference_planned_end_at"));
|
||||
return new Item(number(row,"id"),projectId,text(row,"type"),text(row,"title"),text(row,"description"),nullable(row,"assignee_id"),text(row,"priority"),text(row,"status"),nullable(row,"planned_start_at"),nullable(row,"planned_end_at"),nullable(row,"actual_start_at"),nullable(row,"actual_end_at"),(int)number(row,"version"),flag(row,"deleted"),nullable(row,"stage_id"),nullable(row,"parent_task_id"),nullable(row,"stage_revision_id"),nullable(row,"origin_work_item_id"),nullable(row,"schedule_review_rework_id"),nullable(row,"reference_planned_start_at"),nullable(row,"reference_planned_end_at")).withCreator(nullable(row,"created_by"));
|
||||
}
|
||||
|
||||
/** 校验用户看到的版本,不把缺失版本当作覆盖最新数据的授权。 */
|
||||
@ -774,6 +905,7 @@ public class PmServiceImpl implements IPmService {
|
||||
|
||||
/** 校验普通字段、负责人及同项目有效阶段,软删除有效性由项目锁保护,时间由统一转换检查。 */
|
||||
private void validateFields(long projectId,long iterationId,ItemInput input) {
|
||||
if(input==null||input.assigneeId()==null) throw PmException.bad("请选择工作项负责人");
|
||||
required(input.title(),200,"标题"); if(input.type()==null||!Set.of("REQUIREMENT","TASK","BUG").contains(input.type())) throw PmException.bad("工作项类型无效");
|
||||
if(input.priority()!=null&&!Set.of("LOW","MEDIUM","HIGH","URGENT").contains(input.priority())) throw PmException.bad("优先级无效");
|
||||
if(input.description()!=null&&input.description().length()>50000) throw PmException.bad("描述过长"); access.assignee(projectId,input.assigneeId());
|
||||
|
||||
@ -87,9 +87,16 @@ public class PmStageCompletionServiceImpl implements IPmStageCompletionService {
|
||||
return evidence.decode(text(row,"snapshot_json"));
|
||||
}
|
||||
|
||||
/** 显式开始与工作项开始共用门禁;采购真实开始可放行直连后继,审计记录当时的上游版本事实。 */
|
||||
/**
|
||||
* 当前阶段负责人显式开始阶段,创建者和管理者不能代替执行职责。
|
||||
* @param projectId 项目成员和共享锁边界
|
||||
* @param iterationId 必须为进行中的当前迭代
|
||||
* @param stageId 锁后重读当前负责人的有效阶段
|
||||
* @param input 当前执行版本和数据版本,历史或过期请求不能开始新轮次
|
||||
* 注意:沿用前置、计划复核及冻结门禁;成功时固定启动身份并保存审计,采购开始仍可放行直连后继。
|
||||
*/
|
||||
public void start(long projectId,long iterationId,long stageId,StageCompletionInput input) {
|
||||
locked(projectId,iterationId,"start");var stage=stage(projectId,iterationId,stageId);maintainer(stage);Graph graph=graphs.load(projectId,iterationId);
|
||||
locked(projectId,iterationId,"start");var stage=stage(projectId,iterationId,stageId);owner(stage);Graph graph=graphs.load(projectId,iterationId);
|
||||
var revision=current(stage,projectId,iterationId,input);mutable(graph,stageId);admission(graph,stageId);
|
||||
if(nullable(revision,"started_at")!=null) return;
|
||||
update(revision,map("started_at",PmTime.now()));bindStartedIdentity(stage,revision);revisions.advanceGraphVersion(projectId,iterationId);groups.sync(projectId,iterationId);
|
||||
@ -242,7 +249,16 @@ public class PmStageCompletionServiceImpl implements IPmStageCompletionService {
|
||||
return capabilities(stage,revision,graph,snapshot,historical,viewer(number(stage,"project_id"),graph));
|
||||
}
|
||||
|
||||
/** 后端能力与命令共用身份及类型规则;缺负责人、创建人不可用和排期待复核均给出明确原因。 */
|
||||
/**
|
||||
* 从锁内查看者身份计算执行和交付能力,人工开始仅负责人,审批仍仅阶段创建者。
|
||||
* @param stage 已限定项目和迭代的阶段身份
|
||||
* @param revision 本次详情对应的执行版本
|
||||
* @param graph 锁内当前图,提供冻结、前置和排期复核事实
|
||||
* @param snapshot 交付证据,缺失历史证据保持只读并返回明确原因
|
||||
* @param historical 是否历史查看,历史不能获得写能力
|
||||
* @param viewer 本事务复用的成员和菜单资格,不替代命令中的重新校验
|
||||
* @return 无副作用的交付、执行和审批能力及阻塞原因
|
||||
*/
|
||||
private Map<String,Object> capabilities(Map<String,Object> stage,Map<String,Object> revision,Graph graph,Map<String,Object> snapshot,boolean historical,Viewer viewer) {
|
||||
long id=number(stage,"id"),actor=viewer.actor();boolean owner=Objects.equals(nullable(stage,"owner_id"),actor),creator=number(stage,"created_by")==actor;
|
||||
boolean writable=!historical&&viewer.writable();
|
||||
@ -256,7 +272,7 @@ public class PmStageCompletionServiceImpl implements IPmStageCompletionService {
|
||||
boolean mutable=writable&&!complete&&!pending&&!group;
|
||||
return map("deliveryReady",ready,"blockedReasons",reasons,"stageBlockedReasons",stageReasons,
|
||||
"canEditDelivery",mutable&&(owner||creator),"canEditPurchase",mutable&&purchase&&(owner||creator||viewer.manager()),
|
||||
"canStart",mutable&&admitted&&(owner||creator)&&nullable(revision,"started_at")==null,
|
||||
"canStart",mutable&&admitted&&owner&&nullable(revision,"started_at")==null,
|
||||
"canSubmit",mutable&&!purchase&&owner&&admitted&&ready,"canWithdraw",writable&&pending&&owner&&admitted,
|
||||
"canApprove",writable&&pending&&creator&&admitted,"canConfirmPurchase",mutable&&purchase&&creator&&admitted&&ready);
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import com.ruoyi.project.manage.mapper.PmWorkspaceMapper;
|
||||
import com.ruoyi.project.manage.security.PmAccess;
|
||||
import com.ruoyi.project.manage.security.PmIterationAccess;
|
||||
import com.ruoyi.project.manage.rule.PmRules;
|
||||
import com.ruoyi.project.manage.rule.PmIterationRules;
|
||||
import com.ruoyi.project.manage.rule.PmStageRules;
|
||||
import com.ruoyi.project.manage.service.IPmService;
|
||||
import com.ruoyi.project.manage.service.IPmStageService;
|
||||
@ -70,7 +71,7 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
|
||||
/**
|
||||
* 在项目锁内计算阶段状态、出边放行事实及回退能力,避免独立查询拼出过期门禁。
|
||||
* 回退能力同时考虑既有经理权限和迭代可写性;只读成员仍可看到当前阶段事实。
|
||||
* 全局结构配置限迭代创建者,阶段编辑和计划另按本阶段负责人计算,回退仍沿原经理规则。
|
||||
* @param projectId 协作内部项目 ID(非原项目 ID),先完成成员鉴权再读取摘要
|
||||
* @param iterationId 阶段和版本所属迭代,不能跨迭代混合判断
|
||||
* @return 当前迭代阶段、边及共享布局摘要;布局使用独立版本,工作项明细仍由抽屉分页读取
|
||||
@ -80,6 +81,7 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
List<Map<String,Object>> items=business.items(projectId,iterationId);
|
||||
List<Map<String,Object>> stages=stageRows(projectId,iterationId);
|
||||
Graph graph=graphService.load(projectId,iterationId);
|
||||
boolean canConfigureStages=graph.iteration()!=null&&graph.iteration().mutable()&&iterationAccess.isCreator(projectId,iterationId);
|
||||
boolean canManage=graph.iteration()!=null&&graph.iteration().mutable();
|
||||
if(canManage) {
|
||||
// 复用完整项目管理鉴权;拥有菜单权限但不是本项目经理的成员也不能获得回退能力。
|
||||
@ -87,6 +89,7 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
catch(PmException error) { if(error.getHttpStatus()!=403) throw error; canManage=false; }
|
||||
}
|
||||
boolean canWrite=graph.iteration()!=null&&graph.iteration().mutable()&&access.canWrite(projectId);
|
||||
long actor=access.actor();
|
||||
List<Map<String,Object>> definitions=stages.stream().map(stage->map("id",stage.get("id"),"project_id",projectId,"iteration_id",iterationId,"name",stage.get("name"),"node_type",stage.get("nodeType"),"stage_kind",stage.get("stageKind"),"current_revision_id",stage.get("currentRevisionId"),"created_by",stage.get("creatorId"),"owner_id",stage.get("ownerId"))).toList();
|
||||
var completionSummaries=completion.summaries(projectId,iterationId,definitions,graph);
|
||||
for(Map<String,Object> stage:stages) {
|
||||
@ -98,8 +101,15 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
stage.put("complete","COMPLETED".equals(executionStatus));
|
||||
var children=com.ruoyi.project.manage.rule.PmStageHierarchyRules.children(graph,stageId);
|
||||
boolean group=com.ruoyi.project.manage.rule.PmStageHierarchyRules.info(graph,stageId).group();
|
||||
boolean topologyMutable=canManage&&"NOT_STARTED".equals(executionStatus)&&!flag(stage,"executionHistory");
|
||||
stage.putAll(map("childStageCount",children.size(),"completedChildStageCount",children.stream().filter(child->Set.of("COMPLETED","LEGACY_PASSED").contains(PmStageRules.executionStatus(graph,child))).count(),"stagePath",com.ruoyi.project.manage.rule.PmStageHierarchyRules.path(graph,stageId),"canCreateWorkItem",canWrite&&!group&&!"PURCHASE".equals(stage.get("nodeType"))&&!"PENDING".equals(graph.stageRevisions().get(stageId).approvalStatus())&&!Set.of("COMPLETED","LEGACY_PASSED").contains(executionStatus),"canCreateChildStage",topologyMutable&&group,"canEditStructure",topologyMutable));
|
||||
boolean topologyMutable=canConfigureStages&&"NOT_STARTED".equals(executionStatus)&&!flag(stage,"executionHistory");
|
||||
boolean owner=Objects.equals(nullable(stage,"ownerId"),actor);
|
||||
stage.put("canAddReworkItems",owner&&canWrite&&!group&&!"PURCHASE".equals(stage.get("nodeType"))&&graph.iteration()!=null&&graph.iteration().mutable());
|
||||
boolean pending="PENDING".equals(graph.stageRevisions().get(stageId).approvalStatus());
|
||||
boolean complete=Set.of("COMPLETED","LEGACY_PASSED").contains(executionStatus);
|
||||
boolean canEdit=graph.iteration()!=null&&graph.iteration().mutable()&&(canConfigureStages||owner)&&!pending;
|
||||
// 已完成阶段仍可能缺失历史计划;这里只给出计划身份资格,补录入口继续校验一次性补录约束。
|
||||
stage.putAll(map("canEditStage",canEdit&&!complete,"canScheduleStage",canEdit));
|
||||
stage.putAll(map("childStageCount",children.size(),"completedChildStageCount",children.stream().filter(child->Set.of("COMPLETED","LEGACY_PASSED").contains(PmStageRules.executionStatus(graph,child))).count(),"stagePath",com.ruoyi.project.manage.rule.PmStageHierarchyRules.path(graph,stageId),"canCreateWorkItem",canWrite&&owner&&!group&&!"PURCHASE".equals(stage.get("nodeType"))&&!pending&&!complete,"canCreateChildStage",topologyMutable&&group,"canEditStructure",topologyMutable));
|
||||
stage.putAll(completionSummaries.get(stageId));
|
||||
stage.put("blockedReasons",PmStageRules.blockedStage(graph,stageId));
|
||||
List<Map<String,Object>> reworkBlocked=PmStageRules.reworkBlocked(graph,stageId);
|
||||
@ -116,11 +126,11 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
}).toList();
|
||||
List<Map<String,Object>> reworkEdges=schedules.selectReworkEdges(projectId,iterationId);
|
||||
for(Map<String,Object> edge:reworkEdges) edge.put("latestReworkAt",PmTime.format(nullable(edge,"latestReworkAt"),"Asia/Shanghai"));
|
||||
return map("reworkEdges",reworkEdges,"iterationId",iterationId,"graphVersion",number(revisionMapper.selectGraphVersion(projectId,iterationId),"graph_version"),"stages",stages,"stageEdges",stageEdges,"unassigned",summary(items,null,graph),"items",List.of(),"dependencies",List.of(),"layout",layouts.get(projectId,iterationId));
|
||||
return map("canConfigureStages",canConfigureStages,"reworkEdges",reworkEdges,"iterationId",iterationId,"graphVersion",number(revisionMapper.selectGraphVersion(projectId,iterationId),"graph_version"),"stages",stages,"stageEdges",stageEdges,"unassigned",summary(items,null,graph),"items",List.of(),"dependencies",List.of(),"layout",layouts.get(projectId,iterationId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时固定节点分类,在项目锁内原子保存阶段、首版计划、父级组合、历史及事件。
|
||||
* 迭代创建者在项目锁内固定节点分类并原子保存阶段、首版计划、父级组合、历史及事件。
|
||||
* @param projectId 已鉴权的协作项目 ID
|
||||
* @param iterationId 明确的可编辑迭代,不能跨迭代指定父级
|
||||
* @param input 固定分类、可编辑名称和整日计划;仅 GROUP 可承载子阶段
|
||||
@ -157,15 +167,15 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在统一项目锁内按版本编辑名称、负责人及说明,节点分类和 WORK/GROUP 结构不允许转换。
|
||||
* 迭代创建者或本阶段当前负责人在项目锁内按版本编辑元数据,固定分类和 WORK/GROUP 结构不能转换。
|
||||
* @param projectId 阶段所属的协作项目 ID
|
||||
* @param iterationId 所属可编辑迭代,权限与版本均在持锁后复查
|
||||
* @param iterationId 所属可编辑迭代,真实创建者、当前负责人及版本均在持锁后复查
|
||||
* @param id 需要编辑的有效阶段 ID
|
||||
* @param input 元数据及当前版本;改期和父级迁移必须使用既有专用入口
|
||||
* 注意:分类变更或旧版本请求会被拒绝并回滚,历史与事件仅随成功编辑提交。
|
||||
*/
|
||||
public void editStage(long projectId,long iterationId,long id,StageInput input) {
|
||||
locked(projectId,iterationId,"admin"); Map<String,Object> existing=stage(projectId,iterationId,id); version(input.version(),(int)number(existing,"version")); validateStage(projectId,input);
|
||||
Map<String,Object> existing=lockEditableStage(projectId,iterationId,id); version(input.version(),(int)number(existing,"version")); validateStage(projectId,input);
|
||||
Graph before=graphService.load(projectId,iterationId),after=before.copy();
|
||||
String kind=text(existing,"stage_kind");
|
||||
StageNodeType existingType=StageNodeType.resolve(text(existing,"node_type"),kind);
|
||||
@ -179,6 +189,8 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
PmRules.validateAcyclic(after); PmStageRules.validateExecutedAncestors(before,after);
|
||||
stageMapper.updateStage(id,(int)number(existing,"version"),map("name",input.name().trim(),"sort_order",input.sortOrder()==null?0:input.sortOrder(),"owner_id",input.ownerId(),"description",input.description()));
|
||||
stageMapper.refreshDraftRevisionIdentity(number(existing,"current_revision_id"),kind,nullable(existing,"parent_stage_id"),input.description());
|
||||
// 显式提交批次仍代表维护或重新确认交付范围;即使批次未变化也须保留原权限、确认及审计语义。
|
||||
// 仅编辑阶段元数据时由调用方省略批次字段,避免迭代配置资格隐式授予采购维护职责。
|
||||
if(existingType==StageNodeType.PURCHASE&&input.purchaseBatchIds()!=null) {
|
||||
var r=revisionMapper.selectRevision(projectId,iterationId,id,number(existing,"current_revision_id"));
|
||||
completion.batches(projectId,iterationId,id,new com.ruoyi.project.manage.dto.StagePurchaseInput(number(r,"id"),(int)number(r,"version"),input.purchaseBatchIds()));
|
||||
@ -189,15 +201,14 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
|
||||
/**
|
||||
* 仅更新当前阶段名称,兼容历史未设置负责人的节点;不借快捷入口改动交付或固定类型。
|
||||
* @param projectId 阶段所属协作项目,管理权限在项目锁前后复查
|
||||
* @param projectId 阶段所属协作项目,成员在锁前后检查,迭代创建者或当前阶段负责人在锁内重新读取
|
||||
* @param iterationId 明确的可写迭代范围
|
||||
* @param id 当前有效阶段标识
|
||||
* @param input 名称及预期阶段版本;空名称、过期版本和已冻结版本均拒绝
|
||||
* 注意:项目锁覆盖版本检查、名称写入及定义快照/审计;历史执行快照不随改名重写。
|
||||
*/
|
||||
public void renameStage(long projectId,long iterationId,long id,StageNameInput input) {
|
||||
locked(projectId,iterationId,"admin");
|
||||
Map<String,Object> existing=stage(projectId,iterationId,id);
|
||||
Map<String,Object> existing=lockEditableStage(projectId,iterationId,id);
|
||||
if(input==null||input.name()==null||input.name().isBlank()||input.name().trim().length()>120) throw PmException.bad("阶段名称需为 1—120 个字符");
|
||||
version(input.version(),(int)number(existing,"version"));
|
||||
PmStageRules.requireDeliveryMutable(graphService.load(projectId,iterationId),id);
|
||||
@ -207,7 +218,14 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
auditService.record(projectId,iterationId,null,"STAGE_EDITED",map("stageId",id,"name",input.name().trim()),access.actor());
|
||||
}
|
||||
|
||||
/** 非空阶段拒绝删除;空阶段的连线先移除,再软删阶段并原子保存历史与事件。 */
|
||||
/**
|
||||
* 迭代创建者仅可删除无工作项、子阶段及交付内容的阶段,避免有效业务记录失去入口。
|
||||
* @param projectId 已锁定的协作项目,成员及迭代创建者身份均由服务复验
|
||||
* @param iterationId 目标阶段所属的可写迭代
|
||||
* @param id 当前有效阶段标识,不能跨项目或迭代操作
|
||||
* @param input 预期阶段版本,过期请求不能删除其他人的新配置
|
||||
* 注意:移除连线、软删除、组版本绑定、定义快照及审计处于同一事务,失败全部回滚。
|
||||
*/
|
||||
public void deleteStage(long projectId,long iterationId,long id,VersionInput input) {
|
||||
locked(projectId,iterationId,"admin"); Map<String,Object> existing=stage(projectId,iterationId,id); version(input.version(),(int)number(existing,"version"));
|
||||
if(!com.ruoyi.project.manage.rule.PmStageHierarchyRules.children(graphService.load(projectId,iterationId),id).isEmpty()) throw PmException.conflict("STAGE_NOT_EMPTY","阶段组仍有子阶段,不能删除");
|
||||
@ -230,9 +248,10 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目管理者在共享图中建立阶段执行边;项目锁串行化两个并发加边请求,
|
||||
* 迭代创建者在共享图中建立阶段执行边;项目锁串行化两个并发加边请求,
|
||||
* 最终图同时检查阶段环、任务跨阶段死锁和已开始工作项的新阻塞。
|
||||
* @param projectId 协作内部项目 ID(非原项目 ID)
|
||||
* @param iterationId 创建者配置的明确迭代范围
|
||||
* @param input 当前项目内两个有效阶段 ID
|
||||
* @return 新阶段边 ID;失败时不写入历史或 outbox
|
||||
*/
|
||||
@ -251,7 +270,14 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
auditService.record(projectId,iterationId,null,"STAGE_EDGE_CREATED",map("edgeId",id,"predecessorStageId",source,"successorStageId",target),access.actor()); return id;
|
||||
}
|
||||
|
||||
/** 管理者按当前边版本断开阶段;移除约束不会令已开始任务新增阻塞。 */
|
||||
/**
|
||||
* 迭代创建者在项目锁内按当前边版本断开阶段,最终图仍须保留已执行阶段的结构约束。
|
||||
* @param projectId 共享图及成员范围所属项目
|
||||
* @param iterationId 当前可配置迭代,创建者身份在锁内重读
|
||||
* @param edgeId 当前迭代内的有效执行边
|
||||
* @param input 预期边版本,防止过期画布覆盖新配置
|
||||
* 注意:成功删除与定义快照、审计原子提交,冻结或版本冲突时不留下部分修改。
|
||||
*/
|
||||
public void deleteEdge(long projectId,long iterationId,long edgeId,VersionInput input) {
|
||||
locked(projectId,iterationId,"admin");
|
||||
Graph before=graphService.load(projectId,iterationId),after=before.copy();
|
||||
@ -268,9 +294,18 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
business.assignStage(id,input);
|
||||
}
|
||||
|
||||
/** 预览/提交明确的结构最终态;只迁移未执行阶段,全部边由管理者明确提供,不自动重写跨层语义。 */
|
||||
/**
|
||||
* 迭代创建者预览或提交明确的结构最终态,不自动猜测跨层连线语义。
|
||||
* 在同一项目锁内构造候选层级及完整连线,校验无环、排期和已执行祖先后才允许提交。
|
||||
* @param projectId 结构及共享图锁所属项目
|
||||
* @param iterationId 明确的可写迭代,预览与提交均重新校验真实创建者
|
||||
* @param input 预期图版本、未执行阶段移动及完整连线集合
|
||||
* @param commit true 原子保存层级、连线、定义快照及审计;false 仅计算候选结果
|
||||
* @return 当前图版本、候选移动及连线和是否已提交;预览不推进图版本或写成功历史
|
||||
* 注意:历史执行过的阶段不能借回退生成的新版本解除层级保护;任何失败均整体回滚。
|
||||
*/
|
||||
public Map<String,Object> structure(long projectId,long iterationId,com.ruoyi.project.manage.dto.StageStructureInput input,boolean commit) {
|
||||
locked(projectId,iterationId,"read"); access.project(projectId,"admin"); iterationAccess.require(projectId,iterationId,"admin");
|
||||
locked(projectId,iterationId,"read"); iterationAccess.requireCreator(projectId,iterationId,"admin");
|
||||
long graphVersion=number(revisionMapper.selectGraphVersion(projectId,iterationId),"graph_version");
|
||||
if(input==null||input.graphVersion()==null||input.graphVersion()!=graphVersion) throw PmException.conflict("GRAPH_VERSION_CONFLICT","流程已变化,请刷新结构后重新预览");
|
||||
if(input.stages()==null||input.edges()==null||input.stages().size()>200||input.edges().size()>1000) throw PmException.bad("请提交阶段移动和完整连线列表");
|
||||
@ -347,8 +382,39 @@ public class PmStageServiceImpl implements IPmStageService {
|
||||
|
||||
/** 在已锁定项目中限定有效阶段,不向跨项目调用泄露名称。 */
|
||||
private Map<String,Object> stage(long projectId,long iterationId,long id) { Map<String,Object> row=stageMapper.selectActiveStage(id,projectId,iterationId); if(row==null) throw PmAccess.denied(); return row; }
|
||||
/** 项目锁覆盖权限重查、归属校验和历史/outbox;所有相关写入具有相同锁序。 */
|
||||
private void locked(long projectId,long iterationId,String action) { access.project(projectId,action); workspaceMapper.lockProject(projectId); access.project(projectId,action); iterationAccess.require(projectId,iterationId,action); if("admin".equals(action)) revisionMapper.advanceGraphVersion(projectId,iterationId); }
|
||||
/**
|
||||
* 在固定项目锁序下重读阶段编辑身份,避免等待锁期间转交负责人后旧窗口继续修改。
|
||||
* @param projectId 有效项目成员边界,编辑保留原配置入口的菜单读取权限
|
||||
* @param iterationId 显式迭代范围,创建者以不可变 created_by 为准
|
||||
* @param stageId 同项目同迭代的有效阶段,负责人只能编辑自己负责的阶段
|
||||
* @return 锁内读取的阶段行;无权返回403,只读迭代沿用原生命周期冲突
|
||||
* 注意:仅鉴权通过后推进图版本,阶段冻结、业务版本和定义快照仍由调用方在同一事务内处理。
|
||||
*/
|
||||
private Map<String,Object> lockEditableStage(long projectId,long iterationId,long stageId) {
|
||||
access.project(projectId,"read"); workspaceMapper.lockProject(projectId); access.project(projectId,"read");
|
||||
Map<String,Object> iteration=iterationAccess.require(projectId,iterationId,"read");
|
||||
Map<String,Object> existing=stage(projectId,iterationId,stageId);
|
||||
long actor=access.actor();
|
||||
if(!Objects.equals(nullable(iteration,"created_by"),actor)&&!Objects.equals(nullable(existing,"owner_id"),actor)) throw PmAccess.denied();
|
||||
PmIterationRules.requireAction(text(iteration,"status"),nullable(iteration,"archived_at")!=null,"admin");
|
||||
revisionMapper.advanceGraphVersion(projectId,iterationId);
|
||||
return existing;
|
||||
}
|
||||
/**
|
||||
* 按统一锁序校验成员范围,锁内重读迭代身份后才允许阶段配置或推进图版本。
|
||||
* @param projectId 成员边界及项目图锁所属项目
|
||||
* @param iterationId 显式迭代范围,配置不能借项目经理资格越过真实创建者身份
|
||||
* @param action admin 表示阶段配置,其余动作保留原成员和生命周期规则
|
||||
* 注意:调用方事务覆盖业务、历史及 outbox;锁等待期间身份变化会在取得锁后生效。
|
||||
*/
|
||||
private void locked(long projectId,long iterationId,String action) {
|
||||
String permission="admin".equals(action)?"read":action;
|
||||
access.project(projectId,permission); workspaceMapper.lockProject(projectId); access.project(projectId,permission);
|
||||
if("admin".equals(action)) {
|
||||
iterationAccess.requireCreator(projectId,iterationId,action);
|
||||
revisionMapper.advanceGraphVersion(projectId,iterationId);
|
||||
} else iterationAccess.require(projectId,iterationId,action);
|
||||
}
|
||||
/** 每次图定义变动记录阶段与边的只读快照,已启动轮次仍指向启动时的定义版本。 */
|
||||
private long snapshotDefinition(long projectId,long iterationId) {
|
||||
Map<String,Object> latest=revisionMapper.selectLatestDefinition(projectId,iterationId);
|
||||
|
||||
@ -36,7 +36,7 @@ public class PmGraphService {
|
||||
* 所有查询都绑定迭代,分页或甘特可见窗口不能削减业务校验范围。
|
||||
* @param projectId 所属协作项目
|
||||
* @param iterationId 明确的迭代 ID;不接受其他项目迭代
|
||||
* @return 带迭代状态的工作项、协作分工、父子、依赖和阶段快照,不缓存门禁结果
|
||||
* @return 带迭代状态的工作项、协作分工、父子、依赖和阶段快照;真实创建人随工作项批量加载,不缓存门禁
|
||||
*/
|
||||
public Graph load(long projectId,long iterationId) {
|
||||
Map<String,Object> iteration=iterationMapper.selectIteration(projectId,iterationId);
|
||||
@ -44,7 +44,7 @@ public class PmGraphService {
|
||||
Map<Long,Item> items=new LinkedHashMap<>();
|
||||
var collaborators=participants.load(projectId,iterationId,null);
|
||||
for(Map<String,Object> r:workItemMapper.selectGraphItems(projectId,iterationId)) {
|
||||
Item item=new Item(number(r,"id"),projectId,text(r,"type"),text(r,"title"),text(r,"description"),nullable(r,"assignee_id"),text(r,"priority"),text(r,"status"),nullable(r,"planned_start_at"),nullable(r,"planned_end_at"),nullable(r,"actual_start_at"),nullable(r,"actual_end_at"),(int)number(r,"version"),flag(r,"deleted"),nullable(r,"stage_id"),nullable(r,"parent_task_id"),nullable(r,"stage_revision_id"),nullable(r,"origin_work_item_id"),nullable(r,"schedule_review_rework_id"),nullable(r,"reference_planned_start_at"),nullable(r,"reference_planned_end_at")); items.put(item.id(),item);
|
||||
Item item=new Item(number(r,"id"),projectId,text(r,"type"),text(r,"title"),text(r,"description"),nullable(r,"assignee_id"),text(r,"priority"),text(r,"status"),nullable(r,"planned_start_at"),nullable(r,"planned_end_at"),nullable(r,"actual_start_at"),nullable(r,"actual_end_at"),(int)number(r,"version"),flag(r,"deleted"),nullable(r,"stage_id"),nullable(r,"parent_task_id"),nullable(r,"stage_revision_id"),nullable(r,"origin_work_item_id"),nullable(r,"schedule_review_rework_id"),nullable(r,"reference_planned_start_at"),nullable(r,"reference_planned_end_at")).withCreator(nullable(r,"created_by")); items.put(item.id(),item);
|
||||
}
|
||||
items.replaceAll((id,item)->item.withCollaborators(collaborators.getOrDefault(id,List.of())));
|
||||
// 两种条件标识表达同一工作项完成规则;历史任务条件与新增统一条件必须一起参与图校验。
|
||||
|
||||
@ -56,7 +56,7 @@ manage/
|
||||
|
||||
## 工作项分工与前置条件
|
||||
|
||||
流程画布的共享布局方案、数据边界、接口和验证记录见 [流程共享布局](docs/shared-flow-layout.md)。节点坐标、分区和排版结果按项目、迭代共用,仅由迭代创建者维护,其他成员(含其他项目管理者)只读数据库布局;阶段组父子关系、执行连线及回退记录继续由现有业务表保存。流程视图不再恢复或写入浏览器缓存,旧流程缓存直接清理;框选、辅助线、缩放平移和展开折叠仅作为当前组件的临时状态。
|
||||
流程画布的共享布局方案、数据边界、接口和验证记录见 [流程共享布局](docs/shared-flow-layout.md)。节点坐标、分区和排版结果按项目、迭代共用,仅由迭代创建者维护;节点生成、连线、框选/多选及分组也限定该创建者,其他成员(含其他项目管理者)只读数据库布局。阶段组父子关系、执行连线及回退记录继续由现有业务表保存。流程视图不再恢复或写入浏览器缓存,旧流程缓存直接清理;所有成员可临时平移、缩放、展开折叠及查看详情,浏览动作不保存。页面刷新或显式重新加载成功后恢复数据库坐标、统一展开及默认视口,后台静默同步保留当前浏览状态。
|
||||
|
||||
- 阶段节点展示已有描述的两行摘要,完整说明在阶段抽屉查看;拖入新阶段时可填写描述。
|
||||
- 采购当前执行版本记录实际开始后即放行直接下游,蓝色连线标注“开始即放行”;采购仍须验收及人工确认才算完成。绿色表示真实完成,历史沿用保持琥珀色;多条入边须全部满足,阶段组仍须全部子阶段完成。详情展示服务端完整准入条件(含继承门禁),排期分别标示采购开始至开始、其他执行边结束至开始边界。
|
||||
@ -64,9 +64,10 @@ manage/
|
||||
- 节点分类创建后固定,名称、负责人和说明可编辑;只有阶段组承载子阶段,其余分类沿用工作阶段规则。组内快捷创建可在提交前选择工作分类;复制迭代保留来源分类,回退换版沿用同一节点身份。
|
||||
- 已有数据库上线前执行 `ruoyi-project/sql/upgrade/022_stage_node_types.sql`;脚本可重复执行,已有工作阶段标为普通阶段,已有组标为阶段组,不改动排期、执行版本或工作项。新安装结构已包含分类字段和组合约束。
|
||||
- 已完成 023 的数据库执行 `ruoyi-project/sql/upgrade/024_custom_stage_node.sql` 开放自定义类型;该升级只扩展类型约束及中文字段注释,不转换历史节点分类。
|
||||
- 项目管理者可通过节点名称后的编辑图标快捷改名,接口只接收名称和阶段版本;审批中或已完成版本仍只读。节点右上角删除图标与阶段管理表共用保护条件,已有执行历史、工作项、子阶段、交付附件或采购批次时禁用并说明原因,后端仍持锁复验后软删除。
|
||||
- 阶段新增、删除、层级/连线及画布布局仅迭代创建者维护;编辑、改名及阶段排期允许迭代创建者或该阶段负责人。人工开始及提交/撤回审批仅阶段负责人,审批通过/驳回仅阶段创建者。快捷改名只接收名称和阶段版本,冻结保护不变;已有执行历史、工作项、子阶段、交付附件或采购批次时仍不能删除。
|
||||
- 新建和编辑工作项可从项目成员中多选协作人,负责人仍为单选。协作分工不改变项目角色或访问权限,历史版本保留原分工;回退复制仅继承仍有效的成员,并在预览中说明移除项。
|
||||
- 工作项及子任务仅当前负责人可以开始或进入已完成;未分配负责人、创建者、协作人和项目管理者身份均不额外授予执行资格。关闭后重开到已完成同样受此限制,其余编辑、排期、关闭、取消及回退规则保持原样。看板和详情使用服务端执行能力,服务端在项目锁内重新验证身份及完整准入条件。
|
||||
- 工作项及子任务的新增、编辑、删除、分工/前置、归属和创建子任务由所属阶段负责人维护;开始、完成、关闭、取消等状态操作仅工作项负责人;排期/复核允许工作项负责人或本工作项创建者,必须在有效阶段计划内,子任务同时受父任务约束。评论与上传附件仅工作项负责人或协作人;附件删除保留仅工作项负责人。各能力独立,项目管理或系统管理身份不额外获得资格。
|
||||
- 新建工作项、子任务及回退人工补录须选择负责人,新建所属阶段只能选择本人负责的有效工作阶段。旧项保留迭代创建者仅补齐缺失阶段/负责人的专用入口;补归属只允许待开始根项及其同样待开始、未归属的子任务,不能覆盖已有值或借此普通编辑。阶段负责人仍可补分配本阶段未分配项。普通编辑保持旧计划,调整时间使用独立排期入口。历史、终态与冻结仍只读,待审批保留讨论;未列出的阶段交付、采购及回退职责保持原规则,回退自动复制不改变,人工补录则检查被新增阶段的负责人。完整规则见 [工作项与阶段配置权限](docs/object-permissions.md)。
|
||||
- 新建工作项可选多个同迭代前置工作项,需求、任务、缺陷均可作为依赖两端。所有前置已完成或已关闭才满足条件,取消不满足;编辑依赖仍使用详情中的专用入口。
|
||||
- 依赖、工作项和协作分工在同一项目锁事务中保存,继续共用实际开始、排期及混合执行图环检测。新建表单排期提示由后端约束预览计算,提交时重新验证。
|
||||
- 已有数据库先完成 `ruoyi-project/sql/upgrade/016_work_item_collaboration.sql` 增量升级;该文件新增协作人关联表并兼容新旧依赖标识,保留已有工作项与排期。全新环境使用 `ruoyi-project/sql/project_collaboration.sql`。
|
||||
|
||||
@ -17,6 +17,8 @@ export const workItemApi = {
|
||||
children: (id: number) => request<WorkItem[]>('get', `/items/${id}/children`),
|
||||
/** 编辑白名单字段,后端同时校验时间。 */
|
||||
edit: (id: number, input: ItemInput) => request<void>('patch', `/items/${id}`, input),
|
||||
/** 已有未分配项由阶段负责人或迭代创建者补齐;只提交负责人和版本,不能修改其他字段。 */
|
||||
assignAssignee: (id: number, assigneeId: number, version: number) => request<void>('patch', `/items/${id}/assignee`, { assigneeId, version }),
|
||||
/** 唯一实际开始接口,看板和批量 UI 也必须调用。 */
|
||||
start: (id: number, version: number) => request<void>('post', `/items/${id}/start`, { version }),
|
||||
/** 状态转换进入进行中时服务端再次调用统一开始逻辑。 */
|
||||
@ -27,7 +29,7 @@ export const workItemApi = {
|
||||
dependency: (id: number, input: Record<string, unknown>, depId?: number) => request<number>(depId ? 'patch' : 'post', `/items/${id}/dependencies${depId ? `/${depId}` : ''}`, input),
|
||||
/** 待开始任务可删除前置;提交时仍由后端确认。 */
|
||||
removeDependency: (id: number, dependencyId: number, taskVersion: number, version: number) => request<void>('delete', `/items/${id}/dependencies/${dependencyId}`, { taskVersion, version }),
|
||||
/** 明确移动阶段,位置拖动绝不调用此业务接口。 */
|
||||
/** 阶段负责人迁移或创建者补齐缺失归属,只提交阶段及版本;位置拖动绝不调用此接口。 */
|
||||
assignStage: (item: WorkItem, stageId: number | null) => request<void>('patch', `/items/${item.id}/stage`, { stageId, version: item.version }),
|
||||
/** 新增评论只保存文本,显示时由 Vue 转义。 */
|
||||
comment: (id: number, body: string) => request<void>('post', `/items/${id}/comments`, { body }),
|
||||
@ -37,6 +39,6 @@ export const workItemApi = {
|
||||
data.append('file', file)
|
||||
return request<number>('post', `/items/${id}/attachments`, data)
|
||||
},
|
||||
/** 删除必须同时绑定工作项和附件,服务端重新校验负责人、创建者及当前可写范围。 */
|
||||
/** 删除必须同时绑定工作项和附件,服务端重新校验当前负责人及可写范围。 */
|
||||
removeAttachment: (itemId: number, attachmentId: number) => request<void>('delete', `/items/${itemId}/attachments/${attachmentId}`),
|
||||
}
|
||||
|
||||
@ -57,8 +57,10 @@ export function useProjectCollaboration() {
|
||||
const zone = 'Asia/Shanghai'
|
||||
|
||||
const canWrite = computed(() => !!current.value?.canWrite && !iterationReadOnly(selectedIteration.value))
|
||||
const canCreate = computed(() => !!current.value?.canCreate && !iterationReadOnly(selectedIteration.value))
|
||||
const canCreate = computed(() => !!current.value?.canCreate && !iterationReadOnly(selectedIteration.value) && !!flowView.value?.stages.some(stage => stage.canCreateWorkItem === true))
|
||||
const canExecute = computed(() => canWrite.value && iterationCanExecute(selectedIteration.value))
|
||||
/** 批量入口允许具备任一阶段排期能力的成员进入,提交仍逐行复验。 */
|
||||
const canSchedule = computed(() => canWrite.value || !!flowView.value?.stages.some(stage => stage.canScheduleStage === true))
|
||||
|
||||
const loading = ref(false)
|
||||
const failure = ref('')
|
||||
@ -432,24 +434,28 @@ export function useProjectCollaboration() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 新建只预选阶段,编辑保留服务端原归属。 */
|
||||
/** 新建只预选服务端明确允许的本人阶段;编辑继续复验对象能力与当前范围。 */
|
||||
function openEditor(item: WorkItem | null, stageId: number | null = null) {
|
||||
if (item ? !canWrite.value : !canCreate.value) return
|
||||
if (item ? !canWrite.value || item.canEditWorkItem !== true || !inScope(item) : !canCreate.value) return
|
||||
if (!item && stageId !== null && !flowView.value?.stages.some(stage => stage.id === stageId && stage.canCreateWorkItem === true)) return
|
||||
creatingParent.value = null
|
||||
editing.value = item
|
||||
defaultStageId.value = item ? null : stageId
|
||||
editorOpen.value = true
|
||||
}
|
||||
|
||||
/** 子任务保存仍提交父版本并由后端验证阶段与排期。 */
|
||||
/** 父对象必须属于当前范围且明确允许创建子任务;保存提交父版本并由后端复验。 */
|
||||
function openChildEditor(parent: WorkItem) {
|
||||
if (!parent.canCreateChild || !canWrite.value) return
|
||||
if (parent.canCreateChild !== true || !canWrite.value || !inScope(parent)) return
|
||||
editing.value = null
|
||||
creatingParent.value = parent
|
||||
defaultStageId.value = parent.stageId ?? null
|
||||
editorOpen.value = true
|
||||
}
|
||||
|
||||
/** 事件携带的工作项必须属于当前项目和迭代,切换后的旧行事件不得打开或操作另一范围。 */
|
||||
function inScope(item: WorkItem): boolean { return item.projectId === projectId.value && item.iterationId === iterationId.value }
|
||||
|
||||
/** 保存后只在原导航范围打开详情;刷新期间切换迭代或离页后不恢复旧工作项。 */
|
||||
async function saved(id: number) {
|
||||
const navigation = navigationSequence
|
||||
@ -468,7 +474,7 @@ export function useProjectCollaboration() {
|
||||
* @param item 当前列表快照,提交其版本;服务端再次校验改派和执行条件,拒绝后刷新真实状态。
|
||||
*/
|
||||
async function startOne(item: WorkItem) {
|
||||
if (!canExecute.value || !item.canStart || busy.value) return
|
||||
if (!canExecute.value || !inScope(item) || item.canExecuteWorkItem !== true || !item.canStart || busy.value) return
|
||||
busy.value = true
|
||||
try {
|
||||
await api.start(item.id, item.version)
|
||||
@ -493,7 +499,7 @@ export function useProjectCollaboration() {
|
||||
try {
|
||||
for (const item of [...selection.value]) {
|
||||
if (!active || scope !== scopeSequence || !canExecute.value) break
|
||||
if (!item.canStart) { errors.push(`${item.title}:${item.blockedReasons.map(reason => reason.message || reason.sourceName).filter(Boolean).join(';') || '当前无法开始'}`); continue }
|
||||
if (!inScope(item) || item.canExecuteWorkItem !== true || !item.canStart) { errors.push(`${item.title}:${item.blockedReasons.map(reason => reason.message || reason.sourceName).filter(Boolean).join(';') || '当前无法开始'}`); continue }
|
||||
try {
|
||||
await api.start(item.id, item.version)
|
||||
succeeded++
|
||||
@ -544,9 +550,9 @@ export function useProjectCollaboration() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 仅编辑当前页已加载工作项,轮询不覆盖未提交的排期草稿。 */
|
||||
/** 批量入口由工作项写范围或任一阶段排期能力准入,不能把入口资格当成所有行的授权。 */
|
||||
function openBatch() {
|
||||
if (canWrite.value) batchOpen.value = true
|
||||
if (canSchedule.value) batchOpen.value = true
|
||||
}
|
||||
|
||||
/** 后台请求开始和提交时都检查交互状态,防止请求途中打开的编辑或拖动被旧快照打断。 */
|
||||
@ -603,11 +609,14 @@ export function useProjectCollaboration() {
|
||||
watch([canWrite, canCreate], ([writable, creatable]) => {
|
||||
if (editing.value || creatingParent.value ? !writable : !creatable) editorOpen.value = false
|
||||
if (!writable) {
|
||||
batchOpen.value = false
|
||||
if (!canSchedule.value) batchOpen.value = false
|
||||
selection.value = []
|
||||
}
|
||||
})
|
||||
|
||||
/** 全部排期入口失权才关闭批量草稿;阶段行能力仍由弹窗独立更新。 */
|
||||
watch(canSchedule, allowed => { if (!allowed) batchOpen.value = false })
|
||||
|
||||
/** 浏览器导航恢复同项目迭代和待办目标;只有鉴权读取归属后才打开定位详情。 */
|
||||
watch(() => route?.query, async value => {
|
||||
if (!active || route.path !== pagePath || Number(value?.sourceProjectId) !== sourceProjectId.value) return
|
||||
@ -733,7 +742,7 @@ export function useProjectCollaboration() {
|
||||
|
||||
return {
|
||||
projectId, iterations, iterationId, includeArchived,
|
||||
items, members, flowView, current, selectedIteration, zone, canWrite, canCreate, canExecute,
|
||||
items, members, flowView, current, selectedIteration, zone, canWrite, canCreate, canExecute, canSchedule,
|
||||
loading, failure, tab, keyword, typeFilter, blockedOnly, stageFilter, detailId, focusedItem, focusedStageId, targetFailure, refreshKey, selection,
|
||||
editing, editorOpen, creatingParent, defaultStageId, page, pageSize, total, boardCounts,
|
||||
ganttFrom, ganttTo, ganttMemberIds, boardMemberIds, ganttExportQuery, ganttExportFilters, membersOpen, inviteUser, inviteRole, userCandidates, batchOpen,
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
# 工作项负责人及迭代阶段配置权限实施规范
|
||||
|
||||
## 角色拆分规范
|
||||
|
||||
目标:按用户本轮五项明确要求区分阶段配置、阶段执行、工作项维护、工作项执行、协作和排期身份,避免单个 `canWrite` 或 `canEditWorkItem` 承担所有动作。
|
||||
|
||||
范围仅 `ruoyi-project` 和本前端目录;不变更数据库结构、旧业务数据、迭代生命周期、节点类型或通知机制,不提交或推送代码。
|
||||
|
||||
| 操作 | 本轮确认身份 |
|
||||
| --- | --- |
|
||||
| 新增/删除阶段;层级、连线、布局 | 迭代创建者,结构与布局继续原规则 |
|
||||
| 阶段编辑、快捷改名、阶段计划编辑 | 迭代创建者或该阶段当前负责人 |
|
||||
| 人工开始阶段、提交/撤回完成申请 | 该阶段当前负责人 |
|
||||
| 审批通过/驳回 | 该阶段创建者 |
|
||||
| 工作项新增、编辑、删除、协作分工/前置、子任务创建、阶段迁移 | 所属阶段当前负责人;迁移同时检查目标阶段资格 |
|
||||
| 工作项开始、完成、关闭、取消、状态回退 | 工作项当前负责人 |
|
||||
| 工作项评论、上传附件 | 工作项当前负责人或当前协作人 |
|
||||
| 工作项排期、复核 | 工作项当前负责人或该工作项不可变创建者 |
|
||||
|
||||
新建工作项的所属阶段只能选择当前登录用户负责且允许承载工作项的有效阶段。普通编辑与排期分离:无排期资格的阶段负责人编辑正文、分工等时保留原时间;直接 API 试图同时改期也要拒绝。已有排期保留原精度,新建/主动改期继续整日。主动写入工作项排期必须有所属阶段完整且有效的计划,所有已填写端点都在该区间内,子任务同时受父任务约束。只改变元数据不重写未变化的旧计划。
|
||||
|
||||
边界:锁前锁后成员鉴权;取得项目锁后读取真实负责人、创建者与分工;批量逐项校验全部通过才写入。历史、软删除、归档/结束迭代、待审及已完成阶段仍保留冻结;阶段审批证据、依赖与父子规则不放宽。创建人随候选图变换保留,不能以 origin_work_item_id 的旧创建人代替新版本创建人。
|
||||
|
||||
实现计划:
|
||||
|
||||
1. 为明确的角色矩阵建立真实服务/组件回归,观察现有拒绝或越权,再按动作拆后端守卫与能力。
|
||||
2. 工作项快照加入已有 `created_by`,使用纯权限规则共用阶段维护、排期及协作判断,避免逐行查询创建人。
|
||||
3. 阶段服务分离全局创建者配置能力和逐阶段编辑/排期能力,审批继续独立身份判断;前端各视图及表单逐项接线。
|
||||
4. 测试旧窗口失权、锁后转交、批量混入无权行、隐式编辑改期、范围边界及原职责回归;运行编译、严格类型和构建并审查,再清理所有临时验证文件。
|
||||
|
||||
验收:五项用户要求逐项通过服务与组件角色矩阵;能力输出与命令鉴权一致,无管理身份越权、无部分批量写入、无超阶段计划,注释与本轮规则一致。
|
||||
|
||||
用户补充“全部采用推荐”后,以下规则已确认(RCS 100,RRS 55):阶段回退、交付材料和采购批次维护继续原职责;工作项附件删除仍仅工作项负责人。新建必须归属本人负责的阶段;旧项保留迭代创建者仅补归属/补负责人的修复例外。
|
||||
|
||||
修复例外独立于普通维护能力:仅当前有效迭代创建者可为缺少所属阶段的待开始根工作项补入同迭代有效工作阶段,子任务继续继承;仅缺少负责人时可补负责人。每个入口仅接收目标字段与乐观版本,不允许覆盖已有值,也不开放正文、分工、排期、状态等字段。已有归属及负责人均齐备后,全部恢复本表普通职责。创建者仍须有效项目成员,历史、软删除、只读迭代及阶段冻结不解除;此专用修复身份不要求普通项目写角色。
|
||||
|
||||
补充实施计划:复现创建者修复误拒;复用严格专用API并新增独立修复能力,前端只在旧项缺失时显示入口,普通新建仍只列本人负责阶段。验证字段白名单、修复后失权、锁后身份、父子同步、冻结/版本和普通角色不变,清理本轮临时文件;不迁移或修改已有数据库数据。
|
||||
|
||||
风险:权限变更可能使旧管理角色失去业务入口,因此前后端必须同步发布并清空失权草稿;验证不修改开发数据库。不新增全局角色绕过。
|
||||
|
||||
## 需求与验收
|
||||
|
||||
- FR-001 / AC-001:阶段新增删除仅迭代创建者;阶段编辑/改名/计划允许迭代创建者或阶段负责人。
|
||||
- FR-002 / AC-002:人工阶段开始、申请及撤回仅负责人,通过/驳回仅阶段创建者;原采购确认和交付职责不变。
|
||||
- FR-003 / AC-003:工作项维护按阶段负责人,执行按工作项负责人,评论上传按负责人/协作人;回退人工新增检查目标阶段维护身份。迭代创建者仅通过字段受限的旧项修复入口补缺失值,不取得普通维护能力。
|
||||
- FR-004 / AC-004:工作项排期/复核按自身负责人或自身创建者,不能超有效阶段范围,批量使用最终图,子任务仍受父计划限制。普通编辑保留原日期精度,不能隐式改期。
|
||||
- FR-005 / AC-005:新建所属阶段必选且只列本人负责的有效工作阶段,无权默认值、伪造选择及旧弹窗失权均拒绝。
|
||||
- FR-006 / AC-006:迭代创建者可补齐旧项缺失归属或负责人;新建仍无例外。修复仅保存目标字段与版本,锁后复验身份及缺失值,既有归属/负责人不覆盖,修复后能力消失,不解除原有排期、父子及冻结规则。
|
||||
|
||||
上述五项均通过专项服务/组件回归和独立审查。锁后身份复查、冻结、历史、版本与同项目/迭代边界沿用原约束。
|
||||
|
||||
## 实现及实际验证(2026-11-03)
|
||||
|
||||
- 真实工作项服务回归:71 项检查通过。首轮44项有26项未符合新规则,随后单独复现并修复了补分配、回退人工新增和新建API菜单门禁的旁路;最后覆盖锁后阶段转交/协作人移除、独立执行、旧计划保持及创建人随六种候选变换保留。
|
||||
- 真实阶段服务回归:110项通过,初始96项有46项失败。覆盖创建者/阶段负责人编辑、人工开始、提审/撤回/审批、能力分流、类型及冻结、锁后身份变化。
|
||||
- 真实排期服务回归:61项通过,初始54项有20项失败。覆盖创建者排期、复核早退、阶段负责人计划、混合请求逐项鉴权、阶段无计划/待复核/越界、父子范围、版本及生命周期。
|
||||
- 前端真实Vue组件及Axios传输回归:23项通过;另对独立审查发现的补分配旧窗口失权补充单例,先复现仍显示按钮且发请求,再修复,1/1通过。
|
||||
- `mvn -o -pl ruoyi-project -am test`:构建通过。模块无内置测试源,以上服务专项独立执行;Mapper、对象存储及通知使用内存替身,未写入开发数据库。
|
||||
- 严格 `vue-tsc`(含未使用声明/参数检查)及 `npm run build:prod`:通过。
|
||||
- 全量单元回归348/350通过,另外两项仍为未修改的 `purchase-documents.test.mjs` 采购入口结构断言和 `table-cell-policy.test.mjs` 外部表格类名规则。
|
||||
- 全量运行回归370项通过、59个文件通过;未修改的 `app-release.spec.js` 引用不存在的 `@/views/system/file/AppRelease.vue`,导致该套件加载失败。
|
||||
- 未执行真实数据库事务、MinIO或通知投递联调,无独立Lint脚本;不将这些检查记录为通过。
|
||||
|
||||
独立审查指出的新建菜单门禁及补分配旧窗口失权均已补测修复。新增/修改的重要方法与安全/锁/事务说明已同步,专项源码、class、配置及日志验证后清理,不交付长期测试入口。
|
||||
|
||||
Scope Drift:NONE。Requirement Drift:NONE。无数据库结构及业务数据变更。改动承接本任务开始前已有的项目协作修改,未覆盖或还原这些改动。
|
||||
|
||||
## 推荐选项补充实现及验证(2026-11-03)
|
||||
|
||||
已补齐迭代创建者的旧项修复能力。普通维护仍按阶段负责人;专用修复仅接受缺失字段与版本,不要求普通写角色,也不授予普通编辑或执行资格。创建者信息直接复用锁内迭代行,列表不会逐项追加身份查询。阶段回退、交付材料和采购批次维护保持原职责;附件删除保持仅工作项负责人。
|
||||
|
||||
- 真实服务与严格 Controller 验证57项通过;首轮50项中30项因旧项修复未开放而失败,补齐后全部通过,并增加了并发补齐、目标阶段排期边界、数值解码、历史详情和列表查询次数检查。
|
||||
- 真实 Vue 详情组件与 Axios 传输验证16项通过;覆盖只读菜单创建者补齐、字段白名单、补齐后入口消失、普通角色无权、历史/冻结/终态、旧窗口失权与目标阶段更新。
|
||||
- 本轮 Maven 模块构建、严格前端类型检查及前端生产构建通过。Maven仍无内置测试源,不能替代以上专项检查。
|
||||
- 验证使用 Mapper、审计等内存替身,未连接或写入开发数据库,未联调真实通知、MinIO及数据库事务;本轮未重新运行已知存在外部失败的全量套件。
|
||||
|
||||
本轮临时专项源码、class、配置和日志验证后清理;保留本节为结果记录,不交付临时测试命令或入口。FR-006 / AC-006通过,原职责回归通过;注释、字段白名单及修改范围已复核。Scope Drift、Requirement Drift及Assumption Drift均为NONE。
|
||||
@ -4,19 +4,20 @@
|
||||
|
||||
## 迭代创建者专属布局修正规范
|
||||
|
||||
用户已明确指定本次修正规则,RCS 99、RRS 48,无待确认业务歧义;身份权限变更仅作用于共享布局,不修改阶段/工作项其他权限,不修改或清空已有数据库布局,不需要数据库结构变更。
|
||||
用户已明确继续由迭代创建者统一维护画布,RCS 100、RRS 55,无待确认业务歧义;本次仅收紧画布选择/配置入口并修正显式重载,不修改阶段/工作项其他权限,不修改或清空已有数据库布局,不需要数据库结构变更。
|
||||
|
||||
- FR-001:仅有效项目成员中的迭代创建者可维护节点位置、分区和对齐布局。前端读取当前迭代 `createdBy` 与服务端 `layout.canEdit` 双重判断,后端在项目锁内核验迭代真实 `created_by`,项目管理者或系统管理员均无身份绕过。归档、结束、取消仍只读。
|
||||
- FR-002:其他成员打开、刷新、框选或尝试鼠标/键盘拖动均不得提交布局;直接 PUT 同样拒绝且不得改变布局内容/版本。接收只读快照时丢弃当前未授权草稿,不能用旧草稿阻塞数据库刷新或触发离页保存。
|
||||
- FR-001:仅有效项目成员中的迭代创建者可维护节点位置、分区、框选/多选、对齐和分组;节点生成、执行连线及阶段组结构仍由该创建者配置。布局读取当前迭代 `createdBy` 与服务端 `layout.canEdit` 双重判断,节点生成/连线也核对当前账号与创建者,防止切换账号沿用旧摘要。后端在项目锁内核验迭代真实 `created_by`,项目管理者或系统管理员均无身份绕过。归档、结束、取消仍只读。
|
||||
- FR-002:其他成员不可框选、多选或鼠标/键盘拖动节点,不得提交布局;直接 PUT 同样拒绝且不得改变布局内容/版本。接收只读快照时丢弃未授权草稿、结束旧拖动/框选并清空节点及连线的选中高亮,恢复平移;不能用旧交互阻塞数据库刷新或触发离页保存。
|
||||
- FR-003:数据库为布局唯一来源,停止所有流程视图 localStorage/sessionStorage 读写;仅移除 `pm-flow-view:` 和 `pm-flow-personal:` 前缀的旧键,不读取或迁移其内容,不影响登录信息及其他模块缓存。缩放、折叠与辅助开关仅在当前组件内临时生效,重进页面不恢复缓存。
|
||||
- FR-004:创建者当前未保存修改仍保留现有串行保存、版本冲突保护及网络失败重试;按用户/项目/迭代隔离的会话内未确认草稿只允许同一迭代创建者恢复,不作为已保存数据库布局。非创建者不恢复此类草稿。
|
||||
- FR-005:所有成员可平移、缩放、适应画布、展开/折叠及查看阶段详情,这些浏览动作不提交布局。数据库没有个人折叠或视口字段,页面重新挂载统一展开并使用默认视口;显式“重新加载共享布局”仅在确实应用原可见范围的数据库快照后重置浏览状态,失败或过期响应保留当前浏览状态。后台静默同步仍保留本页浏览状态。
|
||||
- AC-001:创建者保存后切换非创建者、刷新或模拟旧缓存,显示数据库坐标和分区,PUT 调用为0。
|
||||
- AC-002:非创建者(含其他管理者)的鼠标、方向键、自动布局、分区修改和直接 API 无法改库;创建者在不再担任项目管理者但仍是有效成员时仍可维护可写迭代布局。
|
||||
- AC-003:锁后身份/成员/生命周期复查、并发版本保护和创建者新草稿队列继续有效;缓存不可访问时仍正常从数据库加载。
|
||||
|
||||
实施计划:先添加前端运行与后端真实服务入口临时回归,观察当前管理者越权/缓存恢复的预期失败;再收紧服务权限、前端能力与草稿恢复,删除偏好恢复代码并加入旧键清理;最后跑专项测试、模块严格类型检查、构建及适用全量回归,更新中文注释并清理全部新增测试文件。验证不向开发数据库写入业务数据。
|
||||
|
||||
### 本次修正验证结果
|
||||
### 前次创建者权限修正验证结果
|
||||
|
||||
FR-001 至 FR-004、AC-001 至 AC-003:PASS。Scope Drift、Requirement Drift、Assumption Drift:NONE。新增/修改方法中文说明、只读切换、请求队列及缓存兼容说明已检查。
|
||||
|
||||
@ -28,6 +29,19 @@ FR-001 至 FR-004、AC-001 至 AC-003:PASS。Scope Drift、Requirement Drift
|
||||
|
||||
范围:前端仅本模块,后端及安装/升级 SQL 仅 ruoyi-project。不改工作项、阶段执行审批、回退、父子关系或业务连线规则;不新增 websocket、依赖或个人/共享视图选择器。
|
||||
|
||||
### 本轮画布选择及临时浏览状态审查(2026-11-03)
|
||||
|
||||
用户已确认“沿用迭代创建者统一维护画布”。本轮产品改动仅流程视图及共享布局前端 composable、模块说明;后端现有权限与存储经测试符合要求,无需改动,未变更数据库结构或业务数据。
|
||||
|
||||
- 前端专项25项通过:真实 WorkFlow、Vue Flow、Element Plus和Axios传输,覆盖框选/修饰键、拖动与方向键、旧配置快照切换账号、失权清理、直接合成连线/拖放、成员点击详情、缓存不可访问、跨用户读取、个人浏览零PUT、隐藏子节点坐标保留、静默同步及显式重载成功/失败/离页响应、撤权后的迟到PUT与排队草稿。
|
||||
- 首轮15项中6项失败,对应普通成员可框选、旧账号配置入口未关闭、旧选区未清理;均先复现再修复。追加显式重载恢复统一展开及默认视口的失败用例后修复;独立审查再发现执行边高亮残留,补充用例先失败,改用Vue Flow公开选择API后25/25通过。
|
||||
- 后端真实服务及Controller专项54项通过:成员、阶段负责人、其他管理者及系统管理员均不能越过迭代创建者修改布局、阶段生成/删除、连线或分组;验证共享读取无写入、条件版本、锁后成员/创建者/生命周期复查、严格白名单及错误归属。Mapper使用内存替身,不连接开发数据库。
|
||||
- `mvn -o -pl ruoyi-project -am test`模块构建通过;无内置测试源,以上专项独立执行。严格`vue-tsc`含未使用声明检查及最终`npm run build:prod`生产构建通过;连线高亮通过Vue Flow公开选择API清理,保持类型安全。
|
||||
- 全量单元348/350通过,失败仍为范围外的`purchase-documents.test.mjs`采购入口结构断言、`table-cell-policy.test.mjs`其他模块表格类名策略。全量运行370项通过、59个文件通过;`app-release.spec.js`因引用缺失的`@/views/system/file/AppRelease.vue`加载失败。未扩大修改范围处理这些既有问题,不把整仓测试记为全部通过。
|
||||
- 独立只读审查无未解决严重或重要问题;节点及连线高亮清理的轻微发现已修复并复核。新增/修改方法的中文注释、选区清理、快照代次及范围检查已完成。
|
||||
|
||||
本轮未执行真实数据库事务/通知/MinIO或完整浏览器原生D3指针交互联调;专项是实际Vue组件运行验证,不等同于真实浏览器端到端验收。本轮21个临时测试、快照、计划、配置、class及日志文件和两个空目录已按精确清单清理,不保留临时执行入口。FR-001至FR-005及对应AC通过;Scope Drift、Requirement Drift、Assumption Drift均为NONE。
|
||||
|
||||
## 数据及接口契约
|
||||
|
||||
- 新表 `pm_collab_flow_layout`,主键 `(project_id, iteration_id)`,复合外键指向现有迭代表;`layout_json`、独立 `version`、`updated_by`、`updated_at` 全部带中文注释。安装 SQL 同步增加,新环境及已有环境分别适用;升级为 025,仅新增此表,不删除旧表或业务数据。
|
||||
@ -40,9 +54,9 @@ FR-001 至 FR-004、AC-001 至 AC-003:PASS。Scope Drift、Requirement Drift
|
||||
## 前端行为与边界
|
||||
|
||||
- 数据库坐标为唯一共享来源;初始布局使用确定性的完整展开布局计算,避免个人折叠导致默认位置不同。缺少位置的新增节点采用相同规则补位。旧本机节点/分区/个人浏览缓存直接清理,不读取、不导入、不上报。
|
||||
- 缩放/平移、展开折叠、辅助开关、框选高亮与辅助线均为当前组件临时状态,不读写任何本地键;这些操作不得触发布局写入。
|
||||
- 所有成员的缩放/平移、展开折叠均为当前组件临时状态;创建者的框选高亮、辅助开关及辅助线也不持久化,不读写任何本地键。浏览动作不触发布局写入,框选后的实际排版则保存结果坐标。
|
||||
- 迭代创建者拖动结束、对齐/等距、自动布局及分区增删改/缩放后自动保存,约500ms合并;同一页面只允许一个在途写入,期间的新草稿在成功后用新版本继续串行提交。折叠隐藏节点的位置仍须保留,不可被部分可见画布覆盖。
|
||||
- 非创建者成员可框选查看、缩放、平移、折叠、查看详情,但禁用拖动、自动布局、分区编辑、排版及其键盘绕过;项目或系统管理身份不例外,服务端再次鉴权。
|
||||
- 非创建者成员可缩放、平移、折叠、查看详情,但禁用框选/多选、拖动、自动布局、分区编辑、排版及鼠标/键盘绕过;项目或系统管理身份不例外,服务端再次鉴权。失权时同时清理 Vue Flow 选区及高亮,不能仅设置全局 selectable。
|
||||
- 显示加载、待保存、保存中、已保存及失败状态。瞬时失败保留草稿,可重试;版本/结构冲突明确提示,并由用户选择重新加载共享布局,不能将过期草稿自动套用新版本。无失败假成功提示。
|
||||
- 可编辑的创建者未保存/保存中或正在交互时不应用旧轮询快照;保存成功后若本地已有新编辑,不用旧响应覆盖草稿。非创建者及服务端只读快照放弃未授权草稿,数据库更新不得被旧草稿阻塞。接收新版本时保留当前组件视口、折叠及选区,不重开抽屉。离页请求不能写入另一个项目/迭代。
|
||||
- 后端返回的 canEdit 与前端当前迭代 createdBy 共同控制编辑能力,不能依赖项目管理角色;新建阶段后坐标须等最新阶段摘要到达才能保存,避免尚未加载的节点身份被错误拒绝。
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<p v-if="constraints?.sources.length" class="note">排期来源:{{ constraints.sources.map(scheduleSourceLabel).join(';') }}</p>
|
||||
<p v-if="constraints?.scheduleBlockedReasons.length" class="note">{{ constraints.scheduleBlockedReasons.map(reason => [reason.sourceName, reason.message].filter(Boolean).join(':')).join(';') }}</p>
|
||||
<el-alert v-if="failure" type="error" :title="failure" :closable="false" class="failure" />
|
||||
<template #footer><el-button size="small" :disabled="busy" @click="emit('close')">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="!item || loading || invalidStart || invalidEnd" @click="save">保存排期</el-button></template>
|
||||
<template #footer><el-button size="small" :disabled="busy" @click="emit('close')">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="item?.canScheduleWorkItem !== true || loading || invalidStart || invalidEnd" @click="save">保存排期</el-button></template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@ -35,9 +35,9 @@ watch(() => props.itemId, async id => {
|
||||
} catch (error) { if (request === sequence) failure.value = errorText(error) }
|
||||
finally { if (request === sequence) loading.value = false }
|
||||
}, { immediate: true })
|
||||
/** 通过受控入口按整日改期或确认参考计划;冲突保留原草稿,成功后重新读取详情。 */
|
||||
/** 提交前复验最新详情的排期能力和本次对象;缺失能力时拒绝,冲突保留草稿。 */
|
||||
async function save() {
|
||||
if (!item.value || busy.value) return
|
||||
if (!item.value || item.value.id !== props.itemId || item.value.canScheduleWorkItem !== true || busy.value || loading.value || invalidStart.value || invalidEnd.value) return
|
||||
const request = sequence; busy.value = true; failure.value = ''
|
||||
try { await api.schedule({ id: item.value.id, version: item.value.version, ...plannedRange(start.value, end.value) }); if (request === sequence) emit('saved') }
|
||||
catch (error) { if (request === sequence) failure.value = errorText(error) }
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
<el-alert title="阶段与工作项按整批最终时间一起校验;修改失败时整批不保存。待复核行预填参考时间,请勾选确认后再提交。" type="info" :closable="false" />
|
||||
<el-tabs v-model="tab" class="batch-tabs">
|
||||
<el-tab-pane label="阶段计划" name="stages">
|
||||
<p v-if="!canManage" class="note">阶段计划由项目经理维护,成员可以调整工作项排期。</p>
|
||||
<p class="note">阶段计划由迭代创建者或该阶段负责人维护;工作项排期由工作项负责人或创建者维护。</p>
|
||||
<el-table v-loading="loading" :data="stageRows" size="small" max-height="420">
|
||||
<el-table-column label="阶段" min-width="170" class-name="business-control-cell"><template #default="{ row }">{{ row.name }}<el-tag v-if="row.pending" size="small" type="warning">待复核</el-tag><el-checkbox v-if="row.pending && canManage" v-model="row.confirm" size="small">确认参考计划</el-checkbox></template></el-table-column>
|
||||
<el-table-column label="预计开始" min-width="180"><template #default="{ row }"><TimeField boundary="start" v-if="canManage" v-model="row.plannedStartAt" zone="Asia/Shanghai" /><span v-else>{{ readable(row.plannedStartAt) }}</span></template></el-table-column>
|
||||
<el-table-column label="预计结束" min-width="180"><template #default="{ row }"><TimeField boundary="end" v-if="canManage" v-model="row.plannedEndAt" zone="Asia/Shanghai" /><span v-else>{{ readable(row.plannedEndAt) }}</span></template></el-table-column>
|
||||
<el-table-column label="阶段" min-width="170" class-name="business-control-cell"><template #default="{ row }">{{ row.name }}<el-tag v-if="row.pending" size="small" type="warning">待复核</el-tag><el-checkbox v-if="row.pending && stageCanSchedule(row.id)" v-model="row.confirm" size="small">确认参考计划</el-checkbox></template></el-table-column>
|
||||
<el-table-column label="预计开始" min-width="180"><template #default="{ row }"><TimeField boundary="start" v-if="stageCanSchedule(row.id)" v-model="row.plannedStartAt" zone="Asia/Shanghai" /><span v-else>{{ readable(row.plannedStartAt) }}</span></template></el-table-column>
|
||||
<el-table-column label="预计结束" min-width="180"><template #default="{ row }"><TimeField boundary="end" v-if="stageCanSchedule(row.id)" v-model="row.plannedEndAt" zone="Asia/Shanghai" /><span v-else>{{ readable(row.plannedEndAt) }}</span></template></el-table-column>
|
||||
</el-table>
|
||||
<el-input v-if="canManage" v-model="reason" size="small" class="batch-reason" maxlength="2000" placeholder="调整说明(已开始阶段改期必填)" />
|
||||
<el-input v-if="stageScheduleAllowed" v-model="reason" size="small" class="batch-reason" maxlength="2000" placeholder="调整说明(已开始阶段改期必填)" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="`工作项排期 · ${itemRows.length}`" name="items">
|
||||
<p class="note">已载入 {{ itemRows.length }} 个可编辑工作项;单次最多处理 500 个对象。待审批或已完成阶段的工作项只读。</p>
|
||||
@ -22,11 +22,11 @@
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<el-alert v-if="failure" type="error" :title="failure" :closable="false" class="failure" />
|
||||
<template #footer><el-button size="small" :disabled="busy" @click="emit('close')">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="loading || !canWrite" @click="save">保存整批</el-button></template>
|
||||
<template #footer><el-button size="small" :disabled="busy" @click="emit('close')">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="loading || !canWrite && !stageScheduleAllowed" @click="save">保存整批</el-button></template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { vLoading } from 'element-plus'
|
||||
import { api, errorText } from '../../../api'
|
||||
import { plannedDate, plannedRange } from '../../../shared/utils/time'
|
||||
@ -34,21 +34,29 @@ import type { Stage, WorkItem, ScheduleChange, StageScheduleChange } from '../..
|
||||
import TimeField from '../../../shared/components/TimeField.vue'
|
||||
|
||||
interface Draft extends ScheduleChange { name: string; initialStart: string | null; initialEnd: string | null; pending: boolean; confirm: boolean; revisionId?: number }
|
||||
const props = defineProps<{ visible: boolean; projectId: number; iterationId: number; canManage: boolean; canWrite: boolean }>()
|
||||
const props = defineProps<{ visible: boolean; projectId: number; iterationId: number; currentStages?: Stage[]; canWrite: boolean }>()
|
||||
const emit = defineEmits<{ close: []; saved: [] }>()
|
||||
const tab = ref('stages'), loading = ref(false), busy = ref(false), failure = ref(''), reason = ref(''), graphVersion = ref<number>(), stages = ref<Stage[]>([])
|
||||
const stageRows = ref<Draft[]>([]), itemRows = ref<Draft[]>([]), itemTotal = ref(0), loadedCount = ref(0)
|
||||
const loadedItems = ref<WorkItem[]>([])
|
||||
/** 每行同时检查加载快照与父级最新能力;单个阶段负责人不能借批量入口修改其他阶段。 */
|
||||
function stageCanSchedule(id: number): boolean {
|
||||
return stages.value.find(stage => stage.id === id)?.canScheduleStage === true && (props.currentStages === undefined || props.currentStages.some(stage => stage.id === id && stage.canScheduleStage === true)) && !frozen(id)
|
||||
}
|
||||
/** 批量阶段入口仅表示至少有一行可编辑,不能用于授权整张表。 */
|
||||
const stageScheduleAllowed = computed(() => stageRows.value.some(row => stageCanSchedule(row.id)))
|
||||
let sequence = 0, page = 0
|
||||
/** 打开时读取最新完整阶段及独立工作项分页,不依赖当前列表或看板的筛选结果。 */
|
||||
watch(() => [props.visible, props.projectId, props.iterationId], async () => {
|
||||
const request = ++sequence; failure.value = ''; busy.value = false; stageRows.value = []; itemRows.value = []; reason.value = ''; page = 0; loadedCount.value = 0; itemTotal.value = 0
|
||||
const request = ++sequence; failure.value = ''; busy.value = false; stageRows.value = []; itemRows.value = []; loadedItems.value = []; stages.value = []; reason.value = ''; page = 0; loadedCount.value = 0; itemTotal.value = 0
|
||||
if (!props.visible) return
|
||||
tab.value = props.canManage ? 'stages' : 'items'; loading.value = true
|
||||
tab.value = 'items'; loading.value = true
|
||||
try {
|
||||
const view = await api.flowView(props.projectId, props.iterationId)
|
||||
if (request !== sequence) return
|
||||
stages.value = view.stages; graphVersion.value = view.graphVersion
|
||||
stageRows.value = view.stages.filter(stage => !frozen(stage.id)).map(stage => ({ ...draft(stage.id, stage.revisionVersion ?? 0, stage.stagePath || stage.name, stage), revisionId: stage.revisionId ?? stage.currentRevisionId }))
|
||||
if (stageScheduleAllowed.value) tab.value = 'stages'
|
||||
await loadMore()
|
||||
} catch (error) { if (request === sequence) failure.value = errorText(error) }
|
||||
finally { if (request === sequence) loading.value = false }
|
||||
@ -69,18 +77,20 @@ async function loadMore() {
|
||||
try {
|
||||
const result = await api.items(props.projectId, props.iterationId, { view: 'flat', page: nextPage, pageSize: 100 })
|
||||
if (request !== sequence) return
|
||||
itemRows.value.push(...result.rows.filter(item => !item.historical && !item.stageReadOnly && !item.scheduleReviewClosed && !frozen(item.stageId)).map(item => draft(item.id, item.version, item.title, item)))
|
||||
loadedItems.value.push(...result.rows)
|
||||
itemRows.value.push(...result.rows.filter(item => item.canScheduleWorkItem === true && !item.historical && !item.stageReadOnly && !item.scheduleReviewClosed && !frozen(item.stageId)).map(item => draft(item.id, item.version, item.title, item)))
|
||||
loadedCount.value += result.rows.length; itemTotal.value = result.total; page = nextPage
|
||||
} catch (error) { if (request === sequence) failure.value = errorText(error) }
|
||||
finally { if (request === sequence) loading.value = false }
|
||||
}
|
||||
/** 草稿仅比较用户操作,不因展示参考时间而把整张表误判为已修改。 */
|
||||
function changed(row: Draft) { return row.plannedStartAt !== row.initialStart || row.plannedEndAt !== row.initialEnd || row.pending && row.confirm }
|
||||
/** 仅将变更行转换为整日,与阶段、任务及图版本通过一个请求提交;失败保留全部输入。 */
|
||||
/** 仅提交本次仍具排期能力的变更行;逐阶段复验行能力,后端整批持锁验证最终图。 */
|
||||
async function save() {
|
||||
if (!props.canWrite || busy.value || loading.value) return
|
||||
const items: ScheduleChange[] = itemRows.value.filter(changed).map(({ id, version, plannedStartAt, plannedEndAt }) => ({ id, version, ...plannedRange(plannedStartAt, plannedEndAt) }))
|
||||
const stageChanges: StageScheduleChange[] = props.canManage ? stageRows.value.filter(changed).map(row => ({ id: row.id, revisionId: row.revisionId!, version: row.version, ...plannedRange(row.plannedStartAt, row.plannedEndAt), reason: reason.value })) : []
|
||||
if (!props.visible || !props.canWrite && !stageScheduleAllowed.value || busy.value || loading.value) return
|
||||
const allowed = new Set(loadedItems.value.filter(item => item.canScheduleWorkItem === true).map(item => item.id))
|
||||
const items: ScheduleChange[] = props.canWrite ? itemRows.value.filter(row => allowed.has(row.id) && changed(row)).map(({ id, version, plannedStartAt, plannedEndAt }) => ({ id, version, ...plannedRange(plannedStartAt, plannedEndAt) })) : []
|
||||
const stageChanges: StageScheduleChange[] = stageRows.value.filter(row => stageCanSchedule(row.id) && changed(row)).map(row => ({ id: row.id, revisionId: row.revisionId!, version: row.version, ...plannedRange(row.plannedStartAt, row.plannedEndAt), reason: reason.value }))
|
||||
if (!items.length && !stageChanges.length) { emit('close'); return }
|
||||
const request = sequence; busy.value = true; failure.value = ''
|
||||
try { await api.batchSchedule(props.projectId, items, props.iterationId, stageChanges, graphVersion.value); if (request === sequence) emit('saved') }
|
||||
|
||||
@ -26,12 +26,12 @@ import { scheduleSourceLabel } from '../../../shared/constants/schedules'
|
||||
import type { StageSchedule, StageScheduleChange } from '../../../types'
|
||||
import TimeField from '../../../shared/components/TimeField.vue'
|
||||
|
||||
const props = defineProps<{ projectId: number; iterationId?: number; stageId: number; schedule: StageSchedule; canManage?: boolean; historical?: boolean; completed?: boolean; supersededAt?: string | null }>()
|
||||
const props = defineProps<{ projectId: number; iterationId?: number; stageId: number; schedule: StageSchedule; canScheduleStage?: boolean; historical?: boolean; completed?: boolean; supersededAt?: string | null }>()
|
||||
const emit = defineEmits<{ changed: [] }>()
|
||||
const editing = ref(false), busy = ref(false), failure = ref(''), start = ref<string | null>(null), end = ref<string | null>(null), reason = ref(''), invalidStart = ref(false), invalidEnd = ref(false)
|
||||
const draftSource = ref<StageSchedule | null>(null)
|
||||
let sequence = 0
|
||||
const canEdit = computed(() => !!props.canManage && !!props.iterationId && !props.historical && (!props.completed || !props.schedule.plannedStartAt && !props.schedule.plannedEndAt && props.schedule.planSource !== 'BACKFILLED'))
|
||||
const canEdit = computed(() => props.canScheduleStage === true && !!props.iterationId && !props.historical && (!props.completed || !props.schedule.plannedStartAt && !props.schedule.plannedEndAt && props.schedule.planSource !== 'BACKFILLED'))
|
||||
/** 切换项目、阶段或历史轮次时销毁草稿,异步结果不能写到另一个范围。 */
|
||||
watch(() => [props.projectId, props.iterationId, props.stageId, props.historical, props.schedule.revisionId, canEdit.value], () => { sequence++; editing.value = false; busy.value = false; failure.value = '' })
|
||||
/** 自身计划与内部排期分开展示,避免有父计划便误认为全部子项已排好。 */
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<el-row :gutter="16"><el-col :span="12"><el-form-item label="预计开始" required><TimeField v-model="draft.plannedStartAt" zone="Asia/Shanghai" boundary="start" :earliest="parent?.plannedStartAt" :latest="parent?.plannedEndAt" /></el-form-item></el-col><el-col :span="12"><el-form-item label="预计结束" required><TimeField v-model="draft.plannedEndAt" zone="Asia/Shanghai" boundary="end" :earliest="draft.plannedStartAt" :latest="parent?.plannedEndAt" /></el-form-item></el-col></el-row>
|
||||
</el-form>
|
||||
<el-alert v-if="failure" :title="failure" type="error" :closable="false" />
|
||||
<template #footer><el-button size="small" @click="emit('close')">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="!draft.name.trim() || !draft.plannedStartAt || !draft.plannedEndAt || draft.nodeType !== 'PURCHASE' && !draft.ownerId" @click="save">创建</el-button></template>
|
||||
<template #footer><el-button size="small" @click="emit('close')">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="canConfigureStages !== true || !draft.name.trim() || !draft.plannedStartAt || !draft.plannedEndAt || draft.nodeType !== 'PURCHASE' && !draft.ownerId" @click="save">创建</el-button></template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@ -21,7 +21,7 @@ import { api, errorText } from '../../../api'
|
||||
import TimeField from '../../../shared/components/TimeField.vue'
|
||||
import PurchaseBatchPicker from './PurchaseBatchPicker.vue'
|
||||
import { stageNodeTypeLabel, WORK_STAGE_NODE_TYPES } from '../../../shared/constants/stageNodeTypes'
|
||||
const props = defineProps<{ visible: boolean; projectId: number; iterationId?: number; parent?: Stage | null; nodeType?: StageNodeType; members: Member[] }>()
|
||||
const props = defineProps<{ visible: boolean; projectId: number; iterationId?: number; parent?: Stage | null; nodeType?: StageNodeType; members: Member[]; canConfigureStages?: boolean }>()
|
||||
const emit = defineEmits<{ close: []; created: [id: number] }>()
|
||||
const busy = ref(false), failure = ref('')
|
||||
const draft = reactive({ name: '', description: '', nodeType: 'REQUIREMENT' as StageNodeType, ownerId: null as number | null, plannedStartAt: null as string | null, plannedEndAt: null as string | null, purchaseBatchIds: [] as number[] })
|
||||
@ -30,11 +30,11 @@ let generation = 0
|
||||
watch(() => props.visible, visible => { generation++; if (visible) { Object.assign(draft, { name: '', description: '', nodeType: props.nodeType || 'REQUIREMENT', ownerId: null, plannedStartAt: null, plannedEndAt: null, purchaseBatchIds: [] }); failure.value = '' } })
|
||||
/** 离开项目或迭代后不再处理旧创建请求的界面回调,服务端事务结果仍由后续同步读取。 */
|
||||
onBeforeUnmount(() => { generation++ })
|
||||
/** 固定分类与整日计划在同一事务创建;结构类型由分类派生,失败保留草稿供修正日期等输入。 */
|
||||
/** 固定分类与计划在同一事务创建;空采购范围省略字段,明确选批次时沿用交付校验,提交前复验创建者资格。 */
|
||||
async function save() {
|
||||
if (busy.value || !draft.name.trim() || !draft.plannedStartAt || !draft.plannedEndAt) return
|
||||
if (!props.visible || props.canConfigureStages !== true || busy.value || !draft.name.trim() || !draft.plannedStartAt || !draft.plannedEndAt || draft.nodeType !== 'PURCHASE' && !draft.ownerId) return
|
||||
const request = generation; busy.value = true; failure.value = ''
|
||||
try { const id = await api.createStage(props.projectId, { ...draft, purchaseBatchIds: draft.nodeType === 'PURCHASE' ? draft.purchaseBatchIds : undefined, stageKind: draft.nodeType === 'GROUP' ? 'GROUP' : 'WORK', name: draft.name.trim(), sortOrder: 0, parentStageId: props.parent?.id ?? null }, props.iterationId); if (request === generation) emit('created', id) }
|
||||
try { const { purchaseBatchIds, ...fields } = draft; const id = await api.createStage(props.projectId, { ...fields, ...(draft.nodeType === 'PURCHASE' && purchaseBatchIds.length ? { purchaseBatchIds } : {}), stageKind: draft.nodeType === 'GROUP' ? 'GROUP' : 'WORK', name: draft.name.trim(), sortOrder: 0, parentStageId: props.parent?.id ?? null }, props.iterationId); if (request === generation) emit('created', id) }
|
||||
catch (error) { if (request === generation) failure.value = errorText(error) } finally { busy.value = false }
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -2,14 +2,14 @@
|
||||
<el-dialog :close-on-click-modal="false" :model-value="visible" title="项目阶段" width="min(1100px, 96vw)" append-to-body @close="emit('close')">
|
||||
<div class="stage-manager-content">
|
||||
<el-alert title="从左侧节点库拖入阶段并连线确定顺序。采购当前版本实际开始即放行直接下游,验收齐备后仍须人工确认完成;其他阶段审批完成后放行。多条入边须全部满足,阶段组须全部子阶段完成。" type="info" :closable="false" />
|
||||
<el-button v-if="iterationId && view" size="small" class="structure-button" @click="structureOpen = true">调整阶段层级与连线</el-button>
|
||||
<el-button v-if="iterationId && view && canConfigure" size="small" class="structure-button" @click="structureOpen = true">调整阶段层级与连线</el-button>
|
||||
<el-table :data="stages" size="small" table-layout="fixed" max-height="min(55vh, 520px)" class="stage-table">
|
||||
<el-table-column label="阶段" min-width="245" class-name="business-status-cell"><template #default="{ row }"><div class="stage-name"><el-tag size="small" type="info">{{ stageNodeTypeLabel(row) }}</el-tag><span :title="row.stagePath || row.name">{{ row.stagePath || row.name }}</span></div></template></el-table-column>
|
||||
<el-table-column label="负责人" width="100" show-overflow-tooltip><template #default="{ row }">{{ row.ownerName || '未分配' }}</template></el-table-column>
|
||||
<el-table-column label="发起人" width="100" show-overflow-tooltip><template #default="{ row }">{{ row.creatorName || '#' + row.creatorId }}</template></el-table-column>
|
||||
<el-table-column label="工作项" width="70"><template #default="{ row }">{{ row.counts.total }}</template></el-table-column><el-table-column label="状态" min-width="150" class-name="business-status-cell"><template #default="{ row }"><div class="stage-status"><span>{{ stageStatusLabel(row) }}</span><el-tag v-if="row.executionHistory && row.executionStatus === 'NOT_STARTED'" size="small" type="info">有执行历史</el-tag></div></template></el-table-column>
|
||||
<el-table-column label="描述" prop="description" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="126" fixed="right" class-name="business-operation-cell"><template #default="{ row }"><div class="stage-operations"><el-button size="small" link type="primary" :disabled="row.approvalStatus === 'PENDING' || ['COMPLETED', 'LEGACY_PASSED'].includes(row.executionStatus || '')" @click="open(row)">编辑</el-button><el-tooltip :content="deleteBlockedReason(row)" :disabled="!deleteBlockedReason(row)"><span><el-button size="small" link type="danger" :disabled="!!deleteBlockedReason(row) || busy" @click="remove(row)">删除</el-button></span></el-tooltip></div></template></el-table-column>
|
||||
<el-table-column label="操作" width="126" fixed="right" class-name="business-operation-cell"><template #default="{ row }"><div class="stage-operations"><el-button size="small" link type="primary" :disabled="row.canEditStage !== true || row.approvalStatus === 'PENDING' || ['COMPLETED', 'LEGACY_PASSED'].includes(row.executionStatus || '')" @click="open(row)">编辑</el-button><el-tooltip :content="deleteBlockedReason(row)" :disabled="!deleteBlockedReason(row)"><span><el-button size="small" link type="danger" :disabled="!!deleteBlockedReason(row) || busy" @click="remove(row)">删除</el-button></span></el-tooltip></div></template></el-table-column>
|
||||
</el-table>
|
||||
<el-alert v-if="failure" type="error" :title="failure" :closable="false" class="failure" />
|
||||
</div>
|
||||
@ -23,13 +23,13 @@
|
||||
<el-form-item label="阶段描述"><el-input v-model="draft.description" type="textarea" :rows="3" maxlength="10000" placeholder="说明本阶段需要完成的事项" /></el-form-item>
|
||||
</el-form>
|
||||
<el-alert v-if="editorFailure" type="error" :title="editorFailure" :closable="false" class="failure" />
|
||||
<template #footer><el-button size="small" @click="editorOpen = false">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="!draft.name.trim() || !purchaseLoaded || editing?.nodeType !== 'PURCHASE' && !draft.ownerId" @click="save">保存</el-button></template>
|
||||
<template #footer><el-button size="small" @click="editorOpen = false">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="!editingAllowed || !draft.name.trim() || !purchaseLoaded || editing?.nodeType !== 'PURCHASE' && !draft.ownerId" @click="save">保存</el-button></template>
|
||||
</el-dialog>
|
||||
</el-dialog>
|
||||
<StageStructureDialog v-if="view && iterationId" :visible="structureOpen" :project-id="projectId" :iteration-id="iterationId" :view="view" @close="structureOpen = false" @changed="emit('changed')" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { api, errorText } from '../../../api'
|
||||
import StageStructureDialog from './StageStructureDialog.vue'
|
||||
@ -39,33 +39,54 @@ import { stageNodeTypeLabel } from '../../../shared/constants/stageNodeTypes'
|
||||
import { stageStatusLabel } from '../../../shared/constants/labels'
|
||||
import { stageDeleteBlockedReason } from '../utils/actions'
|
||||
const props = defineProps<{ visible: boolean; projectId: number; iterationId?: number; stages: Stage[]; members: Member[]; view?: FlowView }>()
|
||||
/** 仅使用当前迭代返回的配置资格,管理角色不能代替创建者身份。 */
|
||||
const canConfigure = computed(() => props.view?.canConfigureStages === true)
|
||||
const emit = defineEmits<{ close: []; changed: [] }>()
|
||||
const structureOpen = ref(false)
|
||||
const editing = ref<Stage | null>(null), editorOpen = ref(false), busy = ref(false), failure = ref(''), editorFailure = ref('')
|
||||
/** 元数据编辑只取当前阶段最新能力;不能用全局结构资格代替阶段负责人身份。 */
|
||||
const editingAllowed = computed(() => props.stages.find(stage => stage.id === editing.value?.id)?.canEditStage === true)
|
||||
const draft = reactive<StageInput>({ name: '', sortOrder: 0, ownerId: null, description: '' })
|
||||
const purchaseIds = ref<number[]>([]), purchaseBatches = ref<PurchaseBatchProgress[]>([]), purchaseLoaded = ref(true)
|
||||
const originalPurchaseIds = ref<number[]>([])
|
||||
watch(() => props.visible, visible => { if (!visible) { editorOpen.value = false; structureOpen.value = false } failure.value = '' })
|
||||
/** 固定类型和创建人只读;采购范围加载失败时禁止保存,避免空草稿意外清空既有批次。 */
|
||||
/** 资格失效立即关闭内部草稿,避免沿用已打开窗口继续提交。 */
|
||||
watch(canConfigure, allowed => { if (!allowed) structureOpen.value = false })
|
||||
/** 阶段转交或冻结后关闭旧编辑窗口,不沿用打开时复制的能力。 */
|
||||
watch(editingAllowed, allowed => { if (!allowed) editorOpen.value = false })
|
||||
/** 迭代创建者或阶段负责人打开元数据编辑;采购加载失败禁止保存,避免清空批次。 */
|
||||
async function open(stage: Stage) {
|
||||
if (!props.visible || !props.stages.some(value => value.id === stage.id && value.canEditStage === true) || busy.value) return
|
||||
editing.value = stage; Object.assign(draft, { name: stage.name, sortOrder: stage.sortOrder, ownerId: stage.ownerId ?? null, description: stage.description || '', stageKind: stage.stageKind || 'WORK', nodeType: stage.nodeType, version: stage.version }); editorFailure.value = ''; editorOpen.value = true
|
||||
purchaseIds.value = []; purchaseBatches.value = []; purchaseLoaded.value = stage.nodeType !== 'PURCHASE'
|
||||
purchaseIds.value = []; originalPurchaseIds.value = []; purchaseBatches.value = []; purchaseLoaded.value = stage.nodeType !== 'PURCHASE'
|
||||
if (stage.nodeType === 'PURCHASE' && props.iterationId) {
|
||||
try { const result = await api.stageCompletion(props.projectId, props.iterationId, stage.id); if (editing.value?.id === stage.id && editorOpen.value) { purchaseBatches.value = result.delivery?.purchase?.batches || []; purchaseIds.value = purchaseBatches.value.map(row => row.batchId); purchaseLoaded.value = true } }
|
||||
try { const result = await api.stageCompletion(props.projectId, props.iterationId, stage.id); if (editing.value?.id === stage.id && editorOpen.value) { purchaseBatches.value = result.delivery?.purchase?.batches || []; purchaseIds.value = purchaseBatches.value.map(row => row.batchId); originalPurchaseIds.value = [...purchaseIds.value]; purchaseLoaded.value = true } }
|
||||
catch (error) { if (editing.value?.id === stage.id) editorFailure.value = errorText(error) }
|
||||
}
|
||||
}
|
||||
/** 保存经经理鉴权与阶段版本校验的元数据,失败保留草稿。 */
|
||||
async function save() { if (!editing.value) return; busy.value = true; editorFailure.value = ''; try { await api.editStage(props.projectId, editing.value.id, { ...draft, purchaseBatchIds: editing.value.nodeType === 'PURCHASE' ? purchaseIds.value : undefined }, props.iterationId); editorOpen.value = false; emit('changed') } catch (error) { editorFailure.value = errorText(error) } finally { busy.value = false } }
|
||||
/**
|
||||
* 保存前复验该阶段元数据资格;仅批次集合真正变化时提交采购范围,避免普通元数据编辑触发交付权限。
|
||||
* 批次修改仍显式提交原字段,由后端沿用交付维护资格和回退范围确认校验,失败保留草稿。
|
||||
*/
|
||||
async function save() {
|
||||
if (!props.visible || !editorOpen.value || !editingAllowed.value || !editing.value || busy.value || !purchaseLoaded.value) return
|
||||
const changed = editing.value.nodeType === 'PURCHASE' && JSON.stringify([...purchaseIds.value].sort((a, b) => a - b)) !== JSON.stringify([...originalPurchaseIds.value].sort((a, b) => a - b))
|
||||
busy.value = true; editorFailure.value = ''
|
||||
try { await api.editStage(props.projectId, editing.value.id, { ...draft, ...(changed ? { purchaseBatchIds: [...purchaseIds.value] } : {}) }, props.iterationId); editorOpen.value = false; emit('changed') }
|
||||
catch (error) { editorFailure.value = errorText(error) }
|
||||
finally { busy.value = false }
|
||||
}
|
||||
/**
|
||||
* 为删除按钮提供与已有后端保护一致的原因,空工作项不代表阶段从未执行。
|
||||
* @param stage 当前行阶段,父组保护从同一份项目阶段摘要读取
|
||||
* @returns 不可删除的具体原因;空字符串允许发起确认,最终仍由后端持锁复验
|
||||
*/
|
||||
function deleteBlockedReason(stage: Stage): string {
|
||||
if (!canConfigure.value) return '仅迭代创建者可删除阶段。'
|
||||
return stageDeleteBlockedReason(stage, props.stages)
|
||||
}
|
||||
/** 发起确认前重新检查当前摘要,只对可删除空阶段提交;后端继续在项目锁内验证历史与版本。 */
|
||||
async function remove(stage: Stage) { const blocked = deleteBlockedReason(stage); if (blocked) { failure.value = blocked; return } try { await ElMessageBox.confirm('删除这个空阶段?历史数据将保留。', '删除阶段', { type: 'warning', closeOnClickModal: false }) } catch { return } busy.value = true; failure.value = ''; try { await api.removeStage(props.projectId, stage.id, stage.version, props.iterationId); emit('changed') } catch (error) { failure.value = errorText(error) } finally { busy.value = false } }
|
||||
/** 确认前后复验创建者配置资格及同一范围,仅提交当前可删除阶段;后端继续持锁验证历史与版本。 */
|
||||
async function remove(stage: Stage) { if (!props.visible || busy.value) return; const blocked = deleteBlockedReason(stage); if (blocked) { failure.value = blocked; return } const projectId = props.projectId, iterationId = props.iterationId; try { await ElMessageBox.confirm('删除这个空阶段?历史数据将保留。', '删除阶段', { type: 'warning', closeOnClickModal: false }) } catch { return } if (!props.visible || !canConfigure.value || props.projectId !== projectId || props.iterationId !== iterationId) return; busy.value = true; failure.value = ''; try { await api.removeStage(projectId, stage.id, stage.version, iterationId); emit('changed') } catch (error) { failure.value = errorText(error) } finally { busy.value = false } }
|
||||
</script>
|
||||
<style scoped>.failure{margin-top:12px;white-space:pre-line}.structure-button{margin:10px 0}
|
||||
.stage-manager-content{max-height:calc(100vh - 175px);overflow:auto;min-width:0}.stage-table{width:100%;min-width:0}.stage-name{display:flex;align-items:center;gap:6px;min-width:0}.stage-name :deep([class~="el-tag"]){flex:none}.stage-name>span{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.stage-operations{display:flex;align-items:center;gap:16px;white-space:nowrap}.stage-operations>span{display:inline-flex}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<p class="rename-hint">仅修改名称,节点类型和其他阶段信息保持原值。</p>
|
||||
</el-form>
|
||||
<el-alert v-if="failure" :title="failure" type="error" :closable="false" />
|
||||
<template #footer><el-button size="small" :disabled="busy" @click="emit('close')">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="!name.trim()" @click="save">保存</el-button></template>
|
||||
<template #footer><el-button size="small" :disabled="busy" @click="emit('close')">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="stage?.canEditStage !== true || !name.trim()" @click="save">保存</el-button></template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@ -24,11 +24,11 @@ watch(() => props.stage, stage => { generation++; name.value = stage?.name || ''
|
||||
onBeforeUnmount(() => { generation++ })
|
||||
/**
|
||||
* 使用只接受名称和阶段版本的接口,避免快捷改名覆盖负责人、描述、采购范围或日期。
|
||||
* 空值、冻结状态和重复提交在前端拦截;权限和并发版本仍由后端持锁复验。
|
||||
* 空值、冻结状态、失效阶段编辑资格和重复提交在前端拦截;权限和版本仍由后端持锁复验。
|
||||
*/
|
||||
async function save() {
|
||||
const stage = props.stage
|
||||
if (!stage || busy.value || !name.value.trim()) return
|
||||
if (!stage || stage.canEditStage !== true || busy.value || !name.value.trim()) return
|
||||
const blocked = stageRenameBlockedReason(stage)
|
||||
if (blocked) { failure.value = blocked; return }
|
||||
if (name.value.trim() === stage.name) { emit('close'); return }
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<el-form-item label="回退原因"><el-input v-model="reason" type="textarea" :rows="2" maxlength="2000" show-word-limit placeholder="说明需要重做的原因" /></el-form-item>
|
||||
<el-form-item><el-checkbox v-model="sendEmail" size="small" :disabled="busy">发送邮件通知</el-checkbox><span class="rework-note">站内消息始终发送;勾选后,每名相关人员最多收到一封回退汇总邮件。</span></el-form-item>
|
||||
</el-form>
|
||||
<el-button size="small" :loading="busy" :disabled="!sourceCanRework || !targetId" @click="loadPreview">查看影响预览</el-button>
|
||||
<el-button size="small" :loading="busy" :disabled="!sourceCanRework || !targetId || !additionsValid" @click="loadPreview">查看影响预览</el-button>
|
||||
<el-alert v-if="failure" :title="failure" type="error" :closable="false" class="rework-alert" />
|
||||
<template v-if="preview">
|
||||
<p v-if="preview.aggregateStageIds?.length" class="rework-note">仅汇总换版:{{ preview.aggregateStageIds.map(stageName).join('、') }}。保留分支不会复制,旧父版本将冻结本次回退前的内容。</p>
|
||||
@ -20,7 +20,7 @@
|
||||
<el-alert v-if="preview.scheduleReviewStageIds.length" type="info" :closable="false" class="rework-alert" :title="`下游排期待复核:${preview.scheduleReviewStageIds.map(stageName).join('、')}`" />
|
||||
<div v-for="blocker in preview.blockedReasons" :key="`${blocker.code}:${blocker.stageId || blocker.taskName}`" class="rework-blocker">
|
||||
<el-alert type="warning" :closable="false" :title="`${blocker.sourceName || stageName(blocker.stageId)}:${blocker.message}`" />
|
||||
<template v-if="blocker.code === 'REWORK_STAGE_EMPTY' && blocker.stageId">
|
||||
<template v-if="blocker.code === 'REWORK_STAGE_EMPTY' && blocker.stageId && canAddReworkItems(blocker.stageId)">
|
||||
<el-button size="small" @click="addItem(blocker.stageId)">补录工作项</el-button>
|
||||
</template>
|
||||
</div>
|
||||
@ -28,23 +28,26 @@
|
||||
</template>
|
||||
<section v-for="(items, stageId) in additions" :key="stageId" class="addition-section">
|
||||
<strong>{{ stageName(Number(stageId)) }} · 补录新版本工作项</strong>
|
||||
<div v-for="(item, index) in items" :key="index" class="addition-row"><el-select v-model="item.type" size="small"><el-option label="任务" value="TASK" /><el-option label="需求" value="REQUIREMENT" /><el-option label="缺陷" value="BUG" /></el-select><el-input v-model="item.title" size="small" maxlength="200" placeholder="新工作项名称" /><el-button size="small" @click="removeAddition(Number(stageId), index)">移除</el-button></div>
|
||||
<el-button size="small" @click="addItem(Number(stageId))">再补录一项</el-button>
|
||||
<p v-if="items.length && !canAddReworkItems(Number(stageId))" class="rework-note">当前已无该阶段的补录资格,请移除补录草稿后重新预览。</p>
|
||||
<div v-for="(item, index) in items" :key="index" class="addition-row"><el-select v-model="item.type" size="small" :disabled="!canAddReworkItems(Number(stageId))"><el-option label="任务" value="TASK" /><el-option label="需求" value="REQUIREMENT" /><el-option label="缺陷" value="BUG" /></el-select><el-input v-model="item.title" size="small" maxlength="200" placeholder="新工作项名称" :disabled="!canAddReworkItems(Number(stageId))" /><el-select v-model="item.assigneeId" size="small" filterable placeholder="负责人(必选)" :disabled="!canAddReworkItems(Number(stageId))"><el-option v-for="member in members" :key="member.userId" :value="member.userId" :label="member.name" /></el-select><el-button size="small" @click="removeAddition(Number(stageId), index)">移除</el-button></div>
|
||||
<el-button v-if="canAddReworkItems(Number(stageId))" size="small" @click="addItem(Number(stageId))">再补录一项</el-button>
|
||||
</section>
|
||||
<template #footer><el-button size="small" @click="emit('close')">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="!sourceCanRework || !preview?.canCommit || !reason.trim()" @click="commit">确认回退</el-button></template>
|
||||
<template #footer><el-button size="small" @click="emit('close')">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="!sourceCanRework || !additionsValid || !preview?.canCommit || !reason.trim()" @click="commit">确认回退</el-button></template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { api, errorText } from '../../../api'
|
||||
import { createIdempotencyKey } from '../../../shared/utils/idempotency'
|
||||
import type { FlowView, ReworkInput, ReworkItemInput, ReworkPreview } from '../../../types'
|
||||
import type { FlowView, Member, ReworkInput, ReworkItemInput, ReworkPreview } from '../../../types'
|
||||
|
||||
const props = defineProps<{ visible: boolean; projectId: number; iterationId?: number; sourceId: number | null; view: FlowView }>()
|
||||
const props = withDefaults(defineProps<{ visible: boolean; projectId: number; iterationId?: number; sourceId: number | null; view: FlowView; members?: Member[] }>(), { members: () => [] })
|
||||
const emit = defineEmits<{ close: []; changed: [] }>()
|
||||
const targetId = ref<number | null>(null), reason = ref(''), preview = ref<ReworkPreview | null>(null), busy = ref(false), failure = ref(''), idempotencyKey = ref<string | null>(null)
|
||||
const additions = ref<Record<number, ReworkItemInput[]>>({})
|
||||
const sendEmail = ref(false)
|
||||
/** 人工补录必须由目标阶段负责人维护并明确工作项负责人,自动复制继续由原服务端流程处理。 */
|
||||
const additionsValid = computed(() => Object.entries(additions.value).every(([stageId, items]) => !items.length || canAddReworkItems(Number(stageId)) && items.every(item => !!item.title.trim() && !!item.assigneeId)))
|
||||
let previewGeneration = 0
|
||||
/** 当前阶段资格由后端快照提供,不根据前端执行状态自行放行。 */
|
||||
const sourceCanRework = computed(() => props.view.stages.some(stage => stage.id === props.sourceId && stage.canRework))
|
||||
@ -66,19 +69,24 @@ watch(sendEmail, () => { idempotencyKey.value = null })
|
||||
watch([targetId, reason, additions], invalidatePreview, { deep: true })
|
||||
/** 图或来源资格改变后旧预览作废;用户仍可保留原因和补录草稿,再明确选择有效上游。 */
|
||||
watch(() => [props.view.graphVersion, sourceCanRework.value], () => { invalidatePreview(); if (!targets.value.some(stage => stage.id === targetId.value)) targetId.value = null })
|
||||
/** 阶段转交即使未改变执行图版本,也必须废弃包含旧补录资格的预览。 */
|
||||
watch(() => props.view.stages.map(stage => `${stage.id}:${stage.canAddReworkItems === true}`).join(','), invalidatePreview)
|
||||
/** 草稿或图更新时同时废弃在途预览,避免迟到响应恢复已经失效的提交按钮。 */
|
||||
function invalidatePreview() { previewGeneration++; preview.value = null; idempotencyKey.value = null }
|
||||
/** 阶段 ID 仅从当前项目服务端视图解析,缺失时不显示其它项目名称。 */
|
||||
function stageName(id: number | null | undefined): string { return props.view.stages.find(stage => stage.id === id)?.name || '阶段不可用' }
|
||||
/** 回退补录只提交白名单业务文本;时间和状态由后端强制初始化。 */
|
||||
function addItem(stageId: number) { additions.value = { ...additions.value, [stageId]: [...(additions.value[stageId] || []), { type: 'TASK', title: '', description: null, assigneeId: null, priority: 'MEDIUM' }] } }
|
||||
/** 回退补录使用独立身份能力,旧轮次已冻结不能据普通新建能力推断新版本补录资格。 */
|
||||
function canAddReworkItems(stageId: number): boolean { return props.view.stages.some(stage => stage.id === stageId && stage.canAddReworkItems === true) }
|
||||
/** 仅目标阶段负责人可加入补录草稿;时间和状态由后端强制初始化。 */
|
||||
function addItem(stageId: number) { if (!props.visible || !canAddReworkItems(stageId)) return; additions.value = { ...additions.value, [stageId]: [...(additions.value[stageId] || []), { type: 'TASK', title: '', description: null, assigneeId: null, priority: 'MEDIUM' }] } }
|
||||
/** 删除尚未提交的补录行后必须重新预览完整影响。 */
|
||||
function removeAddition(stageId: number, index: number) { additions.value = { ...additions.value, [stageId]: (additions.value[stageId] || []).filter((_, position) => position !== index) } }
|
||||
/** 构造当前草稿及本次邮件选择,提交端追加预览版本、受影响阶段和幂等键。 */
|
||||
function input(): ReworkInput { return { sourceStageId: props.sourceId!, targetStageId: targetId.value!, reason: reason.value, additions: additions.value, sendEmail: sendEmail.value } }
|
||||
/** 后端确定完整影响闭包;只接收当前草稿代次的响应,切换来源或图更新后的旧响应直接丢弃。 */
|
||||
/** 人工补录先检查阶段维护资格与负责人必填,再由后端确定影响闭包;只接收本次草稿响应。 */
|
||||
async function loadPreview() {
|
||||
if (!sourceCanRework.value || !props.sourceId || !targetId.value || busy.value) return
|
||||
if (!props.visible || !sourceCanRework.value || !props.sourceId || !targetId.value || busy.value) return
|
||||
if (!additionsValid.value) { failure.value = '请确认补录阶段的维护资格,并为每个补录工作项填写名称及负责人。'; return }
|
||||
const generation = previewGeneration
|
||||
busy.value = true; failure.value = ''
|
||||
try {
|
||||
@ -87,9 +95,9 @@ async function loadPreview() {
|
||||
} catch (error) { if (generation === previewGeneration) { preview.value = null; failure.value = errorText(error) } }
|
||||
finally { busy.value = false }
|
||||
}
|
||||
/** 当前来源且有有效预览才提交;使用兼容 HTTP 的幂等键并在网络失败重试时保留,成功后刷新四个视图。 */
|
||||
/** 当前来源、有负责人且有有效预览才提交;沿用原回退资格,网络失败重试保留幂等键。 */
|
||||
async function commit() {
|
||||
if (!sourceCanRework.value || !preview.value?.canCommit || !reason.value.trim() || busy.value) return
|
||||
if (!props.visible || !sourceCanRework.value || !additionsValid.value || !preview.value?.canCommit || !reason.value.trim() || busy.value) return
|
||||
busy.value = true; failure.value = ''
|
||||
idempotencyKey.value ||= createIdempotencyKey()
|
||||
try {
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<template>
|
||||
<el-dialog :close-on-click-modal="false" :model-value="visible" title="调整未执行阶段结构" width="min(900px, 96%)" append-to-body @close="emit('close')">
|
||||
<el-alert title="先指定父级,再明确编辑最终保留的全部连线。不会自动猜测跨层连线;已执行阶段、执行过的阶段组结构受保护。预览成功后才能确认。" type="info" :closable="false" />
|
||||
<el-table :data="view.stages" size="small" max-height="280"><el-table-column label="阶段" min-width="200"><template #default="{ row }">{{ row.stagePath || row.name }}</template></el-table-column><el-table-column label="类型" width="90"><template #default="{ row }">{{ row.stageKind === 'GROUP' ? '阶段组' : '工作阶段' }}</template></el-table-column><el-table-column label="父阶段组" min-width="220" class-name="business-control-cell"><template #default="{ row }"><el-select v-model="parents[row.id]" size="small" clearable placeholder="根画布" :disabled="busy || row.stageKind === 'GROUP' || !row.canEditStructure"><el-option v-for="group in groups" :key="group.id" :value="group.id" :label="group.name" /></el-select></template></el-table-column></el-table>
|
||||
<el-table :data="view.stages" size="small" max-height="280"><el-table-column label="阶段" min-width="200"><template #default="{ row }">{{ row.stagePath || row.name }}</template></el-table-column><el-table-column label="类型" width="90"><template #default="{ row }">{{ row.stageKind === 'GROUP' ? '阶段组' : '工作阶段' }}</template></el-table-column><el-table-column label="父阶段组" min-width="220" class-name="business-control-cell"><template #default="{ row }"><el-select v-model="parents[row.id]" size="small" clearable placeholder="根画布" :disabled="view.canConfigureStages !== true || busy || row.stageKind === 'GROUP' || !row.canEditStructure"><el-option v-for="group in groups" :key="group.id" :value="group.id" :label="group.name" /></el-select></template></el-table-column></el-table>
|
||||
<h4>最终执行连线</h4>
|
||||
<div v-for="(edge, index) in links" :key="index" class="edge-row"><el-select v-model="edge.predecessorStageId" :disabled="busy" size="small" filterable><el-option v-for="stage in view.stages" :key="stage.id" :value="stage.id" :label="stage.name" /></el-select><span>→</span><el-select v-model="edge.successorStageId" :disabled="busy" size="small" filterable><el-option v-for="stage in view.stages" :key="stage.id" :value="stage.id" :label="stage.name" /></el-select><span v-if="scope(edge.predecessorStageId) !== scope(edge.successorStageId)" class="invalid">跨画布,请调整</span><el-button size="small" link type="danger" :disabled="busy" @click="links.splice(index, 1)">移除</el-button></div>
|
||||
<el-button size="small" :disabled="busy || view.stages.length < 2" @click="addEdge">增加连线</el-button>
|
||||
<div v-for="(edge, index) in links" :key="index" class="edge-row"><el-select v-model="edge.predecessorStageId" :disabled="view.canConfigureStages !== true || busy" size="small" filterable><el-option v-for="stage in view.stages" :key="stage.id" :value="stage.id" :label="stage.name" /></el-select><span>→</span><el-select v-model="edge.successorStageId" :disabled="view.canConfigureStages !== true || busy" size="small" filterable><el-option v-for="stage in view.stages" :key="stage.id" :value="stage.id" :label="stage.name" /></el-select><span v-if="scope(edge.predecessorStageId) !== scope(edge.successorStageId)" class="invalid">跨画布,请调整</span><el-button size="small" link type="danger" :disabled="view.canConfigureStages !== true || busy" @click="links.splice(index, 1)">移除</el-button></div>
|
||||
<el-button size="small" :disabled="view.canConfigureStages !== true || busy || view.stages.length < 2" @click="addEdge">增加连线</el-button>
|
||||
<el-alert v-if="failure" :title="failure" type="error" :closable="false" class="message" />
|
||||
<el-alert v-if="approved" title="最终结构校验通过。确认后在同一事务中更新父级、版本绑定和连线,阶段及工作项ID保持不变。" type="success" :closable="false" class="message" />
|
||||
<template #footer><el-button size="small" @click="emit('close')">取消</el-button><el-button size="small" :loading="busy" @click="preview">预览校验</el-button><el-button size="small" type="primary" :disabled="!approved" :loading="busy" @click="commit">确认调整</el-button></template>
|
||||
<template #footer><el-button size="small" @click="emit('close')">取消</el-button><el-button size="small" :loading="busy" :disabled="view.canConfigureStages !== true" @click="preview">预览校验</el-button><el-button size="small" type="primary" :disabled="view.canConfigureStages !== true || !approved" :loading="busy" @click="commit">确认调整</el-button></template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@ -22,16 +22,16 @@ let generation = 0
|
||||
/** 打开时从共享图构造草稿,重复打开不沿用过期图版本或上次迁移内容。 */
|
||||
watch(() => props.visible, visible => { if (visible) { parents.value = Object.fromEntries(props.view.stages.map(stage => [stage.id, stage.parentStageId ?? null])); links.value = props.view.stageEdges.map(edge => ({ predecessorStageId: edge.predecessorStageId, successorStageId: edge.successorStageId })); approved.value = false; failure.value = '' } })
|
||||
/** 每次编辑和后台图变化均废弃预览,提交不能沿用另一份结构的校验。 */
|
||||
watch([parents, links, () => props.view.graphVersion, () => props.visible], () => { generation++; approved.value = false }, { deep: true, flush: 'sync' })
|
||||
watch([parents, links, () => props.view.graphVersion, () => props.view.canConfigureStages, () => props.visible], () => { generation++; approved.value = false }, { deep: true, flush: 'sync' })
|
||||
/** clearable控件的空值统一为根画布,不把空字符串写入父级外键。 */
|
||||
function scope(id: number): number | null { return parents.value[id] || null }
|
||||
/** 仅明确记录改变的阶段归属;未变更的已执行阶段不作为迁移对象。 */
|
||||
function input(): StageStructureInput { return { graphVersion: props.view.graphVersion!, stages: props.view.stages.filter(stage => (stage.parentStageId ?? null) !== scope(stage.id)).map(stage => ({ id: stage.id, version: stage.version, parentStageId: scope(stage.id) })), edges: links.value.map(edge => ({ ...edge })) } }
|
||||
/** 新边由管理者明确选择端点,最终由后端检查同层、排期和混合依赖环。 */
|
||||
function addEdge() { links.value.push({ predecessorStageId: props.view.stages[0]!.id, successorStageId: props.view.stages[1]!.id }) }
|
||||
/** 预览仅验证最终态,任何失败都保留草稿并关闭提交资格。 */
|
||||
async function preview() { if (busy.value) return; const request = generation; busy.value = true; failure.value = ''; approved.value = false; try { const result = await api.previewStageStructure(props.projectId, props.iterationId, input()); if (request === generation) approved.value = result.canCommit } catch (error) { if (request === generation) failure.value = errorText(error) } finally { busy.value = false } }
|
||||
/** 提交重新核对图版本和全部约束,成功后由父组件刷新共享快照。 */
|
||||
async function commit() { if (!approved.value || busy.value) return; busy.value = true; failure.value = ''; try { await api.commitStageStructure(props.projectId, props.iterationId, input()); emit('changed'); emit('close') } catch (error) { approved.value = false; failure.value = errorText(error) } finally { busy.value = false } }
|
||||
/** 新边仅由迭代创建者明确选择端点,最终由后端检查同层、排期和混合依赖环。 */
|
||||
function addEdge() { if (props.view.canConfigureStages !== true || props.view.stages.length < 2) return; links.value.push({ predecessorStageId: props.view.stages[0]!.id, successorStageId: props.view.stages[1]!.id }) }
|
||||
/** 预览前检查本次配置资格;任何失败保留草稿并关闭提交资格,失权时拒绝旧弹窗。 */
|
||||
async function preview() { if (!props.visible || props.view.canConfigureStages !== true || busy.value) return; const request = generation; busy.value = true; failure.value = ''; approved.value = false; try { const result = await api.previewStageStructure(props.projectId, props.iterationId, input()); if (request === generation && props.view.canConfigureStages === true) approved.value = result.canCommit } catch (error) { if (request === generation) failure.value = errorText(error) } finally { busy.value = false } }
|
||||
/** 提交重新核对配置资格、图版本和全部约束,成功后由父组件刷新共享快照。 */
|
||||
async function commit() { if (!props.visible || props.view.canConfigureStages !== true || !approved.value || busy.value) return; busy.value = true; failure.value = ''; try { await api.commitStageStructure(props.projectId, props.iterationId, input()); emit('changed'); emit('close') } catch (error) { approved.value = false; failure.value = errorText(error) } finally { busy.value = false } }
|
||||
</script>
|
||||
<style scoped>.edge-row{display:flex;align-items:center;gap:8px;margin:8px 0}.edge-row :deep([class~="el-select"]){width:240px}.invalid{font-size:12px;color:var(--el-color-danger)}.message{margin-top:12px}</style>
|
||||
|
||||
@ -3,11 +3,11 @@
|
||||
<p v-if="stage?.description" class="stage-description">{{ stage.description }}</p>
|
||||
<el-tabs v-model="mode">
|
||||
<el-tab-pane :label="`当前版本 · ${stageTotal}`" name="current">
|
||||
<div class="drawer-intro"><el-tag v-if="stage" size="small">v{{ stage.revisionNo || 1 }} · {{ stageStatusNames[stage.executionStatus || 'NOT_STARTED'] }}</el-tag><span>当前版本共 {{ stageTotal }} 个工作项,包含子任务。</span><el-button v-if="canCreate && (stageId === 0 || stage?.canCreateWorkItem)" size="small" type="primary" @click="emit('create', stageId || null)">新建工作项</el-button></div>
|
||||
<div class="drawer-intro"><el-tag v-if="stage" size="small">v{{ stage.revisionNo || 1 }} · {{ stageStatusNames[stage.executionStatus || 'NOT_STARTED'] }}</el-tag><span>当前版本共 {{ stageTotal }} 个工作项,包含子任务。</span><el-button v-if="canCreate && stage?.canCreateWorkItem === true" size="small" type="primary" @click="createItem">新建工作项</el-button></div>
|
||||
<StageCompletionPanel v-if="stage && iterationId" :project-id="projectId" :iteration-id="iterationId" :stage="stage" :refresh-key="view.graphVersion" @changed="emit('changed')" @editing="emit('editing', $event)" />
|
||||
<div v-if="stage?.stageKind === 'GROUP'" class="group-overview"><p>阶段组 · 子阶段 {{ stage.completedChildStageCount || 0 }}/{{ stage.childStageCount || 0 }} 已完成;下表按工作项去重汇总。</p><el-button v-for="child in children" :key="child.id" size="small" @click="emit('navigate', child.id)">{{ child.name }} · {{ stageStatusLabel(child) }} · {{ child.counts.total }} 项</el-button><el-button v-if="stage.canCreateChildStage && canManage" size="small" type="primary" @click="emit('createChild', stage.id)">新建子阶段</el-button></div>
|
||||
<StageSchedulePanel v-if="stage" :project-id="projectId" :iteration-id="iterationId" :stage-id="stage.id" :schedule="stage" :completed="['COMPLETED', 'LEGACY_PASSED'].includes(stage.executionStatus || '')" :can-manage="canManage" @changed="emit('changed')" />
|
||||
<el-alert v-if="stage?.nodeType === 'PURCHASE'" title="采购阶段通过批次验收进度确认完成,不创建工作项。旧工作项如需迁移请由项目管理者调整归属。" type="info" :closable="false" />
|
||||
<div v-if="stage?.stageKind === 'GROUP'" class="group-overview"><p>阶段组 · 子阶段 {{ stage.completedChildStageCount || 0 }}/{{ stage.childStageCount || 0 }} 已完成;下表按工作项去重汇总。</p><el-button v-for="child in children" :key="child.id" size="small" @click="emit('navigate', child.id)">{{ child.name }} · {{ stageStatusLabel(child) }} · {{ child.counts.total }} 项</el-button><el-button v-if="stage.canCreateChildStage && canConfigureStages" size="small" type="primary" @click="emit('createChild', stage.id)">新建子阶段</el-button></div>
|
||||
<StageSchedulePanel v-if="stage" :project-id="projectId" :iteration-id="iterationId" :stage-id="stage.id" :schedule="stage" :completed="['COMPLETED', 'LEGACY_PASSED'].includes(stage.executionStatus || '')" :can-schedule-stage="stage.canScheduleStage === true" @changed="emit('changed')" />
|
||||
<el-alert v-if="stage?.nodeType === 'PURCHASE'" title="采购阶段通过批次验收进度确认完成,不创建工作项。旧工作项如需迁移请由所属阶段负责人调整归属。" type="info" :closable="false" />
|
||||
<div v-if="stage?.nodeType !== 'PURCHASE'" class="drawer-filters"><el-input v-model="keyword" size="small" clearable placeholder="搜索工作项名称" /><el-select v-model="typeFilter" size="small" clearable placeholder="全部类型"><el-option v-for="(name, type) in typeNames" :key="type" :value="type" :label="name" /></el-select><el-select v-model="statusFilter" size="small" clearable placeholder="全部状态"><el-option v-for="(name, status) in statusNames" :key="status" :value="status" :label="name" /></el-select></div>
|
||||
<p class="drawer-count">显示 {{ filteredItems.length }}/{{ iterationId ? currentTotal : currentItems.length }} 个</p>
|
||||
<el-alert v-if="failure" :title="failure" type="error" :closable="false" />
|
||||
@ -49,7 +49,7 @@ import StageDeliverySnapshot from './StageDeliverySnapshot.vue'
|
||||
import type { FlowView, Member, ItemType, Lifecycle, StageRevision, StageRevisionDetail, WorkItem } from '../../../types'
|
||||
import { itemStatusLabel, stageStatusNames, stageStatusLabel, statusNames, typeNames } from '../../../shared/constants/labels'
|
||||
|
||||
const props = defineProps<{ projectId: number; iterationId?: number; stageId: number | null; initialTab: 'current' | 'history'; view: FlowView; members: Member[]; canCreate: boolean; canManage?: boolean }>()
|
||||
const props = defineProps<{ projectId: number; iterationId?: number; stageId: number | null; initialTab: 'current' | 'history'; view: FlowView; members: Member[]; canCreate: boolean; canConfigureStages?: boolean }>()
|
||||
const emit = defineEmits<{ close: []; open: [id: number]; create: [stageId: number | null]; changed: []; navigate: [id: number]; createChild: [id: number]; editing: [value: boolean] }>()
|
||||
const mode = ref<'current' | 'history'>('current'), keyword = ref(''), typeFilter = ref<ItemType | null>(null), statusFilter = ref<Lifecycle | null>(null)
|
||||
const currentRows = ref<WorkItem[]>([]), currentTotal = ref(0), currentPage = ref(1), currentLoading = ref(false), revisionPage = ref(1), revisionTotal = ref(0), detailPage = ref(1)
|
||||
@ -58,6 +58,8 @@ const snapshotItem = ref<WorkItem | null>(null)
|
||||
const children = computed(() => props.view.stages.filter(value => value.parentStageId === props.stageId))
|
||||
const stage = computed(() => props.view.stages.find(value => value.id === props.stageId))
|
||||
const stageName = computed(() => stage.value?.name || '未分配')
|
||||
/** 未分配节点只能查看,创建必须使用当前服务端明确授权的真实阶段。 */
|
||||
function createItem() { if (props.canCreate && stage.value?.canCreateWorkItem === true) emit('create', stage.value.id) }
|
||||
/** 当前迭代使用阶段分页结果;旧快照仅用于兼容组件独立展示。 */
|
||||
const currentItems = computed(() => {
|
||||
const known = new Set(props.view.stages.map(value => value.id))
|
||||
|
||||
@ -10,17 +10,23 @@
|
||||
<el-alert v-else-if="stageFrozen" type="info" :closable="false" :title="stagePending ? '当前阶段正在审批,交付已冻结;需要修改请负责人先撤回申请,评论仍可讨论。' : '当前阶段已完成,工作项已冻结;如需重做,请由项目经理从流程视图回退。'" class="failure" />
|
||||
<el-alert v-if="detail.scheduleReviewRequired" type="warning" :closable="false" :title="detail.scheduleReviewClosed ? '本轮未确认排期;参考计划未参与本轮排期和超期统计。' : '上游阶段已回退,参考计划尚未生效;请确认阶段计划后调整工作项排期。'" class="failure" />
|
||||
<p v-if="detail.scheduleReviewRequired" class="muted">参考时间:{{ plannedDate(detail.referencePlannedStartAt || null) }} → {{ plannedDate(detail.referencePlannedEndAt || null) }}</p>
|
||||
<el-button v-if="detail.scheduleReviewRequired && !detail.scheduleReviewClosed && writable" size="small" @click="confirmReview">确认保留原排期</el-button>
|
||||
<div class="actions" v-if="writable">
|
||||
<el-button v-if="detail.scheduleReviewRequired && !detail.scheduleReviewClosed && canSchedule" size="small" @click="confirmReview">确认保留原排期</el-button>
|
||||
<el-button v-if="canAssignAssignee" size="small" :disabled="busy || loading" @click="openAssignee">分配负责人</el-button>
|
||||
<el-button v-if="canRepairStage" size="small" :disabled="busy || loading" @click="openAssignment">补充所属阶段</el-button>
|
||||
<div class="actions" v-if="canExecuteItem">
|
||||
<el-tooltip :disabled="detail.canStart" :content="blockedText"><span><el-button type="primary" :disabled="!canExecute || !detail.canStart || busy" @click="start">开始</el-button></span></el-tooltip>
|
||||
<el-button @click="emit('edit', detail)">编辑</el-button><el-button v-if="canManage && detail.status === 'READY' && !detail.parentTaskId" size="small" @click="openAssignment">调整阶段归属</el-button><el-button v-if="!detail.scheduleReviewClosed" size="small" @click="scheduleOpen = true">调整排期</el-button>
|
||||
<el-button v-if="detail.canCreateChild" :disabled="busy" @click="emit('create-child', detail)">创建子任务</el-button>
|
||||
<el-button v-if="detail.status === 'IN_PROGRESS'" :disabled="busy || !canCompleteWorkItem(detail)" :title="canCompleteWorkItem(detail) ? undefined : completionBlockedText(detail)" @click="transition('COMPLETED')">完成</el-button>
|
||||
<el-button v-if="detail.status === 'COMPLETED'" :disabled="busy" @click="transition('CLOSED')">关闭</el-button>
|
||||
<el-button v-if="detail.status === 'CLOSED'" :disabled="busy || !canCompleteWorkItem(detail)" :title="canCompleteWorkItem(detail) ? undefined : completionBlockedText(detail)" @click="transition('COMPLETED')">重开到已完成</el-button>
|
||||
<el-button v-if="!['READY', 'CLOSED'].includes(detail.status)" :disabled="busy" @click="transition('READY')">回退待开始</el-button>
|
||||
<el-button v-if="['READY', 'IN_PROGRESS'].includes(detail.status)" :disabled="busy" @click="transition('CANCELLED')">取消工作项</el-button>
|
||||
<el-button type="danger" text :disabled="busy" @click="remove">删除</el-button>
|
||||
</div>
|
||||
<div class="actions" v-if="writable || canSchedule">
|
||||
<el-button v-if="writable" :disabled="busy" @click="editItem">编辑</el-button>
|
||||
<el-button v-if="canAssignStage" size="small" :disabled="busy" @click="openAssignment">调整阶段归属</el-button>
|
||||
<el-button v-if="canSchedule && !detail.scheduleReviewClosed" size="small" :disabled="busy" @click="scheduleOpen = true">调整排期</el-button>
|
||||
<el-button v-if="writable && detail.canCreateChild === true" :disabled="busy" @click="createChild">创建子任务</el-button>
|
||||
<el-button v-if="writable && detail.canDeleteWorkItem === true" type="danger" text :disabled="busy" @click="remove">删除</el-button>
|
||||
</div>
|
||||
<el-alert v-if="!detail.canStart && detail.status === 'READY'" :title="blockedText" type="warning" :closable="false" class="failure" />
|
||||
<el-alert v-if="['IN_PROGRESS', 'CLOSED'].includes(detail.status) && !canCompleteWorkItem(detail)" type="warning" :closable="false" :title="completionBlockedText(detail)" class="failure" />
|
||||
@ -38,7 +44,7 @@
|
||||
<el-descriptions-item label="实际结束">{{ displayTime(detail.actualEndAt) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<section v-if="detail.type === 'TASK' && !detail.parentTaskId">
|
||||
<div class="section-heading"><h3>子任务</h3><span>已结束 {{ detail.childTerminalCount || 0 }}/{{ detail.childCount || 0 }}(包含已取消)</span><el-button v-if="writable && detail.canCreateChild" size="small" @click="emit('create-child', detail)">创建子任务</el-button></div>
|
||||
<div class="section-heading"><h3>子任务</h3><span>已结束 {{ detail.childTerminalCount || 0 }}/{{ detail.childCount || 0 }}(包含已取消)</span><el-button v-if="writable && detail.canCreateChild === true" size="small" @click="createChild">创建子任务</el-button></div>
|
||||
<el-table :data="childItems" empty-text="暂无子任务"><el-table-column label="任务"><template #default="{ row }"><el-link @click="emit('open', row.id)">{{ row.title }}</el-link></template></el-table-column><el-table-column label="状态" width="130" class-name="business-status-cell"><template #default="{ row }">{{ itemStatusLabel(row) }}</template></el-table-column><el-table-column label="预计结束"><template #default="{ row }">{{ plannedDate(row.plannedEndAt) }}</template></el-table-column></el-table>
|
||||
</section>
|
||||
<section>
|
||||
@ -54,14 +60,15 @@
|
||||
<el-alert v-if="!detail.historical" type="info" :closable="false" :title="detail.scheduleConstraints.earliestPlannedStartAt ? `最早合法预计开始:${planningLimitDate(detail.scheduleConstraints.earliestPlannedStartAt, 'start', 'min')}` : '暂无有效的前置计划边界;采购出边使用预计开始,其他执行边使用预计结束。缺少所需边界时须先完善前置计划。'" />
|
||||
</section>
|
||||
<section><h3>评论</h3><article v-for="comment in detail.comments" :key="comment.id" class="comment"><strong>{{ comment.author }}</strong><p>{{ comment.body }}</p></article><template v-if="canDiscuss"><el-input v-model="commentText" type="textarea" :rows="3" placeholder="添加评论" maxlength="10000" /><el-button size="small" class="comment-submit" :disabled="!commentText.trim() || busy" @click="comment">发送评论</el-button></template></section>
|
||||
<section><div class="section-heading"><h3>附件</h3><label v-if="writable" class="upload-link">上传附件(最多 {{ ATTACHMENT_MAX_SIZE_LABEL }})<input type="file" :disabled="busy" @change="upload" /></label></div><div v-for="file in detail.attachments" :key="file.id" class="attachment"><el-link class="attachment-name" :title="file.name" @click="download(file.id, file.name)">{{ file.name }}</el-link><div class="attachment-actions"><span>{{ (file.size / 1024).toFixed(1) }} KB</span><el-button v-if="writable && detail.canDeleteAttachments" size="small" link type="danger" :disabled="busy || attachmentConfirmationOpen" @click="removeAttachment(file)">删除</el-button></div></div></section>
|
||||
<section><div class="section-heading"><h3>附件</h3><label v-if="canUpload" class="upload-link">上传附件(最多 {{ ATTACHMENT_MAX_SIZE_LABEL }})<input type="file" :disabled="busy" @change="upload" /></label></div><div v-for="file in detail.attachments" :key="file.id" class="attachment"><el-link class="attachment-name" :title="file.name" @click="download(file.id, file.name)">{{ file.name }}</el-link><div class="attachment-actions"><span>{{ (file.size / 1024).toFixed(1) }} KB</span><el-button v-if="canDeleteAttachments" size="small" link type="danger" :disabled="busy || attachmentConfirmationOpen" @click="removeAttachment(file)">删除</el-button></div></div></section>
|
||||
<section><h3>操作历史</h3><div v-for="entry in detail.history" :key="entry.id" class="history"><strong>{{ actionNames[entry.action] || '工作项更新' }}</strong><span>{{ members.find(m => m.userId === entry.createdBy)?.name || `用户 #${entry.createdBy}` }}</span><p>{{ historyText(entry.detail) }}</p><small class="muted">{{ displayTime(entry.createdAt) }}</small></div></section>
|
||||
</template>
|
||||
</div>
|
||||
</el-drawer>
|
||||
|
||||
<el-dialog :close-on-click-modal="false" v-model="assignmentOpen" title="调整工作项阶段归属" width="480px" append-to-body><el-alert type="info" :closable="false" title="仅项目管理者可移动待开始根任务,子任务同步继承。阶段组不能直接承载工作项;后端复验新门禁、排期及循环依赖。" /><el-select v-model="assignmentStageId" size="small" clearable filterable placeholder="未分配阶段" style="width:100%;margin:14px 0"><el-option v-for="stage in stages.filter(value => value.stageKind !== 'GROUP' && value.nodeType !== 'PURCHASE')" :key="stage.id" :value="stage.id" :label="stage.stagePath || stage.name" /></el-select><el-alert v-if="assignmentFailure" :title="assignmentFailure" type="error" :closable="false" /><template #footer><el-button size="small" @click="assignmentOpen = false">取消</el-button><el-button size="small" type="primary" :loading="busy" @click="saveAssignment">保存</el-button></template></el-dialog>
|
||||
<ItemScheduleDialog :item-id="scheduleOpen && writable ? id : null" @close="scheduleOpen = false" @saved="scheduleSaved" />
|
||||
<el-dialog :close-on-click-modal="false" v-model="assignmentOpen" :title="canRepairStage ? '补充工作项所属阶段' : '调整工作项阶段归属'" width="480px" append-to-body><el-alert type="info" :closable="false" :title="canRepairStage ? '迭代创建者仅可补齐旧工作项缺失的所属阶段;子任务继承阶段。本次只保存归属,不修改内容、排期或状态,阶段组及采购阶段不能承载工作项。' : '阶段负责人可将待开始根任务移至本人负责的阶段;子任务继承阶段,后端同时复验目标阶段、新门禁、排期及循环依赖。阶段组不能直接承载工作项。'" /><el-select v-model="assignmentStageId" size="small" filterable :placeholder="canRepairStage ? '选择所属阶段' : '选择本人负责的阶段'" style="width:100%;margin:14px 0"><el-option v-for="stage in assignableStages" :key="stage.id" :value="stage.id" :label="stage.stagePath || stage.name" /></el-select><el-alert v-if="assignmentFailure" :title="assignmentFailure" type="error" :closable="false" /><template #footer><el-button size="small" @click="assignmentOpen = false">取消</el-button><el-button size="small" type="primary" :loading="busy" :disabled="!canAssignStage || !assignableStages.some(stage => stage.id === assignmentStageId)" @click="saveAssignment">保存</el-button></template></el-dialog>
|
||||
<el-dialog :close-on-click-modal="false" v-model="assigneeOpen" title="分配负责人" width="480px" append-to-body><el-alert type="info" :closable="false" title="所属阶段负责人或迭代创建者可补齐已有未分配工作项的负责人;本次仅保存负责人,不开放其他字段编辑,已有负责人不能覆盖。" /><el-select v-model="assigneeId" filterable placeholder="选择负责人" style="width:100%;margin:14px 0"><el-option v-for="member in members" :key="member.userId" :value="member.userId" :label="member.name" /></el-select><el-alert v-if="assigneeFailure" :title="assigneeFailure" type="error" :closable="false" /><template #footer><el-button @click="assigneeOpen = false">取消</el-button><el-button type="primary" :loading="busy" :disabled="!canAssignAssignee || !assigneeId" @click="saveAssignee">分配</el-button></template></el-dialog>
|
||||
<ItemScheduleDialog :item-id="scheduleOpen && canSchedule ? id : null" @close="scheduleOpen = false" @saved="scheduleSaved" />
|
||||
<el-dialog :close-on-click-modal="false" v-model="depOpen" :title="editingDependency ? '编辑前置条件' : '添加前置条件'" width="600px" append-to-body>
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="前置工作项"><PredecessorPicker :model-value="sourceId ? [sourceId] : []" :project-id="detail?.projectId || projectId || 0" :iteration-id="detail?.iterationId" :active="depOpen" :multiple="false" :exclude-id="id" :initial-options="dependencySource" @update:model-value="sourceId = $event[0] ?? null" @error="depFailure = $event" /></el-form-item>
|
||||
@ -93,6 +100,7 @@ const attachmentConfirmationOpen = ref(false)
|
||||
const deleteConfirmationOpen = ref(false)
|
||||
let loadSequence = 0, scopeSequence = 0
|
||||
const scheduleOpen = ref(false), assignmentOpen = ref(false), assignmentStageId = ref<number | null>(null), assignmentFailure = ref('')
|
||||
const assigneeOpen = ref(false), assigneeId = ref<number | null>(null), assigneeFailure = ref('')
|
||||
const scheduleLabel = computed(() => detail.value?.scheduleConstraints.scheduleValidationStatus === 'VALID' ? '排期合法' : detail.value?.scheduleConstraints.scheduleValidationStatus === 'CONFLICT' ? '排期冲突' : '排期未完成')
|
||||
const blockedText = computed(() => detail.value?.blockedReasons.map(r => r.stageId ? `${r.sourceName}:${r.message}` : r.message || `${r.sourceName}:当前 ${lifecycleLabels[r.currentStatus || ''] || r.currentStatus},要求 ${lifecycleLabels[String(r.expectedStatus)] || r.expectedStatus}`).join(';') || '当前无法开始')
|
||||
// 准入条件直接使用详情响应,包含组继承门禁,避免从画布直连边漏掉祖先条件或混入旧轮次状态。
|
||||
@ -115,16 +123,44 @@ const stageCompleted = computed(() =>
|
||||
|| ['COMPLETED', 'LEGACY_PASSED'].includes(currentStage.value?.executionStatus || '')
|
||||
)
|
||||
const stageFrozen = computed(() => stagePending.value || stageCompleted.value)
|
||||
const writable = computed(() => props.canWrite && !detail.value?.iterationReadOnly && !detail.value?.historical && !stageFrozen.value)
|
||||
const canDiscuss = computed(() => props.canWrite && !detail.value?.iterationReadOnly && !detail.value?.historical && !stageCompleted.value)
|
||||
// 各动作独立读取服务端能力;元数据维护、执行、排期及协作不能互相替代授权。
|
||||
const writableScope = computed(() => !detail.value?.iterationReadOnly && !detail.value?.historical && !stageFrozen.value)
|
||||
const writable = computed(() => props.canWrite && writableScope.value && detail.value?.canEditWorkItem === true)
|
||||
const canExecuteItem = computed(() => props.canWrite && writableScope.value && detail.value?.canExecuteWorkItem === true)
|
||||
const canDiscuss = computed(() => detail.value?.canDiscuss === true && !detail.value.iterationReadOnly && !detail.value.historical && !stageCompleted.value)
|
||||
const canUpload = computed(() => detail.value?.canUploadAttachments === true && writableScope.value)
|
||||
const canDeleteAttachments = computed(() => props.canWrite && writableScope.value && detail.value?.canDeleteAttachments === true)
|
||||
const canSchedule = computed(() => props.canWrite && writableScope.value && detail.value?.canScheduleWorkItem === true)
|
||||
/** 迭代创建者的旧项修复独立于普通写权限;只能填补缺失值,不能用于打开普通编辑器。 */
|
||||
const canRepairStage = computed(() => writableScope.value && detail.value?.canRepairStage === true && detail.value.stageId == null && detail.value.status === 'READY' && !detail.value.parentTaskId)
|
||||
const canAssignStage = computed(() => canRepairStage.value || writable.value && detail.value?.canAssignStage === true && detail.value.status === 'READY' && !detail.value.parentTaskId)
|
||||
// 修复可选择他人负责的有效工作阶段;新建及普通迁移仍只列本人负责的阶段,不能混用本列表。
|
||||
const assignableStages = computed(() => props.stages.filter(stage => (canRepairStage.value || stage.canCreateWorkItem === true) && stage.stageKind !== 'GROUP' && stage.nodeType !== 'PURCHASE' && stage.approvalStatus !== 'PENDING' && !['COMPLETED', 'LEGACY_PASSED'].includes(stage.executionStatus || '')))
|
||||
/** 普通补分配仍依赖项目写资格;创建者只在独立修复能力有效且缺少负责人时获得专用入口。 */
|
||||
const canAssignAssignee = computed(() => writableScope.value && detail.value?.assigneeId == null && (detail.value?.canRepairAssignee === true || props.canWrite && detail.value?.canAssignAssignee === true))
|
||||
const editableDependencies = computed(() => writable.value && detail.value?.status === 'READY')
|
||||
const loadedChildren = ref<WorkItem[]>([])
|
||||
const childItems = computed(() => detail.value?.historical ? detail.value.historicalChildren || [] : loadedChildren.value)
|
||||
/** 阶段归属使用独立的经理入口,普通编辑不能清空阶段绕过门禁。 */
|
||||
function openAssignment() { if (!detail.value || !props.canManage) return; assignmentStageId.value = detail.value.stageId ?? null; assignmentFailure.value = ''; assignmentOpen.value = true }
|
||||
/** 修改事件也检查当前对象能力,避免旧窗口或合成事件打开普通编辑器。 */
|
||||
function editItem() { if (writable.value && detail.value) emit('edit', detail.value) }
|
||||
/** 子任务资格只取当前父任务维护能力,不能借工作项执行资格创建子项。 */
|
||||
function createChild() { if (writable.value && detail.value?.canCreateChild === true) emit('create-child', detail.value) }
|
||||
/** 未分配项仅打开负责人专用草稿,不把其他工作项字段传给补分配接口。 */
|
||||
function openAssignee() { if (!canAssignAssignee.value) return; assigneeId.value = null; assigneeFailure.value = ''; assigneeOpen.value = true }
|
||||
/** 补分配绑定当前对象和版本,换详情作废旧回调;服务端持锁复验阶段负责人/迭代创建者及缺失值。 */
|
||||
async function saveAssignee() {
|
||||
if (!assigneeOpen.value || !canAssignAssignee.value || !detail.value || !assigneeId.value || busy.value || loading.value) return
|
||||
const sequence = scopeSequence, item = detail.value, selected = assigneeId.value
|
||||
busy.value = true; assigneeFailure.value = ''; loadSequence++
|
||||
try { await api.assignAssignee(item.id, selected, item.version); if (sequence !== scopeSequence) return; assigneeOpen.value = false; emit('changed'); await load() }
|
||||
catch (error) { if (sequence === scopeSequence) assigneeFailure.value = errorText(error) }
|
||||
finally { if (sequence === scopeSequence) busy.value = false }
|
||||
}
|
||||
/** 阶段迁移与创建者补归属共用字段受限的独立入口;普通编辑不能清空阶段绕过门禁。 */
|
||||
function openAssignment() { if (!detail.value || !canAssignStage.value) return; assignmentStageId.value = detail.value.stageId ?? null; assignmentFailure.value = ''; assignmentOpen.value = true }
|
||||
/** 阶段归属提交绑定当前详情;切换对象后不关闭新表单,也不显示旧请求错误。 */
|
||||
async function saveAssignment() {
|
||||
if (!detail.value || !props.canManage || !writable.value || busy.value || loading.value) return
|
||||
if (!detail.value || !assignmentOpen.value || !canAssignStage.value || !assignableStages.value.some(stage => stage.id === assignmentStageId.value) || busy.value || loading.value) return
|
||||
const sequence = scopeSequence, item = detail.value, stageId = assignmentStageId.value
|
||||
busy.value = true; assignmentFailure.value = ''; loadSequence++
|
||||
try {
|
||||
@ -144,6 +180,9 @@ watch(() => [props.id, props.projectId, props.iterationId], () => {
|
||||
commentText.value = ''
|
||||
scheduleOpen.value = false
|
||||
assignmentOpen.value = false
|
||||
assigneeOpen.value = false
|
||||
assigneeId.value = null
|
||||
assigneeFailure.value = ''
|
||||
depOpen.value = false
|
||||
sourceId.value = null
|
||||
loadedChildren.value = []
|
||||
@ -182,11 +221,12 @@ function displayTime(value: string | null) { return value ? localTime(value, 'As
|
||||
* 串行提交当前工作项动作,仅在用户仍停留于本次详情时应用成功或失败回调。
|
||||
* 前台重读期间不提交旧版本;只使在途后台读失效,避免前台加载状态失去对应的结束回调。
|
||||
* @param commit 已捕获工作项 ID 和版本的请求,不能在等待之后重新读取当前详情作为写入目标。
|
||||
* @param discussion 评论允许在待审批阶段发送,其余写入仍受交付冻结限制。
|
||||
* @param capability 本次动作对应的对象能力;评论允许待审批讨论,上传仍受冻结限制。
|
||||
* @param onSuccess 本次详情内的成功处理,例如清理已发送草稿或关闭已删除对象。
|
||||
*/
|
||||
async function action(commit: () => Promise<unknown>, discussion = false, onSuccess?: () => void) {
|
||||
if (!detail.value || busy.value || loading.value || !(discussion ? canDiscuss.value : writable.value)) return
|
||||
async function action(commit: () => Promise<unknown>, capability: 'edit' | 'execute' | 'discuss' | 'upload' | 'schedule' | 'delete' | 'attachment' = 'edit', onSuccess?: () => void) {
|
||||
const allowed = capability === 'execute' ? canExecuteItem.value : capability === 'discuss' ? canDiscuss.value : capability === 'upload' ? canUpload.value : capability === 'schedule' ? canSchedule.value : capability === 'attachment' ? canDeleteAttachments.value : writable.value && (capability === 'delete' ? detail.value?.canDeleteWorkItem === true : true)
|
||||
if (!detail.value || busy.value || loading.value || !allowed) return
|
||||
const sequence = scopeSequence
|
||||
busy.value = true; failure.value = ''; loadSequence++
|
||||
try {
|
||||
@ -197,38 +237,38 @@ async function action(commit: () => Promise<unknown>, discussion = false, onSucc
|
||||
finally { if (sequence === scopeSequence) busy.value = false }
|
||||
}
|
||||
/** 开始必须具备服务端 canStart,合成事件也不能绕过负责人或准入限制;提交详情版本防止过期点击。 */
|
||||
async function start() { if (props.canExecute && writable.value && detail.value?.canStart) { const item = detail.value; await action(() => api.start(item.id, item.version)) } }
|
||||
async function start() { if (props.canExecute && canExecuteItem.value && detail.value?.canStart) { const item = detail.value; await action(() => api.start(item.id, item.version), 'execute') } }
|
||||
/** 参考计划按整日重新确认,须通过阶段、父子和前置校验;失败保留待复核状态。 */
|
||||
async function confirmReview() { if (detail.value?.scheduleReviewRequired) { const item = detail.value; await action(() => api.confirmScheduleReview(item.id, item.version)) } }
|
||||
async function confirmReview() { if (canSchedule.value && detail.value?.scheduleReviewRequired) { const item = detail.value; await action(() => api.confirmScheduleReview(item.id, item.version), 'schedule') } }
|
||||
/** 排期成功后关闭草稿并刷新详情和所有视图。 */
|
||||
async function scheduleSaved() { scheduleOpen.value = false; emit('changed'); await load() }
|
||||
/**
|
||||
* 提交当前详情版本的状态动作;开始和任何进入完成的路径先检查服务端能力,防止事件绕过禁用按钮。
|
||||
* @param status 目标状态;回退、取消及关闭保持原权限,服务端仍复验完整状态机和子任务门禁。
|
||||
* @param status 目标状态;所有工作项状态操作均须当前负责人,服务端仍复验完整状态机和子任务门禁。
|
||||
*/
|
||||
async function transition(status: Lifecycle) {
|
||||
const item = detail.value
|
||||
if (!item) return
|
||||
if (!item || !canExecuteItem.value) return
|
||||
if (status === 'IN_PROGRESS' && (!props.canExecute || !item.canStart)) { failure.value = blockedText.value; return }
|
||||
if (status === 'COMPLETED' && !canCompleteWorkItem(item)) { failure.value = completionBlockedText(item); return }
|
||||
await action(() => api.transition(item.id, status, item.version))
|
||||
await action(() => api.transition(item.id, status, item.version), 'execute')
|
||||
}
|
||||
/** 确认绑定打开时的工作项及版本,换对象或关闭后作废;后端继续复验软删除条件。 */
|
||||
async function remove() {
|
||||
if (!detail.value || !writable.value || busy.value || loading.value || deleteConfirmationOpen.value) return
|
||||
if (!detail.value || detail.value.canDeleteWorkItem !== true || !writable.value || busy.value || loading.value || deleteConfirmationOpen.value) return
|
||||
const item = detail.value, sequence = scopeSequence
|
||||
deleteConfirmationOpen.value = true
|
||||
try { await ElMessageBox.confirm(`删除工作项“${item.title}”?操作历史会保留,存在已开始的后续任务时将拒绝删除。`, '删除工作项', { type: 'warning', closeOnClickModal: false }) }
|
||||
catch { return }
|
||||
finally { if (sequence === scopeSequence) deleteConfirmationOpen.value = false }
|
||||
if (sequence !== scopeSequence) return
|
||||
await action(() => api.remove(item.id, item.version), false, () => emit('close'))
|
||||
await action(() => api.remove(item.id, item.version), 'delete', () => emit('close'))
|
||||
}
|
||||
/** 评论使用提交时的文本;只有未继续编辑的同一份草稿才在成功后清空。 */
|
||||
async function comment() {
|
||||
if (!detail.value || !commentText.value.trim()) return
|
||||
const itemId = detail.value.id, body = commentText.value
|
||||
await action(() => api.comment(itemId, body), true, () => { if (commentText.value === body) commentText.value = '' })
|
||||
await action(() => api.comment(itemId, body), 'discuss', () => { if (commentText.value === body) commentText.value = '' })
|
||||
}
|
||||
/** 选择文件时固定所属工作项,按协作统一的 50MB 上限检查后上传;清空 input 以允许重试同一文件。 */
|
||||
async function upload(event: Event) {
|
||||
@ -238,7 +278,7 @@ async function upload(event: Event) {
|
||||
if (file.size > ATTACHMENT_MAX_BYTES) {
|
||||
ElMessage.error(`附件不能超过 ${ATTACHMENT_MAX_SIZE_LABEL}`); input.value = ''; return
|
||||
}
|
||||
await action(() => api.upload(itemId, file))
|
||||
await action(() => api.upload(itemId, file), 'upload')
|
||||
input.value = ''
|
||||
}
|
||||
/** 鉴权下载失败仅反馈到发起下载的详情,不把旧错误展示在另一工作项中。 */
|
||||
@ -254,19 +294,19 @@ async function download(id: number, name: string) {
|
||||
* 确认期间暂停后台同步;切换详情后放弃旧确认,避免在另一个工作项中执行旧操作。
|
||||
*/
|
||||
async function removeAttachment(file: { id: number; name: string }) {
|
||||
if (!detail.value?.canDeleteAttachments || !writable.value || busy.value || loading.value || attachmentConfirmationOpen.value) return
|
||||
if (!detail.value || !canDeleteAttachments.value || busy.value || loading.value || attachmentConfirmationOpen.value) return
|
||||
const itemId = detail.value.id, sequence = scopeSequence
|
||||
attachmentConfirmationOpen.value = true
|
||||
try {
|
||||
await ElMessageBox.confirm(`删除附件“${file.name}”?删除后将无法下载。`, '删除附件', { type: 'warning', closeOnClickModal: false, confirmButtonText: '删除', cancelButtonText: '取消' })
|
||||
} catch { return } finally { if (sequence === scopeSequence) attachmentConfirmationOpen.value = false }
|
||||
if (sequence !== scopeSequence || props.id !== itemId || detail.value?.id !== itemId || !detail.value.canDeleteAttachments) return
|
||||
await action(() => api.removeAttachment(itemId, file.id))
|
||||
await action(() => api.removeAttachment(itemId, file.id), 'attachment')
|
||||
}
|
||||
|
||||
const depOpen = ref(false), editingDependency = ref<Condition | null>(null), sourceId = ref<number | null>(null), depFailure = ref('')
|
||||
// 删除确认属于未提交的用户操作,静默同步不能在确认期间替换当前详情。
|
||||
const isEditing = computed(() => busy.value || loading.value || deleteConfirmationOpen.value || attachmentConfirmationOpen.value || scheduleOpen.value || assignmentOpen.value || depOpen.value || !!commentText.value.trim())
|
||||
const isEditing = computed(() => busy.value || loading.value || deleteConfirmationOpen.value || attachmentConfirmationOpen.value || scheduleOpen.value || assignmentOpen.value || assigneeOpen.value || depOpen.value || !!commentText.value.trim())
|
||||
/** 工作区轮询只静默更新空闲详情,评论、依赖和排期草稿均保留到用户完成操作。 */
|
||||
async function synchronize() { if (!isEditing.value) await load(true) }
|
||||
defineExpose({ isEditing, synchronize })
|
||||
@ -274,9 +314,11 @@ defineExpose({ isEditing, synchronize })
|
||||
const dependencySource = computed<PredecessorOption[]>(() => { const condition = editingDependency.value; return condition ? [{ id: condition.sourceId, title: condition.sourceName || '已选择工作项', type: condition.sourceType, plannedEndAt: condition.plannedEndAt }] : [] })
|
||||
/** 生命周期变化立即销毁依赖草稿,不能继续提交已打开的编辑窗口。 */
|
||||
watch(editableDependencies, allowed => { if (!allowed) { depOpen.value = false; sourceId.value = null } })
|
||||
/** 能力刷新后立即销毁失权的专用草稿,旧弹窗不能保留上一次负责人或阶段配置资格。 */
|
||||
watch([canSchedule, canAssignStage, canAssignAssignee], ([schedule, stage, assignee]) => { if (!schedule) scheduleOpen.value = false; if (!stage) assignmentOpen.value = false; if (!assignee) assigneeOpen.value = false })
|
||||
void load()
|
||||
/** 依赖编辑仅针对当前待开始工作项,候选组件覆盖当前迭代全部工作项类型。 */
|
||||
function openDependency(condition?: Condition) { editingDependency.value = condition || null; depFailure.value = ''; sourceId.value = condition?.sourceId || null; depOpen.value = true }
|
||||
function openDependency(condition?: Condition) { if (!editableDependencies.value) return; editingDependency.value = condition || null; depFailure.value = ''; sourceId.value = condition?.sourceId || null; depOpen.value = true }
|
||||
/** 保存依赖绑定本次详情及双版本;同次请求防重,切换后的旧结果不关闭新表单。 */
|
||||
async function saveDependency() {
|
||||
if (!detail.value || !editableDependencies.value || busy.value || loading.value) return
|
||||
@ -290,7 +332,7 @@ async function saveDependency() {
|
||||
finally { if (sequence === scopeSequence) busy.value = false }
|
||||
}
|
||||
/** 删除依赖仍提交任务与依赖版本,失败不从页面移除条件。 */
|
||||
async function deleteDependency(condition: Condition) { if (detail.value) { const item = detail.value; await action(() => api.removeDependency(item.id, condition.id, item.version, condition.version)) } }
|
||||
async function deleteDependency(condition: Condition) { if (editableDependencies.value && detail.value) { const item = detail.value; await action(() => api.removeDependency(item.id, condition.id, item.version, condition.version)) } }
|
||||
|
||||
/** 将审计记录转为业务摘要,预计时间仅显示日期;保留原始审计数据及事件发生时间。 */
|
||||
function historyText(raw: string): string {
|
||||
|
||||
@ -5,23 +5,24 @@
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="8"><el-form-item label="类型"><el-select v-model="draft.type" :disabled="!!item || !!parent"><el-option v-for="(name, type) in typeNames" :key="type" :value="type" :label="name" /></el-select></el-form-item></el-col>
|
||||
<el-col :span="8"><el-form-item label="优先级"><el-select v-model="draft.priority"><el-option v-for="(name, priority) in priorityNames" :key="priority" :value="priority" :label="name" /></el-select></el-form-item></el-col>
|
||||
<el-col :span="8"><el-form-item label="负责人"><el-select v-model="draft.assigneeId" clearable><el-option v-for="member in members" :key="member.userId" :value="member.userId" :label="member.name" /></el-select></el-form-item></el-col>
|
||||
<el-col :span="8"><el-form-item label="负责人" required><el-select v-model="draft.assigneeId" filterable><el-option v-for="member in members" :key="member.userId" :value="member.userId" :label="member.name" /></el-select></el-form-item></el-col>
|
||||
</el-row>
|
||||
<el-form-item label="协作人"><el-select v-model="draft.collaboratorIds" multiple filterable clearable collapse-tags collapse-tags-tooltip :max-collapse-tags="3" placeholder="选择项目成员(可多选)"><el-option v-for="member in members" :key="member.userId" :value="member.userId" :label="member.name" /></el-select></el-form-item>
|
||||
<el-form-item label="标题" required><el-input v-model="draft.title" maxlength="200" /></el-form-item>
|
||||
<el-form-item label="描述"><el-input v-model="draft.description" type="textarea" :rows="4" maxlength="50000" /></el-form-item>
|
||||
<el-form-item label="所属阶段"><el-select v-model="draft.stageId" :disabled="!!parent || !!item" clearable placeholder="未分配阶段"><el-option v-for="stage in workStages" :key="stage.id" :value="stage.id" :label="stage.stagePath || stage.name" /></el-select><span v-if="item" class="dependency-note">归属调整由项目管理者通过详情中的阶段归属操作完成。</span></el-form-item>
|
||||
<el-form-item label="所属阶段" :required="!item"><el-select v-model="draft.stageId" :disabled="!!parent || !!item" placeholder="选择本人负责的阶段"><el-option v-for="stage in workStages" :key="stage.id" :value="stage.id" :label="stage.stagePath || stage.name" /></el-select><span v-if="item" class="dependency-note">阶段负责人通过详情中的阶段归属操作调整归属。</span></el-form-item>
|
||||
<el-form-item v-if="!item" label="前置工作项(可选)"><PredecessorPicker v-model="draft.predecessorWorkItemIds" :project-id="projectId" :iteration-id="iterationId" :active="visible" @error="constraintFailure = $event" /><span class="dependency-note">需求、任务、缺陷均可选择;所有前置工作项已完成或已关闭后才能开始。</span></el-form-item>
|
||||
<el-alert v-if="!item && constraints?.earliestPlannedStartAt" type="info" :closable="false" :title="`最早合法预计开始:${planningLimitDate(constraints.earliestPlannedStartAt, 'start', 'min')}`" />
|
||||
<el-alert v-if="!item && constraints?.scheduleBlockedReasons.length" type="warning" :closable="false" :title="constraints.scheduleBlockedReasons.map(reason => `${reason.sourceName || ''}:${reason.message || '排期约束未完整'}`).join(';')" />
|
||||
<el-alert v-if="constraintFailure" type="warning" :closable="false" :title="constraintFailure" />
|
||||
<el-row :gutter="16"><el-col :span="12"><el-form-item label="预计开始"><TimeField boundary="start" :disabled="!!item?.scheduleReviewRequired" v-model="draft.plannedStartAt" :zone="zone" :earliest="constraints?.earliestPlannedStartAt || parent?.plannedStartAt" @invalid="invalidStart = $event" /></el-form-item></el-col><el-col :span="12"><el-form-item label="预计结束"><TimeField boundary="end" :disabled="!!item?.scheduleReviewRequired" v-model="draft.plannedEndAt" :zone="zone" :latest="constraints?.latestPlannedEndAt || parent?.plannedEndAt" @invalid="invalidEnd = $event" /></el-form-item></el-col></el-row>
|
||||
<el-row :gutter="16"><el-col :span="12"><el-form-item label="预计开始"><TimeField boundary="start" :disabled="!!item" v-model="draft.plannedStartAt" :zone="zone" :earliest="item ? null : constraints?.earliestPlannedStartAt || parent?.plannedStartAt" @invalid="invalidStart = $event" /></el-form-item></el-col><el-col :span="12"><el-form-item label="预计结束"><TimeField boundary="end" :disabled="!!item" v-model="draft.plannedEndAt" :zone="zone" :latest="item ? null : constraints?.latestPlannedEndAt || parent?.plannedEndAt" @invalid="invalidEnd = $event" /></el-form-item></el-col></el-row>
|
||||
<p v-if="item" class="dependency-note">普通编辑保留原计划;需要改期时使用详情中的调整排期入口。</p>
|
||||
<el-alert v-if="item?.scheduleReviewRequired" type="warning" :closable="false" title="排期待复核。请从工作项详情的调整排期或批量排期确认;修改标题、描述不会恢复参考时间。" />
|
||||
<el-alert v-if="item?.scheduleConstraints.sources.length" type="info" :closable="false" :title="`排期来源:${item.scheduleConstraints.sources.map(scheduleSourceLabel).join(';')}`" />
|
||||
<el-form-item class="notification-choice"><el-checkbox v-model="draft.sendEmail" size="small" :disabled="busy">发送邮件通知</el-checkbox><span class="dependency-note">站内消息始终发送;勾选后同时邮件提醒负责人和协作人,无邮箱人员仅接收站内消息。</span></el-form-item>
|
||||
<el-alert v-if="failure" class="failure" type="error" :title="failure" :closable="false" />
|
||||
</el-form>
|
||||
<template #footer><el-button @click="emit('close')">取消</el-button><el-button type="primary" :loading="busy" :disabled="!draft.title.trim() || invalidStart || invalidEnd" @click="save">保存</el-button></template>
|
||||
<template #footer><el-button @click="emit('close')">取消</el-button><el-button type="primary" :loading="busy" :disabled="!draft.title.trim() || !draft.assigneeId || !allowed || invalidStart || invalidEnd" @click="save">保存</el-button></template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@ -31,7 +32,7 @@ import type { WorkItem, Member, ItemInput, Stage, Schedule } from '../../../type
|
||||
import { typeNames, priorityNames } from '../../../shared/constants/labels'
|
||||
import { scheduleSourceLabel } from '../../../shared/constants/schedules'
|
||||
import TimeField from '../../../shared/components/TimeField.vue'
|
||||
import { planningLimitDate, editedPlannedRange, plannedRange } from '../../../shared/utils/time'
|
||||
import { planningLimitDate, plannedRange } from '../../../shared/utils/time'
|
||||
import PredecessorPicker from './PredecessorPicker.vue'
|
||||
const props = withDefaults(defineProps<{ visible: boolean; projectId: number; iterationId?: number; zone: string; item: WorkItem | null; members: Member[]; stages?: Stage[]; defaultStageId?: number | null; parent?: WorkItem | null }>(), { stages: () => [], defaultStageId: null, parent: null })
|
||||
const emit = defineEmits<{ close: []; saved: [id: number] }>()
|
||||
@ -39,12 +40,16 @@ const draft = reactive<ItemInput & { collaboratorIds: number[]; predecessorWorkI
|
||||
const busy = ref(false), failure = ref(''), invalidStart = ref(false), invalidEnd = ref(false)
|
||||
const initialConstraints = ref<Schedule | null>(null), constraintFailure = ref('')
|
||||
const constraints = computed(() => props.item?.scheduleConstraints || initialConstraints.value)
|
||||
/** 阶段组只能容纳子阶段,工作项创建不得将其作为可选归属。 */
|
||||
const workStages = computed(() => props.stages.filter(stage => stage.stageKind !== 'GROUP' && stage.nodeType !== 'PURCHASE'))
|
||||
/** 新建仅选择服务端明确授权的本人阶段;编辑展示已有归属,不能因此取得新建资格。 */
|
||||
const workStages = computed(() => props.stages.filter(stage => stage.stageKind !== 'GROUP' && stage.nodeType !== 'PURCHASE' && (props.item ? stage.id === props.item.stageId : stage.canCreateWorkItem === true)))
|
||||
/** 已打开草稿也复验目标阶段;子任务同时需要父对象能力,空归属及合成的他人阶段均拒绝。 */
|
||||
const allowed = computed(() => props.item ? props.item.canEditWorkItem === true : workStages.value.some(stage => stage.id === draft.stageId) && (!props.parent || props.parent.canCreateChild === true && draft.stageId === props.parent.stageId))
|
||||
let constraintSequence = 0, constraintTimer: ReturnType<typeof setTimeout> | undefined
|
||||
let generation = 0, mounted = true
|
||||
/** 子任务继承父阶段,编辑保留原归属;每次打开清空旧草稿,并要求重新明确选择邮件通知。 */
|
||||
watch(() => props.visible, visible => { generation++; if (!visible) return; const item = props.item; Object.assign(draft, { type: item?.type || 'TASK', title: item?.title || '', description: item?.description || '', assigneeId: item?.assigneeId || null, collaboratorIds: [...(item?.collaboratorIds || [])], predecessorWorkItemIds: [], priority: item?.priority || 'MEDIUM', stageId: item ? item.stageId ?? null : props.parent ? props.parent.stageId ?? null : props.defaultStageId, plannedStartAt: item?.plannedStartAt || null, plannedEndAt: item?.plannedEndAt || null, version: item?.version, sendEmail: false }); failure.value = ''; invalidStart.value = false; invalidEnd.value = false }, { immediate: true })
|
||||
watch(() => props.visible, visible => { generation++; if (!visible) return; const item = props.item; const proposedStage = props.parent ? props.parent.stageId ?? null : props.defaultStageId; Object.assign(draft, { type: item?.type || 'TASK', title: item?.title || '', description: item?.description || '', assigneeId: item?.assigneeId || null, collaboratorIds: [...(item?.collaboratorIds || [])], predecessorWorkItemIds: [], priority: item?.priority || 'MEDIUM', stageId: item ? item.stageId ?? null : workStages.value.some(stage => stage.id === proposedStage) ? proposedStage : null, plannedStartAt: item?.plannedStartAt || null, plannedEndAt: item?.plannedEndAt || null, version: item?.version, sendEmail: false }); failure.value = ''; invalidStart.value = false; invalidEnd.value = false }, { immediate: true })
|
||||
/** 阶段失权时清除新建草稿归属,避免旧选择继续参与约束查询或保存。 */
|
||||
watch(workStages, stages => { if (!props.item && !stages.some(stage => stage.id === draft.stageId)) draft.stageId = null })
|
||||
/** 草稿改变后只接收最新服务端约束,关闭和范围切换立即废弃旧响应。 */
|
||||
watch(() => [props.visible, props.projectId, props.iterationId, props.item?.id, props.parent?.id, draft.stageId, draft.predecessorWorkItemIds?.join(',')], () => {
|
||||
const sequence = ++constraintSequence
|
||||
@ -56,12 +61,12 @@ watch(() => [props.visible, props.projectId, props.iterationId, props.item?.id,
|
||||
}, { immediate: true })
|
||||
/** 范围切换会卸载编辑器,旧保存结果不得打开新迭代中的详情。 */
|
||||
onBeforeUnmount(() => { mounted = false; generation++; constraintSequence++; if (constraintTimer) clearTimeout(constraintTimer) })
|
||||
/** 新建和改期提交整日边界,普通编辑保留旧时间;本次邮件选择随请求提交,冲突时保留草稿。 */
|
||||
/** 提交前重验负责人和阶段能力;元数据编辑总是保留原时间精度,改期只走专用接口。 */
|
||||
async function save() {
|
||||
if (!props.visible || busy.value) return
|
||||
if (!props.visible || busy.value || !allowed.value || !draft.assigneeId || !draft.title.trim() || invalidStart.value || invalidEnd.value) return
|
||||
const sequence = generation
|
||||
busy.value = true; failure.value = ''
|
||||
try { const { predecessorWorkItemIds, ...fields } = draft; const input = { ...fields, ...(props.item ? editedPlannedRange(draft.plannedStartAt, draft.plannedEndAt, props.item.plannedStartAt, props.item.plannedEndAt) : { ...plannedRange(draft.plannedStartAt, draft.plannedEndAt), predecessorWorkItemIds }) }; let id: number; if (props.item) { await api.edit(props.item.id, input); id = props.item.id } else if (props.parent) id = await api.createChild(props.parent, input); else id = await api.create(props.projectId, input, props.iterationId); if (mounted && sequence === generation) emit('saved', id) }
|
||||
try { const { predecessorWorkItemIds, ...fields } = draft; const input = { ...fields, ...(props.item ? { stageId: props.item.stageId ?? null, plannedStartAt: props.item.plannedStartAt, plannedEndAt: props.item.plannedEndAt } : { ...plannedRange(draft.plannedStartAt, draft.plannedEndAt), predecessorWorkItemIds }) }; let id: number; if (props.item) { await api.edit(props.item.id, input); id = props.item.id } else if (props.parent) id = await api.createChild(props.parent, input); else id = await api.create(props.projectId, input, props.iterationId); if (mounted && sequence === generation) emit('saved', id) }
|
||||
catch (error) { if (mounted && sequence === generation) failure.value = errorText(error) }
|
||||
finally { busy.value = false }
|
||||
}
|
||||
|
||||
@ -32,6 +32,8 @@ export interface StageEdge {
|
||||
}
|
||||
|
||||
export interface FlowView {
|
||||
/** 新增、删除和结构配置仅允许迭代创建者;不替代行级编辑、排期及回退资格。 */
|
||||
canConfigureStages?: boolean
|
||||
layout?: FlowLayout
|
||||
graphVersion?: number
|
||||
stages: Stage[]
|
||||
|
||||
@ -56,7 +56,13 @@ export interface Stage extends StageSummary, Omit<StageSchedule, 'plannedStartAt
|
||||
stagePath?: string
|
||||
childStageCount?: number
|
||||
completedChildStageCount?: number
|
||||
/** 阶段元数据编辑资格,仅迭代创建者或当前阶段负责人具备;缺失时拒绝。 */
|
||||
canEditStage?: boolean
|
||||
/** 阶段计划编辑资格,与新增、删除及结构配置能力分别校验。 */
|
||||
canScheduleStage?: boolean
|
||||
canCreateWorkItem?: boolean
|
||||
/** 回退新版本的人工补录身份资格;独立于旧轮次冻结后的普通新建能力。 */
|
||||
canAddReworkItems?: boolean
|
||||
canCreateChildStage?: boolean
|
||||
canEditStructure?: boolean
|
||||
/** 全版本执行历史;旧接口的 MySQL EXISTS 可能返回 0/1,不能用当前工作项数量推断。 */
|
||||
|
||||
@ -61,6 +61,8 @@ export interface WorkItem {
|
||||
title: string
|
||||
description: string | null
|
||||
assigneeId: number | null
|
||||
/** 本工作项不可变创建者;新轮次复制项保留自身真实创建人,不回溯原项。 */
|
||||
createdBy?: number
|
||||
collaboratorIds?: number[]
|
||||
collaborators?: { userId: number; name: string }[]
|
||||
priority: string
|
||||
@ -74,6 +76,24 @@ export interface WorkItem {
|
||||
canStart: boolean
|
||||
/** 服务端综合项目、迭代、阶段可写性及当前负责人身份计算;缺失时不能推断执行授权。 */
|
||||
canExecuteWorkItem?: boolean
|
||||
/** 所属阶段当前负责人且对象可写时才允许维护元数据;能力缺失必须拒绝。 */
|
||||
canEditWorkItem?: boolean
|
||||
/** 服务端综合所属阶段负责人身份、版本和生命周期计算的软删除资格。 */
|
||||
canDeleteWorkItem?: boolean
|
||||
/** 工作项当前负责人或真实创建者的排期/复核资格,与元数据维护分别授权。 */
|
||||
canScheduleWorkItem?: boolean
|
||||
/** 所属阶段当前负责人调整根工作项归属的资格,目标阶段仍须单独复验。 */
|
||||
canAssignStage?: boolean
|
||||
/** 所属阶段负责人通过独立入口补分配已有未分配工作项,仍需具备正常维护能力。 */
|
||||
canAssignAssignee?: boolean
|
||||
/** 仅迭代创建者补齐待开始根项缺失归属;不开放普通编辑,子任务随父项继承。 */
|
||||
canRepairStage?: boolean
|
||||
/** 仅迭代创建者通过负责人专用入口补齐未分配项;已有负责人不能覆盖。 */
|
||||
canRepairAssignee?: boolean
|
||||
/** 工作项负责人或协作人讨论资格,审批中仍可讨论,不依赖项目写权限。 */
|
||||
canDiscuss?: boolean
|
||||
/** 工作项负责人或协作人附件上传资格,继续受原冻结和历史保护限制。 */
|
||||
canUploadAttachments?: boolean
|
||||
blockedReasons: Reason[]
|
||||
stageBlockedReasons?: Reason[]
|
||||
stageAdmissionConditions?: StageAdmissionCondition[]
|
||||
@ -91,7 +111,7 @@ export interface WorkItem {
|
||||
name: string
|
||||
size: number
|
||||
}[]
|
||||
/** 服务端实时判断工作项负责人或创建者资格,并综合历史版本和只读限制。 */
|
||||
/** 仅当前负责人具备附件软删除资格,继续受历史版本和只读限制。 */
|
||||
canDeleteAttachments?: boolean
|
||||
history?: {
|
||||
id: number
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<section v-for="(label, state) in statusNames" :key="state" class="lane" @dragover.prevent @drop.prevent="drop(state)">
|
||||
<header>{{ label }} <span>{{ counts?.[state] ?? itemsByStatus[state].length }}</span></header>
|
||||
<div class="lane-content" role="region" :aria-label="label + '工作项'" tabindex="0">
|
||||
<article v-for="item in itemsByStatus[state]" :key="item.id" class="work-card" :class="{ 'work-card--focused': item.id === focusedItem?.id }" :data-work-item-id="item.id" :draggable="canWrite && !item.stageReadOnly && !busy.has(item.id)" tabindex="0" @keydown.enter="emit('open', item.id)" @dragstart="dragged = item.id" @dragend="dragged = null" @click="emit('open', item.id)">
|
||||
<article v-for="item in itemsByStatus[state]" :key="item.id" class="work-card" :class="{ 'work-card--focused': item.id === focusedItem?.id }" :data-work-item-id="item.id" :draggable="canWrite && item.canExecuteWorkItem === true && !item.stageReadOnly && !busy.has(item.id)" tabindex="0" @keydown.enter="emit('open', item.id)" @dragstart="dragged = item.canExecuteWorkItem === true ? item.id : null" @dragend="dragged = null" @click="emit('open', item.id)">
|
||||
<span v-if="item.id === focusedItem?.id" class="focus-label">定位工作项</span>
|
||||
<div class="card-meta"><span class="card-id">{{ typeNames[item.type] }} #{{ item.id }}</span><small v-if="item.stageId" class="stage-version" :title="item.stagePath || stagesById.get(item.stageId)?.name">{{ item.stagePath || stagesById.get(item.stageId)?.name || '阶段' }} · v{{ stagesById.get(item.stageId)?.revisionNo || 1 }}</small><el-tag size="small" :type="item.priority === 'URGENT' ? 'danger' : 'info'">{{ priorityNames[item.priority] }}</el-tag></div>
|
||||
<strong class="card-title" :title="item.title">{{ item.title }}</strong>
|
||||
@ -71,12 +71,12 @@ onBeforeUnmount(() => { sizeObserver?.disconnect(); window.removeEventListener('
|
||||
* 拖动开始或完成先检查服务端能力,再进行乐观移动;避免非负责人短暂看到执行成功的状态。
|
||||
* @param state 目标状态;进行中调用统一开始接口,关闭后重开完成也须满足当前负责人身份。
|
||||
* 定位项虽可能尚未出现在分页内,仍使用相同的服务端执行能力及提交入口。
|
||||
* 其它状态继续由原状态机验证,不能因为缺少执行身份就禁用整张卡片拖动。
|
||||
* 所有状态变更均要求当前负责人对象能力,拖入取消或关闭也不能绕过。
|
||||
*/
|
||||
async function drop(state: Lifecycle) {
|
||||
const item = dragged.value === props.focusedItem?.id ? props.focusedItem : props.items.find(i => i.id === dragged.value)
|
||||
dragged.value = null
|
||||
if (!props.canWrite || state === 'IN_PROGRESS' && !props.canExecute || !item || item.status === state || busy.has(item.id)) return
|
||||
if (!props.canWrite || state === 'IN_PROGRESS' && !props.canExecute || !item || item.canExecuteWorkItem !== true || item.stageReadOnly || item.historical || item.iterationReadOnly || item.status === state || busy.has(item.id)) return
|
||||
if (state === 'IN_PROGRESS' && !item.canStart) {
|
||||
ElMessage({ type: 'error', message: item.blockedReasons.map(reason => reason.message || reason.sourceName).filter(Boolean).join(';') || '当前无法开始,请确认负责人及执行条件', duration: 8000 })
|
||||
return
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
<div class="flow-toolbar">
|
||||
<div class="flow-tools">
|
||||
<el-button size="small" @click="autoLayout" :disabled="!canEditLayout || busy || canvasInteracting">自动布局</el-button><el-button size="small" @click="fitAll">适应画布</el-button>
|
||||
<el-button size="small" :type="canvasMode === 'select' ? 'primary' : 'default'" :disabled="busy" @click="canvasMode = canvasMode === 'select' ? 'pan' : 'select'">框选</el-button>
|
||||
<el-button size="small" :type="canvasMode === 'section' ? 'primary' : 'default'" :disabled="!canEditLayout || busy || sections.length >= 200" @click="canvasMode = canvasMode === 'section' ? 'pan' : 'section'">分区</el-button>
|
||||
<el-button size="small" :type="canvasMode === 'select' ? 'primary' : 'default'" :disabled="!canEditLayout || busy" @click="changeCanvasMode('select')">框选</el-button>
|
||||
<el-button size="small" :type="canvasMode === 'section' ? 'primary' : 'default'" :disabled="!canEditLayout || busy || sections.length >= 200" @click="changeCanvasMode('section')">分区</el-button>
|
||||
<el-checkbox v-model="guidesEnabled" size="small" :disabled="busy">对齐与间距辅助</el-checkbox>
|
||||
<el-dropdown size="small" trigger="click" :disabled="!canEditLayout || busy || selectedNodes.length < 2 || !sameScope" @command="applyArrangement">
|
||||
<el-button size="small" :disabled="!canEditLayout || busy || selectedNodes.length < 2 || !sameScope" :title="sameScope ? '以选区边界对齐' : '请选择同一画布层级的节点'">对齐 / 等距 ▾</el-button>
|
||||
@ -17,7 +17,7 @@
|
||||
<el-button v-if="selectedNodes.length" size="small" :disabled="!canEditLayout || busy || selectedNodes.some(node => !!node.parentNode) || sections.length >= 200" @click="createSelectionSection">选区设为分区</el-button>
|
||||
<span v-if="selectedNodes.length" class="flow-help">已选 {{ selectedNodes.length }} 个节点{{ sameScope ? '' : '(不同层级)' }}</span>
|
||||
</div>
|
||||
<div class="flow-tools"><span class="flow-help">{{ canvasMode === 'section' ? '在空白处拖框创建分区;拖动分区标题栏可整体移动' : canvasMode === 'select' ? '拖框或点击选择节点;Ctrl / ⌘ 可加选;空格可平移' : '拖动平移;Shift 拖框 / Ctrl 或 ⌘ 点击多选;成员共享节点位置与分区' }}</span><el-button v-if="canManage" size="small" @click="stageOpen = true">管理阶段</el-button></div>
|
||||
<div class="flow-tools"><span class="flow-help">{{ !canEditLayout ? '可平移、缩放及展开折叠;仅迭代创建者可编辑画布,刷新后统一展开' : canvasMode === 'section' ? '在空白处拖框创建分区;拖动分区标题栏可整体移动' : canvasMode === 'select' ? '拖框或点击选择节点;Ctrl / ⌘ 可加选;空格可平移' : '拖动平移;Shift 拖框 / Ctrl 或 ⌘ 点击多选;成员共享节点位置与分区' }}</span><el-button v-if="canManageStages" size="small" @click="stageOpen = true">管理阶段</el-button></div>
|
||||
</div>
|
||||
<div class="flow-layout-status" role="status" aria-live="polite">
|
||||
<span :class="{ 'layout-error': layoutFailure }">{{ layoutStatus }}</span>
|
||||
@ -26,10 +26,14 @@
|
||||
</div>
|
||||
<el-alert v-if="failure" type="error" :title="failure" :closable="false" class="flow-failure" />
|
||||
<div class="flow-editor" :class="{ inactive: !active }">
|
||||
<FlowNodePalette :enabled="canManage && !busy && !stageNameOpen" @pointerdown.capture="finishCanvasGesture" />
|
||||
<FlowNodePalette :enabled="canConfigureStages && !busy && !stageNameOpen" @pointerdown.capture="finishCanvasGesture" />
|
||||
<div ref="canvas" class="flow-canvas" :class="{ 'drawing-section': canvasMode === 'section' }" @pointerdown.capture="canvasTools.drawSection" @keydown.capture="canvasTools.moveWithKeyboard" @dragover.prevent @drop.prevent="dropStage">
|
||||
<!-- 保持阶段组、子阶段和连线的固定层级;选中时自动提升父组会使其背景遮住内部连线。 -->
|
||||
<VueFlow v-if="active" :id="flowId" v-model:nodes="nodes" :edges="edges" :connection-line-type="ConnectionLineType.Bezier" :delete-key-code="null" :min-zoom="0.1" :max-zoom="4" :nodes-connectable="canManage && !busy && canvasMode !== 'section'" :edges-updatable="false" :nodes-draggable="canEditLayout && !busy && canvasMode !== 'section'" :selection-key-code="canvasMode === 'select' ? true : 'Shift'" :multi-selection-key-code="['Control', 'Meta']" :selection-mode="SelectionMode.Full" :pan-on-drag="canvasMode === 'pan' ? true : [1, 2]" :node-drag-threshold="3" :elevate-nodes-on-select="false" @connect="connectStages" @edge-click="edgeClicked" @node-click="selectNode" @node-drag-start="dragStarted" @node-drag="nodeDragged" @node-drag-stop="dragStopped" @move-end="viewportMoved" @nodes-initialized="restoreViewport" @selection-start="selecting = true" @selection-end="selecting = false">
|
||||
<VueFlow v-if="active" :id="flowId" v-model:nodes="nodes" :edges="edges" :connection-line-type="ConnectionLineType.Bezier" :delete-key-code="null" :min-zoom="0.1" :max-zoom="4"
|
||||
:nodes-connectable="canConfigureStages && !busy && canvasMode !== 'section'" :edges-updatable="false" :nodes-draggable="canEditLayout && !busy && canvasMode !== 'section'"
|
||||
:elements-selectable="canEditLayout" :select-nodes-on-drag="canEditLayout" :selection-key-code="canEditLayout ? canvasMode === 'select' ? true : 'Shift' : null" :multi-selection-key-code="canEditLayout ? ['Control', 'Meta'] : null"
|
||||
:selection-mode="SelectionMode.Full" :pan-on-drag="canvasMode === 'pan' ? true : [1, 2]" :node-drag-threshold="3" :elevate-nodes-on-select="false"
|
||||
@connect="connectStages" @edge-click="edgeClicked" @node-click="selectNode" @node-drag-start="dragStarted" @node-drag="nodeDragged" @node-drag-stop="dragStopped" @move-end="viewportMoved" @nodes-initialized="restoreViewport" @selection-start="selectionStarted" @selection-end="selecting = false">
|
||||
<Background :gap="22" :size="1" pattern-color="var(--el-border-color)" />
|
||||
<MiniMap pannable zoomable :node-color="minimapColor" node-stroke-color="var(--el-color-primary-light-3)" mask-color="var(--el-mask-color-extra-light)" />
|
||||
<Controls :show-interactive="false" />
|
||||
@ -39,15 +43,15 @@
|
||||
<template #node-group="{ data }"><FlowStageNode :data="{ ...data, busy }" @view="openDrawer($event, 'current')" @create-child="createChildStage" @toggle="toggleGroup" @rework="openRework" @history="openDrawer($event, 'history')" @rename="renameStage" @remove="removeStage" /></template>
|
||||
</VueFlow>
|
||||
<FlowCanvasGuides :guides="guides" :draft="sectionDraft" :viewport="viewport" />
|
||||
<div v-if="!view.unassigned?.counts?.total && !view.stages.length" class="canvas-empty">{{ canManage ? '从左侧拖入节点,然后连接阶段执行顺序。' : '暂无阶段和工作项。' }}</div>
|
||||
<div v-if="!view.unassigned?.counts?.total && !view.stages.length" class="canvas-empty">{{ canConfigureStages ? '从左侧拖入节点,然后连接阶段执行顺序。' : '暂无阶段和工作项。' }}</div>
|
||||
<div class="canvas-legend"><span class="legend-line"></span>未放行 <span class="legend-line started"></span><span title="采购当前版本实际开始后即放行直接下游;蓝线不代表采购完成,阶段组仍须全部子阶段完成。">采购已开始,已放行(未完成)</span> <span class="legend-line green"></span>已完成 <span class="legend-line legacy"></span>历史沿用 <span class="legend-line rework" :style="{ borderColor: FLOW_REWORK_COLOR }"></span>回退记录 · 多条入边须全部满足</div>
|
||||
</div>
|
||||
</div>
|
||||
<StageCreateDialog :visible="stageNameOpen" :project-id="projectId" :iteration-id="iterationId" :parent="createParent" :node-type="createNodeType" :members="members" @close="stageNameOpen = false" @created="stageCreated" />
|
||||
<StageCreateDialog :can-configure-stages="canConfigureStages" :visible="stageNameOpen" :project-id="projectId" :iteration-id="iterationId" :parent="createParent" :node-type="createNodeType" :members="members" @close="stageNameOpen = false" @created="stageCreated" />
|
||||
<StageManager :visible="stageOpen" :project-id="projectId" :iteration-id="iterationId" :stages="view.stages" :members="members" :view="view" @close="stageOpen = false" @changed="emit('changed')" />
|
||||
<StageRenameDialog :stage="renamingStage" :project-id="projectId" :iteration-id="iterationId" @close="renamingStage = null" @changed="emit('changed')" />
|
||||
<StageReworkDialog :visible="reworkSourceId !== null" :source-id="reworkSourceId" :project-id="projectId" :iteration-id="iterationId" :view="view" @close="reworkSourceId = null" @changed="emit('changed')" />
|
||||
<StageWorkItemsDrawer :stage-id="drawerStageId" :initial-tab="drawerTab" :project-id="projectId" :iteration-id="iterationId" :view="view" :members="members" :can-create="canCreate" :can-manage="canManage" @changed="emit('changed')" @close="drawerStageId = null; drawerEditing = false" @open="openItem" @create="createFromDrawer" @navigate="drawerStageId = $event" @create-child="createChildFromDrawer" @editing="drawerEditing = $event" />
|
||||
<StageReworkDialog :visible="reworkSourceId !== null" :source-id="reworkSourceId" :project-id="projectId" :iteration-id="iterationId" :view="view" :members="members" @close="reworkSourceId = null" @changed="emit('changed')" />
|
||||
<StageWorkItemsDrawer :stage-id="drawerStageId" :initial-tab="drawerTab" :project-id="projectId" :iteration-id="iterationId" :view="view" :members="members" :can-create="canCreate" :can-configure-stages="canConfigureStages" @changed="emit('changed')" @close="drawerStageId = null; drawerEditing = false" @open="openItem" @create="createFromDrawer" @navigate="drawerStageId = $event" @create-child="createChildFromDrawer" @editing="drawerEditing = $event" />
|
||||
</section>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@ -89,12 +93,16 @@ import StageReworkDialog from '../../features/stages/components/StageReworkDialo
|
||||
import StageWorkItemsDrawer from '../../features/stages/components/StageWorkItemsDrawer.vue'
|
||||
|
||||
const props = defineProps<{ view: FlowView; projectId: number; iterationId?: number; iterationCreatorId?: number; userId: number | string; members: Member[]; canCreate: boolean; canManage: boolean; active: boolean; focusStageId?: number | null }>()
|
||||
/** 阶段生成和连线同时核对服务端能力与当前迭代创建者,避免切换账号后沿用旧摘要开放入口。 */
|
||||
const canConfigureStages = computed(() => props.view.canConfigureStages === true && props.iterationCreatorId != null && String(props.iterationCreatorId) === String(props.userId))
|
||||
/** 管理面板允许行级阶段编辑者进入;全局结构操作仍使用创建者资格。 */
|
||||
const canManageStages = computed(() => canConfigureStages.value || props.view.stages.some(stage => stage.canEditStage === true))
|
||||
const emit = defineEmits<{ open: [id: number]; changed: []; create: [stageId: number | null] }>()
|
||||
// 数据库是布局唯一来源;清理旧流程缓存但从不读取其中的坐标、分区或个人视口。
|
||||
discardFlowPreferences()
|
||||
const canvas = ref<HTMLElement | null>(null)
|
||||
const flowId = 'project-flow-' + props.projectId + '-' + props.iterationId
|
||||
const { fitView, setViewport, viewport, screenToFlowCoordinate, getNodes, updateNodeInternals, paneDragging, userSelectionActive, userSelectionRect, nodesSelectionActive } = useVueFlow(flowId)
|
||||
const { fitView, setViewport, viewport, screenToFlowCoordinate, getNodes, removeSelectedElements, updateNodeInternals, paneDragging, userSelectionActive, userSelectionRect, nodesSelectionActive } = useVueFlow(flowId)
|
||||
const nodes = ref<Node<FlowNodeData>[]>([]), edges = ref<Edge<FlowEdgeData>[]>([])
|
||||
const busy = ref(false), dragging = ref(false), failure = ref(''), stageOpen = ref(false), stageNameOpen = ref(false), pendingStagePoint = ref<Point | null>(null)
|
||||
const draftViewport = ref<(Point & { zoom: number }) | null>(null)
|
||||
@ -133,9 +141,9 @@ watch(() => props.view, () => {
|
||||
}
|
||||
rebuild()
|
||||
}, { immediate: true })
|
||||
watch([positions, sections, canEditLayout, () => props.canCreate, () => props.canManage], rebuild)
|
||||
/** 拖动途中变为只读时立即结束旧手势并还原数据库坐标,不能等待可能不再到达的 mouseup。 */
|
||||
watch(canEditLayout, allowed => { if (!allowed && dragging.value) resetReadonlyDrag() })
|
||||
watch([positions, sections, canEditLayout, () => props.canCreate, () => props.canManage, canConfigureStages], rebuild)
|
||||
/** 失权立即结束拖动及框选并清空高亮,不能让旧选区阻塞成员继续平移或接收数据库更新。 */
|
||||
watch(canEditLayout, allowed => { if (!allowed) resetReadonlyInteraction() }, { flush: 'sync' })
|
||||
/**
|
||||
* 待办已在工作区复核审批身份;这里只展开目标父组、定位节点并打开当前版本交付及审批面板。
|
||||
* 原定位清空或换目标时先关闭旧抽屉,避免新申请失效后仍显示另一阶段;普通快照不会重开抽屉。
|
||||
@ -153,23 +161,38 @@ watch(() => props.focusStageId, async (id, previousId) => {
|
||||
openDrawer(stage.id, 'current')
|
||||
await fitView({ nodes: ['s:' + stage.id], padding: 0.4, maxZoom: 1, duration: 200 })
|
||||
}, { immediate: true, flush: 'post' })
|
||||
/** 生命周期或权限变成只读时关闭写对话框,避免已打开的入口继续提交。 */
|
||||
watch(() => props.canManage, allowed => { if (!allowed) { stageOpen.value = false; stageNameOpen.value = false; renamingStage.value = null; reworkSourceId.value = null } })
|
||||
/** 全局配置失权仅关闭新建,阶段元数据草稿按其行能力分别撤销。 */
|
||||
watch(canConfigureStages, allowed => { if (!allowed) stageNameOpen.value = false })
|
||||
/** 无可配置或可编辑阶段时关闭管理面板,避免已撤销身份继续保留旧入口。 */
|
||||
watch(canManageStages, allowed => { if (!allowed) stageOpen.value = false })
|
||||
/** 阶段转交、冻结或删除后撤销快捷名称草稿,不沿用复制快照中的旧能力。 */
|
||||
watch(() => props.view.stages, stages => { if (renamingStage.value && !stages.some(stage => stage.id === renamingStage.value?.id && stage.canEditStage === true)) renamingStage.value = null }, { flush: 'sync' })
|
||||
/** 回退保持原项目管理资格,配置资格变化不剥夺阶段回退能力。 */
|
||||
watch(() => props.canManage, allowed => { if (!allowed) reworkSourceId.value = null })
|
||||
/** 离开页签关闭抽屉并暂存当前组件视口;不读写浏览器缓存,也不凭旧定位重开审批。 */
|
||||
watch(() => props.active, async active => { if (active) { await nextTick(); await restoreViewport() } else { drawerStageId.value = null; drawerEditing.value = false; draftViewport.value = { ...viewport.value } } })
|
||||
|
||||
/** 按子画布和外框实际尺寸重建阶段摘要,折叠只隐藏内部节点,不改变共享业务图。 */
|
||||
/** 按数据库坐标重建子画布;只为有布局资格者保留选区,配置与原有业务权限分别传给节点。 */
|
||||
function rebuild() {
|
||||
if (dragging.value) return
|
||||
const { layout: _layout, ...businessView } = props.view
|
||||
const signature = JSON.stringify([businessView, positions.value, sections.value, collapsedStages.value, props.canCreate, props.canManage, canEditLayout.value])
|
||||
const signature = JSON.stringify([businessView, positions.value, sections.value, collapsedStages.value, props.canCreate, props.canManage, canConfigureStages.value, canEditLayout.value])
|
||||
if (signature === lastGraphSignature) return
|
||||
lastGraphSignature = signature
|
||||
const selected = new Set(getNodes.value.filter(node => node.selected).map(node => node.id))
|
||||
const selected = new Set(canEditLayout.value ? getNodes.value.filter(node => node.selected).map(node => node.id) : [])
|
||||
const graph = buildFlowGraph(props.view, positions.value, collapsedStages.value)
|
||||
for (const node of graph.nodes) if (node.data) { node.data.canWrite = props.canCreate; node.data.canManage = props.canManage; node.data.deleteBlockedReason = node.data.stage ? stageDeleteBlockedReason(node.data.stage, props.view.stages) : ''; node.connectable = !!node.data.stage && props.canManage }
|
||||
for (const edge of graph.edges) edge.selectable = props.canManage && edge.data?.kind !== 'rework'
|
||||
nodes.value = [...canvasTools.sectionNodes(), ...graph.nodes].map(node => ({ ...node, selected: selected.has(node.id) })); edges.value = graph.edges
|
||||
for (const node of graph.nodes) if (node.data) { node.data.canWrite = props.canCreate; node.data.canManage = props.canManage; node.data.canConfigureStages = canConfigureStages.value; node.data.deleteBlockedReason = node.data.stage ? stageDeleteBlockedReason(node.data.stage, props.view.stages) : ''; node.connectable = !!node.data.stage && canConfigureStages.value }
|
||||
for (const edge of graph.edges) edge.selectable = canEditLayout.value && canConfigureStages.value && edge.data?.kind !== 'rework'
|
||||
nodes.value = [...canvasTools.sectionNodes(), ...graph.nodes].map(node => ({ ...node, selectable: canEditLayout.value, selected: selected.has(node.id) })); edges.value = graph.edges
|
||||
}
|
||||
/**
|
||||
* 工具按钮与合成点击共用创建者门禁;切换前结束旧框选,成员始终保留平移模式。
|
||||
* @param mode select 为节点框选,section 为展示分区绘制;再次选择当前模式则恢复平移
|
||||
*/
|
||||
function changeCanvasMode(mode: 'select' | 'section') {
|
||||
if (!canEditLayout.value || busy.value || mode === 'section' && sections.value.length >= 200) return
|
||||
finishCanvasGesture()
|
||||
canvasMode.value = canvasMode.value === mode ? 'pan' : mode
|
||||
}
|
||||
/** 批量排版后先调整组边界及连线,再一次保存补偿后的相对坐标,避免刷新后子节点漂移。 */
|
||||
function persistCanvasLayout() {
|
||||
@ -188,6 +211,8 @@ function applyArrangement(action: ArrangeAction) { failure.value = canvasTools.a
|
||||
function createSelectionSection() { failure.value = canvasTools.sectionFromSelection() }
|
||||
/** 拖动起点记录分区包含的根节点,避免拖动途中将路过的节点吸入分区。 */
|
||||
function dragStarted(event: NodeDragEvent) { if (!canEditLayout.value) return; dragging.value = true; canvasTools.startDrag(event) }
|
||||
/** 原生框选只允许创建者,迟到或合成的只读事件不得把整个工作区永久标记为交互中。 */
|
||||
function selectionStarted() { if (canEditLayout.value && !busy.value) selecting.value = true; else resetReadonlyInteraction() }
|
||||
/** 框选使用原生指针捕获;失焦、隐藏或弹窗接管时解除展示状态,避免静默同步一直被暂停。 */
|
||||
function cancelCanvasSelection() {
|
||||
if (!selecting.value) return
|
||||
@ -211,17 +236,28 @@ function nodeDragged(event: NodeDragEvent) {
|
||||
* 松开时仅由仍有编辑资格的创建者保存坐标;只读的迟到事件必须还原数据库布局。
|
||||
* @param event 拖动最终节点集合,用于保存前完成最后一次边界计算
|
||||
*/
|
||||
function dragStopped(event: NodeDragEvent) { if (!canEditLayout.value) { resetReadonlyDrag(); return }; nodeDragged(event); canvasTools.finishDrag(); dragging.value = false; persistCanvasLayout() }
|
||||
/** 释放 Vue Flow 的旧拖动监听并强制重建;草稿未提交时节点对象的位置可能已偏离共享坐标。 */
|
||||
function resetReadonlyDrag() { finishCanvasGesture(); canvasTools.finishDrag(); dragging.value = false; lastGraphSignature = ''; rebuild() }
|
||||
function dragStopped(event: NodeDragEvent) { if (!canEditLayout.value) { resetReadonlyInteraction(); return }; nodeDragged(event); canvasTools.finishDrag(); dragging.value = false; persistCanvasLayout() }
|
||||
/**
|
||||
* 释放失权会话的拖动及选区,清除 Vue Flow 内部高亮后按数据库草稿重建,绝不提交旧坐标。
|
||||
* 全局 selectable 不会自动清除已选节点,框选中断也可能没有 selectionEnd,因此必须同步复位两层状态。
|
||||
*/
|
||||
function resetReadonlyInteraction() {
|
||||
finishCanvasGesture(); canvasTools.finishDrag(); dragging.value = false; selecting.value = false
|
||||
userSelectionActive.value = false; userSelectionRect.value = null; nodesSelectionActive.value = false
|
||||
// 使用公开选择API同时清除节点和执行边,否则同ID边在重建时仍会合并旧 selected 状态。
|
||||
removeSelectedElements()
|
||||
canvasMode.value = 'pan'; lastGraphSignature = ''; rebuild()
|
||||
}
|
||||
/** 自动排版始终按完整展开图计算,再恢复个人折叠并保存共享位置。 */
|
||||
async function autoLayout() { if (!canEditLayout.value || busy.value || canvasInteracting.value) return; sharedLayout.update(completeLayoutPositions(props.view, {})); rebuild(); await nextTick(); await fitAll() }
|
||||
/** 重载会放弃当前未保存草稿,先明确确认;网络失败继续保留原草稿。 */
|
||||
/** 显式重载成功后恢复数据库坐标、统一展开和默认视口;失败不丢弃当前浏览状态或草稿。 */
|
||||
async function reloadSharedLayout() {
|
||||
if (sharedLayout.dirty.value) {
|
||||
try { await ElMessageBox.confirm('重新加载会放弃当前未保存的布局修改,是否继续?', '重新加载共享布局', { type: 'warning', closeOnClickModal: false }) } catch { return }
|
||||
}
|
||||
await sharedLayout.reload()
|
||||
if (!await sharedLayout.reload()) return
|
||||
collapsedStages.value = []; draftViewport.value = null
|
||||
rebuild(); await nextTick(); await restoreViewport()
|
||||
}
|
||||
/** 缩放和平移只暂存在当前组件内,不持久化,也不提交共享坐标。 */
|
||||
function viewportMoved() { if (movingProgrammatically || !props.active) return; draftViewport.value = { ...viewport.value } }
|
||||
@ -254,17 +290,17 @@ function openDrawer(stageId: number, tab: 'current' | 'history') { if (stageId !
|
||||
/** 工作项详情沿用项目级详情抽屉;先关闭阶段列表,避免两个遮罩层争夺焦点。 */
|
||||
function openItem(id: number) { drawerStageId.value = null; emit('open', id) }
|
||||
/** 打开新建表单前关闭阶段抽屉,使表单返回后由项目快照刷新当前列表。 */
|
||||
function createFromDrawer(stageId: number | null) { drawerStageId.value = null; emit('create', stageId) }
|
||||
function createFromDrawer(stageId: number | null) { if (!props.canCreate || !props.view.stages.some(stage => stage.id === stageId && stage.canCreateWorkItem === true)) return; drawerStageId.value = null; emit('create', stageId) }
|
||||
/** 从组概览创建子阶段时先关闭抽屉,复用画布同一表单。 */
|
||||
function createChildFromDrawer(id: number) { drawerStageId.value = null; createChildStage(id) }
|
||||
/** 阶段内创建仅预选阶段,后端仍复验当前版本、成员权限和阶段冻结状态。 */
|
||||
function createInStage(stageId: number) { if (!props.canCreate || stageId !== 0 && !props.view.stages.some(stage => stage.id === stageId)) return; emit('create', stageId || null) }
|
||||
/** 阶段内创建必须具备该阶段能力;未分配虚拟节点不能成为新建入口。 */
|
||||
function createInStage(stageId: number) { if (!props.canCreate || !props.view.stages.some(stage => stage.id === stageId && stage.canCreateWorkItem === true)) return; emit('create', stageId) }
|
||||
/** 回退入口使用后端当前阶段能力,待开始阶段也可进入;提交仍须通过项目锁内复验。 */
|
||||
function openRework(stageId: number) { if (props.canManage && props.view.stages.some(stage => stage.id === stageId && stage.canRework)) reworkSourceId.value = stageId }
|
||||
/** 快捷改名先检查当前能力;以独立草稿打开,避免画布原始名称被未保存输入改写。 */
|
||||
function renameStage(stageId: number) {
|
||||
const stage = props.view.stages.find(row => row.id === stageId)
|
||||
if (!stage || !props.canManage || busy.value) return
|
||||
if (!stage || stage.canEditStage !== true || busy.value) return
|
||||
const blocked = stageRenameBlockedReason(stage)
|
||||
if (blocked) { failure.value = blocked; return }
|
||||
renamingStage.value = { ...stage }
|
||||
@ -275,13 +311,13 @@ function renameStage(stageId: number) {
|
||||
*/
|
||||
async function removeStage(stageId: number) {
|
||||
const stage = props.view.stages.find(row => row.id === stageId)
|
||||
if (!stage || !props.canManage || busy.value) return
|
||||
if (!stage || !canConfigureStages.value || busy.value) return
|
||||
const blocked = stageDeleteBlockedReason(stage, props.view.stages)
|
||||
if (blocked) { failure.value = blocked; return }
|
||||
busy.value = true; failure.value = ''
|
||||
try {
|
||||
await ElMessageBox.confirm(`删除空阶段“${stage.name}”?关联执行连线将断开,历史记录保留。`, '删除阶段', { type: 'warning', closeOnClickModal: false })
|
||||
if (!props.canManage) return
|
||||
if (!canConfigureStages.value) return
|
||||
await api.removeStage(props.projectId, stage.id, stage.version, props.iterationId)
|
||||
emit('changed')
|
||||
} catch (error) { if (error !== 'cancel' && error !== 'close') { failure.value = errorText(error); emit('changed') } }
|
||||
@ -296,7 +332,7 @@ function minimapColor(node: GraphNode<FlowNodeData>) { return node.type === 'sec
|
||||
*/
|
||||
function dropStage(event: DragEvent) {
|
||||
const type = event.dataTransfer?.getData('application/x-pm-stage') || ''
|
||||
if (!props.active || !props.canManage || busy.value || stageNameOpen.value || !isPaletteNodeType(type)) return
|
||||
if (!props.active || !canConfigureStages.value || busy.value || stageNameOpen.value || !isPaletteNodeType(type)) return
|
||||
const point = screenToFlowCoordinate({ x: event.clientX, y: event.clientY })
|
||||
const parent = stageGroupAt(point, getNodes.value, props.view.stages)
|
||||
if (parent && type === 'GROUP') { failure.value = '阶段组只能创建在根画布,请拖到阶段组外。'; return }
|
||||
@ -309,14 +345,14 @@ function dropStage(event: DragEvent) {
|
||||
pendingStagePoint.value = { x: Math.max(parent ? 24 : -Infinity, point.x - origin.x), y: Math.max(parent ? 194 : -Infinity, point.y - origin.y) }; failure.value = ''; stageNameOpen.value = true
|
||||
}
|
||||
/** 组内快捷创建允许先选择工作节点分类;只在创建前选择,不提供阶段组或后续改类型入口。 */
|
||||
function createChildStage(id: number) { if (!props.view.stages.some(stage => stage.id === id && stage.canCreateChildStage)) return; createParentId.value = id; createNodeType.value = undefined; pendingStagePoint.value = null; stageNameOpen.value = true }
|
||||
function createChildStage(id: number) { if (!canConfigureStages.value || !props.view.stages.some(stage => stage.id === id && stage.canCreateChildStage)) return; createParentId.value = id; createNodeType.value = undefined; pendingStagePoint.value = null; stageNameOpen.value = true }
|
||||
/** 创建后的落点先等待最新业务摘要确认节点和父级,避免把尚未加载的 ID 发送到严格布局接口。 */
|
||||
function stageCreated(id: number) { if (pendingStagePoint.value) createdPlacement = { id, point: { ...pendingStagePoint.value }, parentStageId: createParentId.value }; stageNameOpen.value = false; pendingStagePoint.value = null; if (createParentId.value) collapsedStages.value = collapsedStages.value.filter(value => value !== createParentId.value); emit('changed') }
|
||||
/** 折叠仅影响当前组件展示,重进页面不恢复缓存;展开仍使用数据库的子节点相对位置。 */
|
||||
function toggleGroup(id: number) { collapsedStages.value = collapsedStages.value.includes(id) ? collapsedStages.value.filter(value => value !== id) : [...collapsedStages.value, id]; rebuild() }
|
||||
/** 仅连接当前项目的两个真实阶段;后端在项目锁内复验权限、环和已执行门禁。 */
|
||||
/** 仅迭代创建者连接当前项目的两个真实阶段;后端持锁复验身份、环和执行门禁。 */
|
||||
async function connectStages(connection: Connection) {
|
||||
if (!props.canManage || busy.value || !connection.source?.startsWith('s:') || !connection.target?.startsWith('s:')) return
|
||||
if (!canConfigureStages.value || busy.value || !connection.source?.startsWith('s:') || !connection.target?.startsWith('s:')) return
|
||||
const source = Number(connection.source.slice(2)), target = Number(connection.target.slice(2))
|
||||
if (!props.view.stages.some(stage => stage.id === source) || !props.view.stages.some(stage => stage.id === target)) return
|
||||
busy.value = true; failure.value = ''
|
||||
@ -324,10 +360,11 @@ async function connectStages(connection: Connection) {
|
||||
catch (error) { failure.value = errorText(error); emit('changed') }
|
||||
finally { busy.value = false }
|
||||
}
|
||||
/** 点击连线经确认后按版本断开;失败刷新当前图而不保留伪边。 */
|
||||
/** 点击连线经确认后重验配置资格并按版本断开;失权时不发请求,失败刷新真实图。 */
|
||||
async function edgeClicked(event: { edge: Edge<FlowEdgeData> }) {
|
||||
if (!props.canManage || busy.value || !event.edge.data || event.edge.data.kind === 'rework' || event.edge.data.linkId == null || event.edge.data.version == null) return
|
||||
if (!canConfigureStages.value || busy.value || !event.edge.data || event.edge.data.kind === 'rework' || event.edge.data.linkId == null || event.edge.data.version == null) return
|
||||
try { await ElMessageBox.confirm('断开这两个阶段的执行顺序?', '断开阶段连线', { type: 'warning', closeOnClickModal: false }) } catch { return }
|
||||
if (!canConfigureStages.value || !props.active) return
|
||||
busy.value = true; failure.value = ''
|
||||
try { await api.removeStageEdge(props.projectId, event.edge.data.linkId, event.edge.data.version, props.iterationId); emit('changed') }
|
||||
catch (error) { failure.value = errorText(error); emit('changed') }
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
<template>
|
||||
<div class="phase-group" :class="{ 'is-current': data.stage?.isCurrent, 'is-container': data.stage?.stageKind === 'GROUP' && !data.collapsed }" :data-stage="data.stageId" :data-state="appearance.tone" :style="{ '--phase-background': appearance.background, '--phase-border': appearance.border, '--phase-accent': appearance.accent }">
|
||||
<Handle v-if="data.stage" id="in" type="target" :position="Position.Left" :connectable="!!data.canManage" :style="{ top: '42px' }" />
|
||||
<header class="stage-drag"><span class="phase-dot"></span><span v-if="data.stage" class="stage-type">{{ stageNodeTypeLabel(data.stage) }}</span><span class="stage-title"><strong :title="data.title">{{ data.title }}</strong><button v-if="data.stage && data.canManage" type="button" class="nodrag nopan node-action" aria-label="修改阶段名称" :title="renameBlockedReason || '修改阶段名称'" :disabled="!!renameBlockedReason || !!data.busy" @pointerdown.stop @mousedown.stop @click.stop="emit('rename', data.stageId!)"><EditPen /></button></span><span v-if="data.stage?.isCurrent" class="stage-current">当前</span><button v-if="data.stage?.stageKind === 'GROUP'" class="nodrag stage-toggle" @click.stop="emit('toggle', data.stageId!)">{{ data.collapsed ? '展开' : '折叠' }}</button><span v-if="data.stage" class="stage-version">v{{ data.stage.revisionNo || 1 }}</span><button v-if="data.stage && data.canManage" type="button" class="nodrag nopan node-action node-delete" aria-label="删除阶段" :title="String(data.deleteBlockedReason || '删除空阶段')" :disabled="!!data.deleteBlockedReason || !!data.busy" @pointerdown.stop @mousedown.stop @click.stop="emit('remove', data.stageId!)"><Delete /></button></header>
|
||||
<Handle v-if="data.stage" id="in" type="target" :position="Position.Left" :connectable="!!data.canConfigureStages" :style="{ top: '42px' }" />
|
||||
<header class="stage-drag"><span class="phase-dot"></span><span v-if="data.stage" class="stage-type">{{ stageNodeTypeLabel(data.stage) }}</span><span class="stage-title"><strong :title="data.title">{{ data.title }}</strong><button v-if="data.stage?.canEditStage === true" type="button" class="nodrag nopan node-action" aria-label="修改阶段名称" :title="renameBlockedReason || '修改阶段名称'" :disabled="!!renameBlockedReason || !!data.busy" @pointerdown.stop @mousedown.stop @click.stop="emit('rename', data.stageId!)"><EditPen /></button></span><span v-if="data.stage?.isCurrent" class="stage-current">当前</span><button v-if="data.stage?.stageKind === 'GROUP'" class="nodrag stage-toggle" @click.stop="emit('toggle', data.stageId!)">{{ data.collapsed ? '展开' : '折叠' }}</button><span v-if="data.stage" class="stage-version">v{{ data.stage.revisionNo || 1 }}</span><button v-if="data.stage && data.canConfigureStages" type="button" class="nodrag nopan node-action node-delete" aria-label="删除阶段" :title="String(data.deleteBlockedReason || '删除空阶段')" :disabled="!!data.deleteBlockedReason || !!data.busy" @pointerdown.stop @mousedown.stop @click.stop="emit('remove', data.stageId!)"><Delete /></button></header>
|
||||
<p v-if="data.stage" class="phase-description" :class="{ empty: !data.stage.description?.trim() }" :title="data.stage.description || '未填写阶段描述'">{{ data.stage.description || '未填写阶段描述' }}</p>
|
||||
<div class="phase-body"><button class="nodrag stage-items" :title="data.stage ? `发起人:${data.stage.creatorName || '#' + data.stage.creatorId};负责人:${data.stage.ownerName || '未设置'}。点击查看交付与审批。` : '查看工作项'" @click.stop="emit('view', data.stageId!)">{{ data.stage?.nodeType === 'PURCHASE' ? `${data.stage.purchaseBatchCount || 0} 个批次 · ${data.stage.purchaseProgress || 0}%` : `${data.itemCount || 0} 个工作项` }}</button><span v-if="data.stage" class="stage-status" :title="appearance.description">{{ appearance.label }}</span></div>
|
||||
<div v-if="data.stage" class="phase-plan" :class="{ warning: data.stage.scheduleReviewRequired || data.stage.overdue }" :title="planLabel(data.stage)">{{ planLabel(data.stage) }}</div>
|
||||
<div v-if="data.stage?.stageKind === 'GROUP'" class="group-summary">子阶段 {{ data.stage.completedChildStageCount || 0 }}/{{ data.stage.childStageCount || 0 }} 已完成 · 内部排期{{ data.stage.subtreeScheduleValidationStatus === 'VALID' ? '完整' : '待完善' }}</div>
|
||||
<div v-if="data.stage" class="phase-actions"><button v-if="data.canManage && data.stage.canCreateChildStage" class="nodrag stage-create" @click.stop="emit('createChild', data.stageId!)">+ 子阶段</button><button v-if="data.canWrite && data.stage.canCreateWorkItem" class="nodrag stage-create" @click.stop="emit('create', data.stageId!)">新建</button><button v-if="data.stage.canApproveCompletion || data.stage.canSubmitCompletion || data.stage.canConfirmPurchase" class="nodrag" @click.stop="emit('view', data.stageId!)">{{ data.stage.canApproveCompletion ? '审批' : data.stage.canConfirmPurchase ? '确认完成' : '提审' }}</button><button class="nodrag stage-history" @click.stop="emit('history', data.stageId!)">历史版本</button><button v-if="data.canManage && data.stage.canRework" class="nodrag stage-rework" @click.stop="emit('rework', data.stageId!)">回退</button></div>
|
||||
<div v-if="data.stage" class="phase-actions"><button v-if="data.canConfigureStages && data.stage.canCreateChildStage" class="nodrag stage-create" @click.stop="emit('createChild', data.stageId!)">+ 子阶段</button><button v-if="data.canWrite && data.stage.canCreateWorkItem" class="nodrag stage-create" @click.stop="emit('create', data.stageId!)">新建</button><button v-if="data.stage.canApproveCompletion || data.stage.canSubmitCompletion || data.stage.canConfirmPurchase" class="nodrag" @click.stop="emit('view', data.stageId!)">{{ data.stage.canApproveCompletion ? '审批' : data.stage.canConfirmPurchase ? '确认完成' : '提审' }}</button><button class="nodrag stage-history" @click.stop="emit('history', data.stageId!)">历史版本</button><button v-if="data.canManage && data.stage.canRework" class="nodrag stage-rework" @click.stop="emit('rework', data.stageId!)">回退</button></div>
|
||||
<Handle v-if="data.stage" id="rework-out" type="source" :position="Position.Bottom" :connectable="false" :style="{ left: '70%', opacity: 0, pointerEvents: 'none' }" />
|
||||
<Handle v-if="data.stage" id="rework-in" type="target" :position="Position.Bottom" :connectable="false" :style="{ left: '30%', opacity: 0, pointerEvents: 'none' }" />
|
||||
<Handle v-if="data.stage" id="out" type="source" :position="Position.Right" :connectable="!!data.canManage" :style="{ top: '42px' }" />
|
||||
<Handle v-if="data.stage" id="out" type="source" :position="Position.Right" :connectable="!!data.canConfigureStages" :style="{ top: '42px' }" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
||||
@ -209,19 +209,24 @@ export function useSharedFlowLayout(options: SharedLayoutOptions) {
|
||||
await flush()
|
||||
}
|
||||
|
||||
/** 显式重载由组件先确认丢弃草稿;读取失败时仍保留原草稿和版本。 */
|
||||
async function reload(): Promise<void> {
|
||||
/**
|
||||
* 显式重载由组件先确认丢弃草稿;失败或离开原范围时保留现状,不误报已恢复数据库布局。
|
||||
* @returns 仅在当前可见范围成功应用数据库快照时为 true,供画布随后重置临时浏览状态
|
||||
*/
|
||||
async function reload(): Promise<boolean> {
|
||||
const context = current.value
|
||||
if (!isVisible(context) || !context.iterationId) return
|
||||
if (!isVisible(context) || !context.iterationId) return false
|
||||
clearTimer(context)
|
||||
if (context.inFlight) await context.inFlight
|
||||
const epoch = ++context.readEpoch
|
||||
context.loading = true
|
||||
try {
|
||||
const snapshot = await options.load(context.projectId, context.iterationId)
|
||||
if (isVisible(context) && epoch === context.readEpoch) apply(context, snapshot)
|
||||
if (isVisible(context) && epoch === context.readEpoch) { apply(context, snapshot); return true }
|
||||
return false
|
||||
} catch (error) {
|
||||
if (isVisible(context) && epoch === context.readEpoch) context.failure = '共享布局加载失败:' + errorText(error)
|
||||
return false
|
||||
} finally { if (current.value === context && epoch === context.readEpoch) context.loading = false }
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
</div>
|
||||
<el-empty v-if="!rows.length && !unscheduled.length" :image-size="64" :description="memberFiltered ? '所选成员在当前范围内暂无符合条件的工作项' : '当前范围内暂无符合条件的工作项'" />
|
||||
<el-dialog :close-on-click-modal="false" :model-value="!!selectedStage" :title="(selectedStage?.name || '') + ' · 阶段时间'" width="min(800px, 95%)" append-to-body @close="selectedStageId = null">
|
||||
<StageSchedulePanel v-if="selectedStage && projectId" :project-id="projectId" :iteration-id="iterationId" :stage-id="selectedStage.id" :schedule="selectedStage" :can-manage="canManage && selectedStage.approvalStatus !== 'PENDING'" :completed="frozen(selectedStage.id)" @changed="emit('changed')" />
|
||||
<StageSchedulePanel v-if="selectedStage && projectId" :project-id="projectId" :iteration-id="iterationId" :stage-id="selectedStage.id" :schedule="selectedStage" :can-schedule-stage="selectedStage.canScheduleStage === true && selectedStage.approvalStatus !== 'PENDING'" :completed="frozen(selectedStage.id)" @changed="emit('changed')" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@ -44,7 +44,7 @@ import { useGanttViewport } from './composables/useGanttViewport'
|
||||
import { collectGanttData } from './utils/exportData'
|
||||
import { createGanttImage, ganttImageBlob, downloadGanttImage, type GanttExportFormat } from './utils/exportImage'
|
||||
|
||||
const props = withDefaults(defineProps<{ items: WorkItem[]; stages?: Stage[]; zone: string; canWrite: boolean; canManage?: boolean; projectId?: number; iterationId?: number; from?: string; to?: string; memberFiltered?: boolean; stageFilter?: number | null; loading?: boolean; projectName?: string; iterationName?: string; exportQuery?: ItemQuery; exportFilters?: string }>(), { stages: () => [], memberFiltered: false })
|
||||
const props = withDefaults(defineProps<{ items: WorkItem[]; stages?: Stage[]; zone: string; canWrite: boolean; projectId?: number; iterationId?: number; from?: string; to?: string; memberFiltered?: boolean; stageFilter?: number | null; loading?: boolean; projectName?: string; iterationName?: string; exportQuery?: ItemQuery; exportFilters?: string }>(), { stages: () => [], memberFiltered: false })
|
||||
const emit = defineEmits<{ open: [id: number]; changed: [] }>()
|
||||
const unit = 34, labelWidth = 220, dayMs = 86400000
|
||||
const pending = reactive(new Set<string>()), selectedStageId = ref<number | null>(null)
|
||||
@ -91,8 +91,12 @@ async function exportImage() {
|
||||
}
|
||||
/** 完成后的正常计划只读;缺失计划在专门的补录面板处理。 */
|
||||
function frozen(stageId?: number | null) { return ['COMPLETED', 'LEGACY_PASSED'].includes(props.stages.find(stage => stage.id === stageId)?.executionStatus || '') }
|
||||
/** 参考条、只读阶段及缺少版本的条目不开放手势,最终权限仍由后端重新验证。 */
|
||||
function editable(row: TimelineRow) { const stage = row.stage || props.stages.find(value => value.id === row.item?.stageId); return stage?.approvalStatus !== 'PENDING' && !row.reference && !pending.has(row.key) && (row.stage ? !!props.canManage && !!props.projectId && !!props.iterationId && row.stage.revisionVersion !== undefined && !frozen(row.stage.id) : props.canWrite && !row.item?.historical && !frozen(row.item?.stageId)) }
|
||||
/** 工作项和阶段各取自身排期能力;缺失能力、参考条及冻结对象拒绝手势。 */
|
||||
function editable(row: TimelineRow) {
|
||||
const item = row.item && props.items.find(value => value.id === row.item?.id)
|
||||
const stage = props.stages.find(value => value.id === (row.stage?.id ?? item?.stageId))
|
||||
return stage?.approvalStatus !== 'PENDING' && !row.reference && !pending.has(row.key) && (row.stage ? !!stage && stage.canScheduleStage === true && !!props.projectId && !!props.iterationId && stage.revisionVersion !== undefined && !frozen(stage.id) : !!item && props.canWrite && item.canScheduleWorkItem === true && !item.iterationReadOnly && !item.stageReadOnly && !item.historical && !frozen(item.stageId))
|
||||
}
|
||||
/** 点击阶段查看阶段时间,点击工作项保持原详情弹窗入口。 */
|
||||
function openRow(row: TimelineRow) { if (row.stage) selectedStageId.value = row.stage.id; else if (row.item) emit('open', row.item.id) }
|
||||
/** 日期网格投影原计划;旧排期位置保持精度,主动拖动后的请求才按整日边界提交。 */
|
||||
@ -111,7 +115,7 @@ function begin(row: TimelineRow, event: PointerEvent, kind: 'move' | 'start' | '
|
||||
}
|
||||
/** 只更新临时视觉偏移,失败或取消能直接恢复原条形位置。 */
|
||||
function track(event: PointerEvent) { if (gesture.value) gesture.value.delta = event.clientX - gesture.value.x }
|
||||
/** 阶段与任务按整日边界调用统一改期入口;已开始阶段要求说明原因,失败恢复包含旧精度的原计划。 */
|
||||
/** 松开时复验对象能力;阶段原因确认后再次核对最新行资格及冻结状态,失败恢复原计划。 */
|
||||
async function end() {
|
||||
window.removeEventListener('pointermove', track)
|
||||
const current = gesture.value; gesture.value = null
|
||||
@ -128,7 +132,8 @@ async function end() {
|
||||
try { const answer = await ElMessageBox.prompt('阶段已开始,请填写调整原因', '调整阶段计划', { closeOnClickModal: false, inputValidator: value => !!value?.trim() || '请输入调整原因' }); reason = answer.value }
|
||||
catch { return }
|
||||
}
|
||||
if (disposed) return
|
||||
const latest = props.stages.find(stage => stage.id === row.stage?.id)
|
||||
if (disposed || latest?.canScheduleStage !== true || latest.approvalStatus === 'PENDING' || frozen(latest.id)) return
|
||||
const change: StageScheduleChange = { id: row.stage.id, revisionId: row.stage.revisionId ?? row.stage.currentRevisionId!, version: row.stage.revisionVersion!, plannedStartAt, plannedEndAt, reason }
|
||||
await api.stageSchedule(props.projectId!, props.iterationId!, change)
|
||||
} else if (row.item) {
|
||||
|
||||
@ -145,17 +145,17 @@
|
||||
size="small"
|
||||
link
|
||||
type="primary"
|
||||
:disabled="!canExecute || !row.canStart"
|
||||
@click="emit('start', row)"
|
||||
:disabled="!canExecute || row.canExecuteWorkItem !== true || !row.canStart"
|
||||
@click="startItem(row)"
|
||||
>开始</el-button>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<el-button
|
||||
v-if="row.canCreateChild"
|
||||
v-if="row.canCreateChild === true"
|
||||
size="small"
|
||||
link
|
||||
type="primary"
|
||||
@click="emit('createChild', row)"
|
||||
@click="createChild(row)"
|
||||
>子任务</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -187,6 +187,10 @@ const emit = defineEmits<{
|
||||
createChild: [item: WorkItem]
|
||||
}>()
|
||||
const treeItems = computed(() => buildItemTree(props.items, props.items))
|
||||
/** 按钮、键盘或合成事件共用开始守卫,缺失对象能力不能从项目写权限推断。 */
|
||||
function startItem(item: WorkItem) { if (props.canWrite && props.canExecute && item.canExecuteWorkItem === true && item.canStart) emit('start', item) }
|
||||
/** 子任务创建只使用当前父任务的明确能力,事件不把普通成员升级为负责人。 */
|
||||
function createChild(item: WorkItem) { if (props.canWrite && item.canCreateChild === true) emit('createChild', item) }
|
||||
const expandedKeys = ref<string[]>([])
|
||||
let knownParents = new Set<string>()
|
||||
watch(treeItems, retainExpansion, { immediate: true })
|
||||
|
||||
@ -78,7 +78,7 @@
|
||||
</el-tabs>
|
||||
<div class="toolbar-actions">
|
||||
<el-button
|
||||
v-if="canWrite"
|
||||
v-if="canSchedule"
|
||||
@click="openBatch"
|
||||
>批量排期</el-button>
|
||||
<el-button
|
||||
@ -203,7 +203,6 @@
|
||||
:iteration-name="selectedIteration.name"
|
||||
:loading="loading"
|
||||
:can-write="canWrite"
|
||||
:can-manage="canWrite && current.canManage"
|
||||
:project-id="current.id"
|
||||
:iteration-id="iterationId!"
|
||||
@open="detailId = $event"
|
||||
@ -295,7 +294,7 @@
|
||||
:visible="batchOpen"
|
||||
:project-id="current.id"
|
||||
:iteration-id="iterationId"
|
||||
:can-manage="current.canManage"
|
||||
:current-stages="flowView?.stages || []"
|
||||
:can-write="canWrite"
|
||||
@close="batchOpen = false"
|
||||
@saved="batchOpen = false; refresh()"
|
||||
@ -322,7 +321,7 @@ const emit = defineEmits<{ back: [] }>()
|
||||
|
||||
const {
|
||||
projectId, iterations, iterationId, includeArchived,
|
||||
items, members, flowView, current, selectedIteration, zone, canWrite, canCreate, canExecute,
|
||||
items, members, flowView, current, selectedIteration, zone, canWrite, canCreate, canExecute, canSchedule,
|
||||
loading, failure, tab, keyword, typeFilter, blockedOnly, stageFilter, detailId, focusedItem, focusedStageId, targetFailure, refreshKey, selection,
|
||||
editing, editorOpen, creatingParent, defaultStageId, page, pageSize, total, boardCounts,
|
||||
ganttFrom, ganttTo, ganttMemberIds, boardMemberIds, ganttExportQuery, ganttExportFilters, membersOpen, inviteUser, inviteRole, userCandidates, batchOpen,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user