feat: 前端-接入gbs用户信息
parent
984fc3c64a
commit
b06f03a0a2
|
|
@ -1,11 +1,31 @@
|
|||
/** 企业信息管理:前后端字段与分页格式适配 */
|
||||
|
||||
import { formatDate, formatDateTime, toApiDate, toApiDateTime } from "../../utils/dateFormat";
|
||||
import { resolveUploadFileIds } from "../../utils/mockUpload";
|
||||
import { asId, isIdFieldName, normalizeQueryIds } from "./idUtil";
|
||||
import { withOrgId } from "./orgContext";
|
||||
|
||||
const GENDER_NAME = { 1: "男", 2: "女" };
|
||||
const RESIGN_AUDIT_STATUS_NAME = { 0: "未审核", 1: "已审核", 2: "已退回" };
|
||||
const ENTERPRISE_STATUS_CODE = { 正常: 1, 停业: 2, 注销: 3 };
|
||||
const FILING_TYPE_CODE = { 审核备案: "1", 确认备案: "2" };
|
||||
const FILING_RECORD_STATUS_CODE = { 已备案: 1, 未备案: 2 };
|
||||
const PERSON_TYPE_CODE = { 基础人员: "1", 专职评价师: "2" };
|
||||
|
||||
function parseAttachmentUrls(urls, defaultName = "附件.pdf") {
|
||||
if (!urls) {
|
||||
return [];
|
||||
}
|
||||
return String(urls)
|
||||
.split(",")
|
||||
.map((url) => url.trim())
|
||||
.filter(Boolean)
|
||||
.map((url, index) => ({
|
||||
name: `${defaultName.replace(".pdf", "")}${index + 1}.pdf`,
|
||||
fileName: `${defaultName.replace(".pdf", "")}${index + 1}.pdf`,
|
||||
url,
|
||||
}));
|
||||
}
|
||||
|
||||
/** 分页查询参数:子表 org_id → org_info.id;机构信息管理 getInfo 不走此方法 */
|
||||
export function toPageQuery(params = {}, fieldMap = {}) {
|
||||
|
|
@ -86,16 +106,25 @@ export function toOrgInfoForm(data = {}) {
|
|||
fullTimeEvaluatorCount: data.fulltimeEvaluatorCount,
|
||||
registeredSafetyEngineerCount: data.registeredEngineerCount,
|
||||
authStatusCode: data.authStatusCode,
|
||||
enterpriseStatus: data.enterpriseStatusName,
|
||||
enterpriseScale: data.enterpriseScaleName,
|
||||
filingType: data.filingTypeName ?? "确认备案",
|
||||
filingRecordStatus: data.filingRecordStatusName ?? "未备案",
|
||||
attachments: parseAttachmentUrls(data.attachmentUrls),
|
||||
};
|
||||
}
|
||||
|
||||
export function fromOrgInfoForm(values = {}, options = {}) {
|
||||
const { isDraft = false } = options;
|
||||
const enterpriseStatus = values.enterpriseStatus;
|
||||
const filingType = values.filingType ?? "确认备案";
|
||||
const filingRecordStatus = values.filingRecordStatus ?? "未备案";
|
||||
return {
|
||||
...pick(values, ["id", "tenantId"]),
|
||||
unitName: values.orgName,
|
||||
creditCode: values.creditCode,
|
||||
safetyIndustryCategoryName: values.safetyIndustryCategory,
|
||||
districtCode: values.regionCountyName,
|
||||
districtName: values.regionCountyName,
|
||||
townStreet: values.regionStreetName,
|
||||
villageCommunity: values.regionCommunityName,
|
||||
|
|
@ -121,6 +150,15 @@ export function fromOrgInfoForm(values = {}, options = {}) {
|
|||
registeredEngineerCount: values.registeredSafetyEngineerCount,
|
||||
authStatusCode: isDraft ? 0 : 1,
|
||||
authStatusName: isDraft ? "草稿" : "已提交",
|
||||
enterpriseStatusCode: ENTERPRISE_STATUS_CODE[enterpriseStatus],
|
||||
enterpriseStatusName: enterpriseStatus,
|
||||
enterpriseScaleCode: values.enterpriseScale,
|
||||
enterpriseScaleName: values.enterpriseScale,
|
||||
filingTypeCode: FILING_TYPE_CODE[filingType] ?? filingType,
|
||||
filingTypeName: filingType,
|
||||
filingRecordStatusCode: FILING_RECORD_STATUS_CODE[filingRecordStatus],
|
||||
filingRecordStatusName: filingRecordStatus,
|
||||
attachmentUrls: resolveUploadFileIds(values.attachments),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -202,10 +240,22 @@ export function toStaffForm(data = {}) {
|
|||
idCardNo: data.idCardNo,
|
||||
homeAddress: data.currentAddress,
|
||||
officeAddress: data.officeAddress,
|
||||
educationType: data.educationTypeName,
|
||||
educationLevel: data.educationLevelName,
|
||||
education: data.educationName ?? data.educationCode,
|
||||
graduateSchool: data.graduateSchool,
|
||||
major: data.major,
|
||||
employmentStatus: data.employmentStatusCode,
|
||||
personType: data.personTypeName ?? "基础人员",
|
||||
qualScope: data.qualScope,
|
||||
professionalLevel: data.professionalLevelName,
|
||||
evaluatorCertNo: data.evaluatorCertNo,
|
||||
titleName: data.titleName,
|
||||
registerEngineerFlag: data.registerEngineerFlag ?? 2,
|
||||
publications: data.publications,
|
||||
abilityDeclaration: data.abilityDeclaration,
|
||||
workExperience: data.workExperience,
|
||||
proofMaterials: parseAttachmentUrls(data.proofMaterialUrl, "专业能力证明.pdf"),
|
||||
deptName: data.deptName,
|
||||
positionName: data.postName ?? data.positionName,
|
||||
certNames: data.certNames,
|
||||
|
|
@ -214,6 +264,12 @@ export function toStaffForm(data = {}) {
|
|||
|
||||
export function fromStaffForm(values = {}) {
|
||||
const genderCode = values.gender;
|
||||
const personType = values.personType ?? "基础人员";
|
||||
const educationType = values.educationType;
|
||||
const educationLevel = values.educationLevel;
|
||||
const educationName = educationType && educationLevel
|
||||
? `${educationType}-${educationLevel}`
|
||||
: values.education;
|
||||
return {
|
||||
...pick(values, ["id", "tenantId"]),
|
||||
userName: values.staffName,
|
||||
|
|
@ -226,12 +282,28 @@ export function fromStaffForm(values = {}) {
|
|||
idCardNo: values.idCardNo,
|
||||
currentAddress: values.homeAddress,
|
||||
officeAddress: values.officeAddress,
|
||||
educationName: values.education,
|
||||
educationCode: values.education,
|
||||
educationName,
|
||||
educationCode: educationName,
|
||||
educationTypeCode: educationType,
|
||||
educationTypeName: educationType,
|
||||
educationLevelCode: educationLevel,
|
||||
educationLevelName: educationLevel,
|
||||
graduateSchool: values.graduateSchool,
|
||||
major: values.major,
|
||||
employmentStatusCode: values.employmentStatus ?? 1,
|
||||
employmentStatusName: values.employmentStatus === 2 ? "离职" : "在职",
|
||||
personTypeCode: PERSON_TYPE_CODE[personType] ?? personType,
|
||||
personTypeName: personType,
|
||||
qualScope: values.qualScope,
|
||||
professionalLevelCode: values.professionalLevel,
|
||||
professionalLevelName: values.professionalLevel,
|
||||
evaluatorCertNo: values.evaluatorCertNo,
|
||||
titleName: values.titleName,
|
||||
registerEngineerFlag: values.registerEngineerFlag ?? 2,
|
||||
publications: values.publications,
|
||||
abilityDeclaration: values.abilityDeclaration,
|
||||
workExperience: values.workExperience,
|
||||
proofMaterialUrl: resolveUploadFileIds(values.proofMaterials),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -280,6 +352,21 @@ export function fromStaffCertForm(values = {}) {
|
|||
|
||||
// ─── 机构资质证书 ───
|
||||
|
||||
/** 资质证书 enableFlag(1启用/2禁用) ↔ 前端 enableStatus(1启用/0禁用) */
|
||||
export function mapQualificationEnableStatus(flag) {
|
||||
return Number(flag) === 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
export function mapQualificationEnableFlag(status) {
|
||||
return Number(status) === 1 ? 1 : 2;
|
||||
}
|
||||
|
||||
/** 列表/表单统一判断:优先 enableFlag,兼容 enableStatus */
|
||||
export function isQualificationEnabled(record = {}) {
|
||||
const flag = record.enableFlag ?? record.enableStatus;
|
||||
return mapQualificationEnableStatus(flag) === 1;
|
||||
}
|
||||
|
||||
export function toQualificationForm(data = {}) {
|
||||
const certImgs = data.certImageUrl
|
||||
? [{ url: data.certImageUrl, fileName: data.certName }]
|
||||
|
|
@ -294,7 +381,8 @@ export function toQualificationForm(data = {}) {
|
|||
validStartDate: data.validStartDate,
|
||||
validEndDate: data.validEndDate,
|
||||
remark: data.remark ?? data.remarks,
|
||||
enableStatus: data.enableFlag,
|
||||
enableFlag: data.enableFlag,
|
||||
enableStatus: mapQualificationEnableStatus(data.enableFlag),
|
||||
issueDate: formatDate(data.issueDate),
|
||||
validStartDate: formatDate(data.validStartDate),
|
||||
validEndDate: formatDate(data.validEndDate),
|
||||
|
|
@ -319,17 +407,32 @@ export function fromQualificationForm(values = {}) {
|
|||
validEndDate: toApiDate(values.validEndDate ?? values.validDate?.[1]),
|
||||
certImageUrl,
|
||||
remark: values.remark,
|
||||
enableFlag: values.enableStatus ?? 1,
|
||||
enableFlag: mapQualificationEnableFlag(values.enableStatus),
|
||||
};
|
||||
}
|
||||
|
||||
// ─── 装备 ───
|
||||
|
||||
/** 装备 enableFlag(1启用/2禁用) ↔ 前端 enableStatus(1启用/0禁用) */
|
||||
export function mapEquipEnableStatus(flag) {
|
||||
return Number(flag) === 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
export function mapEquipEnableFlag(status) {
|
||||
return Number(status) === 1 ? 1 : 2;
|
||||
}
|
||||
|
||||
export function isEquipEnabled(record = {}) {
|
||||
const flag = record.enableFlag ?? record.enableStatus;
|
||||
return mapEquipEnableStatus(flag) === 1;
|
||||
}
|
||||
|
||||
export function toEquipForm(data = {}) {
|
||||
const instrumentType = data.instrumentTypeName ?? data.instrumentTypeCode;
|
||||
return {
|
||||
id: asId(data.id),
|
||||
instrumentType,
|
||||
instrumentCategory: instrumentType,
|
||||
deviceType: data.deviceTypeName ?? data.deviceTypeCode,
|
||||
deviceName: data.deviceName,
|
||||
model: data.deviceModel,
|
||||
|
|
@ -341,7 +444,8 @@ export function toEquipForm(data = {}) {
|
|||
calibrationInitialValue: data.calibrationInitValue,
|
||||
onSiteCalibrationType: data.fieldCalibrationTypeName ?? data.fieldCalibrationTypeCode,
|
||||
isDualChannel: data.dualChannelFlag,
|
||||
enableStatus: data.enableFlag,
|
||||
enableFlag: data.enableFlag,
|
||||
enableStatus: mapEquipEnableStatus(data.enableFlag),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -363,7 +467,7 @@ export function fromEquipForm(values = {}) {
|
|||
fieldCalibrationTypeName: values.onSiteCalibrationType,
|
||||
fieldCalibrationTypeCode: values.onSiteCalibrationType,
|
||||
dualChannelFlag: values.isDualChannel,
|
||||
enableFlag: values.enableStatus ?? 1,
|
||||
enableFlag: mapEquipEnableFlag(values.enableStatus),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,31 +11,69 @@ import {
|
|||
toPositionForm,
|
||||
} from "./adapter";
|
||||
import { apiGet } from "./http";
|
||||
import { getOrgInfoId, setOrgInfoId } from "./orgContext";
|
||||
import { clearOrgInfoId, getOrgInfoId, setOrgInfoId } from "./orgContext";
|
||||
|
||||
/** 机构信息管理页路径(无机构数据时唯一可访问页) */
|
||||
export const ORG_INFO_PAGE_PATH = "/certificate/container/EnterpriseInfo/OrgInfo";
|
||||
|
||||
let ensureOrgPromise = null;
|
||||
/** 最近一次 getInfo 转换结果,供机构信息页复用,避免重复请求 */
|
||||
let lastOrgInfoDetail = null;
|
||||
|
||||
/** 确保已缓存机构 id(全局只发起一次 getInfo) */
|
||||
export function ensureOrgContext() {
|
||||
const cached = getOrgInfoId();
|
||||
if (cached) {
|
||||
return Promise.resolve(cached);
|
||||
export function isOrgInfoPage(path = window.location.pathname) {
|
||||
return path === ORG_INFO_PAGE_PATH || path.startsWith(`${ORG_INFO_PAGE_PATH}/`);
|
||||
}
|
||||
|
||||
export function getOrgInfoDetail() {
|
||||
return lastOrgInfoDetail;
|
||||
}
|
||||
|
||||
export function setOrgInfoDetailCache(detail) {
|
||||
lastOrgInfoDetail = detail;
|
||||
}
|
||||
|
||||
function fetchOrgInfoContext() {
|
||||
return apiGet("/safety-eval/org-info/getInfo", {}, {}, { includeOrgContext: false })
|
||||
.then((res) => {
|
||||
lastOrgInfoDetail = fromSingleResponse(res, toOrgInfoForm);
|
||||
const id = lastOrgInfoDetail?.data?.id ?? res?.data?.id;
|
||||
if (id) {
|
||||
setOrgInfoId(id);
|
||||
return { hasOrg: true, orgInfoId: String(id), detail: lastOrgInfoDetail };
|
||||
}
|
||||
clearOrgInfoId();
|
||||
return { hasOrg: false, orgInfoId: null, detail: lastOrgInfoDetail };
|
||||
})
|
||||
.catch((err) => {
|
||||
console.warn("[ensureOrgContext] getInfo failed:", err);
|
||||
clearOrgInfoId();
|
||||
lastOrgInfoDetail = { success: false, data: null };
|
||||
return { hasOrg: false, orgInfoId: null, detail: lastOrgInfoDetail, networkError: true };
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 确保已缓存机构 id(子表分页/请求头 orgInfoId 依赖此值)
|
||||
* @param {{ force?: boolean }} options force=true 时忽略缓存并重新 getInfo(进入企业信息模块时使用)
|
||||
* @returns {Promise<{ hasOrg: boolean, orgInfoId: string|null, detail?: object, networkError?: boolean }>}
|
||||
*/
|
||||
export function ensureOrgContext(options = {}) {
|
||||
const { force = false } = options;
|
||||
|
||||
if (!force) {
|
||||
const cached = getOrgInfoId();
|
||||
if (cached) {
|
||||
return Promise.resolve({ hasOrg: true, orgInfoId: cached, detail: lastOrgInfoDetail });
|
||||
}
|
||||
}
|
||||
if (!ensureOrgPromise) {
|
||||
ensureOrgPromise = apiGet("/safety-eval/org-info/getInfo", {}, {}, { includeOrgContext: false })
|
||||
.then((res) => {
|
||||
const result = fromSingleResponse(res, toOrgInfoForm);
|
||||
const id = result?.data?.id ?? res?.data?.id;
|
||||
if (id) {
|
||||
setOrgInfoId(id);
|
||||
}
|
||||
return getOrgInfoId();
|
||||
})
|
||||
.catch(() => null)
|
||||
.finally(() => {
|
||||
ensureOrgPromise = null;
|
||||
});
|
||||
|
||||
if (ensureOrgPromise) {
|
||||
return ensureOrgPromise;
|
||||
}
|
||||
|
||||
ensureOrgPromise = fetchOrgInfoContext().finally(() => {
|
||||
ensureOrgPromise = null;
|
||||
});
|
||||
return ensureOrgPromise;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {
|
|||
fromEquipForm,
|
||||
fromPageResponse,
|
||||
fromSingleResponse,
|
||||
mapEquipEnableFlag,
|
||||
toEquipForm,
|
||||
toPageQuery,
|
||||
} from "../enterpriseInfo/adapter";
|
||||
|
|
@ -15,6 +16,9 @@ export const equipInfoList = declareRequest("equipInfoLoading", safePageResult(a
|
|||
deviceType: "deviceType",
|
||||
enableStatus: "enableFlag",
|
||||
});
|
||||
if (query.enableFlag !== undefined && query.enableFlag !== "") {
|
||||
query.enableFlag = mapEquipEnableFlag(query.enableFlag);
|
||||
}
|
||||
const res = await apiGet("/safety-eval/org-equipment/page", query);
|
||||
return fromPageResponse(res, toEquipForm);
|
||||
}));
|
||||
|
|
@ -39,9 +43,12 @@ export const equipInfoRemove = declareRequest("equipInfoLoading", safeAction(asy
|
|||
}));
|
||||
|
||||
export const equipInfoToggleStatus = declareRequest("equipInfoLoading", safeAction(async ({ id }) => {
|
||||
const detailRes = await apiGet("/safety-eval/org-equipment/get", { id });
|
||||
const current = toEquipForm(detailRes?.data || {});
|
||||
const nextStatus = current.enableStatus === 1 ? 0 : 1;
|
||||
const res = await apiPost("/safety-eval/org-equipment/modify", fromEquipForm({ ...current, id, enableStatus: nextStatus }));
|
||||
return fromSingleResponse(res, toEquipForm);
|
||||
const res = await apiGet("/safety-eval/org-equipment/get", { id });
|
||||
const data = res?.data || {};
|
||||
const nextFlag = Number(data.enableFlag) === 1 ? 2 : 1;
|
||||
return apiPost("/safety-eval/org-equipment/modify", {
|
||||
...data,
|
||||
id,
|
||||
enableFlag: nextFlag,
|
||||
});
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {
|
|||
toOrgInfoForm,
|
||||
} from "../enterpriseInfo/adapter";
|
||||
import { apiGet, apiPost, safeAction } from "../enterpriseInfo/http";
|
||||
import { setOrgInfoDetailCache } from "../enterpriseInfo/orgBootstrap";
|
||||
import { setOrgInfoId } from "../enterpriseInfo/orgContext";
|
||||
|
||||
function persistOrgInfoId(result, rawData) {
|
||||
|
|
@ -12,6 +13,7 @@ function persistOrgInfoId(result, rawData) {
|
|||
if (id) {
|
||||
setOrgInfoId(id);
|
||||
}
|
||||
setOrgInfoDetailCache(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,21 +34,21 @@ export const orgQualificationCertRemove = declareRequest("orgQualificationCertLo
|
|||
}));
|
||||
|
||||
export const orgQualificationCertDisable = declareRequest("orgQualificationCertLoading", safeAction(async ({ id }) => {
|
||||
const detailRes = await apiGet("/safety-eval/org-qualification/get", { id });
|
||||
const payload = fromQualificationForm({
|
||||
...toQualificationForm(detailRes?.data || {}),
|
||||
const res = await apiGet("/safety-eval/org-qualification/get", { id });
|
||||
const data = res?.data || {};
|
||||
return apiPost("/safety-eval/org-qualification/modify", {
|
||||
...data,
|
||||
id,
|
||||
enableStatus: 0,
|
||||
enableFlag: 2,
|
||||
});
|
||||
return apiPost("/safety-eval/org-qualification/modify", payload);
|
||||
}));
|
||||
|
||||
export const orgQualificationCertEnable = declareRequest("orgQualificationCertLoading", safeAction(async ({ id }) => {
|
||||
const detailRes = await apiGet("/safety-eval/org-qualification/get", { id });
|
||||
const payload = fromQualificationForm({
|
||||
...toQualificationForm(detailRes?.data || {}),
|
||||
const res = await apiGet("/safety-eval/org-qualification/get", { id });
|
||||
const data = res?.data || {};
|
||||
return apiPost("/safety-eval/org-qualification/modify", {
|
||||
...data,
|
||||
id,
|
||||
enableStatus: 1,
|
||||
enableFlag: 1,
|
||||
});
|
||||
return apiPost("/safety-eval/org-qualification/modify", payload);
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
/** 企业信息管理模块下拉选项 */
|
||||
|
||||
/** 重庆市辖区(区/县) */
|
||||
export const CHONGQING_DISTRICTS = [
|
||||
"万州区", "涪陵区", "渝中区", "大渡口区", "江北区", "沙坪坝区", "九龙坡区", "南岸区",
|
||||
"北碚区", "綦江区", "大足区", "渝北区", "巴南区", "黔江区", "长寿区", "江津区",
|
||||
"合川区", "永川区", "南川区", "璧山区", "铜梁区", "潼南区", "荣昌区", "开州区",
|
||||
"梁平区", "武隆区", "城口县", "丰都县", "垫江县", "忠县", "云阳县", "奉节县",
|
||||
"巫山县", "巫溪县", "石柱土家族自治县", "秀山土家族苗族自治县", "酉阳土家族苗族自治县",
|
||||
"彭水苗族土家族自治县",
|
||||
].map((label) => ({ label, value: label }));
|
||||
|
||||
/** 企业状态 */
|
||||
export const ENTERPRISE_STATUS_OPTIONS = [
|
||||
{ label: "正常", value: "正常" },
|
||||
{ label: "停业", value: "停业" },
|
||||
{ label: "注销", value: "注销" },
|
||||
];
|
||||
|
||||
/** 企业规模 */
|
||||
export const ENTERPRISE_SCALE_OPTIONS = [
|
||||
{ label: "大", value: "大" },
|
||||
{ label: "中", value: "中" },
|
||||
{ label: "小", value: "小" },
|
||||
{ label: "微型", value: "微型" },
|
||||
];
|
||||
|
||||
/** 备案类型 */
|
||||
export const FILING_TYPE_OPTIONS = [
|
||||
{ label: "审核备案", value: "审核备案" },
|
||||
{ label: "确认备案", value: "确认备案" },
|
||||
];
|
||||
|
||||
/** 备案状态(机构信息) */
|
||||
export const FILING_RECORD_STATUS_OPTIONS = [
|
||||
{ label: "已备案", value: "已备案" },
|
||||
{ label: "未备案", value: "未备案" },
|
||||
];
|
||||
|
||||
/** 资质范围 / 证照类型(行业) */
|
||||
export const QUALIFICATION_INDUSTRY_OPTIONS = [
|
||||
{ label: "煤炭开采业", value: "煤炭开采业" },
|
||||
{ label: "金属、非金属矿及其他矿采选业", value: "金属、非金属矿及其他矿采选业" },
|
||||
{ label: "陆地石油和天然气开采业", value: "陆地石油和天然气开采业" },
|
||||
{ label: "陆上油气管道运输业", value: "陆上油气管道运输业" },
|
||||
{ label: "石油加工业,化学原料、化学品及医药制造业", value: "石油加工业,化学原料、化学品及医药制造业" },
|
||||
{ label: "烟花爆竹制造业", value: "烟花爆竹制造业" },
|
||||
{ label: "金属冶炼", value: "金属冶炼" },
|
||||
];
|
||||
|
||||
/** 人员类型 */
|
||||
export const PERSON_TYPE_OPTIONS = [
|
||||
{ label: "基础人员", value: "基础人员" },
|
||||
{ label: "专职评价师", value: "专职评价师" },
|
||||
];
|
||||
|
||||
/** 职业等级 */
|
||||
export const PROFESSIONAL_LEVEL_OPTIONS = [
|
||||
{
|
||||
label: "三级安全评价师(对应职业技能等级三级 / 高级工,入门级)",
|
||||
value: "三级安全评价师(对应职业技能等级三级 / 高级工,入门级)",
|
||||
},
|
||||
{
|
||||
label: "二级安全评价师(对应职业技能等级二级 / 技师,中级)",
|
||||
value: "二级安全评价师(对应职业技能等级二级 / 技师,中级)",
|
||||
},
|
||||
{
|
||||
label: "一级安全评价师(对应职业技能等级一级 / 高级技师,最高级)",
|
||||
value: "一级安全评价师(对应职业技能等级一级 / 高级技师,最高级)",
|
||||
},
|
||||
];
|
||||
|
||||
/** 学历类型 */
|
||||
export const EDUCATION_TYPE_OPTIONS = [
|
||||
{ label: "全日制", value: "全日制" },
|
||||
{ label: "在职教育", value: "在职教育" },
|
||||
];
|
||||
|
||||
/** 学历层次 */
|
||||
export const EDUCATION_LEVEL_OPTIONS = [
|
||||
{ label: "专科", value: "专科" },
|
||||
{ label: "本科", value: "本科" },
|
||||
{ label: "硕士", value: "硕士" },
|
||||
{ label: "博士", value: "博士" },
|
||||
];
|
||||
|
||||
/** 是否注册安全工程师 */
|
||||
export const REGISTER_ENGINEER_OPTIONS = [
|
||||
{ label: "是", value: 1 },
|
||||
{ label: "否", value: 2 },
|
||||
];
|
||||
|
|
@ -8,11 +8,11 @@ import Table from "zy-react-library/components/Table";
|
|||
import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender";
|
||||
import useTable from "zy-react-library/hooks/useTable";
|
||||
import { NS_EQUIP_INFO } from "~/enumerate/namespace";
|
||||
import { isEquipEnabled } from "~/api/enterpriseInfo/adapter";
|
||||
import { safeListRequest, safeRequest } from "~/utils";
|
||||
import { positiveNumberRule } from "~/utils/validators";
|
||||
import PageHeader from "../components/PageHeader";
|
||||
|
||||
const ENABLE_STATUS = { 1: "启用", 0: "禁用" };
|
||||
const DUAL_CHANNEL = { 1: "是", 0: "否" };
|
||||
|
||||
function EquipInfoPage(props) {
|
||||
|
|
@ -43,17 +43,21 @@ function EquipInfoPage(props) {
|
|||
});
|
||||
};
|
||||
|
||||
const onToggleStatus = (id, enableStatus) => {
|
||||
const onToggleStatus = (id, record) => {
|
||||
const enabled = isEquipEnabled(record);
|
||||
Modal.confirm({
|
||||
title: "提示",
|
||||
content: enableStatus === 1 ? "是否停用" : "是否启用",
|
||||
content: enabled ? "是否停用" : "是否启用",
|
||||
okText: "是",
|
||||
cancelText: "否",
|
||||
onOk: async () => {
|
||||
const res = await props.equipInfoToggleStatus({ id });
|
||||
if (res?.success !== false) {
|
||||
message.success("操作成功");
|
||||
getData();
|
||||
await getData();
|
||||
}
|
||||
else {
|
||||
message.error(res?.message || "操作失败");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -75,12 +79,13 @@ function EquipInfoPage(props) {
|
|||
name: "enableStatus",
|
||||
label: "设备状态",
|
||||
render: FORM_ITEM_RENDER_ENUM.SELECT,
|
||||
options: Object.entries(ENABLE_STATUS).map(([value, label]) => ({ label, value: Number(value) })),
|
||||
options: [{ label: "启用", value: 1 }, { label: "禁用", value: 0 }],
|
||||
},
|
||||
]}
|
||||
onFinish={getData}
|
||||
/>
|
||||
<Table
|
||||
{...tableProps}
|
||||
toolBarRender={() => (
|
||||
<Button
|
||||
type="primary"
|
||||
|
|
@ -103,8 +108,8 @@ function EquipInfoPage(props) {
|
|||
{ title: "校准初值", dataIndex: "calibrationInitialValue" },
|
||||
{
|
||||
title: "设备状态",
|
||||
dataIndex: "enableStatus",
|
||||
render: (v) => ENABLE_STATUS[v] ?? "-",
|
||||
width: 90,
|
||||
render: (_, record) => (isEquipEnabled(record) ? "启用" : "禁用"),
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
|
|
@ -117,15 +122,14 @@ function EquipInfoPage(props) {
|
|||
<Button type="link" onClick={() => { setCurrentId(record.id); setFormModalOpen(true); }}>
|
||||
编辑
|
||||
</Button>
|
||||
<Button type="link" onClick={() => onToggleStatus(record.id, record.enableStatus)}>
|
||||
{record.enableStatus === 1 ? "禁用" : "启用"}
|
||||
<Button type="link" onClick={() => onToggleStatus(record.id, record)}>
|
||||
{isEquipEnabled(record) ? "禁用" : "启用"}
|
||||
</Button>
|
||||
<Button danger type="link" onClick={() => onDelete(record.id)}>删除</Button>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
{...tableProps}
|
||||
/>
|
||||
|
||||
{formModalOpen && (
|
||||
|
|
|
|||
|
|
@ -3,9 +3,20 @@ import { Button, Form, message, Space } from "antd";
|
|||
import { useEffect, useState } from "react";
|
||||
import FormBuilder from "zy-react-library/components/FormBuilder";
|
||||
import Page from "zy-react-library/components/Page";
|
||||
import Upload from "zy-react-library/components/Upload";
|
||||
import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender";
|
||||
import { getOrgInfoDetail } from "~/api/enterpriseInfo/orgBootstrap";
|
||||
import PageHeader from "../components/PageHeader";
|
||||
import { NS_ORG_INFO } from "~/enumerate/namespace";
|
||||
import {
|
||||
CHONGQING_DISTRICTS,
|
||||
ENTERPRISE_SCALE_OPTIONS,
|
||||
ENTERPRISE_STATUS_OPTIONS,
|
||||
FILING_RECORD_STATUS_OPTIONS,
|
||||
FILING_TYPE_OPTIONS,
|
||||
} from "~/enumerate/enterpriseOptions";
|
||||
import { formSelectField } from "~/utils/enterpriseForm";
|
||||
import { mockUploadFileList } from "~/utils/mockUpload";
|
||||
import {
|
||||
creditCodeRule,
|
||||
latitudeRule,
|
||||
|
|
@ -28,7 +39,7 @@ function OrgInfoPage(props) {
|
|||
|
||||
const loadDetail = async () => {
|
||||
try {
|
||||
const res = await props.orgInfoGet().catch(() => null);
|
||||
const res = getOrgInfoDetail();
|
||||
if (res?.data?.id) {
|
||||
setDetail(res.data);
|
||||
form.setFieldsValue(res.data);
|
||||
|
|
@ -39,6 +50,11 @@ function OrgInfoPage(props) {
|
|||
setDetail({});
|
||||
setHasExistingData(false);
|
||||
setEditing(true);
|
||||
form.setFieldsValue({
|
||||
filingType: "确认备案",
|
||||
filingRecordStatus: "未备案",
|
||||
attachments: mockUploadFileList("资质申请书.pdf"),
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
|
|
@ -118,9 +134,10 @@ function OrgInfoPage(props) {
|
|||
rules: [{ required: true, message: "请输入安全生产监管行业类别" }],
|
||||
},
|
||||
{
|
||||
name: "regionCountyName",
|
||||
label: "所属(县、区)",
|
||||
rules: [{ required: true, message: "请输入所属县区" }],
|
||||
...formSelectField("regionCountyName", "属地", CHONGQING_DISTRICTS, {
|
||||
rules: [{ required: true, message: "请选择属地" }],
|
||||
colProps: { span: 12 },
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "regionStreetName",
|
||||
|
|
@ -259,6 +276,18 @@ function OrgInfoPage(props) {
|
|||
componentProps: { ...numberFieldProps, min: 0, precision: 0 },
|
||||
rules: [nonNegativeIntegerRule("注册安全工程师数量", false)],
|
||||
},
|
||||
formSelectField("enterpriseStatus", "企业状态", ENTERPRISE_STATUS_OPTIONS, { required: false }),
|
||||
formSelectField("enterpriseScale", "企业规模", ENTERPRISE_SCALE_OPTIONS, { required: false }),
|
||||
formSelectField("filingType", "备案类型", FILING_TYPE_OPTIONS, { required: false }),
|
||||
formSelectField("filingRecordStatus", "备案状态", FILING_RECORD_STATUS_OPTIONS, { required: false }),
|
||||
{
|
||||
name: "attachments",
|
||||
label: "上传附件",
|
||||
required: false,
|
||||
render: (
|
||||
<Upload maxCount={5} />
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -5,8 +5,17 @@ import AddIcon from "zy-react-library/components/Icon/AddIcon";
|
|||
import Page from "zy-react-library/components/Page";
|
||||
import Search from "zy-react-library/components/Search";
|
||||
import Table from "zy-react-library/components/Table";
|
||||
import Upload from "zy-react-library/components/Upload";
|
||||
import useTable from "zy-react-library/hooks/useTable";
|
||||
import { NS_ORG_DEPARTMENT, NS_ORG_POSITION, NS_STAFF_INFO } from "~/enumerate/namespace";
|
||||
import {
|
||||
EDUCATION_LEVEL_OPTIONS,
|
||||
EDUCATION_TYPE_OPTIONS,
|
||||
PERSON_TYPE_OPTIONS,
|
||||
PROFESSIONAL_LEVEL_OPTIONS,
|
||||
QUALIFICATION_INDUSTRY_OPTIONS,
|
||||
REGISTER_ENGINEER_OPTIONS,
|
||||
} from "~/enumerate/enterpriseOptions";
|
||||
import { ensureOrgContext, fetchOrgDepartmentPage, fetchOrgPositionPage } from "~/api/enterpriseInfo/orgBootstrap";
|
||||
import { asId, sameId } from "~/api/enterpriseInfo/idUtil";
|
||||
import { getBirthDateFromIdCard, safeListRequest, safeRequest } from "~/utils";
|
||||
|
|
@ -16,6 +25,7 @@ import { idCardRule, mobileRule } from "~/utils/validators";
|
|||
import PageHeader from "../../components/PageHeader";
|
||||
|
||||
const GENDER_MAP = { 1: "男", 2: "女" };
|
||||
const REGISTER_ENGINEER_MAP = { 1: "是", 2: "否" };
|
||||
|
||||
function mapPositionOptions(list = []) {
|
||||
return list.map((p) => ({
|
||||
|
|
@ -208,15 +218,15 @@ function StaffFormModal({
|
|||
const requestDetailsRef = useRef(requestDetails);
|
||||
requestDetailsRef.current = requestDetails;
|
||||
|
||||
const loadPositionsByDept = async (deptId) => {
|
||||
const loadPositionsByDept = async (deptId, currentStaff = null) => {
|
||||
const id = asId(deptId);
|
||||
if (!id) {
|
||||
setDeptPositionOptions([]);
|
||||
return;
|
||||
return [];
|
||||
}
|
||||
const key = id;
|
||||
if (inflightDeptRef.current === key) {
|
||||
return;
|
||||
return deptPositionOptions;
|
||||
}
|
||||
inflightDeptRef.current = key;
|
||||
setPositionLoading(true);
|
||||
|
|
@ -232,11 +242,18 @@ function StaffFormModal({
|
|||
const allRes = await fetchOrgPositionPage({ pageIndex: 1, pageSize: 500 });
|
||||
options = mapPositionOptions(allRes?.data).filter((p) => sameId(p.deptId, id));
|
||||
}
|
||||
const positionId = asId(currentStaff?.positionId);
|
||||
const positionName = currentStaff?.positionName;
|
||||
if (positionId && positionName && !options.some((item) => sameId(item.value, positionId))) {
|
||||
options = [{ label: positionName, value: positionId, deptId: id }, ...options];
|
||||
}
|
||||
setDeptPositionOptions(options);
|
||||
return options;
|
||||
}
|
||||
catch (err) {
|
||||
console.warn("[PersonnelInfo] load positions by dept failed:", err);
|
||||
setDeptPositionOptions([]);
|
||||
return [];
|
||||
}
|
||||
finally {
|
||||
if (inflightDeptRef.current === key) {
|
||||
|
|
@ -251,6 +268,10 @@ function StaffFormModal({
|
|||
if (!currentId) {
|
||||
form.resetFields();
|
||||
setDeptPositionOptions([]);
|
||||
form.setFieldsValue({
|
||||
personType: "基础人员",
|
||||
registerEngineerFlag: 2,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!open) {
|
||||
|
|
@ -265,13 +286,19 @@ function StaffFormModal({
|
|||
}
|
||||
let cancelled = false;
|
||||
setDetailLoading(true);
|
||||
safeRequest(requestDetailsRef.current, { id: currentId }).then((res) => {
|
||||
safeRequest(requestDetailsRef.current, { id: currentId }).then(async (res) => {
|
||||
if (!cancelled && res?.data) {
|
||||
form.setFieldsValue({
|
||||
...res.data,
|
||||
birthDate: toDayjs(res.data.birthDate),
|
||||
});
|
||||
loadPositionsByDept(res.data.deptId);
|
||||
const data = res.data;
|
||||
await loadPositionsByDept(data.deptId, data);
|
||||
if (!cancelled) {
|
||||
form.setFieldsValue({
|
||||
...data,
|
||||
deptId: asId(data.deptId),
|
||||
positionId: asId(data.positionId),
|
||||
birthDate: toDayjs(data.birthDate),
|
||||
proofMaterials: data.proofMaterials?.length ? data.proofMaterials : [],
|
||||
});
|
||||
}
|
||||
}
|
||||
}).finally(() => {
|
||||
if (!cancelled) {
|
||||
|
|
@ -389,8 +416,63 @@ function StaffFormModal({
|
|||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="education" label="学历">
|
||||
<Input placeholder="请输入学历" />
|
||||
<Form.Item name="personType" label="人员类型" initialValue="基础人员">
|
||||
<Select placeholder="请选择人员类型" options={PERSON_TYPE_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="qualScope" label="资质范围">
|
||||
<Select placeholder="请选择资质范围" allowClear options={QUALIFICATION_INDUSTRY_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="professionalLevel" label="职业等级">
|
||||
<Select placeholder="请选择职业等级" allowClear options={PROFESSIONAL_LEVEL_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="evaluatorCertNo" label="证书编号">
|
||||
<Input placeholder="请输入安全评价师证书编号" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="educationType" label="学历类型">
|
||||
<Select placeholder="请选择学历类型" allowClear options={EDUCATION_TYPE_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="educationLevel" label="学历层次">
|
||||
<Select placeholder="请选择学历层次" allowClear options={EDUCATION_LEVEL_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="titleName" label="职称">
|
||||
<Input placeholder="请输入职称" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="registerEngineerFlag" label="是否注册安全工程师" initialValue={2}>
|
||||
<Select placeholder="请选择" options={REGISTER_ENGINEER_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.Item name="publications" label="出版学术专著、专利、获奖、发表学术论文等">
|
||||
<Input.TextArea rows={2} placeholder="请输入" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.Item name="abilityDeclaration" label="自我申报的专业能力及认定方式">
|
||||
<Input.TextArea rows={2} placeholder="请输入" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.Item name="workExperience" label="主要学习工作经历">
|
||||
<Input.TextArea rows={3} placeholder="请输入" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.Item name="proofMaterials" label="申报专业能力证明材料">
|
||||
<Upload maxCount={5} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
|
|
@ -462,12 +544,34 @@ function StaffViewModal({ open, currentId, requestDetails, onCancel }) {
|
|||
<Descriptions.Item label="账号">{info.account}</Descriptions.Item>
|
||||
<Descriptions.Item label="部门">{info.deptName}</Descriptions.Item>
|
||||
<Descriptions.Item label="岗位">{info.positionName}</Descriptions.Item>
|
||||
<Descriptions.Item label="人员类型">{info.personType || "基础人员"}</Descriptions.Item>
|
||||
<Descriptions.Item label="资质范围">{info.qualScope || "-"}</Descriptions.Item>
|
||||
<Descriptions.Item label="职业等级">{info.professionalLevel || "-"}</Descriptions.Item>
|
||||
<Descriptions.Item label="证书编号">{info.evaluatorCertNo || "-"}</Descriptions.Item>
|
||||
<Descriptions.Item label="学历类型">{info.educationType || "-"}</Descriptions.Item>
|
||||
<Descriptions.Item label="学历层次">{info.educationLevel || "-"}</Descriptions.Item>
|
||||
<Descriptions.Item label="职称">{info.titleName || "-"}</Descriptions.Item>
|
||||
<Descriptions.Item label="是否注册安全工程师">
|
||||
{REGISTER_ENGINEER_MAP[info.registerEngineerFlag] ?? "-"}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="身份证号">{info.idCardNo}</Descriptions.Item>
|
||||
<Descriptions.Item label="学历">{info.education}</Descriptions.Item>
|
||||
<Descriptions.Item label="学历">{info.education || "-"}</Descriptions.Item>
|
||||
<Descriptions.Item label="现住地址" span={2}>{info.homeAddress}</Descriptions.Item>
|
||||
<Descriptions.Item label="办公地址" span={2}>{info.officeAddress}</Descriptions.Item>
|
||||
<Descriptions.Item label="毕业院校">{info.graduateSchool}</Descriptions.Item>
|
||||
<Descriptions.Item label="专业">{info.major}</Descriptions.Item>
|
||||
<Descriptions.Item label="出版学术专著、专利、获奖、发表学术论文等" span={2}>
|
||||
{info.publications || "-"}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="自我申报的专业能力及认定方式" span={2}>
|
||||
{info.abilityDeclaration || "-"}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="主要学习工作经历" span={2}>
|
||||
{info.workExperience || "-"}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="申报专业能力证明材料" span={2}>
|
||||
{(info.proofMaterials || []).map((file) => file.name || file.fileName).join("、") || "-"}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Modal>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender";
|
|||
import useGetFile from "zy-react-library/hooks/useGetFile";
|
||||
import useTable from "zy-react-library/hooks/useTable";
|
||||
import { NS_ORG_QUALIFICATION_CERT } from "~/enumerate/namespace";
|
||||
import { QUALIFICATION_INDUSTRY_OPTIONS } from "~/enumerate/enterpriseOptions";
|
||||
import { formSelectField } from "~/utils/enterpriseForm";
|
||||
import { isQualificationEnabled } from "~/api/enterpriseInfo/adapter";
|
||||
import { safeGetFiles, safeListRequest, safeRequest } from "~/utils";
|
||||
import { toDayjs } from "~/utils/dateFormat";
|
||||
import { mockUploadFileList, resolveUploadFileId } from "~/utils/mockUpload";
|
||||
|
|
@ -59,7 +62,10 @@ function QualificationCertPage(props) {
|
|||
const res = await props.orgQualificationCertDisable({ id });
|
||||
if (res?.success !== false) {
|
||||
message.success("操作成功");
|
||||
getData();
|
||||
await getData();
|
||||
}
|
||||
else {
|
||||
message.error(res?.message || "操作失败");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -75,7 +81,10 @@ function QualificationCertPage(props) {
|
|||
const res = await props.orgQualificationCertEnable({ id });
|
||||
if (res?.success !== false) {
|
||||
message.success("操作成功");
|
||||
getData();
|
||||
await getData();
|
||||
}
|
||||
else {
|
||||
message.error(res?.message || "操作失败");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -100,6 +109,7 @@ function QualificationCertPage(props) {
|
|||
onFinish={getData}
|
||||
/>
|
||||
<Table
|
||||
{...tableProps}
|
||||
toolBarRender={() => (
|
||||
<Button
|
||||
type="primary"
|
||||
|
|
@ -123,9 +133,8 @@ function QualificationCertPage(props) {
|
|||
{ title: "证书编号", dataIndex: "certNo" },
|
||||
{
|
||||
title: "状态",
|
||||
dataIndex: "enableStatus",
|
||||
width: 80,
|
||||
render: (v) => (v === 0 ? "禁用" : "启用"),
|
||||
render: (_, record) => (isQualificationEnabled(record) ? "启用" : "禁用"),
|
||||
},
|
||||
{
|
||||
title: "照片",
|
||||
|
|
@ -162,20 +171,19 @@ function QualificationCertPage(props) {
|
|||
<Button danger type="link" onClick={() => onDelete(record.id)}>
|
||||
删除
|
||||
</Button>
|
||||
{record.enableStatus === 0 ? (
|
||||
<Button type="link" onClick={() => onEnable(record.id)}>
|
||||
启用
|
||||
</Button>
|
||||
) : (
|
||||
{isQualificationEnabled(record) ? (
|
||||
<Button type="link" onClick={() => onDisable(record.id)}>
|
||||
禁用
|
||||
</Button>
|
||||
) : (
|
||||
<Button type="link" onClick={() => onEnable(record.id)}>
|
||||
启用
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
{...tableProps}
|
||||
/>
|
||||
|
||||
{addModalOpen && (
|
||||
|
|
@ -316,11 +324,10 @@ function CertFormModal({
|
|||
showActionButtons={false}
|
||||
onFinish={handleSubmit}
|
||||
options={[
|
||||
{
|
||||
name: "certType",
|
||||
label: "证照类型",
|
||||
formSelectField("certType", "证照类型", QUALIFICATION_INDUSTRY_OPTIONS, {
|
||||
rules: [{ required: true, message: "请选择证照类型" }],
|
||||
},
|
||||
colProps: { span: 24 },
|
||||
}),
|
||||
{
|
||||
name: "certName",
|
||||
label: "证书名称",
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ function AddModal({ open, staffOptions, requestAdd, onCancel, onSuccess }) {
|
|||
const handleSubmit = async (values) => {
|
||||
try {
|
||||
setSubmitting(true);
|
||||
const staff = staffOptions.find((s) => String(s.value) === String(values.personnelId));
|
||||
values.applicantName = staff?.staffName || values.applicantName;
|
||||
values.attachmentId = resolveUploadFileId(values.resignReport);
|
||||
const res = await requestAdd(values);
|
||||
if (res?.success !== false) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,54 @@
|
|||
import { useEffect } from "react";
|
||||
import { ensureOrgContext } from "~/api/enterpriseInfo/orgBootstrap";
|
||||
import { message, Spin } from "antd";
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
ensureOrgContext,
|
||||
isOrgInfoPage,
|
||||
ORG_INFO_PAGE_PATH,
|
||||
} from "~/api/enterpriseInfo/orgBootstrap";
|
||||
|
||||
/** 进入企业信息模块时缓存机构 id,供子表分页携带 orgId */
|
||||
/**
|
||||
* 企业信息模块入口:进入时 getInfo,有机构则缓存 orgInfoId;无机构则仅允许访问机构信息管理页。
|
||||
*/
|
||||
function EnterpriseInfo(props) {
|
||||
const [checking, setChecking] = useState(true);
|
||||
const onOrgInfoPage = isOrgInfoPage();
|
||||
|
||||
useEffect(() => {
|
||||
ensureOrgContext().catch(() => null);
|
||||
}, []);
|
||||
let cancelled = false;
|
||||
|
||||
ensureOrgContext({ force: true })
|
||||
.then((ctx) => {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
if (ctx?.networkError && onOrgInfoPage) {
|
||||
message.warning("机构信息加载失败,请确认后端服务已启动");
|
||||
}
|
||||
if (!ctx?.hasOrg && !onOrgInfoPage) {
|
||||
message.warning("请先完善机构信息");
|
||||
window.location.replace(ORG_INFO_PAGE_PATH);
|
||||
return;
|
||||
}
|
||||
setChecking(false);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.warn("[EnterpriseInfo] ensureOrgContext failed:", err);
|
||||
if (!cancelled) {
|
||||
if (onOrgInfoPage) {
|
||||
message.warning("机构信息加载失败,请确认后端服务已启动");
|
||||
}
|
||||
setChecking(false);
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [onOrgInfoPage]);
|
||||
|
||||
if (checking) {
|
||||
return <Spin fullscreen tip="正在加载机构信息..." />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,33 @@ export function resolveUploadFileId(_files) {
|
|||
return DEFAULT_UPLOAD_FILE_URL;
|
||||
}
|
||||
|
||||
/** 多附件:逗号拼接 URL */
|
||||
export function resolveUploadFileIds(files) {
|
||||
if (!files?.length) {
|
||||
return undefined;
|
||||
}
|
||||
const urls = files.map((file) => file?.url || file?.response?.url).filter(Boolean);
|
||||
if (!urls.length) {
|
||||
return DEFAULT_UPLOAD_FILE_URL;
|
||||
}
|
||||
return urls.join(",");
|
||||
}
|
||||
|
||||
export function parseUploadFileList(urls, defaultName = "附件.pdf") {
|
||||
if (!urls) {
|
||||
return [];
|
||||
}
|
||||
return String(urls)
|
||||
.split(",")
|
||||
.map((url) => url.trim())
|
||||
.filter(Boolean)
|
||||
.map((url, index) => ({
|
||||
name: `${defaultName.replace(".pdf", "")}${index + 1}.pdf`,
|
||||
fileName: `${defaultName.replace(".pdf", "")}${index + 1}.pdf`,
|
||||
url,
|
||||
}));
|
||||
}
|
||||
|
||||
export function mockUploadFileList(name = "附件.pdf") {
|
||||
return [{ name, fileName: name, url: DEFAULT_UPLOAD_FILE_URL }];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue