feat(testReport): 新增台账导入功能并重构报告任务表单
- 新增台账导入面板组件,支持Excel模板下载和批量导入 - 在报告任务表单中集成三步式流程(导入→填写→完成) - 添加导入结果预览和分组报告状态展示功能 - 扩展API接口支持台账导入和分组报告查询 - 优化表单验证逻辑,移除送资数据必填限制 - 集成日志面板实时显示导入过程状态 - 更新测试报告页面契约验证规则 - 添加监测点数和分组数统计展示 - 实现台账准备状态检查和快照功能
This commit is contained in:
@@ -30,7 +30,9 @@ export function wrapperEnv(envConf: Recordable): ViteEnv {
|
||||
if (envName === "VITE_PROXY") {
|
||||
try {
|
||||
realName = JSON.parse(realName);
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
// Keep the original string when the proxy config is not valid JSON.
|
||||
}
|
||||
}
|
||||
ret[envName] = realName;
|
||||
}
|
||||
|
||||
@@ -36,12 +36,16 @@ export const downloadReportTaskLedgerTemplateApi = (): Promise<AxiosResponse<Blo
|
||||
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, {
|
||||
export const validateReportTaskLedgerApi = (id: string, formData: FormData) => {
|
||||
return http.post<ReportTask.ReportTaskLedgerValidateResult>(`${REPORT_TASK_BASE_URL}/${id}/ledger/validate`, formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
export const importReportTaskLedgerApi = (id: string, params: ReportTask.ReportTaskLedgerImportRequest) => {
|
||||
return http.post<ReportTask.ReportTaskLedgerImportResult>(`${REPORT_TASK_BASE_URL}/${id}/ledger/import`, params)
|
||||
}
|
||||
|
||||
export const listReportTaskGroupReportsApi = (id: string) => {
|
||||
return http.get<ReportTask.ReportTaskGroupReportRecord[]>(`${REPORT_TASK_BASE_URL}/${id}/group-report/list`)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
export namespace ReportTask {
|
||||
export type ReportTaskState = '01' | '02' | '03' | '04' | '05'
|
||||
export type ReportTaskGenerateState = 0 | 1 | 2
|
||||
export type ReportTaskGroupReportGenerateState = 0 | 1 | 2 | 3
|
||||
export type ReportTaskLedgerImportStage =
|
||||
| '选择文件'
|
||||
| '校验文件'
|
||||
| '文件上传'
|
||||
| '文件导入'
|
||||
| '基础资料维护'
|
||||
| '完成'
|
||||
|
||||
@@ -23,10 +25,11 @@ export namespace ReportTask {
|
||||
checkerName?: string | null
|
||||
checkTime?: string | null
|
||||
checkResult?: string | null
|
||||
state?: ReportTaskState | null
|
||||
status?: number
|
||||
pointCount?: number | null
|
||||
groupCount?: number | null
|
||||
reportGenerateState?: number | null
|
||||
reportGenerateState?: ReportTaskGenerateState | null
|
||||
createBy?: string | null
|
||||
createByName?: string | null
|
||||
createTime?: string | null
|
||||
@@ -40,6 +43,7 @@ export namespace ReportTask {
|
||||
keyword?: string
|
||||
searchBeginTime?: string
|
||||
searchEndTime?: string
|
||||
state?: ReportTaskState | ''
|
||||
timeRange?: string[]
|
||||
pageNum?: number
|
||||
pageSize?: number
|
||||
@@ -94,11 +98,57 @@ export namespace ReportTask {
|
||||
} | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerValidateAttachment {
|
||||
attachmentName?: string | null
|
||||
attachmentType?: string | null
|
||||
referenced?: boolean | null
|
||||
uploaded?: boolean | null
|
||||
missing?: boolean | null
|
||||
reuploadAllowed?: boolean | null
|
||||
message?: string | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerValidatePoint {
|
||||
rowNo?: number | null
|
||||
pointKey?: string | null
|
||||
substationName?: string | null
|
||||
pointName?: string | null
|
||||
complete?: boolean | null
|
||||
missingAttachmentCount?: number | null
|
||||
testDeviceNoValid?: boolean | null
|
||||
testDeviceNoMessage?: string | null
|
||||
clientUnitNameValid?: boolean | null
|
||||
clientUnitNameMessage?: string | null
|
||||
attachments?: ReportTaskLedgerValidateAttachment[] | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerValidateResult {
|
||||
sessionId?: string | null
|
||||
batchId?: string | null
|
||||
success?: boolean | null
|
||||
summaryFileName?: string | null
|
||||
summaryFilePresent?: boolean | null
|
||||
tempStoragePath?: string | null
|
||||
uploadedFileCount?: number | null
|
||||
pointCount?: number | null
|
||||
missingAttachmentCount?: number | null
|
||||
canContinueUpload?: boolean | null
|
||||
requiredSheets?: string[] | null
|
||||
existingSheets?: string[] | null
|
||||
missingSheets?: string[] | null
|
||||
orphanAttachmentNames?: string[] | null
|
||||
failReasons?: string[] | null
|
||||
points?: ReportTaskLedgerValidatePoint[] | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerImportResult {
|
||||
batchId?: string | null
|
||||
currentStage?: ReportTaskLedgerImportStage | string | null
|
||||
success?: boolean | null
|
||||
summaryFileName?: string | null
|
||||
tempStoragePath?: string | null
|
||||
totalFileCount?: number
|
||||
uploadedFileCount?: number
|
||||
pointCount?: number
|
||||
excelAttachmentCount?: number
|
||||
wordAttachmentCount?: number
|
||||
@@ -111,6 +161,10 @@ export namespace ReportTask {
|
||||
stages?: ReportTaskLedgerImportStageRecord[] | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerImportRequest {
|
||||
batchId: string
|
||||
}
|
||||
|
||||
export interface ReportTaskPointRecord {
|
||||
id?: string
|
||||
groupNo?: number | null
|
||||
@@ -150,9 +204,12 @@ export namespace ReportTask {
|
||||
|
||||
export interface ReportTaskLedgerPreparedState {
|
||||
draftId: string
|
||||
validateSessionId: string
|
||||
validateResult: ReportTaskLedgerValidateResult | null
|
||||
latestImportResult: ReportTaskLedgerImportResult | null
|
||||
snapshot: ReportTaskLedgerImportSnapshot | null
|
||||
hasImported: boolean
|
||||
pendingReimport: boolean
|
||||
validatedBatchId: string
|
||||
pendingRevalidate: boolean
|
||||
}
|
||||
}
|
||||
|
||||
7
frontend/src/types/vite-plugin-eslint.d.ts
vendored
Normal file
7
frontend/src/types/vite-plugin-eslint.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
declare module 'vite-plugin-eslint' {
|
||||
import type { Plugin } from 'vite'
|
||||
|
||||
const eslintPlugin: (options?: Record<string, unknown>) => Plugin
|
||||
|
||||
export default eslintPlugin
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
<template>
|
||||
<div class="form-panel">
|
||||
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="108px" class="report-task-form">
|
||||
<el-row :gutter="16">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="报告编号" prop="no">
|
||||
<el-input v-model="localFormModel.no" maxlength="32" clearable placeholder="请输入报告编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="委托单位" prop="clientUnitId">
|
||||
<el-select v-model="localFormModel.clientUnitId" filterable clearable placeholder="请选择委托单位">
|
||||
<el-option v-for="option in clientUnitSelectOptions" :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="reportModelId">
|
||||
<el-select v-model="localFormModel.reportModelId" filterable clearable placeholder="请选择报告模板">
|
||||
<el-option v-for="option in reportModelSelectOptions" :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="createUnit">
|
||||
<el-select v-model="localFormModel.createUnit" filterable clearable placeholder="请选择检测公司">
|
||||
<el-option v-for="option in companySelectOptions" :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="contractNumber">
|
||||
<el-input v-model="localFormModel.contractNumber" maxlength="32" clearable placeholder="请输入合同编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="测试依据" prop="standardIds">
|
||||
<el-select v-model="localFormModel.standardIds" multiple filterable clearable 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="localFormModel.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>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { checkReportTaskLedgerPrepared } from '../utils/testReport'
|
||||
import type { ReportTaskFormModel } from '../utils/testReportForm'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskBaseInfoStep'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
formModel: ReportTaskFormModel
|
||||
record: ReportTask.ReportTaskRecord | null
|
||||
clientUnitOptions: Array<{ label: string; value: string }>
|
||||
reportModelOptions: Array<{ label: string; value: string }>
|
||||
companyOptions: Array<{ label: string; value: string }>
|
||||
standardOptions: Array<{ label: string; value: string }>
|
||||
preparedState: ReportTask.ReportTaskLedgerPreparedState
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'register-form', value: FormInstance | undefined): void
|
||||
(event: 'update:form-model', value: ReportTaskFormModel): void
|
||||
}>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const localFormModel = reactive<ReportTaskFormModel>({ ...props.formModel })
|
||||
|
||||
const formRules: FormRules = {
|
||||
no: [{ required: true, message: '请输入报告编号', trigger: 'blur' }],
|
||||
clientUnitId: [{ required: true, message: '请选择委托单位', trigger: 'change' }],
|
||||
reportModelId: [{ required: true, message: '请选择报告模板', trigger: 'change' }],
|
||||
createUnit: [{ required: true, message: '请选择检测公司', trigger: 'change' }],
|
||||
contractNumber: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
|
||||
standardIds: [{ required: true, message: '请选择测试依据', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const ensureCurrentOption = (
|
||||
options: Array<{ label: string; value: string }>,
|
||||
value: string,
|
||||
fallbackLabel: string
|
||||
) => {
|
||||
if (!value || options.some(option => option.value === value)) return options
|
||||
return [...options, { label: fallbackLabel || value, value }]
|
||||
}
|
||||
|
||||
const clientUnitSelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.clientUnitOptions, localFormModel.clientUnitId, props.record?.clientUnitName || '')
|
||||
)
|
||||
const reportModelSelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.reportModelOptions, localFormModel.reportModelId, props.record?.reportModelName || '')
|
||||
)
|
||||
const companySelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.companyOptions, localFormModel.createUnit, props.record?.createUnit || '')
|
||||
)
|
||||
const standardSelectOptions = computed(() => {
|
||||
const optionMap = new Map(props.standardOptions.map(option => [option.value, option]))
|
||||
const extraOptions = localFormModel.standardIds.filter(item => !optionMap.has(item)).map(item => ({ label: item, value: item }))
|
||||
return [...props.standardOptions, ...extraOptions]
|
||||
})
|
||||
|
||||
const canSubmit = computed(() => checkReportTaskLedgerPrepared(props.preparedState))
|
||||
const importSummary = computed(() => {
|
||||
const importResult = props.preparedState.latestImportResult
|
||||
const snapshot = props.preparedState.snapshot
|
||||
|
||||
return {
|
||||
pointCount: String(importResult?.pointCount ?? snapshot?.rowCount ?? '-'),
|
||||
groupCount: String(importResult?.groupCount ?? snapshot?.groupSummary?.length ?? '-'),
|
||||
summaryFileName: importResult?.summaryFileName || snapshot?.summaryFileName || '-'
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
formRef,
|
||||
value => {
|
||||
emit('register-form', value)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.formModel,
|
||||
value => {
|
||||
Object.assign(localFormModel, value)
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
localFormModel,
|
||||
value => {
|
||||
emit('update:form-model', { ...value, standardIds: [...value.standardIds] })
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.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);
|
||||
}
|
||||
|
||||
:deep(.report-task-form .el-form-item) {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
:deep(.el-select),
|
||||
:deep(.el-input) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.summary-strip {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<div class="complete-panel">
|
||||
<el-result
|
||||
icon="success"
|
||||
:title="mode === 'create' ? '报告任务新增完成' : '报告任务编辑完成'"
|
||||
sub-title="文件导入与基础信息保存均已完成,本次结果已同步刷新到列表。"
|
||||
/>
|
||||
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="报告编号">{{ formModel.no || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="委托单位">{{ resolveCurrentOptionLabel(clientUnitOptions, formModel.clientUnitId) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="检测公司">{{ resolveCurrentOptionLabel(companyOptions, 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>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import type { ReportTaskFormModel } from '../utils/testReportForm'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskCompleteStep'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
mode: 'create' | 'edit'
|
||||
formModel: ReportTaskFormModel
|
||||
preparedState: ReportTask.ReportTaskLedgerPreparedState
|
||||
clientUnitOptions: Array<{ label: string; value: string }>
|
||||
companyOptions: Array<{ label: string; value: string }>
|
||||
}>()
|
||||
|
||||
const resolveCurrentOptionLabel = (options: Array<{ label: string; value: string }>, value: string) =>
|
||||
options.find(option => option.value === value)?.label || value || '-'
|
||||
|
||||
const importSummary = {
|
||||
pointCount: String(props.preparedState.latestImportResult?.pointCount ?? props.preparedState.snapshot?.rowCount ?? '-'),
|
||||
groupCount: String(props.preparedState.latestImportResult?.groupCount ?? props.preparedState.snapshot?.groupSummary?.length ?? '-'),
|
||||
summaryFileName: props.preparedState.latestImportResult?.summaryFileName || props.preparedState.snapshot?.summaryFileName || '-'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.complete-panel {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
padding: 18px;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
</style>
|
||||
@@ -6,17 +6,17 @@
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
class="report-task-flow-dialog"
|
||||
@closed="resetForm"
|
||||
@closed="resetFlow"
|
||||
>
|
||||
<div class="report-task-form-dialog">
|
||||
<div class="flow-nav">
|
||||
<button
|
||||
v-for="step in REPORT_TASK_FORM_STEPS"
|
||||
v-for="step in REPORT_TASK_FLOW_STEPS"
|
||||
:key="step.value"
|
||||
type="button"
|
||||
class="flow-step"
|
||||
:class="[`is-${resolveStepStatus(step.value)}`, { 'is-clickable': canSwitchStep(step.value) }]"
|
||||
:disabled="!canSwitchStep(step.value)"
|
||||
:class="[`is-${resolveFlowStepStatus(step.value, currentStep, ledgerPreparedState)}`, { 'is-clickable': canReachFlowStep(step.value, ledgerPreparedState, currentStep) }]"
|
||||
:disabled="!canReachFlowStep(step.value, ledgerPreparedState, currentStep)"
|
||||
@click="handleStepClick(step.value)"
|
||||
>
|
||||
<span class="flow-step-index">{{ step.index }}</span>
|
||||
@@ -27,149 +27,65 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="report-task-form-body">
|
||||
<div class="flow-main">
|
||||
<div v-if="currentStep === 'import'" class="flow-panel">
|
||||
<ReportTaskLedgerImportPanel
|
||||
<ReportTaskPrepareStep
|
||||
v-if="currentStep === 'prepare'"
|
||||
:draft-id="activeDraftId"
|
||||
:disabled="saving"
|
||||
:prepared-state="ledgerPreparedState"
|
||||
:snapshot="ledgerSnapshot"
|
||||
@change="handleLedgerPreparedChange"
|
||||
@log="handleLog"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-else-if="currentStep === 'form'" class="flow-panel">
|
||||
<div class="form-panel">
|
||||
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="108px" class="report-task-form">
|
||||
<el-row :gutter="16">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="报告编号" prop="no">
|
||||
<el-input v-model="formModel.no" maxlength="32" clearable placeholder="请输入报告编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="委托单位" prop="clientUnitId">
|
||||
<el-select v-model="formModel.clientUnitId" filterable clearable placeholder="请选择委托单位">
|
||||
<el-option
|
||||
v-for="option in clientUnitSelectOptions"
|
||||
: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="reportModelId">
|
||||
<el-select v-model="formModel.reportModelId" filterable clearable placeholder="请选择报告模板">
|
||||
<el-option
|
||||
v-for="option in reportModelSelectOptions"
|
||||
: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="createUnit">
|
||||
<el-select v-model="formModel.createUnit" filterable clearable placeholder="请选择检测公司">
|
||||
<el-option
|
||||
v-for="option in companySelectOptions"
|
||||
: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="contractNumber">
|
||||
<el-input v-model="formModel.contractNumber" maxlength="32" clearable placeholder="请输入合同编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="测试依据" prop="standardIds">
|
||||
<el-select
|
||||
v-model="formModel.standardIds"
|
||||
multiple
|
||||
filterable
|
||||
clearable
|
||||
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="台账导入与基础信息保存均已完成,本次结果已同步刷新到列表。"
|
||||
<ReportTaskImportStep
|
||||
v-else-if="currentStep === 'import'"
|
||||
:disabled="saving"
|
||||
:prepared-state="ledgerPreparedState"
|
||||
:snapshot="ledgerPreparedState.snapshot"
|
||||
@change="handleLedgerPreparedChange"
|
||||
@log="handleLog"
|
||||
/>
|
||||
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="报告编号">{{ formModel.no || '-' }}</el-descriptions-item>
|
||||
<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>
|
||||
<ReportTaskBaseInfoStep
|
||||
v-else-if="currentStep === 'form'"
|
||||
:form-model="formModel"
|
||||
:record="record"
|
||||
:client-unit-options="clientUnitOptions"
|
||||
:report-model-options="reportModelOptions"
|
||||
:company-options="companyOptions"
|
||||
:standard-options="standardOptions"
|
||||
:prepared-state="ledgerPreparedState"
|
||||
@register-form="handleRegisterForm"
|
||||
@update:form-model="handleFormModelChange"
|
||||
/>
|
||||
|
||||
<ReportTaskCompleteStep
|
||||
v-else
|
||||
:mode="mode"
|
||||
:form-model="formModel"
|
||||
:prepared-state="ledgerPreparedState"
|
||||
:client-unit-options="clientUnitOptions"
|
||||
:company-options="companyOptions"
|
||||
/>
|
||||
</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>
|
||||
<aside class="log-floating-panel" :class="{ 'is-collapsed': !logPanelExpanded }">
|
||||
<el-button
|
||||
class="log-panel-collapse-toggle"
|
||||
type="primary"
|
||||
:icon="logPanelExpanded ? ArrowRight : ArrowLeft"
|
||||
circle
|
||||
@click="logPanelExpanded = !logPanelExpanded"
|
||||
/>
|
||||
|
||||
<div v-show="logPanelExpanded" class="log-panel-body">
|
||||
<div v-show="logPanelExpanded" class="log-panel-body-wrapper">
|
||||
<div class="log-panel">
|
||||
<div class="log-panel-header">
|
||||
<div class="log-title">异常日志</div>
|
||||
</div>
|
||||
|
||||
<div 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">
|
||||
@@ -177,20 +93,30 @@
|
||||
<el-tag size="small" :type="resolveLogTagType(entry.type)">{{ resolveLogTypeText(entry.type) }}</el-tag>
|
||||
<span class="log-time">{{ entry.time }}</span>
|
||||
</div>
|
||||
<el-tooltip :content="entry.message" placement="top-start">
|
||||
<div class="log-message">{{ entry.message }}</div>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="当前暂无日志输出" :image-size="60" />
|
||||
<el-empty v-else description="当前暂无日志输出" :image-size="60" class="log-empty" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button :disabled="saving" @click="visibleProxy = false">{{ currentStep === 'done' ? '关闭' : '取消' }}</el-button>
|
||||
|
||||
<template v-if="currentStep === 'import'">
|
||||
<el-button type="primary" :disabled="!canSubmit" @click="goToFormStep">下一步</el-button>
|
||||
<template v-if="currentStep === 'prepare'">
|
||||
<el-button type="primary" :disabled="!canGoToImport" @click="goToImportStep">下一步</el-button>
|
||||
</template>
|
||||
|
||||
<template v-else-if="currentStep === 'import'">
|
||||
<el-button type="primary" plain :disabled="saving" @click="goToPrepareStep">上一步</el-button>
|
||||
<el-button type="primary" :disabled="!canGoToForm" @click="goToFormStep">下一步</el-button>
|
||||
</template>
|
||||
|
||||
<template v-else-if="currentStep === 'form'">
|
||||
@@ -202,52 +128,32 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { ArrowLeft, ArrowRight } from '@element-plus/icons-vue'
|
||||
import { ElMessage, type FormInstance } from 'element-plus'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { generateUUID } from '@/utils'
|
||||
import ReportTaskLedgerImportPanel from './ReportTaskLedgerImportPanel.vue'
|
||||
import ReportTaskBaseInfoStep from './ReportTaskBaseInfoStep.vue'
|
||||
import ReportTaskCompleteStep from './ReportTaskCompleteStep.vue'
|
||||
import ReportTaskImportStep from './ReportTaskImportStep.vue'
|
||||
import ReportTaskPrepareStep from './ReportTaskPrepareStep.vue'
|
||||
import {
|
||||
checkReportTaskLedgerPrepared,
|
||||
getReportTaskErrorMessage,
|
||||
normalizeReportTaskLedgerSnapshot,
|
||||
parseReportTaskStandardIds,
|
||||
stringifyReportTaskStandardIds
|
||||
} from '../utils/testReport'
|
||||
REPORT_TASK_FLOW_STEPS,
|
||||
canReachFlowStep,
|
||||
createEmptyLedgerPreparedState,
|
||||
hasValidatedLedgerBatch,
|
||||
resolveFlowStepStatus,
|
||||
resolveInitialFlowStep,
|
||||
type ReportTaskFlowStep
|
||||
} from '../utils/reportTaskFlow'
|
||||
import { buildReportTaskFormContext, buildReportTaskSavePayload, createDefaultReportTaskFormModel } from '../utils/testReportForm'
|
||||
import { checkReportTaskLedgerPrepared, getReportTaskErrorMessage } from '../utils/testReport'
|
||||
|
||||
defineOptions({
|
||||
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<{
|
||||
visible: boolean
|
||||
mode: 'create' | 'edit'
|
||||
@@ -263,90 +169,29 @@ const props = defineProps<{
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
(event: 'submit', value: ReportTask.ReportTaskSaveRequest): void
|
||||
(event: 'refresh-options'): void
|
||||
}>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const activeDraftId = ref('')
|
||||
const currentStep = ref<ReportTaskFormStep>('import')
|
||||
const logPanelExpanded = ref(true)
|
||||
const currentStep = ref<ReportTaskFlowStep>('prepare')
|
||||
const logPanelExpanded = ref(false)
|
||||
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 ledgerPreparedState = reactive(createEmptyLedgerPreparedState())
|
||||
const formModel = reactive(createDefaultReportTaskFormModel())
|
||||
const lastHandledSaveSuccessVersion = ref(0)
|
||||
|
||||
const formModel = reactive({
|
||||
id: '',
|
||||
no: '',
|
||||
clientUnitId: '',
|
||||
reportModelId: '',
|
||||
createUnit: '',
|
||||
contractNumber: '',
|
||||
standardIds: [] as string[],
|
||||
data: '',
|
||||
phonenumber: ''
|
||||
})
|
||||
|
||||
const formRules: FormRules = {
|
||||
no: [{ required: true, message: '请输入报告编号', trigger: 'blur' }],
|
||||
clientUnitId: [{ required: true, message: '请选择委托单位', trigger: 'change' }],
|
||||
reportModelId: [{ required: true, message: '请选择报告模板', trigger: 'change' }],
|
||||
createUnit: [{ required: true, message: '请选择检测公司', trigger: 'change' }],
|
||||
contractNumber: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
|
||||
standardIds: [{ required: true, message: '请选择测试依据', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
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
|
||||
const canGoToImport = computed(() => hasValidatedLedgerBatch(ledgerPreparedState))
|
||||
const canVisitImport = computed(() => canGoToImport.value || ledgerPreparedState.hasImported || Boolean(ledgerPreparedState.snapshot))
|
||||
const canGoToForm = computed(() => checkReportTaskLedgerPrepared(ledgerPreparedState))
|
||||
const canSubmit = computed(() => !props.saving && checkReportTaskLedgerPrepared(ledgerPreparedState))
|
||||
|
||||
return {
|
||||
pointCount: String(importResult?.pointCount ?? snapshot?.rowCount ?? '-'),
|
||||
groupCount: String(importResult?.groupCount ?? snapshot?.groupSummary?.length ?? '-'),
|
||||
summaryFileName: importResult?.summaryFileName || snapshot?.summaryFileName || '-'
|
||||
}
|
||||
})
|
||||
|
||||
const ensureCurrentOption = (
|
||||
options: Array<{ label: string; value: string }>,
|
||||
value: string,
|
||||
fallbackLabel: string
|
||||
) => {
|
||||
if (!value || options.some(option => option.value === value)) return options
|
||||
|
||||
return [...options, { label: fallbackLabel || value, value }]
|
||||
}
|
||||
|
||||
const clientUnitSelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.clientUnitOptions, formModel.clientUnitId, props.record?.clientUnitName || '')
|
||||
)
|
||||
const reportModelSelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.reportModelOptions, formModel.reportModelId, props.record?.reportModelName || '')
|
||||
)
|
||||
const companySelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.companyOptions, formModel.createUnit, props.record?.createUnit || '')
|
||||
)
|
||||
const standardSelectOptions = computed(() => {
|
||||
const optionMap = new Map(props.standardOptions.map(option => [option.value, option]))
|
||||
const extraOptions = formModel.standardIds
|
||||
.filter(item => !optionMap.has(item))
|
||||
.map(item => ({ label: item, value: item }))
|
||||
|
||||
return [...props.standardOptions, ...extraOptions]
|
||||
})
|
||||
|
||||
const buildLogId = () => window.crypto?.randomUUID?.() || generateUUID()
|
||||
const buildLogId = () => window.crypto?.randomUUID?.() || `${Date.now()}-${Math.random().toString(16).slice(2)}`
|
||||
|
||||
const pushLog = (type: ReportTaskLogType, message: string) => {
|
||||
logEntries.value.push({
|
||||
@@ -361,8 +206,13 @@ 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 handleRegisterForm = (value: FormInstance | undefined) => {
|
||||
formRef.value = value
|
||||
}
|
||||
|
||||
const handleFormModelChange = (value: typeof formModel) => {
|
||||
Object.assign(formModel, value)
|
||||
}
|
||||
|
||||
const resolveLogTagType = (type: ReportTaskLogType) => {
|
||||
if (type === 'success') return 'success'
|
||||
@@ -378,122 +228,102 @@ const resolveLogTypeText = (type: ReportTaskLogType) => {
|
||||
return '信息'
|
||||
}
|
||||
|
||||
const resetForm = () => {
|
||||
const resetFlow = () => {
|
||||
formRef.value?.clearValidate()
|
||||
formModel.id = ''
|
||||
formModel.no = ''
|
||||
formModel.clientUnitId = ''
|
||||
formModel.reportModelId = ''
|
||||
formModel.createUnit = ''
|
||||
formModel.contractNumber = ''
|
||||
formModel.standardIds = []
|
||||
formModel.data = ''
|
||||
formModel.phonenumber = ''
|
||||
Object.assign(formModel, createDefaultReportTaskFormModel())
|
||||
activeDraftId.value = ''
|
||||
currentStep.value = 'import'
|
||||
logPanelExpanded.value = true
|
||||
currentStep.value = 'prepare'
|
||||
logPanelExpanded.value = false
|
||||
logEntries.value = []
|
||||
ledgerPreparedState.value = {
|
||||
draftId: '',
|
||||
latestImportResult: null,
|
||||
snapshot: null,
|
||||
hasImported: false,
|
||||
pendingReimport: false
|
||||
}
|
||||
Object.assign(ledgerPreparedState, createEmptyLedgerPreparedState())
|
||||
}
|
||||
|
||||
const buildDraftId = () => {
|
||||
if (props.mode === 'edit') {
|
||||
return String(props.record?.id || '').trim()
|
||||
}
|
||||
|
||||
return window.crypto?.randomUUID?.() || generateUUID()
|
||||
}
|
||||
|
||||
const applyInitialStep = (hasPreparedLedger: boolean) => {
|
||||
if (props.mode === 'edit' && hasPreparedLedger) {
|
||||
currentStep.value = 'form'
|
||||
pushLog('info', '编辑场景检测到已有导入结果,默认进入基础信息填写步骤')
|
||||
return
|
||||
}
|
||||
|
||||
currentStep.value = 'import'
|
||||
pushLog('info', '已进入数据导入步骤,请先完成台账导入')
|
||||
}
|
||||
|
||||
const fillForm = async () => {
|
||||
const fillFlowContext = 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,
|
||||
const context = buildReportTaskFormContext(props.mode, props.record)
|
||||
Object.assign(formModel, context.formModel)
|
||||
activeDraftId.value = context.draftId
|
||||
Object.assign(ledgerPreparedState, {
|
||||
draftId: context.draftId,
|
||||
validateSessionId: '',
|
||||
validateResult: null,
|
||||
latestImportResult: null,
|
||||
snapshot,
|
||||
hasImported: Boolean(snapshot || Number(record?.pointCount) > 0),
|
||||
pendingReimport: false
|
||||
snapshot: context.snapshot,
|
||||
hasImported: context.hasPreparedImport,
|
||||
validatedBatchId: '',
|
||||
pendingRevalidate: false
|
||||
})
|
||||
|
||||
currentStep.value = resolveInitialFlowStep(props.mode, ledgerPreparedState)
|
||||
if (currentStep.value === 'form') {
|
||||
pushLog('info', '编辑场景检测到已有导入结果,默认进入基础信息维护步骤')
|
||||
} else {
|
||||
pushLog('info', '已进入文件选择与校验步骤,请先完成文件准备')
|
||||
}
|
||||
|
||||
applyInitialStep(Boolean(snapshot || Number(record?.pointCount) > 0))
|
||||
if (snapshot) {
|
||||
pushLog('info', `已加载最近一次导入快照:${snapshot.summaryFileName || '未命名汇总文件'}`)
|
||||
if (context.snapshot) {
|
||||
pushLog('info', `已加载最近一次导入快照:${context.snapshot.summaryFileName || '未命名汇总文件'}`)
|
||||
}
|
||||
} catch (error) {
|
||||
const message = getReportTaskErrorMessage(error, '报告任务台账快照加载失败')
|
||||
const message = getReportTaskErrorMessage(error, '报告任务初始化失败')
|
||||
ElMessage.error(message)
|
||||
pushLog('error', message)
|
||||
}
|
||||
}
|
||||
|
||||
const goToPrepareStep = () => {
|
||||
currentStep.value = 'prepare'
|
||||
pushLog('info', '已返回文件选择与校验步骤')
|
||||
}
|
||||
|
||||
const goToImportStep = () => {
|
||||
if (!canVisitImport.value) {
|
||||
pushLog('warning', '当前文件校验尚未通过,不能进入正式导入步骤')
|
||||
return
|
||||
}
|
||||
|
||||
currentStep.value = 'import'
|
||||
pushLog('info', '已切换到文件导入步骤')
|
||||
}
|
||||
|
||||
const goToFormStep = () => {
|
||||
if (!canSubmit.value) {
|
||||
pushLog('warning', '当前导入尚未完成,不能进入基础信息填写步骤')
|
||||
if (!canGoToForm.value) {
|
||||
pushLog('warning', '当前正式导入尚未完成,不能进入基础信息维护步骤')
|
||||
return
|
||||
}
|
||||
|
||||
currentStep.value = 'form'
|
||||
pushLog('info', '已切换到基础信息填写步骤')
|
||||
}
|
||||
|
||||
const goToImportStep = () => {
|
||||
currentStep.value = 'import'
|
||||
pushLog('info', '已返回数据导入步骤,可继续沿用当前结果或重新导入台账')
|
||||
pushLog('info', '已切换到基础信息维护步骤')
|
||||
}
|
||||
|
||||
const handleLedgerPreparedChange = (value: ReportTask.ReportTaskLedgerPreparedState) => {
|
||||
const wasPrepared = checkReportTaskLedgerPrepared(ledgerPreparedState.value)
|
||||
const nextState = {
|
||||
const wasReadyForImport = hasValidatedLedgerBatch(ledgerPreparedState)
|
||||
const wasReadyForSubmit = checkReportTaskLedgerPrepared(ledgerPreparedState)
|
||||
|
||||
Object.assign(ledgerPreparedState, {
|
||||
...value,
|
||||
draftId: activeDraftId.value
|
||||
})
|
||||
|
||||
if (!wasReadyForImport && hasValidatedLedgerBatch(ledgerPreparedState) && currentStep.value === 'prepare') {
|
||||
currentStep.value = 'import'
|
||||
pushLog('success', '文件校验已通过,已自动进入正式导入步骤')
|
||||
return
|
||||
}
|
||||
|
||||
ledgerPreparedState.value = nextState
|
||||
|
||||
if (!wasPrepared && checkReportTaskLedgerPrepared(nextState) && currentStep.value === 'import') {
|
||||
if (!wasReadyForSubmit && checkReportTaskLedgerPrepared(ledgerPreparedState)) {
|
||||
emit('refresh-options')
|
||||
currentStep.value = 'form'
|
||||
pushLog('success', '台账导入已完成,已自动进入基础信息填写步骤')
|
||||
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: ReportTaskFlowStep) => {
|
||||
if (!canReachFlowStep(step, ledgerPreparedState, currentStep.value)) return
|
||||
if (step === 'prepare') {
|
||||
goToPrepareStep()
|
||||
return
|
||||
}
|
||||
|
||||
const handleStepClick = (step: ReportTaskFormStep) => {
|
||||
if (!canSwitchStep(step)) return
|
||||
if (step === 'import') {
|
||||
goToImportStep()
|
||||
return
|
||||
@@ -503,19 +333,12 @@ const handleStepClick = (step: ReportTaskFormStep) => {
|
||||
}
|
||||
}
|
||||
|
||||
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(
|
||||
() => [props.visible, props.mode, props.record?.id],
|
||||
async ([visible]) => {
|
||||
if (!visible) return
|
||||
resetForm()
|
||||
await fillForm()
|
||||
resetFlow()
|
||||
await fillFlowContext()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
@@ -538,26 +361,16 @@ const submitForm = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
if (!checkReportTaskLedgerPrepared(ledgerPreparedState.value)) {
|
||||
const message = '请先完成台账导入后再提交基础信息'
|
||||
if (!checkReportTaskLedgerPrepared(ledgerPreparedState)) {
|
||||
const message = '请先完成正式导入后再提交基础信息'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
return
|
||||
}
|
||||
|
||||
// 关键业务节点:当前弹窗只接受已完成 ledger/import 的任务,再执行最终 add/update 保存基础信息。
|
||||
// 关键业务节点:当前弹窗只接受已完成 ledger/validate -> ledger/import 的任务,再执行最终 add/update 保存基础信息。
|
||||
pushLog('info', props.mode === 'create' ? '开始提交新增任务基础信息' : '开始提交编辑后的任务基础信息')
|
||||
emit('submit', {
|
||||
id: activeDraftId.value || formModel.id || undefined,
|
||||
no: formModel.no.trim(),
|
||||
clientUnitId: formModel.clientUnitId,
|
||||
reportModelId: formModel.reportModelId,
|
||||
createUnit: formModel.createUnit,
|
||||
contractNumber: formModel.contractNumber.trim(),
|
||||
standard: stringifyReportTaskStandardIds(formModel.standardIds),
|
||||
data: formModel.data.trim(),
|
||||
phonenumber: formModel.phonenumber.trim() || undefined
|
||||
})
|
||||
emit('submit', buildReportTaskSavePayload(activeDraftId.value, formModel))
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -567,15 +380,15 @@ const submitForm = async () => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
height: 560px;
|
||||
min-height: 0;
|
||||
padding-bottom: 24px;
|
||||
}
|
||||
|
||||
.flow-nav {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 0;
|
||||
padding: 22px 18px 18px;
|
||||
padding: 16px 18px 12px;
|
||||
border: 1px solid #d9ebe7;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
@@ -586,8 +399,8 @@ const submitForm = async () => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0 12px 18px;
|
||||
gap: 6px;
|
||||
padding: 0 12px 10px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
text-align: center;
|
||||
@@ -684,97 +497,83 @@ const submitForm = async () => {
|
||||
color: #b9bfc9;
|
||||
}
|
||||
|
||||
.flow-main {
|
||||
.report-task-form-body {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
padding-bottom: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.flow-panel {
|
||||
.flow-main {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.log-floating-panel {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
bottom: 12px;
|
||||
z-index: 4000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
align-items: flex-end;
|
||||
width: 300px;
|
||||
min-height: 0;
|
||||
transition: width 0.2s ease;
|
||||
}
|
||||
|
||||
.form-panel {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
padding: 18px;
|
||||
background: var(--el-fill-color-blank);
|
||||
.log-floating-panel.is-collapsed {
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.summary-strip {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 8px;
|
||||
.log-panel-collapse-toggle {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
left: -28px;
|
||||
flex-shrink: 0;
|
||||
z-index: 4001;
|
||||
}
|
||||
|
||||
.summary-item {
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
background: var(--el-fill-color-light);
|
||||
.log-panel-body-wrapper {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
z-index: 4000;
|
||||
isolation: isolate;
|
||||
}
|
||||
|
||||
.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-floating-panel.is-collapsed .log-panel-body-wrapper {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.log-panel {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 8px;
|
||||
z-index: 3;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
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);
|
||||
box-shadow: var(--el-box-shadow-light);
|
||||
}
|
||||
|
||||
.log-panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
min-height: 46px;
|
||||
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 {
|
||||
@@ -785,15 +584,23 @@ const submitForm = async () => {
|
||||
}
|
||||
|
||||
.log-panel-body {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
border-top: 1px solid #d9e3ff;
|
||||
background: #fff;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.log-popover-body {
|
||||
max-height: 160px;
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 0;
|
||||
background: #fff;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.log-list {
|
||||
@@ -803,7 +610,7 @@ const submitForm = async () => {
|
||||
|
||||
.log-item {
|
||||
display: grid;
|
||||
grid-template-columns: 180px minmax(0, 1fr);
|
||||
grid-template-columns: 116px minmax(0, 1fr);
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
@@ -813,27 +620,27 @@ const submitForm = async () => {
|
||||
|
||||
.log-meta,
|
||||
.log-message {
|
||||
padding: 10px 14px;
|
||||
padding: 8px 10px;
|
||||
}
|
||||
|
||||
.log-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
gap: 6px;
|
||||
border-right: 1px solid var(--el-border-color-lighter);
|
||||
background: #f6f8ff;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.log-time {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
color: var(--el-text-color-secondary);
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.log-message {
|
||||
font-size: 13px;
|
||||
line-height: 1.3;
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
color: var(--el-text-color-primary);
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
@@ -841,29 +648,41 @@ const submitForm = async () => {
|
||||
}
|
||||
|
||||
.log-empty {
|
||||
padding: 18px 0;
|
||||
}
|
||||
|
||||
:deep(.report-task-form .el-form-item) {
|
||||
margin-bottom: 18px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
min-height: 180px;
|
||||
}
|
||||
|
||||
:deep(.report-task-flow-dialog .el-dialog__body) {
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-select),
|
||||
:deep(.el-input) {
|
||||
width: 100%;
|
||||
:deep(.report-task-flow-dialog .el-dialog) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: calc(100vh - 40px);
|
||||
}
|
||||
|
||||
:deep(.report-task-flow-dialog .el-table__fixed),
|
||||
:deep(.report-task-flow-dialog .el-table__fixed-right),
|
||||
:deep(.report-task-flow-dialog .el-table__fixed-right-patch) {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
:deep(.report-task-flow-dialog .el-table__body-wrapper),
|
||||
:deep(.report-task-flow-dialog .el-scrollbar),
|
||||
:deep(.report-task-flow-dialog .el-scrollbar__bar),
|
||||
:deep(.report-task-flow-dialog .el-scrollbar__thumb) {
|
||||
z-index: 1 !important;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.flow-nav,
|
||||
.summary-strip {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.flow-nav {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
}
|
||||
@@ -885,6 +704,23 @@ const submitForm = async () => {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.log-floating-panel {
|
||||
position: static;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
min-height: 220px;
|
||||
}
|
||||
|
||||
.log-floating-panel.is-collapsed {
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.log-panel-collapse-toggle {
|
||||
position: static;
|
||||
align-self: flex-end;
|
||||
}
|
||||
|
||||
.log-panel-header {
|
||||
padding: 0 14px;
|
||||
}
|
||||
@@ -897,6 +733,5 @@ const submitForm = async () => {
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
<template>
|
||||
<div class="report-task-step">
|
||||
<div class="panel-block">
|
||||
<div class="section-header">
|
||||
<div class="section-title">文件导入</div>
|
||||
<div class="section-desc">基于上一阶段校验通过的批次执行正式导入。</div>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="preparedState.pendingRevalidate"
|
||||
title="文件已变更,当前不能继续导入,请先返回上一步重新校验。"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="section-alert"
|
||||
/>
|
||||
|
||||
<el-descriptions :column="3" border>
|
||||
<el-descriptions-item label="sessionId">{{ resolveReportTaskText(preparedState.validateSessionId) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="校验批次">{{ resolveReportTaskText(preparedState.validatedBatchId) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="汇总文件">
|
||||
{{ resolveReportTaskText(preparedState.validateResult?.summaryFileName || snapshot?.summaryFileName) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="已上传文件数">
|
||||
{{ resolveReportTaskText(preparedState.validateResult?.uploadedFileCount) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点数">
|
||||
{{ resolveReportTaskText(preparedState.validateResult?.pointCount || snapshot?.rowCount) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="可继续补传">
|
||||
<el-tag :type="preparedState.validateResult?.canContinueUpload ? 'warning' : 'info'">
|
||||
{{ preparedState.validateResult?.canContinueUpload ? '是' : '否' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div class="action-bar">
|
||||
<el-button type="primary" :icon="UploadFilled" :loading="importing" :disabled="disabled || !canImport" @click="handleImport">
|
||||
执行导入
|
||||
</el-button>
|
||||
</div>
|
||||
</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.batchId) }}</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.uploadedFileCount) }}</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="临时目录">{{ resolveReportTaskText(latestImportResult.tempStoragePath) }}</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>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { UploadFilled } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { computed, ref } from 'vue'
|
||||
import { importReportTaskLedgerApi } from '@/api/aireport/testReport'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { hasValidatedLedgerBatch } from '../utils/reportTaskFlow'
|
||||
import {
|
||||
TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER,
|
||||
checkReportTaskLedgerPrepared,
|
||||
getReportTaskErrorMessage,
|
||||
normalizeReportTaskLedgerImportResult,
|
||||
resolveReportTaskText
|
||||
} from '../utils/testReport'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskImportStep'
|
||||
})
|
||||
|
||||
type ReportTaskLogType = 'info' | 'success' | 'warning' | 'error'
|
||||
|
||||
const props = defineProps<{
|
||||
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 latestImportResult = computed(() => props.preparedState.latestImportResult)
|
||||
const canImport = computed(() => hasValidatedLedgerBatch(props.preparedState))
|
||||
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.stage === '文件导入' || stage.stage === '基础资料维护' || stage.stage === '完成' ? stage.message || stage.success : false
|
||||
)
|
||||
})
|
||||
|
||||
const pushLog = (type: ReportTaskLogType, message: string) => emit('log', { type, message })
|
||||
|
||||
const updatePreparedState = (patch: Partial<ReportTask.ReportTaskLedgerPreparedState>) => {
|
||||
emit('change', {
|
||||
...props.preparedState,
|
||||
...patch
|
||||
})
|
||||
}
|
||||
|
||||
const handleImport = async () => {
|
||||
if (importing.value) return
|
||||
|
||||
if (!canImport.value) {
|
||||
const message = '请先完成文件校验并拿到导入批次后再执行正式导入'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
return
|
||||
}
|
||||
|
||||
importing.value = true
|
||||
pushLog('info', `开始执行正式导入,校验批次:${props.preparedState.validatedBatchId}`)
|
||||
|
||||
try {
|
||||
// 关键业务节点:创建和编辑都统一使用 ledger/validate -> ledger/import,只有正式导入成功后才允许继续执行 add/update。
|
||||
const response = await importReportTaskLedgerApi(props.preparedState.draftId, {
|
||||
batchId: props.preparedState.validatedBatchId
|
||||
})
|
||||
const normalizedResult = normalizeReportTaskLedgerImportResult(response)
|
||||
|
||||
updatePreparedState({
|
||||
latestImportResult: normalizedResult,
|
||||
hasImported: Boolean(normalizedResult.success),
|
||||
pendingRevalidate: false
|
||||
})
|
||||
|
||||
if (
|
||||
!checkReportTaskLedgerPrepared({
|
||||
...props.preparedState,
|
||||
latestImportResult: normalizedResult,
|
||||
hasImported: Boolean(normalizedResult.success),
|
||||
pendingRevalidate: 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">
|
||||
.report-task-step {
|
||||
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);
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.section-desc {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.section-alert,
|
||||
.stage-table,
|
||||
.fail-reason + .fail-reason,
|
||||
.action-bar {
|
||||
margin-top: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,426 +0,0 @@
|
||||
<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>
|
||||
@@ -0,0 +1,588 @@
|
||||
<template>
|
||||
<div class="report-task-step">
|
||||
<div class="panel-block">
|
||||
<div class="section-header">
|
||||
<div class="section-title">文件准备</div>
|
||||
<div class="section-desc">先选择台账汇总与附件,再执行校验并根据会话结果决定是否继续补传。</div>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="preparedState.pendingRevalidate"
|
||||
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 || validating"
|
||||
@change="handleFileChange"
|
||||
@remove="handleFileRemove"
|
||||
>
|
||||
<template #trigger>
|
||||
<el-button type="primary" plain :icon="FolderOpened" :disabled="disabled || validating">选择文件</el-button>
|
||||
</template>
|
||||
</el-upload>
|
||||
|
||||
<el-button type="primary" :icon="Select" :loading="validating" :disabled="disabled" @click="handleValidateFiles">
|
||||
执行校验
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedFiles.length" class="file-summary-grid">
|
||||
<div class="file-summary-card">
|
||||
<span class="file-summary-label">汇总台账</span>
|
||||
<span class="file-summary-value">{{ summaryLedgerFileName || '未选择' }}</span>
|
||||
</div>
|
||||
<div class="file-summary-card">
|
||||
<span class="file-summary-label">附件数量</span>
|
||||
<span class="file-summary-value">{{ otherAttachmentFiles.length }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-button class="toolbar-download" type="primary" plain :icon="Download" :disabled="disabled || validating" @click="handleDownloadTemplate">
|
||||
下载模板
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
title="该步骤只负责 ledger/validate;只有校验通过且返回导入批次后,才允许进入正式导入。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="section-alert"
|
||||
/>
|
||||
|
||||
<div v-if="selectedFiles.length" class="file-table-wrap">
|
||||
<el-table :data="selectedFiles" border size="small" height="100%" 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 || validating" @click="removeSelectedFile($index)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<el-empty v-else description="尚未选择待校验文件" :image-size="88" />
|
||||
</div>
|
||||
|
||||
<div v-if="validateResult" 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="sessionId">{{ resolveReportTaskText(validateResult.sessionId) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="导入批次">{{ resolveReportTaskText(validateResult.batchId) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="校验状态">
|
||||
<el-tag :type="validateResult.success ? 'success' : 'warning'">
|
||||
{{ validateResult.success ? '通过' : '未通过' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="汇总文件">{{ resolveReportTaskText(validateResult.summaryFileName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="已上传文件数">{{ resolveReportTaskText(validateResult.uploadedFileCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点数">{{ resolveReportTaskText(validateResult.pointCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="缺失附件数">{{ resolveReportTaskText(validateResult.missingAttachmentCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="可继续补传">
|
||||
<el-tag :type="validateResult.canContinueUpload ? 'warning' : 'info'">
|
||||
{{ validateResult.canContinueUpload ? '是' : '否' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="临时目录">{{ resolveReportTaskText(validateResult.tempStoragePath) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div v-if="validateResult.failReasons?.length || validateResult.missingSheets?.length || validateResult.orphanAttachmentNames?.length" class="warning-grid">
|
||||
<el-alert
|
||||
v-if="validateResult.failReasons?.length"
|
||||
:title="`存在 ${validateResult.failReasons.length} 条校验提示`"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
>
|
||||
<template #default>
|
||||
<div v-for="reason in validateResult.failReasons" :key="reason" class="fail-reason">{{ reason }}</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<el-alert
|
||||
v-if="validateResult.missingSheets?.length"
|
||||
:title="`缺少 ${validateResult.missingSheets.length} 个必需 sheet`"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
>
|
||||
<template #default>
|
||||
<div class="tag-list">
|
||||
<el-tag v-for="sheet in validateResult.missingSheets" :key="sheet" type="danger" effect="plain">{{ sheet }}</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<el-alert
|
||||
v-if="validateResult.orphanAttachmentNames?.length"
|
||||
:title="`存在 ${validateResult.orphanAttachmentNames.length} 个孤儿附件`"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
>
|
||||
<template #default>
|
||||
<div class="tag-list">
|
||||
<el-tag v-for="fileName in validateResult.orphanAttachmentNames" :key="fileName" type="warning" effect="plain">
|
||||
{{ fileName }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
</div>
|
||||
|
||||
<div class="sheet-summary-grid">
|
||||
<div class="sheet-summary-card">
|
||||
<span class="sheet-summary-label">requiredSheets</span>
|
||||
<div class="tag-list">
|
||||
<el-tag v-for="sheet in validateResult.requiredSheets" :key="sheet" effect="plain">{{ sheet }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sheet-summary-card">
|
||||
<span class="sheet-summary-label">existingSheets</span>
|
||||
<div class="tag-list">
|
||||
<el-tag v-for="sheet in validateResult.existingSheets" :key="sheet" type="success" effect="plain">{{ sheet }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-table v-if="validatePoints.length" :data="validatePoints" border size="small" max-height="320" class="stage-table">
|
||||
<el-table-column type="expand" width="48">
|
||||
<template #default="{ row }">
|
||||
<div class="attachment-panel">
|
||||
<div class="attachment-header">attachments</div>
|
||||
<el-table :data="row.attachments || []" border size="small">
|
||||
<el-table-column prop="attachmentName" label="附件名" min-width="220" show-overflow-tooltip />
|
||||
<el-table-column prop="attachmentType" label="类型" width="100" />
|
||||
<el-table-column label="上传" width="80">
|
||||
<template #default="{ row: attachment }">
|
||||
<el-tag :type="attachment.uploaded ? 'success' : 'info'">{{ attachment.uploaded ? '是' : '否' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="缺失" width="80">
|
||||
<template #default="{ row: attachment }">
|
||||
<el-tag :type="attachment.missing ? 'danger' : 'success'">{{ attachment.missing ? '是' : '否' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="允许补传" width="100">
|
||||
<template #default="{ row: attachment }">
|
||||
<el-tag :type="attachment.reuploadAllowed ? 'warning' : 'info'">
|
||||
{{ attachment.reuploadAllowed ? '是' : '否' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="message" label="说明" min-width="220" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="rowNo" label="行号" width="80" />
|
||||
<el-table-column prop="pointKey" label="点位标识" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="substationName" label="站点" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="pointName" label="点位" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="完整" width="90">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.complete ? 'success' : 'warning'">{{ row.complete ? '是' : '否' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="missingAttachmentCount" label="缺失附件" width="100" />
|
||||
<el-table-column label="设备匹配" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.testDeviceNoValid ? 'success' : 'danger'">{{ row.testDeviceNoValid ? '通过' : '未通过' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="testDeviceNoMessage" label="设备说明" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column label="委托单位匹配" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.clientUnitNameValid ? 'success' : 'danger'">{{ row.clientUnitNameValid ? '通过' : '未通过' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="clientUnitNameMessage" label="委托单位说明" min-width="180" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Download, FolderOpened, Select } from '@element-plus/icons-vue'
|
||||
import { ElMessage, type UploadFile, type UploadFiles } from 'element-plus'
|
||||
import { computed, ref } from 'vue'
|
||||
import { downloadReportTaskLedgerTemplateApi, validateReportTaskLedgerApi } from '@/api/aireport/testReport'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { useDownloadWithServerFileName } from '@/hooks/useDownload'
|
||||
import {
|
||||
getReportTaskErrorMessage,
|
||||
isReportTaskLedgerAttachmentFileName,
|
||||
isReportTaskLedgerSummaryFileName,
|
||||
normalizeReportTaskLedgerValidateResult,
|
||||
resolveReportTaskText
|
||||
} from '../utils/testReport'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskPrepareStep'
|
||||
})
|
||||
|
||||
type ReportTaskLogType = 'info' | 'success' | 'warning' | 'error'
|
||||
|
||||
const props = defineProps<{
|
||||
draftId: string
|
||||
disabled?: boolean
|
||||
preparedState: ReportTask.ReportTaskLedgerPreparedState
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'change', value: ReportTask.ReportTaskLedgerPreparedState): void
|
||||
(event: 'log', payload: { type: ReportTaskLogType; message: string }): void
|
||||
}>()
|
||||
|
||||
const validating = ref(false)
|
||||
const selectedFiles = ref<UploadFile[]>([])
|
||||
const validateResult = computed(() => props.preparedState.validateResult)
|
||||
const validatePoints = computed(() => validateResult.value?.points || [])
|
||||
const summaryLedgerFileName = computed(() => {
|
||||
const summaryFile = selectedFiles.value.find(file => isReportTaskLedgerSummaryFileName(file.name))
|
||||
return summaryFile?.name || ''
|
||||
})
|
||||
const otherAttachmentFiles = computed(() => selectedFiles.value.filter(file => !isReportTaskLedgerSummaryFileName(file.name)))
|
||||
|
||||
const pushLog = (type: ReportTaskLogType, message: string) => emit('log', { type, message })
|
||||
|
||||
const updatePreparedState = (patch: Partial<ReportTask.ReportTaskLedgerPreparedState>) => {
|
||||
emit('change', {
|
||||
...props.preparedState,
|
||||
...patch
|
||||
})
|
||||
}
|
||||
|
||||
const markResultsDirty = () => {
|
||||
updatePreparedState({
|
||||
validateSessionId: '',
|
||||
validateResult: null,
|
||||
latestImportResult: null,
|
||||
hasImported: false,
|
||||
validatedBatchId: '',
|
||||
pendingRevalidate: 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 (isReportTaskLedgerSummaryFileName(normalizedName)) 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.validateResult || props.preparedState.latestImportResult || props.preparedState.hasImported) {
|
||||
markResultsDirty()
|
||||
pushLog('warning', '导入文件已变更,需要重新执行文件校验和正式导入')
|
||||
}
|
||||
}
|
||||
|
||||
const handleFileRemove = (_file: UploadFile, files: UploadFiles) => {
|
||||
selectedFiles.value = [...files]
|
||||
pushLog('info', `已更新待校验文件列表,当前剩余 ${selectedFiles.value.length} 个文件`)
|
||||
|
||||
if (props.preparedState.validateResult || props.preparedState.latestImportResult || props.preparedState.hasImported) {
|
||||
markResultsDirty()
|
||||
pushLog('warning', '导入文件已变更,需要重新执行文件校验和正式导入')
|
||||
}
|
||||
}
|
||||
|
||||
const removeSelectedFile = (index: number) => {
|
||||
selectedFiles.value.splice(index, 1)
|
||||
pushLog('info', `已删除第 ${index + 1} 个待校验文件`)
|
||||
|
||||
if (props.preparedState.validateResult || props.preparedState.latestImportResult || props.preparedState.hasImported) {
|
||||
markResultsDirty()
|
||||
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 handleValidateFiles = async () => {
|
||||
if (validating.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
|
||||
}
|
||||
|
||||
validating.value = true
|
||||
const validateId = props.preparedState.validateSessionId || props.draftId
|
||||
pushLog('info', `开始执行文件校验,本次共上传 ${selectedFiles.value.length} 个文件,会话标识:${validateId}`)
|
||||
|
||||
try {
|
||||
// 关键业务节点:首次校验使用当前草稿 ID,后续补传必须复用后端返回的 sessionId。
|
||||
const response = await validateReportTaskLedgerApi(validateId, formData)
|
||||
const normalizedResult = normalizeReportTaskLedgerValidateResult(response)
|
||||
const nextSessionId = String(normalizedResult.sessionId || validateId)
|
||||
const nextBatchId = normalizedResult.success && normalizedResult.batchId ? String(normalizedResult.batchId) : ''
|
||||
|
||||
updatePreparedState({
|
||||
validateSessionId: nextSessionId,
|
||||
validateResult: normalizedResult,
|
||||
latestImportResult: null,
|
||||
hasImported: false,
|
||||
validatedBatchId: nextBatchId,
|
||||
pendingRevalidate: false
|
||||
})
|
||||
|
||||
if (!normalizedResult.success || !nextBatchId) {
|
||||
const message = normalizedResult.canContinueUpload
|
||||
? '文件校验未通过,请按结果补传后继续使用当前 sessionId 重试'
|
||||
: '文件校验未通过,请根据校验结果修正后重新校验'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
normalizedResult.failReasons?.forEach(reason => pushLog('warning', reason))
|
||||
return
|
||||
}
|
||||
|
||||
ElMessage.success('文件校验通过')
|
||||
pushLog('success', `文件校验通过,可进入正式导入步骤,batchId:${nextBatchId}`)
|
||||
} catch (error) {
|
||||
const message = getReportTaskErrorMessage(error, '文件校验失败')
|
||||
ElMessage.error(message)
|
||||
pushLog('error', message)
|
||||
} finally {
|
||||
validating.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-task-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
gap: 16px;
|
||||
height: 100%;
|
||||
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;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.section-desc {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.section-alert,
|
||||
.file-table,
|
||||
.stage-table,
|
||||
.fail-reason + .fail-reason,
|
||||
.warning-grid,
|
||||
.sheet-summary-grid {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.file-table-wrap {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.file-table {
|
||||
height: 100%;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.toolbar-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.toolbar-download {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.file-summary-grid {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.file-summary-grid > * {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.file-summary-card,
|
||||
.sheet-summary-card {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
max-width: 260px;
|
||||
min-height: 32px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 10px;
|
||||
background: var(--el-fill-color-light);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.file-summary-label,
|
||||
.sheet-summary-label {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.file-summary-value {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.warning-grid {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.sheet-summary-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.sheet-summary-card {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
max-width: none;
|
||||
min-height: 72px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.tag-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.attachment-panel {
|
||||
padding: 8px 16px 16px;
|
||||
background: var(--el-fill-color-lighter);
|
||||
}
|
||||
|
||||
.attachment-header {
|
||||
margin-bottom: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
:deep(.el-empty) {
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,40 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import assert from 'node:assert/strict'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const pageDir = path.resolve(__dirname, '..')
|
||||
const utilsFile = path.join(pageDir, 'utils/testReport.ts')
|
||||
const panelFile = path.join(pageDir, 'components/ReportTaskPrepareStep.vue')
|
||||
|
||||
const read = file => fs.readFileSync(file, 'utf8')
|
||||
|
||||
const utilsSource = read(utilsFile)
|
||||
const panelSource = read(panelFile)
|
||||
|
||||
assert.match(
|
||||
utilsSource,
|
||||
/export const TEST_REPORT_LEDGER_SUMMARY_FILE_BASE_NAME = '台账信息汇总'/,
|
||||
'utils/testReport.ts should define the ledger summary base file name constant'
|
||||
)
|
||||
|
||||
assert.match(
|
||||
utilsSource,
|
||||
/export const isReportTaskLedgerSummaryFileName = \(fileName: string\) =>[\s\S]*includes\(TEST_REPORT_LEDGER_SUMMARY_FILE_BASE_NAME\.toLowerCase\(\)\)[\s\S]*isReportTaskExcelFileName\(normalizedName\)/,
|
||||
'utils/testReport.ts should treat any Excel file containing 台账信息汇总 as the summary ledger file'
|
||||
)
|
||||
|
||||
assert.match(
|
||||
panelSource,
|
||||
/isReportTaskLedgerSummaryFileName/,
|
||||
'ReportTaskPrepareStep.vue should reuse the shared summary ledger matcher'
|
||||
)
|
||||
|
||||
assert.doesNotMatch(
|
||||
panelSource,
|
||||
/const isSummaryLedgerFileName =/,
|
||||
'ReportTaskPrepareStep.vue should not keep a local exact-match summary file matcher'
|
||||
)
|
||||
|
||||
console.log('ledger summary file contract passed')
|
||||
@@ -21,107 +21,97 @@ assertFileIncludes(path.join(srcDir, 'constants/dictCodes.ts'), ['TEST_REPORT_CO
|
||||
|
||||
assertFileIncludes(path.join(apiDir, 'index.ts'), [
|
||||
"const REPORT_TASK_BASE_URL = '/api/test-report'",
|
||||
'listReportTasksApi',
|
||||
'createReportTaskApi',
|
||||
'updateReportTaskApi',
|
||||
'deleteReportTasksApi',
|
||||
'getReportTaskDetailApi',
|
||||
'exportReportTasksApi',
|
||||
'submitReportTaskAuditApi',
|
||||
'downloadReportTaskLedgerTemplateApi',
|
||||
'validateReportTaskLedgerApi',
|
||||
'importReportTaskLedgerApi',
|
||||
'listReportTaskGroupReportsApi'
|
||||
'downloadReportTaskLedgerTemplateApi'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(apiDir, 'interface/index.ts'), [
|
||||
'export namespace ReportTask',
|
||||
'ReportTaskRecord',
|
||||
'ReportTaskListParams',
|
||||
'ReportTaskAddParam',
|
||||
'ReportTaskSaveRequest',
|
||||
'ReportTaskAuditRequest',
|
||||
'ReportTaskLedgerImportResult',
|
||||
'ReportTaskLedgerImportStageRecord',
|
||||
'ReportTaskLedgerImportSnapshot',
|
||||
'ReportTaskGroupReportRecord',
|
||||
'ReportTaskLedgerPreparedState'
|
||||
'ReportTaskLedgerValidateResult',
|
||||
'ReportTaskLedgerImportRequest',
|
||||
'validateSessionId',
|
||||
'validateResult',
|
||||
'validatedBatchId',
|
||||
'pendingRevalidate'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'utils/testReport.ts'), [
|
||||
'TEST_REPORT_EXCEL_EXTENSIONS',
|
||||
'REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP',
|
||||
'isReportTaskExcelFileName',
|
||||
'TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER',
|
||||
'normalizeReportTaskLedgerImportResult',
|
||||
'normalizeReportTaskLedgerSnapshot',
|
||||
'checkReportTaskLedgerPrepared',
|
||||
'resolveReportTaskGroupReportGenerateStateText',
|
||||
'resolveReportTaskGroupReportGenerateStateTagType'
|
||||
assertFileIncludes(path.join(pageDir, 'utils/reportTaskFlow.ts'), [
|
||||
'REPORT_TASK_FLOW_STEPS',
|
||||
'createEmptyLedgerPreparedState',
|
||||
'hasValidatedLedgerBatch',
|
||||
'resolveInitialFlowStep',
|
||||
'canReachFlowStep',
|
||||
'resolveFlowStepStatus'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskLedgerImportPanel.vue'), [
|
||||
"name: 'ReportTaskLedgerImportPanel'",
|
||||
assertFileIncludes(path.join(pageDir, 'utils/testReportForm.ts'), [
|
||||
'createDefaultReportTaskFormModel',
|
||||
'buildReportTaskFormContext',
|
||||
'buildReportTaskSavePayload'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskPrepareStep.vue'), [
|
||||
"name: 'ReportTaskPrepareStep'",
|
||||
'validateReportTaskLedgerApi',
|
||||
'downloadReportTaskLedgerTemplateApi',
|
||||
'importReportTaskLedgerApi',
|
||||
'selectedFiles',
|
||||
'latestImportResult',
|
||||
'handleImportFiles',
|
||||
'toolbar-actions',
|
||||
'toolbar-download'
|
||||
'validateResult',
|
||||
'sessionId',
|
||||
'canContinueUpload',
|
||||
'points',
|
||||
'attachments',
|
||||
'执行校验'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskImportStep.vue'), [
|
||||
"name: 'ReportTaskImportStep'",
|
||||
'importReportTaskLedgerApi',
|
||||
'validatedBatchId',
|
||||
'执行导入',
|
||||
'ledger/validate -> ledger/import'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskBaseInfoStep.vue'), [
|
||||
"name: 'ReportTaskBaseInfoStep'",
|
||||
'register-form',
|
||||
'formRules',
|
||||
'summary-strip'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskCompleteStep.vue'), [
|
||||
"name: 'ReportTaskCompleteStep'",
|
||||
'报告任务新增完成',
|
||||
'报告任务编辑完成'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskFormDialog.vue'), [
|
||||
"name: 'ReportTaskFormDialog'",
|
||||
'ReportTaskLedgerImportPanel',
|
||||
'REPORT_TASK_FORM_STEPS',
|
||||
'currentStep',
|
||||
'logEntries',
|
||||
'logPanelExpanded',
|
||||
'goToImportStep',
|
||||
'handleLedgerPreparedChange',
|
||||
'ledgerPreparedState',
|
||||
'activeDraftId',
|
||||
'checkReportTaskLedgerPrepared',
|
||||
'padding-bottom: 24px',
|
||||
'position: absolute',
|
||||
'z-index: 3',
|
||||
'log-panel-header',
|
||||
'log-panel-body',
|
||||
'log-panel-toggle',
|
||||
'white-space: nowrap',
|
||||
'ReportTaskPrepareStep',
|
||||
'ReportTaskImportStep',
|
||||
'ReportTaskBaseInfoStep',
|
||||
'ReportTaskCompleteStep',
|
||||
'REPORT_TASK_FLOW_STEPS',
|
||||
'createEmptyLedgerPreparedState',
|
||||
'buildReportTaskFormContext',
|
||||
'buildReportTaskSavePayload',
|
||||
'ledger/validate -> ledger/import',
|
||||
'log-floating-panel',
|
||||
'el-tooltip',
|
||||
'text-overflow: ellipsis',
|
||||
'log-empty'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskDetailDialog.vue'), [
|
||||
"name: 'ReportTaskDetailDialog'",
|
||||
'groupReports',
|
||||
'generateState',
|
||||
'group-report-title',
|
||||
'resolveReportTaskGroupReportGenerateStateText'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskAuditDialog.vue'), [
|
||||
"name: 'ReportTaskAuditDialog'",
|
||||
'checkResult'
|
||||
'height: 560px',
|
||||
'max-height: calc(100vh - 40px)',
|
||||
'display: flex',
|
||||
'padding: 16px 18px 12px',
|
||||
'gap: 6px',
|
||||
'padding: 0 12px 10px',
|
||||
'.flow-main {\n display: flex;\n flex: 1;\n min-width: 0;\n min-height: 0;\n overflow: auto;\n}'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'index.vue'), [
|
||||
"name: 'ReportTaskPage'",
|
||||
'<ProTable',
|
||||
'ReportTaskFormDialog',
|
||||
'ReportTaskDetailDialog',
|
||||
'ReportTaskAuditDialog',
|
||||
'listReportTaskGroupReportsApi',
|
||||
'detailGroupReports',
|
||||
'ledger/import -> add/update'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskLedgerImportPanel.vue'), [
|
||||
'min-height: 0',
|
||||
'flex: 1',
|
||||
'display: flex',
|
||||
'flex-direction: column'
|
||||
'@refresh-options',
|
||||
'ledger/validate -> ledger/import -> add/update'
|
||||
])
|
||||
|
||||
console.log('testReport page contract passed')
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
:report-model-options="reportModelOptions"
|
||||
:company-options="companyOptions"
|
||||
:standard-options="standardOptions"
|
||||
@refresh-options="refreshFormOptions"
|
||||
@submit="handleSaveReportTask"
|
||||
/>
|
||||
|
||||
@@ -92,6 +93,11 @@ import {
|
||||
buildDictSelectOptions,
|
||||
buildOptionLabelMap,
|
||||
getReportTaskErrorMessage,
|
||||
getReportTaskGenerateStateTagType,
|
||||
getReportTaskGenerateStateText,
|
||||
getReportTaskStateTagType,
|
||||
getReportTaskStateText,
|
||||
REPORT_TASK_STATE_OPTIONS,
|
||||
normalizeReportTaskGroupReportList,
|
||||
normalizeReportTaskListParams,
|
||||
normalizeReportTaskPage,
|
||||
@@ -124,6 +130,7 @@ const reportModelOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
|
||||
const companyOptions = computed(() => buildDictSelectOptions(dictStore.getDictData(DICT_CODES.TEST_REPORT_COMPANY)))
|
||||
const standardOptions = computed(() => buildDictSelectOptions(dictStore.getDictData(DICT_CODES.TEST_REPORT_STANDARD)))
|
||||
const stateOptions = REPORT_TASK_STATE_OPTIONS
|
||||
const companyLabelMap = computed(() => buildOptionLabelMap(companyOptions.value))
|
||||
const standardLabelMap = computed(() => buildOptionLabelMap(standardOptions.value))
|
||||
const requiredDictCodes = [DICT_CODES.TEST_REPORT_COMPANY, DICT_CODES.TEST_REPORT_STANDARD]
|
||||
@@ -164,6 +171,25 @@ const columns = reactive<ColumnProps<ReportTask.ReportTaskRecord>[]>([
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'state',
|
||||
label: '报告状态',
|
||||
minWidth: 120,
|
||||
enum: stateOptions,
|
||||
search: {
|
||||
el: 'select',
|
||||
order: 3,
|
||||
props: {
|
||||
clearable: true,
|
||||
placeholder: '请选择报告状态'
|
||||
}
|
||||
},
|
||||
render: ({ row }) => (
|
||||
<el-tag type={getReportTaskStateTagType(row.state)} effect="light">
|
||||
{getReportTaskStateText(row.state)}
|
||||
</el-tag>
|
||||
)
|
||||
},
|
||||
{ prop: 'no', label: '报告编号', minWidth: 180, fixed: 'left', render: ({ row }) => resolveReportTaskText(row.no) },
|
||||
{ prop: 'clientUnitName', label: '委托单位', minWidth: 160, render: ({ row }) => resolveReportTaskText(row.clientUnitName) },
|
||||
{ prop: 'reportModelName', label: '报告模板', minWidth: 160, render: ({ row }) => resolveReportTaskText(row.reportModelName) },
|
||||
@@ -181,6 +207,16 @@ const columns = reactive<ColumnProps<ReportTask.ReportTaskRecord>[]>([
|
||||
showOverflowTooltip: true,
|
||||
render: ({ row }) => resolveReportTaskStandardText(row.standard, standardLabelMap.value)
|
||||
},
|
||||
{
|
||||
prop: 'reportGenerateState',
|
||||
label: '生成状态',
|
||||
minWidth: 120,
|
||||
render: ({ row }) => (
|
||||
<el-tag type={getReportTaskGenerateStateTagType(row.reportGenerateState)} effect="light">
|
||||
{getReportTaskGenerateStateText(row.reportGenerateState)}
|
||||
</el-tag>
|
||||
)
|
||||
},
|
||||
{ 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) },
|
||||
@@ -251,6 +287,10 @@ const ensureFormOptionsReady = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const refreshFormOptions = async () => {
|
||||
await ensureFormOptionsReady()
|
||||
}
|
||||
|
||||
const getTableList = async (params: ReportTask.ReportTaskListParams = {}) => {
|
||||
const response = await listReportTasksApi(normalizeReportTaskListParams(params))
|
||||
const pageData = normalizeReportTaskPage<ReportTask.ReportTaskRecord>(
|
||||
@@ -337,7 +377,7 @@ const handleSaveReportTask = async (params: ReportTask.ReportTaskSaveRequest) =>
|
||||
formSaving.value = true
|
||||
|
||||
try {
|
||||
// 关键业务节点:台账导入已在弹窗内完成,页面层这里只执行最终 add/update,整体顺序为 ledger/import -> add/update。
|
||||
// 关键业务节点:文件校验与正式导入已在弹窗内完成,页面层这里只执行最终 add/update,整体顺序为 ledger/validate -> ledger/import -> add/update。
|
||||
if (formMode.value === 'create') {
|
||||
await createReportTaskApi(params)
|
||||
ElMessage.success('报告任务新增成功')
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { checkReportTaskLedgerPrepared } from './testReport'
|
||||
|
||||
export type ReportTaskFlowStep = 'prepare' | 'import' | 'form' | 'done'
|
||||
|
||||
export interface ReportTaskFlowStepOption {
|
||||
index: number
|
||||
value: ReportTaskFlowStep
|
||||
title: string
|
||||
description: string
|
||||
}
|
||||
|
||||
export const REPORT_TASK_FLOW_STEPS: ReportTaskFlowStepOption[] = [
|
||||
{
|
||||
index: 1,
|
||||
value: 'prepare',
|
||||
title: '文件选择与校验',
|
||||
description: '准备台账文件并完成校验'
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
value: 'import',
|
||||
title: '文件导入',
|
||||
description: '使用已校验批次执行正式导入'
|
||||
},
|
||||
{
|
||||
index: 3,
|
||||
value: 'form',
|
||||
title: '基础信息维护',
|
||||
description: '填写并确认任务基础信息'
|
||||
},
|
||||
{
|
||||
index: 4,
|
||||
value: 'done',
|
||||
title: '完成',
|
||||
description: '查看结果并结束本次流程'
|
||||
}
|
||||
]
|
||||
|
||||
export const createEmptyLedgerPreparedState = (): ReportTask.ReportTaskLedgerPreparedState => ({
|
||||
draftId: '',
|
||||
validateSessionId: '',
|
||||
validateResult: null,
|
||||
latestImportResult: null,
|
||||
snapshot: null,
|
||||
hasImported: false,
|
||||
validatedBatchId: '',
|
||||
pendingRevalidate: false
|
||||
})
|
||||
|
||||
export const hasValidatedLedgerBatch = (state: ReportTask.ReportTaskLedgerPreparedState | null | undefined) =>
|
||||
Boolean(state?.draftId && state?.validatedBatchId && state?.validateResult?.success && !state?.pendingRevalidate)
|
||||
|
||||
export const resolveInitialFlowStep = (
|
||||
mode: 'create' | 'edit',
|
||||
state: ReportTask.ReportTaskLedgerPreparedState
|
||||
): ReportTaskFlowStep => {
|
||||
if (mode === 'edit' && checkReportTaskLedgerPrepared(state)) {
|
||||
return 'form'
|
||||
}
|
||||
|
||||
return 'prepare'
|
||||
}
|
||||
|
||||
export const canReachFlowStep = (
|
||||
step: ReportTaskFlowStep,
|
||||
state: ReportTask.ReportTaskLedgerPreparedState,
|
||||
currentStep: ReportTaskFlowStep
|
||||
) => {
|
||||
if (step === 'prepare') return true
|
||||
if (step === 'import') {
|
||||
return hasValidatedLedgerBatch(state) || state.hasImported || Boolean(state.snapshot) || currentStep === 'import' || currentStep === 'form' || currentStep === 'done'
|
||||
}
|
||||
if (step === 'form') return checkReportTaskLedgerPrepared(state) || currentStep === 'form' || currentStep === 'done'
|
||||
return currentStep === 'done'
|
||||
}
|
||||
|
||||
export const resolveFlowStepStatus = (
|
||||
step: ReportTaskFlowStep,
|
||||
currentStep: ReportTaskFlowStep,
|
||||
state: ReportTask.ReportTaskLedgerPreparedState
|
||||
) => {
|
||||
if (currentStep === step) return 'active'
|
||||
if (step === 'prepare' && (hasValidatedLedgerBatch(state) || currentStep === 'form' || currentStep === 'done')) return 'done'
|
||||
if (step === 'import' && (checkReportTaskLedgerPrepared(state) || currentStep === 'done')) return 'done'
|
||||
if (step === 'form' && currentStep === 'done') return 'done'
|
||||
return 'pending'
|
||||
}
|
||||
@@ -1,15 +1,38 @@
|
||||
import type { TagProps } from 'element-plus'
|
||||
import type { Dict, ResultData, ResPage } from '@/api/interface'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
|
||||
type TagType = TagProps['type']
|
||||
|
||||
export const TEST_REPORT_EXCEL_EXTENSIONS = ['.xls', '.xlsx']
|
||||
export const TEST_REPORT_WORD_EXTENSIONS = ['.doc', '.docx']
|
||||
export const TEST_REPORT_LEDGER_SUMMARY_FILE_BASE_NAME = '台账信息汇总'
|
||||
export const TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER: ReportTask.ReportTaskLedgerImportStage[] = [
|
||||
'选择文件',
|
||||
'校验文件',
|
||||
'文件上传',
|
||||
'文件导入',
|
||||
'基础资料维护',
|
||||
'完成'
|
||||
]
|
||||
export const REPORT_TASK_STATE_MAP: Record<ReportTask.ReportTaskState, { text: string; tagType: TagType }> = {
|
||||
'01': { text: '编制中', tagType: 'info' },
|
||||
'02': { text: '审核中', tagType: 'warning' },
|
||||
'03': { text: '已通过', tagType: 'success' },
|
||||
'04': { text: '已退回', tagType: 'danger' },
|
||||
'05': { text: '已删除', tagType: 'info' }
|
||||
}
|
||||
export const REPORT_TASK_STATE_OPTIONS: Array<{ label: string; value: ReportTask.ReportTaskState }> = [
|
||||
{ label: '编制中', value: '01' },
|
||||
{ label: '审核中', value: '02' },
|
||||
{ label: '已通过', value: '03' },
|
||||
{ label: '已退回', value: '04' },
|
||||
{ label: '已删除', value: '05' }
|
||||
]
|
||||
export const REPORT_TASK_GENERATE_STATE_MAP: Record<ReportTask.ReportTaskGenerateState, { text: string; tagType: TagType }> = {
|
||||
0: { text: '未生成', tagType: 'info' },
|
||||
1: { text: '生成中', tagType: 'warning' },
|
||||
2: { text: '已生成', tagType: 'success' }
|
||||
}
|
||||
export const REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP: Record<number, string> = {
|
||||
0: '未生成',
|
||||
1: '生成中',
|
||||
@@ -43,6 +66,7 @@ export const normalizeReportTaskListParams = (
|
||||
keyword: String(params.keyword || '').trim() || undefined,
|
||||
searchBeginTime: searchBeginTime || params.searchBeginTime || undefined,
|
||||
searchEndTime: searchEndTime || params.searchEndTime || undefined,
|
||||
state: params.state || undefined,
|
||||
pageNum: params.pageNum || 1,
|
||||
pageSize: params.pageSize || 10
|
||||
}
|
||||
@@ -88,6 +112,11 @@ export const isReportTaskWordFileName = (fileName: string) => {
|
||||
return TEST_REPORT_WORD_EXTENSIONS.some(extension => normalizedName.endsWith(extension))
|
||||
}
|
||||
|
||||
export const isReportTaskLedgerSummaryFileName = (fileName: string) => {
|
||||
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||
return normalizedName.includes(TEST_REPORT_LEDGER_SUMMARY_FILE_BASE_NAME.toLowerCase()) && isReportTaskExcelFileName(normalizedName)
|
||||
}
|
||||
|
||||
export const isReportTaskLedgerAttachmentFileName = (fileName: string) =>
|
||||
isReportTaskExcelFileName(fileName) || isReportTaskWordFileName(fileName)
|
||||
|
||||
@@ -115,10 +144,13 @@ export const normalizeReportTaskLedgerImportResult = (
|
||||
const stageList = Array.isArray(payload?.stages) ? payload.stages : []
|
||||
|
||||
return {
|
||||
batchId: payload?.batchId || undefined,
|
||||
currentStage: payload?.currentStage || undefined,
|
||||
success: payload?.success ?? false,
|
||||
summaryFileName: payload?.summaryFileName || undefined,
|
||||
tempStoragePath: payload?.tempStoragePath || undefined,
|
||||
totalFileCount: payload?.totalFileCount ?? 0,
|
||||
uploadedFileCount: payload?.uploadedFileCount ?? 0,
|
||||
pointCount: payload?.pointCount ?? 0,
|
||||
excelAttachmentCount: payload?.excelAttachmentCount ?? 0,
|
||||
wordAttachmentCount: payload?.wordAttachmentCount ?? 0,
|
||||
@@ -136,6 +168,61 @@ export const normalizeReportTaskLedgerImportResult = (
|
||||
}
|
||||
}
|
||||
|
||||
export const normalizeReportTaskLedgerValidateResult = (
|
||||
response:
|
||||
| ResultData<ReportTask.ReportTaskLedgerValidateResult>
|
||||
| ReportTask.ReportTaskLedgerValidateResult
|
||||
| null
|
||||
| undefined
|
||||
): ReportTask.ReportTaskLedgerValidateResult => {
|
||||
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskLedgerValidateResult | null | undefined>(
|
||||
response as ResultData<ReportTask.ReportTaskLedgerValidateResult>
|
||||
)
|
||||
|
||||
return {
|
||||
sessionId: payload?.sessionId || undefined,
|
||||
batchId: payload?.batchId || undefined,
|
||||
success: payload?.success ?? false,
|
||||
summaryFileName: payload?.summaryFileName || undefined,
|
||||
summaryFilePresent: payload?.summaryFilePresent ?? false,
|
||||
tempStoragePath: payload?.tempStoragePath || undefined,
|
||||
uploadedFileCount: payload?.uploadedFileCount ?? 0,
|
||||
pointCount: payload?.pointCount ?? 0,
|
||||
missingAttachmentCount: payload?.missingAttachmentCount ?? 0,
|
||||
canContinueUpload: payload?.canContinueUpload ?? false,
|
||||
requiredSheets: Array.isArray(payload?.requiredSheets) ? payload.requiredSheets.filter(Boolean) : [],
|
||||
existingSheets: Array.isArray(payload?.existingSheets) ? payload.existingSheets.filter(Boolean) : [],
|
||||
missingSheets: Array.isArray(payload?.missingSheets) ? payload.missingSheets.filter(Boolean) : [],
|
||||
orphanAttachmentNames: Array.isArray(payload?.orphanAttachmentNames) ? payload.orphanAttachmentNames.filter(Boolean) : [],
|
||||
failReasons: Array.isArray(payload?.failReasons) ? payload.failReasons.filter(Boolean) : [],
|
||||
points: Array.isArray(payload?.points)
|
||||
? payload.points.map(point => ({
|
||||
rowNo: point?.rowNo ?? null,
|
||||
pointKey: point?.pointKey || undefined,
|
||||
substationName: point?.substationName || undefined,
|
||||
pointName: point?.pointName || undefined,
|
||||
complete: point?.complete ?? false,
|
||||
missingAttachmentCount: point?.missingAttachmentCount ?? 0,
|
||||
testDeviceNoValid: point?.testDeviceNoValid ?? false,
|
||||
testDeviceNoMessage: point?.testDeviceNoMessage || undefined,
|
||||
clientUnitNameValid: point?.clientUnitNameValid ?? false,
|
||||
clientUnitNameMessage: point?.clientUnitNameMessage || undefined,
|
||||
attachments: Array.isArray(point?.attachments)
|
||||
? point.attachments.map(attachment => ({
|
||||
attachmentName: attachment?.attachmentName || undefined,
|
||||
attachmentType: attachment?.attachmentType || undefined,
|
||||
referenced: attachment?.referenced ?? false,
|
||||
uploaded: attachment?.uploaded ?? false,
|
||||
missing: attachment?.missing ?? false,
|
||||
reuploadAllowed: attachment?.reuploadAllowed ?? false,
|
||||
message: attachment?.message || undefined
|
||||
}))
|
||||
: []
|
||||
}))
|
||||
: []
|
||||
}
|
||||
}
|
||||
|
||||
export const normalizeReportTaskGroupReportList = (
|
||||
response:
|
||||
| ResultData<ReportTask.ReportTaskGroupReportRecord[]>
|
||||
@@ -209,9 +296,21 @@ export const resolveReportTaskGroupReportGenerateStateTagType = (value: number |
|
||||
return REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TAG_TYPE_MAP[value]
|
||||
}
|
||||
|
||||
export const getReportTaskStateText = (state?: string | null) =>
|
||||
REPORT_TASK_STATE_MAP[state as ReportTask.ReportTaskState]?.text || '未知状态'
|
||||
|
||||
export const getReportTaskStateTagType = (state?: string | null): TagType =>
|
||||
REPORT_TASK_STATE_MAP[state as ReportTask.ReportTaskState]?.tagType || 'info'
|
||||
|
||||
export const getReportTaskGenerateStateText = (state?: number | null) =>
|
||||
REPORT_TASK_GENERATE_STATE_MAP[state as ReportTask.ReportTaskGenerateState]?.text || '未知状态'
|
||||
|
||||
export const getReportTaskGenerateStateTagType = (state?: number | null): TagType =>
|
||||
REPORT_TASK_GENERATE_STATE_MAP[state as ReportTask.ReportTaskGenerateState]?.tagType || 'info'
|
||||
|
||||
export const checkReportTaskLedgerPrepared = (
|
||||
state: ReportTask.ReportTaskLedgerPreparedState | null | undefined
|
||||
) => Boolean(state?.draftId && state.hasImported && !state.pendingReimport)
|
||||
) => Boolean(state?.draftId && state.hasImported && !state.pendingRevalidate)
|
||||
|
||||
export const buildDictSelectOptions = (dictData: Dict[] = []) =>
|
||||
dictData
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { generateUUID } from '@/utils'
|
||||
import { normalizeReportTaskLedgerSnapshot, parseReportTaskStandardIds, stringifyReportTaskStandardIds } from './testReport'
|
||||
|
||||
export interface ReportTaskFormModel {
|
||||
id: string
|
||||
no: string
|
||||
clientUnitId: string
|
||||
reportModelId: string
|
||||
createUnit: string
|
||||
contractNumber: string
|
||||
standardIds: string[]
|
||||
data: string
|
||||
phonenumber: string
|
||||
}
|
||||
|
||||
export const createDefaultReportTaskFormModel = (): ReportTaskFormModel => ({
|
||||
id: '',
|
||||
no: '',
|
||||
clientUnitId: '',
|
||||
reportModelId: '',
|
||||
createUnit: '',
|
||||
contractNumber: '',
|
||||
standardIds: [],
|
||||
data: '',
|
||||
phonenumber: ''
|
||||
})
|
||||
|
||||
export const buildReportTaskDraftId = (mode: 'create' | 'edit', record: ReportTask.ReportTaskRecord | null) => {
|
||||
if (mode === 'edit') {
|
||||
return String(record?.id || '').trim()
|
||||
}
|
||||
|
||||
return window.crypto?.randomUUID?.() || generateUUID()
|
||||
}
|
||||
|
||||
export const buildReportTaskFormContext = (mode: 'create' | 'edit', record: ReportTask.ReportTaskRecord | null) => {
|
||||
const snapshot = normalizeReportTaskLedgerSnapshot(record?.data)
|
||||
const formModel = createDefaultReportTaskFormModel()
|
||||
|
||||
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 || ''
|
||||
|
||||
return {
|
||||
formModel,
|
||||
snapshot,
|
||||
draftId: buildReportTaskDraftId(mode, record),
|
||||
hasPreparedImport: Boolean(snapshot || Number(record?.pointCount) > 0)
|
||||
}
|
||||
}
|
||||
|
||||
export const buildReportTaskSavePayload = (
|
||||
draftId: string,
|
||||
formModel: ReportTaskFormModel
|
||||
): ReportTask.ReportTaskSaveRequest => ({
|
||||
id: draftId || formModel.id || undefined,
|
||||
no: formModel.no.trim(),
|
||||
clientUnitId: formModel.clientUnitId,
|
||||
reportModelId: formModel.reportModelId,
|
||||
createUnit: formModel.createUnit,
|
||||
contractNumber: formModel.contractNumber.trim(),
|
||||
standard: stringifyReportTaskStandardIds(formModel.standardIds),
|
||||
data: formModel.data.trim(),
|
||||
phonenumber: formModel.phonenumber.trim() || undefined
|
||||
})
|
||||
@@ -5,7 +5,10 @@
|
||||
"vitest.config.*",
|
||||
"cypress.config.*",
|
||||
"nightwatch.conf.*",
|
||||
"playwright.config.*"
|
||||
"playwright.config.*",
|
||||
"build/**/*.ts",
|
||||
"build/**/*.d.ts",
|
||||
"src/types/**/*.d.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ConfigEnv, defineConfig, loadEnv, UserConfig } from 'vite'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import type { ConfigEnv, UserConfig } from 'vite'
|
||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import path from 'path'
|
||||
@@ -61,10 +62,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
// dts: "src/types/components.d.ts",
|
||||
}),
|
||||
nodePolyfills({
|
||||
include: ['crypto'],
|
||||
globals: {
|
||||
crypto: true
|
||||
}
|
||||
include: ['crypto']
|
||||
})
|
||||
],
|
||||
// 基础配置
|
||||
|
||||
Reference in New Issue
Block a user