一单四制优化及加入工作流
This commit is contained in:
212
utils/hazardNav.js
Normal file
212
utils/hazardNav.js
Normal file
@@ -0,0 +1,212 @@
|
||||
/** 从列表项解析流程任务 ID */
|
||||
export function resolveItemTaskId(item) {
|
||||
if (!item) return '';
|
||||
const id = item.taskId ?? item.flowTaskId ?? item.currentTaskId ?? '';
|
||||
return id === '' || id == null ? '' : String(id);
|
||||
}
|
||||
|
||||
/** 从列表项解析被指派人身份 ID */
|
||||
export function resolveAssigneeIdentityId(item) {
|
||||
if (!item) return '';
|
||||
return item.assigneeIdentityId ?? item.identityId ?? '';
|
||||
}
|
||||
|
||||
/** 追加被指派人相关查询参数 */
|
||||
export function appendAssigneeQuery(url, item) {
|
||||
if (!item) return url;
|
||||
let result = url;
|
||||
if (item.assigneeId) {
|
||||
result += `&assigneeId=${item.assigneeId}`;
|
||||
}
|
||||
const assigneeIdentityId = resolveAssigneeIdentityId(item);
|
||||
if (assigneeIdentityId) {
|
||||
result += `&assigneeIdentityId=${assigneeIdentityId}`;
|
||||
}
|
||||
if (item.assigneeName) {
|
||||
result += `&assigneeName=${encodeURIComponent(item.assigneeName)}`;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 构建立即整改页 URL */
|
||||
export function buildRectificationUrl(item) {
|
||||
let url = `/pages/hiddendanger/rectification?hazardId=${item.hazardId}&assignId=${item.assignId || ''}`;
|
||||
if (item.taskId) {
|
||||
url += `&taskId=${encodeURIComponent(item.taskId)}`;
|
||||
}
|
||||
if (item.deadline) {
|
||||
url += `&deadline=${encodeURIComponent(item.deadline)}`;
|
||||
}
|
||||
return appendAssigneeQuery(url, item);
|
||||
}
|
||||
|
||||
/** 构建编辑整改页 URL */
|
||||
export function buildEditRectificationUrl(item) {
|
||||
let url = `/pages/hiddendanger/rectification?rectifyId=${item.rectifyId}&isEdit=1`;
|
||||
if (item.hazardId) {
|
||||
url += `&hazardId=${item.hazardId}`;
|
||||
}
|
||||
if (item.assignId) {
|
||||
url += `&assignId=${item.assignId}`;
|
||||
}
|
||||
if (item.taskId) {
|
||||
url += `&taskId=${encodeURIComponent(item.taskId)}`;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/** 构建验收页 URL */
|
||||
export function buildAcceptanceUrl(item) {
|
||||
let url = `/pages/hiddendanger/acceptance?hazardId=${item.hazardId}&assignId=${item.assignId || ''}&rectifyId=${item.rectifyId || ''}`;
|
||||
if (item.taskId) {
|
||||
url += `&taskId=${encodeURIComponent(item.taskId)}`;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/** 构建验收审批页 URL(approval 角色) */
|
||||
export function buildAcceptanceApprovalUrl(item) {
|
||||
let url = `/pages/hiddendanger/acceptance-approval?hazardId=${item.hazardId}&assignId=${item.assignId || ''}&rectifyId=${item.rectifyId || ''}`;
|
||||
if (item.taskId) {
|
||||
url += `&taskId=${encodeURIComponent(item.taskId)}`;
|
||||
}
|
||||
if (item.taskKey) {
|
||||
url += `&taskKey=${encodeURIComponent(item.taskKey)}`;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/** 构建隐患交办页 URL */
|
||||
export function buildAssignmentUrl(item) {
|
||||
let url = `/pages/hiddendanger/assignment?hazardId=${item.hazardId}&assignId=${item.assignId || ''}`;
|
||||
const taskId = resolveItemTaskId(item);
|
||||
if (taskId) {
|
||||
url += `&taskId=${encodeURIComponent(taskId)}`;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/** 构建销号申请页 URL(从列表卡片进入时锁定对应隐患) */
|
||||
export function buildWriteoffApplyUrl(item) {
|
||||
let url = `/pages/closeout/apply?hazardId=${item.hazardId}&locked=1`;
|
||||
if (item.assignId) {
|
||||
url += `&assignId=${item.assignId}`;
|
||||
}
|
||||
if (item.taskId) {
|
||||
url += `&taskId=${encodeURIComponent(item.taskId)}`;
|
||||
}
|
||||
return appendWriteoffHazardQuery(url, item);
|
||||
}
|
||||
|
||||
/** 构建销号审批页 URL */
|
||||
export function buildWriteoffApprovalUrl(item) {
|
||||
let url = `/pages/closeout/approval?hazardId=${item.hazardId}&locked=1`;
|
||||
if (item.assignId) {
|
||||
url += `&assignId=${item.assignId}`;
|
||||
}
|
||||
if (item.taskId) {
|
||||
url += `&taskId=${encodeURIComponent(item.taskId)}`;
|
||||
}
|
||||
return appendWriteoffHazardQuery(url, item);
|
||||
}
|
||||
|
||||
/** 构建销号领导审批页 URL(approval 角色) */
|
||||
export function buildLeaderWriteoffApprovalUrl(item) {
|
||||
let url = `/pages/closeout/leader-approval?hazardId=${item.hazardId}&locked=1`;
|
||||
if (item.assignId) {
|
||||
url += `&assignId=${item.assignId}`;
|
||||
}
|
||||
if (item.taskId) {
|
||||
url += `&taskId=${encodeURIComponent(item.taskId)}`;
|
||||
}
|
||||
if (item.taskKey) {
|
||||
url += `&taskKey=${encodeURIComponent(item.taskKey)}`;
|
||||
}
|
||||
return appendWriteoffHazardQuery(url, item);
|
||||
}
|
||||
|
||||
const decodeQueryValue = (value) => {
|
||||
if (value == null || value === '') return '';
|
||||
try {
|
||||
return decodeURIComponent(String(value));
|
||||
} catch (error) {
|
||||
return String(value);
|
||||
}
|
||||
};
|
||||
|
||||
/** 销号相关页 URL 追加列表项展示字段(title、deadline、deptName、rectifierName、deptId) */
|
||||
export function appendWriteoffHazardQuery(url, item) {
|
||||
if (!item) return url;
|
||||
let result = url;
|
||||
const title = item.title || item.hazardTitle;
|
||||
if (title) {
|
||||
result += `&title=${encodeURIComponent(title)}`;
|
||||
}
|
||||
if (item.deadline) {
|
||||
result += `&deadline=${encodeURIComponent(item.deadline)}`;
|
||||
}
|
||||
if (item.deptName) {
|
||||
result += `&deptName=${encodeURIComponent(item.deptName)}`;
|
||||
}
|
||||
if (item.deptId != null && item.deptId !== '') {
|
||||
result += `&deptId=${item.deptId}`;
|
||||
}
|
||||
if (item.rectifierName) {
|
||||
result += `&rectifierName=${encodeURIComponent(item.rectifierName)}`;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 从页面 onLoad options 解析列表传入的隐患信息(不再依赖 verified/list 对比) */
|
||||
export function buildWriteoffHazardFromOptions(options) {
|
||||
if (!options?.hazardId) return null;
|
||||
return {
|
||||
hazardId: options.hazardId,
|
||||
assignId: options.assignId || '',
|
||||
taskId: options.taskId || '',
|
||||
title: decodeQueryValue(options.title),
|
||||
hazardTitle: decodeQueryValue(options.title),
|
||||
deadline: decodeQueryValue(options.deadline),
|
||||
deptName: decodeQueryValue(options.deptName),
|
||||
deptId: options.deptId || '',
|
||||
rectifierName: decodeQueryValue(options.rectifierName)
|
||||
};
|
||||
}
|
||||
|
||||
const isTruthyFlag = (value) => value === true || value === 1 || value === '1';
|
||||
|
||||
/**
|
||||
* 立即验收按钮展示逻辑(首页、隐患排查列表等共用)
|
||||
*
|
||||
* 展示条件(需同时满足):
|
||||
* 1. statusName === '待验收'
|
||||
* 2. 当前角色为 admin 或 manage
|
||||
* 3. 流程节点类型 nodeType 允许验收
|
||||
*
|
||||
* 【历史变更】
|
||||
* - 最初:item.quickApprove != 0 时展示
|
||||
* - 中间:改为 item.result(null 或 3=驳回)时展示
|
||||
* - 现在:改为 item.nodeType 控制
|
||||
* 仅当 nodeType 为 null、1(重新整改)、2(驳回)、3(重新验收)时展示
|
||||
* 其他 nodeType 值不展示
|
||||
*/
|
||||
export function canShowAcceptanceButton(item, roleKey) {
|
||||
const canAcceptance = roleKey === 'admin' || roleKey === 'manage';
|
||||
const nodeType = item?.nodeType;
|
||||
// null:初始待验收;1:重新整改;2:驳回;3:重新验收
|
||||
const canAcceptByNodeType = nodeType == null
|
||||
|| nodeType === 1 || nodeType === '1'
|
||||
|| nodeType === 2 || nodeType === '2'
|
||||
|| nodeType === 3 || nodeType === '3';
|
||||
return item?.statusName === '待验收' && canAcceptance && canAcceptByNodeType;
|
||||
}
|
||||
|
||||
/** 销号申请按钮:待销号且 applyFlag 为 true */
|
||||
export function canShowWriteoffApplyButton(item) {
|
||||
return item?.statusName === '待销号' && isTruthyFlag(item?.applyFlag);
|
||||
}
|
||||
|
||||
/** 销号审批按钮:待销号、manage 角色且 writeOffFlag 为 true */
|
||||
export function canShowWriteoffApprovalButton(item, roleKey) {
|
||||
return item?.statusName === '待销号' && roleKey === 'manage' && isTruthyFlag(item?.writeOffFlag);
|
||||
}
|
||||
Reference in New Issue
Block a user