21
This commit is contained in:
parent
56f0f76721
commit
139e780158
|
|
@ -506,14 +506,15 @@ public class AssessmentRecordService : IAssessmentRecordService
|
|||
throw new BusinessException(ErrorCodes.AssessmentRecordNotFound, "测评记录不存在");
|
||||
}
|
||||
|
||||
// 校验状态:仅允许状态为 3(生成中)或 5(生成失败)的记录重新生成
|
||||
if (record.Status != 3 && record.Status != 5)
|
||||
// 校验状态:允许状态为 3(生成中)、4(已完成)或 5(生成失败)的记录重新生成
|
||||
if (record.Status != 3 && record.Status != 4 && record.Status != 5)
|
||||
{
|
||||
throw new BusinessException(ErrorCodes.InvalidOperation, "当前状态不允许重新生成");
|
||||
}
|
||||
|
||||
// 重置状态为 3(生成中)
|
||||
record.Status = 3;
|
||||
record.ReportUrl = null;
|
||||
record.UpdateTime = DateTime.Now;
|
||||
|
||||
// 清除已有的测评结果数据
|
||||
|
|
@ -571,7 +572,7 @@ public class AssessmentRecordService : IAssessmentRecordService
|
|||
}
|
||||
|
||||
// 状态不符,跳过
|
||||
if (record.Status != 3 && record.Status != 5)
|
||||
if (record.Status != 3 && record.Status != 4 && record.Status != 5)
|
||||
{
|
||||
_logger.LogWarning("批量重新生成:状态不符,ID: {RecordId}, 状态: {Status}", recordId, record.Status);
|
||||
skippedCount++;
|
||||
|
|
@ -580,6 +581,7 @@ public class AssessmentRecordService : IAssessmentRecordService
|
|||
|
||||
// 重置状态为 3(生成中)
|
||||
record.Status = 3;
|
||||
record.ReportUrl = null;
|
||||
record.UpdateTime = DateTime.Now;
|
||||
|
||||
// 清除已有的测评结果数据
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@
|
|||
下载PDF
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 3 || row.status === 5"
|
||||
v-if="row.status === 3 || row.status === 4 || row.status === 5"
|
||||
type="warning"
|
||||
link
|
||||
size="small"
|
||||
|
|
@ -678,7 +678,7 @@ function handleViewWebReport(row: AssessmentRecordItem) {
|
|||
/** 在新标签页查看 PDF 报告 */
|
||||
function handleViewPdf(row: AssessmentRecordItem) {
|
||||
if (row.reportUrl) {
|
||||
window.open(row.reportUrl, '_blank')
|
||||
window.open(buildReportFileUrl(row.reportUrl), '_blank')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -686,7 +686,7 @@ function handleViewPdf(row: AssessmentRecordItem) {
|
|||
function handleDownloadPdf(row: AssessmentRecordItem) {
|
||||
if (!row.reportUrl) return
|
||||
const link = document.createElement('a')
|
||||
link.href = row.reportUrl
|
||||
link.href = buildReportFileUrl(row.reportUrl)
|
||||
link.download = `测评报告_${row.name}_${row.id}.pdf`
|
||||
link.target = '_blank'
|
||||
document.body.appendChild(link)
|
||||
|
|
@ -694,6 +694,21 @@ function handleDownloadPdf(row: AssessmentRecordItem) {
|
|||
document.body.removeChild(link)
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建报告文件完整URL
|
||||
* 如果 reportUrl 已经是完整URL(http开头)则直接返回,否则拼接 ApiBaseUrl
|
||||
*/
|
||||
function buildReportFileUrl(reportUrl: string): string {
|
||||
if (reportUrl.startsWith('http://') || reportUrl.startsWith('https://')) {
|
||||
return reportUrl
|
||||
}
|
||||
const baseUrl = getApiBaseUrl()
|
||||
if (!baseUrl) {
|
||||
return reportUrl
|
||||
}
|
||||
return `${baseUrl.replace(/\/+$/, '')}${reportUrl.startsWith('/') ? '' : '/'}${reportUrl}`
|
||||
}
|
||||
|
||||
/** 表格选择变化 */
|
||||
function handleSelectionChange(rows: AssessmentRecordItem[]) {
|
||||
state.selectedRows = rows
|
||||
|
|
@ -723,7 +738,7 @@ async function handleRegenerate(row: AssessmentRecordItem) {
|
|||
|
||||
/** 批量重新生成报告 */
|
||||
async function handleBatchRegenerate() {
|
||||
const eligibleRows = state.selectedRows.filter(r => r.status === 3 || r.status === 5)
|
||||
const eligibleRows = state.selectedRows.filter(r => r.status === 3 || r.status === 4 || r.status === 5)
|
||||
if (eligibleRows.length === 0) {
|
||||
ElMessage.warning('请先勾选状态为"生成中"或"生成失败"的记录')
|
||||
return
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
}
|
||||
},
|
||||
"SiteSettings": {
|
||||
"ApiBaseUrl": ""
|
||||
"ApiBaseUrl": "https://api.nxt.shhmkjgs.cn"
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Serilog": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user