878 lines
33 KiB
JavaScript
878 lines
33 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_textarea2 = common_vendor.resolveComponent("up-textarea");
|
||
const _easycom_up_upload2 = common_vendor.resolveComponent("up-upload");
|
||
const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
|
||
const _easycom_wd_signature2 = common_vendor.resolveComponent("wd-signature");
|
||
(_easycom_up_textarea2 + _easycom_up_upload2 + _easycom_u_popup2 + _easycom_wd_signature2)();
|
||
}
|
||
const _easycom_up_textarea = () => "../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
|
||
const _easycom_up_upload = () => "../../uni_modules/uview-plus/components/u-upload/u-upload.js";
|
||
const _easycom_u_popup = () => "../../uni_modules/uview-plus/components/u-popup/u-popup.js";
|
||
const _easycom_wd_signature = () => "../../node-modules/wot-design-uni/components/wd-signature/wd-signature.js";
|
||
if (!Math) {
|
||
(_easycom_up_textarea + _easycom_up_upload + _easycom_u_popup + _easycom_wd_signature)();
|
||
}
|
||
const _sfc_main = {
|
||
__name: "acceptance",
|
||
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 nextStepLoading = common_vendor.ref(false);
|
||
const nextStepDisplay = common_vendor.computed(() => {
|
||
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 resolveNextTaskName = (data) => {
|
||
var _a;
|
||
if (!data)
|
||
return "";
|
||
const branches = data.branches || [];
|
||
const matchedBranch = branches.find((item) => item.matched) || branches[0];
|
||
return ((_a = matchedBranch == null ? void 0 : matchedBranch.nextNode) == null ? void 0 : _a.taskName) || "";
|
||
};
|
||
const buildPreviewVariables = () => {
|
||
if (formData.result === 2) {
|
||
return { pass: false };
|
||
}
|
||
return {
|
||
pass: true,
|
||
quickApprove: formData.quickApproveRadio === "yes"
|
||
};
|
||
};
|
||
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 getCurrentDeptId = () => {
|
||
const userInfo = getStoredUserInfo();
|
||
const identity = userInfo.userIdentity;
|
||
if ((identity == null ? void 0 : identity.deptId) != null && identity.deptId !== "") {
|
||
return String(identity.deptId);
|
||
}
|
||
if (userInfo.deptId != null && userInfo.deptId !== "") {
|
||
return String(userInfo.deptId);
|
||
}
|
||
return "";
|
||
};
|
||
const rectifierDisplayName = common_vendor.computed(() => {
|
||
var _a;
|
||
return ((_a = rectifyData.rectifierName) == null ? void 0 : _a.trim()) || "暂无";
|
||
});
|
||
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 assigneeList = common_vendor.ref([]);
|
||
const assigneeLoading = common_vendor.ref(false);
|
||
const resolveAssigneeIdentityId = (user) => {
|
||
if (!user)
|
||
return "";
|
||
const id = user.identityId ?? user.userIdentityId ?? user.userId ?? "";
|
||
return id === "" || id == null ? "" : String(id);
|
||
};
|
||
const getAssigneeItemKey = (user) => {
|
||
const identityId = resolveAssigneeIdentityId(user);
|
||
if (identityId)
|
||
return `identity-${identityId}`;
|
||
return `user-${user.userId || user.nickName || ""}`;
|
||
};
|
||
const formatAssigneeDisplayName = (user) => {
|
||
if (!user)
|
||
return "";
|
||
const name = user.nickName || user.userName || user.name || "";
|
||
const identityName = user.identityName || "";
|
||
if (name && identityName)
|
||
return `${name}(${identityName})`;
|
||
return name || identityName || "未知人员";
|
||
};
|
||
const resolveAssigneeDeptUserType = () => formData.quickApproveRadio === "yes" ? 2 : 3;
|
||
const fetchAssigneeList = async () => {
|
||
const deptId = getCurrentDeptId();
|
||
if (!deptId) {
|
||
assigneeList.value = [];
|
||
return;
|
||
}
|
||
assigneeLoading.value = true;
|
||
try {
|
||
const res = await request_api.getDeptUsers(deptId, { type: resolveAssigneeDeptUserType() });
|
||
if (res.code === 0) {
|
||
assigneeList.value = res.data || [];
|
||
} else {
|
||
assigneeList.value = [];
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:352", "获取部门人员失败:", error);
|
||
assigneeList.value = [];
|
||
} finally {
|
||
assigneeLoading.value = false;
|
||
}
|
||
};
|
||
const openAssigneePopup = async () => {
|
||
pickerAssigneeIdentityId.value = selectedAssigneeIdentityId.value;
|
||
pickerAssigneeName.value = selectedAssigneeName.value;
|
||
showAssigneePopup.value = true;
|
||
await fetchAssigneeList();
|
||
};
|
||
const onAssigneeItemClick = (user) => {
|
||
const identityId = resolveAssigneeIdentityId(user);
|
||
if (!identityId)
|
||
return;
|
||
pickerAssigneeIdentityId.value = String(identityId);
|
||
pickerAssigneeName.value = formatAssigneeDisplayName(user);
|
||
};
|
||
const confirmAssigneeSelect = () => {
|
||
if (!pickerAssigneeIdentityId.value) {
|
||
common_vendor.index.showToast({ title: "请选择下一步处理人", icon: "none" });
|
||
return;
|
||
}
|
||
selectedAssigneeIdentityId.value = pickerAssigneeIdentityId.value;
|
||
selectedAssigneeName.value = pickerAssigneeName.value;
|
||
showAssigneePopup.value = false;
|
||
};
|
||
const cancelAssigneeSelect = () => {
|
||
showAssigneePopup.value = false;
|
||
};
|
||
const onResultChange = (result) => {
|
||
formData.result = result;
|
||
if (result === 2) {
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
} else if (!formData.quickApproveRadio) {
|
||
formData.quickApproveRadio = "yes";
|
||
}
|
||
fetchNextStep();
|
||
};
|
||
const onQuickApproveChange = (value) => {
|
||
formData.quickApproveRadio = value;
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
fetchNextStep();
|
||
};
|
||
const fetchNextStep = async () => {
|
||
nextStepLoading.value = true;
|
||
try {
|
||
const currentTaskId = taskId.value;
|
||
if (!currentTaskId) {
|
||
nextStepName.value = "";
|
||
return;
|
||
}
|
||
const res = await request_api.getFlowNextNodes({
|
||
taskId: currentTaskId,
|
||
previewVariables: buildPreviewVariables(),
|
||
includeSubProcess: true
|
||
});
|
||
if (res.code === 0) {
|
||
const payload = res.data && typeof res.data === "object" ? res.data : res;
|
||
nextStepName.value = resolveNextTaskName(payload);
|
||
} else {
|
||
nextStepName.value = "";
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:425", "获取下一步流程失败:", error);
|
||
nextStepName.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({
|
||
result: 1,
|
||
// 验收结果 1.通过 2.不通过
|
||
verifyRemark: "",
|
||
// 验收备注
|
||
quickApproveRadio: "yes"
|
||
// 是否快速审批 yes/no,仅通过时有效
|
||
});
|
||
const fileList1 = common_vendor.ref([]);
|
||
const canvasWidth = common_vendor.ref(300);
|
||
const canvasHeight = common_vendor.ref(300);
|
||
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.verifyRemark || data.fileList1 && data.fileList1.length > 0 || 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, rectifyId.value),
|
||
getFallbackKeys: () => {
|
||
const primary = utils_draftCache.buildDraftKey(utils_draftCache.DRAFT_NS.ACCEPT, rectifyId.value);
|
||
const compact = utils_draftCache.buildDraftKeyCompact(utils_draftCache.DRAFT_NS.ACCEPT, rectifyId.value);
|
||
return compact !== primary ? [compact] : [];
|
||
},
|
||
getPayload: () => ({
|
||
formData: {
|
||
result: formData.result,
|
||
verifyRemark: formData.verifyRemark,
|
||
quickApproveRadio: formData.quickApproveRadio
|
||
},
|
||
selectedAssigneeIdentityId: selectedAssigneeIdentityId.value,
|
||
selectedAssigneeName: selectedAssigneeName.value,
|
||
fileList1: fileList1.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 || {};
|
||
formData.result = form.result !== void 0 ? form.result : 1;
|
||
formData.verifyRemark = form.verifyRemark || "";
|
||
formData.quickApproveRadio = form.quickApproveRadio === "no" ? "no" : "yes";
|
||
selectedAssigneeIdentityId.value = data.selectedAssigneeIdentityId || "";
|
||
selectedAssigneeName.value = data.selectedAssigneeName || "";
|
||
fileList1.value = data.fileList1 || [];
|
||
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;
|
||
}
|
||
},
|
||
clearForm: () => {
|
||
formData.result = 1;
|
||
formData.verifyRemark = "";
|
||
formData.quickApproveRadio = "yes";
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
fileList1.value = [];
|
||
signatureServerPath.value = "";
|
||
signatureUrl.value = "";
|
||
signatureLocalPath.value = "";
|
||
showCanvas.value = true;
|
||
signaturePaths.value = [];
|
||
if (signatureRef.value) {
|
||
signatureRef.value.clear();
|
||
}
|
||
},
|
||
canSave: () => !!rectifyId.value,
|
||
requireInitialized: true,
|
||
onAfterRestore: (data) => {
|
||
var _a;
|
||
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.result,
|
||
formData.verifyRemark,
|
||
formData.quickApproveRadio,
|
||
selectedAssigneeIdentityId.value,
|
||
selectedAssigneeName.value,
|
||
fileList1.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 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 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 || [];
|
||
};
|
||
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.vue:719", "获取整改详情失败:", 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.vue:751", "获取隐患详情失败:", error);
|
||
common_vendor.index.showToast({ title: "请求失败", icon: "none" });
|
||
}
|
||
};
|
||
const loadPageData = async () => {
|
||
if (rectifyId.value) {
|
||
await fetchRectifyDetail();
|
||
} else if (hazardId.value) {
|
||
await fetchDetail();
|
||
}
|
||
await fetchNextStep();
|
||
};
|
||
const validateFormBeforeSubmit = () => {
|
||
if (formData.result === 1 && !formData.quickApproveRadio) {
|
||
common_vendor.index.showToast({ title: "请选择是否快速审批", icon: "none" });
|
||
return false;
|
||
}
|
||
if (formData.result === 1 && formData.quickApproveRadio === "no" && !selectedAssigneeIdentityId.value) {
|
||
common_vendor.index.showToast({ title: "请选择下一步处理人", icon: "none" });
|
||
return false;
|
||
}
|
||
return true;
|
||
};
|
||
const handleCancel = () => {
|
||
common_vendor.index.navigateBack();
|
||
};
|
||
const handleSubmit = async () => {
|
||
if (!rectifyId.value) {
|
||
common_vendor.index.showToast({
|
||
title: "缺少整改ID",
|
||
icon: "none"
|
||
});
|
||
return;
|
||
}
|
||
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.vue:830", "签名上传失败:", err);
|
||
common_vendor.index.showToast({ title: "签名上传失败,请重试", icon: "none" });
|
||
}
|
||
}
|
||
};
|
||
const executeSubmit = async () => {
|
||
const attachments = fileList1.value.filter((f) => f.status === "success").map((file) => utils_upload.buildAttachmentItem(file));
|
||
const params = {
|
||
rectifyId: Number(rectifyId.value),
|
||
result: formData.result,
|
||
verifyRemark: formData.verifyRemark || "",
|
||
attachments,
|
||
signPath: signatureServerPath.value || ""
|
||
// 电子签名路径
|
||
// sendMsgFlag: sendMsgFlag.value
|
||
};
|
||
if (formData.result === 1) {
|
||
params.quickApprove = formData.quickApproveRadio === "yes";
|
||
if (formData.quickApproveRadio === "no") {
|
||
params.assigneeIdentityId = selectedAssigneeIdentityId.value;
|
||
}
|
||
}
|
||
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance.vue:859", "提交验收参数:", params);
|
||
try {
|
||
const res = await request_api.acceptanceRectification(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.vue:881", "验收失败:", error);
|
||
common_vendor.index.showToast({
|
||
title: "请求失败",
|
||
icon: "none"
|
||
});
|
||
} finally {
|
||
isSubmitting.value = false;
|
||
}
|
||
};
|
||
const acceptUploadInstance = common_vendor.getCurrentInstance();
|
||
const { afterRead, deletePic } = utils_upload.createUploadListHandlers(fileList1, {
|
||
watermark: {
|
||
canvasId: "watermarkCanvas",
|
||
canvasWidthRef: canvasWidth,
|
||
canvasHeightRef: canvasHeight,
|
||
instance: acceptUploadInstance
|
||
}
|
||
});
|
||
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.vue:990", "签名上传失败:", 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((options) => {
|
||
try {
|
||
const sysInfo = common_vendor.index.getSystemInfoSync();
|
||
signatureWidth.value = sysInfo.windowWidth - 40;
|
||
} catch (e) {
|
||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:1009", "获取系统信息失败:", 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;
|
||
}
|
||
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance.vue:1023", "验收页面参数:", { rectifyId: rectifyId.value, hazardId: hazardId.value, assignId: assignId.value, taskId: taskId.value });
|
||
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.n(formData.result === 1 ? "active" : ""),
|
||
m: common_vendor.o(($event) => onResultChange(1)),
|
||
n: common_vendor.n(formData.result === 2 ? "active" : ""),
|
||
o: common_vendor.o(($event) => onResultChange(2)),
|
||
p: common_vendor.o(($event) => formData.verifyRemark = $event),
|
||
q: common_vendor.p({
|
||
placeholder: "请输入验收备注",
|
||
modelValue: formData.verifyRemark
|
||
}),
|
||
r: common_vendor.o(common_vendor.unref(afterRead)),
|
||
s: common_vendor.o(common_vendor.unref(deletePic)),
|
||
t: common_vendor.p({
|
||
fileList: fileList1.value,
|
||
name: "1",
|
||
multiple: true,
|
||
imageMode: "aspectFill",
|
||
maxCount: 10
|
||
}),
|
||
v: formData.result === 1
|
||
}, formData.result === 1 ? {} : {}, {
|
||
w: formData.result === 1
|
||
}, formData.result === 1 ? {
|
||
x: common_vendor.n(formData.quickApproveRadio === "yes" ? "active" : ""),
|
||
y: common_vendor.o(($event) => onQuickApproveChange("yes")),
|
||
z: common_vendor.n(formData.quickApproveRadio === "no" ? "active" : ""),
|
||
A: common_vendor.o(($event) => onQuickApproveChange("no"))
|
||
} : {}, {
|
||
B: canvasWidth.value,
|
||
C: canvasHeight.value,
|
||
D: canvasWidth.value + "px",
|
||
E: canvasHeight.value + "px",
|
||
F: common_vendor.t(nextStepDisplay.value),
|
||
G: formData.result === 2
|
||
}, formData.result === 2 ? {
|
||
H: common_vendor.t(rectifierDisplayName.value)
|
||
} : {
|
||
I: common_vendor.t(selectedAssigneeName.value || "请选择下一步处理人"),
|
||
J: !selectedAssigneeName.value ? 1 : "",
|
||
K: common_vendor.o(openAssigneePopup)
|
||
}, {
|
||
L: common_vendor.o(cancelAssigneeSelect),
|
||
M: assigneeLoading.value
|
||
}, assigneeLoading.value ? {} : assigneeList.value.length === 0 ? {} : {
|
||
O: common_vendor.f(assigneeList.value, (user, k0, i0) => {
|
||
return common_vendor.e({
|
||
a: common_vendor.t(formatAssigneeDisplayName(user)),
|
||
b: String(pickerAssigneeIdentityId.value) === String(resolveAssigneeIdentityId(user))
|
||
}, String(pickerAssigneeIdentityId.value) === String(resolveAssigneeIdentityId(user)) ? {} : {}, {
|
||
c: getAssigneeItemKey(user),
|
||
d: String(pickerAssigneeIdentityId.value) === String(resolveAssigneeIdentityId(user)) ? 1 : "",
|
||
e: common_vendor.o(($event) => onAssigneeItemClick(user), getAssigneeItemKey(user))
|
||
});
|
||
})
|
||
}, {
|
||
N: assigneeList.value.length === 0,
|
||
P: common_vendor.o(cancelAssigneeSelect),
|
||
Q: common_vendor.o(confirmAssigneeSelect),
|
||
R: common_vendor.o(cancelAssigneeSelect),
|
||
S: common_vendor.p({
|
||
show: showAssigneePopup.value,
|
||
mode: "bottom",
|
||
round: "20"
|
||
}),
|
||
T: showCanvas.value
|
||
}, showCanvas.value ? {
|
||
U: common_vendor.o(clearSignature)
|
||
} : {
|
||
V: common_vendor.o(reSign)
|
||
}, {
|
||
W: !showCanvas.value
|
||
}, !showCanvas.value ? common_vendor.e({
|
||
X: signatureUrl.value
|
||
}, signatureUrl.value ? {
|
||
Y: signatureUrl.value
|
||
} : {}) : {}, {
|
||
Z: showCanvas.value && !showAssigneePopup.value
|
||
}, showCanvas.value && !showAssigneePopup.value ? {
|
||
aa: common_vendor.sr(signatureRef, "39f9b795-3", {
|
||
"k": "signatureRef"
|
||
}),
|
||
ab: common_vendor.o((res) => onSignatureConfirm(res.tempFilePath)),
|
||
ac: common_vendor.o(onSignatureStart),
|
||
ad: common_vendor.o(onSignatureSigning),
|
||
ae: common_vendor.o(onSignatureEnd),
|
||
af: common_vendor.o(onSignatureClear),
|
||
ag: common_vendor.p({
|
||
width: signatureWidth.value,
|
||
height: 160,
|
||
backgroundColor: "#f8f8f8",
|
||
penColor: "#000000",
|
||
lineWidth: 3,
|
||
enableHistory: false
|
||
})
|
||
} : {}, {
|
||
ah: common_vendor.o(handleCancel),
|
||
ai: common_vendor.o(handleSubmit),
|
||
aj: common_vendor.gei(_ctx, "")
|
||
});
|
||
};
|
||
}
|
||
};
|
||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-39f9b795"]]);
|
||
wx.createPage(MiniProgramPage);
|
||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/hiddendanger/acceptance.js.map
|