aegon-dangerious 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/build-report/components/AiPromptGenerateDialog.vue +349 -0
- package/build-report/components/CapsuleScrollbar.vue +145 -0
- package/build-report/components/ChapterTitleScroll.vue +292 -0
- package/build-report/components/PromptField.vue +314 -0
- package/build-report/components/RecentReportsTable.vue +408 -0
- package/build-report/components/ReportChapterPreview.vue +437 -0
- package/build-report/components/ReportChapterWorkspace.vue +923 -0
- package/build-report/components/ReportCollapsibleSection.vue +132 -0
- package/build-report/components/ReportConfigPanel.vue +609 -0
- package/build-report/components/ReportGenerateSettingsPanel.vue +403 -0
- package/build-report/components/ReportGeneratingPanel.vue +908 -0
- package/build-report/components/ReportHistoryList.vue +157 -0
- package/build-report/components/ReportHistoryPanel.vue +140 -0
- package/build-report/components/ReportPromptPanel.vue +445 -0
- package/build-report/components/ReportSectionConfirmPopover.vue +232 -0
- package/build-report/components/ReportSourceFileSummary.vue +544 -0
- package/build-report/components/ReportSourcesMoreOverlay.vue +279 -0
- package/build-report/components/ReportSourcesPanel.vue +1055 -0
- package/build-report/components/ReportTemplateDetail.vue +176 -0
- package/build-report/components/ReportTemplateEditorFormPanel.vue +602 -0
- package/build-report/components/ReportTemplatePicker.vue +802 -0
- package/build-report/components/ReportTemplatePromptField.vue +314 -0
- package/build-report/components/ReportWorkflowSidebar.vue +104 -0
- package/build-report/components/reportEdit.vue +334 -0
- package/build-report/index.vue +646 -0
- package/build-report/report-list.vue +407 -0
- package/build-report/report-template-data.ts +248 -0
- package/build-report/styles/report-workflow-dialog.css +33 -0
- package/build-report/useReportWorkflow.ts +343 -0
- package/build-report/utils/report-edit-route.ts +109 -0
- package/build-report/utils/scroll.ts +361 -0
- package/package.json +12 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<aside class="report-prompt-panel" :class="{ 'is-compact': !promptOpen && !historyOpen }">
|
|
3
|
+
<ReportCollapsibleSection v-model:open="promptOpen" title="Prompt">
|
|
4
|
+
<div class="report-prompt-panel__content">
|
|
5
|
+
<div class="report-prompt-panel__prompt">
|
|
6
|
+
<PromptField
|
|
7
|
+
v-model="promptChapterForm.prompt"
|
|
8
|
+
label="Prompt"
|
|
9
|
+
layout="stack"
|
|
10
|
+
:required="false"
|
|
11
|
+
:rows="8"
|
|
12
|
+
min-height="180px"
|
|
13
|
+
:maxlength="1300"
|
|
14
|
+
:disabled="!chapterEditMode"
|
|
15
|
+
/>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div class="report-prompt-panel__options">
|
|
19
|
+
<label class="report-prompt-panel__option report-prompt-panel__option--inline">
|
|
20
|
+
<input
|
|
21
|
+
v-model="promptChapterForm.enableBodyContent"
|
|
22
|
+
type="checkbox"
|
|
23
|
+
class="report-prompt-panel__checkbox"
|
|
24
|
+
:disabled="!chapterEditMode"
|
|
25
|
+
/>
|
|
26
|
+
<span class="report-prompt-panel__option-label">正文內容</span>
|
|
27
|
+
<input
|
|
28
|
+
v-model.number="promptChapterForm.bodyWordLimit"
|
|
29
|
+
type="number"
|
|
30
|
+
class="report-prompt-panel__number-input"
|
|
31
|
+
:disabled="!chapterEditMode || !promptChapterForm.enableBodyContent"
|
|
32
|
+
min="1"
|
|
33
|
+
max="5000"
|
|
34
|
+
/>
|
|
35
|
+
<span class="report-prompt-panel__option-suffix">字以內</span>
|
|
36
|
+
</label>
|
|
37
|
+
|
|
38
|
+
<div class="report-prompt-panel__option-group">
|
|
39
|
+
<div class="report-prompt-panel__option-header">
|
|
40
|
+
<label class="report-prompt-panel__option">
|
|
41
|
+
<input
|
|
42
|
+
v-model="promptChapterForm.enableTable"
|
|
43
|
+
type="checkbox"
|
|
44
|
+
class="report-prompt-panel__checkbox"
|
|
45
|
+
:disabled="!chapterEditMode"
|
|
46
|
+
/>
|
|
47
|
+
<span class="report-prompt-panel__option-label">生成表格</span>
|
|
48
|
+
</label>
|
|
49
|
+
<button
|
|
50
|
+
type="button"
|
|
51
|
+
class="report-prompt-panel__fold-toggle"
|
|
52
|
+
aria-label="展開或收起生成設置"
|
|
53
|
+
@click="optionsDetailsOpen = !optionsDetailsOpen"
|
|
54
|
+
>
|
|
55
|
+
<span class="report-prompt-panel__fold-arrow" :class="{ 'is-open': optionsDetailsOpen }" aria-hidden="true" />
|
|
56
|
+
</button>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<div v-show="optionsDetailsOpen" class="report-prompt-panel__details">
|
|
60
|
+
<div v-if="promptChapterForm.enableTable" class="report-prompt-panel__nested">
|
|
61
|
+
<label class="report-prompt-panel__field">
|
|
62
|
+
<span class="report-prompt-panel__field-label">表格標題</span>
|
|
63
|
+
<el-input
|
|
64
|
+
v-model="promptChapterForm.tableTitle"
|
|
65
|
+
class="report-prompt-panel__input"
|
|
66
|
+
placeholder="請輸入表格名稱"
|
|
67
|
+
:disabled="!chapterEditMode"
|
|
68
|
+
/>
|
|
69
|
+
</label>
|
|
70
|
+
<label class="report-prompt-panel__field">
|
|
71
|
+
<span class="report-prompt-panel__field-label">列標籤</span>
|
|
72
|
+
<el-input
|
|
73
|
+
v-model="promptChapterForm.tableRowLabels"
|
|
74
|
+
type="textarea"
|
|
75
|
+
:rows="3"
|
|
76
|
+
resize="none"
|
|
77
|
+
class="report-prompt-panel__textarea"
|
|
78
|
+
:disabled="!chapterEditMode"
|
|
79
|
+
/>
|
|
80
|
+
</label>
|
|
81
|
+
<label class="report-prompt-panel__field">
|
|
82
|
+
<span class="report-prompt-panel__field-label">欄標籤</span>
|
|
83
|
+
<el-input
|
|
84
|
+
v-model="promptChapterForm.tableColumnLabels"
|
|
85
|
+
type="textarea"
|
|
86
|
+
:rows="3"
|
|
87
|
+
resize="none"
|
|
88
|
+
class="report-prompt-panel__textarea"
|
|
89
|
+
:disabled="!chapterEditMode"
|
|
90
|
+
/>
|
|
91
|
+
</label>
|
|
92
|
+
<label class="report-prompt-panel__field">
|
|
93
|
+
<span class="report-prompt-panel__field-label">內容</span>
|
|
94
|
+
<el-input
|
|
95
|
+
v-model="promptChapterForm.tableContent"
|
|
96
|
+
type="textarea"
|
|
97
|
+
:rows="3"
|
|
98
|
+
resize="none"
|
|
99
|
+
class="report-prompt-panel__textarea"
|
|
100
|
+
:disabled="!chapterEditMode"
|
|
101
|
+
/>
|
|
102
|
+
</label>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<div class="report-prompt-panel__option-group report-prompt-panel__option-group--nested">
|
|
106
|
+
<label class="report-prompt-panel__option">
|
|
107
|
+
<input
|
|
108
|
+
v-model="promptChapterForm.enableSourceChart"
|
|
109
|
+
type="checkbox"
|
|
110
|
+
class="report-prompt-panel__checkbox"
|
|
111
|
+
:disabled="!chapterEditMode"
|
|
112
|
+
/>
|
|
113
|
+
<span class="report-prompt-panel__option-label">引用資訊源圖表</span>
|
|
114
|
+
</label>
|
|
115
|
+
|
|
116
|
+
<div v-if="promptChapterForm.enableSourceChart" class="report-prompt-panel__nested">
|
|
117
|
+
<label class="report-prompt-panel__field">
|
|
118
|
+
<span class="report-prompt-panel__field-label">圖表描述</span>
|
|
119
|
+
<el-input
|
|
120
|
+
v-model="promptChapterForm.chartDescription"
|
|
121
|
+
type="textarea"
|
|
122
|
+
:rows="4"
|
|
123
|
+
resize="none"
|
|
124
|
+
class="report-prompt-panel__textarea"
|
|
125
|
+
:disabled="!chapterEditMode"
|
|
126
|
+
/>
|
|
127
|
+
</label>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<div class="report-prompt-panel__actions">
|
|
132
|
+
<button type="button" class="app-btn app-btn--wide" @click="handleGenerateChapter">
|
|
133
|
+
生成章節內容
|
|
134
|
+
</button>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
</ReportCollapsibleSection>
|
|
141
|
+
|
|
142
|
+
<ReportCollapsibleSection v-model:open="historyOpen" title="章節歷史">
|
|
143
|
+
<ReportHistoryList
|
|
144
|
+
v-model:active-key="activeChapterHistoryKey"
|
|
145
|
+
:items="chapterHistory"
|
|
146
|
+
:show-title="false"
|
|
147
|
+
/>
|
|
148
|
+
</ReportCollapsibleSection>
|
|
149
|
+
</aside>
|
|
150
|
+
</template>
|
|
151
|
+
|
|
152
|
+
<script lang="ts">
|
|
153
|
+
export interface PromptLibraryItem {
|
|
154
|
+
id: string
|
|
155
|
+
label: string
|
|
156
|
+
content: string
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export const MOCK_PROMPT_LIBRARY: PromptLibraryItem[] = [
|
|
160
|
+
{
|
|
161
|
+
id: 'p1',
|
|
162
|
+
label: '風險摘要',
|
|
163
|
+
content: '請以風控經理視角,用 3 段話概括本章核心風險與管控重點。',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: 'p2',
|
|
167
|
+
label: '數據解讀',
|
|
168
|
+
content: '結合已引用資料,解讀關鍵指標同比/環比變化,並指出異常波動原因。',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
id: 'p3',
|
|
172
|
+
label: '政策影響',
|
|
173
|
+
content: '分析近期監管與政策變化對本行授信策略的潛在影響。',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: 'p4',
|
|
177
|
+
label: '行動建議',
|
|
178
|
+
content: '給出可執行的風險管控建議,包含責任部門與跟進時限。',
|
|
179
|
+
},
|
|
180
|
+
]
|
|
181
|
+
</script>
|
|
182
|
+
|
|
183
|
+
<script setup lang="ts">
|
|
184
|
+
import { ref } from 'vue'
|
|
185
|
+
import { ElInput, ElMessage } from 'element-plus'
|
|
186
|
+
import PromptField from './PromptField.vue'
|
|
187
|
+
import ReportHistoryList, {
|
|
188
|
+
type ReportHistoryItem,
|
|
189
|
+
} from './ReportHistoryList.vue'
|
|
190
|
+
import ReportCollapsibleSection from './ReportCollapsibleSection.vue'
|
|
191
|
+
import { useReportWorkflow } from '../useReportWorkflow'
|
|
192
|
+
|
|
193
|
+
const { promptChapterForm, chapterEditMode } = useReportWorkflow()
|
|
194
|
+
|
|
195
|
+
const promptOpen = ref(true)
|
|
196
|
+
const historyOpen = ref(true)
|
|
197
|
+
const optionsDetailsOpen = ref(false)
|
|
198
|
+
|
|
199
|
+
const chapterHistory = ref<ReportHistoryItem[]>([
|
|
200
|
+
{ key: 'history-final', title: '定稿版本', author: '陳大文', time: '15min前' },
|
|
201
|
+
{ key: 'history-v2', title: 'V2', author: '陳大文', time: '15min前' },
|
|
202
|
+
])
|
|
203
|
+
const activeChapterHistoryKey = ref('history-final')
|
|
204
|
+
|
|
205
|
+
function handleGenerateChapter() {
|
|
206
|
+
if (!promptChapterForm.prompt.trim()) {
|
|
207
|
+
ElMessage.warning('請先填寫 Prompt')
|
|
208
|
+
return
|
|
209
|
+
}
|
|
210
|
+
console.log('generate chapter content', { ...promptChapterForm })
|
|
211
|
+
ElMessage.success('章節內容生成中')
|
|
212
|
+
}
|
|
213
|
+
</script>
|
|
214
|
+
|
|
215
|
+
<style scoped>
|
|
216
|
+
.report-prompt-panel {
|
|
217
|
+
display: flex;
|
|
218
|
+
flex-direction: column;
|
|
219
|
+
gap: 14px;
|
|
220
|
+
min-width: 0;
|
|
221
|
+
height: 100%;
|
|
222
|
+
box-sizing: border-box;
|
|
223
|
+
overflow: visible;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.report-prompt-panel.is-compact {
|
|
227
|
+
height: auto;
|
|
228
|
+
align-self: flex-start;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.report-prompt-panel > :deep(.report-collapsible-section:last-child:not(.is-collapsed)) {
|
|
232
|
+
flex: 1;
|
|
233
|
+
display: flex;
|
|
234
|
+
flex-direction: column;
|
|
235
|
+
min-height: 0;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.report-prompt-panel > :deep(.report-collapsible-section:last-child:not(.is-collapsed) .report-collapsible-section__body) {
|
|
239
|
+
flex: 1;
|
|
240
|
+
display: flex;
|
|
241
|
+
flex-direction: column;
|
|
242
|
+
min-height: 0;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.report-prompt-panel :deep(.report-collapsible-section__toggle) {
|
|
246
|
+
border-bottom: none;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.report-prompt-panel :deep(.report-collapsible-section.is-collapsed .report-collapsible-section__toggle) {
|
|
250
|
+
padding-bottom: 0;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.report-prompt-panel__content {
|
|
254
|
+
display: flex;
|
|
255
|
+
flex-direction: column;
|
|
256
|
+
gap: 8px;
|
|
257
|
+
min-width: 0;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.report-prompt-panel__prompt :deep(.gen-ai-prompt-field__label) {
|
|
261
|
+
display: none;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.report-prompt-panel__prompt :deep(.gen-ai-prompt-field--row) {
|
|
265
|
+
grid-template-columns: minmax(0, 1fr);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.report-prompt-panel__prompt :deep(.gen-ai-prompt-field__count) {
|
|
269
|
+
margin-top: 2px;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.report-prompt-panel__options {
|
|
273
|
+
display: flex;
|
|
274
|
+
flex-direction: column;
|
|
275
|
+
gap: 8px;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.report-prompt-panel__option-group {
|
|
279
|
+
display: flex;
|
|
280
|
+
flex-direction: column;
|
|
281
|
+
gap: 6px;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.report-prompt-panel__option-header {
|
|
285
|
+
display: flex;
|
|
286
|
+
align-items: center;
|
|
287
|
+
justify-content: space-between;
|
|
288
|
+
gap: 8px;
|
|
289
|
+
min-width: 0;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.report-prompt-panel__fold-toggle {
|
|
293
|
+
display: inline-flex;
|
|
294
|
+
align-items: center;
|
|
295
|
+
justify-content: center;
|
|
296
|
+
flex-shrink: 0;
|
|
297
|
+
width: 24px;
|
|
298
|
+
height: 24px;
|
|
299
|
+
margin: 0;
|
|
300
|
+
padding: 0;
|
|
301
|
+
border: 0;
|
|
302
|
+
background: none;
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.report-prompt-panel__fold-arrow {
|
|
307
|
+
display: inline-block;
|
|
308
|
+
width: 0;
|
|
309
|
+
height: 0;
|
|
310
|
+
border-left: 5px solid transparent;
|
|
311
|
+
border-right: 5px solid transparent;
|
|
312
|
+
border-bottom: 7px solid #c53355;
|
|
313
|
+
transition: transform 0.2s ease;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.report-prompt-panel__fold-arrow.is-open {
|
|
317
|
+
transform: rotate(180deg);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.report-prompt-panel__option {
|
|
321
|
+
display: inline-flex;
|
|
322
|
+
align-items: center;
|
|
323
|
+
gap: 8px;
|
|
324
|
+
cursor: pointer;
|
|
325
|
+
user-select: none;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.report-prompt-panel__option--inline {
|
|
329
|
+
flex-wrap: wrap;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.report-prompt-panel__checkbox {
|
|
333
|
+
width: 14px;
|
|
334
|
+
height: 14px;
|
|
335
|
+
margin: 0;
|
|
336
|
+
accent-color: #c53355;
|
|
337
|
+
flex-shrink: 0;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.report-prompt-panel__option-label {
|
|
341
|
+
font-size: 13px;
|
|
342
|
+
font-weight: 500;
|
|
343
|
+
color: #303133;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.report-prompt-panel__option-suffix {
|
|
347
|
+
font-size: 13px;
|
|
348
|
+
color: #606266;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.report-prompt-panel__number-input {
|
|
352
|
+
width: 64px;
|
|
353
|
+
height: 28px;
|
|
354
|
+
padding: 2px 8px;
|
|
355
|
+
border: 1px solid #dcdfe6;
|
|
356
|
+
border-radius: 4px;
|
|
357
|
+
font-size: 13px;
|
|
358
|
+
color: #303133;
|
|
359
|
+
box-sizing: border-box;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.report-prompt-panel__number-input:disabled {
|
|
363
|
+
background: #f5f7fa;
|
|
364
|
+
color: #c0c4cc;
|
|
365
|
+
cursor: not-allowed;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.report-prompt-panel__nested {
|
|
369
|
+
display: flex;
|
|
370
|
+
flex-direction: column;
|
|
371
|
+
gap: 8px;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.report-prompt-panel__details {
|
|
375
|
+
display: flex;
|
|
376
|
+
flex-direction: column;
|
|
377
|
+
gap: 8px;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.report-prompt-panel__option-group--nested {
|
|
381
|
+
margin-top: 0;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.report-prompt-panel__field {
|
|
385
|
+
display: flex;
|
|
386
|
+
flex-direction: column;
|
|
387
|
+
gap: 4px;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.report-prompt-panel__field-label {
|
|
391
|
+
font-size: 13px;
|
|
392
|
+
color: #606266;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.report-prompt-panel__input :deep(.el-input__wrapper),
|
|
396
|
+
.report-prompt-panel__textarea :deep(.el-textarea__inner) {
|
|
397
|
+
border-radius: 4px;
|
|
398
|
+
font-size: 13px;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.report-prompt-panel__textarea :deep(.el-textarea__inner) {
|
|
402
|
+
min-height: 72px;
|
|
403
|
+
line-height: 1.6;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.report-prompt-panel__actions {
|
|
407
|
+
display: flex;
|
|
408
|
+
justify-content: center;
|
|
409
|
+
padding-top: 8px;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.app-btn {
|
|
413
|
+
display: inline-flex;
|
|
414
|
+
align-items: center;
|
|
415
|
+
justify-content: center;
|
|
416
|
+
box-sizing: border-box;
|
|
417
|
+
width: 160px;
|
|
418
|
+
height: 39px;
|
|
419
|
+
min-width: 160px;
|
|
420
|
+
padding: 0;
|
|
421
|
+
border: 1px solid #c53355;
|
|
422
|
+
border-radius: 4px;
|
|
423
|
+
background: #c53355;
|
|
424
|
+
color: #fff;
|
|
425
|
+
font-size: 14px;
|
|
426
|
+
font-weight: 600;
|
|
427
|
+
line-height: 1;
|
|
428
|
+
cursor: pointer;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.app-btn:hover:not(:disabled) {
|
|
432
|
+
background: #fff;
|
|
433
|
+
color: #c53355;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.app-btn:disabled {
|
|
437
|
+
opacity: 0.45;
|
|
438
|
+
cursor: not-allowed;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
.app-btn--wide {
|
|
442
|
+
width: 160px;
|
|
443
|
+
min-width: 160px;
|
|
444
|
+
}
|
|
445
|
+
</style>
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-popover :visible="visible" :virtual-ref="virtualRef" placement="bottom-start" :width="popoverWidth"
|
|
3
|
+
:popper-options="popperOptions" :popper-style="popperStyle" popper-class="report-config-popover"
|
|
4
|
+
:transition="instant ? 'report-config-popover-instant' : 'report-config-popover-fade'" :gpu-acceleration="false"
|
|
5
|
+
:teleported="true">
|
|
6
|
+
<div class="report-section-confirm">
|
|
7
|
+
<h4 class="report-section-confirm__title">{{ title }}</h4>
|
|
8
|
+
<p class="report-section-confirm__message">{{ message }}</p>
|
|
9
|
+
<div class="report-section-confirm__actions">
|
|
10
|
+
<button type="button" class="report-section-confirm__btn" @click="emit('cancel')">取消</button>
|
|
11
|
+
<button type="button" class="report-section-confirm__btn report-section-confirm__btn--primary"
|
|
12
|
+
@click="emit('confirm')">
|
|
13
|
+
確認
|
|
14
|
+
</button>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</el-popover>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup lang="ts">
|
|
21
|
+
import { ElPopover } from 'element-plus'
|
|
22
|
+
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(
|
|
25
|
+
defineProps<{
|
|
26
|
+
visible: boolean
|
|
27
|
+
virtualRef: HTMLElement | null
|
|
28
|
+
boundaryEl: HTMLElement | null
|
|
29
|
+
triggerBtn?: HTMLElement | null
|
|
30
|
+
title?: string
|
|
31
|
+
message: string
|
|
32
|
+
instant?: boolean
|
|
33
|
+
}>(),
|
|
34
|
+
{
|
|
35
|
+
title: '確認刪除',
|
|
36
|
+
triggerBtn: null,
|
|
37
|
+
instant: false,
|
|
38
|
+
},
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
const emit = defineEmits<{
|
|
42
|
+
confirm: []
|
|
43
|
+
cancel: []
|
|
44
|
+
}>()
|
|
45
|
+
|
|
46
|
+
const popoverWidthPx = ref(240)
|
|
47
|
+
const arrowAlignKey = ref(0)
|
|
48
|
+
const popoverWidth = computed(() => popoverWidthPx.value)
|
|
49
|
+
|
|
50
|
+
function getSectionContentInsets() {
|
|
51
|
+
if (!props.boundaryEl) return { paddingLeft: 0, contentWidth: 240 }
|
|
52
|
+
const styles = getComputedStyle(props.boundaryEl)
|
|
53
|
+
const paddingLeft = parseFloat(styles.paddingLeft)
|
|
54
|
+
const paddingRight = parseFloat(styles.paddingRight)
|
|
55
|
+
return {
|
|
56
|
+
paddingLeft,
|
|
57
|
+
contentWidth: Math.round(props.boundaryEl.clientWidth - paddingLeft - paddingRight),
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getHorizontalSkid(): number {
|
|
62
|
+
if (!props.virtualRef || !props.boundaryEl) return 0
|
|
63
|
+
const { paddingLeft } = getSectionContentInsets()
|
|
64
|
+
const sectionRect = props.boundaryEl.getBoundingClientRect()
|
|
65
|
+
const anchorRect = props.virtualRef.getBoundingClientRect()
|
|
66
|
+
return Math.round(sectionRect.left + paddingLeft - anchorRect.left)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function syncLayout() {
|
|
70
|
+
if (!props.boundaryEl) return
|
|
71
|
+
const { contentWidth } = getSectionContentInsets()
|
|
72
|
+
popoverWidthPx.value = contentWidth
|
|
73
|
+
arrowAlignKey.value += 1
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const popperStyle = computed(() => {
|
|
77
|
+
void arrowAlignKey.value
|
|
78
|
+
const sectionEl = props.boundaryEl
|
|
79
|
+
const triggerBtn = props.triggerBtn ?? props.virtualRef
|
|
80
|
+
if (!triggerBtn || !sectionEl) return {}
|
|
81
|
+
const sectionRect = sectionEl.getBoundingClientRect()
|
|
82
|
+
const { paddingLeft } = getSectionContentInsets()
|
|
83
|
+
const btnRect = triggerBtn.getBoundingClientRect()
|
|
84
|
+
const popperLeft = sectionRect.left + paddingLeft
|
|
85
|
+
const left = btnRect.left + btnRect.width / 2 - popperLeft - 8
|
|
86
|
+
return { '--report-config-arrow-left': `${left}px` }
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const popperOptions = computed(() => {
|
|
90
|
+
void arrowAlignKey.value
|
|
91
|
+
return {
|
|
92
|
+
modifiers: [
|
|
93
|
+
{
|
|
94
|
+
name: 'preventOverflow',
|
|
95
|
+
options: {
|
|
96
|
+
boundary: props.boundaryEl ?? 'viewport',
|
|
97
|
+
padding: 0,
|
|
98
|
+
altAxis: true,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'flip',
|
|
103
|
+
enabled: false,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'offset',
|
|
107
|
+
options: {
|
|
108
|
+
offset: [getHorizontalSkid(), 8],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
watch(
|
|
116
|
+
() => props.visible,
|
|
117
|
+
(open) => {
|
|
118
|
+
if (open) {
|
|
119
|
+
syncLayout()
|
|
120
|
+
void nextTick(() => {
|
|
121
|
+
arrowAlignKey.value += 1
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
watch(() => props.boundaryEl, () => syncLayout())
|
|
128
|
+
|
|
129
|
+
watch(() => props.virtualRef, () => syncLayout())
|
|
130
|
+
|
|
131
|
+
let resizeObserver: ResizeObserver | null = null
|
|
132
|
+
|
|
133
|
+
onMounted(() => {
|
|
134
|
+
syncLayout()
|
|
135
|
+
if (props.boundaryEl) {
|
|
136
|
+
resizeObserver = new ResizeObserver(() => syncLayout())
|
|
137
|
+
resizeObserver.observe(props.boundaryEl)
|
|
138
|
+
}
|
|
139
|
+
window.addEventListener('resize', syncLayout)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
onUnmounted(() => {
|
|
143
|
+
resizeObserver?.disconnect()
|
|
144
|
+
window.removeEventListener('resize', syncLayout)
|
|
145
|
+
})
|
|
146
|
+
</script>
|
|
147
|
+
|
|
148
|
+
<style scoped>
|
|
149
|
+
.report-section-confirm__title {
|
|
150
|
+
margin: 0 0 8px;
|
|
151
|
+
font-size: 14px;
|
|
152
|
+
font-weight: 700;
|
|
153
|
+
color: #303133;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.report-section-confirm__message {
|
|
157
|
+
margin: 0;
|
|
158
|
+
font-size: 13px;
|
|
159
|
+
line-height: 1.5;
|
|
160
|
+
color: #606266;
|
|
161
|
+
word-break: break-word;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.report-section-confirm__actions {
|
|
165
|
+
display: flex;
|
|
166
|
+
justify-content: flex-end;
|
|
167
|
+
gap: 8px;
|
|
168
|
+
margin-top: 12px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.report-section-confirm__btn {
|
|
172
|
+
min-width: 72px;
|
|
173
|
+
padding: 6px 10px;
|
|
174
|
+
border: 1px solid #dcdfe6;
|
|
175
|
+
border-radius: 4px;
|
|
176
|
+
background: #fff;
|
|
177
|
+
font-size: 12px;
|
|
178
|
+
color: #606266;
|
|
179
|
+
cursor: pointer;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.report-section-confirm__btn--primary {
|
|
183
|
+
border-color: #c53355;
|
|
184
|
+
background: #c53355;
|
|
185
|
+
color: #fff;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.report-section-confirm__btn--primary:hover {
|
|
189
|
+
background: #fff;
|
|
190
|
+
color: #c53355;
|
|
191
|
+
}
|
|
192
|
+
</style>
|
|
193
|
+
|
|
194
|
+
<style>
|
|
195
|
+
.report-config-popover.el-popover.el-popper {
|
|
196
|
+
max-width: 100%;
|
|
197
|
+
padding: 12px;
|
|
198
|
+
box-sizing: border-box;
|
|
199
|
+
overflow: hidden;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.report-config-popover.el-popper[data-popper-placement^='bottom'] .el-popper__arrow {
|
|
203
|
+
left: var(--report-config-arrow-left) !important;
|
|
204
|
+
right: auto !important;
|
|
205
|
+
top: -6px !important;
|
|
206
|
+
transform: translateX(-50%) !important;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.report-config-popover.el-popper[data-popper-placement^='bottom'] .el-popper__arrow::before {
|
|
210
|
+
bottom: -1px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.report-config-popover-fade-enter-active,
|
|
214
|
+
.report-config-popover-fade-leave-active {
|
|
215
|
+
transition: opacity 0.12s ease;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.report-config-popover-fade-enter-from,
|
|
219
|
+
.report-config-popover-fade-leave-to {
|
|
220
|
+
opacity: 0;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.report-config-popover-instant-enter-active,
|
|
224
|
+
.report-config-popover-instant-leave-active {
|
|
225
|
+
transition: none !important;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.report-config-popover-instant-enter-from,
|
|
229
|
+
.report-config-popover-instant-leave-to {
|
|
230
|
+
opacity: 0;
|
|
231
|
+
}
|
|
232
|
+
</style>
|