fix(产品需求): 修复需求树的序号展示问题。
This commit is contained in:
@@ -147,6 +147,17 @@ function getPriorityTagType(priority?: number | null): UI.ThemeColor {
|
|||||||
return priorityTagTypeMap[priority] || 'info';
|
return priorityTagTypeMap[priority] || 'info';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function flattenTree(nodes: Api.Product.Requirement[]): Api.Product.Requirement[] {
|
||||||
|
const result: Api.Product.Requirement[] = [];
|
||||||
|
for (const node of nodes) {
|
||||||
|
result.push(node);
|
||||||
|
if (node.children?.length) {
|
||||||
|
result.push(...flattenTree(node.children));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
function collectAllRequirementIds(nodes: Api.Product.Requirement[]): string[] {
|
function collectAllRequirementIds(nodes: Api.Product.Requirement[]): string[] {
|
||||||
const ids: string[] = [];
|
const ids: string[] = [];
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
@@ -186,11 +197,25 @@ function getRowActions(row: Api.Product.Requirement): Api.Product.RequirementLif
|
|||||||
}
|
}
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{ prop: 'index', type: 'index', label: '序号', width: 64 },
|
{
|
||||||
|
type: 'index',
|
||||||
|
label: '序号',
|
||||||
|
width: 64,
|
||||||
|
align: 'center',
|
||||||
|
index: (index: number): number => {
|
||||||
|
const flatList = flattenTree(treeData.value);
|
||||||
|
const row = flatList[index];
|
||||||
|
if (!row || row.parentId !== '0') {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const parentIndex = treeData.value.findIndex(item => item.id === row.id);
|
||||||
|
return parentIndex >= 0 ? (pagination.pageNo - 1) * pagination.pageSize + parentIndex + 1 : 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
prop: 'title',
|
prop: 'title',
|
||||||
label: '标题',
|
label: '标题',
|
||||||
minWidth: 220,
|
minWidth: 200,
|
||||||
formatter: (row: Api.Product.Requirement) => {
|
formatter: (row: Api.Product.Requirement) => {
|
||||||
const isTerminal = isTerminalStatus(row.statusCode);
|
const isTerminal = isTerminalStatus(row.statusCode);
|
||||||
const className = 'requirement-title';
|
const className = 'requirement-title';
|
||||||
@@ -625,13 +650,15 @@ watch(
|
|||||||
<ElTable
|
<ElTable
|
||||||
ref="requirementTableRef"
|
ref="requirementTableRef"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
height="100%"
|
|
||||||
border
|
border
|
||||||
|
lazy
|
||||||
row-key="id"
|
row-key="id"
|
||||||
|
:indent="32"
|
||||||
|
height="100%"
|
||||||
:data="treeData"
|
:data="treeData"
|
||||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||||
>
|
>
|
||||||
<ElTableColumn v-for="col in columns" :key="String(col.prop)" v-bind="col" />
|
<ElTableColumn v-for="col in columns" :key="String(col.prop || 'index')" v-bind="col" />
|
||||||
|
|
||||||
<template #empty>
|
<template #empty>
|
||||||
<ElEmpty description="当前模块下暂无需求" />
|
<ElEmpty description="当前模块下暂无需求" />
|
||||||
@@ -714,4 +741,8 @@ watch(
|
|||||||
:deep(.requirement-source-link) {
|
:deep(.requirement-source-link) {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.el-table__row[class*='el-table__row--level-']:not(.el-table__row--level-0) td:first-child .cell) {
|
||||||
|
color: transparent;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user