813 lines
31 KiB
JavaScript
813 lines
31 KiB
JavaScript
"use strict";
|
||
const common_vendor = require("../../common/vendor.js");
|
||
const request_api = require("../../request/api.js");
|
||
const utils_upload = require("../../utils/upload.js");
|
||
const utils_hazardNav = require("../../utils/hazardNav.js");
|
||
if (!Array) {
|
||
const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
|
||
const _easycom_up_radio2 = common_vendor.resolveComponent("up-radio");
|
||
const _easycom_up_radio_group2 = common_vendor.resolveComponent("up-radio-group");
|
||
const _easycom_wd_signature2 = common_vendor.resolveComponent("wd-signature");
|
||
const _easycom_up_picker2 = common_vendor.resolveComponent("up-picker");
|
||
(_easycom_up_textarea2 + _easycom_up_radio2 + _easycom_up_radio_group2 + _easycom_wd_signature2 + _easycom_up_picker2)();
|
||
}
|
||
const _easycom_up_textarea = () => "../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
|
||
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_wd_signature = () => "../../node-modules/wot-design-uni/components/wd-signature/wd-signature.js";
|
||
const _easycom_up_picker = () => "../../uni_modules/uview-plus/components/u-picker/u-picker.js";
|
||
if (!Math) {
|
||
(_easycom_up_textarea + _easycom_up_radio + _easycom_up_radio_group + _easycom_wd_signature + _easycom_up_picker + FlowAssigneePickerPopup)();
|
||
}
|
||
const FlowAssigneePickerPopup = () => "../../components/flow/FlowAssigneePickerPopup.js";
|
||
const FLOW_END_STEP_NAME = "隐患流程结束";
|
||
const _sfc_main = {
|
||
__name: "approval",
|
||
setup(__props) {
|
||
const showHazardPicker = common_vendor.ref(false);
|
||
const hazardLocked = common_vendor.ref(false);
|
||
const selectedHazard = common_vendor.ref("");
|
||
const selectedHazardId = common_vendor.ref("");
|
||
const applyId = common_vendor.ref("");
|
||
const assignId = common_vendor.ref("");
|
||
const taskId = common_vendor.ref("");
|
||
const hazardColumns = common_vendor.ref([["暂无数据"]]);
|
||
const acceptanceHazardList = common_vendor.ref([]);
|
||
const selectedDeptName = common_vendor.ref("");
|
||
const aiGenerating = common_vendor.ref(false);
|
||
const quickApproveRadio = common_vendor.ref("yes");
|
||
const quickApprove = common_vendor.computed(() => quickApproveRadio.value === "yes");
|
||
const sendMsgFlagRadio = common_vendor.ref("yes");
|
||
const sendMsgFlag = common_vendor.computed(() => sendMsgFlagRadio.value === "yes");
|
||
const nextStepName = common_vendor.ref("");
|
||
const nextStepLoading = common_vendor.ref(false);
|
||
const nextStepDisplay = common_vendor.computed(() => {
|
||
if (nextStepLoading.value)
|
||
return "加载中...";
|
||
return nextStepName.value || "暂无下一步流程";
|
||
});
|
||
const needNextAssignee = common_vendor.computed(() => {
|
||
if (formData.approvalResult !== 1)
|
||
return false;
|
||
if (quickApprove.value && nextStepName.value === FLOW_END_STEP_NAME)
|
||
return false;
|
||
return true;
|
||
});
|
||
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 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 signatureLocalPath = common_vendor.ref("");
|
||
const approvalOptions = [
|
||
{ label: "重新整改", value: "rectify" },
|
||
{ label: "重新验收", value: "verify" }
|
||
];
|
||
const formData = common_vendor.reactive({
|
||
rectifyDeadline: "",
|
||
responsibleDeptId: "",
|
||
responsiblePerson: "",
|
||
mainTreatmentContent: "",
|
||
treatmentResult: "",
|
||
selfVerifyContent: "",
|
||
approvalResult: 1,
|
||
approvalOpinion: "",
|
||
opinionRemark: ""
|
||
});
|
||
const onApprovalResultChange = (result) => {
|
||
formData.approvalResult = result;
|
||
if (result === 2) {
|
||
quickApproveRadio.value = "no";
|
||
formData.approvalOpinion = "";
|
||
formData.opinionRemark = "";
|
||
} else {
|
||
formData.approvalOpinion = "";
|
||
formData.opinionRemark = "";
|
||
quickApproveRadio.value = "yes";
|
||
}
|
||
resetSignature();
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
if (result === 1) {
|
||
fetchNextStep();
|
||
} else {
|
||
nextStepName.value = "";
|
||
}
|
||
};
|
||
const fillHazardRelatedFields = (hazard) => {
|
||
formData.rectifyDeadline = hazard.deadline || "";
|
||
selectedDeptName.value = hazard.deptName || "";
|
||
formData.responsiblePerson = hazard.rectifierName || "";
|
||
formData.responsibleDeptId = hazard.deptId || "";
|
||
};
|
||
const applyWriteoffHazardPreview = (hazard) => {
|
||
if (!hazard)
|
||
return;
|
||
selectedHazard.value = hazard.title || hazard.hazardTitle || `隐患${hazard.hazardId}`;
|
||
selectedHazardId.value = String(hazard.hazardId);
|
||
if (hazard.assignId) {
|
||
assignId.value = String(hazard.assignId);
|
||
}
|
||
if (hazard.taskId) {
|
||
taskId.value = String(hazard.taskId);
|
||
}
|
||
fillHazardRelatedFields(hazard);
|
||
};
|
||
const resolveTaskIdFromHazard = (hazard) => {
|
||
var _a, _b;
|
||
if (!hazard)
|
||
return "";
|
||
const candidates = [
|
||
hazard.taskId,
|
||
hazard.flowTaskId,
|
||
hazard.currentTaskId,
|
||
(_a = hazard.flowTask) == null ? void 0 : _a.taskId,
|
||
(_b = hazard.currentTask) == null ? void 0 : _b.taskId
|
||
];
|
||
for (const id of candidates) {
|
||
if (id != null && id !== "")
|
||
return String(id);
|
||
}
|
||
return "";
|
||
};
|
||
const resolveTaskIdFromAssign = (assign) => {
|
||
var _a, _b, _c, _d, _e;
|
||
if (!assign)
|
||
return "";
|
||
const candidates = [
|
||
assign.taskId,
|
||
assign.flowTaskId,
|
||
assign.currentTaskId,
|
||
(_a = assign.rectify) == null ? void 0 : _a.taskId,
|
||
(_b = assign.rectify) == null ? void 0 : _b.flowTaskId,
|
||
(_c = assign.rectify) == null ? void 0 : _c.currentTaskId,
|
||
(_d = assign.flow) == null ? void 0 : _d.taskId,
|
||
(_e = assign.currentTask) == null ? void 0 : _e.taskId
|
||
];
|
||
for (const id of candidates) {
|
||
if (id != null && id !== "")
|
||
return String(id);
|
||
}
|
||
return "";
|
||
};
|
||
const resolveAssignWithRectify = (assigns, currentAssignId) => {
|
||
if (!(assigns == null ? void 0 : assigns.length))
|
||
return null;
|
||
if (currentAssignId) {
|
||
const byAssignId = assigns.find(
|
||
(item) => String(item.assignId) === String(currentAssignId) && item.rectify
|
||
);
|
||
if (byAssignId)
|
||
return byAssignId;
|
||
}
|
||
return assigns.find((item) => item.rectify) || assigns[0] || 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, assignId.value);
|
||
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.approvalResult === 2) {
|
||
return { pass: false };
|
||
}
|
||
return {
|
||
pass: true,
|
||
quickApprove: quickApproveRadio.value === "yes",
|
||
type: "agree"
|
||
};
|
||
};
|
||
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 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);
|
||
if (!needNextAssignee.value) {
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
}
|
||
} else {
|
||
nextStepName.value = "";
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/closeout/approval.vue:460", "获取下一步流程失败:", error);
|
||
nextStepName.value = "";
|
||
} finally {
|
||
nextStepLoading.value = false;
|
||
}
|
||
};
|
||
const resolveTaskIdForHazard = async (hazard) => {
|
||
const presetTaskId = taskId.value;
|
||
const fromHazard = resolveTaskIdFromHazard(hazard);
|
||
if (fromHazard) {
|
||
taskId.value = fromHazard;
|
||
}
|
||
if (!(hazard == null ? void 0 : hazard.hazardId)) {
|
||
return;
|
||
}
|
||
if (!assignId.value && hazard.assignId) {
|
||
assignId.value = String(hazard.assignId);
|
||
}
|
||
if (taskId.value) {
|
||
return;
|
||
}
|
||
try {
|
||
const params = { hazardId: hazard.hazardId };
|
||
if (assignId.value) {
|
||
params.assignId = assignId.value;
|
||
}
|
||
const res = await request_api.getHiddenDangerDetail(params);
|
||
if (res.code === 0 && res.data) {
|
||
taskId.value = resolveTaskIdFromDetail(res.data) || presetTaskId;
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/closeout/approval.vue:496", "获取隐患任务信息失败:", error);
|
||
}
|
||
if (!taskId.value && presetTaskId) {
|
||
taskId.value = presetTaskId;
|
||
}
|
||
};
|
||
const resetFlowSelection = () => {
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
nextStepName.value = "";
|
||
};
|
||
const applySelectedHazard = async (hazard) => {
|
||
if (!hazard)
|
||
return;
|
||
selectedHazard.value = hazard.title || hazard.hazardTitle || `隐患${hazard.hazardId}`;
|
||
selectedHazardId.value = hazard.hazardId;
|
||
assignId.value = hazard.assignId ? String(hazard.assignId) : "";
|
||
fillHazardRelatedFields(hazard);
|
||
resetFlowSelection();
|
||
await resolveTaskIdForHazard(hazard);
|
||
await fetchNextStep();
|
||
};
|
||
const formatDeadline = (value) => {
|
||
if (!value)
|
||
return "";
|
||
return String(value).split(" ")[0];
|
||
};
|
||
const applyWriteoffFormData = (data) => {
|
||
if (!data)
|
||
return;
|
||
if (data.hazardId != null) {
|
||
selectedHazardId.value = String(data.hazardId);
|
||
}
|
||
selectedHazard.value = data.title || "";
|
||
formData.rectifyDeadline = formatDeadline(data.rectifyDeadline);
|
||
formData.responsibleDeptId = data.responsibleDeptId ?? "";
|
||
selectedDeptName.value = data.responsibleDeptName || "";
|
||
formData.responsiblePerson = data.responsiblePerson || "";
|
||
if (data.applyId != null) {
|
||
applyId.value = String(data.applyId);
|
||
}
|
||
formData.mainTreatmentContent = data.mainTreatmentContent || "";
|
||
formData.treatmentResult = data.treatmentResult || "";
|
||
formData.selfVerifyContent = data.selfVerifyContent || "";
|
||
};
|
||
const fetchWriteoffForm = async (hazardId) => {
|
||
if (!hazardId)
|
||
return null;
|
||
try {
|
||
const res = await request_api.getWriteoffForm(hazardId);
|
||
if (res.code === 0 && res.data) {
|
||
applyWriteoffFormData(res.data);
|
||
} else {
|
||
common_vendor.index.showToast({ title: res.msg || "获取销号审批表单失败", icon: "none" });
|
||
}
|
||
return res;
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/closeout/approval.vue:555", "获取销号审批表单失败:", error);
|
||
common_vendor.index.showToast({ title: "获取销号审批表单失败", icon: "none" });
|
||
return null;
|
||
}
|
||
};
|
||
const onHazardConfirm = async (e) => {
|
||
if (e.value && e.value.length > 0) {
|
||
const index = e.indexs[0];
|
||
const hazard = acceptanceHazardList.value[index];
|
||
if (hazard) {
|
||
await applySelectedHazard(hazard);
|
||
}
|
||
}
|
||
showHazardPicker.value = false;
|
||
};
|
||
common_vendor.watch(quickApproveRadio, (value) => {
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
if (value === "yes") {
|
||
formData.approvalOpinion = "";
|
||
formData.opinionRemark = "";
|
||
}
|
||
fetchNextStep();
|
||
});
|
||
common_vendor.watch(needNextAssignee, (value) => {
|
||
if (!value) {
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
}
|
||
});
|
||
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 resetSignature = () => {
|
||
showCanvas.value = true;
|
||
signatureUrl.value = "";
|
||
signatureServerPath.value = "";
|
||
signatureLocalPath.value = "";
|
||
isSignatureEmpty.value = true;
|
||
if (signatureRef.value) {
|
||
signatureRef.value.clear();
|
||
}
|
||
};
|
||
const onSignatureStart = () => {
|
||
isSignatureEmpty.value = false;
|
||
};
|
||
const onSignatureSigning = () => {
|
||
isSignatureEmpty.value = false;
|
||
};
|
||
const onSignatureClear = () => {
|
||
isSignatureEmpty.value = true;
|
||
signatureLocalPath.value = "";
|
||
};
|
||
const onSignatureEnd = () => {
|
||
isSignatureEmpty.value = false;
|
||
};
|
||
const clearSignature = () => {
|
||
isSignatureEmpty.value = true;
|
||
signatureLocalPath.value = "";
|
||
if (signatureRef.value) {
|
||
signatureRef.value.clear();
|
||
}
|
||
};
|
||
const reSign = () => {
|
||
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) => {
|
||
try {
|
||
const { url } = await utils_upload.uploadToCloud(tempFilePath);
|
||
applySignatureFromServer(url);
|
||
if (isSubmitting.value) {
|
||
await executeSubmit();
|
||
}
|
||
} catch (err) {
|
||
isSubmitting.value = false;
|
||
common_vendor.index.hideLoading();
|
||
common_vendor.index.__f__("error", "at pages/closeout/approval.vue:681", "签名上传失败:", err);
|
||
common_vendor.index.showToast({ title: "签名上传失败,请重试", icon: "none" });
|
||
}
|
||
};
|
||
const handleAiGenerate = async () => {
|
||
if (!selectedHazardId.value) {
|
||
common_vendor.index.showToast({ title: "请先选择隐患", icon: "none" });
|
||
return;
|
||
}
|
||
aiGenerating.value = true;
|
||
try {
|
||
const hazardRes = await request_api.getHiddenDangerDetail({ hazardId: selectedHazardId.value });
|
||
if (hazardRes.code !== 0 || !hazardRes.data) {
|
||
common_vendor.index.showToast({ title: "获取隐患详情失败", icon: "none" });
|
||
return;
|
||
}
|
||
const assigns = hazardRes.data.assigns;
|
||
if (!assigns || assigns.length === 0 || !assigns[0].rectify) {
|
||
common_vendor.index.showToast({ title: "该隐患暂无整改记录", icon: "none" });
|
||
return;
|
||
}
|
||
const rectifyId = assigns[0].rectify.rectifyId;
|
||
const rectifyRes = await request_api.getRectifyDetail({ rectifyId });
|
||
if (rectifyRes.code !== 0 || !rectifyRes.data) {
|
||
common_vendor.index.showToast({ title: "获取整改详情失败", icon: "none" });
|
||
return;
|
||
}
|
||
const rectifyPlan = rectifyRes.data.rectifyPlan;
|
||
if (!rectifyPlan) {
|
||
common_vendor.index.showToast({ title: "整改方案内容为空", icon: "none" });
|
||
return;
|
||
}
|
||
const aiRes = await request_api.generateWriteoffContent({ rectifyContent: rectifyPlan });
|
||
if (aiRes.code === 0 && aiRes.data) {
|
||
formData.mainTreatmentContent = aiRes.data.mainContent || "";
|
||
formData.treatmentResult = aiRes.data.completionContent || "";
|
||
formData.selfVerifyContent = aiRes.data.selfInspection || "";
|
||
common_vendor.index.showToast({ title: "AI生成成功", icon: "success" });
|
||
} else {
|
||
common_vendor.index.showToast({ title: aiRes.msg || "AI生成失败", icon: "none" });
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/closeout/approval.vue:729", "AI生成销号方案失败:", error);
|
||
common_vendor.index.showToast({ title: "AI生成失败,请重试", icon: "none" });
|
||
} finally {
|
||
aiGenerating.value = false;
|
||
}
|
||
};
|
||
const handleCancel = () => {
|
||
common_vendor.index.navigateBack();
|
||
};
|
||
const ensureSignatureAndSubmit = async () => {
|
||
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();
|
||
return;
|
||
}
|
||
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/closeout/approval.vue:766", "签名上传失败:", err);
|
||
common_vendor.index.showToast({ title: "签名上传失败,请重试", icon: "none" });
|
||
}
|
||
};
|
||
const handleSubmit = async () => {
|
||
var _a;
|
||
if (!selectedHazardId.value) {
|
||
common_vendor.index.showToast({ title: "请选择隐患", icon: "none" });
|
||
return;
|
||
}
|
||
if (!formData.approvalResult) {
|
||
common_vendor.index.showToast({ title: "请选择审批结果", icon: "none" });
|
||
return;
|
||
}
|
||
if (!applyId.value) {
|
||
common_vendor.index.showToast({ title: "缺少申请ID", icon: "none" });
|
||
return;
|
||
}
|
||
if (formData.approvalResult === 1) {
|
||
if (!quickApproveRadio.value) {
|
||
common_vendor.index.showToast({ title: "请选择是否快速审批", icon: "none" });
|
||
return;
|
||
}
|
||
if (needNextAssignee.value && !selectedAssigneeIdentityId.value) {
|
||
common_vendor.index.showToast({ title: "请选择下一步处理人", icon: "none" });
|
||
return;
|
||
}
|
||
await ensureSignatureAndSubmit();
|
||
return;
|
||
}
|
||
if (formData.approvalResult === 2) {
|
||
if (!formData.approvalOpinion) {
|
||
common_vendor.index.showToast({ title: "请选择审批意见", icon: "none" });
|
||
return;
|
||
}
|
||
if (!((_a = formData.opinionRemark) == null ? void 0 : _a.trim())) {
|
||
common_vendor.index.showToast({ title: "请输入意见说明", icon: "none" });
|
||
return;
|
||
}
|
||
await ensureSignatureAndSubmit();
|
||
}
|
||
};
|
||
const executeSubmit = async () => {
|
||
const hazardId = Number(selectedHazardId.value);
|
||
const applyIdNum = Number(applyId.value);
|
||
const signPath = signatureServerPath.value || "";
|
||
try {
|
||
let res;
|
||
if (formData.approvalResult === 1) {
|
||
const approvePayload = {
|
||
hazardId,
|
||
applyId: applyIdNum,
|
||
signPath,
|
||
type: "agree",
|
||
quickApprove: quickApproveRadio.value === "yes",
|
||
sendMsgFlag: sendMsgFlag.value
|
||
};
|
||
if (needNextAssignee.value) {
|
||
approvePayload.assigneeId = Number(selectedAssigneeIdentityId.value);
|
||
}
|
||
res = await request_api.writeoffApprove(approvePayload);
|
||
} else {
|
||
res = await request_api.writeoffReject({
|
||
hazardId,
|
||
applyId: applyIdNum,
|
||
signPath,
|
||
type: formData.approvalOpinion,
|
||
remark: formData.opinionRemark.trim(),
|
||
sendMsgFlag: sendMsgFlag.value
|
||
});
|
||
}
|
||
common_vendor.index.hideLoading();
|
||
if (res.code === 0) {
|
||
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.__f__("error", "at pages/closeout/approval.vue:853", "审批失败:", error);
|
||
common_vendor.index.showToast({ title: "请求失败", icon: "none" });
|
||
} finally {
|
||
isSubmitting.value = false;
|
||
common_vendor.index.hideLoading();
|
||
}
|
||
};
|
||
common_vendor.onLoad(async (options) => {
|
||
try {
|
||
const sysInfo = common_vendor.index.getSystemInfoSync();
|
||
signatureWidth.value = sysInfo.windowWidth - 40;
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/closeout/approval.vue:866", "获取系统信息失败:", error);
|
||
}
|
||
const hazardId = options == null ? void 0 : options.hazardId;
|
||
hazardLocked.value = (options == null ? void 0 : options.locked) === "1";
|
||
if (options == null ? void 0 : options.assignId) {
|
||
assignId.value = String(options.assignId);
|
||
}
|
||
if (options == null ? void 0 : options.taskId) {
|
||
taskId.value = String(options.taskId);
|
||
}
|
||
const hazardFromOptions = utils_hazardNav.buildWriteoffHazardFromOptions(options);
|
||
if (hazardFromOptions) {
|
||
applyWriteoffHazardPreview(hazardFromOptions);
|
||
}
|
||
if (hazardId) {
|
||
selectedHazardId.value = String(hazardId);
|
||
await fetchWriteoffForm(hazardId);
|
||
if (taskId.value) {
|
||
await fetchNextStep();
|
||
}
|
||
} else if (taskId.value) {
|
||
await fetchNextStep();
|
||
}
|
||
});
|
||
return (_ctx, _cache) => {
|
||
return common_vendor.e({
|
||
a: hazardLocked.value
|
||
}, hazardLocked.value ? {
|
||
b: common_vendor.t(selectedHazard.value || "加载中..."),
|
||
c: common_vendor.n(selectedHazard.value ? "" : "text-gray")
|
||
} : {
|
||
d: common_vendor.t(selectedHazard.value || "请选择隐患"),
|
||
e: common_vendor.n(selectedHazard.value ? "" : "text-gray"),
|
||
f: common_vendor.o(($event) => showHazardPicker.value = true)
|
||
}, {
|
||
g: common_vendor.t(formData.rectifyDeadline || "请先选择隐患"),
|
||
h: common_vendor.n(formData.rectifyDeadline ? "" : "text-gray"),
|
||
i: common_vendor.t(selectedDeptName.value || "请先选择隐患"),
|
||
j: common_vendor.n(selectedDeptName.value ? "" : "text-gray"),
|
||
k: common_vendor.t(formData.responsiblePerson || "请先选择隐患"),
|
||
l: common_vendor.n(formData.responsiblePerson ? "" : "text-gray"),
|
||
m: !aiGenerating.value
|
||
}, !aiGenerating.value ? {} : {}, {
|
||
n: common_vendor.t(aiGenerating.value ? "AI生成中..." : "AI 生成销号方案"),
|
||
o: aiGenerating.value,
|
||
p: aiGenerating.value,
|
||
q: common_vendor.o(handleAiGenerate),
|
||
r: common_vendor.o(($event) => formData.mainTreatmentContent = $event),
|
||
s: common_vendor.p({
|
||
placeholder: "暂无",
|
||
disabled: true,
|
||
modelValue: formData.mainTreatmentContent
|
||
}),
|
||
t: common_vendor.o(($event) => formData.treatmentResult = $event),
|
||
v: common_vendor.p({
|
||
placeholder: "暂无",
|
||
disabled: true,
|
||
modelValue: formData.treatmentResult
|
||
}),
|
||
w: common_vendor.o(($event) => formData.selfVerifyContent = $event),
|
||
x: common_vendor.p({
|
||
placeholder: "暂无",
|
||
disabled: true,
|
||
modelValue: formData.selfVerifyContent
|
||
}),
|
||
y: common_vendor.n(formData.approvalResult === 1 ? "active" : ""),
|
||
z: common_vendor.o(($event) => onApprovalResultChange(1)),
|
||
A: common_vendor.n(formData.approvalResult === 2 ? "active" : ""),
|
||
B: common_vendor.o(($event) => onApprovalResultChange(2)),
|
||
C: formData.approvalResult === 1
|
||
}, formData.approvalResult === 1 ? {
|
||
D: common_vendor.p({
|
||
label: "是",
|
||
name: "yes",
|
||
customStyle: {
|
||
marginRight: "48rpx"
|
||
}
|
||
}),
|
||
E: common_vendor.p({
|
||
label: "否",
|
||
name: "no"
|
||
}),
|
||
F: common_vendor.o(($event) => quickApproveRadio.value = $event),
|
||
G: common_vendor.p({
|
||
placement: "row",
|
||
activeColor: "#2667e9",
|
||
modelValue: quickApproveRadio.value
|
||
})
|
||
} : {}, {
|
||
H: formData.approvalResult === 2
|
||
}, formData.approvalResult === 2 ? {
|
||
I: common_vendor.f(approvalOptions, (opt, index, i0) => {
|
||
return {
|
||
a: opt.value,
|
||
b: "367b7912-7-" + i0 + ",367b7912-6",
|
||
c: common_vendor.p({
|
||
label: opt.label,
|
||
name: opt.value,
|
||
customStyle: {
|
||
marginRight: index < approvalOptions.length - 1 ? "24rpx" : "0"
|
||
}
|
||
})
|
||
};
|
||
}),
|
||
J: common_vendor.o(($event) => formData.approvalOpinion = $event),
|
||
K: common_vendor.p({
|
||
placement: "row",
|
||
activeColor: "#2667e9",
|
||
modelValue: formData.approvalOpinion
|
||
}),
|
||
L: common_vendor.o(($event) => formData.opinionRemark = $event),
|
||
M: common_vendor.p({
|
||
placeholder: "请输入意见说明",
|
||
modelValue: formData.opinionRemark
|
||
})
|
||
} : {}, {
|
||
N: formData.approvalResult === 1
|
||
}, formData.approvalResult === 1 ? common_vendor.e({
|
||
O: common_vendor.t(nextStepDisplay.value),
|
||
P: needNextAssignee.value
|
||
}, needNextAssignee.value ? {
|
||
Q: common_vendor.t(selectedAssigneeName.value || "请选择下一步处理人"),
|
||
R: !selectedAssigneeName.value ? 1 : "",
|
||
S: common_vendor.o(openAssigneePopup)
|
||
} : {}) : {}, {
|
||
T: common_vendor.p({
|
||
label: "是",
|
||
name: "yes",
|
||
customStyle: {
|
||
marginRight: "48rpx"
|
||
}
|
||
}),
|
||
U: common_vendor.p({
|
||
label: "否",
|
||
name: "no"
|
||
}),
|
||
V: common_vendor.o(($event) => sendMsgFlagRadio.value = $event),
|
||
W: common_vendor.p({
|
||
placement: "row",
|
||
activeColor: "#2667e9",
|
||
modelValue: sendMsgFlagRadio.value
|
||
}),
|
||
X: formData.approvalResult === 1 || formData.approvalResult === 2
|
||
}, formData.approvalResult === 1 || formData.approvalResult === 2 ? common_vendor.e({
|
||
Y: showCanvas.value
|
||
}, showCanvas.value ? {
|
||
Z: common_vendor.o(clearSignature)
|
||
} : {
|
||
aa: common_vendor.o(reSign)
|
||
}, {
|
||
ab: !showCanvas.value
|
||
}, !showCanvas.value ? common_vendor.e({
|
||
ac: signatureUrl.value
|
||
}, signatureUrl.value ? {
|
||
ad: signatureUrl.value
|
||
} : {}) : {}, {
|
||
ae: showCanvas.value && !showAssigneePopup.value
|
||
}, showCanvas.value && !showAssigneePopup.value ? {
|
||
af: common_vendor.sr(signatureRef, "367b7912-12", {
|
||
"k": "signatureRef"
|
||
}),
|
||
ag: common_vendor.o((res) => onSignatureConfirm(res.tempFilePath)),
|
||
ah: common_vendor.o(onSignatureStart),
|
||
ai: common_vendor.o(onSignatureSigning),
|
||
aj: common_vendor.o(onSignatureEnd),
|
||
ak: common_vendor.o(onSignatureClear),
|
||
al: common_vendor.p({
|
||
width: signatureWidth.value,
|
||
height: 160,
|
||
backgroundColor: "#f8f8f8",
|
||
penColor: "#000000",
|
||
lineWidth: 3,
|
||
enableHistory: false
|
||
})
|
||
} : {}) : {}, {
|
||
am: common_vendor.o(handleCancel),
|
||
an: common_vendor.o(handleSubmit),
|
||
ao: !hazardLocked.value
|
||
}, !hazardLocked.value ? {
|
||
ap: common_vendor.o(onHazardConfirm),
|
||
aq: common_vendor.o(($event) => showHazardPicker.value = false),
|
||
ar: common_vendor.o(($event) => showHazardPicker.value = false),
|
||
as: common_vendor.p({
|
||
show: showHazardPicker.value,
|
||
columns: hazardColumns.value
|
||
})
|
||
} : {}, {
|
||
at: common_vendor.o(cancelAssigneeSelect),
|
||
av: common_vendor.o(confirmAssigneeSelect),
|
||
aw: common_vendor.o(($event) => pickerAssigneeIdentityId.value = $event),
|
||
ax: common_vendor.o(($event) => pickerAssigneeName.value = $event),
|
||
ay: common_vendor.p({
|
||
show: showAssigneePopup.value,
|
||
["task-id"]: taskId.value,
|
||
["picker-identity-id"]: pickerAssigneeIdentityId.value,
|
||
["picker-name"]: pickerAssigneeName.value
|
||
}),
|
||
az: common_vendor.gei(_ctx, "")
|
||
});
|
||
};
|
||
}
|
||
};
|
||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-367b7912"]]);
|
||
wx.createPage(MiniProgramPage);
|
||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/closeout/approval.js.map
|