feat: 优化
This commit is contained in:
parent
84f0efecba
commit
642d88d9a1
@ -4,12 +4,12 @@
|
||||
<el-alert title="从左侧节点库拖入阶段并连线确定顺序;交付齐备后须经阶段创建人审批,才放行后续。阶段组聚合子阶段结果;采购按批次验收人工确认。" type="info" :closable="false" />
|
||||
<el-button v-if="iterationId && view" 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"><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="阶段" 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="完成" width="80"><template #default="{ row }">{{ row.complete ? '已完成' : '未完成' }}</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="row.childStageCount ? '请先移出或删除组内子阶段' : row.deliveryAttachmentCount ? '请先移除本轮交付附件' : row.purchaseBatchCount ? '请先清空采购批次范围' : '请先移动阶段中的工作项'" :disabled="!row.counts.total && !row.childStageCount && !row.deliveryAttachmentCount && !row.purchaseBatchCount"><span><el-button size="small" link type="danger" :disabled="!!row.counts.total || !!row.childStageCount || !!row.deliveryAttachmentCount || !!row.purchaseBatchCount || 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.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>
|
||||
@ -36,6 +36,7 @@ import StageStructureDialog from './StageStructureDialog.vue'
|
||||
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'
|
||||
const props = defineProps<{ visible: boolean; projectId: number; iterationId?: number; stages: Stage[]; members: Member[]; view?: FlowView }>()
|
||||
const emit = defineEmits<{ close: []; changed: [] }>()
|
||||
const structureOpen = ref(false)
|
||||
@ -54,10 +55,35 @@ 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 } }
|
||||
/** 经产品内确认软删除空阶段,后端仍在项目锁内重查是否为空。 */
|
||||
async function remove(stage: Stage) { 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 } }
|
||||
/**
|
||||
* 根据服务端的历史与当前执行状态判断是否曾执行,不把回退后的新版本误当作全新阶段。
|
||||
* @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 ''
|
||||
}
|
||||
/** 发起确认前重新检查当前摘要,只对可删除空阶段提交;后端继续在项目锁内验证历史与版本。 */
|
||||
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 } }
|
||||
</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}
|
||||
.stage-status{display:flex;align-items:center;gap:5px;flex-wrap:wrap}
|
||||
/* 组件 DOM 和状态类由运行时生成;按 class token 匹配保持原选择器的含义和优先级,避免 IDE 静态模板匹配误报。 */
|
||||
:deep([class~="el-select"]){width:100%}</style>
|
||||
|
||||
@ -39,6 +39,8 @@ export interface Stage extends StageSummary, Omit<StageSchedule, 'plannedStartAt
|
||||
canCreateWorkItem?: boolean
|
||||
canCreateChildStage?: boolean
|
||||
canEditStructure?: boolean
|
||||
/** 全版本执行历史;旧接口的 MySQL EXISTS 可能返回 0/1,不能用当前工作项数量推断。 */
|
||||
executionHistory?: boolean | 0 | 1
|
||||
subtreeScheduleValidationStatus?: 'VALID' | 'INCOMPLETE' | 'CONFLICT'
|
||||
|
||||
id: number
|
||||
|
||||
Loading…
Reference in New Issue
Block a user