aegon-lv82 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -0
- package/src/App.vue +44 -0
- package/src/api/index.ts +19 -0
- package/src/api/modules/build-report/reportEditor.ts +526 -0
- package/src/api/modules/build-report/reportPermission.ts +64 -0
- package/src/api/modules/index.ts +69 -0
- package/src/api/modules/industry/green_mortgage.ts +42 -0
- package/src/api/modules/user/index.ts +4 -0
- package/src/api/request.ts +124 -0
- package/src/assets/sample-access-icon.png +0 -0
- package/src/assets/sample-pie-chart.png +0 -0
- package/src/assets/vue.svg +1 -0
- package/src/components/CapsuleScrollbar.vue +7 -0
- package/src/components/Export/ExcelExport.vue +592 -0
- package/src/components/Export/ExcelExport2.vue +494 -0
- package/src/components/Export/ExcelExport3.vue +342 -0
- package/src/components/Export/ExcelExport4.vue +665 -0
- package/src/components/Export/excelExport.js +547 -0
- package/src/components/Export/excelExport.ts +551 -0
- package/src/components/GEN-AI/index.vue +140 -0
- package/src/components/GEN-AI/index1.vue +422 -0
- package/src/components/GEN-AI/index10.vue +5 -0
- package/src/components/GEN-AI/index2.vue +548 -0
- package/src/components/GEN-AI/index3.vue +605 -0
- package/src/components/GEN-AI/index4.vue +609 -0
- package/src/components/GEN-AI/index5.vue +558 -0
- package/src/components/GEN-AI/index6.vue +634 -0
- package/src/components/GEN-AI/index7.vue +688 -0
- package/src/components/GEN-AI/index8.vue +458 -0
- package/src/components/GEN-AI/index9.vue +1217 -0
- package/src/components/GEN-AI/types.ts +12 -0
- package/src/components/GEN-AI/utils.ts +42 -0
- package/src/components/HelloWorld.vue +41 -0
- package/src/components/PageCard.vue +124 -0
- package/src/components/PageHeader.vue +32 -0
- package/src/components/backup/index5 copy.vue +556 -0
- package/src/components/backup/index5.vue +620 -0
- package/src/components/backup/index9 copy.vue +1029 -0
- package/src/components/backup/index9-pro.vue +1065 -0
- package/src/components/backup/index9.vue +1057 -0
- package/src/directives/btnLoading.ts +455 -0
- package/src/directives/debounce copy.ts +670 -0
- package/src/directives/debounce.ts +98 -0
- package/src/directives/index.ts +25 -0
- package/src/layouts/MainLayout.vue +129 -0
- package/src/main.ts +76 -0
- package/src/router/index.ts +142 -0
- package/src/router/menus.ts +28 -0
- package/src/store/modules/gen-ai/index.ts +1 -0
- package/src/store/modules/gen-ai/reportBuild.ts +37 -0
- package/src/style.css +79 -0
- package/src/styles/report-config-popover.css +39 -0
- package/src/styles/report-icon-btn.css +19 -0
- package/src/test/mock.ts +101 -0
- package/src/test/test1.vue +402 -0
- package/src/test/test2.vue +1689 -0
- package/src/types/gen-ai/build-report/reportEditor.ts +684 -0
- package/src/utils/function.ts +46 -0
- package/src/utils/gen-ai-navigation.ts +1 -0
- package/src/utils/gen-ai-scroll.ts +1 -0
- package/src/utils/openDataLoaderWordExport.ts +33 -0
- package/src/utils/pageScrollbar.ts +115 -0
- package/src/utils/randomTranscode.ts +87 -0
- package/src/utils/reportPdfExport.ts +44 -0
- package/src/views/Blank.vue +68 -0
- package/src/views/Home.vue +29 -0
- package/src/views/TemplateCenter/Knowledge.ts +83 -0
- package/src/views/TemplateCenter/data.d.ts +10 -0
- package/src/views/TemplateCenter/index.vue +1128 -0
- package/src/views/TemplateCenter/service.ts +69 -0
- package/src/views/gen-ai/build-report/chartStreamRefs.ts +174 -0
- package/src/views/gen-ai/build-report/coherence-check/index.vue +559 -0
- package/src/views/gen-ai/build-report/components/ReportChapterWorkspace.vue +4258 -0
- package/src/views/gen-ai/build-report/components/ReportConfigPanel.vue +727 -0
- package/src/views/gen-ai/build-report/components/ReportGenerateSettingsPanel.vue +2361 -0
- package/src/views/gen-ai/build-report/components/ReportGeneratingPanel.vue +1765 -0
- package/src/views/gen-ai/build-report/components/ReportPromptPanel.vue +614 -0
- package/src/views/gen-ai/build-report/components/ReportSourceFileSummary.vue +656 -0
- package/src/views/gen-ai/build-report/components/ReportSourcesPanel.vue +1327 -0
- package/src/views/gen-ai/build-report/components/ReportTemplateDetail.vue +191 -0
- package/src/views/gen-ai/build-report/components/ReportTemplateEditorFormPanel.vue +667 -0
- package/src/views/gen-ai/build-report/components/ReportTemplatePicker.vue +302 -0
- package/src/views/gen-ai/build-report/components/ReportWorkflowSidebar.vue +148 -0
- package/src/views/gen-ai/build-report/components/paramsSetting.vue +886 -0
- package/src/views/gen-ai/build-report/components/reportEdit.vue +2283 -0
- package/src/views/gen-ai/build-report/index.vue +856 -0
- package/src/views/gen-ai/build-report/report-domain.ts +1133 -0
- package/src/views/gen-ai/build-report/report-template-data.ts +295 -0
- package/src/views/gen-ai/build-report/useReportWorkflow.ts +1408 -0
- package/src/views/gen-ai/common/assets/NotoSans-SC.woff2 +0 -0
- package/src/views/gen-ai/common/assets/NotoSans-TC.woff2 +0 -0
- package/src/views/gen-ai/common/assets/NotoSans.woff2 +0 -0
- package/src/views/gen-ai/common/assets/fonts.css +278 -0
- package/src/views/gen-ai/common/assets/pagination.css +163 -0
- package/src/views/gen-ai/common/directives/btnLoading.ts +455 -0
- package/src/views/gen-ai/common/directives/debounce.ts +98 -0
- package/src/views/gen-ai/common/directives/index.ts +30 -0
- package/src/views/gen-ai/common/en.md +417 -0
- package/src/views/gen-ai/common/index.ts +36 -0
- package/src/views/gen-ai/common/types/component-expose.ts +9 -0
- package/src/views/gen-ai/common/utils/api-res-status.ts +7 -0
- package/src/views/gen-ai/common/utils/navigation.ts +59 -0
- package/src/views/gen-ai/common/utils/remote-request.ts +45 -0
- package/src/views/gen-ai/common/utils/scroll.ts +577 -0
- package/src/views/gen-ai/components/AIExport/docx-export.ts +950 -0
- package/src/views/gen-ai/components/AIExport/docxExport.ts +2566 -0
- package/src/views/gen-ai/components/AIExport/index.ts +52 -0
- package/src/views/gen-ai/components/AIExport/parseMarkdownHtml.ts +649 -0
- package/src/views/gen-ai/components/CapsuleScrollbar.vue +149 -0
- package/src/views/gen-ai/components/ChapterTitleScroll.vue +468 -0
- package/src/views/gen-ai/components/EntryHeroNavCards.vue +379 -0
- package/src/views/gen-ai/components/GenAiPagination.vue +52 -0
- package/src/views/gen-ai/components/ModelCard.vue +1114 -0
- package/src/views/gen-ai/components/Preview/FilePreviewPage.vue +947 -0
- package/src/views/gen-ai/components/Preview/PreviewCapsuleScroll.vue +205 -0
- package/src/views/gen-ai/components/Preview/PreviewOutlineTree.vue +148 -0
- package/src/views/gen-ai/components/Preview/index.ts +11 -0
- package/src/views/gen-ai/components/Preview/preview.ts +722 -0
- package/src/views/gen-ai/components/PromptField.vue +505 -0
- package/src/views/gen-ai/components/RecentReportsTable.vue +974 -0
- package/src/views/gen-ai/components/ReportCollapsibleSection.vue +172 -0
- package/src/views/gen-ai/components/ReportHistoryList.vue +637 -0
- package/src/views/gen-ai/components/ReportSectionConfirmPopover.vue +251 -0
- package/src/views/gen-ai/components/editor/ChapterTiptapEditor.vue +3139 -0
- package/src/views/gen-ai/components/editor/StructureBlockView.vue +441 -0
- package/src/views/gen-ai/components/editor/TiptapToolbar.vue +1036 -0
- package/src/views/gen-ai/components/editor/TypewriterDocEditor.vue +398 -0
- package/src/views/gen-ai/components/editor/_StructureOrgNode.vue +326 -0
- package/src/views/gen-ai/components/editor/index.ts +12 -0
- package/src/views/gen-ai/components/editor/parseMarkdownHtml.ts +667 -0
- package/src/views/gen-ai/gen-entry/api/index.ts +32 -0
- package/src/views/gen-ai/gen-entry/index.vue +287 -0
- package/src/views/gen-ai/gen-entry/types/index.ts +4 -0
- package/src/views/gen-ai/i.mark +2 -0
- package/src/views/gen-ai/management-center/index.vue +1815 -0
- package/src/views/gen-ai/management-center/mockData.ts +248 -0
- package/src/views/gen-ai/management-center/types/index.ts +37 -0
- package/src/views/gen-ai/model-manager/TemplateEditorFormPanel.vue +661 -0
- package/src/views/gen-ai/model-manager/api/index.ts +32 -0
- package/src/views/gen-ai/model-manager/api/mockApi.ts +33 -0
- package/src/views/gen-ai/model-manager/index.vue +1583 -0
- package/src/views/gen-ai/model-manager/mockData.ts +177 -0
- package/src/views/gen-ai/model-manager/template-detail-shared.ts +154 -0
- package/src/views/gen-ai/model-manager/template-editor.vue +345 -0
- package/src/views/gen-ai/model-manager/types/index.ts +40 -0
- package/src/views/gen-ai/model-manager/utils.ts +25 -0
- package/src/views/greenMortgage.vue +1834 -0
- package/src/vite-env.d.ts +46 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/** build-report 模板數據與 API */
|
|
2
|
+
|
|
3
|
+
export interface TemplateListParams {
|
|
4
|
+
unit?: string
|
|
5
|
+
keyword?: string
|
|
6
|
+
language?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TemplateItem {
|
|
10
|
+
id: string
|
|
11
|
+
name: string
|
|
12
|
+
description: string
|
|
13
|
+
chapters: string[]
|
|
14
|
+
author: string
|
|
15
|
+
approver: string
|
|
16
|
+
updatedAt: string
|
|
17
|
+
unit: string
|
|
18
|
+
locked: boolean
|
|
19
|
+
locker: string
|
|
20
|
+
/** 卡片標籤:行業 */
|
|
21
|
+
industry?: string
|
|
22
|
+
approvalStatus?: '待審批' | '已通過' | '已拒絕'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface TemplateChapterForm {
|
|
26
|
+
id: string
|
|
27
|
+
title: string
|
|
28
|
+
description: string
|
|
29
|
+
prompt: string
|
|
30
|
+
expanded: boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface TemplateEditorForm {
|
|
34
|
+
language: string
|
|
35
|
+
title: string
|
|
36
|
+
description: string
|
|
37
|
+
chapters: TemplateChapterForm[]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type TemplateEditorMode = 'create' | 'edit' | 'copy'
|
|
41
|
+
|
|
42
|
+
const INDUSTRY_RISK_ANNUAL_NAME = '行業風險年報測試擴展內容用於省略展示測試擴展內容用於省略展示'
|
|
43
|
+
const INDUSTRY_RISK_ANNUAL_INDUSTRY = '新能源汽車測試擴展內容用於省略展示測試擴展內容用於省略展示測'
|
|
44
|
+
|
|
45
|
+
const INDUSTRY_RISK_ANNUAL_DESC =
|
|
46
|
+
'本模板用於生成年度行業風險分析報告,覆蓋宏觀環境、行業運行、風險識別、授信結構、資產質素等模塊配置。適用於風險管理、授信審批及合規條線年度復盤,可按產業視角擴展指標口徑、預警規則與附件數據清單,確保報告內容一致、可追溯且具備決策參考價值。適用於風險管理、授信審批及合規條線年度復盤,可按產業視角擴展指標口徑、預警規則與附件數據清單,確保報告內容一致、可追溯且具備決策參考價值。適用於風險管理、授信審批及合規條線年度復盤,可按產業視角擴展指標口徑、預警規則與附件數據清單,確保報告內容一致、可追溯且具備決策參考價值。適用於風險管理、授信審批及合規條線年度復盤,可按產業視角擴展指標口徑、預警規則與附件數據清單,確保報告內容一致、可追溯且具備決策參考價值。適用於風險管理、授信審批及合規條線年度復盤,可按產業視角擴展指標口徑、預警規則與附件數據清單,確保報告內容一致、可追溯且具備決策參考價值。適用於風險管理、授信審批及合規條線年度復盤,可按產業視角擴展指標口徑、預警規則與附件數據清單,確保報告內容一致、可追溯且具備決策參考價值。適用於風險管理、授信審批及合規條線年度復盤,可按產業視角擴展指標口徑、預'
|
|
47
|
+
|
|
48
|
+
const INDUSTRY_RISK_ANNUAL_CHAPTERS = [
|
|
49
|
+
'1. 摘要與本年總結',
|
|
50
|
+
'2. 宏觀經濟與政策背景',
|
|
51
|
+
'3. 行業運行情況與核心指標',
|
|
52
|
+
'4. 風險識別與評級',
|
|
53
|
+
'5. 授信與客戶結構分析',
|
|
54
|
+
'6. 資產質素與逾期/不良變化資產質素與逾期/不良變化資產質素與逾期/不良變化資產質素與逾期/不良變化資產質素與逾期/不良變化資產質素與逾期/不良變化',
|
|
55
|
+
'7. 重點客戶/項目風險',
|
|
56
|
+
'8. 新發生風險與預警',
|
|
57
|
+
'9. 風險管控措施與成效',
|
|
58
|
+
'10. 下年度風險研判與策略',
|
|
59
|
+
'11. 附件與數據',
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
const QUARTERLY_BRIEF_DESC =
|
|
63
|
+
'面向季度復盤的輕量模板,聚焦行業景氣、核心指標波動、重點風險事件與管控建議,適用於管理層例會與條線月報。'
|
|
64
|
+
|
|
65
|
+
const QUARTERLY_BRIEF_CHAPTERS = [
|
|
66
|
+
'1. 季度摘要',
|
|
67
|
+
'2. 行業景氣與政策動態',
|
|
68
|
+
'3. 核心指標走勢',
|
|
69
|
+
'4. 重點風險事件',
|
|
70
|
+
'5. 管控措施與下季關注',
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
const FULL_RISK_DESC =
|
|
74
|
+
'完整版風險報告模板,章節可擴展至 20+,覆蓋母行、子公司、區域及產品線多維度風險拆解,支援附錄與數據口徑說明。'
|
|
75
|
+
|
|
76
|
+
const FULL_RISK_CHAPTERS = [
|
|
77
|
+
...INDUSTRY_RISK_ANNUAL_CHAPTERS,
|
|
78
|
+
'12. 區域風險分佈',
|
|
79
|
+
'13. 產品線風險拆解',
|
|
80
|
+
'14. 關聯方與集中度',
|
|
81
|
+
'15. 市場與流動性風險',
|
|
82
|
+
'16. 操作與合規風險',
|
|
83
|
+
'17. 聲譽與環境風險',
|
|
84
|
+
'18. 壓力測試結果',
|
|
85
|
+
'19. 整改跟進清單',
|
|
86
|
+
'20. 監管關注重點',
|
|
87
|
+
'21. 術語與指標口徑',
|
|
88
|
+
'22. 修訂記錄',
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
export const REPORT_TEMPLATE_ITEMS: TemplateItem[] = [
|
|
92
|
+
{
|
|
93
|
+
id: '1',
|
|
94
|
+
name: INDUSTRY_RISK_ANNUAL_NAME,
|
|
95
|
+
description: INDUSTRY_RISK_ANNUAL_DESC,
|
|
96
|
+
chapters: INDUSTRY_RISK_ANNUAL_CHAPTERS,
|
|
97
|
+
author: '王明輝(風險管理部)',
|
|
98
|
+
approver: '李思琪(合規部)',
|
|
99
|
+
updatedAt: '2025/11/7 15:21',
|
|
100
|
+
unit: '風險管理部',
|
|
101
|
+
industry: INDUSTRY_RISK_ANNUAL_INDUSTRY,
|
|
102
|
+
locked: false,
|
|
103
|
+
locker: '陳大文(授信審批部)',
|
|
104
|
+
approvalStatus: '待審批',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: '2',
|
|
108
|
+
name: INDUSTRY_RISK_ANNUAL_NAME,
|
|
109
|
+
description: INDUSTRY_RISK_ANNUAL_DESC,
|
|
110
|
+
chapters: INDUSTRY_RISK_ANNUAL_CHAPTERS,
|
|
111
|
+
author: '張偉(風險管理部)',
|
|
112
|
+
approver: '劉芳(合規部)',
|
|
113
|
+
updatedAt: '2025/10/28 09:15',
|
|
114
|
+
unit: '授信審批部',
|
|
115
|
+
industry: INDUSTRY_RISK_ANNUAL_INDUSTRY,
|
|
116
|
+
locked: true,
|
|
117
|
+
locker: '陳大文(授信審批部)',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: '3',
|
|
121
|
+
name: INDUSTRY_RISK_ANNUAL_NAME,
|
|
122
|
+
description: INDUSTRY_RISK_ANNUAL_DESC,
|
|
123
|
+
chapters: INDUSTRY_RISK_ANNUAL_CHAPTERS,
|
|
124
|
+
author: '趙敏(公司金融部)',
|
|
125
|
+
approver: '周傑(合規部)',
|
|
126
|
+
updatedAt: '2025/9/12 11:40',
|
|
127
|
+
unit: '風險管理部',
|
|
128
|
+
industry: INDUSTRY_RISK_ANNUAL_INDUSTRY,
|
|
129
|
+
locked: false,
|
|
130
|
+
locker: '陳大文(授信審批部)',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: '4',
|
|
134
|
+
name: '季度行業風險簡報',
|
|
135
|
+
description: QUARTERLY_BRIEF_DESC,
|
|
136
|
+
chapters: QUARTERLY_BRIEF_CHAPTERS,
|
|
137
|
+
author: '陳曉東(風險管理部)',
|
|
138
|
+
approver: '何靜(合規部)',
|
|
139
|
+
updatedAt: '2025/8/3 16:05',
|
|
140
|
+
unit: '合規部',
|
|
141
|
+
industry: '零售銀行',
|
|
142
|
+
locked: false,
|
|
143
|
+
locker: '陳大文(授信審批部)',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: '5',
|
|
147
|
+
name: '全面風險分析模板',
|
|
148
|
+
description: FULL_RISK_DESC,
|
|
149
|
+
chapters: FULL_RISK_CHAPTERS,
|
|
150
|
+
author: '孫麗(風險管理部)',
|
|
151
|
+
approver: '馬強(合規部)',
|
|
152
|
+
updatedAt: '2025/7/19 14:32',
|
|
153
|
+
unit: '公司金融部',
|
|
154
|
+
industry: '房地產',
|
|
155
|
+
locked: false,
|
|
156
|
+
locker: '陳大文(授信審批部)',
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: '6',
|
|
160
|
+
name: INDUSTRY_RISK_ANNUAL_NAME,
|
|
161
|
+
description: INDUSTRY_RISK_ANNUAL_DESC,
|
|
162
|
+
chapters: INDUSTRY_RISK_ANNUAL_CHAPTERS,
|
|
163
|
+
author: '黃磊(授信審批部)',
|
|
164
|
+
approver: '吳婷(合規部)',
|
|
165
|
+
updatedAt: '2025/6/25 10:18',
|
|
166
|
+
unit: '授信審批部',
|
|
167
|
+
industry: INDUSTRY_RISK_ANNUAL_INDUSTRY,
|
|
168
|
+
locked: true,
|
|
169
|
+
locker: '陳大文(授信審批部)',
|
|
170
|
+
},
|
|
171
|
+
]
|
|
172
|
+
|
|
173
|
+
let chapterSeed = 0
|
|
174
|
+
|
|
175
|
+
export function createEmptyChapter(expanded = false): TemplateChapterForm {
|
|
176
|
+
chapterSeed += 1
|
|
177
|
+
return {
|
|
178
|
+
id: `chapter-${Date.now()}-${chapterSeed}`,
|
|
179
|
+
title: '',
|
|
180
|
+
description: '',
|
|
181
|
+
prompt: '',
|
|
182
|
+
expanded,
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function stripChapterOrder(title: string) {
|
|
187
|
+
return title.replace(/^\d+\.\s*/, '')
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function buildEditorFormFromTemplate(
|
|
191
|
+
template: TemplateItem,
|
|
192
|
+
copy = false
|
|
193
|
+
): TemplateEditorForm {
|
|
194
|
+
return {
|
|
195
|
+
language: 'zh',
|
|
196
|
+
title: copy ? `${template.name}(副本)` : template.name,
|
|
197
|
+
description: template.description,
|
|
198
|
+
chapters: template.chapters.map((chapterTitle, index) => ({
|
|
199
|
+
id: `chapter-${template.id}-${index}`,
|
|
200
|
+
title: stripChapterOrder(chapterTitle),
|
|
201
|
+
description: index === 0 ? '本章節概述報告核心結論與年度重點。' : '',
|
|
202
|
+
prompt: index === 0 ? '請根據行業數據與風控政策,生成本章節分析內容。' : '',
|
|
203
|
+
expanded: index === 0,
|
|
204
|
+
})),
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function findTemplateById(id: string) {
|
|
209
|
+
return REPORT_TEMPLATE_ITEMS.find((item) => item.id === id)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function filterTemplates(list: TemplateItem[], params: TemplateListParams) {
|
|
213
|
+
const kw = params.keyword?.trim().toLowerCase() ?? ''
|
|
214
|
+
return list.filter((item) => {
|
|
215
|
+
const unitOk = !params.unit || item.unit === params.unit
|
|
216
|
+
const keywordOk =
|
|
217
|
+
!kw ||
|
|
218
|
+
item.name.toLowerCase().includes(kw) ||
|
|
219
|
+
item.description.toLowerCase().includes(kw) ||
|
|
220
|
+
item.author.toLowerCase().includes(kw)
|
|
221
|
+
return unitOk && keywordOk
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const TEMPLATE_FETCH_DELAY_MS = 200
|
|
226
|
+
|
|
227
|
+
/** 全量模板列表記憶體暫存:同會話內重複進入選擇頁不重複請求 */
|
|
228
|
+
let cachedAllTemplates: TemplateItem[] | null = null
|
|
229
|
+
let templateListInflight: Promise<TemplateItem[]> | null = null
|
|
230
|
+
|
|
231
|
+
async function loadAllTemplates(force = false): Promise<TemplateItem[]> {
|
|
232
|
+
if (force) {
|
|
233
|
+
cachedAllTemplates = null
|
|
234
|
+
templateListInflight = null
|
|
235
|
+
}
|
|
236
|
+
if (cachedAllTemplates) return cachedAllTemplates
|
|
237
|
+
if (!templateListInflight) {
|
|
238
|
+
templateListInflight = (async () => {
|
|
239
|
+
await new Promise<void>((resolve) => {
|
|
240
|
+
window.setTimeout(resolve, TEMPLATE_FETCH_DELAY_MS)
|
|
241
|
+
})
|
|
242
|
+
cachedAllTemplates = [...REPORT_TEMPLATE_ITEMS]
|
|
243
|
+
return cachedAllTemplates
|
|
244
|
+
})()
|
|
245
|
+
}
|
|
246
|
+
return templateListInflight
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export async function fetchReportTemplateList(
|
|
250
|
+
params: TemplateListParams = {},
|
|
251
|
+
options?: { force?: boolean }
|
|
252
|
+
) {
|
|
253
|
+
const all = await loadAllTemplates(!!options?.force)
|
|
254
|
+
return filterTemplates(all, params)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** 手動清空模板列表暫存(如登出) */
|
|
258
|
+
export function clearReportTemplateListCache() {
|
|
259
|
+
cachedAllTemplates = null
|
|
260
|
+
templateListInflight = null
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface ReportTemplateCard {
|
|
264
|
+
id: string
|
|
265
|
+
name: string
|
|
266
|
+
description: string
|
|
267
|
+
chapters: string[]
|
|
268
|
+
author: string
|
|
269
|
+
updatedAt: string
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export function templateItemToReportCard(item: TemplateItem): ReportTemplateCard {
|
|
273
|
+
const dateOnly = item.updatedAt.includes(' ')
|
|
274
|
+
? item.updatedAt.slice(0, item.updatedAt.indexOf(' '))
|
|
275
|
+
: item.updatedAt
|
|
276
|
+
|
|
277
|
+
return {
|
|
278
|
+
id: item.id,
|
|
279
|
+
name: item.name,
|
|
280
|
+
description: item.description,
|
|
281
|
+
chapters: [...item.chapters],
|
|
282
|
+
author: item.author,
|
|
283
|
+
updatedAt: dateOnly,
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export const REPORT_TEMPLATE_CARDS: ReportTemplateCard[] =
|
|
288
|
+
REPORT_TEMPLATE_ITEMS.map(templateItemToReportCard)
|
|
289
|
+
|
|
290
|
+
/** 兼容舊名 MOCK_REPORT_TEMPLATES */
|
|
291
|
+
export const MOCK_REPORT_TEMPLATES = REPORT_TEMPLATE_CARDS
|
|
292
|
+
|
|
293
|
+
export function resolveReportTemplateById(templateId: string): ReportTemplateCard | null {
|
|
294
|
+
return REPORT_TEMPLATE_CARDS.find((item) => item.id === templateId) ?? null
|
|
295
|
+
}
|