feat(testReport): 新增台账导入功能并重构报告任务表单
- 新增台账导入面板组件,支持Excel模板下载和批量导入 - 在报告任务表单中集成三步式流程(导入→填写→完成) - 添加导入结果预览和分组报告状态展示功能 - 扩展API接口支持台账导入和分组报告查询 - 优化表单验证逻辑,移除送资数据必填限制 - 集成日志面板实时显示导入过程状态 - 更新测试报告页面契约验证规则 - 添加监测点数和分组数统计展示 - 实现台账准备状态检查和快照功能
This commit is contained in:
@@ -30,7 +30,9 @@ export function wrapperEnv(envConf: Recordable): ViteEnv {
|
|||||||
if (envName === "VITE_PROXY") {
|
if (envName === "VITE_PROXY") {
|
||||||
try {
|
try {
|
||||||
realName = JSON.parse(realName);
|
realName = JSON.parse(realName);
|
||||||
} catch (error) {}
|
} catch (error) {
|
||||||
|
// Keep the original string when the proxy config is not valid JSON.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ret[envName] = realName;
|
ret[envName] = realName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,12 +36,16 @@ export const downloadReportTaskLedgerTemplateApi = (): Promise<AxiosResponse<Blo
|
|||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
}) as unknown as Promise<AxiosResponse<Blob>>
|
}) as unknown as Promise<AxiosResponse<Blob>>
|
||||||
|
|
||||||
export const importReportTaskLedgerApi = (id: string, formData: FormData) => {
|
export const validateReportTaskLedgerApi = (id: string, formData: FormData) => {
|
||||||
return http.post<ReportTask.ReportTaskLedgerImportResult>(`${REPORT_TASK_BASE_URL}/${id}/ledger/import`, formData, {
|
return http.post<ReportTask.ReportTaskLedgerValidateResult>(`${REPORT_TASK_BASE_URL}/${id}/ledger/validate`, formData, {
|
||||||
headers: { 'Content-Type': 'multipart/form-data' }
|
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) => {
|
export const listReportTaskGroupReportsApi = (id: string) => {
|
||||||
return http.get<ReportTask.ReportTaskGroupReportRecord[]>(`${REPORT_TASK_BASE_URL}/${id}/group-report/list`)
|
return http.get<ReportTask.ReportTaskGroupReportRecord[]>(`${REPORT_TASK_BASE_URL}/${id}/group-report/list`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
export namespace ReportTask {
|
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 ReportTaskGroupReportGenerateState = 0 | 1 | 2 | 3
|
||||||
export type ReportTaskLedgerImportStage =
|
export type ReportTaskLedgerImportStage =
|
||||||
| '选择文件'
|
| '选择文件'
|
||||||
| '校验文件'
|
| '校验文件'
|
||||||
| '文件上传'
|
| '文件导入'
|
||||||
| '基础资料维护'
|
| '基础资料维护'
|
||||||
| '完成'
|
| '完成'
|
||||||
|
|
||||||
@@ -23,10 +25,11 @@ export namespace ReportTask {
|
|||||||
checkerName?: string | null
|
checkerName?: string | null
|
||||||
checkTime?: string | null
|
checkTime?: string | null
|
||||||
checkResult?: string | null
|
checkResult?: string | null
|
||||||
|
state?: ReportTaskState | null
|
||||||
status?: number
|
status?: number
|
||||||
pointCount?: number | null
|
pointCount?: number | null
|
||||||
groupCount?: number | null
|
groupCount?: number | null
|
||||||
reportGenerateState?: number | null
|
reportGenerateState?: ReportTaskGenerateState | null
|
||||||
createBy?: string | null
|
createBy?: string | null
|
||||||
createByName?: string | null
|
createByName?: string | null
|
||||||
createTime?: string | null
|
createTime?: string | null
|
||||||
@@ -40,6 +43,7 @@ export namespace ReportTask {
|
|||||||
keyword?: string
|
keyword?: string
|
||||||
searchBeginTime?: string
|
searchBeginTime?: string
|
||||||
searchEndTime?: string
|
searchEndTime?: string
|
||||||
|
state?: ReportTaskState | ''
|
||||||
timeRange?: string[]
|
timeRange?: string[]
|
||||||
pageNum?: number
|
pageNum?: number
|
||||||
pageSize?: number
|
pageSize?: number
|
||||||
@@ -94,11 +98,57 @@ export namespace ReportTask {
|
|||||||
} | null
|
} | 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 {
|
export interface ReportTaskLedgerImportResult {
|
||||||
|
batchId?: string | null
|
||||||
currentStage?: ReportTaskLedgerImportStage | string | null
|
currentStage?: ReportTaskLedgerImportStage | string | null
|
||||||
success?: boolean | null
|
success?: boolean | null
|
||||||
summaryFileName?: string | null
|
summaryFileName?: string | null
|
||||||
|
tempStoragePath?: string | null
|
||||||
totalFileCount?: number
|
totalFileCount?: number
|
||||||
|
uploadedFileCount?: number
|
||||||
pointCount?: number
|
pointCount?: number
|
||||||
excelAttachmentCount?: number
|
excelAttachmentCount?: number
|
||||||
wordAttachmentCount?: number
|
wordAttachmentCount?: number
|
||||||
@@ -111,6 +161,10 @@ export namespace ReportTask {
|
|||||||
stages?: ReportTaskLedgerImportStageRecord[] | null
|
stages?: ReportTaskLedgerImportStageRecord[] | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ReportTaskLedgerImportRequest {
|
||||||
|
batchId: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface ReportTaskPointRecord {
|
export interface ReportTaskPointRecord {
|
||||||
id?: string
|
id?: string
|
||||||
groupNo?: number | null
|
groupNo?: number | null
|
||||||
@@ -150,9 +204,12 @@ export namespace ReportTask {
|
|||||||
|
|
||||||
export interface ReportTaskLedgerPreparedState {
|
export interface ReportTaskLedgerPreparedState {
|
||||||
draftId: string
|
draftId: string
|
||||||
|
validateSessionId: string
|
||||||
|
validateResult: ReportTaskLedgerValidateResult | null
|
||||||
latestImportResult: ReportTaskLedgerImportResult | null
|
latestImportResult: ReportTaskLedgerImportResult | null
|
||||||
snapshot: ReportTaskLedgerImportSnapshot | null
|
snapshot: ReportTaskLedgerImportSnapshot | null
|
||||||
hasImported: boolean
|
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>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -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'), [
|
assertFileIncludes(path.join(apiDir, 'index.ts'), [
|
||||||
"const REPORT_TASK_BASE_URL = '/api/test-report'",
|
"const REPORT_TASK_BASE_URL = '/api/test-report'",
|
||||||
'listReportTasksApi',
|
'validateReportTaskLedgerApi',
|
||||||
'createReportTaskApi',
|
|
||||||
'updateReportTaskApi',
|
|
||||||
'deleteReportTasksApi',
|
|
||||||
'getReportTaskDetailApi',
|
|
||||||
'exportReportTasksApi',
|
|
||||||
'submitReportTaskAuditApi',
|
|
||||||
'downloadReportTaskLedgerTemplateApi',
|
|
||||||
'importReportTaskLedgerApi',
|
'importReportTaskLedgerApi',
|
||||||
'listReportTaskGroupReportsApi'
|
'downloadReportTaskLedgerTemplateApi'
|
||||||
])
|
])
|
||||||
|
|
||||||
assertFileIncludes(path.join(apiDir, 'interface/index.ts'), [
|
assertFileIncludes(path.join(apiDir, 'interface/index.ts'), [
|
||||||
'export namespace ReportTask',
|
'ReportTaskLedgerValidateResult',
|
||||||
'ReportTaskRecord',
|
'ReportTaskLedgerImportRequest',
|
||||||
'ReportTaskListParams',
|
'validateSessionId',
|
||||||
'ReportTaskAddParam',
|
'validateResult',
|
||||||
'ReportTaskSaveRequest',
|
'validatedBatchId',
|
||||||
'ReportTaskAuditRequest',
|
'pendingRevalidate'
|
||||||
'ReportTaskLedgerImportResult',
|
|
||||||
'ReportTaskLedgerImportStageRecord',
|
|
||||||
'ReportTaskLedgerImportSnapshot',
|
|
||||||
'ReportTaskGroupReportRecord',
|
|
||||||
'ReportTaskLedgerPreparedState'
|
|
||||||
])
|
])
|
||||||
|
|
||||||
assertFileIncludes(path.join(pageDir, 'utils/testReport.ts'), [
|
assertFileIncludes(path.join(pageDir, 'utils/reportTaskFlow.ts'), [
|
||||||
'TEST_REPORT_EXCEL_EXTENSIONS',
|
'REPORT_TASK_FLOW_STEPS',
|
||||||
'REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP',
|
'createEmptyLedgerPreparedState',
|
||||||
'isReportTaskExcelFileName',
|
'hasValidatedLedgerBatch',
|
||||||
'TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER',
|
'resolveInitialFlowStep',
|
||||||
'normalizeReportTaskLedgerImportResult',
|
'canReachFlowStep',
|
||||||
'normalizeReportTaskLedgerSnapshot',
|
'resolveFlowStepStatus'
|
||||||
'checkReportTaskLedgerPrepared',
|
|
||||||
'resolveReportTaskGroupReportGenerateStateText',
|
|
||||||
'resolveReportTaskGroupReportGenerateStateTagType'
|
|
||||||
])
|
])
|
||||||
|
|
||||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskLedgerImportPanel.vue'), [
|
assertFileIncludes(path.join(pageDir, 'utils/testReportForm.ts'), [
|
||||||
"name: 'ReportTaskLedgerImportPanel'",
|
'createDefaultReportTaskFormModel',
|
||||||
|
'buildReportTaskFormContext',
|
||||||
|
'buildReportTaskSavePayload'
|
||||||
|
])
|
||||||
|
|
||||||
|
assertFileIncludes(path.join(pageDir, 'components/ReportTaskPrepareStep.vue'), [
|
||||||
|
"name: 'ReportTaskPrepareStep'",
|
||||||
|
'validateReportTaskLedgerApi',
|
||||||
'downloadReportTaskLedgerTemplateApi',
|
'downloadReportTaskLedgerTemplateApi',
|
||||||
'importReportTaskLedgerApi',
|
|
||||||
'selectedFiles',
|
'selectedFiles',
|
||||||
'latestImportResult',
|
'validateResult',
|
||||||
'handleImportFiles',
|
'sessionId',
|
||||||
'toolbar-actions',
|
'canContinueUpload',
|
||||||
'toolbar-download'
|
'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'), [
|
assertFileIncludes(path.join(pageDir, 'components/ReportTaskFormDialog.vue'), [
|
||||||
"name: 'ReportTaskFormDialog'",
|
"name: 'ReportTaskFormDialog'",
|
||||||
'ReportTaskLedgerImportPanel',
|
'ReportTaskPrepareStep',
|
||||||
'REPORT_TASK_FORM_STEPS',
|
'ReportTaskImportStep',
|
||||||
'currentStep',
|
'ReportTaskBaseInfoStep',
|
||||||
'logEntries',
|
'ReportTaskCompleteStep',
|
||||||
'logPanelExpanded',
|
'REPORT_TASK_FLOW_STEPS',
|
||||||
'goToImportStep',
|
'createEmptyLedgerPreparedState',
|
||||||
'handleLedgerPreparedChange',
|
'buildReportTaskFormContext',
|
||||||
'ledgerPreparedState',
|
'buildReportTaskSavePayload',
|
||||||
'activeDraftId',
|
'ledger/validate -> ledger/import',
|
||||||
'checkReportTaskLedgerPrepared',
|
'log-floating-panel',
|
||||||
'padding-bottom: 24px',
|
'el-tooltip',
|
||||||
'position: absolute',
|
|
||||||
'z-index: 3',
|
|
||||||
'log-panel-header',
|
|
||||||
'log-panel-body',
|
|
||||||
'log-panel-toggle',
|
|
||||||
'white-space: nowrap',
|
|
||||||
'text-overflow: ellipsis',
|
'text-overflow: ellipsis',
|
||||||
'log-empty'
|
'height: 560px',
|
||||||
])
|
'max-height: calc(100vh - 40px)',
|
||||||
|
'display: flex',
|
||||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskDetailDialog.vue'), [
|
'padding: 16px 18px 12px',
|
||||||
"name: 'ReportTaskDetailDialog'",
|
'gap: 6px',
|
||||||
'groupReports',
|
'padding: 0 12px 10px',
|
||||||
'generateState',
|
'.flow-main {\n display: flex;\n flex: 1;\n min-width: 0;\n min-height: 0;\n overflow: auto;\n}'
|
||||||
'group-report-title',
|
|
||||||
'resolveReportTaskGroupReportGenerateStateText'
|
|
||||||
])
|
|
||||||
|
|
||||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskAuditDialog.vue'), [
|
|
||||||
"name: 'ReportTaskAuditDialog'",
|
|
||||||
'checkResult'
|
|
||||||
])
|
])
|
||||||
|
|
||||||
assertFileIncludes(path.join(pageDir, 'index.vue'), [
|
assertFileIncludes(path.join(pageDir, 'index.vue'), [
|
||||||
"name: 'ReportTaskPage'",
|
"name: 'ReportTaskPage'",
|
||||||
'<ProTable',
|
|
||||||
'ReportTaskFormDialog',
|
'ReportTaskFormDialog',
|
||||||
'ReportTaskDetailDialog',
|
'@refresh-options',
|
||||||
'ReportTaskAuditDialog',
|
'ledger/validate -> ledger/import -> add/update'
|
||||||
'listReportTaskGroupReportsApi',
|
|
||||||
'detailGroupReports',
|
|
||||||
'ledger/import -> add/update'
|
|
||||||
])
|
|
||||||
|
|
||||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskLedgerImportPanel.vue'), [
|
|
||||||
'min-height: 0',
|
|
||||||
'flex: 1',
|
|
||||||
'display: flex',
|
|
||||||
'flex-direction: column'
|
|
||||||
])
|
])
|
||||||
|
|
||||||
console.log('testReport page contract passed')
|
console.log('testReport page contract passed')
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
:report-model-options="reportModelOptions"
|
:report-model-options="reportModelOptions"
|
||||||
:company-options="companyOptions"
|
:company-options="companyOptions"
|
||||||
:standard-options="standardOptions"
|
:standard-options="standardOptions"
|
||||||
|
@refresh-options="refreshFormOptions"
|
||||||
@submit="handleSaveReportTask"
|
@submit="handleSaveReportTask"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -92,6 +93,11 @@ import {
|
|||||||
buildDictSelectOptions,
|
buildDictSelectOptions,
|
||||||
buildOptionLabelMap,
|
buildOptionLabelMap,
|
||||||
getReportTaskErrorMessage,
|
getReportTaskErrorMessage,
|
||||||
|
getReportTaskGenerateStateTagType,
|
||||||
|
getReportTaskGenerateStateText,
|
||||||
|
getReportTaskStateTagType,
|
||||||
|
getReportTaskStateText,
|
||||||
|
REPORT_TASK_STATE_OPTIONS,
|
||||||
normalizeReportTaskGroupReportList,
|
normalizeReportTaskGroupReportList,
|
||||||
normalizeReportTaskListParams,
|
normalizeReportTaskListParams,
|
||||||
normalizeReportTaskPage,
|
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 companyOptions = computed(() => buildDictSelectOptions(dictStore.getDictData(DICT_CODES.TEST_REPORT_COMPANY)))
|
||||||
const standardOptions = computed(() => buildDictSelectOptions(dictStore.getDictData(DICT_CODES.TEST_REPORT_STANDARD)))
|
const standardOptions = computed(() => buildDictSelectOptions(dictStore.getDictData(DICT_CODES.TEST_REPORT_STANDARD)))
|
||||||
|
const stateOptions = REPORT_TASK_STATE_OPTIONS
|
||||||
const companyLabelMap = computed(() => buildOptionLabelMap(companyOptions.value))
|
const companyLabelMap = computed(() => buildOptionLabelMap(companyOptions.value))
|
||||||
const standardLabelMap = computed(() => buildOptionLabelMap(standardOptions.value))
|
const standardLabelMap = computed(() => buildOptionLabelMap(standardOptions.value))
|
||||||
const requiredDictCodes = [DICT_CODES.TEST_REPORT_COMPANY, DICT_CODES.TEST_REPORT_STANDARD]
|
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: 'no', label: '报告编号', minWidth: 180, fixed: 'left', render: ({ row }) => resolveReportTaskText(row.no) },
|
||||||
{ prop: 'clientUnitName', label: '委托单位', minWidth: 160, render: ({ row }) => resolveReportTaskText(row.clientUnitName) },
|
{ prop: 'clientUnitName', label: '委托单位', minWidth: 160, render: ({ row }) => resolveReportTaskText(row.clientUnitName) },
|
||||||
{ prop: 'reportModelName', label: '报告模板', minWidth: 160, render: ({ row }) => resolveReportTaskText(row.reportModelName) },
|
{ prop: 'reportModelName', label: '报告模板', minWidth: 160, render: ({ row }) => resolveReportTaskText(row.reportModelName) },
|
||||||
@@ -181,6 +207,16 @@ const columns = reactive<ColumnProps<ReportTask.ReportTaskRecord>[]>([
|
|||||||
showOverflowTooltip: true,
|
showOverflowTooltip: true,
|
||||||
render: ({ row }) => resolveReportTaskStandardText(row.standard, standardLabelMap.value)
|
render: ({ row }) => resolveReportTaskStandardText(row.standard, standardLabelMap.value)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
prop: '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: 'pointCount', label: '监测点数', minWidth: 100, render: ({ row }) => resolveReportTaskText(row.pointCount) },
|
||||||
{ prop: 'groupCount', label: '分组数', minWidth: 100, render: ({ row }) => resolveReportTaskText(row.groupCount) },
|
{ prop: 'groupCount', label: '分组数', minWidth: 100, render: ({ row }) => resolveReportTaskText(row.groupCount) },
|
||||||
{ prop: 'phonenumber', label: '联系电话', minWidth: 140, render: ({ row }) => resolveReportTaskText(row.phonenumber) },
|
{ prop: 'phonenumber', label: '联系电话', minWidth: 140, render: ({ row }) => resolveReportTaskText(row.phonenumber) },
|
||||||
@@ -251,6 +287,10 @@ const ensureFormOptionsReady = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const refreshFormOptions = async () => {
|
||||||
|
await ensureFormOptionsReady()
|
||||||
|
}
|
||||||
|
|
||||||
const getTableList = async (params: ReportTask.ReportTaskListParams = {}) => {
|
const getTableList = async (params: ReportTask.ReportTaskListParams = {}) => {
|
||||||
const response = await listReportTasksApi(normalizeReportTaskListParams(params))
|
const response = await listReportTasksApi(normalizeReportTaskListParams(params))
|
||||||
const pageData = normalizeReportTaskPage<ReportTask.ReportTaskRecord>(
|
const pageData = normalizeReportTaskPage<ReportTask.ReportTaskRecord>(
|
||||||
@@ -337,7 +377,7 @@ const handleSaveReportTask = async (params: ReportTask.ReportTaskSaveRequest) =>
|
|||||||
formSaving.value = true
|
formSaving.value = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 关键业务节点:台账导入已在弹窗内完成,页面层这里只执行最终 add/update,整体顺序为 ledger/import -> add/update。
|
// 关键业务节点:文件校验与正式导入已在弹窗内完成,页面层这里只执行最终 add/update,整体顺序为 ledger/validate -> ledger/import -> add/update。
|
||||||
if (formMode.value === 'create') {
|
if (formMode.value === 'create') {
|
||||||
await createReportTaskApi(params)
|
await createReportTaskApi(params)
|
||||||
ElMessage.success('报告任务新增成功')
|
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 { Dict, ResultData, ResPage } from '@/api/interface'
|
||||||
import type { ReportTask } from '@/api/aireport/testReport/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_EXCEL_EXTENSIONS = ['.xls', '.xlsx']
|
||||||
export const TEST_REPORT_WORD_EXTENSIONS = ['.doc', '.docx']
|
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 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> = {
|
export const REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP: Record<number, string> = {
|
||||||
0: '未生成',
|
0: '未生成',
|
||||||
1: '生成中',
|
1: '生成中',
|
||||||
@@ -43,6 +66,7 @@ export const normalizeReportTaskListParams = (
|
|||||||
keyword: String(params.keyword || '').trim() || undefined,
|
keyword: String(params.keyword || '').trim() || undefined,
|
||||||
searchBeginTime: searchBeginTime || params.searchBeginTime || undefined,
|
searchBeginTime: searchBeginTime || params.searchBeginTime || undefined,
|
||||||
searchEndTime: searchEndTime || params.searchEndTime || undefined,
|
searchEndTime: searchEndTime || params.searchEndTime || undefined,
|
||||||
|
state: params.state || undefined,
|
||||||
pageNum: params.pageNum || 1,
|
pageNum: params.pageNum || 1,
|
||||||
pageSize: params.pageSize || 10
|
pageSize: params.pageSize || 10
|
||||||
}
|
}
|
||||||
@@ -88,6 +112,11 @@ export const isReportTaskWordFileName = (fileName: string) => {
|
|||||||
return TEST_REPORT_WORD_EXTENSIONS.some(extension => normalizedName.endsWith(extension))
|
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) =>
|
export const isReportTaskLedgerAttachmentFileName = (fileName: string) =>
|
||||||
isReportTaskExcelFileName(fileName) || isReportTaskWordFileName(fileName)
|
isReportTaskExcelFileName(fileName) || isReportTaskWordFileName(fileName)
|
||||||
|
|
||||||
@@ -115,10 +144,13 @@ export const normalizeReportTaskLedgerImportResult = (
|
|||||||
const stageList = Array.isArray(payload?.stages) ? payload.stages : []
|
const stageList = Array.isArray(payload?.stages) ? payload.stages : []
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
batchId: payload?.batchId || undefined,
|
||||||
currentStage: payload?.currentStage || undefined,
|
currentStage: payload?.currentStage || undefined,
|
||||||
success: payload?.success ?? false,
|
success: payload?.success ?? false,
|
||||||
summaryFileName: payload?.summaryFileName || undefined,
|
summaryFileName: payload?.summaryFileName || undefined,
|
||||||
|
tempStoragePath: payload?.tempStoragePath || undefined,
|
||||||
totalFileCount: payload?.totalFileCount ?? 0,
|
totalFileCount: payload?.totalFileCount ?? 0,
|
||||||
|
uploadedFileCount: payload?.uploadedFileCount ?? 0,
|
||||||
pointCount: payload?.pointCount ?? 0,
|
pointCount: payload?.pointCount ?? 0,
|
||||||
excelAttachmentCount: payload?.excelAttachmentCount ?? 0,
|
excelAttachmentCount: payload?.excelAttachmentCount ?? 0,
|
||||||
wordAttachmentCount: payload?.wordAttachmentCount ?? 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 = (
|
export const normalizeReportTaskGroupReportList = (
|
||||||
response:
|
response:
|
||||||
| ResultData<ReportTask.ReportTaskGroupReportRecord[]>
|
| ResultData<ReportTask.ReportTaskGroupReportRecord[]>
|
||||||
@@ -209,9 +296,21 @@ export const resolveReportTaskGroupReportGenerateStateTagType = (value: number |
|
|||||||
return REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TAG_TYPE_MAP[value]
|
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 = (
|
export const checkReportTaskLedgerPrepared = (
|
||||||
state: ReportTask.ReportTaskLedgerPreparedState | null | undefined
|
state: ReportTask.ReportTaskLedgerPreparedState | null | undefined
|
||||||
) => Boolean(state?.draftId && state.hasImported && !state.pendingReimport)
|
) => Boolean(state?.draftId && state.hasImported && !state.pendingRevalidate)
|
||||||
|
|
||||||
export const buildDictSelectOptions = (dictData: Dict[] = []) =>
|
export const buildDictSelectOptions = (dictData: Dict[] = []) =>
|
||||||
dictData
|
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.*",
|
"vitest.config.*",
|
||||||
"cypress.config.*",
|
"cypress.config.*",
|
||||||
"nightwatch.conf.*",
|
"nightwatch.conf.*",
|
||||||
"playwright.config.*"
|
"playwright.config.*",
|
||||||
|
"build/**/*.ts",
|
||||||
|
"build/**/*.d.ts",
|
||||||
|
"src/types/**/*.d.ts"
|
||||||
],
|
],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
"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 { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
@@ -61,10 +62,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
|||||||
// dts: "src/types/components.d.ts",
|
// dts: "src/types/components.d.ts",
|
||||||
}),
|
}),
|
||||||
nodePolyfills({
|
nodePolyfills({
|
||||||
include: ['crypto'],
|
include: ['crypto']
|
||||||
globals: {
|
|
||||||
crypto: true
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
// 基础配置
|
// 基础配置
|
||||||
|
|||||||
Reference in New Issue
Block a user