207 lines
6.5 KiB
JavaScript
207 lines
6.5 KiB
JavaScript
"use strict";
|
|
const HAZARD_NODE_TYPES = {
|
|
SUBMIT: "submit",
|
|
ASSIGN: "assign",
|
|
RECTIFY: "rectify",
|
|
VERIFY: "verify",
|
|
WRITEOFF: "writeoff"
|
|
};
|
|
const HAZARD_STATUS_CLASS_MAP = {
|
|
1: "status-blue",
|
|
2: "status-orange",
|
|
3: "status-red",
|
|
4: "status-yellow",
|
|
5: "status-green"
|
|
};
|
|
const STATUS_NAME_CLASS_MAP = {
|
|
待交办: "status-blue",
|
|
待整改: "status-orange",
|
|
整改中: "status-orange",
|
|
待验收: "status-red",
|
|
待销号: "status-yellow",
|
|
已完成: "status-green",
|
|
已销号: "status-green"
|
|
};
|
|
const LEVEL_NAME_MAP = {
|
|
2: "一般隐患",
|
|
3: "重大隐患"
|
|
};
|
|
function getLevelName(level) {
|
|
return LEVEL_NAME_MAP[level] || "未知";
|
|
}
|
|
function getStatusClass(status, statusName) {
|
|
if (statusName && STATUS_NAME_CLASS_MAP[statusName]) {
|
|
return STATUS_NAME_CLASS_MAP[statusName];
|
|
}
|
|
return HAZARD_STATUS_CLASS_MAP[status] || "";
|
|
}
|
|
function getStepIconPath(type, active = false) {
|
|
const baseMap = {
|
|
submit: "tijiao",
|
|
assign: "jiaoban",
|
|
rectify: "zhenggai",
|
|
verify: "yanshou",
|
|
writeoff: "xiaohao"
|
|
};
|
|
const base = baseMap[type] || "tijiao";
|
|
if (base === "zhenggai") {
|
|
return active ? "/static/yinhuan_detail/zhenggai_selected.png" : "/static/yinhuan_detail/zhenggai__unselected.png";
|
|
}
|
|
return `/static/yinhuan_detail/${base}__${active ? "selected" : "unselected"}.png`;
|
|
}
|
|
function formatNameList(names, fallback = "-") {
|
|
if (Array.isArray(names) && names.length) {
|
|
return names.join("、");
|
|
}
|
|
if (typeof names === "string" && names.trim()) {
|
|
const parts = names.split(/[,,、]/).map((s) => s.trim()).filter(Boolean);
|
|
return parts.length ? parts.join("、") : names;
|
|
}
|
|
return fallback;
|
|
}
|
|
function isWriteoffRecord(record) {
|
|
if (!record)
|
|
return false;
|
|
return record.type === 2 || record.typeName === "销号";
|
|
}
|
|
function buildVerifyNode(record) {
|
|
return {
|
|
type: HAZARD_NODE_TYPES.VERIFY,
|
|
nodeName: "验收",
|
|
titlePrefix: "验收",
|
|
operator: record.verifierName || "-",
|
|
time: record.verifyTime || "-",
|
|
content: {
|
|
resultName: record.resultName || "-",
|
|
remark: record.remark || "",
|
|
attachments: record.attachments || [],
|
|
signPath: record.signPath || "",
|
|
verifyDeptName: record.verifyDeptName || "-"
|
|
}
|
|
};
|
|
}
|
|
function buildWriteoffNode(record) {
|
|
return {
|
|
type: HAZARD_NODE_TYPES.WRITEOFF,
|
|
nodeName: "销号",
|
|
titlePrefix: "销号",
|
|
operator: record.verifierName || "-",
|
|
time: record.verifyTime || "-",
|
|
content: {
|
|
resultName: record.resultName || "-",
|
|
remark: record.remark || "",
|
|
attachments: record.attachments || [],
|
|
signPath: record.signPath || "",
|
|
writeoffDeptName: record.writeoffDeptName || "-"
|
|
}
|
|
};
|
|
}
|
|
function appendAuditNodes(list, records, seenIds) {
|
|
(records || []).forEach((record) => {
|
|
if (!record)
|
|
return;
|
|
const key = record.verifyId ?? record.id;
|
|
if (key != null) {
|
|
if (seenIds.has(key))
|
|
return;
|
|
seenIds.add(key);
|
|
}
|
|
list.push(isWriteoffRecord(record) ? buildWriteoffNode(record) : buildVerifyNode(record));
|
|
});
|
|
}
|
|
function resolveWriteoffRecords(flow) {
|
|
return flow.writeOffs || flow.writeoffs || [];
|
|
}
|
|
function resolveRectifierNames(rectify) {
|
|
if (!rectify)
|
|
return "-";
|
|
if (Array.isArray(rectify.rectifierNames) && rectify.rectifierNames.length) {
|
|
return rectify.rectifierNames.join("、");
|
|
}
|
|
if (Array.isArray(rectify.memberNames) && rectify.memberNames.length) {
|
|
return rectify.memberNames.join("、");
|
|
}
|
|
return formatNameList(rectify.rectifierName, "-");
|
|
}
|
|
function generateHazardHistory(data) {
|
|
if (!data)
|
|
return [];
|
|
const list = [];
|
|
list.push({
|
|
type: HAZARD_NODE_TYPES.SUBMIT,
|
|
nodeName: "提交",
|
|
titlePrefix: "提交",
|
|
operator: data.reporterName || "-",
|
|
time: data.createdAt || "-",
|
|
content: {
|
|
code: data.code || "-",
|
|
title: data.title || "-",
|
|
source: data.source || "-",
|
|
hazardSourceName: data.hazardSourceName || "-",
|
|
areaName: data.areaName || "-",
|
|
areaColor: data.areaColor || "",
|
|
address: data.address || "-",
|
|
level: data.level,
|
|
levelName: data.levelName || getLevelName(data.level),
|
|
tagName: data.tagName || "-",
|
|
description: data.description || "-",
|
|
attachments: data.attachments || [],
|
|
legalBasis: data.legalBasis || data.regulationName || "-",
|
|
reporterPhone: data.reporterPhone || "-",
|
|
reportDeptName: data.reportDeptName || "-"
|
|
}
|
|
});
|
|
if (data.assignFlows && data.assignFlows.length > 0) {
|
|
data.assignFlows.forEach((flow) => {
|
|
if (flow.assignId) {
|
|
list.push({
|
|
type: HAZARD_NODE_TYPES.ASSIGN,
|
|
nodeName: "交办",
|
|
titlePrefix: "交办",
|
|
operator: flow.assignerName || "-",
|
|
time: flow.assignTime || "-",
|
|
content: {
|
|
assigneeName: flow.assigneeName || "-",
|
|
deadline: flow.deadline || "-",
|
|
assignDeptName: flow.assignDeptName || "-",
|
|
assignRemark: flow.assignRemark || "-",
|
|
priorityName: flow.priorityName || "-"
|
|
}
|
|
});
|
|
}
|
|
if (flow.rectify) {
|
|
list.push({
|
|
type: HAZARD_NODE_TYPES.RECTIFY,
|
|
nodeName: "整改",
|
|
titlePrefix: "整改",
|
|
operator: flow.rectify.rectifierName || "-",
|
|
time: flow.rectify.rectifyTime || "-",
|
|
content: {
|
|
rectifyPlan: flow.rectify.rectifyPlan || "-",
|
|
rectifyResult: flow.rectify.rectifyResult || "-",
|
|
rectificationMeasures: flow.rectify.rectificationMeasures || "-",
|
|
controlMeasures: flow.rectify.controlMeasures || "-",
|
|
deadline: flow.deadline || "-",
|
|
rectifierNames: resolveRectifierNames(flow.rectify),
|
|
managerNames: formatNameList(flow.rectify.managerNames, "-"),
|
|
planCost: flow.rectify.planCost,
|
|
actualCost: flow.rectify.actualCost,
|
|
attachments: flow.rectify.attachments || [],
|
|
signPath: flow.rectify.signPath || "",
|
|
rectifyStatusName: flow.rectify.rectifyStatusName || "-"
|
|
}
|
|
});
|
|
}
|
|
const seenAuditIds = /* @__PURE__ */ new Set();
|
|
appendAuditNodes(list, flow.verifies || [], seenAuditIds);
|
|
appendAuditNodes(list, resolveWriteoffRecords(flow), seenAuditIds);
|
|
});
|
|
}
|
|
return list;
|
|
}
|
|
exports.formatNameList = formatNameList;
|
|
exports.generateHazardHistory = generateHazardHistory;
|
|
exports.getStatusClass = getStatusClass;
|
|
exports.getStepIconPath = getStepIconPath;
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/components/hazardDetail/hazardDetail.js.map
|