349 lines
13 KiB
JavaScript
349 lines
13 KiB
JavaScript
"use strict";
|
||
const components_hazardDetail_hazardDetail = require("./hazardDetail.js");
|
||
const PENDING_LABEL = "待处理";
|
||
const isNodeCompleted = (node) => (node == null ? void 0 : node.completed) !== false;
|
||
const resolveFieldDisplay = (value, completed = true) => {
|
||
if (value != null && value !== "")
|
||
return value;
|
||
return completed ? "-" : PENDING_LABEL;
|
||
};
|
||
const PROCESS_NODE_TYPES = {
|
||
ADD: "add",
|
||
ASSIGN: "assign",
|
||
RECTIFY: "rectify",
|
||
RECTIFY_ASSIGN: "rectifyAssign",
|
||
VERIFY: "verify",
|
||
VERIFY_SUB: "verify_sub",
|
||
WRITEOFF_APPLY: "writeoff_apply",
|
||
WRITEOFF_APPROVE: "writeoff_approve",
|
||
WRITEOFF_SUB: "writeoff_sub",
|
||
APPROVAL: "approval"
|
||
};
|
||
const SUB_TYPE_SUFFIX_MAP = {
|
||
verify: "验收",
|
||
writeoff: "销号"
|
||
};
|
||
const TITLE_PREFIX_MAP = {
|
||
add: "提交",
|
||
assign: "交办",
|
||
rectify: "整改",
|
||
rectifyAssign: "交办",
|
||
verify: "验收",
|
||
verify_sub: "审批",
|
||
writeoff_apply: "销号申请",
|
||
writeoff_approve: "销号审核",
|
||
writeoff_sub: "审批"
|
||
};
|
||
const APPROVAL_TASK_KEY_ICON = {
|
||
department_review: "bumenshenpi",
|
||
section_chief_review: "fenguanshenpi",
|
||
supervising_executive_review: "fenguanshenpi",
|
||
supervising_leader_review_1: "zhuguanshenpi",
|
||
supervising_leader_review_2: "zhuguanshenpi"
|
||
};
|
||
const NODE_TYPE_ICON = {
|
||
add: "tijiao",
|
||
assign: "jiaoban",
|
||
rectifyAssign: "jiaoban",
|
||
rectify: "zhenggai",
|
||
verify: "yanshou",
|
||
writeoff_apply: "xiaohao",
|
||
writeoff_approve: "xiaohao"
|
||
};
|
||
const resolveTaskKey = (node) => {
|
||
var _a;
|
||
return (node == null ? void 0 : node.taskKey) || ((_a = node == null ? void 0 : node.subProcessApprovalInfo) == null ? void 0 : _a.taskKey) || "";
|
||
};
|
||
const resolveCurrentHandlerName = (currentHandler) => {
|
||
if (!currentHandler || typeof currentHandler !== "object") {
|
||
return "";
|
||
}
|
||
return toDisplayText(currentHandler.handlerNames) || toDisplayText(currentHandler.assigneeName) || "";
|
||
};
|
||
const toSafeObject = (value) => value && typeof value === "object" ? value : {};
|
||
const toDisplayText = (value) => {
|
||
if (value == null || value === "")
|
||
return "";
|
||
return value;
|
||
};
|
||
const getProcessStepDisplayName = (node) => {
|
||
var _a;
|
||
if (!node)
|
||
return "";
|
||
const nodeType = node.nodeType;
|
||
if (nodeType === "verify_sub" || nodeType === "writeoff_sub") {
|
||
const subType = (_a = node.subProcessApprovalInfo) == null ? void 0 : _a.subType;
|
||
const suffix = SUB_TYPE_SUFFIX_MAP[subType];
|
||
return suffix ? `${node.nodeName}(${suffix})` : node.nodeName;
|
||
}
|
||
return node.nodeName || "";
|
||
};
|
||
const getProcessStepIconPath = (item, active = false) => {
|
||
const type = item == null ? void 0 : item.type;
|
||
const taskKey = (item == null ? void 0 : item.taskKey) || "";
|
||
const state = active ? "selected" : "unselected";
|
||
if (type === PROCESS_NODE_TYPES.APPROVAL) {
|
||
const iconBase = APPROVAL_TASK_KEY_ICON[taskKey] || "bumenshenpi";
|
||
return `/static/yinhuan_detail/${iconBase}_${state}.png`;
|
||
}
|
||
const base = NODE_TYPE_ICON[item == null ? void 0 : item.rawType] || NODE_TYPE_ICON[type] || "tijiao";
|
||
if (base === "zhenggai") {
|
||
return active ? "/static/yinhuan_detail/zhenggai_selected.png" : "/static/yinhuan_detail/zhenggai__unselected.png";
|
||
}
|
||
return `/static/yinhuan_detail/${base}__${state}.png`;
|
||
};
|
||
const resolveOperator = (node, nodeType) => {
|
||
var _a, _b, _c, _d, _e;
|
||
const completed = isNodeCompleted(node);
|
||
const fallback = completed ? "-" : "";
|
||
if (nodeType === PROCESS_NODE_TYPES.ADD) {
|
||
return ((_a = node.hazardInfo) == null ? void 0 : _a.reporterName) || fallback;
|
||
}
|
||
if (nodeType === PROCESS_NODE_TYPES.ASSIGN) {
|
||
return ((_b = node.assignInfo) == null ? void 0 : _b.assignerName) || fallback;
|
||
}
|
||
if (nodeType === PROCESS_NODE_TYPES.RECTIFY) {
|
||
return ((_c = node.rectifyInfo) == null ? void 0 : _c.rectifierName) || fallback;
|
||
}
|
||
if (nodeType === PROCESS_NODE_TYPES.VERIFY || nodeType === PROCESS_NODE_TYPES.WRITEOFF_APPROVE) {
|
||
return ((_d = node.verifyInfo) == null ? void 0 : _d.verifierName) || fallback;
|
||
}
|
||
if (nodeType === PROCESS_NODE_TYPES.WRITEOFF_APPLY) {
|
||
return ((_e = node.writeOffApplyInfo) == null ? void 0 : _e.applicantName) || fallback;
|
||
}
|
||
if (nodeType === PROCESS_NODE_TYPES.APPROVAL) {
|
||
const info = node.subProcessApprovalInfo || {};
|
||
return info.operatorName || info.assigneeName || fallback;
|
||
}
|
||
return fallback;
|
||
};
|
||
const resolveTime = (node, nodeType) => {
|
||
var _a, _b, _c, _d, _e, _f;
|
||
const completed = isNodeCompleted(node);
|
||
const fallback = completed ? "-" : "";
|
||
if (nodeType === PROCESS_NODE_TYPES.ADD) {
|
||
return ((_a = node.hazardInfo) == null ? void 0 : _a.createdAt) || node.completedAt || node.occurredAt || fallback;
|
||
}
|
||
if (nodeType === PROCESS_NODE_TYPES.ASSIGN) {
|
||
return ((_b = node.assignInfo) == null ? void 0 : _b.assignTime) || node.completedAt || fallback;
|
||
}
|
||
if (nodeType === PROCESS_NODE_TYPES.RECTIFY) {
|
||
return ((_c = node.rectifyInfo) == null ? void 0 : _c.rectifyTime) || node.completedAt || fallback;
|
||
}
|
||
if (nodeType === PROCESS_NODE_TYPES.VERIFY || nodeType === PROCESS_NODE_TYPES.WRITEOFF_APPROVE) {
|
||
return ((_d = node.verifyInfo) == null ? void 0 : _d.verifyTime) || node.completedAt || fallback;
|
||
}
|
||
if (nodeType === PROCESS_NODE_TYPES.WRITEOFF_APPLY) {
|
||
return ((_e = node.writeOffApplyInfo) == null ? void 0 : _e.applyTime) || node.completedAt || fallback;
|
||
}
|
||
if (nodeType === PROCESS_NODE_TYPES.APPROVAL) {
|
||
return ((_f = node.subProcessApprovalInfo) == null ? void 0 : _f.endTime) || node.completedAt || fallback;
|
||
}
|
||
return node.completedAt || node.occurredAt || fallback;
|
||
};
|
||
const mapAddContent = (info) => {
|
||
const data = toSafeObject(info);
|
||
return {
|
||
code: toDisplayText(data.code),
|
||
title: toDisplayText(data.title),
|
||
source: toDisplayText(data.source),
|
||
hazardSourceName: toDisplayText(data.hazardSourceName),
|
||
areaName: toDisplayText(data.areaName),
|
||
address: toDisplayText(data.address),
|
||
level: data.level ?? null,
|
||
levelName: toDisplayText(data.levelName),
|
||
tagName: toDisplayText(data.tagName),
|
||
description: toDisplayText(data.description),
|
||
attachments: Array.isArray(data.attachments) ? data.attachments : [],
|
||
legalBasis: toDisplayText(data.legalBasis)
|
||
};
|
||
};
|
||
const mapAssignContent = (info) => {
|
||
const data = toSafeObject(info);
|
||
return {
|
||
assigneeName: toDisplayText(data.assigneeName),
|
||
deadline: toDisplayText(data.deadline),
|
||
assignRemark: toDisplayText(data.assignRemark),
|
||
assignStatusName: toDisplayText(data.assignStatusName)
|
||
};
|
||
};
|
||
const mapRectifyContent = (info) => {
|
||
const data = toSafeObject(info);
|
||
return {
|
||
rectifyStatusName: toDisplayText(data.rectifyStatusName),
|
||
rectifyPlan: toDisplayText(data.rectifyPlan),
|
||
rectifyResult: toDisplayText(data.rectifyResult),
|
||
rectificationMeasures: toDisplayText(data.rectificationMeasures),
|
||
controlMeasures: toDisplayText(data.controlMeasures),
|
||
rectifierName: toDisplayText(data.rectifierName),
|
||
managerNames: components_hazardDetail_hazardDetail.formatNameList(data.managerNames, ""),
|
||
memberNames: components_hazardDetail_hazardDetail.formatNameList(data.memberNames, ""),
|
||
planCost: data.planCost ?? null,
|
||
actualCost: data.actualCost ?? null,
|
||
attachments: Array.isArray(data.attachments) ? data.attachments : [],
|
||
signPath: toDisplayText(data.signPath)
|
||
};
|
||
};
|
||
const mapVerifyContent = (info) => {
|
||
const data = toSafeObject(info);
|
||
return {
|
||
resultName: toDisplayText(data.resultName),
|
||
remark: toDisplayText(data.remark),
|
||
attachments: Array.isArray(data.attachments) ? data.attachments : [],
|
||
signPath: toDisplayText(data.signPath)
|
||
};
|
||
};
|
||
const mapApprovalContent = (info) => {
|
||
const data = toSafeObject(info);
|
||
return {
|
||
approveTypeName: toDisplayText(data.approveTypeName),
|
||
pass: data.pass ?? null,
|
||
comment: toDisplayText(data.comment),
|
||
nextStepName: toDisplayText(data.nextStepName),
|
||
nextAssigneeName: toDisplayText(data.nextAssigneeName),
|
||
sendMsgFlag: data.sendMsgFlag ?? null,
|
||
signPath: toDisplayText(data.signPath)
|
||
};
|
||
};
|
||
const mapWriteoffApplyContent = (info) => {
|
||
const data = toSafeObject(info);
|
||
return {
|
||
rectifyDeadline: toDisplayText(data.rectifyDeadline),
|
||
responsibleDeptName: toDisplayText(data.responsibleDeptName),
|
||
responsiblePerson: toDisplayText(data.responsiblePerson),
|
||
mainTreatmentContent: toDisplayText(data.mainTreatmentContent),
|
||
treatmentResult: toDisplayText(data.treatmentResult),
|
||
selfVerifyContent: toDisplayText(data.selfVerifyContent),
|
||
signPath: toDisplayText(data.signPath)
|
||
};
|
||
};
|
||
const resolveNodeType = (node) => {
|
||
const nodeType = node == null ? void 0 : node.nodeType;
|
||
if (nodeType === "verify_sub" || nodeType === "writeoff_sub") {
|
||
return PROCESS_NODE_TYPES.APPROVAL;
|
||
}
|
||
return nodeType || PROCESS_NODE_TYPES.ADD;
|
||
};
|
||
const hasRectifyData = (rectifyInfo) => {
|
||
if (!rectifyInfo || typeof rectifyInfo !== "object") {
|
||
return false;
|
||
}
|
||
return Boolean(
|
||
rectifyInfo.rectifyId || rectifyInfo.rectifyPlan || rectifyInfo.rectifyResult || rectifyInfo.rectifyTime || rectifyInfo.rectifierName
|
||
);
|
||
};
|
||
const hasAssignData = (assignInfo) => {
|
||
if (!assignInfo || typeof assignInfo !== "object") {
|
||
return false;
|
||
}
|
||
return Boolean(
|
||
assignInfo.assignId || assignInfo.assigneeName || assignInfo.assignerName || assignInfo.assignTime
|
||
);
|
||
};
|
||
const isAssignLikeNodeType = (nodeType) => nodeType === PROCESS_NODE_TYPES.ASSIGN || nodeType === PROCESS_NODE_TYPES.RECTIFY_ASSIGN;
|
||
const resolveAssignRectifyDisplayType = (node) => {
|
||
if (hasRectifyData(node == null ? void 0 : node.rectifyInfo)) {
|
||
return PROCESS_NODE_TYPES.RECTIFY;
|
||
}
|
||
if (hasAssignData(node == null ? void 0 : node.assignInfo)) {
|
||
return PROCESS_NODE_TYPES.ASSIGN;
|
||
}
|
||
return null;
|
||
};
|
||
const resolveDisplayType = (node, nodeType) => {
|
||
if (isAssignLikeNodeType(nodeType)) {
|
||
return resolveAssignRectifyDisplayType(node) || PROCESS_NODE_TYPES.ASSIGN;
|
||
}
|
||
if (nodeType === PROCESS_NODE_TYPES.RECTIFY) {
|
||
return resolveAssignRectifyDisplayType(node) || PROCESS_NODE_TYPES.RECTIFY;
|
||
}
|
||
return nodeType;
|
||
};
|
||
const resolveTitlePrefix = (rawType, displayType, node) => {
|
||
if (displayType === PROCESS_NODE_TYPES.ASSIGN) {
|
||
return TITLE_PREFIX_MAP[rawType] || TITLE_PREFIX_MAP.assign;
|
||
}
|
||
if (displayType === PROCESS_NODE_TYPES.RECTIFY) {
|
||
return TITLE_PREFIX_MAP.rectify;
|
||
}
|
||
return TITLE_PREFIX_MAP[displayType] || TITLE_PREFIX_MAP[rawType] || node.nodeName || "处理";
|
||
};
|
||
const mapNodeContent = (node, displayType) => {
|
||
switch (displayType) {
|
||
case PROCESS_NODE_TYPES.ADD:
|
||
return mapAddContent(node.hazardInfo);
|
||
case PROCESS_NODE_TYPES.ASSIGN:
|
||
return mapAssignContent(node.assignInfo);
|
||
case PROCESS_NODE_TYPES.RECTIFY:
|
||
return mapRectifyContent(node.rectifyInfo);
|
||
case PROCESS_NODE_TYPES.VERIFY:
|
||
case PROCESS_NODE_TYPES.WRITEOFF_APPROVE:
|
||
return mapVerifyContent(node.verifyInfo);
|
||
case PROCESS_NODE_TYPES.WRITEOFF_APPLY:
|
||
return mapWriteoffApplyContent(node.writeOffApplyInfo);
|
||
case PROCESS_NODE_TYPES.APPROVAL:
|
||
return mapApprovalContent(node.subProcessApprovalInfo);
|
||
default:
|
||
return {};
|
||
}
|
||
};
|
||
const mapProcessNodeToHistoryItem = (node) => {
|
||
if (!node || typeof node !== "object") {
|
||
return {
|
||
type: PROCESS_NODE_TYPES.ADD,
|
||
rawType: "",
|
||
taskKey: "",
|
||
nodeName: "",
|
||
titlePrefix: "处理",
|
||
operator: "",
|
||
time: "",
|
||
currentHandlerName: "",
|
||
content: {},
|
||
flowTaskId: "",
|
||
completed: true
|
||
};
|
||
}
|
||
const nodeType = resolveNodeType(node);
|
||
const rawType = node.nodeType || nodeType;
|
||
const displayType = resolveDisplayType(node, nodeType);
|
||
return {
|
||
type: displayType,
|
||
rawType,
|
||
taskKey: resolveTaskKey(node),
|
||
nodeName: getProcessStepDisplayName(node),
|
||
titlePrefix: resolveTitlePrefix(rawType, displayType, node),
|
||
operator: resolveOperator(node, displayType),
|
||
time: resolveTime(node, displayType),
|
||
currentHandlerName: resolveCurrentHandlerName(node.currentHandler),
|
||
content: mapNodeContent(node, displayType),
|
||
flowTaskId: node.flowTaskId || "",
|
||
completed: isNodeCompleted(node)
|
||
};
|
||
};
|
||
const mapProcessChainNodes = (nodes = []) => {
|
||
if (!Array.isArray(nodes) || nodes.length === 0)
|
||
return [];
|
||
return nodes.map((node) => mapProcessNodeToHistoryItem(node));
|
||
};
|
||
const resolveProcessChainSummary = (data) => {
|
||
var _a;
|
||
if (!data) {
|
||
return {
|
||
statusName: "-",
|
||
createdAt: "-"
|
||
};
|
||
}
|
||
const addNode = (data.nodes || []).find((item) => item.nodeType === "add");
|
||
const createdAt = ((_a = addNode == null ? void 0 : addNode.hazardInfo) == null ? void 0 : _a.createdAt) || "-";
|
||
return {
|
||
statusName: data.statusName || "-",
|
||
createdAt
|
||
};
|
||
};
|
||
exports.PENDING_LABEL = PENDING_LABEL;
|
||
exports.getProcessStepIconPath = getProcessStepIconPath;
|
||
exports.mapProcessChainNodes = mapProcessChainNodes;
|
||
exports.resolveFieldDisplay = resolveFieldDisplay;
|
||
exports.resolveProcessChainSummary = resolveProcessChainSummary;
|
||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/components/hazardDetail/processChain.js.map
|