179 lines
6.0 KiB
JavaScript
179 lines
6.0 KiB
JavaScript
"use strict";
|
|
function resolveItemTaskId(item) {
|
|
if (!item)
|
|
return "";
|
|
const id = item.taskId ?? item.flowTaskId ?? item.currentTaskId ?? "";
|
|
return id === "" || id == null ? "" : String(id);
|
|
}
|
|
function resolveAssigneeIdentityId(item) {
|
|
if (!item)
|
|
return "";
|
|
return item.assigneeIdentityId ?? item.identityId ?? "";
|
|
}
|
|
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;
|
|
}
|
|
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);
|
|
}
|
|
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;
|
|
}
|
|
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;
|
|
}
|
|
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;
|
|
}
|
|
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;
|
|
}
|
|
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);
|
|
}
|
|
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);
|
|
}
|
|
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);
|
|
}
|
|
};
|
|
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;
|
|
}
|
|
function buildWriteoffHazardFromOptions(options) {
|
|
if (!(options == null ? void 0 : 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";
|
|
function canShowAcceptanceButton(item) {
|
|
return isTruthyFlag(item == null ? void 0 : item.verifyFlag);
|
|
}
|
|
function canShowWriteoffApplyButton(item) {
|
|
return (item == null ? void 0 : item.statusName) === "待销号" && isTruthyFlag(item == null ? void 0 : item.applyFlag);
|
|
}
|
|
function canShowWriteoffApprovalButton(item, roleKey) {
|
|
return (item == null ? void 0 : item.statusName) === "待销号" && roleKey === "manage" && isTruthyFlag(item == null ? void 0 : item.writeOffFlag);
|
|
}
|
|
exports.buildAcceptanceApprovalUrl = buildAcceptanceApprovalUrl;
|
|
exports.buildAcceptanceUrl = buildAcceptanceUrl;
|
|
exports.buildAssignmentUrl = buildAssignmentUrl;
|
|
exports.buildEditRectificationUrl = buildEditRectificationUrl;
|
|
exports.buildLeaderWriteoffApprovalUrl = buildLeaderWriteoffApprovalUrl;
|
|
exports.buildRectificationUrl = buildRectificationUrl;
|
|
exports.buildWriteoffApplyUrl = buildWriteoffApplyUrl;
|
|
exports.buildWriteoffApprovalUrl = buildWriteoffApprovalUrl;
|
|
exports.buildWriteoffHazardFromOptions = buildWriteoffHazardFromOptions;
|
|
exports.canShowAcceptanceButton = canShowAcceptanceButton;
|
|
exports.canShowWriteoffApplyButton = canShowWriteoffApplyButton;
|
|
exports.canShowWriteoffApprovalButton = canShowWriteoffApprovalButton;
|
|
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/hazardNav.js.map
|