feat(报表分析): 新增签署总览等四个报表菜单并拆分演示数据开关

This commit is contained in:
yelan
2026-09-24 21:03:39 +08:00
parent abe7e17582
commit 78402859fd
26 changed files with 3618 additions and 193 deletions
@@ -4,14 +4,13 @@ import { ElMessage } from 'element-plus'
import { getCampuses, getDepartments } from '@/api/management/organization'
import { downloadSigningArtifact, getSigningArtifacts } from '@/api/workbench/artifacts'
import { mockCatalogCategories, mockCatalogDepartments } from '@/api/workbench/mock-catalog'
import {
getAllSigningRecords,
getSigningRecordDetail,
getSigningRecordEvents,
getSigningRecords,
isSigningRecordsMockEnabled,
mockRecordCategories,
mockRecordDepartments,
} from '@/api/workbench/records'
import type {
SigningApiOptions,
@@ -22,6 +21,7 @@ import type {
} from '@/api/workbench/types'
import { useAppStore } from '@/stores/app'
import { useLoginStore } from '@/stores/login'
import { downloadCsv, fileStamp, saveBlob } from '@/utils/csv-export'
import { downloadSigningPdf } from '@/utils/signing-pdf'
import SigningRecordDetailDialog from './components/SigningRecordDetailDialog.vue'
@@ -143,7 +143,7 @@ const methodOptions: SigningRecordFilterOption<SigningMethod | 'all'>[] = [
* 不用「当前页出现过的科室」——翻页会换掉可选项,筛完再想换一个科室就找不到了。
*/
const departmentOptions = computed<SigningRecordFilterOption[]>(() => {
const names = isSigningRecordsMockEnabled ? mockRecordDepartments : departmentNames.value
const names = isSigningRecordsMockEnabled ? mockCatalogDepartments : departmentNames.value
return [
{ label: '全部科室', value: '' },
...names.map((name) => ({ label: name, value: name })),
@@ -153,7 +153,7 @@ const departmentOptions = computed<SigningRecordFilterOption[]>(() => {
const categoryOptions = computed<SigningRecordFilterOption[]>(() => {
// 真实模式下后端签署任务接口不支持按类别检索,这里给不出可选项,由筛选条禁用该字段
const categories = isSigningRecordsMockEnabled
? mockRecordCategories
? mockCatalogCategories
: [...new Set(rows.value.map((row) => row.category).filter(Boolean))]
return [
@@ -309,16 +309,6 @@ function closeRecord() {
detailEvents.value = []
}
function saveBlob(blob: Blob, fileName: string) {
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = fileName
link.click()
window.setTimeout(() => URL.revokeObjectURL(url), 0)
}
async function handleDownloadPdf() {
const record = detailRecord.value
@@ -370,10 +360,6 @@ async function handleDownloadPdf() {
}
}
function escapeCsvField(value: string) {
return /[",\n\r]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value
}
/**
* 导出当前筛选条件下的全部记录。
*
@@ -405,25 +391,7 @@ async function handleExport() {
return
}
const lines = [
EXPORT_COLUMNS.map((column) => escapeCsvField(column.label)).join(','),
...records.map((record) =>
EXPORT_COLUMNS.map((column) => escapeCsvField(column.value(record))).join(','),
),
]
const now = new Date()
const stamp = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(
now.getDate(),
).padStart(2, '0')}${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(
2,
'0',
)}`
// 带 BOM:Excel 直接打开 UTF-8 CSV 才不会把中文显示成乱码
saveBlob(
new Blob([`\uFEFF${lines.join('\r\n')}`], { type: 'text/csv;charset=utf-8' }),
`签署记录_${stamp}.csv`,
)
downloadCsv(EXPORT_COLUMNS, records, `签署记录_${fileStamp()}.csv`)
ElMessage.success(`已导出 ${records.length} 条签署记录`)
} catch {
ElMessage.error('导出失败,请稍后重试')