feat: 迭代操作
This commit is contained in:
parent
6973a391ac
commit
c100721ecf
@ -573,10 +573,10 @@ CREATE TABLE pm_collab_stage_revision_member (
|
||||
|
||||
-- 画布分类固定于阶段身份,不随执行版本变化;历史普通阶段使用 STAGE。
|
||||
ALTER TABLE pm_collab_project_stage
|
||||
ADD COLUMN node_type VARCHAR(24) NOT NULL DEFAULT 'STAGE' COMMENT '固定节点类型:GROUP阶段组,REQUIREMENT需求,PROPOSAL方案,PURCHASE采购,DESIGN设计,MACHINING加工,ASSEMBLY组装,DEBUGGING调试,DEVELOPMENT研发,TESTING测试,STAGE历史普通阶段',
|
||||
ADD COLUMN node_type VARCHAR(24) NOT NULL DEFAULT 'STAGE' COMMENT '固定节点类型:GROUP阶段组,REQUIREMENT需求,PROPOSAL方案,PURCHASE采购,DESIGN设计,MACHINING加工,ASSEMBLY组装,DEBUGGING调试,DEVELOPMENT研发,TESTING测试,CUSTOM自定义,STAGE历史普通阶段',
|
||||
ADD CONSTRAINT ck_pm_stage_node_type CHECK (
|
||||
(node_type='GROUP' AND stage_kind='GROUP') OR
|
||||
(node_type IN ('STAGE','REQUIREMENT','PROPOSAL','PURCHASE','DESIGN','MACHINING','ASSEMBLY','DEBUGGING','DEVELOPMENT','TESTING') AND stage_kind='WORK')
|
||||
(node_type IN ('STAGE','REQUIREMENT','PROPOSAL','PURCHASE','DESIGN','MACHINING','ASSEMBLY','DEBUGGING','DEVELOPMENT','TESTING','CUSTOM') AND stage_kind='WORK')
|
||||
);
|
||||
|
||||
-- 阶段版本交付、人工完成审批及采购批次引用。
|
||||
|
||||
12
ruoyi-project/sql/upgrade/024_custom_stage_node.sql
Normal file
12
ruoyi-project/sql/upgrade/024_custom_stage_node.sql
Normal file
@ -0,0 +1,12 @@
|
||||
-- 项目协作:新增自定义工作阶段分类。023 后执行,可重复执行;不修改历史类型或执行事实。
|
||||
SET NAMES utf8mb4;
|
||||
SET @pm_custom_check_exists=(SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS
|
||||
WHERE CONSTRAINT_SCHEMA=DATABASE() AND TABLE_NAME='pm_collab_project_stage' AND CONSTRAINT_NAME='ck_pm_stage_node_type');
|
||||
-- 在同一 ALTER 内替换分类约束和补充中文注释,避免存在无类型校验的中间状态。
|
||||
SET @pm_custom_ddl=CONCAT('ALTER TABLE pm_collab_project_stage ',
|
||||
IF(@pm_custom_check_exists>0,'DROP CHECK ck_pm_stage_node_type, ',''),
|
||||
'MODIFY COLUMN node_type VARCHAR(24) NOT NULL DEFAULT ''STAGE'' COMMENT ''固定节点类型:GROUP阶段组,REQUIREMENT需求,PROPOSAL方案,PURCHASE采购,DESIGN设计,MACHINING加工,ASSEMBLY组装,DEBUGGING调试,DEVELOPMENT研发,TESTING测试,CUSTOM自定义,STAGE历史普通阶段'', ',
|
||||
'ADD CONSTRAINT ck_pm_stage_node_type CHECK ((node_type=''GROUP'' AND stage_kind=''GROUP'') OR (node_type IN (''STAGE'',''REQUIREMENT'',''PROPOSAL'',''PURCHASE'',''DESIGN'',''MACHINING'',''ASSEMBLY'',''DEBUGGING'',''DEVELOPMENT'',''TESTING'',''CUSTOM'') AND stage_kind=''WORK''))');
|
||||
PREPARE pm_custom_stmt FROM @pm_custom_ddl;
|
||||
EXECUTE pm_custom_stmt;
|
||||
DEALLOCATE PREPARE pm_custom_stmt;
|
||||
@ -2,6 +2,7 @@ package com.ruoyi.project.manage.controller;
|
||||
|
||||
import com.ruoyi.project.manage.dto.StageAssignment;
|
||||
import com.ruoyi.project.manage.dto.StageInput;
|
||||
import com.ruoyi.project.manage.dto.StageNameInput;
|
||||
import com.ruoyi.project.manage.dto.StageEdgeInput;
|
||||
import com.ruoyi.project.manage.dto.VersionInput;
|
||||
import com.ruoyi.project.manage.exception.PmException;
|
||||
@ -38,6 +39,9 @@ public class PmStageController {
|
||||
/** 阶段版本与所属迭代状态均在统一项目锁内检查。 */
|
||||
@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); }
|
||||
/** 仅当前迭代的空阶段可软删除,保留原版本记录。 */
|
||||
@DeleteMapping("/projects/{id}/iterations/{iterationId}/stages/{stageId}")
|
||||
public Map<String,Object> iterationDelete(@PathVariable long id,@PathVariable long iterationId,@PathVariable long stageId,@RequestBody JsonNode body) { service.deleteStage(id,iterationId,stageId,decode(body,VersionInput.class)); return ok(null); }
|
||||
|
||||
@ -4,7 +4,7 @@ import com.ruoyi.project.manage.exception.PmException;
|
||||
|
||||
/** 画布节点的固定业务类型;仅 GROUP 承载子阶段,其余类型共用工作阶段的执行规则。 */
|
||||
public enum StageNodeType {
|
||||
GROUP, REQUIREMENT, PROPOSAL, PURCHASE, DESIGN, MACHINING, ASSEMBLY, DEBUGGING, DEVELOPMENT, TESTING, STAGE;
|
||||
GROUP, REQUIREMENT, PROPOSAL, PURCHASE, DESIGN, MACHINING, ASSEMBLY, DEBUGGING, DEVELOPMENT, TESTING, CUSTOM, STAGE;
|
||||
|
||||
/** 将分类映射为既有结构类型,返回 GROUP 容器或 WORK 工作阶段,不改变执行和排期规则。 */
|
||||
public String kind() { return this == GROUP ? "GROUP" : "WORK"; }
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
package com.ruoyi.project.manage.dto;
|
||||
|
||||
/** 画布快捷改名白名单;不接收类型、负责人、采购范围或排期,防止改名覆盖其他业务信息。 */
|
||||
public record StageNameInput(String name, Integer version) { }
|
||||
@ -3,6 +3,7 @@ package com.ruoyi.project.manage.service;
|
||||
import com.ruoyi.project.manage.exception.PmException;
|
||||
import com.ruoyi.project.manage.dto.StageAssignment;
|
||||
import com.ruoyi.project.manage.dto.StageInput;
|
||||
import com.ruoyi.project.manage.dto.StageNameInput;
|
||||
import com.ruoyi.project.manage.dto.StageEdgeInput;
|
||||
import com.ruoyi.project.manage.dto.VersionInput;
|
||||
|
||||
@ -43,6 +44,8 @@ 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(); }
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package com.ruoyi.project.manage.service.impl;
|
||||
import com.ruoyi.project.manage.dto.StageAssignment;
|
||||
import com.ruoyi.project.manage.dto.StageEdgeInput;
|
||||
import com.ruoyi.project.manage.dto.StageInput;
|
||||
import com.ruoyi.project.manage.dto.StageNameInput;
|
||||
import com.ruoyi.project.manage.dto.VersionInput;
|
||||
import com.ruoyi.project.manage.exception.PmException;
|
||||
import com.ruoyi.project.manage.domain.Graph;
|
||||
@ -179,6 +180,26 @@ 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 renameStage(long projectId,long iterationId,long id,StageNameInput input) {
|
||||
locked(projectId,iterationId,"admin");
|
||||
Map<String,Object> existing=stage(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);
|
||||
stageMapper.updateStage(id,(int)number(existing,"version"),map("name",input.name().trim()));
|
||||
groups.bind(projectId,iterationId);
|
||||
snapshotDefinition(projectId,iterationId);
|
||||
auditService.record(projectId,iterationId,null,"STAGE_EDITED",map("stageId",id,"name",input.name().trim()),access.actor());
|
||||
}
|
||||
|
||||
/** 非空阶段拒绝删除;空阶段的连线先移除,再软删阶段并原子保存历史与事件。 */
|
||||
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"));
|
||||
|
||||
@ -57,14 +57,22 @@ manage/
|
||||
## 工作项分工与前置条件
|
||||
|
||||
- 阶段节点展示已有描述的两行摘要,完整说明在阶段抽屉查看;拖入新阶段时可填写描述。
|
||||
- 流程画布左侧节点库提供阶段组、需求、方案、采购、设计、加工、组装、调试、研发和测试,支持搜索与拖放。普通类型拖入组内(包括子节点上方)自动归属,组本身仍只支持根画布;未执行及历史保护规则保持不变。
|
||||
- 流程画布左侧节点库提供阶段组、需求、方案、采购、设计、加工、组装、调试、研发、测试和自定义,支持搜索与拖放。普通类型拖入组内(包括子节点上方)自动归属,组本身仍只支持根画布;未执行及历史保护规则保持不变。自定义类型按普通工作阶段要求交付齐备后提审,不支持承载子阶段。
|
||||
- 节点分类创建后固定,名称、负责人和说明可编辑;只有阶段组承载子阶段,其余分类沿用工作阶段规则。组内快捷创建可在提交前选择工作分类;复制迭代保留来源分类,回退换版沿用同一节点身份。
|
||||
- 已有数据库上线前执行 `ruoyi-project/sql/upgrade/022_stage_node_types.sql`;脚本可重复执行,已有工作阶段标为普通阶段,已有组标为阶段组,不改动排期、执行版本或工作项。新安装结构已包含分类字段和组合约束。
|
||||
- 已完成 023 的数据库执行 `ruoyi-project/sql/upgrade/024_custom_stage_node.sql` 开放自定义类型;该升级只扩展类型约束及中文字段注释,不转换历史节点分类。
|
||||
- 项目管理者可通过节点名称后的编辑图标快捷改名,接口只接收名称和阶段版本;审批中或已完成版本仍只读。节点右上角删除图标与阶段管理表共用保护条件,已有执行历史、工作项、子阶段、交付附件或采购批次时禁用并说明原因,后端仍持锁复验后软删除。
|
||||
- 新建和编辑工作项可从项目成员中多选协作人,负责人仍为单选。协作分工不改变项目角色或访问权限,历史版本保留原分工;回退复制仅继承仍有效的成员,并在预览中说明移除项。
|
||||
- 新建工作项可选多个同迭代前置工作项,需求、任务、缺陷均可作为依赖两端。所有前置已完成或已关闭才满足条件,取消不满足;编辑依赖仍使用详情中的专用入口。
|
||||
- 依赖、工作项和协作分工在同一项目锁事务中保存,继续共用实际开始、排期及混合执行图环检测。新建表单排期提示由后端约束预览计算,提交时重新验证。
|
||||
- 已有数据库先完成 `ruoyi-project/sql/upgrade/016_work_item_collaboration.sql` 增量升级;该文件新增协作人关联表并兼容新旧依赖标识,保留已有工作项与排期。全新环境使用 `ruoyi-project/sql/project_collaboration.sql`。
|
||||
|
||||
## 迭代操作
|
||||
|
||||
- 项目管理者在迭代工具栏直接编辑、开始、结束或删除当前迭代,更多操作使用点击菜单;普通成员不能管理迭代。归档及终态迭代的编辑入口禁用,可先取消归档或重新打开。
|
||||
- 筹备迭代由管理者手动开始并记录实际开始时间;执行中由管理者预览、确认结束并记录实际结束时间,不根据预计日期自动切换状态。待开始或进行中的工作项阻止结束,取消工作项或未审批阶段须逐条确认异常并说明原因后才能带异常结束。
|
||||
- 删除仅适用于从未执行且没有任何工作项或执行历史的筹备迭代,后端软删除并保留审计;已执行迭代通过结束、取消、归档保留历史。
|
||||
|
||||
## 甘特成员筛选
|
||||
|
||||
- 甘特排期的成员下拉支持多选当前项目成员;清空表示全部,多选按负责人或协作人任一匹配取并集,同一工作项只显示一次。
|
||||
|
||||
@ -30,6 +30,8 @@ export const stageApi = {
|
||||
removeStageEdge: (id: number, edgeId: number, version: number, iterationId?: number) => request<void>('delete', iterationPath(id, iterationId, `stage-edges/${edgeId}`), { version }),
|
||||
/** 阶段元数据独立版本更新,不调整任务状态或排期。 */
|
||||
editStage: (id: number, stageId: number, input: StageInput, iterationId?: number) => request<void>('patch', iterationPath(id, iterationId, `stages/${stageId}`), input),
|
||||
/** 画布快捷改名只传名称及当前版本,不能借此改动交付数据或固定类型。 */
|
||||
renameStage: (id: number, stageId: number, name: string, version: number, iterationId?: number) => request<void>('patch', iterationPath(id, iterationId, `stages/${stageId}/name`), { name, version }),
|
||||
/** 非空阶段由后端拒绝;空阶段软删除保留历史。 */
|
||||
removeStage: (id: number, stageId: number, version: number, iterationId?: number) => request<void>('delete', iterationPath(id, iterationId, `stages/${stageId}`), { version }),
|
||||
}
|
||||
|
||||
@ -5,15 +5,17 @@
|
||||
<el-tag v-if="selected" :type="readOnly ? 'info' : 'success'">{{ iterationStatusNames[selected.status] }}{{ selected.archivedAt ? ' · 已归档' : '' }}</el-tag>
|
||||
<span v-if="selected?.finishResult" class="iteration-note">{{ selected.finishResult === 'COMPLETED' ? '正常完成' : '带异常结束' }}</span>
|
||||
<el-button v-if="canManage" @click="openEditor()">新建迭代</el-button>
|
||||
<el-dropdown v-if="selected && canManage"><el-button>迭代操作</el-button><template #dropdown><el-dropdown-menu>
|
||||
<el-dropdown-item v-if="!readOnly" @click="openEditor(selected)">编辑迭代</el-dropdown-item>
|
||||
<el-dropdown-item v-if="!selected.archivedAt && selected.status === 'PLANNED'" @click="simpleAction('activate')">开始迭代</el-dropdown-item>
|
||||
<el-dropdown-item v-if="!selected.archivedAt && selected.status === 'ACTIVE'" @click="openPreview('finish')">结束迭代</el-dropdown-item>
|
||||
<template v-if="selected && canManage">
|
||||
<el-button :disabled="readOnly || busy" :title="readOnly ? '当前迭代只读;请先取消归档或重新打开,再编辑。' : '修改迭代名称、目标和计划日期'" @click="openEditor(selected)">编辑迭代</el-button>
|
||||
<el-button v-if="!selected.archivedAt && selected.status === 'PLANNED'" type="primary" plain :disabled="busy" @click="simpleAction('activate')">开始迭代</el-button>
|
||||
<el-button v-if="!selected.archivedAt && selected.status === 'ACTIVE'" type="primary" plain :disabled="busy" @click="openPreview('finish')">结束迭代</el-button>
|
||||
<el-button type="danger" plain :disabled="!!deleteDisabledReason || busy" :title="deleteDisabledReason || '仅可删除没有工作项或执行历史的筹备迭代;阶段配置会保留在软删除记录中。'" @click="remove">删除迭代</el-button>
|
||||
</template>
|
||||
<el-dropdown v-if="selected && canManage" trigger="click"><el-button :disabled="busy">更多迭代操作 <el-icon><ArrowDown /></el-icon></el-button><template #dropdown><el-dropdown-menu>
|
||||
<el-dropdown-item v-if="!readOnly" @click="openPreview('cancel')">取消迭代</el-dropdown-item>
|
||||
<el-dropdown-item v-if="!selected.archivedAt && ['FINISHED', 'CANCELLED'].includes(selected.status)" @click="simpleAction('reopen')">重新打开</el-dropdown-item>
|
||||
<el-dropdown-item v-if="!selected.archivedAt && ['FINISHED', 'CANCELLED'].includes(selected.status)" @click="simpleAction('archive')">归档</el-dropdown-item>
|
||||
<el-dropdown-item v-if="selected.archivedAt" @click="simpleAction('unarchive')">取消归档</el-dropdown-item>
|
||||
<el-dropdown-item v-if="selected.status === 'PLANNED' && !selected.archivedAt" @click="remove">删除空迭代</el-dropdown-item>
|
||||
</el-dropdown-menu></template></el-dropdown>
|
||||
<span v-if="readOnly && selected" class="iteration-note">当前迭代只读,可查看详情、历史与下载附件。</span>
|
||||
<el-dialog :close-on-click-modal="false" v-model="editorOpen" :title="editing ? '编辑迭代' : '新建迭代'" width="min(600px, 95%)" append-to-body>
|
||||
@ -39,6 +41,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ArrowDown } from '@element-plus/icons-vue'
|
||||
import { api, errorText } from '../../../api'
|
||||
import type { Iteration, IterationInput, IterationAction, IterationPreview, Lifecycle } from '../../../types'
|
||||
import { iterationStatusNames, statusNames } from '../../../shared/constants/labels'
|
||||
@ -49,6 +52,8 @@ import { createIdempotencyKey } from '../../../shared/utils/idempotency'
|
||||
const props = defineProps<{ projectId: number; iterationId: number | null; iterations: Iteration[]; canManage: boolean; includeArchived: boolean }>()
|
||||
const emit = defineEmits<{ select: [id: number]; changed: [id?: number]; 'archive-filter': [include: boolean] }>()
|
||||
const selected = computed(() => props.iterations.find(row => row.id === props.iterationId)), readOnly = computed(() => iterationReadOnly(selected.value))
|
||||
// 状态不允许删除时保留入口并解释原因;工作项和历史是否为空仍由后端事务内核验。
|
||||
const deleteDisabledReason = computed(() => selected.value?.archivedAt ? '归档迭代不能删除,请先取消归档。' : selected.value?.status !== 'PLANNED' ? '仅从未执行的筹备迭代可以删除;已执行迭代请结束或归档保留历史。' : '')
|
||||
const editorOpen = ref(false), editing = ref<Iteration | null>(null), busy = ref(false), failure = ref(''), invalidStart = ref(false), invalidEnd = ref(false)
|
||||
const draft = reactive<IterationInput>({ code: '', name: '', goal: '', plannedStartAt: null, plannedEndAt: null, sortOrder: 0, sourceIterationId: null })
|
||||
const previewOpen = ref(false), previewAction = ref<'finish' | 'cancel'>('finish'), preview = ref<IterationPreview | null>(null), accepted = ref<string[]>([]), reason = ref(''), requestKey = ref('')
|
||||
@ -62,21 +67,22 @@ function openEditor(row?: Iteration) { editing.value = row || null; Object.assig
|
||||
async function save() { const token = sequence; busy.value = true; failure.value = ''; try { const input = { ...draft, ...(editing.value ? editedPlannedRange(draft.plannedStartAt, draft.plannedEndAt, editing.value.plannedStartAt, editing.value.plannedEndAt) : plannedRange(draft.plannedStartAt, draft.plannedEndAt)), idempotencyKey: requestKey.value }; if (input.sourceIterationId) input.sourceGraphVersion = (await api.iteration(props.projectId, input.sourceIterationId)).graphVersion; const result = editing.value ? await api.editIteration(props.projectId, editing.value.id, input) : await api.createIteration(props.projectId, input); if (token === sequence) { if (result.copyWarnings?.length) ElMessage.warning(result.copyWarnings.map(warning => warning.message).join('\n')); editorOpen.value = false; emit('changed', result.id) } } catch (error) { if (token === sequence) failure.value = errorText(error) } finally { busy.value = false } }
|
||||
/** 所有动作包含元数据及图版本和兼容 HTTP 的幂等键,拒绝时不修改本地生命周期。 */
|
||||
function actionInput(row: Iteration): IterationAction { return { version: row.version, graphVersion: row.graphVersion, idempotencyKey: createIdempotencyKey() } }
|
||||
/** 开始、重开和归档展示具体确认,确认后以服务端状态刷新。 */
|
||||
async function simpleAction(action: 'activate' | 'reopen' | 'archive' | 'unarchive') { const row = selected.value; if (!row) return; const token = sequence, projectId = props.projectId; const labels = { activate: '开始迭代', reopen: '重新打开迭代', archive: '归档迭代', unarchive: '取消归档' }; try { await ElMessageBox.confirm(`${labels[action]}“${row.name}”?`, labels[action], { closeOnClickModal: false }); const latest = await api.iteration(projectId, row.id); if (token !== sequence) return; await api.iterationAction(projectId, row.id, action, { ...actionInput(row), graphVersion: latest.graphVersion }); if (token === sequence) emit('changed', row.id) } catch (error) { if (error !== 'cancel' && error !== 'close') ElMessage.error(errorText(error)) } }
|
||||
/** 开始、重开和归档须明确确认;确认期间暂停同步及重复操作,切换迭代后忽略旧请求回调。 */
|
||||
async function simpleAction(action: 'activate' | 'reopen' | 'archive' | 'unarchive') { const row = selected.value; if (!row || busy.value) return; const token = sequence, projectId = props.projectId; const labels = { activate: '开始迭代', reopen: '重新打开迭代', archive: '归档迭代', unarchive: '取消归档' }; busy.value = true; try { await ElMessageBox.confirm(`${labels[action]}“${row.name}”?`, labels[action], { closeOnClickModal: false }); if (token !== sequence) return; const latest = await api.iteration(projectId, row.id); if (token !== sequence) return; await api.iterationAction(projectId, row.id, action, { ...actionInput(row), graphVersion: latest.graphVersion }); if (token === sequence) emit('changed', row.id) } catch (error) { if (token === sequence && error !== 'cancel' && error !== 'close') ElMessage.error(errorText(error)) } finally { busy.value = false } }
|
||||
/** 结束和取消先生成兼容 HTTP 的预览请求键并取得完整影响清单,预览与提交沿用同一键。 */
|
||||
async function openPreview(action: 'finish' | 'cancel') { const row = selected.value; if (!row) return; const token = sequence; busy.value = true; failure.value = ''; preview.value = null; accepted.value = []; reason.value = ''; previewAction.value = action; requestKey.value = createIdempotencyKey(); previewOpen.value = true; try { const result = await api.previewIteration(props.projectId, row.id, action, { ...actionInput(row), idempotencyKey: requestKey.value }); if (token === sequence) preview.value = result } catch (error) { if (token === sequence) failure.value = errorText(error) } finally { busy.value = false } }
|
||||
/** 异常必须逐条显式确认,取消勾选会立即阻止带异常结束。 */
|
||||
function toggleException(key: string, checked: boolean) { accepted.value = checked ? [...new Set([...accepted.value, key])] : accepted.value.filter(value => value !== key) }
|
||||
/** 提交与预览一致的版本和确认清单;取消清单在服务端同事务重新比对。 */
|
||||
async function commitPreview() { const row = selected.value, result = preview.value; if (!row || !result || !canCommit.value) return; const token = sequence; busy.value = true; failure.value = ''; try { await api.iterationAction(props.projectId, row.id, previewAction.value, { version: result.version, graphVersion: result.graphVersion, idempotencyKey: requestKey.value, reason: reason.value, acceptedExceptionIds: accepted.value, acceptedItemIds: previewAction.value === 'cancel' ? result.itemsToCancel.map(item => item.id) : [] }); if (token === sequence) { previewOpen.value = false; emit('changed', row.id) } } catch (error) { if (token === sequence) { failure.value = errorText(error); preview.value = null } } finally { busy.value = false } }
|
||||
/** 删除仅允许空迭代并由后端核验;软删除保留审计记录。 */
|
||||
async function remove() { const row = selected.value; if (!row) return; try { await ElMessageBox.confirm(`删除空迭代“${row.name}”?存在工作项或执行历史时将拒绝。`, '删除空迭代', { type: 'warning', closeOnClickModal: false }); await api.deleteIteration(props.projectId, row.id, actionInput(row)); emit('changed') } catch (error) { if (error !== 'cancel' && error !== 'close') ElMessage.error(errorText(error)) } }
|
||||
/** 删除空筹备迭代由后端核验并软删除;确认期间暂停同步,切换范围后不发旧请求或刷新新迭代。 */
|
||||
async function remove() { const row = selected.value; if (!row || deleteDisabledReason.value || busy.value) return; const token = sequence, projectId = props.projectId; busy.value = true; try { await ElMessageBox.confirm(`删除筹备迭代“${row.name}”?存在工作项或执行历史时将拒绝;通过后软删除并保留记录。`, '删除迭代', { type: 'warning', closeOnClickModal: false }); if (token !== sequence) return; await api.deleteIteration(projectId, row.id, actionInput(row)); if (token === sequence) emit('changed') } catch (error) { if (token === sequence && error !== 'cancel' && error !== 'close') ElMessage.error(errorText(error)) } finally { busy.value = false } }
|
||||
defineExpose({ isEditing: computed(() => editorOpen.value || previewOpen.value || busy.value) })
|
||||
</script>
|
||||
<style scoped>.iteration-controls{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:10px}
|
||||
/* 组件 DOM 和状态类由运行时生成;按 class token 匹配保持原选择器的含义和优先级,避免 IDE 静态模板匹配误报。 */
|
||||
.iteration-controls>[class~="el-select"]{width:250px}.iteration-note{font-size:12px;color:var(--el-text-color-secondary)}
|
||||
.iteration-controls :deep(.el-button+.el-button){margin-left:0}
|
||||
.el-form [class~="el-select"]{width:100%}
|
||||
.el-dialog [class~="el-checkbox"]{display:block;height:auto;white-space:normal;margin:10px 0}
|
||||
[class~="el-textarea"]{margin-top:12px}</style>
|
||||
|
||||
@ -37,6 +37,7 @@ import PurchaseBatchPicker from './PurchaseBatchPicker.vue'
|
||||
import type { Stage, StageInput, Member, FlowView, PurchaseBatchProgress } from '../../../types'
|
||||
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 emit = defineEmits<{ close: []; changed: [] }>()
|
||||
const structureOpen = ref(false)
|
||||
@ -55,29 +56,13 @@ async function open(stage: Stage) {
|
||||
}
|
||||
/** 保存经经理鉴权与阶段版本校验的元数据,失败保留草稿。 */
|
||||
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 } }
|
||||
/**
|
||||
* 根据服务端的历史与当前执行状态判断是否曾执行,不把回退后的新版本误当作全新阶段。
|
||||
* @param stage 已鉴权阶段摘要,历史标记兼容旧接口返回的 0/1
|
||||
* @returns 是否必须保留执行历史对应的阶段结构
|
||||
*/
|
||||
function hasExecutionHistory(stage: Stage): boolean { return !!stage.executionHistory || !!stage.executionStatus && stage.executionStatus !== 'NOT_STARTED' }
|
||||
|
||||
/**
|
||||
* 为删除按钮提供与已有后端保护一致的原因,空工作项不代表阶段从未执行。
|
||||
* @param stage 当前行阶段,父组保护从同一份项目阶段摘要读取
|
||||
* @returns 不可删除的具体原因;空字符串允许发起确认,最终仍由后端持锁复验
|
||||
*/
|
||||
function deleteBlockedReason(stage: Stage): string {
|
||||
if (hasExecutionHistory(stage)) return '该阶段已有执行历史,不能删除;清空工作项或回退换版不会清除执行历史。'
|
||||
const parent = props.stages.find(value => value.id === stage.parentStageId)
|
||||
if (parent && hasExecutionHistory(parent)) return '所属阶段组已有执行历史,不能删除其中的子阶段。'
|
||||
if (stage.approvalStatus === 'PENDING') return '阶段正在审批,不能删除。'
|
||||
if (stage.canEditStructure === false || parent?.canEditStructure === false) return '当前阶段或所属阶段组的结构不可编辑,不能删除。'
|
||||
if (stage.childStageCount) return '请先移出或删除组内子阶段。'
|
||||
if (stage.counts.total) return '请先移动阶段中的工作项。'
|
||||
if (stage.deliveryAttachmentCount) return '请先移除本轮交付附件。'
|
||||
if (stage.purchaseBatchCount) return '请先清空采购批次范围。'
|
||||
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 } }
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<el-dialog :model-value="!!stage" :close-on-click-modal="false" title="修改阶段名称" width="min(440px, 94vw)" append-to-body @close="emit('close')">
|
||||
<el-form size="small" label-position="top" @submit.prevent="save">
|
||||
<el-form-item label="阶段名称" required><el-input v-model="name" maxlength="120" show-word-limit autofocus :disabled="busy" /></el-form-item>
|
||||
<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>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { api, errorText } from '../../../api'
|
||||
import type { Stage } from '../../../types'
|
||||
import { stageRenameBlockedReason } from '../utils/actions'
|
||||
|
||||
const props = defineProps<{ stage: Stage | null; projectId: number; iterationId?: number }>()
|
||||
const emit = defineEmits<{ close: []; changed: [] }>()
|
||||
const name = ref(''), busy = ref(false), failure = ref('')
|
||||
let generation = 0
|
||||
/** 切换节点时建立独立名称草稿;不把当前输入绑定到共享阶段摘要。 */
|
||||
watch(() => props.stage, stage => { generation++; name.value = stage?.name || ''; failure.value = '' }, { immediate: true })
|
||||
/** 关闭或离开迭代后忽略旧请求回调,防止关闭另一节点的编辑框。 */
|
||||
onBeforeUnmount(() => { generation++ })
|
||||
/**
|
||||
* 使用只接受名称和阶段版本的接口,避免快捷改名覆盖负责人、描述、采购范围或日期。
|
||||
* 空值、冻结状态和重复提交在前端拦截;权限和并发版本仍由后端持锁复验。
|
||||
*/
|
||||
async function save() {
|
||||
const stage = props.stage
|
||||
if (!stage || 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 }
|
||||
const token = generation; busy.value = true; failure.value = ''
|
||||
try {
|
||||
await api.renameStage(props.projectId, stage.id, name.value.trim(), stage.version, props.iterationId)
|
||||
if (token === generation) { emit('changed'); emit('close') }
|
||||
} catch (error) { if (token === generation) failure.value = errorText(error) }
|
||||
finally { busy.value = false }
|
||||
}
|
||||
</script>
|
||||
<style scoped>.rename-hint{font-size:12px;color:var(--el-text-color-secondary)}</style>
|
||||
@ -0,0 +1,32 @@
|
||||
import type { Stage } from '../../../types'
|
||||
|
||||
/** 当前版本改名遵循交付冻结规则;历史名称快照保持只读,不随改名覆盖。 */
|
||||
export function stageRenameBlockedReason(stage: Stage): string {
|
||||
if (stage.approvalStatus === 'PENDING') return '阶段正在审批,请先撤回申请后修改名称。'
|
||||
if (['COMPLETED', 'LEGACY_PASSED'].includes(stage.executionStatus || '')) return '阶段已完成,当前版本只读。'
|
||||
return ''
|
||||
}
|
||||
|
||||
/** 根据全版本历史识别执行过的阶段,不能把回退后的空版本当作全新节点。 */
|
||||
function hasExecutionHistory(stage: Stage): boolean {
|
||||
return !!stage.executionHistory || !!stage.executionStatus && stage.executionStatus !== 'NOT_STARTED'
|
||||
}
|
||||
|
||||
/**
|
||||
* 为画布及管理表统一提供删除受限原因,后端仍在项目锁内复验历史、内容与版本。
|
||||
* @param stage 当前阶段;未分配虚拟节点不调用此方法
|
||||
* @param stages 当前迭代全部阶段,用于校验父组的历史保护
|
||||
* @returns 空字符串表示可请求删除确认,其他值用于禁用提示
|
||||
*/
|
||||
export function stageDeleteBlockedReason(stage: Stage, stages: readonly Stage[]): string {
|
||||
if (hasExecutionHistory(stage)) return '该阶段已有执行历史,不能删除;清空工作项或回退换版不会清除执行历史。'
|
||||
const parent = stages.find(value => value.id === stage.parentStageId)
|
||||
if (parent && hasExecutionHistory(parent)) return '所属阶段组已有执行历史,不能删除其中的子阶段。'
|
||||
if (stage.approvalStatus === 'PENDING') return '阶段正在审批,不能删除。'
|
||||
if (stage.canEditStructure === false || parent?.canEditStructure === false) return '当前阶段或所属阶段组的结构不可编辑,不能删除。'
|
||||
if (stage.childStageCount) return '请先移出或删除组内子阶段。'
|
||||
if (stage.counts.total) return '请先移动阶段中的工作项。'
|
||||
if (stage.deliveryAttachmentCount) return '请先移除本轮交付附件。'
|
||||
if (stage.purchaseBatchCount) return '请先清空采购批次范围。'
|
||||
return ''
|
||||
}
|
||||
@ -12,6 +12,7 @@ export const STAGE_NODE_TYPES = [
|
||||
{ value: 'DEBUGGING', label: '调试', symbol: '调', description: '开展设备或系统调试' },
|
||||
{ value: 'DEVELOPMENT', label: '研发', symbol: '研', description: '实施研发与功能开发' },
|
||||
{ value: 'TESTING', label: '测试', symbol: '测', description: '执行测试和验证工作' },
|
||||
{ value: 'CUSTOM', label: '自定义', symbol: '自', description: '自定名称和事项,按普通阶段提审完成' },
|
||||
] as const satisfies readonly { value: StageNodeType; label: string; symbol: string; description: string }[]
|
||||
|
||||
export const WORK_STAGE_NODE_TYPES = STAGE_NODE_TYPES.filter(type => type.value !== 'GROUP')
|
||||
|
||||
@ -27,7 +27,7 @@ export interface StageSummary {
|
||||
export type StageExecutionStatus = 'NOT_STARTED' | 'IN_PROGRESS' | 'COMPLETED' | 'LEGACY_PASSED'
|
||||
|
||||
/** 节点分类创建后固定;STAGE 只用于兼容历史普通阶段。 */
|
||||
export type StageNodeType = 'GROUP' | 'REQUIREMENT' | 'PROPOSAL' | 'PURCHASE' | 'DESIGN' | 'MACHINING' | 'ASSEMBLY' | 'DEBUGGING' | 'DEVELOPMENT' | 'TESTING' | 'STAGE'
|
||||
export type StageNodeType = 'GROUP' | 'REQUIREMENT' | 'PROPOSAL' | 'PURCHASE' | 'DESIGN' | 'MACHINING' | 'ASSEMBLY' | 'DEBUGGING' | 'DEVELOPMENT' | 'TESTING' | 'CUSTOM' | 'STAGE'
|
||||
|
||||
export interface Stage extends StageSummary, Omit<StageSchedule, 'plannedStartAt' | 'plannedEndAt'> {
|
||||
stageKind?: 'WORK' | 'GROUP'
|
||||
|
||||
@ -14,8 +14,8 @@
|
||||
<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" />
|
||||
<template #edge-rework="edgeProps"><FlowReworkEdge v-bind="edgeProps" /></template>
|
||||
<template #node-stage="{ data }"><FlowStageNode :data="data" @view="openDrawer($event, 'current')" @create="createInStage" @rework="openRework" @history="openDrawer($event, 'history')" /></template>
|
||||
<template #node-group="{ data }"><FlowStageNode :data="data" @view="openDrawer($event, 'current')" @create-child="createChildStage" @toggle="toggleGroup" @rework="openRework" @history="openDrawer($event, 'history')" /></template>
|
||||
<template #node-stage="{ data }"><FlowStageNode :data="{ ...data, busy }" @view="openDrawer($event, 'current')" @create="createInStage" @rework="openRework" @history="openDrawer($event, 'history')" @rename="renameStage" @remove="removeStage" /></template>
|
||||
<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>
|
||||
<div v-if="!view.unassigned?.counts?.total && !view.stages.length" class="canvas-empty">{{ canManage ? '从左侧拖入节点,然后连接阶段执行顺序。' : '暂无阶段和工作项。' }}</div>
|
||||
<div class="canvas-legend"><span class="legend-line"></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>
|
||||
@ -23,6 +23,7 @@
|
||||
</div>
|
||||
<StageCreateDialog :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" />
|
||||
</section>
|
||||
@ -47,9 +48,11 @@ import { stageGroupAt } from './utils/stageDrop'
|
||||
import { useCanvasGestureCleanup } from './composables/useCanvasGestureCleanup'
|
||||
import { isPaletteNodeType } from '../../shared/constants/stageNodeTypes'
|
||||
import type { FlowNodeData, FlowEdgeData } from './utils/graph'
|
||||
import type { FlowView, Member, Point, StageNodeType } from '../../types'
|
||||
import type { FlowView, Member, Point, Stage, StageNodeType } from '../../types'
|
||||
import StageManager from '../../features/stages/components/StageManager.vue'
|
||||
import StageCreateDialog from '../../features/stages/components/StageCreateDialog.vue'
|
||||
import StageRenameDialog from '../../features/stages/components/StageRenameDialog.vue'
|
||||
import { stageDeleteBlockedReason, stageRenameBlockedReason } from '../../features/stages/utils/actions'
|
||||
import FlowStageNode from './components/FlowStageNode.vue'
|
||||
import FlowNodePalette from './components/FlowNodePalette.vue'
|
||||
import FlowReworkEdge from './components/FlowReworkEdge.vue'
|
||||
@ -70,11 +73,12 @@ const createNodeType = ref<StageNodeType | undefined>(undefined)
|
||||
const createParent = computed(() => props.view.stages.find(stage => stage.id === createParentId.value) || null)
|
||||
const reworkSourceId = ref<number | null>(null), drawerStageId = ref<number | null>(null), drawerTab = ref<'current' | 'history'>('current')
|
||||
const drawerEditing = ref(false)
|
||||
const renamingStage = ref<Stage | null>(null)
|
||||
// 平移和节点移动期间都暂停静默同步,避免尚未释放的鼠标手势遇到画布重建;坐标仍仅保存到当前浏览器。
|
||||
const isEditing = computed(() => drawerEditing.value || dragging.value || paneDragging.value || busy.value || stageOpen.value || stageNameOpen.value || reworkSourceId.value !== null)
|
||||
const isEditing = computed(() => drawerEditing.value || dragging.value || paneDragging.value || busy.value || stageOpen.value || stageNameOpen.value || renamingStage.value !== null || reworkSourceId.value !== null)
|
||||
const { finishCanvasGesture } = useCanvasGestureCleanup(
|
||||
computed(() => dragging.value || paneDragging.value),
|
||||
computed(() => !props.active || stageOpen.value || stageNameOpen.value || drawerStageId.value !== null || reworkSourceId.value !== null),
|
||||
computed(() => !props.active || stageOpen.value || stageNameOpen.value || renamingStage.value !== null || drawerStageId.value !== null || reworkSourceId.value !== null),
|
||||
)
|
||||
defineExpose({ isEditing })
|
||||
let loaded = false, movingProgrammatically = false
|
||||
@ -96,14 +100,14 @@ watch(() => props.view, () => {
|
||||
}, { immediate: true })
|
||||
watch(() => [props.canCreate, props.canManage], rebuild)
|
||||
/** 生命周期或权限变成只读时关闭写对话框,避免已打开的入口继续提交。 */
|
||||
watch(() => props.canManage, allowed => { if (!allowed) { stageOpen.value = false; stageNameOpen.value = false; reworkSourceId.value = null } })
|
||||
watch(() => props.canManage, allowed => { if (!allowed) { stageOpen.value = false; stageNameOpen.value = false; renamingStage.value = null; reworkSourceId.value = null } })
|
||||
watch(() => props.active, async active => { if (active) { await nextTick(); await restoreViewport() } else if (loaded) { draftViewport.value = { ...viewport.value }; savePreference() } })
|
||||
|
||||
/** 按子画布和外框实际尺寸重建阶段摘要,折叠只隐藏内部节点,不改变共享业务图。 */
|
||||
function rebuild() {
|
||||
if (dragging.value) return
|
||||
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.connectable = !!node.data.stage && props.canManage }
|
||||
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 = graph.nodes; edges.value = graph.edges
|
||||
}
|
||||
@ -161,6 +165,32 @@ function createChildFromDrawer(id: number) { drawerStageId.value = null; createC
|
||||
function createInStage(stageId: number) { if (!props.canCreate || stageId !== 0 && !props.view.stages.some(stage => stage.id === stageId)) return; emit('create', stageId || null) }
|
||||
/** 回退入口使用后端当前阶段能力,待开始阶段也可进入;提交仍须通过项目锁内复验。 */
|
||||
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
|
||||
const blocked = stageRenameBlockedReason(stage)
|
||||
if (blocked) { failure.value = blocked; return }
|
||||
renamingStage.value = { ...stage }
|
||||
}
|
||||
/**
|
||||
* 删除真实空阶段前展示明确确认,取消不发请求;历史、子阶段和交付保护与管理表共用。
|
||||
* 确认期间暂停同步,提交仍携带原阶段版本;失败保留服务端节点并刷新最新原因。
|
||||
*/
|
||||
async function removeStage(stageId: number) {
|
||||
const stage = props.view.stages.find(row => row.id === stageId)
|
||||
if (!stage || !props.canManage || 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
|
||||
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') } }
|
||||
finally { busy.value = false }
|
||||
}
|
||||
/** 小地图复用当前版本的状态色,便于缩小时定位回退待重做阶段;主题切换由 CSS 变量即时响应。 */
|
||||
function minimapColor(node: GraphNode<FlowNodeData>) { return stageAppearance(node.data?.stage).accent }
|
||||
/**
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<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><strong :title="data.title">{{ data.title }}</strong><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></header>
|
||||
<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>
|
||||
<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>
|
||||
@ -14,16 +14,19 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { EditPen, Delete } from '@element-plus/icons-vue'
|
||||
import { Handle, Position } from '@vue-flow/core'
|
||||
import type { FlowNodeData } from '../utils/graph'
|
||||
import { stageAppearance } from '../utils/stageAppearance'
|
||||
import { stageNodeTypeLabel } from '../../../shared/constants/stageNodeTypes'
|
||||
import type { Stage } from '../../../types'
|
||||
import { plannedDate } from '../../../shared/utils/time'
|
||||
import { stageRenameBlockedReason } from '../../../features/stages/utils/actions'
|
||||
const props = defineProps<{ data: FlowNodeData }>()
|
||||
// 配色仅反映当前版本快照,后台静默同步状态后无需重载画布即可更新。
|
||||
const appearance = computed(() => stageAppearance(props.data.stage))
|
||||
const emit = defineEmits<{ view: [id: number]; create: [id: number]; rework: [id: number]; history: [id: number]; createChild: [id: number]; toggle: [id: number] }>()
|
||||
const renameBlockedReason = computed(() => props.data.stage ? stageRenameBlockedReason(props.data.stage) : '')
|
||||
const emit = defineEmits<{ view: [id: number]; create: [id: number]; rework: [id: number]; history: [id: number]; createChild: [id: number]; toggle: [id: number]; rename: [id: number]; remove: [id: number] }>()
|
||||
/** 节点仅展示阶段自身的预计日期;参考时间留在抽屉,避免混作本轮有效排期。 */
|
||||
function planLabel(stage: Stage): string {
|
||||
if (stage.scheduleReviewRequired) return stage.scheduleReviewClosed ? '本轮未确认排期' : '排期待复核'
|
||||
@ -33,8 +36,9 @@ function planLabel(stage: Stage): string {
|
||||
</script>
|
||||
<style scoped>
|
||||
.stage-type{flex:none;white-space:nowrap;font-size:10px;line-height:16px;padding:0 4px;border-radius:3px;color:var(--phase-accent);background:color-mix(in srgb,var(--phase-accent) 12%,var(--el-bg-color-overlay))}
|
||||
.stage-title{display:flex;align-items:center;gap:3px;min-width:0;flex:1}.stage-title strong{flex:0 1 auto}.node-action{display:inline-flex;align-items:center;justify-content:center;width:17px;height:20px;flex:none;padding:1px;border:0;border-radius:3px;background:transparent;color:var(--el-color-primary);cursor:pointer}.node-action svg{width:13px;height:13px}.node-action:hover:not(:disabled){background:var(--el-fill-color)}.node-action:disabled{color:var(--el-text-color-disabled);cursor:not-allowed}.node-delete{color:var(--el-color-danger)}
|
||||
.phase-group[class~="is-current"]{border-color:var(--el-color-primary)}.stage-current{font-size:10px;color:var(--el-color-primary);background:var(--el-color-primary-light-9);border-radius:3px;padding:1px 4px;white-space:nowrap;flex:none}
|
||||
.phase-group{width:100%;height:100%;background:var(--phase-background);border:1px solid var(--phase-border);border-radius:11px;color:var(--el-text-color-primary);cursor:pointer;box-sizing:border-box}.stage-drag{display:flex;align-items:center;gap:8px;padding:13px 14px 4px;cursor:grab}.stage-drag strong{font-size:13px;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.stage-version{font-size:11px;color:var(--el-text-color-secondary)}.phase-dot{width:8px;height:8px;border-radius:50%;background:var(--phase-accent);flex:none}
|
||||
.phase-group{width:100%;height:100%;background:var(--phase-background);border:1px solid var(--phase-border);border-radius:11px;color:var(--el-text-color-primary);cursor:pointer;box-sizing:border-box}.stage-drag{display:flex;align-items:center;gap:8px;padding:13px 14px 4px;cursor:grab}.stage-drag strong{font-size:13px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.stage-version{font-size:11px;color:var(--el-text-color-secondary)}.phase-dot{width:8px;height:8px;border-radius:50%;background:var(--phase-accent);flex:none}
|
||||
.phase-body{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:1px 14px 0}.stage-items{font-size:12px;font-weight:600;color:var(--el-color-primary)}.stage-status{font-size:11px;color:var(--el-text-color-regular);white-space:nowrap}.phase-actions{display:flex;align-items:center;gap:11px;padding:5px 14px}.stage-items,.phase-actions button{border:0;background:transparent;padding:0;cursor:pointer}.phase-actions button{color:var(--el-color-primary);font-size:11px;white-space:nowrap}
|
||||
.phase-plan{font-size:10px;padding:3px 14px 0;color:var(--el-text-color-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.phase-plan.warning{color:var(--el-color-warning)}
|
||||
.phase-description{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;white-space:pre-wrap;overflow-wrap:anywhere;font-size:11px;line-height:16px;height:32px;margin:3px 14px 6px;color:var(--el-text-color-regular)}.phase-description.empty{color:var(--el-text-color-placeholder)}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user