feat(testReport): 新增台账导入功能并重构报告任务表单
- 新增台账导入面板组件,支持Excel模板下载和批量导入 - 在报告任务表单中集成三步式流程(导入→填写→完成) - 添加导入结果预览和分组报告状态展示功能 - 扩展API接口支持台账导入和分组报告查询 - 优化表单验证逻辑,移除送资数据必填限制 - 集成日志面板实时显示导入过程状态 - 更新测试报告页面契约验证规则 - 添加监测点数和分组数统计展示 - 实现台账准备状态检查和快照功能
This commit is contained in:
@@ -8,7 +8,7 @@ export const listReportTasksApi = (params: ReportTask.ReportTaskListParams) => {
|
|||||||
return http.post(`${REPORT_TASK_BASE_URL}/list`, params)
|
return http.post(`${REPORT_TASK_BASE_URL}/list`, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createReportTaskApi = (params: ReportTask.ReportTaskSaveRequest) => {
|
export const createReportTaskApi = (params: ReportTask.ReportTaskAddParam) => {
|
||||||
return http.post<boolean>(`${REPORT_TASK_BASE_URL}/add`, params)
|
return http.post<boolean>(`${REPORT_TASK_BASE_URL}/add`, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,3 +30,18 @@ export const exportReportTasksApi = (params: ReportTask.ReportTaskListParams): P
|
|||||||
export const submitReportTaskAuditApi = (params: ReportTask.ReportTaskAuditRequest) => {
|
export const submitReportTaskAuditApi = (params: ReportTask.ReportTaskAuditRequest) => {
|
||||||
return http.post<boolean>(`${REPORT_TASK_BASE_URL}/submit-audit`, params)
|
return http.post<boolean>(`${REPORT_TASK_BASE_URL}/submit-audit`, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const downloadReportTaskLedgerTemplateApi = (): Promise<AxiosResponse<Blob>> =>
|
||||||
|
http.get(`${REPORT_TASK_BASE_URL}/ledger/template`, undefined, {
|
||||||
|
responseType: 'blob'
|
||||||
|
}) as unknown as Promise<AxiosResponse<Blob>>
|
||||||
|
|
||||||
|
export const importReportTaskLedgerApi = (id: string, formData: FormData) => {
|
||||||
|
return http.post<ReportTask.ReportTaskLedgerImportResult>(`${REPORT_TASK_BASE_URL}/${id}/ledger/import`, formData, {
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const listReportTaskGroupReportsApi = (id: string) => {
|
||||||
|
return http.get<ReportTask.ReportTaskGroupReportRecord[]>(`${REPORT_TASK_BASE_URL}/${id}/group-report/list`)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
export namespace ReportTask {
|
export namespace ReportTask {
|
||||||
|
export type ReportTaskGroupReportGenerateState = 0 | 1 | 2 | 3
|
||||||
|
export type ReportTaskLedgerImportStage =
|
||||||
|
| '选择文件'
|
||||||
|
| '校验文件'
|
||||||
|
| '文件上传'
|
||||||
|
| '基础资料维护'
|
||||||
|
| '完成'
|
||||||
|
|
||||||
export interface ReportTaskRecord {
|
export interface ReportTaskRecord {
|
||||||
id?: string
|
id?: string
|
||||||
no?: string | null
|
no?: string | null
|
||||||
@@ -16,12 +24,16 @@ export namespace ReportTask {
|
|||||||
checkTime?: string | null
|
checkTime?: string | null
|
||||||
checkResult?: string | null
|
checkResult?: string | null
|
||||||
status?: number
|
status?: number
|
||||||
|
pointCount?: number | null
|
||||||
|
groupCount?: number | null
|
||||||
|
reportGenerateState?: number | null
|
||||||
createBy?: string | null
|
createBy?: string | null
|
||||||
createByName?: string | null
|
createByName?: string | null
|
||||||
createTime?: string | null
|
createTime?: string | null
|
||||||
updateBy?: string | null
|
updateBy?: string | null
|
||||||
updateByName?: string | null
|
updateByName?: string | null
|
||||||
updateTime?: string | null
|
updateTime?: string | null
|
||||||
|
groupReports?: ReportTaskGroupReportRecord[] | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReportTaskListParams {
|
export interface ReportTaskListParams {
|
||||||
@@ -33,7 +45,7 @@ export namespace ReportTask {
|
|||||||
pageSize?: number
|
pageSize?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReportTaskSaveRequest {
|
export interface ReportTaskAddParam {
|
||||||
id?: string
|
id?: string
|
||||||
no: string
|
no: string
|
||||||
clientUnitId: string
|
clientUnitId: string
|
||||||
@@ -45,8 +57,102 @@ export namespace ReportTask {
|
|||||||
phonenumber?: string
|
phonenumber?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ReportTaskSaveRequest extends ReportTaskAddParam {}
|
||||||
|
|
||||||
export interface ReportTaskAuditRequest {
|
export interface ReportTaskAuditRequest {
|
||||||
id: string
|
id: string
|
||||||
checkResult?: string
|
checkResult?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ReportTaskLedgerImportStageRecord {
|
||||||
|
stage?: ReportTaskLedgerImportStage | string | null
|
||||||
|
success?: boolean | null
|
||||||
|
message?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReportTaskLedgerImportSnapshotGroupRecord {
|
||||||
|
groupNo?: number | null
|
||||||
|
count?: number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReportTaskLedgerImportSnapshot {
|
||||||
|
version?: string | null
|
||||||
|
importMode?: string | null
|
||||||
|
summaryFileName?: string | null
|
||||||
|
sheetSummary?: {
|
||||||
|
pointSheet?: string | null
|
||||||
|
deviceSheetPresent?: boolean | null
|
||||||
|
clientSheetPresent?: boolean | null
|
||||||
|
} | null
|
||||||
|
rowCount?: number | null
|
||||||
|
groupSummary?: ReportTaskLedgerImportSnapshotGroupRecord[] | null
|
||||||
|
baseDataSummary?: {
|
||||||
|
deviceAddedCount?: number | null
|
||||||
|
deviceReuseCount?: number | null
|
||||||
|
clientAddedCount?: number | null
|
||||||
|
clientReuseCount?: number | null
|
||||||
|
} | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReportTaskLedgerImportResult {
|
||||||
|
currentStage?: ReportTaskLedgerImportStage | string | null
|
||||||
|
success?: boolean | null
|
||||||
|
summaryFileName?: string | null
|
||||||
|
totalFileCount?: number
|
||||||
|
pointCount?: number
|
||||||
|
excelAttachmentCount?: number
|
||||||
|
wordAttachmentCount?: number
|
||||||
|
deviceAddedCount?: number
|
||||||
|
deviceReuseCount?: number
|
||||||
|
clientAddedCount?: number
|
||||||
|
clientReuseCount?: number
|
||||||
|
groupCount?: number
|
||||||
|
failReasons?: string[] | null
|
||||||
|
stages?: ReportTaskLedgerImportStageRecord[] | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReportTaskPointRecord {
|
||||||
|
id?: string
|
||||||
|
groupNo?: number | null
|
||||||
|
substationName?: string | null
|
||||||
|
pointName?: string | null
|
||||||
|
monitorTime?: string | null
|
||||||
|
voltageLevel?: string | null
|
||||||
|
ptRatio?: string | null
|
||||||
|
ctRatio?: string | null
|
||||||
|
baseShortCircuitCapacity?: string | null
|
||||||
|
minShortCircuitCapacity?: string | null
|
||||||
|
protocolCapacity?: string | null
|
||||||
|
powerSupplyCapacity?: string | null
|
||||||
|
excelAttachmentName?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReportTaskPointGroupItem {
|
||||||
|
groupNo: number
|
||||||
|
pointIds: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReportTaskGroupSaveRequest {
|
||||||
|
groups: ReportTaskPointGroupItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReportTaskGroupReportRecord {
|
||||||
|
id?: string
|
||||||
|
groupNo?: number | null
|
||||||
|
reportName?: string | null
|
||||||
|
reportFileName?: string | null
|
||||||
|
reportStoragePath?: string | null
|
||||||
|
generateState?: ReportTaskGroupReportGenerateState | null
|
||||||
|
generateMessage?: string | null
|
||||||
|
generateTime?: string | null
|
||||||
|
sortNo?: number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReportTaskLedgerPreparedState {
|
||||||
|
draftId: string
|
||||||
|
latestImportResult: ReportTaskLedgerImportResult | null
|
||||||
|
snapshot: ReportTaskLedgerImportSnapshot | null
|
||||||
|
hasImported: boolean
|
||||||
|
pendingReimport: boolean
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog v-model="visibleProxy" title="报告任务详情" width="760px" append-to-body destroy-on-close>
|
<el-dialog v-model="visibleProxy" title="报告任务详情" width="880px" append-to-body destroy-on-close>
|
||||||
<div v-loading="loading" class="report-task-detail-dialog">
|
<div v-loading="loading" class="report-task-detail-dialog">
|
||||||
<el-descriptions class="detail-descriptions" :column="2" border>
|
<el-descriptions class="detail-descriptions" :column="2" border>
|
||||||
<el-descriptions-item label="报告编号">{{ resolveReportTaskText(detail?.no) }}</el-descriptions-item>
|
<el-descriptions-item label="报告编号">{{ resolveReportTaskText(detail?.no) }}</el-descriptions-item>
|
||||||
@@ -14,6 +14,8 @@
|
|||||||
{{ resolveReportTaskStandardText(detail?.standard, standardLabelMap) }}
|
{{ resolveReportTaskStandardText(detail?.standard, standardLabelMap) }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="送资数据" :span="2">{{ resolveReportTaskText(detail?.data) }}</el-descriptions-item>
|
<el-descriptions-item label="送资数据" :span="2">{{ resolveReportTaskText(detail?.data) }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="监测点数量">{{ resolveReportTaskText(detail?.pointCount) }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="分组数量">{{ resolveReportTaskText(detail?.groupCount) }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="审核人">{{ resolveReportTaskText(detail?.checkerName) }}</el-descriptions-item>
|
<el-descriptions-item label="审核人">{{ resolveReportTaskText(detail?.checkerName) }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="审核时间">{{ resolveReportTaskText(detail?.checkTime) }}</el-descriptions-item>
|
<el-descriptions-item label="审核时间">{{ resolveReportTaskText(detail?.checkTime) }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="审核意见" :span="2">{{ resolveReportTaskText(detail?.checkResult) }}</el-descriptions-item>
|
<el-descriptions-item label="审核意见" :span="2">{{ resolveReportTaskText(detail?.checkResult) }}</el-descriptions-item>
|
||||||
@@ -26,6 +28,24 @@
|
|||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="更新时间">{{ resolveReportTaskText(detail?.updateTime) }}</el-descriptions-item>
|
<el-descriptions-item label="更新时间">{{ resolveReportTaskText(detail?.updateTime) }}</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
|
|
||||||
|
<div class="group-report-section">
|
||||||
|
<div class="group-report-title">分组报告生成状态</div>
|
||||||
|
<el-empty v-if="!groupReports.length" description="暂无分组报告记录" :image-size="88" />
|
||||||
|
<el-table v-else :data="groupReports" border size="small">
|
||||||
|
<el-table-column prop="groupNo" label="分组号" width="100" />
|
||||||
|
<el-table-column prop="reportName" label="报告名称" min-width="180" show-overflow-tooltip />
|
||||||
|
<el-table-column label="生成状态" width="120">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag :type="resolveReportTaskGroupReportGenerateStateTagType(row.generateState)">
|
||||||
|
{{ resolveReportTaskGroupReportGenerateStateText(row.generateState) }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="generateMessage" label="生成消息" min-width="180" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="generateTime" label="生成时间" min-width="160" show-overflow-tooltip />
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button type="primary" @click="visibleProxy = false">关闭</el-button>
|
<el-button type="primary" @click="visibleProxy = false">关闭</el-button>
|
||||||
@@ -38,6 +58,8 @@ import { computed } from 'vue'
|
|||||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||||
import {
|
import {
|
||||||
resolveReportTaskCreateUnitText,
|
resolveReportTaskCreateUnitText,
|
||||||
|
resolveReportTaskGroupReportGenerateStateTagType,
|
||||||
|
resolveReportTaskGroupReportGenerateStateText,
|
||||||
resolveReportTaskStandardText,
|
resolveReportTaskStandardText,
|
||||||
resolveReportTaskText
|
resolveReportTaskText
|
||||||
} from '../utils/testReport'
|
} from '../utils/testReport'
|
||||||
@@ -50,6 +72,7 @@ const props = defineProps<{
|
|||||||
visible: boolean
|
visible: boolean
|
||||||
loading: boolean
|
loading: boolean
|
||||||
detail: ReportTask.ReportTaskRecord | null
|
detail: ReportTask.ReportTaskRecord | null
|
||||||
|
groupReports: ReportTask.ReportTaskGroupReportRecord[]
|
||||||
companyLabelMap: Record<string, string>
|
companyLabelMap: Record<string, string>
|
||||||
standardLabelMap: Record<string, string>
|
standardLabelMap: Record<string, string>
|
||||||
}>()
|
}>()
|
||||||
@@ -65,6 +88,7 @@ const visibleProxy = computed({
|
|||||||
|
|
||||||
const companyLabelMap = computed(() => props.companyLabelMap)
|
const companyLabelMap = computed(() => props.companyLabelMap)
|
||||||
const standardLabelMap = computed(() => props.standardLabelMap)
|
const standardLabelMap = computed(() => props.standardLabelMap)
|
||||||
|
const groupReports = computed(() => props.groupReports || [])
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -80,4 +104,15 @@ const standardLabelMap = computed(() => props.standardLabelMap)
|
|||||||
.report-task-detail-dialog :deep(.detail-descriptions .el-descriptions__label.el-descriptions__cell.is-bordered-label) {
|
.report-task-detail-dialog :deep(.detail-descriptions .el-descriptions__label.el-descriptions__cell.is-bordered-label) {
|
||||||
width: 112px;
|
width: 112px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.group-report-section {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-report-title {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--el-text-color-primary);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,127 +2,258 @@
|
|||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="visibleProxy"
|
v-model="visibleProxy"
|
||||||
:title="mode === 'create' ? '新增报告任务' : '编辑报告任务'"
|
:title="mode === 'create' ? '新增报告任务' : '编辑报告任务'"
|
||||||
width="720px"
|
width="1080px"
|
||||||
append-to-body
|
append-to-body
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
|
class="report-task-flow-dialog"
|
||||||
@closed="resetForm"
|
@closed="resetForm"
|
||||||
>
|
>
|
||||||
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="108px" class="report-task-form">
|
<div class="report-task-form-dialog">
|
||||||
<el-row :gutter="16">
|
<div class="flow-nav">
|
||||||
<el-col :xs="24" :sm="12">
|
<button
|
||||||
<el-form-item label="报告编号" prop="no">
|
v-for="step in REPORT_TASK_FORM_STEPS"
|
||||||
<el-input v-model="formModel.no" maxlength="32" clearable placeholder="请输入报告编号" />
|
:key="step.value"
|
||||||
</el-form-item>
|
type="button"
|
||||||
</el-col>
|
class="flow-step"
|
||||||
<el-col :xs="24" :sm="12">
|
:class="[`is-${resolveStepStatus(step.value)}`, { 'is-clickable': canSwitchStep(step.value) }]"
|
||||||
<el-form-item label="委托单位" prop="clientUnitId">
|
:disabled="!canSwitchStep(step.value)"
|
||||||
<el-select v-model="formModel.clientUnitId" filterable clearable placeholder="请选择委托单位">
|
@click="handleStepClick(step.value)"
|
||||||
<el-option
|
>
|
||||||
v-for="option in clientUnitSelectOptions"
|
<span class="flow-step-index">{{ step.index }}</span>
|
||||||
:key="option.value"
|
<span class="flow-step-content">
|
||||||
:label="option.label"
|
<span class="flow-step-title">{{ step.title }}</span>
|
||||||
:value="option.value"
|
<span class="flow-step-desc">{{ step.description }}</span>
|
||||||
/>
|
</span>
|
||||||
</el-select>
|
</button>
|
||||||
</el-form-item>
|
</div>
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12">
|
<div class="flow-main">
|
||||||
<el-form-item label="报告模板" prop="reportModelId">
|
<div v-if="currentStep === 'import'" class="flow-panel">
|
||||||
<el-select v-model="formModel.reportModelId" filterable clearable placeholder="请选择报告模板">
|
<ReportTaskLedgerImportPanel
|
||||||
<el-option
|
:draft-id="activeDraftId"
|
||||||
v-for="option in reportModelSelectOptions"
|
:disabled="saving"
|
||||||
:key="option.value"
|
:prepared-state="ledgerPreparedState"
|
||||||
:label="option.label"
|
:snapshot="ledgerSnapshot"
|
||||||
:value="option.value"
|
@change="handleLedgerPreparedChange"
|
||||||
/>
|
@log="handleLog"
|
||||||
</el-select>
|
/>
|
||||||
</el-form-item>
|
</div>
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12">
|
<div v-else-if="currentStep === 'form'" class="flow-panel">
|
||||||
<el-form-item label="检测公司" prop="createUnit">
|
<div class="form-panel">
|
||||||
<el-select v-model="formModel.createUnit" filterable clearable placeholder="请选择检测公司">
|
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="108px" class="report-task-form">
|
||||||
<el-option
|
<el-row :gutter="16">
|
||||||
v-for="option in companySelectOptions"
|
<el-col :xs="24" :sm="12">
|
||||||
:key="option.value"
|
<el-form-item label="报告编号" prop="no">
|
||||||
:label="option.label"
|
<el-input v-model="formModel.no" maxlength="32" clearable placeholder="请输入报告编号" />
|
||||||
:value="option.value"
|
</el-form-item>
|
||||||
/>
|
</el-col>
|
||||||
</el-select>
|
<el-col :xs="24" :sm="12">
|
||||||
</el-form-item>
|
<el-form-item label="委托单位" prop="clientUnitId">
|
||||||
</el-col>
|
<el-select v-model="formModel.clientUnitId" filterable clearable placeholder="请选择委托单位">
|
||||||
<el-col :xs="24" :sm="12">
|
<el-option
|
||||||
<el-form-item label="合同编号" prop="contractNumber">
|
v-for="option in clientUnitSelectOptions"
|
||||||
<el-input v-model="formModel.contractNumber" maxlength="32" clearable placeholder="请输入合同编号" />
|
:key="option.value"
|
||||||
</el-form-item>
|
:label="option.label"
|
||||||
</el-col>
|
:value="option.value"
|
||||||
<el-col :xs="24" :sm="12">
|
/>
|
||||||
<el-form-item label="测试依据" prop="standardIds">
|
</el-select>
|
||||||
<el-select
|
</el-form-item>
|
||||||
v-model="formModel.standardIds"
|
</el-col>
|
||||||
multiple
|
<el-col :xs="24" :sm="12">
|
||||||
filterable
|
<el-form-item label="报告模板" prop="reportModelId">
|
||||||
clearable
|
<el-select v-model="formModel.reportModelId" filterable clearable placeholder="请选择报告模板">
|
||||||
collapse-tags
|
<el-option
|
||||||
placeholder="请选择测试依据"
|
v-for="option in reportModelSelectOptions"
|
||||||
>
|
:key="option.value"
|
||||||
<el-option
|
:label="option.label"
|
||||||
v-for="option in standardSelectOptions"
|
:value="option.value"
|
||||||
:key="option.value"
|
/>
|
||||||
:label="option.label"
|
</el-select>
|
||||||
:value="option.value"
|
</el-form-item>
|
||||||
>
|
</el-col>
|
||||||
<div class="standard-option">
|
<el-col :xs="24" :sm="12">
|
||||||
<el-checkbox
|
<el-form-item label="检测公司" prop="createUnit">
|
||||||
class="standard-option-checkbox"
|
<el-select v-model="formModel.createUnit" filterable clearable placeholder="请选择检测公司">
|
||||||
:model-value="formModel.standardIds.includes(option.value)"
|
<el-option
|
||||||
/>
|
v-for="option in companySelectOptions"
|
||||||
<span class="standard-option-label">{{ option.label }}</span>
|
:key="option.value"
|
||||||
</div>
|
:label="option.label"
|
||||||
</el-option>
|
:value="option.value"
|
||||||
</el-select>
|
/>
|
||||||
</el-form-item>
|
</el-select>
|
||||||
</el-col>
|
</el-form-item>
|
||||||
<el-col :xs="24" :sm="12">
|
</el-col>
|
||||||
<el-form-item label="联系电话" prop="phonenumber">
|
<el-col :xs="24" :sm="12">
|
||||||
<el-input v-model="formModel.phonenumber" maxlength="32" clearable placeholder="请输入联系电话" />
|
<el-form-item label="合同编号" prop="contractNumber">
|
||||||
</el-form-item>
|
<el-input v-model="formModel.contractNumber" maxlength="32" clearable placeholder="请输入合同编号" />
|
||||||
</el-col>
|
</el-form-item>
|
||||||
<el-col :span="24">
|
</el-col>
|
||||||
<el-form-item label="送资数据" prop="data">
|
<el-col :xs="24" :sm="12">
|
||||||
<el-input
|
<el-form-item label="测试依据" prop="standardIds">
|
||||||
v-model="formModel.data"
|
<el-select
|
||||||
type="textarea"
|
v-model="formModel.standardIds"
|
||||||
:rows="4"
|
multiple
|
||||||
maxlength="256"
|
filterable
|
||||||
show-word-limit
|
clearable
|
||||||
placeholder="请输入送资数据"
|
collapse-tags
|
||||||
|
placeholder="请选择测试依据"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="option in standardSelectOptions"
|
||||||
|
:key="option.value"
|
||||||
|
:label="option.label"
|
||||||
|
:value="option.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="12">
|
||||||
|
<el-form-item label="联系电话" prop="phonenumber">
|
||||||
|
<el-input v-model="formModel.phonenumber" maxlength="32" clearable placeholder="请输入联系电话" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<div class="summary-strip">
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">导入状态</span>
|
||||||
|
<el-tag :type="canSubmit ? 'success' : 'warning'">
|
||||||
|
{{ canSubmit ? '已准备提交' : '待完成台账导入' }}
|
||||||
|
</el-tag>
|
||||||
|
</div>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">监测点数</span>
|
||||||
|
<span class="summary-value">{{ importSummary.pointCount }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">分组数</span>
|
||||||
|
<span class="summary-value">{{ importSummary.groupCount }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">汇总文件</span>
|
||||||
|
<span class="summary-value">{{ importSummary.summaryFileName }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="flow-panel">
|
||||||
|
<div class="complete-panel">
|
||||||
|
<el-result
|
||||||
|
icon="success"
|
||||||
|
:title="mode === 'create' ? '报告任务新增完成' : '报告任务编辑完成'"
|
||||||
|
sub-title="台账导入与基础信息保存均已完成,本次结果已同步刷新到列表。"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
<el-descriptions :column="2" border>
|
||||||
</el-row>
|
<el-descriptions-item label="报告编号">{{ formModel.no || '-' }}</el-descriptions-item>
|
||||||
</el-form>
|
<el-descriptions-item label="委托单位">
|
||||||
|
{{ resolveCurrentOptionLabel(clientUnitSelectOptions, formModel.clientUnitId) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="检测公司">
|
||||||
|
{{ resolveCurrentOptionLabel(companySelectOptions, formModel.createUnit) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="监测点数">{{ importSummary.pointCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="分组数">{{ importSummary.groupCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="汇总文件">{{ importSummary.summaryFileName }}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="log-panel" :class="{ 'is-collapsed': !logPanelExpanded }">
|
||||||
|
<button type="button" class="log-panel-header" @click="logPanelExpanded = !logPanelExpanded">
|
||||||
|
<span class="log-panel-toggle" :class="{ 'is-collapsed': !logPanelExpanded }" aria-hidden="true"></span>
|
||||||
|
<div class="log-title">日志信息</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div v-show="logPanelExpanded" class="log-panel-body">
|
||||||
|
<div class="log-popover-body">
|
||||||
|
<div v-if="logEntries.length" class="log-list">
|
||||||
|
<div v-for="entry in logEntries" :key="entry.id" class="log-item">
|
||||||
|
<div class="log-meta">
|
||||||
|
<el-tag size="small" :type="resolveLogTagType(entry.type)">{{ resolveLogTypeText(entry.type) }}</el-tag>
|
||||||
|
<span class="log-time">{{ entry.time }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="log-message">{{ entry.message }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-empty v-else description="当前暂无日志输出" :image-size="60" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button :disabled="saving" @click="visibleProxy = false">取消</el-button>
|
<el-button :disabled="saving" @click="visibleProxy = false">{{ currentStep === 'done' ? '关闭' : '取消' }}</el-button>
|
||||||
<el-button type="primary" :loading="saving" @click="submitForm">确定</el-button>
|
|
||||||
|
<template v-if="currentStep === 'import'">
|
||||||
|
<el-button type="primary" :disabled="!canSubmit" @click="goToFormStep">下一步</el-button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-else-if="currentStep === 'form'">
|
||||||
|
<el-button type="primary" plain :disabled="saving" @click="goToImportStep">返回导入</el-button>
|
||||||
|
<el-button type="primary" :loading="saving" :disabled="!canSubmit" @click="submitForm">提交</el-button>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { type FormInstance, type FormRules } from 'element-plus'
|
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||||
import { computed, reactive, ref, watch } from 'vue'
|
import { computed, reactive, ref, watch } from 'vue'
|
||||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||||
import { parseReportTaskStandardIds, stringifyReportTaskStandardIds } from '../utils/testReport'
|
import { generateUUID } from '@/utils'
|
||||||
|
import ReportTaskLedgerImportPanel from './ReportTaskLedgerImportPanel.vue'
|
||||||
|
import {
|
||||||
|
checkReportTaskLedgerPrepared,
|
||||||
|
getReportTaskErrorMessage,
|
||||||
|
normalizeReportTaskLedgerSnapshot,
|
||||||
|
parseReportTaskStandardIds,
|
||||||
|
stringifyReportTaskStandardIds
|
||||||
|
} from '../utils/testReport'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'ReportTaskFormDialog'
|
name: 'ReportTaskFormDialog'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
type ReportTaskFormStep = 'import' | 'form' | 'done'
|
||||||
|
type ReportTaskLogType = 'info' | 'success' | 'warning' | 'error'
|
||||||
|
|
||||||
|
const REPORT_TASK_FORM_STEPS: Array<{
|
||||||
|
index: number
|
||||||
|
value: ReportTaskFormStep
|
||||||
|
title: string
|
||||||
|
description: string
|
||||||
|
}> = [
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
value: 'import',
|
||||||
|
title: '数据导入',
|
||||||
|
description: '先完成台账与附件导入'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 2,
|
||||||
|
value: 'form',
|
||||||
|
title: '基础信息填写',
|
||||||
|
description: '填写并确认任务基础信息'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 3,
|
||||||
|
value: 'done',
|
||||||
|
title: '完成',
|
||||||
|
description: '查看结果并结束本次流程'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
visible: boolean
|
visible: boolean
|
||||||
mode: 'create' | 'edit'
|
mode: 'create' | 'edit'
|
||||||
record: ReportTask.ReportTaskRecord | null
|
record: ReportTask.ReportTaskRecord | null
|
||||||
saving: boolean
|
saving: boolean
|
||||||
|
saveSuccessVersion: number
|
||||||
clientUnitOptions: Array<{ label: string; value: string }>
|
clientUnitOptions: Array<{ label: string; value: string }>
|
||||||
reportModelOptions: Array<{ label: string; value: string }>
|
reportModelOptions: Array<{ label: string; value: string }>
|
||||||
companyOptions: Array<{ label: string; value: string }>
|
companyOptions: Array<{ label: string; value: string }>
|
||||||
@@ -135,6 +266,19 @@ const emit = defineEmits<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
const formRef = ref<FormInstance>()
|
const formRef = ref<FormInstance>()
|
||||||
|
const activeDraftId = ref('')
|
||||||
|
const currentStep = ref<ReportTaskFormStep>('import')
|
||||||
|
const logPanelExpanded = ref(true)
|
||||||
|
const logEntries = ref<Array<{ id: string; type: ReportTaskLogType; time: string; message: string }>>([])
|
||||||
|
const ledgerPreparedState = ref<ReportTask.ReportTaskLedgerPreparedState>({
|
||||||
|
draftId: '',
|
||||||
|
latestImportResult: null,
|
||||||
|
snapshot: null,
|
||||||
|
hasImported: false,
|
||||||
|
pendingReimport: false
|
||||||
|
})
|
||||||
|
const lastHandledSaveSuccessVersion = ref(0)
|
||||||
|
|
||||||
const formModel = reactive({
|
const formModel = reactive({
|
||||||
id: '',
|
id: '',
|
||||||
no: '',
|
no: '',
|
||||||
@@ -153,8 +297,7 @@ const formRules: FormRules = {
|
|||||||
reportModelId: [{ required: true, message: '请选择报告模板', trigger: 'change' }],
|
reportModelId: [{ required: true, message: '请选择报告模板', trigger: 'change' }],
|
||||||
createUnit: [{ required: true, message: '请选择检测公司', trigger: 'change' }],
|
createUnit: [{ required: true, message: '请选择检测公司', trigger: 'change' }],
|
||||||
contractNumber: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
|
contractNumber: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
|
||||||
standardIds: [{ required: true, message: '请选择测试依据', trigger: 'change' }],
|
standardIds: [{ required: true, message: '请选择测试依据', trigger: 'change' }]
|
||||||
data: [{ required: true, message: '请输入送资数据', trigger: 'blur' }]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const visibleProxy = computed({
|
const visibleProxy = computed({
|
||||||
@@ -162,6 +305,19 @@ const visibleProxy = computed({
|
|||||||
set: value => emit('update:visible', value)
|
set: value => emit('update:visible', value)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const ledgerSnapshot = computed(() => ledgerPreparedState.value.snapshot)
|
||||||
|
const canSubmit = computed(() => !props.saving && checkReportTaskLedgerPrepared(ledgerPreparedState.value))
|
||||||
|
const importSummary = computed(() => {
|
||||||
|
const importResult = ledgerPreparedState.value.latestImportResult
|
||||||
|
const snapshot = ledgerPreparedState.value.snapshot
|
||||||
|
|
||||||
|
return {
|
||||||
|
pointCount: String(importResult?.pointCount ?? snapshot?.rowCount ?? '-'),
|
||||||
|
groupCount: String(importResult?.groupCount ?? snapshot?.groupSummary?.length ?? '-'),
|
||||||
|
summaryFileName: importResult?.summaryFileName || snapshot?.summaryFileName || '-'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const ensureCurrentOption = (
|
const ensureCurrentOption = (
|
||||||
options: Array<{ label: string; value: string }>,
|
options: Array<{ label: string; value: string }>,
|
||||||
value: string,
|
value: string,
|
||||||
@@ -190,6 +346,38 @@ const standardSelectOptions = computed(() => {
|
|||||||
return [...props.standardOptions, ...extraOptions]
|
return [...props.standardOptions, ...extraOptions]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const buildLogId = () => window.crypto?.randomUUID?.() || generateUUID()
|
||||||
|
|
||||||
|
const pushLog = (type: ReportTaskLogType, message: string) => {
|
||||||
|
logEntries.value.push({
|
||||||
|
id: buildLogId(),
|
||||||
|
type,
|
||||||
|
time: new Date().toLocaleTimeString('zh-CN', { hour12: false }),
|
||||||
|
message
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleLog = (payload: { type: ReportTaskLogType; message: string }) => {
|
||||||
|
pushLog(payload.type, payload.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolveCurrentOptionLabel = (options: Array<{ label: string; value: string }>, value: string) =>
|
||||||
|
options.find(option => option.value === value)?.label || value || '-'
|
||||||
|
|
||||||
|
const resolveLogTagType = (type: ReportTaskLogType) => {
|
||||||
|
if (type === 'success') return 'success'
|
||||||
|
if (type === 'warning') return 'warning'
|
||||||
|
if (type === 'error') return 'danger'
|
||||||
|
return 'info'
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolveLogTypeText = (type: ReportTaskLogType) => {
|
||||||
|
if (type === 'success') return '成功'
|
||||||
|
if (type === 'warning') return '警告'
|
||||||
|
if (type === 'error') return '错误'
|
||||||
|
return '信息'
|
||||||
|
}
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
formRef.value?.clearValidate()
|
formRef.value?.clearValidate()
|
||||||
formModel.id = ''
|
formModel.id = ''
|
||||||
@@ -201,35 +389,166 @@ const resetForm = () => {
|
|||||||
formModel.standardIds = []
|
formModel.standardIds = []
|
||||||
formModel.data = ''
|
formModel.data = ''
|
||||||
formModel.phonenumber = ''
|
formModel.phonenumber = ''
|
||||||
|
activeDraftId.value = ''
|
||||||
|
currentStep.value = 'import'
|
||||||
|
logPanelExpanded.value = true
|
||||||
|
logEntries.value = []
|
||||||
|
ledgerPreparedState.value = {
|
||||||
|
draftId: '',
|
||||||
|
latestImportResult: null,
|
||||||
|
snapshot: null,
|
||||||
|
hasImported: false,
|
||||||
|
pendingReimport: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fillForm = () => {
|
const buildDraftId = () => {
|
||||||
formModel.id = props.record?.id || ''
|
if (props.mode === 'edit') {
|
||||||
formModel.no = props.record?.no || ''
|
return String(props.record?.id || '').trim()
|
||||||
formModel.clientUnitId = props.record?.clientUnitId || ''
|
}
|
||||||
formModel.reportModelId = props.record?.reportModelId || ''
|
|
||||||
formModel.createUnit = props.record?.createUnit || ''
|
return window.crypto?.randomUUID?.() || generateUUID()
|
||||||
formModel.contractNumber = props.record?.contractNumber || ''
|
}
|
||||||
formModel.standardIds = parseReportTaskStandardIds(props.record?.standard)
|
|
||||||
formModel.data = props.record?.data || ''
|
const applyInitialStep = (hasPreparedLedger: boolean) => {
|
||||||
formModel.phonenumber = props.record?.phonenumber || ''
|
if (props.mode === 'edit' && hasPreparedLedger) {
|
||||||
|
currentStep.value = 'form'
|
||||||
|
pushLog('info', '编辑场景检测到已有导入结果,默认进入基础信息填写步骤')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
currentStep.value = 'import'
|
||||||
|
pushLog('info', '已进入数据导入步骤,请先完成台账导入')
|
||||||
|
}
|
||||||
|
|
||||||
|
const fillForm = async () => {
|
||||||
|
try {
|
||||||
|
const record = props.record
|
||||||
|
const snapshot = normalizeReportTaskLedgerSnapshot(record?.data)
|
||||||
|
|
||||||
|
formModel.id = record?.id || ''
|
||||||
|
formModel.no = record?.no || ''
|
||||||
|
formModel.clientUnitId = record?.clientUnitId || ''
|
||||||
|
formModel.reportModelId = record?.reportModelId || ''
|
||||||
|
formModel.createUnit = record?.createUnit || ''
|
||||||
|
formModel.contractNumber = record?.contractNumber || ''
|
||||||
|
formModel.standardIds = parseReportTaskStandardIds(record?.standard)
|
||||||
|
formModel.data = record?.data || ''
|
||||||
|
formModel.phonenumber = record?.phonenumber || ''
|
||||||
|
|
||||||
|
activeDraftId.value = buildDraftId()
|
||||||
|
ledgerPreparedState.value = {
|
||||||
|
draftId: activeDraftId.value,
|
||||||
|
latestImportResult: null,
|
||||||
|
snapshot,
|
||||||
|
hasImported: Boolean(snapshot || Number(record?.pointCount) > 0),
|
||||||
|
pendingReimport: false
|
||||||
|
}
|
||||||
|
|
||||||
|
applyInitialStep(Boolean(snapshot || Number(record?.pointCount) > 0))
|
||||||
|
if (snapshot) {
|
||||||
|
pushLog('info', `已加载最近一次导入快照:${snapshot.summaryFileName || '未命名汇总文件'}`)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
const message = getReportTaskErrorMessage(error, '报告任务台账快照加载失败')
|
||||||
|
ElMessage.error(message)
|
||||||
|
pushLog('error', message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const goToFormStep = () => {
|
||||||
|
if (!canSubmit.value) {
|
||||||
|
pushLog('warning', '当前导入尚未完成,不能进入基础信息填写步骤')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
currentStep.value = 'form'
|
||||||
|
pushLog('info', '已切换到基础信息填写步骤')
|
||||||
|
}
|
||||||
|
|
||||||
|
const goToImportStep = () => {
|
||||||
|
currentStep.value = 'import'
|
||||||
|
pushLog('info', '已返回数据导入步骤,可继续沿用当前结果或重新导入台账')
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleLedgerPreparedChange = (value: ReportTask.ReportTaskLedgerPreparedState) => {
|
||||||
|
const wasPrepared = checkReportTaskLedgerPrepared(ledgerPreparedState.value)
|
||||||
|
const nextState = {
|
||||||
|
...value,
|
||||||
|
draftId: activeDraftId.value
|
||||||
|
}
|
||||||
|
|
||||||
|
ledgerPreparedState.value = nextState
|
||||||
|
|
||||||
|
if (!wasPrepared && checkReportTaskLedgerPrepared(nextState) && currentStep.value === 'import') {
|
||||||
|
currentStep.value = 'form'
|
||||||
|
pushLog('success', '台账导入已完成,已自动进入基础信息填写步骤')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const canSwitchStep = (step: ReportTaskFormStep) => {
|
||||||
|
if (step === 'import') return true
|
||||||
|
if (step === 'form') return canSubmit.value || currentStep.value === 'form' || currentStep.value === 'done'
|
||||||
|
return currentStep.value === 'done'
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleStepClick = (step: ReportTaskFormStep) => {
|
||||||
|
if (!canSwitchStep(step)) return
|
||||||
|
if (step === 'import') {
|
||||||
|
goToImportStep()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (step === 'form') {
|
||||||
|
goToFormStep()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolveStepStatus = (step: ReportTaskFormStep) => {
|
||||||
|
if (currentStep.value === step) return 'active'
|
||||||
|
if (step === 'import' && (currentStep.value === 'form' || currentStep.value === 'done')) return 'done'
|
||||||
|
if (step === 'form' && currentStep.value === 'done') return 'done'
|
||||||
|
return 'pending'
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [props.visible, props.mode, props.record?.id],
|
() => [props.visible, props.mode, props.record?.id],
|
||||||
([visible]) => {
|
async ([visible]) => {
|
||||||
if (visible) fillForm()
|
if (!visible) return
|
||||||
|
resetForm()
|
||||||
|
await fillForm()
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.saveSuccessVersion,
|
||||||
|
value => {
|
||||||
|
if (!props.visible || !value || value === lastHandledSaveSuccessVersion.value) return
|
||||||
|
|
||||||
|
lastHandledSaveSuccessVersion.value = value
|
||||||
|
currentStep.value = 'done'
|
||||||
|
pushLog('success', props.mode === 'create' ? '报告任务新增成功,流程已完成' : '报告任务编辑成功,流程已完成')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
const valid = await formRef.value?.validate().catch(() => false)
|
const valid = await formRef.value?.validate().catch(() => false)
|
||||||
|
if (!valid) {
|
||||||
|
pushLog('warning', '基础信息校验未通过,请检查必填项')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!valid) return
|
if (!checkReportTaskLedgerPrepared(ledgerPreparedState.value)) {
|
||||||
|
const message = '请先完成台账导入后再提交基础信息'
|
||||||
|
ElMessage.warning(message)
|
||||||
|
pushLog('warning', message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关键业务节点:当前弹窗只接受已完成 ledger/import 的任务,再执行最终 add/update 保存基础信息。
|
||||||
|
pushLog('info', props.mode === 'create' ? '开始提交新增任务基础信息' : '开始提交编辑后的任务基础信息')
|
||||||
emit('submit', {
|
emit('submit', {
|
||||||
id: formModel.id || undefined,
|
id: activeDraftId.value || formModel.id || undefined,
|
||||||
no: formModel.no.trim(),
|
no: formModel.no.trim(),
|
||||||
clientUnitId: formModel.clientUnitId,
|
clientUnitId: formModel.clientUnitId,
|
||||||
reportModelId: formModel.reportModelId,
|
reportModelId: formModel.reportModelId,
|
||||||
@@ -243,28 +562,341 @@ const submitForm = async () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
.report-task-form-dialog {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
min-height: 0;
|
||||||
|
padding-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-nav {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 0;
|
||||||
|
padding: 22px 18px 18px;
|
||||||
|
border: 1px solid #d9ebe7;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 0 12px 18px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
text-align: center;
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step::before,
|
||||||
|
.flow-step::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 12px;
|
||||||
|
width: calc(50% - 18px);
|
||||||
|
height: 1px;
|
||||||
|
background: #cfd5df;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step::before {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step::after {
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step:first-child::before,
|
||||||
|
.flow-step:last-child::after {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step.is-clickable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step:disabled {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step.is-active .flow-step-title,
|
||||||
|
.flow-step.is-active .flow-step-desc {
|
||||||
|
color: #67c23a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step.is-done .flow-step-index {
|
||||||
|
border-color: var(--el-color-success);
|
||||||
|
background: rgba(103, 194, 58, 0.1);
|
||||||
|
color: var(--el-color-success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step.is-done::after,
|
||||||
|
.flow-step.is-done + .flow-step::before {
|
||||||
|
background: rgba(103, 194, 58, 0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step-index {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 26px;
|
||||||
|
height: 26px;
|
||||||
|
border: 2px solid #b8bec9;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #fff;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1;
|
||||||
|
color: #a9b0bb;
|
||||||
|
flex-shrink: 0;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step.is-active .flow-step-index {
|
||||||
|
border-color: #67c23a;
|
||||||
|
background: rgba(103, 194, 58, 0.1);
|
||||||
|
color: #67c23a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.2;
|
||||||
|
color: #a9b0bb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step-desc {
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.25;
|
||||||
|
color: #b9bfc9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-main {
|
||||||
|
min-height: 0;
|
||||||
|
flex: 1;
|
||||||
|
padding-bottom: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-panel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-panel {
|
||||||
|
border: 1px solid var(--el-border-color-light);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 18px;
|
||||||
|
background: var(--el-fill-color-blank);
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-strip {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-item {
|
||||||
|
padding: 12px 14px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: var(--el-fill-color-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-value {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--el-text-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.complete-panel {
|
||||||
|
border: 1px solid var(--el-border-color-light);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 18px;
|
||||||
|
background: var(--el-fill-color-blank);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-panel {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 8px;
|
||||||
|
z-index: 3;
|
||||||
|
border: 1px solid var(--el-border-color-light);
|
||||||
|
border-radius: 12px;
|
||||||
|
background: var(--el-fill-color-blank);
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 12px 28px rgba(47, 79, 183, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-panel-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 44px;
|
||||||
|
padding: 0 16px;
|
||||||
|
border: none;
|
||||||
|
background: linear-gradient(180deg, #eef3ff 0%, #e6ecff 100%);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-panel-toggle {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
border-right: 2px solid #2f4fb7;
|
||||||
|
border-bottom: 2px solid #2f4fb7;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
transition: transform 0.2s ease;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-panel-toggle.is-collapsed {
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-title {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #2f4fb7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-panel-body {
|
||||||
|
border-top: 1px solid #d9e3ff;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-popover-body {
|
||||||
|
max-height: 160px;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 0;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-item {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 180px minmax(0, 1fr);
|
||||||
|
border-top: 1px solid var(--el-border-color-lighter);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-item:first-child {
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-meta,
|
||||||
|
.log-message {
|
||||||
|
padding: 10px 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-meta {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
border-right: 1px solid var(--el-border-color-lighter);
|
||||||
|
background: #f6f8ff;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-time {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-message {
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.3;
|
||||||
|
color: var(--el-text-color-primary);
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-empty {
|
||||||
|
padding: 18px 0;
|
||||||
|
}
|
||||||
|
|
||||||
:deep(.report-task-form .el-form-item) {
|
:deep(.report-task-form .el-form-item) {
|
||||||
margin-bottom: 18px;
|
margin-bottom: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.report-task-flow-dialog .el-dialog__body) {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
:deep(.el-select),
|
:deep(.el-select),
|
||||||
:deep(.el-textarea),
|
|
||||||
:deep(.el-input) {
|
:deep(.el-input) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.standard-option {
|
@media (max-width: 900px) {
|
||||||
display: flex;
|
.flow-nav,
|
||||||
align-items: center;
|
.summary-strip {
|
||||||
gap: 8px;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.standard-option-checkbox {
|
.flow-nav {
|
||||||
pointer-events: none;
|
gap: 14px;
|
||||||
}
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step {
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
padding: 0;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step::before,
|
||||||
|
.flow-step::after {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flow-step-content {
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-panel-header {
|
||||||
|
padding: 0 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-item {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-meta {
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||||
|
}
|
||||||
|
|
||||||
.standard-option-label {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -0,0 +1,426 @@
|
|||||||
|
<template>
|
||||||
|
<div class="ledger-import-panel">
|
||||||
|
<div class="panel-block">
|
||||||
|
<div class="section-header">
|
||||||
|
<div class="section-title">数据导入</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-alert
|
||||||
|
v-if="preparedState.pendingReimport"
|
||||||
|
title="已重新选择文件,当前导入结果已失效,请重新执行台账导入。"
|
||||||
|
type="warning"
|
||||||
|
:closable="false"
|
||||||
|
show-icon
|
||||||
|
class="section-alert"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="toolbar">
|
||||||
|
<div class="toolbar-actions">
|
||||||
|
<el-upload
|
||||||
|
:auto-upload="false"
|
||||||
|
:show-file-list="false"
|
||||||
|
multiple
|
||||||
|
accept=".xls,.xlsx,.doc,.docx"
|
||||||
|
:disabled="disabled || importing"
|
||||||
|
@change="handleFileChange"
|
||||||
|
@remove="handleFileRemove"
|
||||||
|
>
|
||||||
|
<template #trigger>
|
||||||
|
<el-button type="primary" plain :icon="FolderOpened" :disabled="disabled || importing">选择文件</el-button>
|
||||||
|
</template>
|
||||||
|
</el-upload>
|
||||||
|
|
||||||
|
<el-button type="primary" :icon="UploadFilled" :loading="importing" :disabled="disabled" @click="handleImportFiles">
|
||||||
|
执行导入
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-button class="toolbar-download" type="primary" plain :icon="Download" :disabled="disabled || importing" @click="handleDownloadTemplate">
|
||||||
|
下载模板
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table v-if="selectedFiles.length" :data="selectedFiles" border size="small" max-height="260" class="file-table">
|
||||||
|
<el-table-column type="index" label="序号" width="68" />
|
||||||
|
<el-table-column prop="name" label="文件名称" min-width="280" show-overflow-tooltip />
|
||||||
|
<el-table-column label="文件大小" width="140">
|
||||||
|
<template #default="{ row }">{{ formatFileSize(row.size) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="文件类型" width="120">
|
||||||
|
<template #default="{ row }">{{ resolveFileTypeText(row.name) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="100" fixed="right">
|
||||||
|
<template #default="{ $index }">
|
||||||
|
<el-button link type="danger" :disabled="disabled || importing" @click="removeSelectedFile($index)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<el-empty v-else description="尚未选择待导入文件" :image-size="88" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="latestImportResult" class="panel-block">
|
||||||
|
<div class="section-header">
|
||||||
|
<div class="section-title">导入结果</div>
|
||||||
|
<div class="section-desc">以后端返回的阶段结果和汇总统计为准。</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-descriptions :column="3" border>
|
||||||
|
<el-descriptions-item label="当前阶段">{{ resolveReportTaskText(latestImportResult.currentStage) }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="导入状态">
|
||||||
|
<el-tag :type="latestImportResult.success ? 'success' : 'warning'">
|
||||||
|
{{ latestImportResult.success ? '成功' : '未完成' }}
|
||||||
|
</el-tag>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="汇总文件">{{ resolveReportTaskText(latestImportResult.summaryFileName) }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="总文件数">{{ resolveReportTaskText(latestImportResult.totalFileCount) }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="监测点数">{{ resolveReportTaskText(latestImportResult.pointCount) }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="分组数">{{ resolveReportTaskText(latestImportResult.groupCount) }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="Excel 附件数">
|
||||||
|
{{ resolveReportTaskText(latestImportResult.excelAttachmentCount) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="Word 附件数">
|
||||||
|
{{ resolveReportTaskText(latestImportResult.wordAttachmentCount) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="设备新增 / 复用">
|
||||||
|
{{ `${latestImportResult.deviceAddedCount || 0} / ${latestImportResult.deviceReuseCount || 0}` }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="委托单位新增 / 复用" :span="2">
|
||||||
|
{{ `${latestImportResult.clientAddedCount || 0} / ${latestImportResult.clientReuseCount || 0}` }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
|
||||||
|
<el-alert
|
||||||
|
v-if="latestImportResult.failReasons?.length"
|
||||||
|
:title="`存在 ${latestImportResult.failReasons.length} 条失败提示`"
|
||||||
|
type="warning"
|
||||||
|
:closable="false"
|
||||||
|
show-icon
|
||||||
|
class="section-alert"
|
||||||
|
>
|
||||||
|
<template #default>
|
||||||
|
<div v-for="reason in latestImportResult.failReasons" :key="reason" class="fail-reason">{{ reason }}</div>
|
||||||
|
</template>
|
||||||
|
</el-alert>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
v-if="orderedStages.length"
|
||||||
|
:data="orderedStages"
|
||||||
|
border
|
||||||
|
size="small"
|
||||||
|
max-height="240"
|
||||||
|
class="stage-table"
|
||||||
|
>
|
||||||
|
<el-table-column prop="stage" label="阶段" width="150" />
|
||||||
|
<el-table-column label="结果" width="120">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag :type="row.success ? 'success' : 'warning'">{{ row.success ? '成功' : '未通过' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="message" label="说明" min-width="280" show-overflow-tooltip />
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="snapshot" class="panel-block">
|
||||||
|
<div class="section-header">
|
||||||
|
<div class="section-title">已保存快照</div>
|
||||||
|
<div class="section-desc">编辑场景下展示当前任务最近一次已保存的台账导入摘要。</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-descriptions :column="2" border>
|
||||||
|
<el-descriptions-item label="汇总文件">{{ resolveReportTaskText(snapshot.summaryFileName) }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="导入模式">{{ resolveReportTaskText(snapshot.importMode) }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="监测点 Sheet">
|
||||||
|
{{ resolveReportTaskText(snapshot.sheetSummary?.pointSheet) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="监测点行数">{{ resolveReportTaskText(snapshot.rowCount) }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="设备 Sheet">
|
||||||
|
{{ snapshot.sheetSummary?.deviceSheetPresent ? '存在' : '不存在' }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="委托单位 Sheet">
|
||||||
|
{{ snapshot.sheetSummary?.clientSheetPresent ? '存在' : '不存在' }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { Download, FolderOpened, UploadFilled } from '@element-plus/icons-vue'
|
||||||
|
import { ElMessage, type UploadFile, type UploadFiles } from 'element-plus'
|
||||||
|
import { computed, ref, watch } from 'vue'
|
||||||
|
import { downloadReportTaskLedgerTemplateApi, importReportTaskLedgerApi } from '@/api/aireport/testReport'
|
||||||
|
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||||
|
import { useDownloadWithServerFileName } from '@/hooks/useDownload'
|
||||||
|
import {
|
||||||
|
TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER,
|
||||||
|
checkReportTaskLedgerPrepared,
|
||||||
|
getReportTaskErrorMessage,
|
||||||
|
isReportTaskLedgerAttachmentFileName,
|
||||||
|
normalizeReportTaskLedgerImportResult,
|
||||||
|
resolveReportTaskText
|
||||||
|
} from '../utils/testReport'
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'ReportTaskLedgerImportPanel'
|
||||||
|
})
|
||||||
|
|
||||||
|
type ReportTaskLogType = 'info' | 'success' | 'warning' | 'error'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
draftId: string
|
||||||
|
disabled?: boolean
|
||||||
|
preparedState: ReportTask.ReportTaskLedgerPreparedState
|
||||||
|
snapshot: ReportTask.ReportTaskLedgerImportSnapshot | null
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(event: 'change', value: ReportTask.ReportTaskLedgerPreparedState): void
|
||||||
|
(event: 'log', payload: { type: ReportTaskLogType; message: string }): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const importing = ref(false)
|
||||||
|
const selectedFiles = ref<UploadFile[]>([])
|
||||||
|
const latestImportResult = ref<ReportTask.ReportTaskLedgerImportResult | null>(null)
|
||||||
|
|
||||||
|
const orderedStages = computed(() => {
|
||||||
|
const stageMap = new Map((latestImportResult.value?.stages || []).map(stage => [stage.stage, stage]))
|
||||||
|
|
||||||
|
return TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER.map(stage => {
|
||||||
|
const currentStage = stageMap.get(stage)
|
||||||
|
return {
|
||||||
|
stage,
|
||||||
|
success: currentStage?.success ?? false,
|
||||||
|
message: currentStage?.message || ''
|
||||||
|
}
|
||||||
|
}).filter(stage => stage.message || latestImportResult.value?.currentStage === stage.stage || stage.success)
|
||||||
|
})
|
||||||
|
|
||||||
|
const pushLog = (type: ReportTaskLogType, message: string) => {
|
||||||
|
emit('log', {
|
||||||
|
type,
|
||||||
|
message
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const updatePreparedState = (patch: Partial<ReportTask.ReportTaskLedgerPreparedState>) => {
|
||||||
|
emit('change', {
|
||||||
|
...props.preparedState,
|
||||||
|
...patch
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.preparedState,
|
||||||
|
value => {
|
||||||
|
latestImportResult.value = value.latestImportResult
|
||||||
|
},
|
||||||
|
{ immediate: true, deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
const formatFileSize = (size?: number) => {
|
||||||
|
if (!size) return '0 B'
|
||||||
|
if (size < 1024) return `${size} B`
|
||||||
|
if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`
|
||||||
|
return `${(size / (1024 * 1024)).toFixed(1)} MB`
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolveFileTypeText = (fileName: string) => {
|
||||||
|
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||||
|
if (normalizedName === '台账信息汇总.xlsx') return '汇总台账'
|
||||||
|
if (normalizedName.endsWith('.doc') || normalizedName.endsWith('.docx')) return 'Word 附件'
|
||||||
|
if (normalizedName.endsWith('.xls') || normalizedName.endsWith('.xlsx')) return 'Excel 附件'
|
||||||
|
return '未知'
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleFileChange = (_file: UploadFile, files: UploadFiles) => {
|
||||||
|
selectedFiles.value = [...files]
|
||||||
|
pushLog('info', `已选择 ${selectedFiles.value.length} 个待导入文件`)
|
||||||
|
|
||||||
|
if (props.preparedState.hasImported) {
|
||||||
|
updatePreparedState({
|
||||||
|
pendingReimport: true
|
||||||
|
})
|
||||||
|
pushLog('warning', '已更换导入文件,需重新执行台账导入后才能继续保存')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleFileRemove = (_file: UploadFile, files: UploadFiles) => {
|
||||||
|
selectedFiles.value = [...files]
|
||||||
|
pushLog('info', `已更新待导入文件列表,当前剩余 ${selectedFiles.value.length} 个文件`)
|
||||||
|
|
||||||
|
if (props.preparedState.hasImported) {
|
||||||
|
updatePreparedState({
|
||||||
|
pendingReimport: true
|
||||||
|
})
|
||||||
|
pushLog('warning', '导入文件已发生变化,之前的导入结果已标记为失效')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeSelectedFile = (index: number) => {
|
||||||
|
selectedFiles.value.splice(index, 1)
|
||||||
|
pushLog('info', `已删除第 ${index + 1} 个待导入文件`)
|
||||||
|
|
||||||
|
if (props.preparedState.hasImported) {
|
||||||
|
updatePreparedState({
|
||||||
|
pendingReimport: true
|
||||||
|
})
|
||||||
|
pushLog('warning', '导入文件已发生变化,之前的导入结果已标记为失效')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDownloadTemplate = async () => {
|
||||||
|
try {
|
||||||
|
await useDownloadWithServerFileName(downloadReportTaskLedgerTemplateApi, '台账信息汇总', undefined, false, '.xlsx')
|
||||||
|
pushLog('success', '台账导入模板下载成功')
|
||||||
|
} catch (error) {
|
||||||
|
const message = getReportTaskErrorMessage(error, '台账模板下载失败')
|
||||||
|
ElMessage.error(message)
|
||||||
|
pushLog('error', message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleImportFiles = async () => {
|
||||||
|
if (importing.value) return
|
||||||
|
|
||||||
|
if (!props.draftId) {
|
||||||
|
const message = '报告任务 ID 缺失,无法执行台账导入'
|
||||||
|
ElMessage.error(message)
|
||||||
|
pushLog('error', message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!selectedFiles.value.length) {
|
||||||
|
const message = '请先选择待导入的台账汇总与附件文件'
|
||||||
|
ElMessage.warning(message)
|
||||||
|
pushLog('warning', message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const invalidFile = selectedFiles.value.find(file => !isReportTaskLedgerAttachmentFileName(file.name))
|
||||||
|
if (invalidFile) {
|
||||||
|
const message = '仅支持导入 .xls、.xlsx、.doc、.docx 文件'
|
||||||
|
ElMessage.warning(message)
|
||||||
|
pushLog('warning', `${message},异常文件:${invalidFile.name}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData()
|
||||||
|
selectedFiles.value.forEach(file => {
|
||||||
|
if (file.raw) {
|
||||||
|
formData.append('files', file.raw)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!formData.getAll('files').length) {
|
||||||
|
const message = '未检测到可上传的文件内容'
|
||||||
|
ElMessage.warning(message)
|
||||||
|
pushLog('warning', message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
importing.value = true
|
||||||
|
pushLog('info', `开始执行台账导入,本次共上传 ${selectedFiles.value.length} 个文件`)
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 关键业务节点:创建和编辑都统一使用 ledger/import,只有台账导入成功后才允许继续执行 add/update。
|
||||||
|
const response = await importReportTaskLedgerApi(props.draftId, formData)
|
||||||
|
const normalizedResult = normalizeReportTaskLedgerImportResult(response)
|
||||||
|
|
||||||
|
latestImportResult.value = normalizedResult
|
||||||
|
updatePreparedState({
|
||||||
|
latestImportResult: normalizedResult,
|
||||||
|
hasImported: Boolean(normalizedResult.success),
|
||||||
|
pendingReimport: false
|
||||||
|
})
|
||||||
|
|
||||||
|
if (
|
||||||
|
!checkReportTaskLedgerPrepared({
|
||||||
|
...props.preparedState,
|
||||||
|
latestImportResult: normalizedResult,
|
||||||
|
hasImported: Boolean(normalizedResult.success),
|
||||||
|
pendingReimport: false
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
const message = '台账导入未完成,请根据阶段结果修正后重新导入'
|
||||||
|
ElMessage.warning(message)
|
||||||
|
pushLog('warning', message)
|
||||||
|
normalizedResult.failReasons?.forEach(reason => pushLog('warning', reason))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ElMessage.success('台账导入成功')
|
||||||
|
pushLog('success', '台账导入成功,可以继续填写基础信息')
|
||||||
|
} catch (error) {
|
||||||
|
const message = getReportTaskErrorMessage(error, '台账导入失败')
|
||||||
|
ElMessage.error(message)
|
||||||
|
pushLog('error', message)
|
||||||
|
} finally {
|
||||||
|
importing.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.ledger-import-panel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-block {
|
||||||
|
border: 1px solid var(--el-border-color-light);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 16px;
|
||||||
|
background: var(--el-fill-color-blank);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-block:first-child {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-header {
|
||||||
|
margin-bottom: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--el-text-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-alert,
|
||||||
|
.file-table,
|
||||||
|
.stage-table,
|
||||||
|
.fail-reason + .fail-reason {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar-download {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-empty) {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -27,53 +27,83 @@ assertFileIncludes(path.join(apiDir, 'index.ts'), [
|
|||||||
'deleteReportTasksApi',
|
'deleteReportTasksApi',
|
||||||
'getReportTaskDetailApi',
|
'getReportTaskDetailApi',
|
||||||
'exportReportTasksApi',
|
'exportReportTasksApi',
|
||||||
'submitReportTaskAuditApi'
|
'submitReportTaskAuditApi',
|
||||||
|
'downloadReportTaskLedgerTemplateApi',
|
||||||
|
'importReportTaskLedgerApi',
|
||||||
|
'listReportTaskGroupReportsApi'
|
||||||
])
|
])
|
||||||
|
|
||||||
assertFileIncludes(path.join(apiDir, 'interface/index.ts'), [
|
assertFileIncludes(path.join(apiDir, 'interface/index.ts'), [
|
||||||
'export namespace ReportTask',
|
'export namespace ReportTask',
|
||||||
'ReportTaskRecord',
|
'ReportTaskRecord',
|
||||||
'ReportTaskListParams',
|
'ReportTaskListParams',
|
||||||
|
'ReportTaskAddParam',
|
||||||
'ReportTaskSaveRequest',
|
'ReportTaskSaveRequest',
|
||||||
'ReportTaskAuditRequest',
|
'ReportTaskAuditRequest',
|
||||||
'standard?: string[] | string | null',
|
'ReportTaskLedgerImportResult',
|
||||||
'standard: string[]'
|
'ReportTaskLedgerImportStageRecord',
|
||||||
|
'ReportTaskLedgerImportSnapshot',
|
||||||
|
'ReportTaskGroupReportRecord',
|
||||||
|
'ReportTaskLedgerPreparedState'
|
||||||
])
|
])
|
||||||
|
|
||||||
assertFileIncludes(path.join(pageDir, 'utils/testReport.ts'), [
|
assertFileIncludes(path.join(pageDir, 'utils/testReport.ts'), [
|
||||||
'normalizeReportTaskListParams',
|
'TEST_REPORT_EXCEL_EXTENSIONS',
|
||||||
'normalizeReportTaskPage',
|
'REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP',
|
||||||
'parseReportTaskStandardIds',
|
'isReportTaskExcelFileName',
|
||||||
'stringifyReportTaskStandardIds',
|
'TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER',
|
||||||
'resolveReportTaskStandardText',
|
'normalizeReportTaskLedgerImportResult',
|
||||||
'buildDictSelectOptions',
|
'normalizeReportTaskLedgerSnapshot',
|
||||||
'value?: string[] | string | null',
|
'checkReportTaskLedgerPrepared',
|
||||||
"return text ? [text] : []"
|
'resolveReportTaskGroupReportGenerateStateText',
|
||||||
|
'resolveReportTaskGroupReportGenerateStateTagType'
|
||||||
|
])
|
||||||
|
|
||||||
|
assertFileIncludes(path.join(pageDir, 'components/ReportTaskLedgerImportPanel.vue'), [
|
||||||
|
"name: 'ReportTaskLedgerImportPanel'",
|
||||||
|
'downloadReportTaskLedgerTemplateApi',
|
||||||
|
'importReportTaskLedgerApi',
|
||||||
|
'selectedFiles',
|
||||||
|
'latestImportResult',
|
||||||
|
'handleImportFiles',
|
||||||
|
'toolbar-actions',
|
||||||
|
'toolbar-download'
|
||||||
])
|
])
|
||||||
|
|
||||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskFormDialog.vue'), [
|
assertFileIncludes(path.join(pageDir, 'components/ReportTaskFormDialog.vue'), [
|
||||||
"name: 'ReportTaskFormDialog'",
|
"name: 'ReportTaskFormDialog'",
|
||||||
'clientUnitId',
|
'ReportTaskLedgerImportPanel',
|
||||||
'reportModelId',
|
'REPORT_TASK_FORM_STEPS',
|
||||||
'createUnit',
|
'currentStep',
|
||||||
'standardIds',
|
'logEntries',
|
||||||
'stringifyReportTaskStandardIds',
|
'logPanelExpanded',
|
||||||
'el-checkbox',
|
'goToImportStep',
|
||||||
'standard-option-checkbox'
|
'handleLedgerPreparedChange',
|
||||||
|
'ledgerPreparedState',
|
||||||
|
'activeDraftId',
|
||||||
|
'checkReportTaskLedgerPrepared',
|
||||||
|
'padding-bottom: 24px',
|
||||||
|
'position: absolute',
|
||||||
|
'z-index: 3',
|
||||||
|
'log-panel-header',
|
||||||
|
'log-panel-body',
|
||||||
|
'log-panel-toggle',
|
||||||
|
'white-space: nowrap',
|
||||||
|
'text-overflow: ellipsis',
|
||||||
|
'log-empty'
|
||||||
])
|
])
|
||||||
|
|
||||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskDetailDialog.vue'), [
|
assertFileIncludes(path.join(pageDir, 'components/ReportTaskDetailDialog.vue'), [
|
||||||
"name: 'ReportTaskDetailDialog'",
|
"name: 'ReportTaskDetailDialog'",
|
||||||
'报告任务详情',
|
'groupReports',
|
||||||
'resolveReportTaskCreateUnitText',
|
'generateState',
|
||||||
'resolveReportTaskStandardText',
|
'group-report-title',
|
||||||
'table-layout: fixed'
|
'resolveReportTaskGroupReportGenerateStateText'
|
||||||
])
|
])
|
||||||
|
|
||||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskAuditDialog.vue'), [
|
assertFileIncludes(path.join(pageDir, 'components/ReportTaskAuditDialog.vue'), [
|
||||||
"name: 'ReportTaskAuditDialog'",
|
"name: 'ReportTaskAuditDialog'",
|
||||||
'checkResult',
|
'checkResult'
|
||||||
'提交审核'
|
|
||||||
])
|
])
|
||||||
|
|
||||||
assertFileIncludes(path.join(pageDir, 'index.vue'), [
|
assertFileIncludes(path.join(pageDir, 'index.vue'), [
|
||||||
@@ -82,14 +112,16 @@ assertFileIncludes(path.join(pageDir, 'index.vue'), [
|
|||||||
'ReportTaskFormDialog',
|
'ReportTaskFormDialog',
|
||||||
'ReportTaskDetailDialog',
|
'ReportTaskDetailDialog',
|
||||||
'ReportTaskAuditDialog',
|
'ReportTaskAuditDialog',
|
||||||
'listReportTasksApi',
|
'listReportTaskGroupReportsApi',
|
||||||
'submitReportTaskAuditApi',
|
'detailGroupReports',
|
||||||
'exportReportTasksApi',
|
'ledger/import -> add/update'
|
||||||
'DICT_CODES.TEST_REPORT_COMPANY',
|
])
|
||||||
'DICT_CODES.TEST_REPORT_STANDARD',
|
|
||||||
'type="primary" :icon="Plus"',
|
assertFileIncludes(path.join(pageDir, 'components/ReportTaskLedgerImportPanel.vue'), [
|
||||||
'type="danger"',
|
'min-height: 0',
|
||||||
'type="primary" plain'
|
'flex: 1',
|
||||||
|
'display: flex',
|
||||||
|
'flex-direction: column'
|
||||||
])
|
])
|
||||||
|
|
||||||
console.log('testReport page contract passed')
|
console.log('testReport page contract passed')
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
:mode="formMode"
|
:mode="formMode"
|
||||||
:record="currentRecord"
|
:record="currentRecord"
|
||||||
:saving="formSaving"
|
:saving="formSaving"
|
||||||
|
:save-success-version="formSaveSuccessVersion"
|
||||||
:client-unit-options="clientUnitOptions"
|
:client-unit-options="clientUnitOptions"
|
||||||
:report-model-options="reportModelOptions"
|
:report-model-options="reportModelOptions"
|
||||||
:company-options="companyOptions"
|
:company-options="companyOptions"
|
||||||
@@ -46,6 +47,7 @@
|
|||||||
v-model:visible="detailDialogVisible"
|
v-model:visible="detailDialogVisible"
|
||||||
:loading="detailLoading"
|
:loading="detailLoading"
|
||||||
:detail="detailRecord"
|
:detail="detailRecord"
|
||||||
|
:group-reports="detailGroupReports"
|
||||||
:company-label-map="companyLabelMap"
|
:company-label-map="companyLabelMap"
|
||||||
:standard-label-map="standardLabelMap"
|
:standard-label-map="standardLabelMap"
|
||||||
/>
|
/>
|
||||||
@@ -67,12 +69,13 @@ import type { Dict, ResPage } from '@/api/interface'
|
|||||||
import ProTable from '@/components/ProTable/index.vue'
|
import ProTable from '@/components/ProTable/index.vue'
|
||||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||||
import {
|
import {
|
||||||
|
createReportTaskApi,
|
||||||
deleteReportTasksApi,
|
deleteReportTasksApi,
|
||||||
exportReportTasksApi,
|
exportReportTasksApi,
|
||||||
getReportTaskDetailApi,
|
getReportTaskDetailApi,
|
||||||
|
listReportTaskGroupReportsApi,
|
||||||
listReportTasksApi,
|
listReportTasksApi,
|
||||||
submitReportTaskAuditApi,
|
submitReportTaskAuditApi,
|
||||||
createReportTaskApi,
|
|
||||||
updateReportTaskApi
|
updateReportTaskApi
|
||||||
} from '@/api/aireport/testReport'
|
} from '@/api/aireport/testReport'
|
||||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||||
@@ -89,6 +92,7 @@ import {
|
|||||||
buildDictSelectOptions,
|
buildDictSelectOptions,
|
||||||
buildOptionLabelMap,
|
buildOptionLabelMap,
|
||||||
getReportTaskErrorMessage,
|
getReportTaskErrorMessage,
|
||||||
|
normalizeReportTaskGroupReportList,
|
||||||
normalizeReportTaskListParams,
|
normalizeReportTaskListParams,
|
||||||
normalizeReportTaskPage,
|
normalizeReportTaskPage,
|
||||||
resolveReportTaskCreateUnitText,
|
resolveReportTaskCreateUnitText,
|
||||||
@@ -107,11 +111,13 @@ const formDialogVisible = ref(false)
|
|||||||
const detailDialogVisible = ref(false)
|
const detailDialogVisible = ref(false)
|
||||||
const auditDialogVisible = ref(false)
|
const auditDialogVisible = ref(false)
|
||||||
const formSaving = ref(false)
|
const formSaving = ref(false)
|
||||||
|
const formSaveSuccessVersion = ref(0)
|
||||||
const detailLoading = ref(false)
|
const detailLoading = ref(false)
|
||||||
const auditSaving = ref(false)
|
const auditSaving = ref(false)
|
||||||
const formMode = ref<'create' | 'edit'>('create')
|
const formMode = ref<'create' | 'edit'>('create')
|
||||||
const currentRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
const currentRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
||||||
const detailRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
const detailRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
||||||
|
const detailGroupReports = ref<ReportTask.ReportTaskGroupReportRecord[]>([])
|
||||||
const currentAuditRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
const currentAuditRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
||||||
const clientUnitOptions = ref<Array<{ label: string; value: string }>>([])
|
const clientUnitOptions = ref<Array<{ label: string; value: string }>>([])
|
||||||
const reportModelOptions = ref<Array<{ label: string; value: string }>>([])
|
const reportModelOptions = ref<Array<{ label: string; value: string }>>([])
|
||||||
@@ -175,6 +181,8 @@ const columns = reactive<ColumnProps<ReportTask.ReportTaskRecord>[]>([
|
|||||||
showOverflowTooltip: true,
|
showOverflowTooltip: true,
|
||||||
render: ({ row }) => resolveReportTaskStandardText(row.standard, standardLabelMap.value)
|
render: ({ row }) => resolveReportTaskStandardText(row.standard, standardLabelMap.value)
|
||||||
},
|
},
|
||||||
|
{ prop: 'pointCount', label: '监测点数', minWidth: 100, render: ({ row }) => resolveReportTaskText(row.pointCount) },
|
||||||
|
{ prop: 'groupCount', label: '分组数', minWidth: 100, render: ({ row }) => resolveReportTaskText(row.groupCount) },
|
||||||
{ prop: 'phonenumber', label: '联系电话', minWidth: 140, render: ({ row }) => resolveReportTaskText(row.phonenumber) },
|
{ prop: 'phonenumber', label: '联系电话', minWidth: 140, render: ({ row }) => resolveReportTaskText(row.phonenumber) },
|
||||||
{ prop: 'checkerName', label: '审核人', minWidth: 120, render: ({ row }) => resolveReportTaskText(row.checkerName) },
|
{ prop: 'checkerName', label: '审核人', minWidth: 120, render: ({ row }) => resolveReportTaskText(row.checkerName) },
|
||||||
{ prop: 'checkTime', label: '审核时间', minWidth: 120, render: ({ row }) => resolveReportTaskText(row.checkTime) },
|
{ prop: 'checkTime', label: '审核时间', minWidth: 120, render: ({ row }) => resolveReportTaskText(row.checkTime) },
|
||||||
@@ -201,7 +209,7 @@ const ensureReportTaskDictOptionsReady = async () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 关键业务节点:检测公司和测试依据展示依赖字典缓存,需要在页面缺失时补载后再做 ID 到名称映射。
|
// 关键业务节点:检测公司和测试依据展示依赖字典缓存,缺失时必须先补齐再做 ID 到名称映射。
|
||||||
dictStore.setDictData(Array.from(nextDictMap.values()))
|
dictStore.setDictData(Array.from(nextDictMap.values()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +288,7 @@ const openEditDialog = async (row: ReportTask.ReportTaskRecord) => {
|
|||||||
formMode.value = 'edit'
|
formMode.value = 'edit'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 关键业务节点:编辑表单提交时依赖 clientUnitId、reportModelId、createUnit、standard 等原始值,不能只用列表展示字段回填。
|
// 关键业务节点:编辑表单提交仍依赖原始 clientUnitId、reportModelId、createUnit、standard 等字段,不能只回填列表展示文本。
|
||||||
const response = await getReportTaskDetailApi(row.id)
|
const response = await getReportTaskDetailApi(row.id)
|
||||||
currentRecord.value = unwrapReportTaskPayload<ReportTask.ReportTaskRecord>(response)
|
currentRecord.value = unwrapReportTaskPayload<ReportTask.ReportTaskRecord>(response)
|
||||||
formDialogVisible.value = true
|
formDialogVisible.value = true
|
||||||
@@ -296,12 +304,18 @@ const openDetailDialog = async (row: ReportTask.ReportTaskRecord) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
detailRecord.value = null
|
detailRecord.value = null
|
||||||
|
detailGroupReports.value = []
|
||||||
detailDialogVisible.value = true
|
detailDialogVisible.value = true
|
||||||
detailLoading.value = true
|
detailLoading.value = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await getReportTaskDetailApi(row.id)
|
const [detailResponse, groupReportsResponse] = await Promise.all([
|
||||||
detailRecord.value = unwrapReportTaskPayload<ReportTask.ReportTaskRecord>(response)
|
getReportTaskDetailApi(row.id),
|
||||||
|
listReportTaskGroupReportsApi(row.id)
|
||||||
|
])
|
||||||
|
|
||||||
|
detailRecord.value = unwrapReportTaskPayload<ReportTask.ReportTaskRecord>(detailResponse)
|
||||||
|
detailGroupReports.value = normalizeReportTaskGroupReportList(groupReportsResponse)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务详情查询失败'))
|
ElMessage.error(getReportTaskErrorMessage(error, '报告任务详情查询失败'))
|
||||||
} finally {
|
} finally {
|
||||||
@@ -323,6 +337,7 @@ const handleSaveReportTask = async (params: ReportTask.ReportTaskSaveRequest) =>
|
|||||||
formSaving.value = true
|
formSaving.value = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// 关键业务节点:台账导入已在弹窗内完成,页面层这里只执行最终 add/update,整体顺序为 ledger/import -> add/update。
|
||||||
if (formMode.value === 'create') {
|
if (formMode.value === 'create') {
|
||||||
await createReportTaskApi(params)
|
await createReportTaskApi(params)
|
||||||
ElMessage.success('报告任务新增成功')
|
ElMessage.success('报告任务新增成功')
|
||||||
@@ -331,7 +346,7 @@ const handleSaveReportTask = async (params: ReportTask.ReportTaskSaveRequest) =>
|
|||||||
ElMessage.success('报告任务编辑成功')
|
ElMessage.success('报告任务编辑成功')
|
||||||
}
|
}
|
||||||
|
|
||||||
formDialogVisible.value = false
|
formSaveSuccessVersion.value += 1
|
||||||
refreshReportTasks()
|
refreshReportTasks()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务保存失败'))
|
ElMessage.error(getReportTaskErrorMessage(error, '报告任务保存失败'))
|
||||||
@@ -400,11 +415,12 @@ const handleExport = async () => {
|
|||||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务导出失败'))
|
ElMessage.error(getReportTaskErrorMessage(error, '报告任务导出失败'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
await ensureReportTaskDictOptionsReady()
|
await ensureReportTaskDictOptionsReady()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(getReportTaskErrorMessage(error, '鎶ュ憡浠诲姟瀛楀吀鍔犺浇澶辫触'))
|
ElMessage.error(getReportTaskErrorMessage(error, '报告任务字典加载失败'))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,6 +1,31 @@
|
|||||||
import type { Dict, ResultData, ResPage } from '@/api/interface'
|
import type { Dict, ResultData, ResPage } from '@/api/interface'
|
||||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||||
|
|
||||||
|
export const TEST_REPORT_EXCEL_EXTENSIONS = ['.xls', '.xlsx']
|
||||||
|
export const TEST_REPORT_WORD_EXTENSIONS = ['.doc', '.docx']
|
||||||
|
export const TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER: ReportTask.ReportTaskLedgerImportStage[] = [
|
||||||
|
'选择文件',
|
||||||
|
'校验文件',
|
||||||
|
'文件上传',
|
||||||
|
'基础资料维护',
|
||||||
|
'完成'
|
||||||
|
]
|
||||||
|
export const REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP: Record<number, string> = {
|
||||||
|
0: '未生成',
|
||||||
|
1: '生成中',
|
||||||
|
2: '生成成功',
|
||||||
|
3: '生成失败'
|
||||||
|
}
|
||||||
|
export const REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TAG_TYPE_MAP: Record<
|
||||||
|
number,
|
||||||
|
'warning' | 'success' | 'danger' | undefined
|
||||||
|
> = {
|
||||||
|
0: undefined,
|
||||||
|
1: 'warning',
|
||||||
|
2: 'success',
|
||||||
|
3: 'danger'
|
||||||
|
}
|
||||||
|
|
||||||
export const resolveReportTaskText = (value: unknown) => {
|
export const resolveReportTaskText = (value: unknown) => {
|
||||||
if (value === null || value === undefined) return '-'
|
if (value === null || value === undefined) return '-'
|
||||||
|
|
||||||
@@ -53,6 +78,141 @@ export const getReportTaskErrorMessage = (error: unknown, fallback: string) => {
|
|||||||
return fallback
|
return fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isReportTaskExcelFileName = (fileName: string) => {
|
||||||
|
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||||
|
return TEST_REPORT_EXCEL_EXTENSIONS.some(extension => normalizedName.endsWith(extension))
|
||||||
|
}
|
||||||
|
|
||||||
|
export const isReportTaskWordFileName = (fileName: string) => {
|
||||||
|
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||||
|
return TEST_REPORT_WORD_EXTENSIONS.some(extension => normalizedName.endsWith(extension))
|
||||||
|
}
|
||||||
|
|
||||||
|
export const isReportTaskLedgerAttachmentFileName = (fileName: string) =>
|
||||||
|
isReportTaskExcelFileName(fileName) || isReportTaskWordFileName(fileName)
|
||||||
|
|
||||||
|
export const normalizeReportTaskPointList = (
|
||||||
|
response: ResultData<ReportTask.ReportTaskPointRecord[]> | ReportTask.ReportTaskPointRecord[] | null | undefined
|
||||||
|
) => {
|
||||||
|
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskPointRecord[] | null | undefined>(
|
||||||
|
response as ResultData<ReportTask.ReportTaskPointRecord[]>
|
||||||
|
)
|
||||||
|
|
||||||
|
return Array.isArray(payload) ? payload : []
|
||||||
|
}
|
||||||
|
|
||||||
|
export const normalizeReportTaskLedgerImportResult = (
|
||||||
|
response:
|
||||||
|
| ResultData<ReportTask.ReportTaskLedgerImportResult>
|
||||||
|
| ReportTask.ReportTaskLedgerImportResult
|
||||||
|
| null
|
||||||
|
| undefined
|
||||||
|
): ReportTask.ReportTaskLedgerImportResult => {
|
||||||
|
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskLedgerImportResult | null | undefined>(
|
||||||
|
response as ResultData<ReportTask.ReportTaskLedgerImportResult>
|
||||||
|
)
|
||||||
|
|
||||||
|
const stageList = Array.isArray(payload?.stages) ? payload.stages : []
|
||||||
|
|
||||||
|
return {
|
||||||
|
currentStage: payload?.currentStage || undefined,
|
||||||
|
success: payload?.success ?? false,
|
||||||
|
summaryFileName: payload?.summaryFileName || undefined,
|
||||||
|
totalFileCount: payload?.totalFileCount ?? 0,
|
||||||
|
pointCount: payload?.pointCount ?? 0,
|
||||||
|
excelAttachmentCount: payload?.excelAttachmentCount ?? 0,
|
||||||
|
wordAttachmentCount: payload?.wordAttachmentCount ?? 0,
|
||||||
|
deviceAddedCount: payload?.deviceAddedCount ?? 0,
|
||||||
|
deviceReuseCount: payload?.deviceReuseCount ?? 0,
|
||||||
|
clientAddedCount: payload?.clientAddedCount ?? 0,
|
||||||
|
clientReuseCount: payload?.clientReuseCount ?? 0,
|
||||||
|
groupCount: payload?.groupCount ?? 0,
|
||||||
|
failReasons: Array.isArray(payload?.failReasons) ? payload.failReasons.filter(Boolean) : [],
|
||||||
|
stages: stageList.map(stage => ({
|
||||||
|
stage: stage?.stage || undefined,
|
||||||
|
success: stage?.success ?? false,
|
||||||
|
message: stage?.message || ''
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const normalizeReportTaskGroupReportList = (
|
||||||
|
response:
|
||||||
|
| ResultData<ReportTask.ReportTaskGroupReportRecord[]>
|
||||||
|
| ReportTask.ReportTaskGroupReportRecord[]
|
||||||
|
| null
|
||||||
|
| undefined
|
||||||
|
) => {
|
||||||
|
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskGroupReportRecord[] | null | undefined>(
|
||||||
|
response as ResultData<ReportTask.ReportTaskGroupReportRecord[]>
|
||||||
|
)
|
||||||
|
|
||||||
|
return Array.isArray(payload) ? payload : []
|
||||||
|
}
|
||||||
|
|
||||||
|
export const normalizeReportTaskLedgerSnapshot = (
|
||||||
|
value: string | ReportTask.ReportTaskLedgerImportSnapshot | null | undefined
|
||||||
|
): ReportTask.ReportTaskLedgerImportSnapshot | null => {
|
||||||
|
if (!value) return null
|
||||||
|
|
||||||
|
const snapshot =
|
||||||
|
typeof value === 'string'
|
||||||
|
? (() => {
|
||||||
|
try {
|
||||||
|
return JSON.parse(value) as ReportTask.ReportTaskLedgerImportSnapshot
|
||||||
|
} catch {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
: value
|
||||||
|
|
||||||
|
if (!snapshot || typeof snapshot !== 'object') return null
|
||||||
|
|
||||||
|
return {
|
||||||
|
version: snapshot.version || undefined,
|
||||||
|
importMode: snapshot.importMode || undefined,
|
||||||
|
summaryFileName: snapshot.summaryFileName || undefined,
|
||||||
|
sheetSummary: snapshot.sheetSummary
|
||||||
|
? {
|
||||||
|
pointSheet: snapshot.sheetSummary.pointSheet || undefined,
|
||||||
|
deviceSheetPresent: snapshot.sheetSummary.deviceSheetPresent ?? false,
|
||||||
|
clientSheetPresent: snapshot.sheetSummary.clientSheetPresent ?? false
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
rowCount: snapshot.rowCount ?? 0,
|
||||||
|
groupSummary: Array.isArray(snapshot.groupSummary)
|
||||||
|
? snapshot.groupSummary.map(item => ({
|
||||||
|
groupNo: item?.groupNo ?? null,
|
||||||
|
count: item?.count ?? 0
|
||||||
|
}))
|
||||||
|
: [],
|
||||||
|
baseDataSummary: snapshot.baseDataSummary
|
||||||
|
? {
|
||||||
|
deviceAddedCount: snapshot.baseDataSummary.deviceAddedCount ?? 0,
|
||||||
|
deviceReuseCount: snapshot.baseDataSummary.deviceReuseCount ?? 0,
|
||||||
|
clientAddedCount: snapshot.baseDataSummary.clientAddedCount ?? 0,
|
||||||
|
clientReuseCount: snapshot.baseDataSummary.clientReuseCount ?? 0
|
||||||
|
}
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const resolveReportTaskGroupReportGenerateStateText = (value: number | null | undefined) => {
|
||||||
|
if (value === null || value === undefined) return '-'
|
||||||
|
|
||||||
|
return REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP[value] || String(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const resolveReportTaskGroupReportGenerateStateTagType = (value: number | null | undefined) => {
|
||||||
|
if (value === null || value === undefined) return undefined
|
||||||
|
|
||||||
|
return REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TAG_TYPE_MAP[value]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const checkReportTaskLedgerPrepared = (
|
||||||
|
state: ReportTask.ReportTaskLedgerPreparedState | null | undefined
|
||||||
|
) => Boolean(state?.draftId && state.hasImported && !state.pendingReimport)
|
||||||
|
|
||||||
export const buildDictSelectOptions = (dictData: Dict[] = []) =>
|
export const buildDictSelectOptions = (dictData: Dict[] = []) =>
|
||||||
dictData
|
dictData
|
||||||
.filter(item => item.id && item.name)
|
.filter(item => item.id && item.name)
|
||||||
@@ -90,6 +250,57 @@ export const parseReportTaskStandardIds = (value?: string[] | string | null) =>
|
|||||||
export const stringifyReportTaskStandardIds = (value: string[]) =>
|
export const stringifyReportTaskStandardIds = (value: string[]) =>
|
||||||
value.map(item => String(item).trim()).filter(Boolean)
|
value.map(item => String(item).trim()).filter(Boolean)
|
||||||
|
|
||||||
|
export const normalizeReportTaskGroupSavePayload = (
|
||||||
|
pointList: ReportTask.ReportTaskPointRecord[],
|
||||||
|
pointGroupMap: Record<string, number | string | null | undefined>
|
||||||
|
): ReportTask.ReportTaskGroupSaveRequest => {
|
||||||
|
const groupedPointMap = new Map<number, string[]>()
|
||||||
|
|
||||||
|
pointList.forEach(point => {
|
||||||
|
const pointId = String(point.id || '').trim()
|
||||||
|
if (!pointId) return
|
||||||
|
|
||||||
|
const rawGroupNo = pointGroupMap[pointId]
|
||||||
|
const groupNo = Number(rawGroupNo)
|
||||||
|
if (!Number.isInteger(groupNo) || groupNo <= 0) return
|
||||||
|
|
||||||
|
const groupPointIds = groupedPointMap.get(groupNo) || []
|
||||||
|
groupPointIds.push(pointId)
|
||||||
|
groupedPointMap.set(groupNo, groupPointIds)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
groups: Array.from(groupedPointMap.entries())
|
||||||
|
.sort(([groupNoA], [groupNoB]) => groupNoA - groupNoB)
|
||||||
|
.map(([groupNo, pointIds]) => ({
|
||||||
|
groupNo,
|
||||||
|
pointIds
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const checkReportTaskGroupingCompleted = (
|
||||||
|
pointList: ReportTask.ReportTaskPointRecord[],
|
||||||
|
payload: ReportTask.ReportTaskGroupSaveRequest | null | undefined
|
||||||
|
) => {
|
||||||
|
if (!pointList.length || !payload?.groups?.length) return false
|
||||||
|
|
||||||
|
const pointIds = pointList.map(point => String(point.id || '').trim()).filter(Boolean)
|
||||||
|
if (!pointIds.length) return false
|
||||||
|
|
||||||
|
const groupedIds = payload.groups.flatMap(group => group.pointIds.map(pointId => String(pointId || '').trim()).filter(Boolean))
|
||||||
|
if (groupedIds.length !== pointIds.length) return false
|
||||||
|
|
||||||
|
const uniqueGroupedIds = new Set(groupedIds)
|
||||||
|
if (uniqueGroupedIds.size !== pointIds.length) return false
|
||||||
|
|
||||||
|
const pointIdSet = new Set(pointIds)
|
||||||
|
const hasInvalidPointId = Array.from(uniqueGroupedIds).some(pointId => !pointIdSet.has(pointId))
|
||||||
|
if (hasInvalidPointId) return false
|
||||||
|
|
||||||
|
return payload.groups.every(group => Number.isInteger(group.groupNo) && group.groupNo > 0 && group.pointIds.length > 0)
|
||||||
|
}
|
||||||
|
|
||||||
export const resolveReportTaskCreateUnitText = (
|
export const resolveReportTaskCreateUnitText = (
|
||||||
value: string | null | undefined,
|
value: string | null | undefined,
|
||||||
companyLabelMap: Record<string, string>
|
companyLabelMap: Record<string, string>
|
||||||
|
|||||||
Reference in New Issue
Block a user