Files
threeonecheck_web/unpackage/dist/dev/mp-weixin/pages/hiddendanger/acceptance-approval.js
2026-07-27 09:27:22 +08:00

1062 lines
39 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const request_api = require("../../request/api.js");
const request_request = require("../../request/request.js");
const utils_draftCache = require("../../utils/draftCache.js");
const utils_useDraftCache = require("../../utils/useDraftCache.js");
const utils_upload = require("../../utils/upload.js");
if (!Array) {
const _easycom_up_radio2 = common_vendor.resolveComponent("up-radio");
const _easycom_up_radio_group2 = common_vendor.resolveComponent("up-radio-group");
const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
const _easycom_wd_signature2 = common_vendor.resolveComponent("wd-signature");
(_easycom_up_radio2 + _easycom_up_radio_group2 + _easycom_up_textarea2 + _easycom_wd_signature2)();
}
const _easycom_up_radio = () => "../../uni_modules/uview-plus/components/u-radio/u-radio.js";
const _easycom_up_radio_group = () => "../../uni_modules/uview-plus/components/u-radio-group/u-radio-group.js";
const _easycom_up_textarea = () => "../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
const _easycom_wd_signature = () => "../../node-modules/wot-design-uni/components/wd-signature/wd-signature.js";
if (!Math) {
(_easycom_up_radio + _easycom_up_radio_group + _easycom_up_textarea + FlowAssigneePickerPopup + _easycom_wd_signature)();
}
const FlowAssigneePickerPopup = () => "../../components/flow/FlowAssigneePickerPopup.js";
const FLOW_END_STEP_NAME = "验收快速审结束";
const FLOW_INCLUDE_SUB_PROCESS = true;
const _sfc_main = {
__name: "acceptance-approval",
setup(__props) {
const rectifyId = common_vendor.ref("");
const hazardId = common_vendor.ref("");
const assignId = common_vendor.ref("");
const taskId = common_vendor.ref("");
const nextStepName = common_vendor.ref("");
const nextStepKey = common_vendor.ref("");
const nextStepLoading = common_vendor.ref(false);
const FIXED_NEXT_STEP_MAP = {
re_rectify: "隐患整改"
};
const currentTaskKey = common_vendor.ref("");
const resolveFixedNextStepName = (opinion) => FIXED_NEXT_STEP_MAP[opinion] || "";
const isFixedNextStepOpinion = (opinion) => !!resolveFixedNextStepName(opinion);
const APPROVAL_TYPE_MAP = {
agree: "agree",
reject: "reject",
report: "report",
re_rectify: "rectify"
};
const APPROVAL_OPTIONS_AGREE_REJECT = [
{ label: "同意", value: "agree" },
{ label: "驳回", value: "reject" }
];
const APPROVAL_OPTIONS_WITH_REPORT = [
{ label: "同意", value: "agree" },
{ label: "驳回", value: "reject" },
{ label: "上报", value: "report" }
];
const APPROVAL_OPTIONS_ALL = [
{ label: "同意", value: "agree" },
{ label: "驳回", value: "reject" },
{ label: "上报", value: "report" },
{ label: "重新整改", value: "re_rectify" }
];
const APPROVAL_OPTIONS_LEADER_PREFECTURE = [
{ label: "同意", value: "agree" },
{ label: "驳回", value: "reject" },
{ label: "重新整改", value: "re_rectify" }
];
const resolveApprovalOptionsByCurrentTaskKey = (taskKey, deptType) => {
const key = String(taskKey || "");
const dept = String(deptType || "");
if (key === "supervising_leader_review_1" || key === "supervising_leader_review_2") {
if (dept === "prefecture") {
return APPROVAL_OPTIONS_LEADER_PREFECTURE;
}
return APPROVAL_OPTIONS_ALL;
}
if (key === "department_review" && dept === "town_street") {
return APPROVAL_OPTIONS_WITH_REPORT;
}
if (key === "department_review" || key === "section_chief_review" || key === "supervising_executive_review") {
return APPROVAL_OPTIONS_AGREE_REJECT;
}
return key ? APPROVAL_OPTIONS_ALL : [];
};
const approvalOptions = common_vendor.computed(() => resolveApprovalOptionsByCurrentTaskKey(currentTaskKey.value, getCurrentDeptType()));
const needNextAssignee = common_vendor.computed(() => {
if (formData.approvalOpinion !== "agree" && formData.approvalOpinion !== "report") {
return false;
}
if (formData.approvalOpinion === "agree" && nextStepName.value === FLOW_END_STEP_NAME) {
return false;
}
return true;
});
const nextStepDisplay = common_vendor.computed(() => {
if (!formData.approvalOpinion)
return "请先选择审批意见";
const fixedName = resolveFixedNextStepName(formData.approvalOpinion);
if (fixedName)
return fixedName;
if (nextStepLoading.value)
return "加载中...";
return nextStepName.value || "暂无下一步流程";
});
const resolveTaskIdFromAssign = (assign) => {
if (!assign)
return "";
if (assign.taskId)
return String(assign.taskId);
if (assign.flowTaskId)
return String(assign.flowTaskId);
if (assign.currentTaskId)
return String(assign.currentTaskId);
return "";
};
const resolveAssignWithRectify = (assigns) => {
if (!(assigns == null ? void 0 : assigns.length))
return null;
if (rectifyId.value) {
const byRectifyId = assigns.find(
(item) => item.rectify && String(item.rectify.rectifyId) === String(rectifyId.value)
);
if (byRectifyId)
return byRectifyId;
}
if (assignId.value) {
const byAssignId = assigns.find(
(item) => String(item.assignId) === String(assignId.value) && item.rectify
);
if (byAssignId)
return byAssignId;
}
return assigns.find((item) => item.rectify) || null;
};
const resolveTaskIdFromDetail = (data) => {
if (!data)
return "";
if (data.taskId)
return String(data.taskId);
if (data.flowTaskId)
return String(data.flowTaskId);
if (data.currentTaskId)
return String(data.currentTaskId);
const assigns = data.assigns || [];
const matchedAssign = resolveAssignWithRectify(assigns);
const fromMatched = resolveTaskIdFromAssign(matchedAssign);
if (fromMatched)
return fromMatched;
for (const assign of assigns) {
const id = resolveTaskIdFromAssign(assign);
if (id)
return id;
}
return "";
};
const resolveMatchedBranch = (data) => {
if (!data)
return null;
const branches = data.branches || [];
return branches.find((item) => item.matched) || branches[0] || null;
};
const resolveNextTaskName = (data) => {
var _a, _b;
return ((_b = (_a = resolveMatchedBranch(data)) == null ? void 0 : _a.nextNode) == null ? void 0 : _b.taskName) || "";
};
const resolveNextTaskKey = (data) => {
var _a;
return resolveNextNodeTaskKey((_a = resolveMatchedBranch(data)) == null ? void 0 : _a.nextNode);
};
const resolveNextNodeTaskKey = (node) => {
if (!(node == null ? void 0 : node.taskKey))
return "";
return String(node.taskKey);
};
const resolveCurrentTaskKey = (data) => {
if (data == null ? void 0 : data.currentTaskKey) {
return String(data.currentTaskKey);
}
if (data == null ? void 0 : data.taskKey) {
return String(data.taskKey);
}
return "";
};
const clearSelectedAssignee = () => {
selectedAssigneeIdentityId.value = "";
selectedAssigneeName.value = "";
pickerAssigneeIdentityId.value = "";
pickerAssigneeName.value = "";
};
const syncApprovalOpinionWithOptions = () => {
const validValues = approvalOptions.value.map((item) => item.value);
if (formData.approvalOpinion && !validValues.includes(formData.approvalOpinion)) {
formData.approvalOpinion = "";
}
if (!needNextAssignee.value) {
clearSelectedAssignee();
}
};
const applyDefaultOpinionRemark = (opinion) => {
if (opinion === "agree") {
formData.opinionRemark = "同意";
} else if (opinion === "report") {
formData.opinionRemark = "上报";
} else if (opinion) {
formData.opinionRemark = "";
}
};
const resolveApproveType = (opinion) => APPROVAL_TYPE_MAP[opinion] || "";
const buildPreviewVariables = (approvalOpinion) => {
const deptType = getCurrentDeptType();
const vars = {};
if (deptType) {
vars.deptType = deptType;
}
if (approvalOpinion === "report") {
vars.reportLeader = true;
} else if (approvalOpinion === "agree") {
vars.reportLeader = false;
}
return vars;
};
const buildFlowNextNodesParams = (currentTaskId, approvalOpinion) => {
const params = {
taskId: currentTaskId,
includeSubProcess: FLOW_INCLUDE_SUB_PROCESS
};
if (approvalOpinion === "reject") {
params.reject = true;
} else {
params.previewVariables = buildPreviewVariables(approvalOpinion);
}
return params;
};
const getStoredUserInfo = () => {
try {
const stored = common_vendor.index.getStorageSync("userInfo");
if (!stored)
return {};
return typeof stored === "string" ? JSON.parse(stored) : stored;
} catch (error) {
return {};
}
};
const getCurrentDeptType = () => {
var _a;
const userInfo = getStoredUserInfo();
const deptType = (_a = userInfo.userIdentity) == null ? void 0 : _a.deptType;
return deptType != null && deptType !== "" ? String(deptType) : "";
};
const selectedAssigneeIdentityId = common_vendor.ref("");
const selectedAssigneeName = common_vendor.ref("");
const pickerAssigneeIdentityId = common_vendor.ref("");
const pickerAssigneeName = common_vendor.ref("");
const showAssigneePopup = common_vendor.ref(false);
const openAssigneePopup = () => {
if (!taskId.value) {
common_vendor.index.showToast({ title: "缺少任务ID", icon: "none" });
return;
}
pickerAssigneeIdentityId.value = selectedAssigneeIdentityId.value;
pickerAssigneeName.value = selectedAssigneeName.value;
showAssigneePopup.value = true;
};
const confirmAssigneeSelect = ({ identityId, name }) => {
selectedAssigneeIdentityId.value = identityId;
selectedAssigneeName.value = name;
showAssigneePopup.value = false;
};
const cancelAssigneeSelect = () => {
showAssigneePopup.value = false;
};
const verifyData = common_vendor.reactive({
verifyId: null,
resultName: "",
remark: "",
verifierName: "",
verifyTime: ""
});
const verifyAttachments = common_vendor.ref([]);
const fetchFlowContext = async () => {
if (!taskId.value) {
return;
}
try {
const res = await request_api.getFlowNextNodes({
taskId: taskId.value,
previewVariables: buildPreviewVariables(""),
includeSubProcess: FLOW_INCLUDE_SUB_PROCESS
});
if (res.code === 0) {
const payload = res.data && typeof res.data === "object" ? res.data : res;
const resolvedKey = resolveCurrentTaskKey(payload);
if (resolvedKey) {
currentTaskKey.value = resolvedKey;
}
syncApprovalOpinionWithOptions();
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance-approval.vue:549", "获取流程上下文失败:", error);
}
};
const fetchNextStep = async () => {
if (!formData.approvalOpinion) {
nextStepName.value = "";
nextStepKey.value = "";
return;
}
const fixedName = resolveFixedNextStepName(formData.approvalOpinion);
if (fixedName) {
nextStepName.value = fixedName;
nextStepKey.value = "";
return;
}
nextStepLoading.value = true;
try {
const currentTaskId = taskId.value;
if (!currentTaskId) {
nextStepName.value = "";
nextStepKey.value = "";
return;
}
const res = await request_api.getFlowNextNodes(
buildFlowNextNodesParams(currentTaskId, formData.approvalOpinion)
);
if (res.code === 0) {
const payload = res.data && typeof res.data === "object" ? res.data : res;
nextStepName.value = resolveNextTaskName(payload);
nextStepKey.value = resolveNextTaskKey(payload);
if (!needNextAssignee.value) {
clearSelectedAssignee();
}
} else {
nextStepName.value = "";
nextStepKey.value = "";
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance-approval.vue:591", "获取下一步流程失败:", error);
nextStepName.value = "";
nextStepKey.value = "";
} finally {
nextStepLoading.value = false;
}
};
const rectifyData = common_vendor.reactive({
rectifyPlan: "",
rectificationMeasures: "",
controlMeasures: "",
rectifyResult: "",
planCost: null,
actualCost: null,
managerNames: [],
memberNames: [],
rectifierName: "",
rectifyStatusName: ""
});
const formatPersonNames = (names) => {
if (!names)
return "暂无";
if (Array.isArray(names)) {
const text = names.filter(Boolean).join("、");
return text || "暂无";
}
if (typeof names === "string") {
return names.trim() || "暂无";
}
return "暂无";
};
const formatMoney = (value) => {
if (value === null || value === void 0 || value === "") {
return "暂无";
}
const num = Number(value);
if (Number.isNaN(num)) {
return "暂无";
}
return `${num.toFixed(2)}`;
};
const rectifyAttachments = common_vendor.ref([]);
const formData = common_vendor.reactive({
approvalOpinion: "",
// 审批意见 agree/reject/report/re_rectify
opinionRemark: ""
// 意见说明
});
const sendMsgFlagRadio = common_vendor.ref("yes");
const sendMsgFlag = common_vendor.computed(() => sendMsgFlagRadio.value === "yes");
const suppressOpinionRemarkAutofill = common_vendor.ref(false);
common_vendor.watch(() => formData.approvalOpinion, (opinion) => {
clearSelectedAssignee();
nextStepName.value = "";
nextStepKey.value = "";
if (!suppressOpinionRemarkAutofill.value) {
applyDefaultOpinionRemark(opinion);
}
if (opinion) {
fetchNextStep();
}
syncApprovalOpinionWithOptions();
});
common_vendor.watch(needNextAssignee, (value) => {
if (!value) {
clearSelectedAssignee();
}
});
const showCanvas = common_vendor.ref(true);
const signatureUrl = common_vendor.ref("");
const signatureServerPath = common_vendor.ref("");
const signatureWidth = common_vendor.ref(340);
const signatureRef = common_vendor.ref(null);
const isSignatureEmpty = common_vendor.ref(true);
const isSubmitting = common_vendor.ref(false);
const signaturePaths = common_vendor.ref([]);
const signatureLocalPath = common_vendor.ref("");
const isDraftExporting = common_vendor.ref(false);
let signatureExportTimer = null;
const applySignatureFromServer = (signPath) => {
const url = signPath ? utils_upload.toSubmitFileUrl(signPath) : "";
if (!url) {
showCanvas.value = true;
signatureServerPath.value = "";
signatureUrl.value = "";
signatureLocalPath.value = "";
isSignatureEmpty.value = true;
return;
}
signatureServerPath.value = url;
signatureUrl.value = url;
signatureLocalPath.value = "";
showCanvas.value = false;
isSignatureEmpty.value = false;
};
const applySignatureFromLocal = (localPath) => {
if (!localPath)
return;
signatureLocalPath.value = localPath;
signatureUrl.value = localPath;
signatureServerPath.value = "";
showCanvas.value = false;
isSignatureEmpty.value = false;
};
const acceptDraftHasContent = (data) => {
const form = data.formData || {};
return !!(form.approvalOpinion || form.opinionRemark || data.signatureServerPath || data.signatureLocalPath || data.signaturePaths && data.signaturePaths.length > 0);
};
const {
showRestoreBanner,
clear: clearDraft,
restore: restoreDraft,
save: saveDraft,
bindAutoSave
} = utils_useDraftCache.useDraftCache({
getKey: () => utils_draftCache.buildDraftKey(utils_draftCache.DRAFT_NS.ACCEPT_APPROVAL, rectifyId.value),
getFallbackKeys: () => {
const primary = utils_draftCache.buildDraftKey(utils_draftCache.DRAFT_NS.ACCEPT_APPROVAL, rectifyId.value);
const compact = utils_draftCache.buildDraftKeyCompact(utils_draftCache.DRAFT_NS.ACCEPT_APPROVAL, rectifyId.value);
return compact !== primary ? [compact] : [];
},
getPayload: () => ({
formData: {
approvalOpinion: formData.approvalOpinion,
opinionRemark: formData.opinionRemark
},
selectedAssigneeIdentityId: selectedAssigneeIdentityId.value,
selectedAssigneeName: selectedAssigneeName.value,
signatureServerPath: signatureServerPath.value,
signatureUrl: signatureUrl.value,
signatureLocalPath: signatureLocalPath.value,
showCanvas: showCanvas.value,
signaturePaths: signaturePaths.value,
sendMsgFlagRadio: sendMsgFlagRadio.value
}),
hasContent: acceptDraftHasContent,
applyPayload: (data) => {
const form = data.formData || {};
suppressOpinionRemarkAutofill.value = true;
formData.approvalOpinion = form.approvalOpinion || "";
formData.opinionRemark = form.opinionRemark || "";
suppressOpinionRemarkAutofill.value = false;
selectedAssigneeIdentityId.value = data.selectedAssigneeIdentityId || "";
selectedAssigneeName.value = data.selectedAssigneeName || "";
signaturePaths.value = data.signaturePaths || [];
if (data.signatureServerPath || data.signatureUrl) {
applySignatureFromServer(data.signatureServerPath || data.signatureUrl);
} else if (data.signatureLocalPath) {
applySignatureFromLocal(data.signatureLocalPath);
} else {
showCanvas.value = data.showCanvas !== void 0 ? data.showCanvas : true;
signatureServerPath.value = "";
signatureUrl.value = "";
signatureLocalPath.value = "";
isSignatureEmpty.value = true;
}
sendMsgFlagRadio.value = data.sendMsgFlagRadio === "no" ? "no" : "yes";
},
clearForm: () => {
formData.approvalOpinion = "";
formData.opinionRemark = "";
selectedAssigneeIdentityId.value = "";
selectedAssigneeName.value = "";
signatureServerPath.value = "";
signatureUrl.value = "";
signatureLocalPath.value = "";
showCanvas.value = true;
signaturePaths.value = [];
if (signatureRef.value) {
signatureRef.value.clear();
}
sendMsgFlagRadio.value = "yes";
},
canSave: () => !!rectifyId.value,
requireInitialized: true,
onAfterRestore: async (data) => {
var _a;
if (taskId.value && !currentTaskKey.value) {
await fetchFlowContext();
}
if (formData.approvalOpinion) {
await fetchNextStep();
}
if (data.signatureServerPath || data.signatureUrl || data.signatureLocalPath) {
return;
}
if (((_a = data.signaturePaths) == null ? void 0 : _a.length) > 0) {
setTimeout(() => {
if (signatureRef.value) {
isSignatureEmpty.value = false;
}
}, 450);
}
}
});
bindAutoSave(() => [
formData.approvalOpinion,
formData.opinionRemark,
selectedAssigneeIdentityId.value,
selectedAssigneeName.value,
signatureServerPath.value,
signatureUrl.value,
signatureLocalPath.value,
showCanvas.value,
signaturePaths.value,
sendMsgFlagRadio.value
]);
const getFullPath = (filePath) => {
if (!filePath)
return "";
if (filePath.startsWith("http://") || filePath.startsWith("https://")) {
return request_request.toImageUrl(filePath);
}
return request_request.toImageUrl(filePath);
};
const previewImage = (index) => {
const urls = rectifyAttachments.value.map((item) => getFullPath(item.filePath));
common_vendor.index.previewImage({
current: index,
urls
});
};
const previewVerifyImage = (index) => {
const urls = verifyAttachments.value.map((item) => getFullPath(item.filePath));
common_vendor.index.previewImage({
current: index,
urls
});
};
const mapPersonListToNickNames = (people) => {
if (!Array.isArray(people) || people.length === 0)
return [];
const names = people.map((person) => person.nickName || person.userName || person.name || "").filter(Boolean);
return [...new Set(names)];
};
const resolveManagerNames = (rectify) => {
if (Array.isArray(rectify.managers) && rectify.managers.length > 0) {
return mapPersonListToNickNames(rectify.managers);
}
return rectify.managerNames || [];
};
const resolveMemberNames = (rectify) => {
if (Array.isArray(rectify.members) && rectify.members.length > 0) {
return mapPersonListToNickNames(rectify.members);
}
return rectify.memberNames || [];
};
const resolveLatestVerify = (verifies) => {
if (!Array.isArray(verifies) || verifies.length === 0)
return null;
return verifies[verifies.length - 1];
};
const resolveVerifyResultName = (verify) => {
if (!verify)
return "";
if (verify.resultName)
return verify.resultName;
if (verify.result === 1)
return "通过";
if (verify.result === 2)
return "不通过";
return "";
};
const applyVerifyData = (rectify) => {
const verify = resolveLatestVerify(rectify == null ? void 0 : rectify.verifies);
if (!verify) {
verifyData.verifyId = null;
verifyData.resultName = "";
verifyData.remark = "";
verifyData.verifierName = "";
verifyData.verifyTime = "";
verifyAttachments.value = [];
return;
}
verifyData.verifyId = verify.verifyId ?? null;
verifyData.resultName = resolveVerifyResultName(verify);
verifyData.remark = verify.remark || "";
verifyData.verifierName = verify.verifierName || "";
verifyData.verifyTime = verify.verifyTime || "";
verifyAttachments.value = verify.attachments || [];
};
const applyRectifyData = (rectify) => {
if (!rectify)
return;
rectifyData.rectifyPlan = rectify.rectifyPlan || "";
rectifyData.rectificationMeasures = rectify.rectificationMeasures || "";
rectifyData.controlMeasures = rectify.controlMeasures || "";
rectifyData.rectifyResult = rectify.rectifyResult || "";
rectifyData.planCost = rectify.planCost ?? null;
rectifyData.actualCost = rectify.actualCost ?? null;
rectifyData.managerNames = resolveManagerNames(rectify);
rectifyData.memberNames = resolveMemberNames(rectify);
rectifyData.rectifierName = rectify.rectifierName || "";
rectifyData.rectifyStatusName = rectify.rectifyStatusName || rectify.statusName || "";
rectifyAttachments.value = rectify.attachments || [];
applyVerifyData(rectify);
};
const fetchRectifyDetail = async () => {
if (!rectifyId.value)
return;
try {
const res = await request_api.getRectifyDetail({ rectifyId: rectifyId.value });
if (res.code === 0 && res.data) {
applyRectifyData(res.data);
if (!hazardId.value && res.data.hazardId) {
hazardId.value = String(res.data.hazardId);
}
if (!assignId.value && res.data.assignId) {
assignId.value = String(res.data.assignId);
}
const resolvedTaskId = resolveTaskIdFromDetail(res.data);
if (resolvedTaskId) {
taskId.value = resolvedTaskId;
}
} else {
common_vendor.index.showToast({ title: res.msg || "获取整改详情失败", icon: "none" });
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance-approval.vue:939", "获取整改详情失败:", error);
common_vendor.index.showToast({ title: "获取整改详情失败", icon: "none" });
}
};
const fetchDetail = async () => {
if (!hazardId.value)
return;
try {
const res = await request_api.getHiddenDangerDetail({
hazardId: hazardId.value,
assignId: assignId.value
});
if (res.code === 0 && res.data) {
const assign = resolveAssignWithRectify(res.data.assigns);
if (assign == null ? void 0 : assign.rectify) {
applyRectifyData(assign.rectify);
if (!rectifyId.value && assign.rectify.rectifyId) {
rectifyId.value = String(assign.rectify.rectifyId);
}
} else {
common_vendor.index.showToast({ title: "该隐患暂无整改记录", icon: "none" });
}
const resolvedTaskId = resolveTaskIdFromAssign(assign) || resolveTaskIdFromDetail(res.data);
if (resolvedTaskId) {
taskId.value = resolvedTaskId;
}
} else {
common_vendor.index.showToast({ title: res.msg || "获取详情失败", icon: "none" });
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance-approval.vue:971", "获取隐患详情失败:", error);
common_vendor.index.showToast({ title: "请求失败", icon: "none" });
}
};
const loadPageData = async () => {
if (hazardId.value) {
await fetchDetail();
} else if (rectifyId.value) {
await fetchRectifyDetail();
}
await fetchFlowContext();
};
const validateFormBeforeSubmit = () => {
var _a;
if (!taskId.value) {
common_vendor.index.showToast({ title: "缺少任务ID", icon: "none" });
return false;
}
if (!formData.approvalOpinion) {
common_vendor.index.showToast({ title: "请选择审批意见", icon: "none" });
return false;
}
if (!((_a = formData.opinionRemark) == null ? void 0 : _a.trim())) {
common_vendor.index.showToast({ title: "请输入意见说明", icon: "none" });
return false;
}
if (!nextStepName.value) {
common_vendor.index.showToast({ title: "暂无下一步流程", icon: "none" });
return false;
}
if (!isFixedNextStepOpinion(formData.approvalOpinion) && !nextStepKey.value) {
common_vendor.index.showToast({ title: "暂无下一步流程", icon: "none" });
return false;
}
if (needNextAssignee.value && !selectedAssigneeIdentityId.value) {
common_vendor.index.showToast({ title: "请选择下一步处理人", icon: "none" });
return false;
}
if (!verifyData.verifyId) {
common_vendor.index.showToast({ title: "缺少验收记录ID", icon: "none" });
return false;
}
return true;
};
const handleCancel = () => {
common_vendor.index.navigateBack();
};
const handleSubmit = async () => {
if (!validateFormBeforeSubmit()) {
return;
}
if (showCanvas.value) {
if (!signatureRef.value || isSignatureEmpty.value) {
common_vendor.index.showToast({
title: "请进行电子签名",
icon: "none"
});
return;
}
isSubmitting.value = true;
common_vendor.index.showLoading({ title: "正在提交...", mask: true });
signatureRef.value.confirm();
} else {
if (!signatureServerPath.value && !signatureLocalPath.value) {
common_vendor.index.showToast({
title: "请进行电子签名",
icon: "none"
});
return;
}
isSubmitting.value = true;
common_vendor.index.showLoading({ title: "正在提交...", mask: true });
try {
if (!signatureServerPath.value && signatureLocalPath.value) {
const { url } = await utils_upload.uploadToCloud(signatureLocalPath.value);
applySignatureFromServer(url);
}
await executeSubmit();
} catch (err) {
isSubmitting.value = false;
common_vendor.index.hideLoading();
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance-approval.vue:1062", "签名上传失败:", err);
common_vendor.index.showToast({ title: "签名上传失败,请重试", icon: "none" });
}
}
};
const executeSubmit = async () => {
const params = {
taskId: taskId.value,
bizId: Number(verifyData.verifyId),
comment: formData.opinionRemark.trim(),
type: resolveApproveType(formData.approvalOpinion),
signPath: signatureServerPath.value || "",
sendMsgFlag: sendMsgFlag.value,
nextStepName: nextStepName.value
};
if (nextStepKey.value) {
params.nextStepKey = nextStepKey.value;
}
if (needNextAssignee.value) {
params.nextAssigneeIdentityId = Number(selectedAssigneeIdentityId.value);
params.nextAssigneeName = selectedAssigneeName.value;
params.nextAssigneeCategory = "identity";
}
if (formData.approvalOpinion === "report") {
params.reportLeader = true;
}
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance-approval.vue:1093", "提交审批参数:", params);
try {
const res = await request_api.flowTaskApprove(params);
common_vendor.index.hideLoading();
if (res.code === 0) {
clearDraft(false);
common_vendor.index.showToast({
title: "审批成功",
icon: "success"
});
setTimeout(() => {
common_vendor.index.navigateBack();
}, 1500);
} else {
common_vendor.index.showToast({
title: res.msg || "审批失败",
icon: "none"
});
}
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance-approval.vue:1115", "审批失败:", error);
common_vendor.index.showToast({
title: "请求失败",
icon: "none"
});
} finally {
isSubmitting.value = false;
}
};
const onSignatureStart = () => {
isSignatureEmpty.value = false;
};
const onSignatureSigning = () => {
isSignatureEmpty.value = false;
};
const onSignatureClear = () => {
isSignatureEmpty.value = true;
signatureLocalPath.value = "";
};
const scheduleSignatureDraftExport = () => {
clearTimeout(signatureExportTimer);
signatureExportTimer = setTimeout(() => {
if (!showCanvas.value || isSignatureEmpty.value || !signatureRef.value || isSubmitting.value || isDraftExporting.value) {
return;
}
isDraftExporting.value = true;
signatureRef.value.confirm();
}, 600);
};
const onSignatureEnd = () => {
isSignatureEmpty.value = false;
scheduleSignatureDraftExport();
};
const clearSignature = () => {
clearTimeout(signatureExportTimer);
isSignatureEmpty.value = true;
signatureLocalPath.value = "";
if (signatureRef.value) {
signatureRef.value.clear();
}
};
const reSign = () => {
clearTimeout(signatureExportTimer);
isSignatureEmpty.value = true;
showCanvas.value = true;
signatureUrl.value = "";
signatureServerPath.value = "";
signatureLocalPath.value = "";
common_vendor.nextTick$1(() => {
if (signatureRef.value) {
signatureRef.value.clear();
}
});
};
const onSignatureConfirm = async (tempFilePath) => {
if (isDraftExporting.value) {
isDraftExporting.value = false;
applySignatureFromLocal(tempFilePath);
saveDraft();
return;
}
try {
const { url } = await utils_upload.uploadToCloud(tempFilePath);
applySignatureFromServer(url);
saveDraft();
if (isSubmitting.value) {
await executeSubmit();
}
} catch (err) {
isSubmitting.value = false;
common_vendor.index.hideLoading();
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance-approval.vue:1214", "签名上传失败:", err);
common_vendor.index.showToast({ title: "签名上传失败,请重试", icon: "none" });
}
};
common_vendor.onHide(() => {
if (showCanvas.value && !isSignatureEmpty.value && signatureRef.value && !isDraftExporting.value) {
isDraftExporting.value = true;
signatureRef.value.confirm();
}
saveDraft();
});
common_vendor.onLoad(async (options) => {
try {
const sysInfo = common_vendor.index.getSystemInfoSync();
signatureWidth.value = sysInfo.windowWidth - 40;
} catch (e) {
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance-approval.vue:1233", "获取系统信息失败:", e);
}
if (options.rectifyId) {
rectifyId.value = options.rectifyId;
}
if (options.hazardId) {
hazardId.value = options.hazardId;
}
if (options.assignId) {
assignId.value = options.assignId;
}
if (options.taskId) {
taskId.value = options.taskId;
}
if (options.taskKey) {
currentTaskKey.value = String(options.taskKey);
}
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance-approval.vue:1251", "验收审批页面参数:", {
rectifyId: rectifyId.value,
hazardId: hazardId.value,
assignId: assignId.value,
taskId: taskId.value,
taskKey: currentTaskKey.value
});
await loadPageData();
restoreDraft();
});
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.t(rectifyData.rectifyPlan || "暂无"),
b: common_vendor.t(rectifyData.rectificationMeasures || "暂无"),
c: common_vendor.t(rectifyData.controlMeasures || "暂无"),
d: common_vendor.t(rectifyData.rectifyResult || "暂无"),
e: common_vendor.t(formatMoney(rectifyData.planCost)),
f: common_vendor.t(formatMoney(rectifyData.actualCost)),
g: common_vendor.t(formatPersonNames(rectifyData.managerNames)),
h: common_vendor.t(formatPersonNames(rectifyData.memberNames)),
i: common_vendor.t(rectifyData.rectifyStatusName || "暂无"),
j: rectifyAttachments.value.length > 0
}, rectifyAttachments.value.length > 0 ? {
k: common_vendor.f(rectifyAttachments.value, (img, idx, i0) => {
return {
a: idx,
b: getFullPath(img.filePath),
c: common_vendor.o(($event) => previewImage(idx), idx)
};
})
} : {}, {
l: common_vendor.t(verifyData.resultName || "暂无"),
m: common_vendor.t(verifyData.remark || "暂无"),
n: common_vendor.t(verifyData.verifierName || "暂无"),
o: common_vendor.t(verifyData.verifyTime || "暂无"),
p: verifyAttachments.value.length > 0
}, verifyAttachments.value.length > 0 ? {
q: common_vendor.f(verifyAttachments.value, (img, idx, i0) => {
return {
a: idx,
b: getFullPath(img.filePath),
c: common_vendor.o(($event) => previewVerifyImage(idx), idx)
};
})
} : {}, {
r: common_vendor.f(approvalOptions.value, (opt, index, i0) => {
return {
a: opt.value,
b: "1ff36a41-1-" + i0 + ",1ff36a41-0",
c: common_vendor.p({
label: opt.label,
name: opt.value,
customStyle: {
marginRight: index < approvalOptions.value.length - 1 ? "24rpx" : "0"
}
})
};
}),
s: common_vendor.o(($event) => formData.approvalOpinion = $event),
t: common_vendor.p({
placement: "row",
activeColor: "#2667e9",
modelValue: formData.approvalOpinion
}),
v: common_vendor.o(($event) => formData.opinionRemark = $event),
w: common_vendor.p({
placeholder: "请输入意见说明",
modelValue: formData.opinionRemark
}),
x: common_vendor.t(nextStepDisplay.value),
y: needNextAssignee.value
}, needNextAssignee.value ? {} : {}, {
z: needNextAssignee.value
}, needNextAssignee.value ? {
A: common_vendor.t(selectedAssigneeName.value || "请选择下一步处理人"),
B: !selectedAssigneeName.value ? 1 : "",
C: common_vendor.o(openAssigneePopup)
} : {}, {
D: common_vendor.o(cancelAssigneeSelect),
E: common_vendor.o(confirmAssigneeSelect),
F: common_vendor.o(($event) => pickerAssigneeIdentityId.value = $event),
G: common_vendor.o(($event) => pickerAssigneeName.value = $event),
H: common_vendor.p({
show: showAssigneePopup.value,
["task-id"]: taskId.value,
["picker-identity-id"]: pickerAssigneeIdentityId.value,
["picker-name"]: pickerAssigneeName.value
}),
I: common_vendor.p({
label: "是",
name: "yes",
customStyle: {
marginRight: "48rpx"
}
}),
J: common_vendor.p({
label: "否",
name: "no"
}),
K: common_vendor.o(($event) => sendMsgFlagRadio.value = $event),
L: common_vendor.p({
placement: "row",
activeColor: "#2667e9",
modelValue: sendMsgFlagRadio.value
}),
M: showCanvas.value
}, showCanvas.value ? {
N: common_vendor.o(clearSignature)
} : {
O: common_vendor.o(reSign)
}, {
P: !showCanvas.value
}, !showCanvas.value ? common_vendor.e({
Q: signatureUrl.value
}, signatureUrl.value ? {
R: signatureUrl.value
} : {}) : {}, {
S: showCanvas.value && !showAssigneePopup.value
}, showCanvas.value && !showAssigneePopup.value ? {
T: common_vendor.sr(signatureRef, "1ff36a41-7", {
"k": "signatureRef"
}),
U: common_vendor.o((res) => onSignatureConfirm(res.tempFilePath)),
V: common_vendor.o(onSignatureStart),
W: common_vendor.o(onSignatureSigning),
X: common_vendor.o(onSignatureEnd),
Y: common_vendor.o(onSignatureClear),
Z: common_vendor.p({
width: signatureWidth.value,
height: 160,
backgroundColor: "#f8f8f8",
penColor: "#000000",
lineWidth: 3,
enableHistory: false
})
} : {}, {
aa: common_vendor.o(handleCancel),
ab: common_vendor.o(handleSubmit),
ac: common_vendor.gei(_ctx, "")
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1ff36a41"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/hiddendanger/acceptance-approval.js.map