diff --git a/src/api/qualFiling/index.js b/src/api/qualFiling/index.js index da48a21..dd90f28 100644 --- a/src/api/qualFiling/index.js +++ b/src/api/qualFiling/index.js @@ -128,17 +128,68 @@ export function fromFilingCommitmentForm(values = {}, filingId) { // ─── 字段映射:人员 / 装备 ─── export function toFilingPersonnelRow(data = {}) { + const personName = data.personName || data.userName || data.staffName; return { id: asId(data.id), filingId: asId(data.filingId), sourcePersonnelId: asId(data.sourcePersonnelId), - personName: data.personName, + personName, + userName: personName, + personTypeCode: data.personTypeCode, personTypeName: data.personTypeName, positionName: data.positionName, titleName: data.titleName, + genderCode: data.genderCode, + genderName: data.genderName, + birthDate: data.birthDate, + joinWorkDate: data.joinWorkDate, + idCardNo: data.idCardNo, + currentAddress: data.currentAddress, + officeAddress: data.officeAddress, + educationCode: data.educationCode, + educationName: data.educationName, + graduateSchool: data.graduateSchool, + major: data.major, + qualScope: data.qualScope, + publications: data.publications, + professionalLevelCert: data.professionalLevelCert, + registerEngineerFlag: data.registerEngineerFlag, + abilityDeclaration: data.abilityDeclaration, + workExperience: data.workExperience, + proofMaterialUrl: data.proofMaterialUrl, }; } +export function fromFilingPersonnelAddCmd(item = {}) { + const row = toFilingPersonnelRow(item); + return normalizeQueryIds({ + sourcePersonnelId: row.sourcePersonnelId, + personName: row.personName, + personTypeCode: row.personTypeCode, + personTypeName: row.personTypeName, + positionName: row.positionName, + titleName: row.titleName, + genderCode: row.genderCode, + genderName: row.genderName, + birthDate: row.birthDate, + joinWorkDate: row.joinWorkDate, + idCardNo: row.idCardNo, + currentAddress: row.currentAddress, + officeAddress: row.officeAddress, + educationCode: row.educationCode, + educationName: row.educationName, + graduateSchool: row.graduateSchool, + major: row.major, + qualScope: row.qualScope, + publications: row.publications, + professionalLevelCert: row.professionalLevelCert, + registerEngineerFlag: row.registerEngineerFlag, + abilityDeclaration: row.abilityDeclaration, + workExperience: row.workExperience, + proofMaterialUrl: row.proofMaterialUrl, + }); +} + export function toFilingEquipmentRow(data = {}) { return { id: asId(data.id), @@ -168,6 +219,25 @@ export function toChangeHistory(data = {}) { +// ─── 分页查询参数映射 ─── + +function toFilingPageQuery(params = {}) { + const { filingTerritoryName, filingTerritoryCode, filingStatus, ...rest } = params; + const query = toPageQuery(rest, { + filingUnitName: "filingUnitName", + filingNo: "filingNo", + applyTypeCode: "applyTypeCode", + }); + const territory = filingTerritoryCode || filingTerritoryName; + if (territory) { + query.filingTerritoryCode = territory; + } + if (filingStatus !== undefined && filingStatus !== null && filingStatus !== "") { + query.filingStatusCode = Number(filingStatus); + } + return query; +} + // ═══════════════════════════════════════════════════ // 接口 Action // ═══════════════════════════════════════════════════ @@ -190,14 +260,12 @@ export async function fetchQualFilingChangeHistory(filingId) { } export const qualFilingPage = declareRequest("qualFilingLoading", safePageResult(async (params) => { - - const res = await apiGet("/safetyEval/qual-filing/page", params); + const res = await apiGet("/safetyEval/qual-filing/page", toFilingPageQuery(params)); return fromPageResponse(res, toFilingListRow); })); export const qualFilingFiledPage = declareRequest("qualFilingLoading", safePageResult(async (params) => { - - const res = await apiGet("/safetyEval/qual-filing/filed/page", params); + const res = await apiGet("/safetyEval/qual-filing/filed/page", toFilingPageQuery(params)); return fromPageResponse(res, toFilingListRow); })); diff --git a/src/pages/Container/QualApplication/FilingApplication/List/index.js b/src/pages/Container/QualApplication/FilingApplication/List/index.js index 6b47b6f..7478e10 100644 --- a/src/pages/Container/QualApplication/FilingApplication/List/index.js +++ b/src/pages/Container/QualApplication/FilingApplication/List/index.js @@ -72,9 +72,12 @@ function FilingApplicationListPage(props) { cancelText: "否", onOk: async () => { const res = await props.qualFilingDelete({ id: record.id }); - - message.success("删除成功"); - getData(); + if (res?.success !== false) { + message.success("删除成功"); + getData(); + } else { + message.error(res?.message || res?.errMessage || "删除失败"); + } }, }); }; diff --git a/src/pages/Container/QualApplication/FilingForm/components/PersonnelStep.jsx b/src/pages/Container/QualApplication/FilingForm/components/PersonnelStep.jsx index 57eb3f0..a76a819 100644 --- a/src/pages/Container/QualApplication/FilingForm/components/PersonnelStep.jsx +++ b/src/pages/Container/QualApplication/FilingForm/components/PersonnelStep.jsx @@ -13,8 +13,7 @@ export default function PersonnelStep({ const [selectOpen, setSelectOpen] = useState(false); const [viewId, setViewId] = useState(""); - const existingIds = personnelList.map((item) => String(item.id || "")); - console.log(personnelList); + const existingIds = personnelList.map((item) => String(item.sourcePersonnelId || item.id || "")); return ( <> @@ -36,7 +35,7 @@ export default function PersonnelStep({ dataSource={personnelList} columns={[ { title: "序号", width: 60, render: (_, __, index) => index + 1 }, - { title: "人员姓名", dataIndex: "userName" }, + { title: "人员姓名", dataIndex: "userName", render: (_, record) => record.userName || record.personName }, { title: "类型", dataIndex: "personTypeName" }, { title: "职称", dataIndex: "titleName" }, diff --git a/src/pages/Container/QualApplication/FilingForm/index.js b/src/pages/Container/QualApplication/FilingForm/index.js index e3343ff..d6a57af 100644 --- a/src/pages/Container/QualApplication/FilingForm/index.js +++ b/src/pages/Container/QualApplication/FilingForm/index.js @@ -3,7 +3,7 @@ import { tools } from "@cqsjjb/jjb-common-lib"; import { Button, Form, message, Modal, Space, Spin, Tabs } from "antd"; import { useCallback, useEffect, useRef, useState } from "react"; import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout"; -import { fetchQualFilingDetail, fetchQualChangeDetail } from "~/api/qualFiling"; +import { fetchQualFilingDetail, fetchQualChangeDetail, fromFilingPersonnelAddCmd } from "~/api/qualFiling"; import { NS_QUAL_FILING } from "~/enumerate/namespace"; import { FILING_FORM_MODE } from "~/enumerate/qualFilingOptions"; import { FILING_MATERIAL_TEMPLATE } from "../filingMaterialTemplate"; @@ -97,6 +97,46 @@ function FilingFormPage(props) { }); }, [basicForm, commitmentForm, detail]); + const syncCommitmentFromBasic = useCallback(() => { + const filingUnitName = + basicForm.getFieldValue("filingUnitName") || detail?.filingUnitName || ""; + const legalRepName = commitmentForm.getFieldValue("legalRepName") || ""; + commitmentForm.setFieldsValue({ filingUnitName, legalRepName }); + }, [basicForm, commitmentForm, detail?.filingUnitName]); + + const goToStep = useCallback( + (key) => { + if (key === "commitment") { + syncCommitmentFromBasic(); + } + setActiveStep(key); + }, + [syncCommitmentFromBasic], + ); + + const handleSaveDraft = async () => { + if (readOnly) { + return; + } + setSubmitting(true); + try { + const currentDetail = collectCurrentDetail(); + await persistFilingToBackend(props, currentDetail, mode); + message.success("暂存成功"); + props.history.goBack(); + } catch (err) { + message.error(err?.message || "暂存失败"); + } finally { + setSubmitting(false); + } + }; + + useEffect(() => { + if (activeStep === "commitment") { + syncCommitmentFromBasic(); + } + }, [activeStep, syncCommitmentFromBasic]); + const handleSubmitRequest = async () => { if (readOnly) { return; @@ -151,10 +191,7 @@ function FilingFormPage(props) { delete params.materials; } if (params.personnelList) { - body[`qualFilingPersonnel${word}AddCmds`] = params.personnelList.map((item) => ({ - ...item, - personName: item.userName, - })); + body[`qualFilingPersonnel${word}AddCmds`] = params.personnelList.map(fromFilingPersonnelAddCmd); delete params.personnelList; } if (params.equipmentList) { @@ -202,7 +239,7 @@ function FilingFormPage(props) { const handlePersonnelAdd = (sourcePersonnelIds, rows = []) => { const existing = new Set( (detailRef.current?.personnelList || []).map((item) => - String(item.sourcePersonnelId), + String(item.sourcePersonnelId || item.id), ), ); const idsToAdd = sourcePersonnelIds.filter( @@ -214,7 +251,7 @@ function FilingFormPage(props) { const rowMap = new Map((rows || []).map((row) => [String(row.id), row])); const newRows = idsToAdd.map((id) => { const row = rowMap.get(String(id)); - return row; + return row ? mapStaffRowToFilingPersonnel(row) : mapStaffRowToFilingPersonnel({ id }); }); setDetail((prev) => ({ ...prev, @@ -226,7 +263,7 @@ function FilingFormPage(props) { const handlePersonnelRemove = (record) => { Modal.confirm({ title: "提示", - content: `确认删除人员「${record.userName}」?`, + content: `确认删除人员「${record.userName || record.personName}」?`, onOk: () => { setDetail((prev) => ({ ...prev, @@ -358,23 +395,14 @@ function FilingFormPage(props) { { - if (key === "commitment") { - commitmentForm.setFieldsValue({ - filingUnitName: - basicForm.getFieldValue("filingUnitName") || - detail?.filingUnitName, - }); - } - setActiveStep(key); - }} + onChange={goToStep} /> {stepIndex > 0 && ( )} diff --git a/src/pages/Container/QualApplication/filingPersist.js b/src/pages/Container/QualApplication/filingPersist.js index bcbb1c9..2f03f13 100644 --- a/src/pages/Container/QualApplication/filingPersist.js +++ b/src/pages/Container/QualApplication/filingPersist.js @@ -29,6 +29,7 @@ export function mapStaffRowToFilingPersonnel(row = {}) { id: `local-person-${id}`, sourcePersonnelId: id, personName: row.staffName, + userName: row.staffName, personTypeName: row.personType, positionName: row.positionName, titleName: row.titleName, @@ -188,6 +189,10 @@ async function syncEquipment(props, filingId, localList = [], backendList = []) /** * 将本地表单全量同步到后端(暂存 / 提交确认时调用) */ +function getApiErrorMessage(res, fallback) { + return res?.message || res?.errMessage || fallback; +} + export async function persistFilingToBackend(props, detail, mode) { let filingId = detail.id; const basicValues = collectBasicValues(detail); @@ -198,7 +203,7 @@ export async function persistFilingToBackend(props, detail, mode) { : props.qualFilingDraft; const draftRes = await createDraft(); if (draftRes?.success === false || !draftRes?.data?.id) { - throw new Error(draftRes?.message || "创建草稿失败"); + throw new Error(getApiErrorMessage(draftRes, "创建草稿失败")); } filingId = draftRes.data.id; basicValues.id = filingId; @@ -206,7 +211,7 @@ export async function persistFilingToBackend(props, detail, mode) { const saveRes = await props.qualFilingSaveDraft({ ...basicValues, id: filingId }); if (saveRes?.success === false) { - throw new Error(saveRes?.message || "暂存基本信息失败"); + throw new Error(getApiErrorMessage(saveRes, "暂存基本信息失败")); } if (detail.attachmentUrl) { @@ -230,7 +235,7 @@ export async function persistFilingToBackend(props, detail, mode) { buildCommitmentPayload({ ...detail, id: filingId }), ); if (commitmentRes?.success === false) { - throw new Error(commitmentRes?.message || "暂存承诺书失败"); + throw new Error(getApiErrorMessage(commitmentRes, "暂存承诺书失败")); } } diff --git a/src/pages/Container/QualificationReview/ExpertVerification/index.js b/src/pages/Container/QualificationReview/ExpertVerification/index.js index b470a1e..e44bbfd 100644 --- a/src/pages/Container/QualificationReview/ExpertVerification/index.js +++ b/src/pages/Container/QualificationReview/ExpertVerification/index.js @@ -1,104 +1,70 @@ -import React, { useState, useEffect } from "react"; -import { Button, Form, Select, Space, Table, Tag } from "antd"; +import React, { useEffect } from "react"; +import { Button, Form, Select, Table, Tag } from "antd"; import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout"; import SearchForm from "@cqsjjb/jjb-react-admin-component/SearchForm"; +import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction"; import ControlWrapper from "@cqsjjb/jjb-react-admin-component/ControlWrapper"; import { AntdTableFuncControl } from "@cqsjjb/jjb-common-decorator/antd"; -import {tools} from '@cqsjjb/jjb-common-lib' +import { tools } from "@cqsjjb/jjb-common-lib"; +import { Connect } from "@cqsjjb/jjb-dva-runtime"; +import { NS_QUAL_REVIEW } from "~/enumerate/namespace"; import { VERIFY_STATUS_MAP } from "~/enumerate/constant"; +import { + FILING_CODE_TO_CONFIRM, + REVIEW_BUSINESS_SCOPE_OPTIONS, + REVIEW_UNIT_TYPE_OPTIONS, + toQualReviewPageQuery, +} from "../reviewPageQuery"; - - -// 静态模拟数据 -const MOCK_DATA = [ - { - id: 1, - orgName: "重庆安评技术研究院有限公司", - orgType: "本地机构", - certNo: "API-2026-001", - businessScope: "化工, 石油加工", - confirmStatus: "pending", - }, - { - id: 2, - orgName: "北京中安评价中心(重庆分公司)", - orgType: "异地机构", - certNo: "API-2026-015", - businessScope: "矿山", - confirmStatus: "passed", - }, - { - id: 3, - orgName: "重庆华安评价有限公司", - orgType: "异地机构", - certNo: "API-2025-088", - businessScope: "石油加工", - confirmStatus: "pending", - }, - { - id: 4, - orgName: "重庆安评科技有限公司", - orgType: "本地机构", - certNo: "API-2024-056", - businessScope: "化工", - confirmStatus: "rejected", - }, - { - id: 5, - orgName: "重庆恒安安全评价有限公司", - orgType: "本地机构", - certNo: "API-2025-032", - businessScope: "矿山, 石油加工", - confirmStatus: "passed", - }, -]; - -const {router} = tools; +const { router } = tools; const ExpertVerification = (props) => { const [form] = Form.useForm(); - const [loading, setLoading] = useState(false); + const { qualReview, queryReviewList } = props; + const { qualReviewList, qualReviewTotal, qualReviewLoading } = qualReview || {}; const handleSearch = () => { - setLoading(true); - console.log(router.query); - setTimeout(() => setLoading(false), 500); + queryReviewList({ + ...toQualReviewPageQuery(router.query), + supervision: true, + applyTypeCode: 1, + }); }; const handleReset = (values) => { - setLoading(true); - router.query={ + router.query = { ...router.query, ...values, current: 1, - pageSize: 10, - } + size: 10, + }; handleSearch(); }; useEffect(() => { form.setFieldsValue(router.query); + handleSearch(); }, []); const columns = [ { title: "序号", - dataIndex: "id", width: 60, fixed: "left", - render: (text, record, index) => index + 1, + render: (_, __, index) => index + 1, }, - { title: "机构名称", dataIndex: "orgName", width: 220, ellipsis: true }, - { title: "机构类型", dataIndex: "orgType", width: 100 }, - { title: "证书编号", dataIndex: "certNo", width: 140, ellipsis: true }, + { title: "机构名称", dataIndex: "filingUnitName", width: 220, ellipsis: true }, + { title: "机构类型", dataIndex: "filingUnitTypeName", width: 100 }, + { title: "证书编号", dataIndex: "filingNo", width: 140, ellipsis: true }, { title: "安全评价业务范围", dataIndex: "businessScope", width: 180, ellipsis: true }, { title: "确认状态", - dataIndex: "confirmStatus", + dataIndex: "filingStatusCode", width: 100, - render: (status) => { + render: (code) => { + const status = FILING_CODE_TO_CONFIRM[code]; const config = VERIFY_STATUS_MAP[status]; - return config ? {config.label} : status; + return config ? {config.label} : "--"; }, }, { @@ -106,61 +72,54 @@ const ExpertVerification = (props) => { width: 140, fixed: "right", render: (_, record) => ( - + - {record.confirmStatus === "pending" && ( + {record.filingStatusCode === 2 && ( )} - + ), }, ]; return ( - + , - + - 本地机构 - 异地机构 - + options={REVIEW_UNIT_TYPE_OPTIONS} + /> , - + - 石油加工 - 化工 - 矿山 - + options={REVIEW_BUSINESS_SCOPE_OPTIONS} + /> , @@ -172,12 +131,12 @@ const ExpertVerification = (props) => { ]} onReset={handleReset} onFinish={(values) => { - router.query={ + router.query = { ...router.query, ...values, current: 1, - pageSize: 10, - } + size: 10, + }; handleSearch(); }} /> @@ -185,22 +144,21 @@ const ExpertVerification = (props) => { `共 ${total} 条`, - current: router.query.current, - pageSize: router.query.pageSize, + current: router.query.current || 1, + pageSize: router.query.size || 10, onChange: (page, pageSize) => { - - router.query={ + router.query = { ...router.query, current: page, - pageSize, + size: pageSize, }; handleSearch(); }, @@ -210,4 +168,4 @@ const ExpertVerification = (props) => { ); }; -export default AntdTableFuncControl(ExpertVerification); +export default Connect([NS_QUAL_REVIEW], true)(AntdTableFuncControl(ExpertVerification)); diff --git a/src/pages/Container/QualificationReview/QualConfirm/index.js b/src/pages/Container/QualificationReview/QualConfirm/index.js index 566f5d2..d937b71 100644 --- a/src/pages/Container/QualificationReview/QualConfirm/index.js +++ b/src/pages/Container/QualificationReview/QualConfirm/index.js @@ -9,6 +9,11 @@ import { tools } from "@cqsjjb/jjb-common-lib"; import { Connect } from "@cqsjjb/jjb-dva-runtime"; import { NS_QUAL_REVIEW } from "~/enumerate/namespace"; import { FILING_STATUS_MAP } from "~/enumerate/constant"; +import { + REVIEW_BUSINESS_SCOPE_OPTIONS, + REVIEW_UNIT_TYPE_OPTIONS, + toQualReviewPageQuery, +} from "../reviewPageQuery"; const { router } = tools; @@ -19,7 +24,7 @@ const QualConfirm = (props) => { const handleSearch = () => { queryReviewList({ - ...router.query, + ...toQualReviewPageQuery(router.query), supervision: true, applyTypeCode: 2, }); @@ -89,31 +94,27 @@ const QualConfirm = (props) => { , - + - 本地机构 - 异地机构 - + options={REVIEW_UNIT_TYPE_OPTIONS} + /> , - 石油加工 - 化工 - 矿山 - 建筑施工 - + options={REVIEW_BUSINESS_SCOPE_OPTIONS} + /> , - + { const handleSearch = () => { queryReviewList({ - ...router.query, + ...toQualReviewPageQuery(router.query), supervision: true, applyTypeCode: 1, }); - }; const handleReset = (values) => { @@ -104,29 +108,25 @@ const QualReview = (props) => { , - + - 本地机构 - 异地机构 - + options={REVIEW_UNIT_TYPE_OPTIONS} + /> , - 石油加工 - 化工 - 矿山 - 建筑施工 - + options={REVIEW_BUSINESS_SCOPE_OPTIONS} + /> , 备案状态编码 */ +const CONFIRM_STATUS_TO_FILING_CODE = { + pending: 2, + passed: 1, + rejected: 3, +}; + +/** 备案状态编码 -> 确认状态展示 */ +export const FILING_CODE_TO_CONFIRM = { + 2: "pending", + 1: "passed", + 3: "rejected", +}; + +/** 专家核验/确认列表筛选项(与备案申请表单保持一致) */ +export const REVIEW_UNIT_TYPE_OPTIONS = FILING_UNIT_TYPE_OPTIONS; +export const REVIEW_BUSINESS_SCOPE_OPTIONS = QUALIFICATION_INDUSTRY_OPTIONS; + +/** 资质审核列表查询参数映射 */ +export function toQualReviewPageQuery(query = {}) { + const { confirmStatus, orgType, filingUnitTypeName, filingStatusCode, ...rest } = query; + const params = { ...rest }; + const unitType = filingUnitTypeName || orgType; + if (unitType) { + params.filingUnitTypeName = unitType; + } + const statusKey = confirmStatus || filingStatusCode; + if (statusKey && CONFIRM_STATUS_TO_FILING_CODE[statusKey] != null) { + params.filingStatusCode = CONFIRM_STATUS_TO_FILING_CODE[statusKey]; + } else if (filingStatusCode !== undefined && filingStatusCode !== null && filingStatusCode !== "") { + params.filingStatusCode = Number(filingStatusCode); + } + delete params.confirmStatus; + delete params.orgType; + return params; +} diff --git a/src/utils/enterpriseInfo/http.js b/src/utils/enterpriseInfo/http.js index 5d5d441..661572b 100644 --- a/src/utils/enterpriseInfo/http.js +++ b/src/utils/enterpriseInfo/http.js @@ -56,9 +56,8 @@ export async function apiPost(path, data = {}, headers = {}, options = {}) { } export async function apiPostDelete(path, id, options = {}) { - const url = `${path}?id=${encodeURIComponent(asId(id) ?? "")}`; try { - return await Post(url, {}, buildRequestHeaders({}, options)); + return await Post(`@${path}`, { data: asId(id) }, buildRequestHeaders({}, options)); } catch (err) { return parseHttpError(err); @@ -85,7 +84,7 @@ export function safeAction(mapper) { if (res && res.success === false) { return { success: false, - message: res.message || res.msg || "操作失败", + message: res.message || res.msg || res.errMessage || "操作失败", code: res.code, }; }