Compare commits
4 Commits
2026-06
...
b1cbc3d304
| Author | SHA1 | Date | |
|---|---|---|---|
| b1cbc3d304 | |||
| 08fd57ada1 | |||
| f9c826ffea | |||
| 55fd3df55d |
@@ -30,7 +30,9 @@ export function wrapperEnv(envConf: Recordable): ViteEnv {
|
||||
if (envName === "VITE_PROXY") {
|
||||
try {
|
||||
realName = JSON.parse(realName);
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
// Keep the original string when the proxy config is not valid JSON.
|
||||
}
|
||||
}
|
||||
ret[envName] = realName;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export const listReportTasksApi = (params: ReportTask.ReportTaskListParams) => {
|
||||
return http.post(`${REPORT_TASK_BASE_URL}/list`, params)
|
||||
}
|
||||
|
||||
export const createReportTaskApi = (params: ReportTask.ReportTaskSaveRequest) => {
|
||||
export const createReportTaskApi = (params: ReportTask.ReportTaskAddParam) => {
|
||||
return http.post<boolean>(`${REPORT_TASK_BASE_URL}/add`, params)
|
||||
}
|
||||
|
||||
@@ -30,3 +30,18 @@ export const exportReportTasksApi = (params: ReportTask.ReportTaskListParams): P
|
||||
export const submitReportTaskAuditApi = (params: ReportTask.ReportTaskAuditRequest) => {
|
||||
return http.post<boolean>(`${REPORT_TASK_BASE_URL}/submit-audit`, params)
|
||||
}
|
||||
|
||||
export const downloadReportTaskLedgerTemplateApi = (): Promise<AxiosResponse<Blob>> =>
|
||||
http.get(`${REPORT_TASK_BASE_URL}/ledger/template`, undefined, {
|
||||
responseType: 'blob'
|
||||
}) as unknown as Promise<AxiosResponse<Blob>>
|
||||
|
||||
export const validateReportTaskLedgerApi = (id: string, formData: FormData) => {
|
||||
return http.post<ReportTask.ReportTaskLedgerImportResult>(`${REPORT_TASK_BASE_URL}/${id}/ledger/validate`, formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
export const listReportTaskGroupReportsApi = (id: string) => {
|
||||
return http.get<ReportTask.ReportTaskGroupReportRecord[]>(`${REPORT_TASK_BASE_URL}/${id}/group-report/list`)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
export namespace ReportTask {
|
||||
export type ReportTaskGroupReportGenerateState = 0 | 1 | 2 | 3
|
||||
export type ReportTaskLedgerImportStage =
|
||||
| '选择文件'
|
||||
| '校验文件'
|
||||
| '文件上传'
|
||||
| '基础资料维护'
|
||||
| '完成'
|
||||
|
||||
export interface ReportTaskRecord {
|
||||
id?: string
|
||||
no?: string | null
|
||||
@@ -16,12 +24,16 @@ export namespace ReportTask {
|
||||
checkTime?: string | null
|
||||
checkResult?: string | null
|
||||
status?: number
|
||||
pointCount?: number | null
|
||||
groupCount?: number | null
|
||||
reportGenerateState?: number | null
|
||||
createBy?: string | null
|
||||
createByName?: string | null
|
||||
createTime?: string | null
|
||||
updateBy?: string | null
|
||||
updateByName?: string | null
|
||||
updateTime?: string | null
|
||||
groupReports?: ReportTaskGroupReportRecord[] | null
|
||||
}
|
||||
|
||||
export interface ReportTaskListParams {
|
||||
@@ -33,7 +45,7 @@ export namespace ReportTask {
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface ReportTaskSaveRequest {
|
||||
export interface ReportTaskAddParam {
|
||||
id?: string
|
||||
no: string
|
||||
clientUnitId: string
|
||||
@@ -42,11 +54,108 @@ export namespace ReportTask {
|
||||
contractNumber: string
|
||||
standard: string[]
|
||||
data: string
|
||||
batchId?: string
|
||||
phonenumber?: string
|
||||
}
|
||||
|
||||
export interface ReportTaskSaveRequest extends ReportTaskAddParam {}
|
||||
|
||||
export interface ReportTaskAuditRequest {
|
||||
id: string
|
||||
checkResult?: string
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerImportStageRecord {
|
||||
stage?: ReportTaskLedgerImportStage | string | null
|
||||
success?: boolean | null
|
||||
message?: string | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerImportSnapshotGroupRecord {
|
||||
groupNo?: number | null
|
||||
count?: number | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerImportSnapshot {
|
||||
version?: string | null
|
||||
importMode?: string | null
|
||||
summaryFileName?: string | null
|
||||
sheetSummary?: {
|
||||
pointSheet?: string | null
|
||||
deviceSheetPresent?: boolean | null
|
||||
clientSheetPresent?: boolean | null
|
||||
} | null
|
||||
rowCount?: number | null
|
||||
groupSummary?: ReportTaskLedgerImportSnapshotGroupRecord[] | null
|
||||
baseDataSummary?: {
|
||||
deviceAddedCount?: number | null
|
||||
deviceReuseCount?: number | null
|
||||
clientAddedCount?: number | null
|
||||
clientReuseCount?: number | null
|
||||
} | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerImportResult {
|
||||
batchId?: string | null
|
||||
currentStage?: ReportTaskLedgerImportStage | string | null
|
||||
success?: boolean | null
|
||||
summaryFileName?: string | null
|
||||
totalFileCount?: number
|
||||
pointCount?: number
|
||||
excelAttachmentCount?: number
|
||||
wordAttachmentCount?: number
|
||||
deviceAddedCount?: number
|
||||
deviceReuseCount?: number
|
||||
clientAddedCount?: number
|
||||
clientReuseCount?: number
|
||||
groupCount?: number
|
||||
failReasons?: string[] | null
|
||||
stages?: ReportTaskLedgerImportStageRecord[] | null
|
||||
}
|
||||
|
||||
export interface ReportTaskPointRecord {
|
||||
id?: string
|
||||
groupNo?: number | null
|
||||
substationName?: string | null
|
||||
pointName?: string | null
|
||||
monitorTime?: string | null
|
||||
voltageLevel?: string | null
|
||||
ptRatio?: string | null
|
||||
ctRatio?: string | null
|
||||
baseShortCircuitCapacity?: string | null
|
||||
minShortCircuitCapacity?: string | null
|
||||
protocolCapacity?: string | null
|
||||
powerSupplyCapacity?: string | null
|
||||
excelAttachmentName?: string | null
|
||||
}
|
||||
|
||||
export interface ReportTaskPointGroupItem {
|
||||
groupNo: number
|
||||
pointIds: string[]
|
||||
}
|
||||
|
||||
export interface ReportTaskGroupSaveRequest {
|
||||
groups: ReportTaskPointGroupItem[]
|
||||
}
|
||||
|
||||
export interface ReportTaskGroupReportRecord {
|
||||
id?: string
|
||||
groupNo?: number | null
|
||||
reportName?: string | null
|
||||
reportFileName?: string | null
|
||||
reportStoragePath?: string | null
|
||||
generateState?: ReportTaskGroupReportGenerateState | null
|
||||
generateMessage?: string | null
|
||||
generateTime?: string | null
|
||||
sortNo?: number | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerPreparedState {
|
||||
draftId: string
|
||||
batchId: string
|
||||
latestImportResult: ReportTaskLedgerImportResult | null
|
||||
snapshot: ReportTaskLedgerImportSnapshot | null
|
||||
hasImported: boolean
|
||||
pendingReimport: boolean
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,60 +20,67 @@ export namespace Login {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 用户管理模块
|
||||
export namespace User {
|
||||
/**
|
||||
* 用户数据表格分页查询参数
|
||||
*/
|
||||
export interface ReqUserParams extends ReqPage {
|
||||
id: string // 装置序号用户ID 必填
|
||||
name?: string //用户名(别名)
|
||||
loginTime?: string //最后一次登录时间
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户数据表格分页查询参数
|
||||
*/
|
||||
export interface ReqUserParams extends ReqPage{
|
||||
id: string; // 装置序号用户ID 必填
|
||||
name?: string; //用户名(别名)
|
||||
loginTime?: string;//最后一次登录时间
|
||||
}
|
||||
// 用户接口
|
||||
export interface ResUser {
|
||||
id: string //用户ID,作为唯一标识
|
||||
name: string //用户名(别名)
|
||||
loginName: string //登录名
|
||||
deptId?: number //部门ID
|
||||
password: string //密码
|
||||
phone?: string //手机号
|
||||
email?: string //邮箱
|
||||
loginTime?: string //最后一次登录时间
|
||||
loginErrorTimes: number //登录错误次数
|
||||
lockTime?: string //用户密码错误锁定时间
|
||||
state: number //0-删除;1-正常;2-锁定;3-待审核;4-休眠;5-密码过期
|
||||
createBy?: string //创建用户
|
||||
createTime?: string //创建时间
|
||||
updateBy?: string //更新用户
|
||||
updateTime?: string //更新时间
|
||||
roleIds?: string[]
|
||||
roleNames?: string[]
|
||||
roleCodes?: string[]
|
||||
signatureFileId?: string
|
||||
signatureFileName?: string
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
// 用户接口
|
||||
export interface ResUser {
|
||||
id: string; //用户ID,作为唯一标识
|
||||
name: string; //用户名(别名)
|
||||
loginName: string;//登录名
|
||||
deptId?: number;//部门ID
|
||||
password: string; //密码
|
||||
phone?: string; //手机号
|
||||
email?: string; //邮箱
|
||||
loginTime?: string;//最后一次登录时间
|
||||
loginErrorTimes: number;//登录错误次数
|
||||
lockTime?: string; //用户密码错误锁定时间
|
||||
state:number;//0-删除;1-正常;2-锁定;3-待审核;4-休眠;5-密码过期
|
||||
createBy?: string;//创建用户
|
||||
createTime?: string;//创建时间
|
||||
updateBy?: string;//更新用户
|
||||
updateTime?: string;//更新时间
|
||||
roleIds?: string[]; //
|
||||
roleNames?:string[]; //
|
||||
roleCodes?:string[]; //
|
||||
disabled?: boolean;
|
||||
}
|
||||
export interface UserSaveRequest {
|
||||
id?: string
|
||||
name: string
|
||||
loginName?: string
|
||||
password?: string
|
||||
deptId?: string | number
|
||||
phone?: string
|
||||
email?: string
|
||||
roleIds?: string[]
|
||||
}
|
||||
|
||||
// 用户接口
|
||||
export interface ResPassWordUser {
|
||||
id: string; //用户ID,作为唯一标识
|
||||
oldPassword: string; //密码
|
||||
newPassword: string; //新密码
|
||||
surePassword:string;
|
||||
}
|
||||
// 用户接口
|
||||
export interface ResPassWordUser {
|
||||
id: string //用户ID,作为唯一标识
|
||||
oldPassword: string //密码
|
||||
newPassword: string //新密码
|
||||
surePassword: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户表格查询分页返回的对象;
|
||||
*/
|
||||
export interface ResUserPage extends ResPage<ResUser> {}
|
||||
// // 用户+分页
|
||||
// export interface ReqUserParams extends ReqPage,UserBO {
|
||||
|
||||
/**
|
||||
* 用户表格查询分页返回的对象;
|
||||
*/
|
||||
export interface ResUserPage extends ResPage<ResUser> {
|
||||
|
||||
}
|
||||
// // 用户+分页
|
||||
// export interface ReqUserParams extends ReqPage,UserBO {
|
||||
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,43 +1,65 @@
|
||||
import type { AxiosResponse } from 'axios'
|
||||
import http from '@/api'
|
||||
import type { Role } from '@/api/user/interface/role'
|
||||
import type { User } from '@/api/user/interface/user'
|
||||
import http from '@/api'
|
||||
|
||||
const buildUserFormData = (request: User.UserSaveRequest, signatureFile?: File | null) => {
|
||||
const formData = new FormData()
|
||||
|
||||
// 关键业务节点:新增和编辑用户都按 request JSON Part + signatureFile 文件分段提交,字段名必须与后端 @RequestPart 保持一致。
|
||||
formData.append('request', new Blob([JSON.stringify(request)], { type: 'application/json' }))
|
||||
|
||||
if (signatureFile) {
|
||||
formData.append('signatureFile', signatureFile)
|
||||
}
|
||||
|
||||
return formData
|
||||
}
|
||||
|
||||
/**
|
||||
* @name 用户管理模块
|
||||
*/
|
||||
// 获取用户列表
|
||||
export const getUserList = (params: User.ReqUserParams) => {
|
||||
return http.post(`/sysUser/list`, params)
|
||||
return http.post(`/sysUser/list`, params)
|
||||
}
|
||||
|
||||
|
||||
// 新增用户
|
||||
export const addUser = (params: User.ResUser) => {
|
||||
return http.post(`/sysUser/add`, params)
|
||||
export const addUser = (request: User.UserSaveRequest, signatureFile?: File | null) => {
|
||||
return http.post(`/sysUser/add`, buildUserFormData(request, signatureFile), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
// 编辑用户
|
||||
export const updateUser = (params: User.ResUser) => {
|
||||
return http.post(`/sysUser/update`, params)
|
||||
export const updateUser = (request: User.UserSaveRequest, signatureFile?: File | null) => {
|
||||
return http.post(`/sysUser/update`, buildUserFormData(request, signatureFile), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
export const deleteUser = (params: string[] ) => {
|
||||
return http.post(`/sysUser/delete`, params)
|
||||
export const deleteUser = (params: string[]) => {
|
||||
return http.post(`/sysUser/delete`, params)
|
||||
}
|
||||
|
||||
|
||||
// 获取角色列表
|
||||
export const getRoleList = () => {
|
||||
return http.get<Role.RoleBO>(`/sysRole/simpleList`)
|
||||
return http.get<Role.RoleBO>(`/sysRole/simpleList`)
|
||||
}
|
||||
|
||||
//修改密码
|
||||
// 修改密码
|
||||
export const updatePassWord = (params: User.ResPassWordUser) => {
|
||||
return http.post(`/sysUser/updatePassword`,params)
|
||||
return http.post(`/sysUser/updatePassword`, params)
|
||||
}
|
||||
|
||||
// 获取所有用户
|
||||
export const getAllUser= () => {
|
||||
return http.get(`/sysUser/getAll`)
|
||||
export const getAllUser = () => {
|
||||
return http.get(`/sysUser/getAll`)
|
||||
}
|
||||
|
||||
export const previewUserSignature = (id: string): Promise<AxiosResponse<Blob>> => {
|
||||
return http.get(`/sysUser/${id}/signature`, undefined, { responseType: 'blob' }) as unknown as Promise<
|
||||
AxiosResponse<Blob>
|
||||
>
|
||||
}
|
||||
|
||||
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>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog v-model="visibleProxy" title="报告任务详情" width="760px" append-to-body destroy-on-close>
|
||||
<el-dialog v-model="visibleProxy" title="报告任务详情" width="880px" append-to-body destroy-on-close>
|
||||
<div v-loading="loading" class="report-task-detail-dialog">
|
||||
<el-descriptions class="detail-descriptions" :column="2" border>
|
||||
<el-descriptions-item label="报告编号">{{ resolveReportTaskText(detail?.no) }}</el-descriptions-item>
|
||||
@@ -14,6 +14,8 @@
|
||||
{{ resolveReportTaskStandardText(detail?.standard, standardLabelMap) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="送资数据" :span="2">{{ resolveReportTaskText(detail?.data) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点数量">{{ resolveReportTaskText(detail?.pointCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="分组数量">{{ resolveReportTaskText(detail?.groupCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核人">{{ resolveReportTaskText(detail?.checkerName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核时间">{{ resolveReportTaskText(detail?.checkTime) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核意见" :span="2">{{ resolveReportTaskText(detail?.checkResult) }}</el-descriptions-item>
|
||||
@@ -26,6 +28,24 @@
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">{{ resolveReportTaskText(detail?.updateTime) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div class="group-report-section">
|
||||
<div class="group-report-title">分组报告生成状态</div>
|
||||
<el-empty v-if="!groupReports.length" description="暂无分组报告记录" :image-size="88" />
|
||||
<el-table v-else :data="groupReports" border size="small">
|
||||
<el-table-column prop="groupNo" label="分组号" width="100" />
|
||||
<el-table-column prop="reportName" label="报告名称" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column label="生成状态" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="resolveReportTaskGroupReportGenerateStateTagType(row.generateState)">
|
||||
{{ resolveReportTaskGroupReportGenerateStateText(row.generateState) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="generateMessage" label="生成消息" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="generateTime" label="生成时间" min-width="160" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="visibleProxy = false">关闭</el-button>
|
||||
@@ -38,6 +58,8 @@ import { computed } from 'vue'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import {
|
||||
resolveReportTaskCreateUnitText,
|
||||
resolveReportTaskGroupReportGenerateStateTagType,
|
||||
resolveReportTaskGroupReportGenerateStateText,
|
||||
resolveReportTaskStandardText,
|
||||
resolveReportTaskText
|
||||
} from '../utils/testReport'
|
||||
@@ -50,6 +72,7 @@ const props = defineProps<{
|
||||
visible: boolean
|
||||
loading: boolean
|
||||
detail: ReportTask.ReportTaskRecord | null
|
||||
groupReports: ReportTask.ReportTaskGroupReportRecord[]
|
||||
companyLabelMap: Record<string, string>
|
||||
standardLabelMap: Record<string, string>
|
||||
}>()
|
||||
@@ -65,6 +88,7 @@ const visibleProxy = computed({
|
||||
|
||||
const companyLabelMap = computed(() => props.companyLabelMap)
|
||||
const standardLabelMap = computed(() => props.standardLabelMap)
|
||||
const groupReports = computed(() => props.groupReports || [])
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -80,4 +104,15 @@ const standardLabelMap = computed(() => props.standardLabelMap)
|
||||
.report-task-detail-dialog :deep(.detail-descriptions .el-descriptions__label.el-descriptions__cell.is-bordered-label) {
|
||||
width: 112px;
|
||||
}
|
||||
|
||||
.group-report-section {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.group-report-title {
|
||||
margin-bottom: 12px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,127 +2,258 @@
|
||||
<el-dialog
|
||||
v-model="visibleProxy"
|
||||
:title="mode === 'create' ? '新增报告任务' : '编辑报告任务'"
|
||||
width="720px"
|
||||
width="1080px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
class="report-task-flow-dialog"
|
||||
@closed="resetForm"
|
||||
>
|
||||
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="108px" class="report-task-form">
|
||||
<el-row :gutter="16">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="报告编号" prop="no">
|
||||
<el-input v-model="formModel.no" maxlength="32" clearable placeholder="请输入报告编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="委托单位" prop="clientUnitId">
|
||||
<el-select v-model="formModel.clientUnitId" filterable clearable placeholder="请选择委托单位">
|
||||
<el-option
|
||||
v-for="option in clientUnitSelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="报告模板" prop="reportModelId">
|
||||
<el-select v-model="formModel.reportModelId" filterable clearable placeholder="请选择报告模板">
|
||||
<el-option
|
||||
v-for="option in reportModelSelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="检测公司" prop="createUnit">
|
||||
<el-select v-model="formModel.createUnit" filterable clearable placeholder="请选择检测公司">
|
||||
<el-option
|
||||
v-for="option in companySelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="合同编号" prop="contractNumber">
|
||||
<el-input v-model="formModel.contractNumber" maxlength="32" clearable placeholder="请输入合同编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="测试依据" prop="standardIds">
|
||||
<el-select
|
||||
v-model="formModel.standardIds"
|
||||
multiple
|
||||
filterable
|
||||
clearable
|
||||
collapse-tags
|
||||
placeholder="请选择测试依据"
|
||||
>
|
||||
<el-option
|
||||
v-for="option in standardSelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
>
|
||||
<div class="standard-option">
|
||||
<el-checkbox
|
||||
class="standard-option-checkbox"
|
||||
:model-value="formModel.standardIds.includes(option.value)"
|
||||
/>
|
||||
<span class="standard-option-label">{{ option.label }}</span>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="联系电话" prop="phonenumber">
|
||||
<el-input v-model="formModel.phonenumber" maxlength="32" clearable placeholder="请输入联系电话" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="送资数据" prop="data">
|
||||
<el-input
|
||||
v-model="formModel.data"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
maxlength="256"
|
||||
show-word-limit
|
||||
placeholder="请输入送资数据"
|
||||
<div class="report-task-form-dialog">
|
||||
<div class="flow-nav">
|
||||
<button
|
||||
v-for="step in REPORT_TASK_FORM_STEPS"
|
||||
:key="step.value"
|
||||
type="button"
|
||||
class="flow-step"
|
||||
:class="[`is-${resolveStepStatus(step.value)}`, { 'is-clickable': canSwitchStep(step.value) }]"
|
||||
:disabled="!canSwitchStep(step.value)"
|
||||
@click="handleStepClick(step.value)"
|
||||
>
|
||||
<span class="flow-step-index">{{ step.index }}</span>
|
||||
<span class="flow-step-content">
|
||||
<span class="flow-step-title">{{ step.title }}</span>
|
||||
<span class="flow-step-desc">{{ step.description }}</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flow-main">
|
||||
<div v-if="currentStep === 'import'" class="flow-panel">
|
||||
<ReportTaskLedgerImportPanel
|
||||
:draft-id="activeDraftId"
|
||||
:disabled="saving"
|
||||
:prepared-state="ledgerPreparedState"
|
||||
:snapshot="ledgerSnapshot"
|
||||
@change="handleLedgerPreparedChange"
|
||||
@log="handleLog"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-else-if="currentStep === 'form'" class="flow-panel">
|
||||
<div class="form-panel">
|
||||
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="108px" class="report-task-form">
|
||||
<el-row :gutter="16">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="报告编号" prop="no">
|
||||
<el-input v-model="formModel.no" maxlength="32" clearable placeholder="请输入报告编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="委托单位" prop="clientUnitId">
|
||||
<el-select v-model="formModel.clientUnitId" filterable clearable placeholder="请选择委托单位">
|
||||
<el-option
|
||||
v-for="option in clientUnitSelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="报告模板" prop="reportModelId">
|
||||
<el-select v-model="formModel.reportModelId" filterable clearable placeholder="请选择报告模板">
|
||||
<el-option
|
||||
v-for="option in reportModelSelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="检测公司" prop="createUnit">
|
||||
<el-select v-model="formModel.createUnit" filterable clearable placeholder="请选择检测公司">
|
||||
<el-option
|
||||
v-for="option in companySelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="合同编号" prop="contractNumber">
|
||||
<el-input v-model="formModel.contractNumber" maxlength="32" clearable placeholder="请输入合同编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="测试依据" prop="standardIds">
|
||||
<el-select
|
||||
v-model="formModel.standardIds"
|
||||
multiple
|
||||
filterable
|
||||
clearable
|
||||
collapse-tags
|
||||
placeholder="请选择测试依据"
|
||||
>
|
||||
<el-option
|
||||
v-for="option in standardSelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="联系电话" prop="phonenumber">
|
||||
<el-input v-model="formModel.phonenumber" maxlength="32" clearable placeholder="请输入联系电话" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<div class="summary-strip">
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">导入状态</span>
|
||||
<el-tag :type="canSubmit ? 'success' : 'warning'">
|
||||
{{ canSubmit ? '已准备提交' : '待完成台账校验' }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">监测点数</span>
|
||||
<span class="summary-value">{{ importSummary.pointCount }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">分组数</span>
|
||||
<span class="summary-value">{{ importSummary.groupCount }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">汇总文件</span>
|
||||
<span class="summary-value">{{ importSummary.summaryFileName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="flow-panel">
|
||||
<div class="complete-panel">
|
||||
<el-result
|
||||
icon="success"
|
||||
:title="mode === 'create' ? '报告任务新增完成' : '报告任务编辑完成'"
|
||||
sub-title="台账校验与基础信息保存均已完成,本次结果已同步刷新到列表。"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="报告编号">{{ formModel.no || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="委托单位">
|
||||
{{ resolveCurrentOptionLabel(clientUnitSelectOptions, formModel.clientUnitId) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="检测公司">
|
||||
{{ resolveCurrentOptionLabel(companySelectOptions, formModel.createUnit) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点数">{{ importSummary.pointCount }}</el-descriptions-item>
|
||||
<el-descriptions-item label="分组数">{{ importSummary.groupCount }}</el-descriptions-item>
|
||||
<el-descriptions-item label="汇总文件">{{ importSummary.summaryFileName }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="log-panel" :class="{ 'is-collapsed': !logPanelExpanded }">
|
||||
<button type="button" class="log-panel-header" @click="logPanelExpanded = !logPanelExpanded">
|
||||
<span class="log-panel-toggle" :class="{ 'is-collapsed': !logPanelExpanded }" aria-hidden="true"></span>
|
||||
<div class="log-title">日志信息</div>
|
||||
</button>
|
||||
|
||||
<div v-show="logPanelExpanded" class="log-panel-body">
|
||||
<div class="log-popover-body">
|
||||
<div v-if="logEntries.length" class="log-list">
|
||||
<div v-for="entry in logEntries" :key="entry.id" class="log-item">
|
||||
<div class="log-meta">
|
||||
<el-tag size="small" :type="resolveLogTagType(entry.type)">{{ resolveLogTypeText(entry.type) }}</el-tag>
|
||||
<span class="log-time">{{ entry.time }}</span>
|
||||
</div>
|
||||
<div class="log-message">{{ entry.message }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="当前暂无日志输出" :image-size="60" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button :disabled="saving" @click="visibleProxy = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="submitForm">确定</el-button>
|
||||
<el-button :disabled="saving" @click="visibleProxy = false">{{ currentStep === 'done' ? '关闭' : '取消' }}</el-button>
|
||||
|
||||
<template v-if="currentStep === 'import'">
|
||||
<el-button type="primary" :disabled="!canSubmit" @click="goToFormStep">下一步</el-button>
|
||||
</template>
|
||||
|
||||
<template v-else-if="currentStep === 'form'">
|
||||
<el-button type="primary" plain :disabled="saving" @click="goToImportStep">返回导入</el-button>
|
||||
<el-button type="primary" :loading="saving" :disabled="!canSubmit" @click="submitForm">提交</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { type FormInstance, type FormRules } from 'element-plus'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { parseReportTaskStandardIds, stringifyReportTaskStandardIds } from '../utils/testReport'
|
||||
import { generateUUID } from '@/utils'
|
||||
import ReportTaskLedgerImportPanel from './ReportTaskLedgerImportPanel.vue'
|
||||
import {
|
||||
checkReportTaskLedgerPrepared,
|
||||
getReportTaskErrorMessage,
|
||||
normalizeReportTaskLedgerSnapshot,
|
||||
parseReportTaskStandardIds,
|
||||
stringifyReportTaskStandardIds
|
||||
} from '../utils/testReport'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskFormDialog'
|
||||
})
|
||||
|
||||
type ReportTaskFormStep = 'import' | 'form' | 'done'
|
||||
type ReportTaskLogType = 'info' | 'success' | 'warning' | 'error'
|
||||
|
||||
const REPORT_TASK_FORM_STEPS: Array<{
|
||||
index: number
|
||||
value: ReportTaskFormStep
|
||||
title: string
|
||||
description: string
|
||||
}> = [
|
||||
{
|
||||
index: 1,
|
||||
value: 'import',
|
||||
title: '数据导入',
|
||||
description: '先完成台账与附件校验'
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
value: 'form',
|
||||
title: '基础信息填写',
|
||||
description: '填写并确认任务基础信息'
|
||||
},
|
||||
{
|
||||
index: 3,
|
||||
value: 'done',
|
||||
title: '完成',
|
||||
description: '查看结果并结束本次流程'
|
||||
}
|
||||
]
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
mode: 'create' | 'edit'
|
||||
record: ReportTask.ReportTaskRecord | null
|
||||
saving: boolean
|
||||
saveSuccessVersion: number
|
||||
clientUnitOptions: Array<{ label: string; value: string }>
|
||||
reportModelOptions: Array<{ label: string; value: string }>
|
||||
companyOptions: Array<{ label: string; value: string }>
|
||||
@@ -135,6 +266,20 @@ const emit = defineEmits<{
|
||||
}>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const activeDraftId = ref('')
|
||||
const currentStep = ref<ReportTaskFormStep>('import')
|
||||
const logPanelExpanded = ref(true)
|
||||
const logEntries = ref<Array<{ id: string; type: ReportTaskLogType; time: string; message: string }>>([])
|
||||
const ledgerPreparedState = ref<ReportTask.ReportTaskLedgerPreparedState>({
|
||||
draftId: '',
|
||||
batchId: '',
|
||||
latestImportResult: null,
|
||||
snapshot: null,
|
||||
hasImported: false,
|
||||
pendingReimport: false
|
||||
})
|
||||
const lastHandledSaveSuccessVersion = ref(0)
|
||||
|
||||
const formModel = reactive({
|
||||
id: '',
|
||||
no: '',
|
||||
@@ -153,8 +298,7 @@ const formRules: FormRules = {
|
||||
reportModelId: [{ required: true, message: '请选择报告模板', trigger: 'change' }],
|
||||
createUnit: [{ required: true, message: '请选择检测公司', trigger: 'change' }],
|
||||
contractNumber: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
|
||||
standardIds: [{ required: true, message: '请选择测试依据', trigger: 'change' }],
|
||||
data: [{ required: true, message: '请输入送资数据', trigger: 'blur' }]
|
||||
standardIds: [{ required: true, message: '请选择测试依据', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const visibleProxy = computed({
|
||||
@@ -162,6 +306,19 @@ const visibleProxy = computed({
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const ledgerSnapshot = computed(() => ledgerPreparedState.value.snapshot)
|
||||
const canSubmit = computed(() => !props.saving && checkReportTaskLedgerPrepared(ledgerPreparedState.value))
|
||||
const importSummary = computed(() => {
|
||||
const importResult = ledgerPreparedState.value.latestImportResult
|
||||
const snapshot = ledgerPreparedState.value.snapshot
|
||||
|
||||
return {
|
||||
pointCount: String(importResult?.pointCount ?? snapshot?.rowCount ?? '-'),
|
||||
groupCount: String(importResult?.groupCount ?? snapshot?.groupSummary?.length ?? '-'),
|
||||
summaryFileName: importResult?.summaryFileName || snapshot?.summaryFileName || '-'
|
||||
}
|
||||
})
|
||||
|
||||
const ensureCurrentOption = (
|
||||
options: Array<{ label: string; value: string }>,
|
||||
value: string,
|
||||
@@ -190,6 +347,38 @@ const standardSelectOptions = computed(() => {
|
||||
return [...props.standardOptions, ...extraOptions]
|
||||
})
|
||||
|
||||
const buildLogId = () => window.crypto?.randomUUID?.() || generateUUID()
|
||||
|
||||
const pushLog = (type: ReportTaskLogType, message: string) => {
|
||||
logEntries.value.push({
|
||||
id: buildLogId(),
|
||||
type,
|
||||
time: new Date().toLocaleTimeString('zh-CN', { hour12: false }),
|
||||
message
|
||||
})
|
||||
}
|
||||
|
||||
const handleLog = (payload: { type: ReportTaskLogType; message: string }) => {
|
||||
pushLog(payload.type, payload.message)
|
||||
}
|
||||
|
||||
const resolveCurrentOptionLabel = (options: Array<{ label: string; value: string }>, value: string) =>
|
||||
options.find(option => option.value === value)?.label || value || '-'
|
||||
|
||||
const resolveLogTagType = (type: ReportTaskLogType) => {
|
||||
if (type === 'success') return 'success'
|
||||
if (type === 'warning') return 'warning'
|
||||
if (type === 'error') return 'danger'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
const resolveLogTypeText = (type: ReportTaskLogType) => {
|
||||
if (type === 'success') return '成功'
|
||||
if (type === 'warning') return '警告'
|
||||
if (type === 'error') return '错误'
|
||||
return '信息'
|
||||
}
|
||||
|
||||
const resetForm = () => {
|
||||
formRef.value?.clearValidate()
|
||||
formModel.id = ''
|
||||
@@ -201,35 +390,167 @@ const resetForm = () => {
|
||||
formModel.standardIds = []
|
||||
formModel.data = ''
|
||||
formModel.phonenumber = ''
|
||||
activeDraftId.value = ''
|
||||
currentStep.value = 'import'
|
||||
logPanelExpanded.value = true
|
||||
logEntries.value = []
|
||||
ledgerPreparedState.value = {
|
||||
draftId: '',
|
||||
batchId: '',
|
||||
latestImportResult: null,
|
||||
snapshot: null,
|
||||
hasImported: false,
|
||||
pendingReimport: false
|
||||
}
|
||||
}
|
||||
|
||||
const fillForm = () => {
|
||||
formModel.id = props.record?.id || ''
|
||||
formModel.no = props.record?.no || ''
|
||||
formModel.clientUnitId = props.record?.clientUnitId || ''
|
||||
formModel.reportModelId = props.record?.reportModelId || ''
|
||||
formModel.createUnit = props.record?.createUnit || ''
|
||||
formModel.contractNumber = props.record?.contractNumber || ''
|
||||
formModel.standardIds = parseReportTaskStandardIds(props.record?.standard)
|
||||
formModel.data = props.record?.data || ''
|
||||
formModel.phonenumber = props.record?.phonenumber || ''
|
||||
const buildDraftId = () => {
|
||||
if (props.mode === 'edit') {
|
||||
return String(props.record?.id || '').trim()
|
||||
}
|
||||
|
||||
return window.crypto?.randomUUID?.() || generateUUID()
|
||||
}
|
||||
|
||||
const applyInitialStep = (hasPreparedLedger: boolean) => {
|
||||
if (props.mode === 'edit' && hasPreparedLedger) {
|
||||
currentStep.value = 'form'
|
||||
pushLog('info', '编辑场景检测到已有导入结果,默认进入基础信息填写步骤')
|
||||
return
|
||||
}
|
||||
|
||||
currentStep.value = 'import'
|
||||
pushLog('info', '已进入数据导入步骤,请先完成台账校验')
|
||||
}
|
||||
|
||||
const fillForm = async () => {
|
||||
try {
|
||||
const record = props.record
|
||||
const snapshot = normalizeReportTaskLedgerSnapshot(record?.data)
|
||||
|
||||
formModel.id = record?.id || ''
|
||||
formModel.no = record?.no || ''
|
||||
formModel.clientUnitId = record?.clientUnitId || ''
|
||||
formModel.reportModelId = record?.reportModelId || ''
|
||||
formModel.createUnit = record?.createUnit || ''
|
||||
formModel.contractNumber = record?.contractNumber || ''
|
||||
formModel.standardIds = parseReportTaskStandardIds(record?.standard)
|
||||
formModel.data = record?.data || ''
|
||||
formModel.phonenumber = record?.phonenumber || ''
|
||||
|
||||
activeDraftId.value = buildDraftId()
|
||||
ledgerPreparedState.value = {
|
||||
draftId: activeDraftId.value,
|
||||
batchId: '',
|
||||
latestImportResult: null,
|
||||
snapshot,
|
||||
hasImported: Boolean(snapshot || Number(record?.pointCount) > 0),
|
||||
pendingReimport: false
|
||||
}
|
||||
|
||||
applyInitialStep(Boolean(snapshot || Number(record?.pointCount) > 0))
|
||||
if (snapshot) {
|
||||
pushLog('info', `已加载最近一次导入快照:${snapshot.summaryFileName || '未命名汇总文件'}`)
|
||||
}
|
||||
} catch (error) {
|
||||
const message = getReportTaskErrorMessage(error, '报告任务台账快照加载失败')
|
||||
ElMessage.error(message)
|
||||
pushLog('error', message)
|
||||
}
|
||||
}
|
||||
|
||||
const goToFormStep = () => {
|
||||
if (!canSubmit.value) {
|
||||
pushLog('warning', '当前校验尚未完成,不能进入基础信息填写步骤')
|
||||
return
|
||||
}
|
||||
|
||||
currentStep.value = 'form'
|
||||
pushLog('info', '已切换到基础信息填写步骤')
|
||||
}
|
||||
|
||||
const goToImportStep = () => {
|
||||
currentStep.value = 'import'
|
||||
pushLog('info', '已返回数据导入步骤,可继续沿用当前结果或重新校验台账')
|
||||
}
|
||||
|
||||
const handleLedgerPreparedChange = (value: ReportTask.ReportTaskLedgerPreparedState) => {
|
||||
const wasPrepared = checkReportTaskLedgerPrepared(ledgerPreparedState.value)
|
||||
const nextState = {
|
||||
...value,
|
||||
draftId: activeDraftId.value
|
||||
}
|
||||
|
||||
ledgerPreparedState.value = nextState
|
||||
|
||||
if (!wasPrepared && checkReportTaskLedgerPrepared(nextState) && currentStep.value === 'import') {
|
||||
currentStep.value = 'form'
|
||||
pushLog('success', '台账校验已完成,已自动进入基础信息填写步骤')
|
||||
}
|
||||
}
|
||||
|
||||
const canSwitchStep = (step: ReportTaskFormStep) => {
|
||||
if (step === 'import') return true
|
||||
if (step === 'form') return canSubmit.value || currentStep.value === 'form' || currentStep.value === 'done'
|
||||
return currentStep.value === 'done'
|
||||
}
|
||||
|
||||
const handleStepClick = (step: ReportTaskFormStep) => {
|
||||
if (!canSwitchStep(step)) return
|
||||
if (step === 'import') {
|
||||
goToImportStep()
|
||||
return
|
||||
}
|
||||
if (step === 'form') {
|
||||
goToFormStep()
|
||||
}
|
||||
}
|
||||
|
||||
const resolveStepStatus = (step: ReportTaskFormStep) => {
|
||||
if (currentStep.value === step) return 'active'
|
||||
if (step === 'import' && (currentStep.value === 'form' || currentStep.value === 'done')) return 'done'
|
||||
if (step === 'form' && currentStep.value === 'done') return 'done'
|
||||
return 'pending'
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.visible, props.mode, props.record?.id],
|
||||
([visible]) => {
|
||||
if (visible) fillForm()
|
||||
async ([visible]) => {
|
||||
if (!visible) return
|
||||
resetForm()
|
||||
await fillForm()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.saveSuccessVersion,
|
||||
value => {
|
||||
if (!props.visible || !value || value === lastHandledSaveSuccessVersion.value) return
|
||||
|
||||
lastHandledSaveSuccessVersion.value = value
|
||||
currentStep.value = 'done'
|
||||
pushLog('success', props.mode === 'create' ? '报告任务新增成功,流程已完成' : '报告任务编辑成功,流程已完成')
|
||||
}
|
||||
)
|
||||
|
||||
const submitForm = async () => {
|
||||
const valid = await formRef.value?.validate().catch(() => false)
|
||||
if (!valid) {
|
||||
pushLog('warning', '基础信息校验未通过,请检查必填项')
|
||||
return
|
||||
}
|
||||
|
||||
if (!valid) return
|
||||
if (!checkReportTaskLedgerPrepared(ledgerPreparedState.value)) {
|
||||
const message = '请先完成台账校验后再提交基础信息'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
return
|
||||
}
|
||||
|
||||
pushLog('info', props.mode === 'create' ? '开始提交新增任务基础信息并写入台账数据' : '开始提交编辑后的任务基础信息并更新台账数据')
|
||||
emit('submit', {
|
||||
id: formModel.id || undefined,
|
||||
id: activeDraftId.value || formModel.id || undefined,
|
||||
no: formModel.no.trim(),
|
||||
clientUnitId: formModel.clientUnitId,
|
||||
reportModelId: formModel.reportModelId,
|
||||
@@ -237,34 +558,339 @@ const submitForm = async () => {
|
||||
contractNumber: formModel.contractNumber.trim(),
|
||||
standard: stringifyReportTaskStandardIds(formModel.standardIds),
|
||||
data: formModel.data.trim(),
|
||||
batchId: ledgerPreparedState.value.batchId || undefined,
|
||||
phonenumber: formModel.phonenumber.trim() || undefined
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
:deep(.report-task-form .el-form-item) {
|
||||
margin-bottom: 18px;
|
||||
.report-task-form-dialog {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.flow-nav {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 0;
|
||||
padding: 22px 18px 18px;
|
||||
border: 1px solid #d9ebe7;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.flow-step {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0 12px 18px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
text-align: center;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.flow-step::before,
|
||||
.flow-step::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
width: calc(50% - 18px);
|
||||
height: 1px;
|
||||
background: #cfd5df;
|
||||
}
|
||||
|
||||
.flow-step::before {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.flow-step::after {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.flow-step:first-child::before,
|
||||
.flow-step:last-child::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.flow-step.is-clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.flow-step:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.flow-step.is-active .flow-step-title,
|
||||
.flow-step.is-active .flow-step-desc {
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
.flow-step.is-done .flow-step-index {
|
||||
border-color: var(--el-color-success);
|
||||
background: rgba(103, 194, 58, 0.1);
|
||||
color: var(--el-color-success);
|
||||
}
|
||||
|
||||
.flow-step.is-done::after,
|
||||
.flow-step.is-done + .flow-step::before {
|
||||
background: rgba(103, 194, 58, 0.45);
|
||||
}
|
||||
|
||||
.flow-step-index {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border: 2px solid #b8bec9;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
color: #a9b0bb;
|
||||
flex-shrink: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.flow-step.is-active .flow-step-index {
|
||||
border-color: #67c23a;
|
||||
background: rgba(103, 194, 58, 0.1);
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
.flow-step-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.flow-step-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
color: #a9b0bb;
|
||||
}
|
||||
|
||||
.flow-step-desc {
|
||||
font-size: 12px;
|
||||
line-height: 1.25;
|
||||
color: #b9bfc9;
|
||||
}
|
||||
|
||||
.flow-main {
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
padding-bottom: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.flow-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.form-panel {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
padding: 18px;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
|
||||
.summary-strip {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.summary-item {
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.complete-panel {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
padding: 18px;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
|
||||
.log-panel {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
background: var(--el-fill-color-blank);
|
||||
overflow: hidden;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.log-panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
padding: 0 16px;
|
||||
border: none;
|
||||
background: linear-gradient(180deg, #eef3ff 0%, #e6ecff 100%);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.log-panel-toggle {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin-right: 10px;
|
||||
border-right: 2px solid #2f4fb7;
|
||||
border-bottom: 2px solid #2f4fb7;
|
||||
transform: rotate(45deg);
|
||||
transition: transform 0.2s ease;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.log-panel-toggle.is-collapsed {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.log-title {
|
||||
flex: 1;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #2f4fb7;
|
||||
text-align: center;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.log-panel-body {
|
||||
border-top: 1px solid #d9e3ff;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.log-popover-body {
|
||||
max-height: 160px;
|
||||
overflow: auto;
|
||||
padding: 0;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.log-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.log-item {
|
||||
display: grid;
|
||||
grid-template-columns: 180px minmax(0, 1fr);
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.log-item:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.log-meta,
|
||||
.log-message {
|
||||
padding: 10px 14px;
|
||||
}
|
||||
|
||||
.log-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
border-right: 1px solid var(--el-border-color-lighter);
|
||||
background: #f6f8ff;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.log-time {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.log-message {
|
||||
font-size: 13px;
|
||||
line-height: 1.3;
|
||||
color: var(--el-text-color-primary);
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.log-empty {
|
||||
padding: 18px 0;
|
||||
}
|
||||
|
||||
:deep(.report-task-flow-dialog .el-dialog__body) {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-select),
|
||||
:deep(.el-textarea),
|
||||
:deep(.el-input) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.standard-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.flow-nav,
|
||||
.summary-strip {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.standard-option-checkbox {
|
||||
pointer-events: none;
|
||||
}
|
||||
.flow-nav {
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.flow-step {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.flow-step::before,
|
||||
.flow-step::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.flow-step-content {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.log-panel-header {
|
||||
padding: 0 14px;
|
||||
}
|
||||
|
||||
.log-item {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.log-meta {
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.standard-option-label {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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>
|
||||
@@ -0,0 +1,434 @@
|
||||
<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, validateReportTaskLedgerApi } 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({
|
||||
batchId: '',
|
||||
pendingReimport: true
|
||||
})
|
||||
pushLog('warning', '已更换导入文件,需重新执行台账校验后才能继续保存')
|
||||
}
|
||||
}
|
||||
|
||||
const handleFileRemove = (_file: UploadFile, files: UploadFiles) => {
|
||||
selectedFiles.value = [...files]
|
||||
pushLog('info', `已更新待导入文件列表,当前剩余 ${selectedFiles.value.length} 个文件`)
|
||||
|
||||
if (props.preparedState.hasImported) {
|
||||
updatePreparedState({
|
||||
batchId: '',
|
||||
pendingReimport: true
|
||||
})
|
||||
pushLog('warning', '导入文件已发生变化,之前的导入结果已标记为失效')
|
||||
}
|
||||
}
|
||||
|
||||
const removeSelectedFile = (index: number) => {
|
||||
selectedFiles.value.splice(index, 1)
|
||||
pushLog('info', `已删除第 ${index + 1} 个待导入文件`)
|
||||
|
||||
if (props.preparedState.hasImported) {
|
||||
updatePreparedState({
|
||||
batchId: '',
|
||||
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 {
|
||||
const response = await validateReportTaskLedgerApi(props.draftId, formData)
|
||||
const normalizedResult = normalizeReportTaskLedgerImportResult(response)
|
||||
|
||||
latestImportResult.value = normalizedResult
|
||||
updatePreparedState({
|
||||
batchId: normalizedResult.batchId || '',
|
||||
latestImportResult: normalizedResult,
|
||||
hasImported: Boolean(normalizedResult.success),
|
||||
pendingReimport: false
|
||||
})
|
||||
|
||||
if (
|
||||
!checkReportTaskLedgerPrepared({
|
||||
...props.preparedState,
|
||||
batchId: normalizedResult.batchId || '',
|
||||
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) {
|
||||
updatePreparedState({
|
||||
batchId: '',
|
||||
hasImported: false
|
||||
})
|
||||
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')
|
||||
@@ -27,53 +27,80 @@ assertFileIncludes(path.join(apiDir, 'index.ts'), [
|
||||
'deleteReportTasksApi',
|
||||
'getReportTaskDetailApi',
|
||||
'exportReportTasksApi',
|
||||
'submitReportTaskAuditApi'
|
||||
'submitReportTaskAuditApi',
|
||||
'downloadReportTaskLedgerTemplateApi',
|
||||
'importReportTaskLedgerApi',
|
||||
'listReportTaskGroupReportsApi'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(apiDir, 'interface/index.ts'), [
|
||||
'export namespace ReportTask',
|
||||
'ReportTaskRecord',
|
||||
'ReportTaskListParams',
|
||||
'ReportTaskAddParam',
|
||||
'ReportTaskSaveRequest',
|
||||
'ReportTaskAuditRequest',
|
||||
'standard?: string[] | string | null',
|
||||
'standard: string[]'
|
||||
'ReportTaskLedgerImportResult',
|
||||
'ReportTaskLedgerImportStageRecord',
|
||||
'ReportTaskLedgerImportSnapshot',
|
||||
'ReportTaskGroupReportRecord',
|
||||
'ReportTaskLedgerPreparedState'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'utils/testReport.ts'), [
|
||||
'normalizeReportTaskListParams',
|
||||
'normalizeReportTaskPage',
|
||||
'parseReportTaskStandardIds',
|
||||
'stringifyReportTaskStandardIds',
|
||||
'resolveReportTaskStandardText',
|
||||
'buildDictSelectOptions',
|
||||
'value?: string[] | string | null',
|
||||
"return text ? [text] : []"
|
||||
'TEST_REPORT_EXCEL_EXTENSIONS',
|
||||
'REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP',
|
||||
'isReportTaskExcelFileName',
|
||||
'TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER',
|
||||
'normalizeReportTaskLedgerImportResult',
|
||||
'normalizeReportTaskLedgerSnapshot',
|
||||
'checkReportTaskLedgerPrepared',
|
||||
'resolveReportTaskGroupReportGenerateStateText',
|
||||
'resolveReportTaskGroupReportGenerateStateTagType'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskLedgerImportPanel.vue'), [
|
||||
"name: 'ReportTaskLedgerImportPanel'",
|
||||
'downloadReportTaskLedgerTemplateApi',
|
||||
'importReportTaskLedgerApi',
|
||||
'selectedFiles',
|
||||
'latestImportResult',
|
||||
'handleImportFiles',
|
||||
'toolbar-actions',
|
||||
'toolbar-download'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskFormDialog.vue'), [
|
||||
"name: 'ReportTaskFormDialog'",
|
||||
'clientUnitId',
|
||||
'reportModelId',
|
||||
'createUnit',
|
||||
'standardIds',
|
||||
'stringifyReportTaskStandardIds',
|
||||
'el-checkbox',
|
||||
'standard-option-checkbox'
|
||||
'ReportTaskLedgerImportPanel',
|
||||
'REPORT_TASK_FORM_STEPS',
|
||||
'currentStep',
|
||||
'logEntries',
|
||||
'logPanelExpanded',
|
||||
'goToImportStep',
|
||||
'handleLedgerPreparedChange',
|
||||
'ledgerPreparedState',
|
||||
'activeDraftId',
|
||||
'checkReportTaskLedgerPrepared',
|
||||
'log-panel-header',
|
||||
'log-panel-body',
|
||||
'log-panel-toggle',
|
||||
'white-space: nowrap',
|
||||
'text-overflow: ellipsis',
|
||||
'log-empty'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskDetailDialog.vue'), [
|
||||
"name: 'ReportTaskDetailDialog'",
|
||||
'报告任务详情',
|
||||
'resolveReportTaskCreateUnitText',
|
||||
'resolveReportTaskStandardText',
|
||||
'table-layout: fixed'
|
||||
'groupReports',
|
||||
'generateState',
|
||||
'group-report-title',
|
||||
'resolveReportTaskGroupReportGenerateStateText'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskAuditDialog.vue'), [
|
||||
"name: 'ReportTaskAuditDialog'",
|
||||
'checkResult',
|
||||
'提交审核'
|
||||
'checkResult'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'index.vue'), [
|
||||
@@ -82,14 +109,16 @@ assertFileIncludes(path.join(pageDir, 'index.vue'), [
|
||||
'ReportTaskFormDialog',
|
||||
'ReportTaskDetailDialog',
|
||||
'ReportTaskAuditDialog',
|
||||
'listReportTasksApi',
|
||||
'submitReportTaskAuditApi',
|
||||
'exportReportTasksApi',
|
||||
'DICT_CODES.TEST_REPORT_COMPANY',
|
||||
'DICT_CODES.TEST_REPORT_STANDARD',
|
||||
'type="primary" :icon="Plus"',
|
||||
'type="danger"',
|
||||
'type="primary" plain'
|
||||
'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')
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
:mode="formMode"
|
||||
:record="currentRecord"
|
||||
:saving="formSaving"
|
||||
:save-success-version="formSaveSuccessVersion"
|
||||
:client-unit-options="clientUnitOptions"
|
||||
:report-model-options="reportModelOptions"
|
||||
:company-options="companyOptions"
|
||||
@@ -46,6 +47,7 @@
|
||||
v-model:visible="detailDialogVisible"
|
||||
:loading="detailLoading"
|
||||
:detail="detailRecord"
|
||||
:group-reports="detailGroupReports"
|
||||
:company-label-map="companyLabelMap"
|
||||
:standard-label-map="standardLabelMap"
|
||||
/>
|
||||
@@ -67,12 +69,13 @@ import type { Dict, ResPage } from '@/api/interface'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||
import {
|
||||
createReportTaskApi,
|
||||
deleteReportTasksApi,
|
||||
exportReportTasksApi,
|
||||
getReportTaskDetailApi,
|
||||
listReportTaskGroupReportsApi,
|
||||
listReportTasksApi,
|
||||
submitReportTaskAuditApi,
|
||||
createReportTaskApi,
|
||||
updateReportTaskApi
|
||||
} from '@/api/aireport/testReport'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
@@ -89,6 +92,7 @@ import {
|
||||
buildDictSelectOptions,
|
||||
buildOptionLabelMap,
|
||||
getReportTaskErrorMessage,
|
||||
normalizeReportTaskGroupReportList,
|
||||
normalizeReportTaskListParams,
|
||||
normalizeReportTaskPage,
|
||||
resolveReportTaskCreateUnitText,
|
||||
@@ -107,11 +111,13 @@ const formDialogVisible = ref(false)
|
||||
const detailDialogVisible = ref(false)
|
||||
const auditDialogVisible = ref(false)
|
||||
const formSaving = ref(false)
|
||||
const formSaveSuccessVersion = ref(0)
|
||||
const detailLoading = ref(false)
|
||||
const auditSaving = ref(false)
|
||||
const formMode = ref<'create' | 'edit'>('create')
|
||||
const currentRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
||||
const detailRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
||||
const detailGroupReports = ref<ReportTask.ReportTaskGroupReportRecord[]>([])
|
||||
const currentAuditRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
||||
const clientUnitOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
const reportModelOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
@@ -175,6 +181,8 @@ const columns = reactive<ColumnProps<ReportTask.ReportTaskRecord>[]>([
|
||||
showOverflowTooltip: true,
|
||||
render: ({ row }) => resolveReportTaskStandardText(row.standard, standardLabelMap.value)
|
||||
},
|
||||
{ prop: 'pointCount', label: '监测点数', minWidth: 100, render: ({ row }) => resolveReportTaskText(row.pointCount) },
|
||||
{ prop: 'groupCount', label: '分组数', minWidth: 100, render: ({ row }) => resolveReportTaskText(row.groupCount) },
|
||||
{ prop: 'phonenumber', label: '联系电话', minWidth: 140, render: ({ row }) => resolveReportTaskText(row.phonenumber) },
|
||||
{ prop: 'checkerName', label: '审核人', minWidth: 120, render: ({ row }) => resolveReportTaskText(row.checkerName) },
|
||||
{ prop: 'checkTime', label: '审核时间', minWidth: 120, render: ({ row }) => resolveReportTaskText(row.checkTime) },
|
||||
@@ -201,7 +209,7 @@ const ensureReportTaskDictOptionsReady = async () => {
|
||||
}
|
||||
})
|
||||
|
||||
// 关键业务节点:检测公司和测试依据展示依赖字典缓存,需要在页面缺失时补载后再做 ID 到名称映射。
|
||||
// 关键业务节点:检测公司和测试依据展示依赖字典缓存,缺失时必须先补齐再做 ID 到名称映射。
|
||||
dictStore.setDictData(Array.from(nextDictMap.values()))
|
||||
}
|
||||
|
||||
@@ -280,7 +288,7 @@ const openEditDialog = async (row: ReportTask.ReportTaskRecord) => {
|
||||
formMode.value = 'edit'
|
||||
|
||||
try {
|
||||
// 关键业务节点:编辑表单提交时依赖 clientUnitId、reportModelId、createUnit、standard 等原始值,不能只用列表展示字段回填。
|
||||
// 关键业务节点:编辑表单提交仍依赖原始 clientUnitId、reportModelId、createUnit、standard 等字段,不能只回填列表展示文本。
|
||||
const response = await getReportTaskDetailApi(row.id)
|
||||
currentRecord.value = unwrapReportTaskPayload<ReportTask.ReportTaskRecord>(response)
|
||||
formDialogVisible.value = true
|
||||
@@ -296,12 +304,18 @@ const openDetailDialog = async (row: ReportTask.ReportTaskRecord) => {
|
||||
}
|
||||
|
||||
detailRecord.value = null
|
||||
detailGroupReports.value = []
|
||||
detailDialogVisible.value = true
|
||||
detailLoading.value = true
|
||||
|
||||
try {
|
||||
const response = await getReportTaskDetailApi(row.id)
|
||||
detailRecord.value = unwrapReportTaskPayload<ReportTask.ReportTaskRecord>(response)
|
||||
const [detailResponse, groupReportsResponse] = await Promise.all([
|
||||
getReportTaskDetailApi(row.id),
|
||||
listReportTaskGroupReportsApi(row.id)
|
||||
])
|
||||
|
||||
detailRecord.value = unwrapReportTaskPayload<ReportTask.ReportTaskRecord>(detailResponse)
|
||||
detailGroupReports.value = normalizeReportTaskGroupReportList(groupReportsResponse)
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务详情查询失败'))
|
||||
} finally {
|
||||
@@ -325,13 +339,12 @@ const handleSaveReportTask = async (params: ReportTask.ReportTaskSaveRequest) =>
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
await createReportTaskApi(params)
|
||||
ElMessage.success('报告任务新增成功')
|
||||
} else {
|
||||
await updateReportTaskApi(params)
|
||||
ElMessage.success('报告任务编辑成功')
|
||||
}
|
||||
|
||||
formDialogVisible.value = false
|
||||
ElMessage.success(formMode.value === 'create' ? '报告任务新增成功' : '报告任务编辑成功')
|
||||
formSaveSuccessVersion.value += 1
|
||||
refreshReportTasks()
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务保存失败'))
|
||||
@@ -400,11 +413,12 @@ const handleExport = async () => {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务导出失败'))
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await ensureReportTaskDictOptionsReady()
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '鎶ュ憡浠诲姟瀛楀吀鍔犺浇澶辫触'))
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务字典加载失败'))
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -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,6 +1,54 @@
|
||||
import type { TagProps } from 'element-plus'
|
||||
import type { Dict, ResultData, ResPage } from '@/api/interface'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
|
||||
type TagType = TagProps['type']
|
||||
|
||||
export const TEST_REPORT_EXCEL_EXTENSIONS = ['.xls', '.xlsx']
|
||||
export const TEST_REPORT_WORD_EXTENSIONS = ['.doc', '.docx']
|
||||
export const TEST_REPORT_LEDGER_SUMMARY_FILE_BASE_NAME = '台账信息汇总'
|
||||
export const TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER: ReportTask.ReportTaskLedgerImportStage[] = [
|
||||
'选择文件',
|
||||
'校验文件',
|
||||
'文件导入',
|
||||
'基础资料维护',
|
||||
'完成'
|
||||
]
|
||||
export const REPORT_TASK_STATE_MAP: Record<ReportTask.ReportTaskState, { text: string; tagType: TagType }> = {
|
||||
'01': { text: '编制中', tagType: 'info' },
|
||||
'02': { text: '审核中', tagType: 'warning' },
|
||||
'03': { text: '已通过', tagType: 'success' },
|
||||
'04': { text: '已退回', tagType: 'danger' },
|
||||
'05': { text: '已删除', tagType: 'info' }
|
||||
}
|
||||
export const REPORT_TASK_STATE_OPTIONS: Array<{ label: string; value: ReportTask.ReportTaskState }> = [
|
||||
{ label: '编制中', value: '01' },
|
||||
{ label: '审核中', value: '02' },
|
||||
{ label: '已通过', value: '03' },
|
||||
{ label: '已退回', value: '04' },
|
||||
{ label: '已删除', value: '05' }
|
||||
]
|
||||
export const REPORT_TASK_GENERATE_STATE_MAP: Record<ReportTask.ReportTaskGenerateState, { text: string; tagType: TagType }> = {
|
||||
0: { text: '未生成', tagType: 'info' },
|
||||
1: { text: '生成中', tagType: 'warning' },
|
||||
2: { text: '已生成', tagType: 'success' }
|
||||
}
|
||||
export const REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP: Record<number, string> = {
|
||||
0: '未生成',
|
||||
1: '生成中',
|
||||
2: '生成成功',
|
||||
3: '生成失败'
|
||||
}
|
||||
export const REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TAG_TYPE_MAP: Record<
|
||||
number,
|
||||
'warning' | 'success' | 'danger' | undefined
|
||||
> = {
|
||||
0: undefined,
|
||||
1: 'warning',
|
||||
2: 'success',
|
||||
3: 'danger'
|
||||
}
|
||||
|
||||
export const resolveReportTaskText = (value: unknown) => {
|
||||
if (value === null || value === undefined) return '-'
|
||||
|
||||
@@ -18,6 +66,7 @@ export const normalizeReportTaskListParams = (
|
||||
keyword: String(params.keyword || '').trim() || undefined,
|
||||
searchBeginTime: searchBeginTime || params.searchBeginTime || undefined,
|
||||
searchEndTime: searchEndTime || params.searchEndTime || undefined,
|
||||
state: params.state || undefined,
|
||||
pageNum: params.pageNum || 1,
|
||||
pageSize: params.pageSize || 10
|
||||
}
|
||||
@@ -53,6 +102,216 @@ export const getReportTaskErrorMessage = (error: unknown, fallback: string) => {
|
||||
return fallback
|
||||
}
|
||||
|
||||
export const isReportTaskExcelFileName = (fileName: string) => {
|
||||
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||
return TEST_REPORT_EXCEL_EXTENSIONS.some(extension => normalizedName.endsWith(extension))
|
||||
}
|
||||
|
||||
export const isReportTaskWordFileName = (fileName: string) => {
|
||||
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||
return TEST_REPORT_WORD_EXTENSIONS.some(extension => normalizedName.endsWith(extension))
|
||||
}
|
||||
|
||||
export const isReportTaskLedgerSummaryFileName = (fileName: string) => {
|
||||
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||
return normalizedName.includes(TEST_REPORT_LEDGER_SUMMARY_FILE_BASE_NAME.toLowerCase()) && isReportTaskExcelFileName(normalizedName)
|
||||
}
|
||||
|
||||
export const isReportTaskLedgerAttachmentFileName = (fileName: string) =>
|
||||
isReportTaskExcelFileName(fileName) || isReportTaskWordFileName(fileName)
|
||||
|
||||
export const normalizeReportTaskPointList = (
|
||||
response: ResultData<ReportTask.ReportTaskPointRecord[]> | ReportTask.ReportTaskPointRecord[] | null | undefined
|
||||
) => {
|
||||
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskPointRecord[] | null | undefined>(
|
||||
response as ResultData<ReportTask.ReportTaskPointRecord[]>
|
||||
)
|
||||
|
||||
return Array.isArray(payload) ? payload : []
|
||||
}
|
||||
|
||||
export const normalizeReportTaskLedgerImportResult = (
|
||||
response:
|
||||
| ResultData<ReportTask.ReportTaskLedgerImportResult>
|
||||
| ReportTask.ReportTaskLedgerImportResult
|
||||
| null
|
||||
| undefined
|
||||
): ReportTask.ReportTaskLedgerImportResult => {
|
||||
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskLedgerImportResult | null | undefined>(
|
||||
response as ResultData<ReportTask.ReportTaskLedgerImportResult>
|
||||
)
|
||||
|
||||
const stageList = Array.isArray(payload?.stages) ? payload.stages : []
|
||||
|
||||
return {
|
||||
batchId: payload?.batchId || undefined,
|
||||
currentStage: payload?.currentStage || undefined,
|
||||
success: payload?.success ?? false,
|
||||
summaryFileName: payload?.summaryFileName || undefined,
|
||||
tempStoragePath: payload?.tempStoragePath || undefined,
|
||||
totalFileCount: payload?.totalFileCount ?? 0,
|
||||
uploadedFileCount: payload?.uploadedFileCount ?? 0,
|
||||
pointCount: payload?.pointCount ?? 0,
|
||||
excelAttachmentCount: payload?.excelAttachmentCount ?? 0,
|
||||
wordAttachmentCount: payload?.wordAttachmentCount ?? 0,
|
||||
deviceAddedCount: payload?.deviceAddedCount ?? 0,
|
||||
deviceReuseCount: payload?.deviceReuseCount ?? 0,
|
||||
clientAddedCount: payload?.clientAddedCount ?? 0,
|
||||
clientReuseCount: payload?.clientReuseCount ?? 0,
|
||||
groupCount: payload?.groupCount ?? 0,
|
||||
failReasons: Array.isArray(payload?.failReasons) ? payload.failReasons.filter(Boolean) : [],
|
||||
stages: stageList.map(stage => ({
|
||||
stage: stage?.stage || undefined,
|
||||
success: stage?.success ?? false,
|
||||
message: stage?.message || ''
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
export const normalizeReportTaskLedgerValidateResult = (
|
||||
response:
|
||||
| ResultData<ReportTask.ReportTaskLedgerValidateResult>
|
||||
| ReportTask.ReportTaskLedgerValidateResult
|
||||
| null
|
||||
| undefined
|
||||
): ReportTask.ReportTaskLedgerValidateResult => {
|
||||
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskLedgerValidateResult | null | undefined>(
|
||||
response as ResultData<ReportTask.ReportTaskLedgerValidateResult>
|
||||
)
|
||||
|
||||
return {
|
||||
sessionId: payload?.sessionId || undefined,
|
||||
batchId: payload?.batchId || undefined,
|
||||
success: payload?.success ?? false,
|
||||
summaryFileName: payload?.summaryFileName || undefined,
|
||||
summaryFilePresent: payload?.summaryFilePresent ?? false,
|
||||
tempStoragePath: payload?.tempStoragePath || undefined,
|
||||
uploadedFileCount: payload?.uploadedFileCount ?? 0,
|
||||
pointCount: payload?.pointCount ?? 0,
|
||||
missingAttachmentCount: payload?.missingAttachmentCount ?? 0,
|
||||
canContinueUpload: payload?.canContinueUpload ?? false,
|
||||
requiredSheets: Array.isArray(payload?.requiredSheets) ? payload.requiredSheets.filter(Boolean) : [],
|
||||
existingSheets: Array.isArray(payload?.existingSheets) ? payload.existingSheets.filter(Boolean) : [],
|
||||
missingSheets: Array.isArray(payload?.missingSheets) ? payload.missingSheets.filter(Boolean) : [],
|
||||
orphanAttachmentNames: Array.isArray(payload?.orphanAttachmentNames) ? payload.orphanAttachmentNames.filter(Boolean) : [],
|
||||
failReasons: Array.isArray(payload?.failReasons) ? payload.failReasons.filter(Boolean) : [],
|
||||
points: Array.isArray(payload?.points)
|
||||
? payload.points.map(point => ({
|
||||
rowNo: point?.rowNo ?? null,
|
||||
pointKey: point?.pointKey || undefined,
|
||||
substationName: point?.substationName || undefined,
|
||||
pointName: point?.pointName || undefined,
|
||||
complete: point?.complete ?? false,
|
||||
missingAttachmentCount: point?.missingAttachmentCount ?? 0,
|
||||
testDeviceNoValid: point?.testDeviceNoValid ?? false,
|
||||
testDeviceNoMessage: point?.testDeviceNoMessage || undefined,
|
||||
clientUnitNameValid: point?.clientUnitNameValid ?? false,
|
||||
clientUnitNameMessage: point?.clientUnitNameMessage || undefined,
|
||||
attachments: Array.isArray(point?.attachments)
|
||||
? point.attachments.map(attachment => ({
|
||||
attachmentName: attachment?.attachmentName || undefined,
|
||||
attachmentType: attachment?.attachmentType || undefined,
|
||||
referenced: attachment?.referenced ?? false,
|
||||
uploaded: attachment?.uploaded ?? false,
|
||||
missing: attachment?.missing ?? false,
|
||||
reuploadAllowed: attachment?.reuploadAllowed ?? false,
|
||||
message: attachment?.message || undefined
|
||||
}))
|
||||
: []
|
||||
}))
|
||||
: []
|
||||
}
|
||||
}
|
||||
|
||||
export const normalizeReportTaskGroupReportList = (
|
||||
response:
|
||||
| ResultData<ReportTask.ReportTaskGroupReportRecord[]>
|
||||
| ReportTask.ReportTaskGroupReportRecord[]
|
||||
| null
|
||||
| undefined
|
||||
) => {
|
||||
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskGroupReportRecord[] | null | undefined>(
|
||||
response as ResultData<ReportTask.ReportTaskGroupReportRecord[]>
|
||||
)
|
||||
|
||||
return Array.isArray(payload) ? payload : []
|
||||
}
|
||||
|
||||
export const normalizeReportTaskLedgerSnapshot = (
|
||||
value: string | ReportTask.ReportTaskLedgerImportSnapshot | null | undefined
|
||||
): ReportTask.ReportTaskLedgerImportSnapshot | null => {
|
||||
if (!value) return null
|
||||
|
||||
const snapshot =
|
||||
typeof value === 'string'
|
||||
? (() => {
|
||||
try {
|
||||
return JSON.parse(value) as ReportTask.ReportTaskLedgerImportSnapshot
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
})()
|
||||
: value
|
||||
|
||||
if (!snapshot || typeof snapshot !== 'object') return null
|
||||
|
||||
return {
|
||||
version: snapshot.version || undefined,
|
||||
importMode: snapshot.importMode || undefined,
|
||||
summaryFileName: snapshot.summaryFileName || undefined,
|
||||
sheetSummary: snapshot.sheetSummary
|
||||
? {
|
||||
pointSheet: snapshot.sheetSummary.pointSheet || undefined,
|
||||
deviceSheetPresent: snapshot.sheetSummary.deviceSheetPresent ?? false,
|
||||
clientSheetPresent: snapshot.sheetSummary.clientSheetPresent ?? false
|
||||
}
|
||||
: null,
|
||||
rowCount: snapshot.rowCount ?? 0,
|
||||
groupSummary: Array.isArray(snapshot.groupSummary)
|
||||
? snapshot.groupSummary.map(item => ({
|
||||
groupNo: item?.groupNo ?? null,
|
||||
count: item?.count ?? 0
|
||||
}))
|
||||
: [],
|
||||
baseDataSummary: snapshot.baseDataSummary
|
||||
? {
|
||||
deviceAddedCount: snapshot.baseDataSummary.deviceAddedCount ?? 0,
|
||||
deviceReuseCount: snapshot.baseDataSummary.deviceReuseCount ?? 0,
|
||||
clientAddedCount: snapshot.baseDataSummary.clientAddedCount ?? 0,
|
||||
clientReuseCount: snapshot.baseDataSummary.clientReuseCount ?? 0
|
||||
}
|
||||
: null
|
||||
}
|
||||
}
|
||||
|
||||
export const resolveReportTaskGroupReportGenerateStateText = (value: number | null | undefined) => {
|
||||
if (value === null || value === undefined) return '-'
|
||||
|
||||
return REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP[value] || String(value)
|
||||
}
|
||||
|
||||
export const resolveReportTaskGroupReportGenerateStateTagType = (value: number | null | undefined) => {
|
||||
if (value === null || value === undefined) return undefined
|
||||
|
||||
return REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TAG_TYPE_MAP[value]
|
||||
}
|
||||
|
||||
export const getReportTaskStateText = (state?: string | null) =>
|
||||
REPORT_TASK_STATE_MAP[state as ReportTask.ReportTaskState]?.text || '未知状态'
|
||||
|
||||
export const getReportTaskStateTagType = (state?: string | null): TagType =>
|
||||
REPORT_TASK_STATE_MAP[state as ReportTask.ReportTaskState]?.tagType || 'info'
|
||||
|
||||
export const getReportTaskGenerateStateText = (state?: number | null) =>
|
||||
REPORT_TASK_GENERATE_STATE_MAP[state as ReportTask.ReportTaskGenerateState]?.text || '未知状态'
|
||||
|
||||
export const getReportTaskGenerateStateTagType = (state?: number | null): TagType =>
|
||||
REPORT_TASK_GENERATE_STATE_MAP[state as ReportTask.ReportTaskGenerateState]?.tagType || 'info'
|
||||
|
||||
export const checkReportTaskLedgerPrepared = (
|
||||
state: ReportTask.ReportTaskLedgerPreparedState | null | undefined
|
||||
) => Boolean(state?.draftId && state.hasImported && !state.pendingRevalidate)
|
||||
|
||||
export const buildDictSelectOptions = (dictData: Dict[] = []) =>
|
||||
dictData
|
||||
.filter(item => item.id && item.name)
|
||||
@@ -90,6 +349,57 @@ export const parseReportTaskStandardIds = (value?: string[] | string | null) =>
|
||||
export const stringifyReportTaskStandardIds = (value: string[]) =>
|
||||
value.map(item => String(item).trim()).filter(Boolean)
|
||||
|
||||
export const normalizeReportTaskGroupSavePayload = (
|
||||
pointList: ReportTask.ReportTaskPointRecord[],
|
||||
pointGroupMap: Record<string, number | string | null | undefined>
|
||||
): ReportTask.ReportTaskGroupSaveRequest => {
|
||||
const groupedPointMap = new Map<number, string[]>()
|
||||
|
||||
pointList.forEach(point => {
|
||||
const pointId = String(point.id || '').trim()
|
||||
if (!pointId) return
|
||||
|
||||
const rawGroupNo = pointGroupMap[pointId]
|
||||
const groupNo = Number(rawGroupNo)
|
||||
if (!Number.isInteger(groupNo) || groupNo <= 0) return
|
||||
|
||||
const groupPointIds = groupedPointMap.get(groupNo) || []
|
||||
groupPointIds.push(pointId)
|
||||
groupedPointMap.set(groupNo, groupPointIds)
|
||||
})
|
||||
|
||||
return {
|
||||
groups: Array.from(groupedPointMap.entries())
|
||||
.sort(([groupNoA], [groupNoB]) => groupNoA - groupNoB)
|
||||
.map(([groupNo, pointIds]) => ({
|
||||
groupNo,
|
||||
pointIds
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
export const checkReportTaskGroupingCompleted = (
|
||||
pointList: ReportTask.ReportTaskPointRecord[],
|
||||
payload: ReportTask.ReportTaskGroupSaveRequest | null | undefined
|
||||
) => {
|
||||
if (!pointList.length || !payload?.groups?.length) return false
|
||||
|
||||
const pointIds = pointList.map(point => String(point.id || '').trim()).filter(Boolean)
|
||||
if (!pointIds.length) return false
|
||||
|
||||
const groupedIds = payload.groups.flatMap(group => group.pointIds.map(pointId => String(pointId || '').trim()).filter(Boolean))
|
||||
if (groupedIds.length !== pointIds.length) return false
|
||||
|
||||
const uniqueGroupedIds = new Set(groupedIds)
|
||||
if (uniqueGroupedIds.size !== pointIds.length) return false
|
||||
|
||||
const pointIdSet = new Set(pointIds)
|
||||
const hasInvalidPointId = Array.from(uniqueGroupedIds).some(pointId => !pointIdSet.has(pointId))
|
||||
if (hasInvalidPointId) return false
|
||||
|
||||
return payload.groups.every(group => Number.isInteger(group.groupNo) && group.groupNo > 0 && group.pointIds.length > 0)
|
||||
}
|
||||
|
||||
export const resolveReportTaskCreateUnitText = (
|
||||
value: string | null | undefined,
|
||||
companyLabelMap: Record<string, string>
|
||||
|
||||
@@ -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
|
||||
})
|
||||
@@ -1,180 +1,328 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog v-model='dialogVisible' :title="dialogTitle" v-bind="dialogSmall" @close="close" align-center>
|
||||
<div>
|
||||
<el-form :model="formContent"
|
||||
ref='dialogFormRef'
|
||||
:rules='rules'
|
||||
>
|
||||
<el-form-item label="用户名" prop='name' :label-width="100">
|
||||
<el-input v-model="formContent.name" placeholder="请输入用户名" autocomplete="off" maxlength="32" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label="登录名" prop='loginName' :label-width="100" >
|
||||
<el-input v-model="formContent.loginName" placeholder="请输入登录名" autocomplete="off" :disabled="LoginNameIsShow" maxlength="32" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop='password' :label-width="100" v-if="IsPasswordShow">
|
||||
<el-input type="password" v-model="formContent.password" show-password placeholder="请输入密码" autocomplete="off" maxlength="32" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label='角色' :label-width='100' prop='roles'>
|
||||
<el-select v-model="formContent.roleIds" multiple placeholder="请选择角色">
|
||||
<el-option
|
||||
v-for="item in roleList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码" prop='phone' :label-width="100">
|
||||
<el-input v-model="formContent.phone" placeholder="请输入手机号码" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱地址" prop='email' :label-width="100">
|
||||
<el-input v-model="formContent.email" placeholder="请输入邮箱地址" autocomplete="off" />
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="close()">取消</el-button>
|
||||
<el-button type="primary" @click="save()">
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" v-bind="dialogSmall" @close="close" align-center>
|
||||
<el-form ref="dialogFormRef" :model="formContent" :rules="rules">
|
||||
<el-form-item label="用户名" prop="name" :label-width="100">
|
||||
<el-input
|
||||
v-model="formContent.name"
|
||||
placeholder="请输入用户名"
|
||||
autocomplete="off"
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="登录名" prop="loginName" :label-width="100">
|
||||
<el-input
|
||||
v-model="formContent.loginName"
|
||||
placeholder="请输入登录名"
|
||||
autocomplete="off"
|
||||
:disabled="loginNameDisabled"
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isPasswordShow" label="密码" prop="password" :label-width="100">
|
||||
<el-input
|
||||
v-model="formContent.password"
|
||||
type="password"
|
||||
show-password
|
||||
placeholder="请输入密码"
|
||||
autocomplete="off"
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色" prop="roleIds" :label-width="100">
|
||||
<el-select v-model="formContent.roleIds" multiple placeholder="请选择角色">
|
||||
<el-option v-for="item in roleList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码" prop="phone" :label-width="100">
|
||||
<el-input v-model="formContent.phone" placeholder="请输入手机号码" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱地址" prop="email" :label-width="100">
|
||||
<el-input v-model="formContent.email" placeholder="请输入邮箱地址" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="用户签名" :label-width="100">
|
||||
<div class="signature-upload">
|
||||
<el-input :model-value="signatureDisplayName" readonly placeholder="请选择签名文件" />
|
||||
<div class="signature-upload__actions">
|
||||
<el-button type="primary" plain @click="openFilePicker">选择文件</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
:disabled="!canPreviewSignature"
|
||||
@click="handlePreviewSignature"
|
||||
>
|
||||
预览签名
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="signature-upload__tip">支持 png/jpg/jpeg/bmp/webp</div>
|
||||
<input
|
||||
ref="fileInputRef"
|
||||
class="hidden-file-input"
|
||||
type="file"
|
||||
accept=".png,.jpg,.jpeg,.bmp,.webp"
|
||||
@change="handleSignatureFileChange"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref,computed, type Ref } from 'vue'
|
||||
import {dialogSmall} from '@/utils/elementBind'
|
||||
import { ElMessage, type FormInstance,type FormItemRule } from 'element-plus'
|
||||
import {
|
||||
addUser,
|
||||
updateUser,
|
||||
} from '@/api/user/user'
|
||||
// 使用 dayjs 库格式化
|
||||
import dayjs from 'dayjs';
|
||||
import { type User } from '@/api/user/interface/user';
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { type Role } from '@/api/user/interface/role';
|
||||
const dictStore = useDictStore()
|
||||
// 定义弹出组件元信息
|
||||
const dialogFormRef = ref()
|
||||
const IsPasswordShow = ref(false)
|
||||
const roleList = ref<Role.RoleBO[]>([])
|
||||
const LoginNameIsShow = ref(false)
|
||||
function useMetaInfo() {
|
||||
const dialogVisible = ref(false)
|
||||
const titleType = ref('add')
|
||||
const formContent = ref<User.ResUser>({
|
||||
id: '', //用户ID,作为唯一标识
|
||||
name: '', //用户名(别名)
|
||||
loginName: '',//登录名
|
||||
password: '',//密码
|
||||
phone: '', //手机号
|
||||
email: '', //邮箱
|
||||
loginTime: '',//最后一次登录时间
|
||||
loginErrorTimes: 0,//登录错误次数
|
||||
lockTime: '', //用户密码错误锁定时间
|
||||
state: 1, //
|
||||
})
|
||||
return { dialogVisible, titleType, formContent }
|
||||
}
|
||||
|
||||
const { dialogVisible, titleType, formContent } = useMetaInfo()
|
||||
// 清空formContent
|
||||
const resetFormContent = () => {
|
||||
formContent.value = {
|
||||
id: '', //用户ID,作为唯一标识
|
||||
name: '', //用户名(别名)
|
||||
loginName: '',//登录名
|
||||
password: '',//密码
|
||||
phone: '', //手机号
|
||||
email: '', //邮箱
|
||||
loginTime: '',//最后一次登录时间
|
||||
loginErrorTimes: 0,//登录错误次数
|
||||
lockTime: '', //用户密码错误锁定时间
|
||||
state: 1, //
|
||||
}
|
||||
}
|
||||
|
||||
let dialogTitle = computed(() => {
|
||||
return titleType.value === 'add' ? '新增用户' : '编辑用户'
|
||||
})
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="close()">取消</el-button>
|
||||
<el-button type="primary" @click="save()">保存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref, type Ref } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormItemRule } from 'element-plus'
|
||||
import { dialogSmall } from '@/utils/elementBind'
|
||||
import { addUser, previewUserSignature, updateUser } from '@/api/user/user'
|
||||
import type { Role } from '@/api/user/interface/role'
|
||||
import type { User } from '@/api/user/interface/user'
|
||||
|
||||
//定义规则
|
||||
const formRuleRef = ref<FormInstance>()
|
||||
//定义校验规则
|
||||
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||
name: [{ required: true, message: '名称必填!', trigger: 'blur' },
|
||||
// 指定正则,此处是数字正则
|
||||
{ pattern: /^[A-Za-z\u4e00-\u9fa5]{1,16}$/, message: '名称需1~16位的英文或汉字', trigger: 'blur' }],
|
||||
loginName: [{ required: true, message: '登录名必填!', trigger: 'blur' },
|
||||
{ pattern: /^[a-zA-Z]{1}[a-zA-Z0-9]{2,15}$/, message: '格式错误,需以字母开头,长度为3-16位的字母或数字', trigger: 'blur' }],
|
||||
password: [{ required: true, message: '密码必填!', trigger: 'blur' },
|
||||
{ pattern: /^(?=.*[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]).{8,16}$/, message: '密码长度为8-16,需包含特殊字符', trigger: 'blur' }],
|
||||
})
|
||||
|
||||
|
||||
// 关闭弹窗
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
// 清空dialogForm中的值
|
||||
resetFormContent()
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
const save = () => {
|
||||
try {
|
||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
if (formContent.value.id) {
|
||||
await updateUser(formContent.value);
|
||||
} else {
|
||||
await addUser(formContent.value);
|
||||
}
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
close()
|
||||
// 刷新表格
|
||||
await props.refreshTable!()
|
||||
defineOptions({
|
||||
name: 'UserPopup'
|
||||
})
|
||||
|
||||
const SIGNATURE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'bmp', 'webp']
|
||||
|
||||
type UserPopupMode = 'add' | 'edit'
|
||||
|
||||
interface UserFormModel {
|
||||
id: string
|
||||
name: string
|
||||
loginName: string
|
||||
password: string
|
||||
phone: string
|
||||
email: string
|
||||
roleIds: string[]
|
||||
signatureFileId: string
|
||||
signatureFileName: string
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
refreshTable: (() => Promise<void>) | undefined
|
||||
}>()
|
||||
|
||||
const dialogFormRef = ref<FormInstance>()
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
const dialogVisible = ref(false)
|
||||
const titleType = ref<UserPopupMode>('add')
|
||||
const roleList = ref<Role.RoleBO[]>([])
|
||||
const selectedSignatureFile = ref<File | null>(null)
|
||||
const existingSignatureFileName = ref('')
|
||||
const formContent = reactive<UserFormModel>({
|
||||
id: '',
|
||||
name: '',
|
||||
loginName: '',
|
||||
password: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
roleIds: [],
|
||||
signatureFileId: '',
|
||||
signatureFileName: ''
|
||||
})
|
||||
|
||||
const dialogTitle = computed(() => (titleType.value === 'add' ? '新增用户' : '编辑用户'))
|
||||
const isPasswordShow = computed(() => titleType.value === 'add')
|
||||
const loginNameDisabled = computed(() => titleType.value === 'edit')
|
||||
const signatureDisplayName = computed(() => selectedSignatureFile.value?.name || existingSignatureFileName.value || '')
|
||||
const canPreviewSignature = computed(() =>
|
||||
Boolean(selectedSignatureFile.value || (formContent.id && existingSignatureFileName.value))
|
||||
)
|
||||
|
||||
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||
name: [
|
||||
{ required: true, message: '名称必填', trigger: 'blur' },
|
||||
{ pattern: /^[A-Za-z\u4e00-\u9fa5]{1,16}$/, message: '名称需1~16位的英文或汉字', trigger: 'blur' }
|
||||
],
|
||||
loginName: [
|
||||
{ required: true, message: '登录名必填', trigger: 'blur' },
|
||||
{ pattern: /^[a-zA-Z]{1}[a-zA-Z0-9]{2,15}$/, message: '需以字母开头,长度为3-16位字母或数字', trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '密码必填', trigger: 'blur' },
|
||||
{
|
||||
pattern: /^(?=.*[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]).{8,16}$/,
|
||||
message: '密码长度为8-16,需包含特殊字符',
|
||||
trigger: 'blur'
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('验证过程中出现错误', err)
|
||||
]
|
||||
})
|
||||
|
||||
const resetFormContent = () => {
|
||||
formContent.id = ''
|
||||
formContent.name = ''
|
||||
formContent.loginName = ''
|
||||
formContent.password = ''
|
||||
formContent.phone = ''
|
||||
formContent.email = ''
|
||||
formContent.roleIds = []
|
||||
formContent.signatureFileId = ''
|
||||
formContent.signatureFileName = ''
|
||||
}
|
||||
|
||||
const resetSignatureState = () => {
|
||||
selectedSignatureFile.value = null
|
||||
existingSignatureFileName.value = ''
|
||||
|
||||
if (fileInputRef.value) {
|
||||
fileInputRef.value.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (sign: string, data: User.ResUser,roleParams: Role.RoleBO[]) => {
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
// 获取角色列表
|
||||
}
|
||||
|
||||
const resetPopupState = () => {
|
||||
resetFormContent()
|
||||
resetSignatureState()
|
||||
dialogFormRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
const validateSignatureFile = (file: File) => {
|
||||
const fileName = file.name || ''
|
||||
const extension = fileName.includes('.') ? fileName.split('.').pop()?.toLowerCase() : ''
|
||||
|
||||
if (!extension || !SIGNATURE_EXTENSIONS.includes(extension)) {
|
||||
return '签名文件仅支持 png、jpg、jpeg、bmp、webp'
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
const buildSaveRequest = (): User.UserSaveRequest => ({
|
||||
id: formContent.id || undefined,
|
||||
name: formContent.name.trim(),
|
||||
loginName: titleType.value === 'add' ? formContent.loginName.trim() : undefined,
|
||||
password: titleType.value === 'add' ? formContent.password : undefined,
|
||||
phone: formContent.phone.trim() || undefined,
|
||||
email: formContent.email.trim() || undefined,
|
||||
roleIds: formContent.roleIds
|
||||
})
|
||||
|
||||
const openBlobPreview = (blob: Blob) => {
|
||||
const previewUrl = URL.createObjectURL(blob)
|
||||
window.open(previewUrl, '_blank')
|
||||
window.setTimeout(() => URL.revokeObjectURL(previewUrl), 60 * 1000)
|
||||
}
|
||||
|
||||
const openFilePicker = () => {
|
||||
fileInputRef.value?.click()
|
||||
}
|
||||
|
||||
const handleSignatureFileChange = (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0] || null
|
||||
|
||||
input.value = ''
|
||||
if (!file) return
|
||||
|
||||
const validationMessage = validateSignatureFile(file)
|
||||
if (validationMessage) {
|
||||
ElMessage.warning(validationMessage)
|
||||
return
|
||||
}
|
||||
|
||||
selectedSignatureFile.value = file
|
||||
}
|
||||
|
||||
const handlePreviewSignature = async () => {
|
||||
try {
|
||||
if (selectedSignatureFile.value) {
|
||||
openBlobPreview(selectedSignatureFile.value)
|
||||
return
|
||||
}
|
||||
|
||||
if (!formContent.id || !existingSignatureFileName.value) {
|
||||
ElMessage.warning('当前用户暂无可预览的签名')
|
||||
return
|
||||
}
|
||||
|
||||
const response = await previewUserSignature(formContent.id)
|
||||
openBlobPreview(response.data)
|
||||
} catch {
|
||||
ElMessage.error('用户签名预览失败')
|
||||
}
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
resetPopupState()
|
||||
}
|
||||
|
||||
const save = async () => {
|
||||
try {
|
||||
await dialogFormRef.value?.validate()
|
||||
|
||||
// 关键业务节点:编辑用户时如果未重新选择签名文件,则只提交 request,后端会保留原签名;选了新文件才会触发替换。
|
||||
if (formContent.id) {
|
||||
await updateUser(buildSaveRequest(), selectedSignatureFile.value)
|
||||
} else {
|
||||
await addUser(buildSaveRequest(), selectedSignatureFile.value)
|
||||
}
|
||||
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功` })
|
||||
close()
|
||||
await props.refreshTable?.()
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const open = async (sign: string, data: Partial<User.ResUser> = {}, roleParams: Role.RoleBO[]) => {
|
||||
resetPopupState()
|
||||
roleList.value = roleParams
|
||||
titleType.value = sign
|
||||
titleType.value = sign === 'edit' ? 'edit' : 'add'
|
||||
dialogVisible.value = true
|
||||
|
||||
if (data.id) {
|
||||
IsPasswordShow.value = false
|
||||
LoginNameIsShow.value = true
|
||||
formContent.value = { ...data }
|
||||
|
||||
|
||||
} else {
|
||||
IsPasswordShow.value = true
|
||||
LoginNameIsShow.value = false
|
||||
resetFormContent()
|
||||
formContent.id = data.id
|
||||
formContent.name = data.name || ''
|
||||
formContent.loginName = data.loginName || ''
|
||||
formContent.password = ''
|
||||
formContent.phone = data.phone || ''
|
||||
formContent.email = data.email || ''
|
||||
formContent.roleIds = Array.isArray(data.roleIds) ? [...data.roleIds] : []
|
||||
formContent.signatureFileId = data.signatureFileId || ''
|
||||
formContent.signatureFileName = data.signatureFileName || ''
|
||||
existingSignatureFileName.value = data.signatureFileName || ''
|
||||
}
|
||||
}
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
const props = defineProps<{
|
||||
refreshTable: (() => Promise<void>) | undefined;
|
||||
}>()
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.signature-upload {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.signature-upload__actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.signature-upload__tip {
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.hidden-file-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-select),
|
||||
:deep(.el-input) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
"vitest.config.*",
|
||||
"cypress.config.*",
|
||||
"nightwatch.conf.*",
|
||||
"playwright.config.*"
|
||||
"playwright.config.*",
|
||||
"build/**/*.ts",
|
||||
"build/**/*.d.ts",
|
||||
"src/types/**/*.d.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ConfigEnv, defineConfig, loadEnv, UserConfig } from 'vite'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import type { ConfigEnv, UserConfig } from 'vite'
|
||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import path from 'path'
|
||||
@@ -61,10 +62,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
// dts: "src/types/components.d.ts",
|
||||
}),
|
||||
nodePolyfills({
|
||||
include: ['crypto'],
|
||||
globals: {
|
||||
crypto: true
|
||||
}
|
||||
include: ['crypto']
|
||||
})
|
||||
],
|
||||
// 基础配置
|
||||
|
||||
Reference in New Issue
Block a user