929 lines
35 KiB
JavaScript
929 lines
35 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: "leader-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 sendMsgFlagRadio = common_vendor.ref("yes");
|
||
const sendMsgFlag = common_vendor.computed(() => sendMsgFlagRadio.value === "yes");
|
||
const nextStepName = common_vendor.ref("");
|
||
const nextStepKey = common_vendor.ref("");
|
||
const nextStepLoading = common_vendor.ref(false);
|
||
const FIXED_NEXT_STEP_MAP = {
|
||
re_rectify: "隐患整改",
|
||
verify: "隐患验收"
|
||
};
|
||
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",
|
||
verify: "verify"
|
||
};
|
||
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" },
|
||
{ label: "重新验收", value: "verify" }
|
||
];
|
||
const APPROVAL_OPTIONS_LEADER_PREFECTURE = [
|
||
{ label: "同意", value: "agree" },
|
||
{ label: "驳回", value: "reject" },
|
||
{ label: "重新整改", value: "re_rectify" },
|
||
{ label: "重新验收", value: "verify" }
|
||
];
|
||
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 [];
|
||
};
|
||
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 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 formData = common_vendor.reactive({
|
||
rectifyDeadline: "",
|
||
responsibleDeptId: "",
|
||
responsiblePerson: "",
|
||
mainTreatmentContent: "",
|
||
treatmentResult: "",
|
||
selfVerifyContent: "",
|
||
approvalOpinion: "",
|
||
opinionRemark: ""
|
||
});
|
||
const syncApprovalOpinionWithOptions = () => {
|
||
const validValues = approvalOptions.value.map((item) => item.value);
|
||
if (formData.approvalOpinion && !validValues.includes(formData.approvalOpinion)) {
|
||
formData.approvalOpinion = "";
|
||
}
|
||
if (!needNextAssignee.value) {
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
pickerAssigneeIdentityId.value = "";
|
||
pickerAssigneeName.value = "";
|
||
}
|
||
};
|
||
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 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 resolveMatchedBranch = (data) => {
|
||
if (!data)
|
||
return null;
|
||
const branches = data.branches || [];
|
||
return branches.find((item) => item.matched) || branches[0] || null;
|
||
};
|
||
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 "";
|
||
return String(data.currentTaskKey);
|
||
};
|
||
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: false
|
||
};
|
||
if (approvalOpinion === "reject") {
|
||
params.reject = true;
|
||
} else {
|
||
params.previewVariables = buildPreviewVariables(approvalOpinion);
|
||
}
|
||
return params;
|
||
};
|
||
const fetchFlowContext = async () => {
|
||
if (!taskId.value) {
|
||
currentTaskKey.value = "";
|
||
return;
|
||
}
|
||
try {
|
||
const res = await request_api.getFlowNextNodes({
|
||
taskId: taskId.value,
|
||
previewVariables: buildPreviewVariables(""),
|
||
includeSubProcess: false
|
||
});
|
||
if (res.code === 0) {
|
||
const payload = res.data && typeof res.data === "object" ? res.data : res;
|
||
currentTaskKey.value = resolveCurrentTaskKey(payload);
|
||
syncApprovalOpinionWithOptions();
|
||
} else {
|
||
currentTaskKey.value = "";
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/closeout/leader-approval.vue:547", "获取流程上下文失败:", error);
|
||
currentTaskKey.value = "";
|
||
}
|
||
};
|
||
const getCurrentDeptType = () => {
|
||
var _a;
|
||
const userInfo = getStoredUserInfo();
|
||
const deptType = (_a = userInfo.userIdentity) == null ? void 0 : _a.deptType;
|
||
return deptType != null && deptType !== "" ? String(deptType) : "";
|
||
};
|
||
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 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 () => {
|
||
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) {
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
pickerAssigneeIdentityId.value = "";
|
||
pickerAssigneeName.value = "";
|
||
}
|
||
} else {
|
||
nextStepName.value = "";
|
||
nextStepKey.value = "";
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/closeout/leader-approval.vue:629", "获取下一步流程失败:", error);
|
||
nextStepName.value = "";
|
||
nextStepKey.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/leader-approval.vue:666", "获取隐患任务信息失败:", error);
|
||
}
|
||
if (!taskId.value && presetTaskId) {
|
||
taskId.value = presetTaskId;
|
||
}
|
||
};
|
||
const resetFlowSelection = () => {
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
nextStepName.value = "";
|
||
nextStepKey.value = "";
|
||
currentTaskKey.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 fetchFlowContext();
|
||
};
|
||
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/leader-approval.vue:727", "获取销号审批表单失败:", 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(() => formData.approvalOpinion, (opinion) => {
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
pickerAssigneeIdentityId.value = "";
|
||
pickerAssigneeName.value = "";
|
||
nextStepName.value = "";
|
||
nextStepKey.value = "";
|
||
applyDefaultOpinionRemark(opinion);
|
||
if (opinion) {
|
||
fetchNextStep();
|
||
}
|
||
syncApprovalOpinionWithOptions();
|
||
});
|
||
common_vendor.watch(needNextAssignee, (value) => {
|
||
if (!value) {
|
||
selectedAssigneeIdentityId.value = "";
|
||
selectedAssigneeName.value = "";
|
||
pickerAssigneeIdentityId.value = "";
|
||
pickerAssigneeName.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 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/leader-approval.vue:859", "签名上传失败:", 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/leader-approval.vue:907", "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/leader-approval.vue:944", "签名上传失败:", err);
|
||
common_vendor.index.showToast({ title: "签名上传失败,请重试", icon: "none" });
|
||
}
|
||
};
|
||
const validateFormBeforeSubmit = () => {
|
||
var _a;
|
||
if (!taskId.value) {
|
||
common_vendor.index.showToast({ title: "缺少任务ID", icon: "none" });
|
||
return false;
|
||
}
|
||
if (!applyId.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;
|
||
}
|
||
return true;
|
||
};
|
||
const handleSubmit = async () => {
|
||
if (!selectedHazardId.value) {
|
||
common_vendor.index.showToast({ title: "请选择隐患", icon: "none" });
|
||
return;
|
||
}
|
||
if (!validateFormBeforeSubmit()) {
|
||
return;
|
||
}
|
||
await ensureSignatureAndSubmit();
|
||
};
|
||
const executeSubmit = async () => {
|
||
const params = {
|
||
taskId: taskId.value,
|
||
bizId: Number(applyId.value),
|
||
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;
|
||
}
|
||
try {
|
||
const res = await request_api.flowTaskApprove(params);
|
||
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/leader-approval.vue:1028", "审批失败:", 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/leader-approval.vue:1041", "获取系统信息失败:", 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);
|
||
}
|
||
if (options == null ? void 0 : options.taskKey) {
|
||
currentTaskKey.value = String(options.taskKey);
|
||
}
|
||
const hazardFromOptions = utils_hazardNav.buildWriteoffHazardFromOptions(options);
|
||
if (hazardFromOptions) {
|
||
applyWriteoffHazardPreview(hazardFromOptions);
|
||
}
|
||
if (hazardId) {
|
||
selectedHazardId.value = String(hazardId);
|
||
await fetchWriteoffForm(hazardId);
|
||
if (taskId.value) {
|
||
await fetchFlowContext();
|
||
}
|
||
} else if (taskId.value) {
|
||
await fetchFlowContext();
|
||
}
|
||
});
|
||
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.f(approvalOptions.value, (opt, index, i0) => {
|
||
return {
|
||
a: opt.value,
|
||
b: "480a9a4b-4-" + i0 + ",480a9a4b-3",
|
||
c: common_vendor.p({
|
||
label: opt.label,
|
||
name: opt.value,
|
||
customStyle: {
|
||
marginRight: index < approvalOptions.value.length - 1 ? "24rpx" : "0"
|
||
}
|
||
})
|
||
};
|
||
}),
|
||
z: common_vendor.o(($event) => formData.approvalOpinion = $event),
|
||
A: common_vendor.p({
|
||
placement: "row",
|
||
activeColor: "#2667e9",
|
||
modelValue: formData.approvalOpinion
|
||
}),
|
||
B: common_vendor.o(($event) => formData.opinionRemark = $event),
|
||
C: common_vendor.p({
|
||
placeholder: "请输入意见说明",
|
||
modelValue: formData.opinionRemark
|
||
}),
|
||
D: common_vendor.t(nextStepDisplay.value),
|
||
E: needNextAssignee.value
|
||
}, needNextAssignee.value ? {} : {}, {
|
||
F: needNextAssignee.value
|
||
}, needNextAssignee.value ? {
|
||
G: common_vendor.t(selectedAssigneeName.value || "请选择下一步处理人"),
|
||
H: !selectedAssigneeName.value ? 1 : "",
|
||
I: common_vendor.o(openAssigneePopup)
|
||
} : {}, {
|
||
J: common_vendor.p({
|
||
label: "是",
|
||
name: "yes",
|
||
customStyle: {
|
||
marginRight: "48rpx"
|
||
}
|
||
}),
|
||
K: common_vendor.p({
|
||
label: "否",
|
||
name: "no"
|
||
}),
|
||
L: common_vendor.o(($event) => sendMsgFlagRadio.value = $event),
|
||
M: common_vendor.p({
|
||
placement: "row",
|
||
activeColor: "#2667e9",
|
||
modelValue: sendMsgFlagRadio.value
|
||
}),
|
||
N: showCanvas.value
|
||
}, showCanvas.value ? {
|
||
O: common_vendor.o(clearSignature)
|
||
} : {
|
||
P: common_vendor.o(reSign)
|
||
}, {
|
||
Q: !showCanvas.value
|
||
}, !showCanvas.value ? common_vendor.e({
|
||
R: signatureUrl.value
|
||
}, signatureUrl.value ? {
|
||
S: signatureUrl.value
|
||
} : {}) : {}, {
|
||
T: showCanvas.value && !showAssigneePopup.value
|
||
}, showCanvas.value && !showAssigneePopup.value ? {
|
||
U: common_vendor.sr(signatureRef, "480a9a4b-9", {
|
||
"k": "signatureRef"
|
||
}),
|
||
V: common_vendor.o((res) => onSignatureConfirm(res.tempFilePath)),
|
||
W: common_vendor.o(onSignatureStart),
|
||
X: common_vendor.o(onSignatureSigning),
|
||
Y: common_vendor.o(onSignatureEnd),
|
||
Z: common_vendor.o(onSignatureClear),
|
||
aa: common_vendor.p({
|
||
width: signatureWidth.value,
|
||
height: 160,
|
||
backgroundColor: "#f8f8f8",
|
||
penColor: "#000000",
|
||
lineWidth: 3,
|
||
enableHistory: false
|
||
})
|
||
} : {}, {
|
||
ab: common_vendor.o(handleCancel),
|
||
ac: common_vendor.o(handleSubmit),
|
||
ad: !hazardLocked.value
|
||
}, !hazardLocked.value ? {
|
||
ae: common_vendor.o(onHazardConfirm),
|
||
af: common_vendor.o(($event) => showHazardPicker.value = false),
|
||
ag: common_vendor.o(($event) => showHazardPicker.value = false),
|
||
ah: common_vendor.p({
|
||
show: showHazardPicker.value,
|
||
columns: hazardColumns.value
|
||
})
|
||
} : {}, {
|
||
ai: common_vendor.o(cancelAssigneeSelect),
|
||
aj: common_vendor.o(confirmAssigneeSelect),
|
||
ak: common_vendor.o(($event) => pickerAssigneeIdentityId.value = $event),
|
||
al: common_vendor.o(($event) => pickerAssigneeName.value = $event),
|
||
am: common_vendor.p({
|
||
show: showAssigneePopup.value,
|
||
["task-id"]: taskId.value,
|
||
["picker-identity-id"]: pickerAssigneeIdentityId.value,
|
||
["picker-name"]: pickerAssigneeName.value
|
||
}),
|
||
an: common_vendor.gei(_ctx, "")
|
||
});
|
||
};
|
||
}
|
||
};
|
||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-480a9a4b"]]);
|
||
wx.createPage(MiniProgramPage);
|
||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/closeout/leader-approval.js.map
|