From 31fefeadb43a60eace560548115c36fcaac42003 Mon Sep 17 00:00:00 2001 From: zhanghao <774378400@qq.com> Date: Wed, 28 Oct 2026 17:34:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AF=BC=E5=87=BA=E7=94=98=E7=89=B9?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../composables/useProjectCollaboration.ts | 14 +- .../project/manage/views/gantt/WorkGantt.vue | 103 ++++++++----- .../gantt/composables/useGanttViewport.ts | 85 +++++++++++ .../manage/views/gantt/utils/exportData.ts | 41 ++++++ .../manage/views/gantt/utils/exportImage.ts | 135 ++++++++++++++++++ .../manage/views/gantt/utils/timeline.ts | 57 ++++++++ .../views/workspace/ProjectWorkspace.vue | 7 +- 7 files changed, 405 insertions(+), 37 deletions(-) create mode 100644 ruoyi-ui-vue3/src/views/project/manage/views/gantt/composables/useGanttViewport.ts create mode 100644 ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/exportData.ts create mode 100644 ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/exportImage.ts create mode 100644 ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/timeline.ts diff --git a/ruoyi-ui-vue3/src/views/project/manage/composables/useProjectCollaboration.ts b/ruoyi-ui-vue3/src/views/project/manage/composables/useProjectCollaboration.ts index ab3c9be..18623a6 100644 --- a/ruoyi-ui-vue3/src/views/project/manage/composables/useProjectCollaboration.ts +++ b/ruoyi-ui-vue3/src/views/project/manage/composables/useProjectCollaboration.ts @@ -4,6 +4,7 @@ import { ElMessage, ElMessageBox } from 'element-plus' import useUserStore from '@/store/modules/user' import { api, errorText, isAccessFailure } from '../api' import { plannedDate, planBoundary } from '../shared/utils/time' +import { typeNames } from '../shared/constants/labels' import { reconcileRows, retainSnapshot } from '../shared/utils/snapshot' import type { Project, Member, WorkItem, ItemType, Lifecycle, FlowView, Iteration, ItemQuery } from '../types' import { iterationReadOnly, iterationCanExecute } from '../features/iterations/utils/scope' @@ -169,6 +170,17 @@ export function useProjectCollaboration() { return { view, page: page.value, pageSize, keyword: keyword.value, type: typeFilter.value, blockedOnly: blockedOnly.value, stageId: stageFilter.value, ...(view === 'gantt' ? { from: ganttFrom.value, to: ganttTo.value, memberIds: [...ganttMemberIds.value] } : {}) } } + /** 导出沿用甘特的完整服务端筛选,但独立从第一页读取,翻页不改变导出范围。 */ + const ganttExportQuery = computed(() => ({ ...query('gantt'), page: 1, pageSize: 200 })) + /** 文件中记录本次筛选含义,成员多选仍按负责人或协作人命中任一成员计算。 */ + const ganttExportFilters = computed(() => [ + keyword.value.trim() ? `标题:${keyword.value.trim()}` : '', + typeFilter.value ? `类型:${typeNames[typeFilter.value]}` : '全部类型', + blockedOnly.value ? '仅看依赖阻塞' : '', + stageFilter.value == null ? '全部阶段' : stageFilter.value === 0 ? '未分配阶段' : `阶段:${flowView.value?.stages.find(stage => stage.id === stageFilter.value)?.stagePath || flowView.value?.stages.find(stage => stage.id === stageFilter.value)?.name || stageFilter.value}`, + ganttMemberIds.value.length ? `成员:${ganttMemberIds.value.map(id => members.value.find(member => member.userId === id)?.name || `用户 #${id}`).join('、')}` : '全部成员', + ].filter(Boolean).join(';')) + /** 用户主动刷新或业务操作完成时显示加载状态;独立包装避免分页事件的页码被当作后台标志。 */ async function refresh() { await refreshData(false) @@ -613,7 +625,7 @@ export function useProjectCollaboration() { items, members, flowView, current, selectedIteration, zone, canWrite, canCreate, canExecute, loading, failure, tab, keyword, typeFilter, blockedOnly, stageFilter, detailId, refreshKey, selection, editing, editorOpen, creatingParent, defaultStageId, page, pageSize, total, boardCounts, - ganttFrom, ganttTo, ganttMemberIds, membersOpen, inviteUser, inviteRole, userCandidates, batchOpen, + ganttFrom, ganttTo, ganttMemberIds, ganttExportQuery, ganttExportFilters, membersOpen, inviteUser, inviteRole, userCandidates, batchOpen, notifications, statCards, userStore, refreshWorkspace, refresh, loadBoardMore, moveGanttWindow, changeIteration, iterationsChanged, archiveFilterChanged, openNotice, diff --git a/ruoyi-ui-vue3/src/views/project/manage/views/gantt/WorkGantt.vue b/ruoyi-ui-vue3/src/views/project/manage/views/gantt/WorkGantt.vue index 20906e4..562dc1b 100644 --- a/ruoyi-ui-vue3/src/views/project/manage/views/gantt/WorkGantt.vue +++ b/ruoyi-ui-vue3/src/views/project/manage/views/gantt/WorkGantt.vue @@ -1,8 +1,16 @@ diff --git a/ruoyi-ui-vue3/src/views/project/manage/views/gantt/composables/useGanttViewport.ts b/ruoyi-ui-vue3/src/views/project/manage/views/gantt/composables/useGanttViewport.ts new file mode 100644 index 0000000..9288d8f --- /dev/null +++ b/ruoyi-ui-vue3/src/views/project/manage/views/gantt/composables/useGanttViewport.ts @@ -0,0 +1,85 @@ +import { nextTick, onActivated, onBeforeUnmount, onDeactivated, onMounted, ref, type Ref } from 'vue' + +/** + * 根据滚动区真实位置分配高度,避免顶部换行、页面缩放和系统页签高度变化遮住横向滚动条。 + * @param element 甘特唯一的双向滚动容器 + * @returns 最大可用高度;内容较少时仍自然收缩,不改变滚动位置 + * 只监听当前工作区,尺寸回调通过一帧合并;卸载时释放全部监听及观察器。 + */ +export function useGanttViewport(element: Ref) { + const maxHeight = ref(320) + let observer: ResizeObserver | undefined, mutations: MutationObserver | undefined, frame = 0, disposed = false, active = true + let host: HTMLElement | null = null + + /** 统一使用可视坐标,CSS 缩放时转换回布局像素;分页、容器边距与系统页脚均留在滚动区外。 */ + function measure() { + frame = 0 + const scroll = element.value + if (!scroll || disposed || !active) return + const rect = scroll.getBoundingClientRect() + if (!rect.width || !scroll.offsetWidth) return + const scale = rect.width / scroll.offsetWidth + const viewport = window.visualViewport + let bottom = viewport ? viewport.offsetTop + viewport.height : window.innerHeight + if (host) { + const bounds = host.getBoundingClientRect(), style = getComputedStyle(host) + bottom = Math.min(bottom, bounds.top + host.clientHeight * scale - (parseFloat(style.paddingBottom) || 0) * scale) + } + const surface = scroll.closest('.work-surface') + const pagination = surface?.querySelector('.work-pagination') + const footer = pagination ? pagination.getBoundingClientRect().height / scale + (parseFloat(getComputedStyle(pagination).marginTop) || 0) : 0 + const height = Math.max(80, Math.floor((bottom - Math.max(0, rect.top)) / scale - footer - 20)) + if (height !== maxHeight.value) maxHeight.value = height + } + + /** 尺寸及外层滚动事件可能同帧触发多次,只安排一次测量,避免 ResizeObserver 内同步写布局。 */ + function scheduleMeasure() { + if (active && !disposed && !frame) frame = window.requestAnimationFrame(measure) + } + + /** + * 页面有 min-height 时,筛选换行可能只挤占留白,整页尺寸不变;因此也观察前置兄弟和甘特提示区。 + * 直接子节点增删后重建目标集合,避免错误提示或分页新出现时继续沿用旧位置。 + */ + function observeLayout() { + const scroll = element.value, workspace = scroll?.closest('.pm-app') + if (!observer || !scroll) return + observer.disconnect() + for (const target of new Set([host, workspace, scroll.parentElement, ...(workspace?.children || [])])) { + if (target) observer.observe(target) + } + scheduleMeasure() + } + + onMounted(() => { + host = element.value?.closest('.app-main') || null + void nextTick(scheduleMeasure) + window.addEventListener('resize', scheduleMeasure) + host?.addEventListener('scroll', scheduleMeasure, { passive: true }) + window.visualViewport?.addEventListener('resize', scheduleMeasure) + window.visualViewport?.addEventListener('scroll', scheduleMeasure) + if (typeof ResizeObserver !== 'undefined' && element.value) { + observer = new ResizeObserver(scheduleMeasure) + observeLayout() + const workspace = element.value.closest('.pm-app') + if (workspace && typeof MutationObserver !== 'undefined') { + mutations = new MutationObserver(observeLayout) + mutations.observe(workspace, { childList: true }) + } + } + }) + // KeepAlive 停用期间不计算脱离页面的尺寸;返回后即使外层尺寸未变化也重新测量。 + onActivated(() => { active = true; void nextTick(scheduleMeasure) }) + onDeactivated(() => { active = false; window.cancelAnimationFrame(frame); frame = 0 }) + onBeforeUnmount(() => { + disposed = true + observer?.disconnect() + mutations?.disconnect() + window.cancelAnimationFrame(frame) + window.removeEventListener('resize', scheduleMeasure) + host?.removeEventListener('scroll', scheduleMeasure) + window.visualViewport?.removeEventListener('resize', scheduleMeasure) + window.visualViewport?.removeEventListener('scroll', scheduleMeasure) + }) + return maxHeight +} diff --git a/ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/exportData.ts b/ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/exportData.ts new file mode 100644 index 0000000..98a6fc2 --- /dev/null +++ b/ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/exportData.ts @@ -0,0 +1,41 @@ +import { api } from '../../../api' +import type { ItemQuery, WorkItem } from '../../../types' + +/** + * 读取当前筛选的全部分页,不把页面当前页误当作完整甘特图。 + * @param projectId 已选协作项目,所有请求继续经过原鉴权接口 + * @param iterationId 已选迭代,不跨迭代汇总 + * @param query 本次点击时的筛选快照,页码由导出独立管理 + * @param isCurrent 页面、迭代或筛选变化后返回 false,停止续页及文件生成 + * @returns 图版本一致的阶段与工作项;读取失败或版本变化时整次失败,不交付部分结果 + */ +export async function collectGanttData(projectId: number, iterationId: number, query: ItemQuery, isCurrent: () => boolean) { + const filter = { ...query, memberIds: [...(query.memberIds || [])], view: 'gantt' as const } + checkScope() + const graph = await api.flowView(projectId, iterationId) + checkScope() + const items: WorkItem[] = [], ids = new Set() + let total = 0 + for (let page = 1; ; page++) { + checkScope() + const result = await api.items(projectId, iterationId, { ...filter, page, pageSize: 200 }) + checkScope() + if (result.graphVersion !== graph.graphVersion || page > 1 && result.total !== total) throw new Error('导出期间排期数据发生变化,请重新导出') + total = result.total + if (total > 10000) throw new Error('匹配工作项超过 10000 项,请缩小时间或筛选范围后导出') + for (const item of result.rows) { + if (ids.has(item.id)) throw new Error('导出期间分页数据发生变化,请重新导出') + ids.add(item.id); items.push(item) + } + if (items.length === total) break + if (!result.rows.length || items.length > total) throw new Error('导出数据不完整,请刷新后重试') + } + // 最后一页完成后再走一次鉴权与图版本检查;不把两次修改前后的分页拼成一张图。 + const latest = await api.items(projectId, iterationId, { ...filter, page: 1, pageSize: 1 }) + checkScope() + if (latest.graphVersion !== graph.graphVersion || latest.total !== total) throw new Error('导出期间排期数据发生变化,请重新导出') + return { items, stages: graph.stages } + + /** 即使切走后又返回相同迭代,调用方的代次检查也会使旧导出失效。 */ + function checkScope() { if (!isCurrent()) throw new Error('导出范围已切换') } +} diff --git a/ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/exportImage.ts b/ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/exportImage.ts new file mode 100644 index 0000000..3704155 --- /dev/null +++ b/ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/exportImage.ts @@ -0,0 +1,135 @@ +import { itemStatusLabel, stageStatusLabel, typeNames } from '../../../shared/constants/labels' +import { plannedDate, visualMillis } from '../../../shared/utils/time' +import type { TimelineRow } from './timeline' + +export type GanttExportFormat = 'png' | 'svg' +export interface GanttImage { svg: string; width: number; height: number } +interface ImageInput { + rows: TimelineRow[] + minimum: number + days: number + zone: string + projectName: string + iterationName: string + filters: string +} + +/** 用户名称仅作为 SVG 文本,移除 XML 禁止字符并转义标记,不能产生脚本、链接或外部资源引用。 */ +function xml(value: string): string { + return value.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\ufffe\uffff]/g, '').replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char]!) +} + +/** 按中英文近似字宽拆行,不省略长名称;行高随拆行增长,导出不依赖屏幕上的省略号或裁切。 */ +function wrap(value: string, units: number): string[] { + const lines: string[] = [] + let line = '', length = 0 + for (const char of value.replace(/\s+/g, ' ')) { + const size = char.charCodeAt(0) > 255 ? 2 : 1 + if (length + size > units && line) { lines.push(line); line = ''; length = 0 } + line += char; length += size + } + lines.push(line) + return lines +} + +/** SVG 基础文本保持固定字体和浅色底,导出不受用户暗黑主题影响;所有可变内容先转义。 */ +function text(x: number, y: number, value: string, size = 12, color = '#334155', weight = 400): string { + return `${xml(value)}` +} + +/** + * 从完整业务行生成独立矢量甘特,不截取 DOM,因此屏幕滚动、分页与设备像素比不会截断文件。 + * @param input 导出瞬间固定的标题、筛选、日期轴和完整行,预计日期仍按业务时区显示 + * @returns 不依赖外部字体、样式和图片的 SVG 及逻辑尺寸;参考计划仅作虚线标识 + */ +export function createGanttImage(input: ImageInput): GanttImage { + const { rows, minimum, days, zone } = input + const unit = 34, dayMs = 86400000, padding = 16, labelWidth = 370, statusWidth = 130 + const timelineX = padding + labelWidth + statusWidth, timelineWidth = days * unit, width = timelineX + timelineWidth + padding + const titleLines = wrap(`${input.projectName} / ${input.iterationName} · 甘特排期`, Math.floor((width - 32) / 11)) + const filters = wrap(`筛选:${input.filters || '全部'};工作项 ${rows.filter(row => row.item).length} 项`, Math.floor((width - 32) / 7)) + const layout = rows.map(row => { + const prefix = row.stage ? `${row.stage.stageKind === 'GROUP' ? '阶段组' : '阶段'} · ` : `${row.item?.parentTaskId ? '子任务' : typeNames[row.item!.type]} #${row.item!.id} · ` + const name = prefix + row.label + (row.stage ? ` · v${row.stage.revisionNo || 1}` : '') + const indent = Math.min(row.depth || 0, 8) * 16 + const lines = wrap(name, Math.floor((labelWidth - indent - 20) / 7)) + return { row, name, indent, lines, height: Math.max(74, lines.length * 18 + 50) } + }) + const headerTop = 78 + titleLines.length * 26 + filters.length * 18 + const bodyTop = headerTop + 34, height = bodyTop + layout.reduce((sum, row) => sum + row.height, 0) + 24 + const output = [`${xml(`${input.projectName} / ${input.iterationName} 甘特排期`)}`] + titleLines.forEach((line, i) => output.push(text(padding, 30 + i * 26, line, 20, '#0f172a', 600))) + let y = 38 + titleLines.length * 26 + output.push(text(padding, y, `日期:${plannedDate(new Date(minimum).toISOString(), zone)} — ${plannedDate(new Date(minimum + days * dayMs - 1).toISOString(), zone)}`)) + filters.forEach((line, i) => output.push(text(padding, y + 22 + i * 18, line))) + output.push(text(padding, headerTop - 12, '蓝色:有效计划 橙色:前置阻塞 虚线:参考计划(未生效)', 11, '#64748b')) + output.push(``, text(padding + 8, headerTop + 22, '阶段 / 工作项 · 日期 · 负责人', 12, '#334155', 600), text(padding + labelWidth + 8, headerTop + 22, '状态', 12, '#334155', 600)) + for (let day = 0; day < days; day++) output.push(text(timelineX + day * unit + 2, headerTop + 22, plannedDate(new Date(minimum + day * dayMs).toISOString(), zone).slice(5), 10)) + y = bodyTop + for (const entry of layout) { + const { row, height: rowHeight, indent, lines, name } = entry + const source = (row.stage || row.item)!, reference = row.reference && !!row.start && !!row.end + const date = reference ? `参考:${plannedDate(row.start, zone)} → ${plannedDate(row.end, zone)}` : `${plannedDate(source.plannedStartAt, zone)} → ${plannedDate(source.plannedEndAt, zone)}` + output.push(`${xml(name)}`) + lines.forEach((line, index) => output.push(text(padding + 8 + indent, y + 19 + index * 18, line, 12, '#0f172a', row.stage ? 600 : 400))) + output.push(text(padding + 8 + indent, y + lines.length * 18 + 19, date, 11, reference ? '#b45309' : '#64748b')) + output.push(text(padding + 8 + indent, y + lines.length * 18 + 35, `负责人:${row.stage?.ownerName || row.item?.assigneeName || '未分配'}`, 11, '#64748b')) + const status = row.stage ? stageStatusLabel(row.stage) : itemStatusLabel(row.item!) + wrap(status, 16).forEach((line, index) => output.push(text(padding + labelWidth + 8, y + 23 + index * 18, line))) + if (reference) output.push(text(padding + labelWidth + 8, y + 46, source.scheduleReviewClosed ? '本轮未确认' : '排期待复核', 11, '#b45309')) + else if (!row.start || !row.end) output.push(text(padding + labelWidth + 8, y + 46, '排期未完成', 11, '#b45309')) + output.push(``) + if (row.start && row.end) { + // 只裁切时间条到当前日期窗口;左侧日期保持完整,不能改写或截断源排期。 + const startAt = visualMillis(row.start), endAt = visualMillis(row.end) + if (endAt >= minimum && startAt < minimum + days * dayMs && endAt >= startAt) { + const start = Math.min(timelineWidth - 1, Math.max(0, (startAt - minimum) / dayMs * unit)) + const end = Math.min(timelineWidth, (endAt - minimum) / dayMs * unit) + // 既有计划允许起止相等或相差不足毫秒;这些窗口内区间仍有标记,不能被当作窗口外计划丢弃。 + output.push(``) + } + } + output.push(``) + y += rowHeight + } + output.push('') + return { svg: output.join(''), width, height } +} + +/** PNG 尽量使用双倍像素;超过保守画布边长或总像素限制时明确拒绝,避免下载空白图或浏览器耗尽内存。 */ +export function pngScale(width: number, height: number): number { + const scale = Math.min(2, 8192 / width, 16384 / height, Math.sqrt(24_000_000 / (width * height))) + if (!Number.isFinite(scale) || scale < 1) throw new Error('当前甘特图过大,请选择 SVG 矢量图,或缩小时间和筛选范围后导出 PNG') + return scale +} + +/** + * SVG 直接下载;PNG 将同一份无外链 SVG 绘制到画布,确保两种格式具有相同内容。 + * @param image 已完成排版的独立图像 + * @param format 用户选择的图片格式 + * @returns 可下载文件;浏览器解码或编码失败时抛错,临时 URL 和画布像素始终释放 + */ +export async function ganttImageBlob(image: GanttImage, format: GanttExportFormat): Promise { + const svg = new Blob([image.svg], { type: 'image/svg+xml;charset=utf-8' }) + if (format === 'svg') return svg + const scale = pngScale(image.width, image.height), url = URL.createObjectURL(svg), canvas = document.createElement('canvas') + try { + const bitmap = new Image() + await new Promise((resolve, reject) => { bitmap.onload = () => resolve(); bitmap.onerror = () => reject(new Error('图片生成失败,请尝试 SVG 格式')); bitmap.src = url }) + canvas.width = Math.ceil(image.width * scale); canvas.height = Math.ceil(image.height * scale) + const context = canvas.getContext('2d') + if (!context) throw new Error('浏览器无法生成 PNG,请选择 SVG 格式') + context.drawImage(bitmap, 0, 0, canvas.width, canvas.height) + return await new Promise((resolve, reject) => canvas.toBlob(blob => blob ? resolve(blob) : reject(new Error('PNG 编码失败,请选择 SVG 格式')), 'image/png')) + } finally { URL.revokeObjectURL(url); canvas.width = 0; canvas.height = 0 } +} + +/** 文件名不携带路径或控制字符;点击后延迟释放 URL,给浏览器下载进程保留读取时间。 */ +export function downloadGanttImage(blob: Blob, name: string, format: GanttExportFormat): void { + const url = URL.createObjectURL(blob), anchor = document.createElement('a') + anchor.href = url + anchor.download = `${name.replace(/[<>:"/\\|?*\u0000-\u001f]/g, '_').slice(0, 140) || '甘特排期'}.${format}` + document.body.append(anchor) + try { anchor.click() } + finally { anchor.remove(); window.setTimeout(() => URL.revokeObjectURL(url), 10000) } +} diff --git a/ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/timeline.ts b/ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/timeline.ts new file mode 100644 index 0000000..a4a5ce6 --- /dev/null +++ b/ruoyi-ui-vue3/src/views/project/manage/views/gantt/utils/timeline.ts @@ -0,0 +1,57 @@ +import type { Stage, WorkItem } from '../../../types' + +export interface TimelineRow { + key: string + label: string + depth?: number + item?: WorkItem + stage?: Stage + start: string | null + end: string | null + reference: boolean +} + +/** 有效时间优先,参考时间必须作为整对使用;不把有效端点与参考端点拼成看似有效的计划。 */ +function timelineRow(key: string, label: string, source: Stage | WorkItem, stage: boolean): TimelineRow { + const normal = !!source.plannedStartAt && !!source.plannedEndAt + return { key, label, stage: stage ? source as Stage : undefined, item: stage ? undefined : source as WorkItem, start: normal ? source.plannedStartAt : source.referencePlannedStartAt || null, end: normal ? source.plannedEndAt : source.referencePlannedEndAt || null, reference: !normal } +} + +/** 不完整任务在界面顶部保留入口;只有完整有效或参考区间才绘制时间条。 */ +function hasRange(item: WorkItem) { + return !!(item.plannedStartAt && item.plannedEndAt || item.referencePlannedStartAt && item.referencePlannedEndAt) +} + +/** + * 屏幕与导出共用阶段层级和工作项顺序,成员筛选保留所属阶段的父路径。 + * @param items 已由服务端按当前筛选和权限过滤的工作项,不在此扩大查询范围 + * @param stages 当前迭代阶段摘要,组计划采用自身计划,不用子阶段包络代替 + * @param memberFiltered 是否只展示匹配成员所在的阶段 + * @param stageFilter 指定阶段或阶段组,0 表示未分配阶段 + * @param includeUnscheduled 导出时将未排期项纳入对应阶段,界面仍使用顶部未排期入口 + * @returns 不修改源数据的有序行,每个工作项最多出现一次 + */ +export function buildTimelineRows(items: WorkItem[], stages: Stage[], memberFiltered = false, stageFilter?: number | null, includeUnscheduled = false): TimelineRow[] { + const result: TimelineRow[] = [], known = new Set(stages.map(stage => stage.id)) + const visible = new Set(items.map(item => item.stageId).filter((id): id is number => !!id)) + if (stageFilter && !memberFiltered) { + visible.add(stageFilter) + for (const child of stages.filter(stage => stage.parentStageId === stageFilter)) visible.add(child.id) + } + for (const stage of stages) if (visible.has(stage.id) && stage.parentStageId) visible.add(stage.parentStageId) + for (const root of stages.filter(stage => !stage.parentStageId)) append(root, 0) + for (const item of items.filter(item => !item.stageId || !known.has(item.stageId))) { + if (includeUnscheduled || hasRange(item)) result.push(timelineRow('i:' + item.id, item.title, item, false)) + } + return result + + /** 父级先于子级展示,层级仅用于显示,不改变后端阶段门禁或改期入口。 */ + function append(stage: Stage, depth: number) { + if ((memberFiltered || stageFilter != null) && !visible.has(stage.id)) return + result.push({ ...timelineRow('s:' + stage.id, stage.name, stage, true), depth }) + for (const child of stages.filter(candidate => candidate.parentStageId === stage.id)) append(child, depth + 1) + for (const item of items.filter(item => item.stageId === stage.id)) { + if (includeUnscheduled || hasRange(item)) result.push({ ...timelineRow('i:' + item.id, item.title, item, false), depth: depth + 1 + (item.parentTaskId ? 1 : 0) }) + } + } +} diff --git a/ruoyi-ui-vue3/src/views/project/manage/views/workspace/ProjectWorkspace.vue b/ruoyi-ui-vue3/src/views/project/manage/views/workspace/ProjectWorkspace.vue index eba65a2..5457726 100644 --- a/ruoyi-ui-vue3/src/views/project/manage/views/workspace/ProjectWorkspace.vue +++ b/ruoyi-ui-vue3/src/views/project/manage/views/workspace/ProjectWorkspace.vue @@ -178,6 +178,11 @@ :to="ganttTo" :member-filtered="ganttMemberIds.length > 0" :stage-filter="stageFilter" + :export-query="ganttExportQuery" + :export-filters="ganttExportFilters" + :project-name="current.name" + :iteration-name="selectedIteration.name" + :loading="loading" :can-write="canWrite" :can-manage="canWrite && current.canManage" :project-id="current.id" @@ -299,7 +304,7 @@ const { items, members, flowView, current, selectedIteration, zone, canWrite, canCreate, canExecute, loading, failure, tab, keyword, typeFilter, blockedOnly, stageFilter, detailId, refreshKey, selection, editing, editorOpen, creatingParent, defaultStageId, page, pageSize, total, boardCounts, - ganttFrom, ganttTo, ganttMemberIds, membersOpen, inviteUser, inviteRole, userCandidates, batchOpen, + ganttFrom, ganttTo, ganttMemberIds, ganttExportQuery, ganttExportFilters, membersOpen, inviteUser, inviteRole, userCandidates, batchOpen, notifications, statCards, userStore, refreshWorkspace, refresh, loadBoardMore, moveGanttWindow, changeIteration, iterationsChanged, archiveFilterChanged, openNotice,