Files

969 lines
39 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
const common_vendor = require("../../common/vendor.js");
const request_api = require("../../request/api.js");
const utils_upload = require("../../utils/upload.js");
if (!Array) {
const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
const _easycom_up_datetime_picker2 = common_vendor.resolveComponent("up-datetime-picker");
const _easycom_up_checkbox2 = common_vendor.resolveComponent("up-checkbox");
const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
const _easycom_up_upload2 = common_vendor.resolveComponent("up-upload");
const _easycom_wd_signature2 = common_vendor.resolveComponent("wd-signature");
(_easycom_up_textarea2 + _easycom_up_input2 + _easycom_up_datetime_picker2 + _easycom_up_checkbox2 + _easycom_u_popup2 + _easycom_up_upload2 + _easycom_wd_signature2)();
}
const _easycom_up_textarea = () => "../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
const _easycom_up_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
const _easycom_up_datetime_picker = () => "../../uni_modules/uview-plus/components/u-datetime-picker/u-datetime-picker.js";
const _easycom_up_checkbox = () => "../../uni_modules/uview-plus/components/u-checkbox/u-checkbox.js";
const _easycom_u_popup = () => "../../uni_modules/uview-plus/components/u-popup/u-popup.js";
const _easycom_up_upload = () => "../../uni_modules/uview-plus/components/u-upload/u-upload.js";
const _easycom_wd_signature = () => "../../node-modules/wot-design-uni/components/wd-signature/wd-signature.js";
if (!Math) {
(_easycom_up_textarea + _easycom_up_input + _easycom_up_datetime_picker + _easycom_up_checkbox + _easycom_u_popup + _easycom_up_upload + _easycom_wd_signature)();
}
const _sfc_main = {
__name: "rectification",
setup(__props) {
const hazardId = common_vendor.ref("");
const assignId = common_vendor.ref("");
const rectifyId = common_vendor.ref("");
const isEdit = common_vendor.ref(false);
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 clearSignature = () => {
isSignatureEmpty.value = true;
if (signatureRef.value) {
signatureRef.value.clear();
}
};
const resolveSignPathFromData = (data) => {
if (!data)
return "";
return data.signPath || data.signUrl || data.signature || data.signatureUrl || data.signaturePath || "";
};
const applySignatureFromServer = (signPath) => {
const url = signPath ? utils_upload.toSubmitFileUrl(signPath) : "";
if (!url) {
showCanvas.value = true;
signatureServerPath.value = "";
signatureUrl.value = "";
isSignatureEmpty.value = true;
return;
}
signatureServerPath.value = url;
signatureUrl.value = url;
showCanvas.value = false;
isSignatureEmpty.value = false;
};
const onSignatureImageError = () => {
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:321", "签名图片加载失败:", signatureUrl.value);
common_vendor.index.showToast({ title: "签名图片加载失败", icon: "none" });
};
const reSign = () => {
isSignatureEmpty.value = true;
showCanvas.value = true;
signatureUrl.value = "";
signatureServerPath.value = "";
common_vendor.nextTick$1(() => {
if (signatureRef.value) {
signatureRef.value.clear();
}
});
};
const formData = common_vendor.reactive({
rectifyPlan: "",
// 整改方案
rectificationMeasures: "",
// 整改措施
controlMeasures: "",
// 管控措施
rectifyResult: "",
// 整改完成情况
planCost: "",
// 投资资金(计划)
actualCost: ""
// 投资资金(实际)
});
const selectedDeadlineDate = common_vendor.ref("");
const showRectifyTimePicker = common_vendor.ref(false);
const rectifyTimeValue = common_vendor.ref(Date.now());
const selectedRectifyTime = common_vendor.ref("");
const formatDateValue = (timestamp) => {
if (!timestamp)
return "";
const date = new Date(timestamp);
if (Number.isNaN(date.getTime()))
return "";
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};
const parseDeadlineToTimestamp = (deadline) => {
if (!deadline)
return null;
const decoded = decodeURIComponent(String(deadline)).trim();
const normalized = decoded.replace("T", " ").replace(/-/g, "/");
const ts = new Date(normalized).getTime();
return Number.isNaN(ts) ? null : ts;
};
const applyDeadlineFromOptions = (deadline) => {
const ts = parseDeadlineToTimestamp(deadline);
if (ts) {
selectedDeadlineDate.value = formatDateValue(ts);
} else if (deadline) {
selectedDeadlineDate.value = String(deadline).trim().replace("T", " ");
}
};
const parseIdList = (raw) => {
if (raw === null || raw === void 0 || raw === "")
return [];
if (Array.isArray(raw)) {
return raw.map((id) => String(id)).filter(Boolean);
}
return String(raw).split(",").map((id) => String(id).trim()).filter(Boolean);
};
const resolveManagerIdsFromDetail = (data) => {
const ids = parseIdList(data.manageIds ?? data.managerIds);
if (ids.length > 0)
return ids;
if (Array.isArray(data.managers) && data.managers.length > 0) {
return data.managers.map((item) => String(item.userId)).filter(Boolean);
}
return [];
};
const buildUserItemFromDetail = (user) => ({
id: String(user.userId),
name: formatUserDisplayName(user),
deptName: user.deptName || ""
});
const getUsersByIdsFromTree = (ids, tree) => {
const userMap = /* @__PURE__ */ new Map();
(tree || []).forEach((dept) => {
(dept.users || []).forEach((user) => {
userMap.set(String(user.userId), buildUserItem(user, dept));
});
});
return ids.map((id) => userMap.get(String(id))).filter(Boolean);
};
const mergeUsersFromDetailPool = (ids, resolvedUsers) => {
const userMap = new Map(resolvedUsers.map((user) => [user.id, user]));
ids.forEach((id) => {
const key = String(id);
if (userMap.has(key))
return;
const found = detailPersonPool.value.find((user) => String(user.userId) === key);
if (found) {
userMap.set(key, buildUserItemFromDetail(found));
}
});
return ids.map((id) => userMap.get(String(id))).filter(Boolean);
};
const applyRectifyTimeValue = (timeStr) => {
const ts = parseDeadlineToTimestamp(timeStr);
if (ts) {
rectifyTimeValue.value = ts;
selectedRectifyTime.value = formatDateValue(ts);
} else if (timeStr) {
selectedRectifyTime.value = String(timeStr).trim().replace("T", " ");
}
};
const initRectifyTimeDefault = () => {
rectifyTimeValue.value = Date.now();
selectedRectifyTime.value = formatDateValue(rectifyTimeValue.value);
};
const onRectifyTimeConfirm = (e) => {
rectifyTimeValue.value = e.value;
selectedRectifyTime.value = formatDateValue(e.value);
showRectifyTimePicker.value = false;
};
const managerDeptList = common_vendor.ref([]);
const deptList = common_vendor.ref([]);
const detailPersonPool = common_vendor.ref([]);
const showManagerPopup = common_vendor.ref(false);
const selectedManagerIds = common_vendor.ref([]);
const selectedManagers = common_vendor.ref([]);
const activeManagerDeptIndex = common_vendor.ref(0);
const managerPickerSelectedIds = common_vendor.ref([]);
const showUserPopup = common_vendor.ref(false);
const selectedUserIds = common_vendor.ref([]);
const selectedUsers = common_vendor.ref([]);
const activeDeptIndex = common_vendor.ref(0);
const userPickerSelectedIds = common_vendor.ref([]);
const formatUserDisplayName = (user) => {
if (user.postName) {
return `${user.nickName}_${user.postName}`;
}
return user.nickName || "";
};
const buildUserItem = (user, dept) => ({
id: String(user.userId),
name: formatUserDisplayName(user),
deptName: dept.deptName
});
const buildSelectedPersonText = (users) => {
if (users.length === 0)
return "";
if (users.length <= 2) {
return users.map((u) => u.name).join("、");
}
return `${users[0].name}${users.length}`;
};
const selectedManagersText = common_vendor.computed(() => buildSelectedPersonText(selectedManagers.value));
const selectedUsersText = common_vendor.computed(() => buildSelectedPersonText(selectedUsers.value));
const currentManagerDeptUsers = common_vendor.computed(() => {
const dept = managerDeptList.value[activeManagerDeptIndex.value];
return (dept == null ? void 0 : dept.users) || [];
});
const managerPickerSelectedText = common_vendor.computed(() => {
const users = getManagerUsersByIds(managerPickerSelectedIds.value);
return buildSelectedPersonText(users);
});
const managerPickerSelectedSet = common_vendor.computed(() => {
return new Set(managerPickerSelectedIds.value.map((id) => String(id)));
});
const currentDeptUsers = common_vendor.computed(() => {
const dept = deptList.value[activeDeptIndex.value];
return (dept == null ? void 0 : dept.users) || [];
});
const userPickerSelectedText = common_vendor.computed(() => {
const users = getUsersByIds(userPickerSelectedIds.value);
return buildSelectedPersonText(users);
});
const userPickerSelectedSet = common_vendor.computed(() => {
return new Set(userPickerSelectedIds.value.map((id) => String(id)));
});
const getManagerUsersByIds = (ids) => {
let users = getUsersByIdsFromTree(ids, managerDeptList.value);
if (users.length < ids.length) {
const userDeptUsers = getUsersByIdsFromTree(ids, deptList.value);
const userMap = new Map(users.map((user) => [user.id, user]));
userDeptUsers.forEach((user) => {
if (!userMap.has(user.id))
userMap.set(user.id, user);
});
users = ids.map((id) => userMap.get(String(id))).filter(Boolean);
}
return mergeUsersFromDetailPool(ids, users);
};
const getUsersByIds = (ids) => {
let users = getUsersByIdsFromTree(ids, deptList.value);
return mergeUsersFromDetailPool(ids, users);
};
const syncSelectedManagersFromIds = (ids) => {
selectedManagers.value = getManagerUsersByIds(ids);
};
const syncSelectedUsersFromIds = (ids) => {
selectedUsers.value = getUsersByIds(ids);
};
const getManagerDeptSelectedCount = (dept) => {
var _a;
if (!((_a = dept.users) == null ? void 0 : _a.length))
return 0;
const selectedSet = new Set(managerPickerSelectedIds.value.map(String));
return dept.users.filter((user) => selectedSet.has(String(user.userId))).length;
};
const getDeptSelectedCount = (dept) => {
var _a;
if (!((_a = dept.users) == null ? void 0 : _a.length))
return 0;
const selectedSet = new Set(userPickerSelectedIds.value.map(String));
return dept.users.filter((user) => selectedSet.has(String(user.userId))).length;
};
function onManagerCheckChange(userId, checked) {
const id = String(userId);
if (checked) {
if (!managerPickerSelectedSet.value.has(id)) {
managerPickerSelectedIds.value = [...managerPickerSelectedIds.value, id];
}
return;
}
managerPickerSelectedIds.value = managerPickerSelectedIds.value.filter((item) => String(item) !== id);
}
function onUserCheckChange(userId, checked) {
const id = String(userId);
if (checked) {
if (!userPickerSelectedSet.value.has(id)) {
userPickerSelectedIds.value = [...userPickerSelectedIds.value, id];
}
return;
}
userPickerSelectedIds.value = userPickerSelectedIds.value.filter((item) => String(item) !== id);
}
const openManagerPopup = () => {
managerPickerSelectedIds.value = [...selectedManagerIds.value];
const firstDeptWithUsers = managerDeptList.value.findIndex((dept) => {
var _a;
return ((_a = dept.users) == null ? void 0 : _a.length) > 0;
});
activeManagerDeptIndex.value = firstDeptWithUsers >= 0 ? firstDeptWithUsers : 0;
showManagerPopup.value = true;
};
const cancelManagerSelect = () => {
showManagerPopup.value = false;
};
const openUserPopup = () => {
userPickerSelectedIds.value = [...selectedUserIds.value];
const firstDeptWithUsers = deptList.value.findIndex((dept) => {
var _a;
return ((_a = dept.users) == null ? void 0 : _a.length) > 0;
});
activeDeptIndex.value = firstDeptWithUsers >= 0 ? firstDeptWithUsers : 0;
showUserPopup.value = true;
};
const cancelUserSelect = () => {
showUserPopup.value = false;
};
const confirmManagerSelect = () => {
selectedManagerIds.value = managerPickerSelectedIds.value.map((id) => String(id));
syncSelectedManagersFromIds(selectedManagerIds.value);
showManagerPopup.value = false;
};
const confirmUserSelect = () => {
selectedUserIds.value = userPickerSelectedIds.value.map((id) => String(id));
syncSelectedUsersFromIds(selectedUserIds.value);
showUserPopup.value = false;
};
const fetchManagerDeptUsers = async () => {
try {
const res = await request_api.getDepartmentPersonUsers();
if (res.code === 0 && res.data) {
managerDeptList.value = res.data;
if (selectedManagerIds.value.length > 0) {
syncSelectedManagersFromIds(selectedManagerIds.value);
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:633", "获取安全管理人员列表失败:", error);
}
};
const fetchRectifyDeptUsers = async () => {
common_vendor.index.__f__("log", "at pages/hiddendanger/rectification.vue:639", "当前hazardId:", hazardId.value);
try {
const res = await request_api.getDeptUsersWithSubordinates({ hazardId: hazardId.value });
if (res.code === 0 && res.data) {
deptList.value = res.data;
if (selectedUserIds.value.length > 0) {
syncSelectedUsersFromIds(selectedUserIds.value);
}
common_vendor.index.__f__("log", "at pages/hiddendanger/rectification.vue:647", "整改责任人部门树:", deptList.value);
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:650", "获取整改责任人列表失败:", error);
}
};
const fetchPersonnelLists = async () => {
await Promise.all([fetchManagerDeptUsers(), fetchRectifyDeptUsers()]);
if (selectedManagerIds.value.length > 0) {
syncSelectedManagersFromIds(selectedManagerIds.value);
}
};
const fileList1 = common_vendor.ref([]);
const rectifyUploadInstance = common_vendor.getCurrentInstance();
const { afterRead, deletePic } = utils_upload.createUploadListHandlers(fileList1, {
watermark: {
canvasId: "watermarkCanvas",
canvasWidthRef: canvasWidth,
canvasHeightRef: canvasHeight,
instance: rectifyUploadInstance
}
});
const executeSubmit = async () => {
const attachments = fileList1.value.filter((f) => f.status === "success").map((file) => utils_upload.buildAttachmentItem(file));
const params = {
hazardId: hazardId.value,
assignId: assignId.value,
rectifyPlan: formData.rectifyPlan,
rectificationMeasures: formData.rectificationMeasures,
controlMeasures: formData.controlMeasures,
rectifyResult: formData.rectifyResult,
planCost: Number(formData.planCost) || 0,
actualCost: Number(formData.actualCost) || 0,
attachments,
manageIds: selectedManagerIds.value.map((id) => Number(id)),
memberIds: selectedUserIds.value.map((id) => Number(id)),
rectifyTime: selectedRectifyTime.value || formatDateValue(rectifyTimeValue.value),
signPath: signatureServerPath.value || ""
};
if (rectifyId.value) {
params.rectifyId = rectifyId.value;
}
try {
const res = await request_api.submitRectification(params);
common_vendor.index.hideLoading();
if (res.code === 0) {
clearDraft(false);
common_vendor.index.showToast({
title: isEdit.value ? "保存成功" : "提交成功",
icon: "success"
});
setTimeout(() => {
common_vendor.index.navigateBack();
}, 1500);
} else {
common_vendor.index.showToast({
title: res.msg || (isEdit.value ? "保存失败" : "提交失败"),
icon: "none"
});
}
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:721", "提交整改失败:", error);
common_vendor.index.showToast({
title: "操作失败",
icon: "none"
});
} finally {
isSubmitting.value = false;
}
};
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/hiddendanger/rectification.vue:743", "签名上传失败:", err);
common_vendor.index.showToast({ title: "签名上传失败,请重试", icon: "none" });
}
};
const handleSubmit = async () => {
if (!formData.rectifyPlan) {
common_vendor.index.showToast({
title: "请输入整改方案",
icon: "none"
});
return;
}
if (!formData.rectificationMeasures) {
common_vendor.index.showToast({
title: "请输入整改措施",
icon: "none"
});
return;
}
if (!formData.controlMeasures) {
common_vendor.index.showToast({
title: "请输入管控措施",
icon: "none"
});
return;
}
if (!formData.rectifyResult) {
common_vendor.index.showToast({
title: "请输入整改完成情况",
icon: "none"
});
return;
}
if (!selectedRectifyTime.value) {
common_vendor.index.showToast({
title: "请选择实际整改时间",
icon: "none"
});
return;
}
if (selectedManagers.value.length === 0) {
common_vendor.index.showToast({
title: "请选择安全管理人员",
icon: "none"
});
return;
}
if (selectedUsers.value.length === 0) {
common_vendor.index.showToast({
title: "请选择整改责任人",
icon: "none"
});
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) {
common_vendor.index.showToast({
title: "请进行电子签名",
icon: "none"
});
return;
}
isSubmitting.value = true;
common_vendor.index.showLoading({ title: "正在提交...", mask: true });
await executeSubmit();
}
};
const fetchRectifyDetail = async () => {
try {
common_vendor.index.showLoading({ title: "加载中..." });
const res = await request_api.getRectifyDetail({ rectifyId: rectifyId.value });
common_vendor.index.hideLoading();
if (res.code === 0 && res.data) {
const data = res.data;
formData.rectifyPlan = data.rectifyPlan || "";
formData.rectificationMeasures = data.rectificationMeasures || "";
formData.controlMeasures = data.controlMeasures || "";
formData.rectifyResult = data.rectifyResult || "";
formData.planCost = data.planCost ? String(data.planCost) : "";
formData.actualCost = data.actualCost ? String(data.actualCost) : "";
if (data.deadline) {
applyDeadlineFromOptions(data.deadline);
}
if (data.rectifyTime) {
applyRectifyTimeValue(data.rectifyTime);
}
const signPath = resolveSignPathFromData(data);
common_vendor.index.__f__("log", "at pages/hiddendanger/rectification.vue:926", "整改详情签名路径:", signPath);
applySignatureFromServer(signPath);
hazardId.value = data.hazardId || "";
assignId.value = data.assignId || "";
detailPersonPool.value = [
...Array.isArray(data.managers) ? data.managers : [],
...Array.isArray(data.members) ? data.members : []
];
const managerIdArr = resolveManagerIdsFromDetail(data);
const memberIdArr = parseIdList(data.memberIds);
if (managerIdArr.length > 0) {
selectedManagerIds.value = managerIdArr;
}
if (memberIdArr.length > 0) {
selectedUserIds.value = memberIdArr;
} else if (data.rectifierId) {
selectedUserIds.value = [String(data.rectifierId)];
}
await fetchPersonnelLists();
if (data.attachments && data.attachments.length > 0) {
fileList1.value = data.attachments.map((att) => utils_upload.mapServerFileToUploadItem(att));
}
common_vendor.index.setNavigationBarTitle({ title: "编辑整改信息" });
}
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:960", "获取整改详情失败:", error);
common_vendor.index.showToast({ title: "获取详情失败", icon: "none" });
}
};
const aiGenerating = common_vendor.ref(false);
const handleAiGenerate = async () => {
if (!hazardId.value) {
common_vendor.index.showToast({ title: "缺少隐患信息", icon: "none" });
return;
}
aiGenerating.value = true;
try {
const detailRes = await request_api.getHiddenDangerDetail({
hazardId: hazardId.value,
assignId: assignId.value
});
if (detailRes.code !== 0 || !detailRes.data) {
common_vendor.index.showToast({ title: "获取隐患详情失败", icon: "none" });
return;
}
const { title, description } = detailRes.data;
const aiRes = await request_api.generateRectifyPlan({ title, description });
if (aiRes.code === 0 && aiRes.data) {
if (aiRes.data.rawResponse) {
formData.rectifyPlan = aiRes.data.rawResponse;
}
common_vendor.index.showToast({ title: "AI生成完成", icon: "success", duration: 2e3 });
} else {
common_vendor.index.showToast({ title: aiRes.msg || "AI生成失败", icon: "none" });
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:997", "AI生成整改方案失败:", error);
common_vendor.index.showToast({ title: "AI生成失败请重试", icon: "none" });
} finally {
aiGenerating.value = false;
}
};
const hasDraft = common_vendor.ref(false);
const showRestoreBanner = common_vendor.ref(false);
const isRestoring = common_vendor.ref(false);
const signaturePaths = common_vendor.ref([]);
const getDraftKey = () => `draft_rectify_${hazardId.value || ""}_${rectifyId.value || ""}`;
const saveDraft = () => {
if (isRestoring.value)
return;
const key = getDraftKey();
const hasContent = formData.rectifyPlan || formData.rectificationMeasures || formData.controlMeasures || formData.rectifyResult || formData.planCost || formData.actualCost || fileList1.value.length > 0 || signatureServerPath.value || signaturePaths.value.length > 0;
if (!hasContent) {
common_vendor.index.removeStorageSync(key);
hasDraft.value = false;
return;
}
const data = {
formData: {
rectifyPlan: formData.rectifyPlan,
rectificationMeasures: formData.rectificationMeasures,
controlMeasures: formData.controlMeasures,
rectifyResult: formData.rectifyResult,
planCost: formData.planCost,
actualCost: formData.actualCost
},
fileList1: fileList1.value,
signatureServerPath: signatureServerPath.value,
signatureUrl: signatureUrl.value,
showCanvas: showCanvas.value,
signaturePaths: signaturePaths.value
};
common_vendor.index.setStorageSync(key, JSON.stringify(data));
hasDraft.value = true;
};
const clearDraft = (showToast = true) => {
const key = getDraftKey();
common_vendor.index.removeStorageSync(key);
hasDraft.value = false;
showRestoreBanner.value = false;
isRestoring.value = true;
formData.rectifyPlan = "";
formData.rectificationMeasures = "";
formData.controlMeasures = "";
formData.rectifyResult = "";
formData.planCost = "";
formData.actualCost = "";
fileList1.value = [];
signatureServerPath.value = "";
signatureUrl.value = "";
showCanvas.value = true;
signaturePaths.value = [];
if (signatureRef.value) {
signatureRef.value.clear();
}
common_vendor.nextTick$1(() => {
isRestoring.value = false;
});
if (showToast) {
common_vendor.index.showToast({ title: "草稿已清空", icon: "none" });
}
};
const restoreDraft = () => {
const key = getDraftKey();
const cached = common_vendor.index.getStorageSync(key);
if (cached) {
try {
const data = JSON.parse(cached);
const hasContent = data.formData.rectifyPlan || data.formData.rectificationMeasures || data.formData.controlMeasures || data.formData.rectifyResult || data.formData.planCost || data.formData.actualCost || data.fileList1 && data.fileList1.length > 0 || data.signatureServerPath || data.signaturePaths && data.signaturePaths.length > 0;
if (!hasContent)
return;
isRestoring.value = true;
formData.rectifyPlan = data.formData.rectifyPlan || "";
formData.rectificationMeasures = data.formData.rectificationMeasures || "";
formData.controlMeasures = data.formData.controlMeasures || "";
formData.rectifyResult = data.formData.rectifyResult || "";
formData.planCost = data.formData.planCost || "";
formData.actualCost = data.formData.actualCost || "";
fileList1.value = data.fileList1 || [];
signaturePaths.value = data.signaturePaths || [];
if (data.signatureServerPath || data.signatureUrl) {
applySignatureFromServer(data.signatureServerPath || data.signatureUrl);
} else if (data.showCanvas === false) {
showCanvas.value = false;
}
hasDraft.value = true;
showRestoreBanner.value = true;
if (signaturePaths.value.length > 0) {
setTimeout(() => {
if (signatureRef.value) {
isSignatureEmpty.value = false;
}
}, 450);
}
common_vendor.nextTick$1(() => {
isRestoring.value = false;
});
common_vendor.index.showToast({
title: "已自动恢复您上次未提交的内容",
icon: "none",
duration: 2500
});
} catch (e) {
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:1145", "解析草稿失败:", e);
isRestoring.value = false;
}
}
};
common_vendor.watch(
() => [
formData.rectifyPlan,
formData.rectificationMeasures,
formData.controlMeasures,
formData.rectifyResult,
formData.planCost,
formData.actualCost,
fileList1.value,
signatureServerPath.value,
signaturePaths.value
],
() => {
if (hazardId.value || rectifyId.value) {
saveDraft();
}
},
{ deep: true }
);
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/rectification.vue:1178", "获取系统信息失败:", e);
}
if (options.hazardId) {
hazardId.value = options.hazardId;
}
if (options.assignId) {
assignId.value = options.assignId;
}
if (!options.rectifyId)
fetchPersonnelLists();
if (options.rectifyId) {
rectifyId.value = options.rectifyId;
isEdit.value = options.isEdit === "1";
fetchRectifyDetail();
} else {
restoreDraft();
initRectifyTimeDefault();
}
if (options.deadline) {
applyDeadlineFromOptions(options.deadline);
}
});
return (_ctx, _cache) => {
return common_vendor.e({
a: showRestoreBanner.value
}, showRestoreBanner.value ? {
b: common_vendor.o(($event) => clearDraft(true))
} : {}, {
c: !aiGenerating.value
}, !aiGenerating.value ? {} : {}, {
d: common_vendor.t(aiGenerating.value ? "AI生成中..." : "AI生成整改方案"),
e: aiGenerating.value,
f: aiGenerating.value,
g: common_vendor.o(handleAiGenerate),
h: common_vendor.o(($event) => formData.rectifyPlan = $event),
i: common_vendor.p({
placeholder: "请输入内容",
maxlength: -1,
autoHeight: true,
modelValue: formData.rectifyPlan
}),
j: common_vendor.o(($event) => formData.rectificationMeasures = $event),
k: common_vendor.p({
placeholder: "请输入整改措施",
modelValue: formData.rectificationMeasures
}),
l: common_vendor.o(($event) => formData.controlMeasures = $event),
m: common_vendor.p({
placeholder: "请输入管控措施",
modelValue: formData.controlMeasures
}),
n: common_vendor.o(($event) => formData.rectifyResult = $event),
o: common_vendor.p({
placeholder: "请输入内容",
modelValue: formData.rectifyResult
}),
p: common_vendor.o(($event) => formData.planCost = $event),
q: common_vendor.p({
placeholder: "请输入内容",
type: "number",
modelValue: formData.planCost
}),
r: common_vendor.o(($event) => formData.actualCost = $event),
s: common_vendor.p({
placeholder: "请输入内容",
type: "number",
modelValue: formData.actualCost
}),
t: common_vendor.t(selectedDeadlineDate.value || "暂无"),
v: !selectedDeadlineDate.value ? 1 : "",
w: common_vendor.t(selectedRectifyTime.value || "请选择实际整改时间"),
x: !selectedRectifyTime.value ? 1 : "",
y: common_vendor.o(($event) => showRectifyTimePicker.value = true),
z: common_vendor.o(onRectifyTimeConfirm),
A: common_vendor.o(($event) => showRectifyTimePicker.value = false),
B: common_vendor.o(($event) => showRectifyTimePicker.value = false),
C: common_vendor.o(($event) => rectifyTimeValue.value = $event),
D: common_vendor.p({
show: showRectifyTimePicker.value,
mode: "datetime",
modelValue: rectifyTimeValue.value
}),
E: common_vendor.t(selectedManagers.value.length > 0 ? selectedManagersText.value : "请选择安全管理人员(可多选)"),
F: selectedManagers.value.length === 0 ? 1 : "",
G: common_vendor.o(openManagerPopup),
H: common_vendor.t(selectedUsers.value.length > 0 ? selectedUsersText.value : "请选择整改责任人(可多选)"),
I: selectedUsers.value.length === 0 ? 1 : "",
J: common_vendor.o(openUserPopup),
K: common_vendor.o(cancelManagerSelect),
L: managerPickerSelectedIds.value.length > 0
}, managerPickerSelectedIds.value.length > 0 ? {
M: common_vendor.t(managerPickerSelectedIds.value.length),
N: common_vendor.t(managerPickerSelectedText.value)
} : {}, {
O: common_vendor.f(managerDeptList.value, (dept, index, i0) => {
return common_vendor.e({
a: common_vendor.t(dept.deptName),
b: getManagerDeptSelectedCount(dept) > 0
}, getManagerDeptSelectedCount(dept) > 0 ? {
c: common_vendor.t(getManagerDeptSelectedCount(dept))
} : {}, {
d: "manager-dept-" + dept.deptId,
e: common_vendor.n({
active: activeManagerDeptIndex.value === index
}),
f: common_vendor.o(($event) => activeManagerDeptIndex.value = index, "manager-dept-" + dept.deptId)
});
}),
P: currentManagerDeptUsers.value.length === 0
}, currentManagerDeptUsers.value.length === 0 ? {} : {
Q: common_vendor.f(currentManagerDeptUsers.value, (user, k0, i0) => {
return {
a: common_vendor.o((checked) => onManagerCheckChange(user.userId, checked), "manager-user-" + user.userId),
b: "f18ba0ce-8-" + i0 + ",f18ba0ce-7",
c: common_vendor.p({
usedAlone: true,
checked: managerPickerSelectedSet.value.has(String(user.userId)),
label: formatUserDisplayName(user),
activeColor: "#2667E9",
shape: "square"
}),
d: "manager-user-" + user.userId
};
})
}, {
R: "manager-dept-users-" + activeManagerDeptIndex.value,
S: common_vendor.o(cancelManagerSelect),
T: common_vendor.o(confirmManagerSelect),
U: common_vendor.o(cancelManagerSelect),
V: common_vendor.p({
show: showManagerPopup.value,
mode: "bottom",
round: "20"
}),
W: common_vendor.o(cancelUserSelect),
X: userPickerSelectedIds.value.length > 0
}, userPickerSelectedIds.value.length > 0 ? {
Y: common_vendor.t(userPickerSelectedIds.value.length),
Z: common_vendor.t(userPickerSelectedText.value)
} : {}, {
aa: common_vendor.f(deptList.value, (dept, index, i0) => {
return common_vendor.e({
a: common_vendor.t(dept.deptName),
b: getDeptSelectedCount(dept) > 0
}, getDeptSelectedCount(dept) > 0 ? {
c: common_vendor.t(getDeptSelectedCount(dept))
} : {}, {
d: dept.deptId,
e: common_vendor.n({
active: activeDeptIndex.value === index
}),
f: common_vendor.o(($event) => activeDeptIndex.value = index, dept.deptId)
});
}),
ab: currentDeptUsers.value.length === 0
}, currentDeptUsers.value.length === 0 ? {} : {
ac: common_vendor.f(currentDeptUsers.value, (user, k0, i0) => {
return {
a: common_vendor.o((checked) => onUserCheckChange(user.userId, checked), "user-" + user.userId),
b: "f18ba0ce-10-" + i0 + ",f18ba0ce-9",
c: common_vendor.p({
usedAlone: true,
checked: userPickerSelectedSet.value.has(String(user.userId)),
label: formatUserDisplayName(user),
activeColor: "#2667E9",
shape: "square"
}),
d: "user-" + user.userId
};
})
}, {
ad: "dept-users-" + activeDeptIndex.value,
ae: common_vendor.o(cancelUserSelect),
af: common_vendor.o(confirmUserSelect),
ag: common_vendor.o(cancelUserSelect),
ah: common_vendor.p({
show: showUserPopup.value,
mode: "bottom",
round: "20"
}),
ai: common_vendor.o(common_vendor.unref(afterRead)),
aj: common_vendor.o(common_vendor.unref(deletePic)),
ak: common_vendor.p({
fileList: fileList1.value,
name: "1",
multiple: true,
imageMode: "aspectFill",
maxCount: 10
}),
al: !showUserPopup.value && !showManagerPopup.value && !showRectifyTimePicker.value
}, !showUserPopup.value && !showManagerPopup.value && !showRectifyTimePicker.value ? {
am: canvasWidth.value,
an: canvasHeight.value,
ao: canvasWidth.value + "px",
ap: canvasHeight.value + "px"
} : {}, {
aq: showCanvas.value
}, showCanvas.value ? {
ar: common_vendor.o(clearSignature)
} : {
as: common_vendor.o(reSign)
}, {
at: !showCanvas.value
}, !showCanvas.value ? common_vendor.e({
av: signatureUrl.value
}, signatureUrl.value ? {
aw: signatureUrl.value,
ax: common_vendor.o(onSignatureImageError)
} : {}) : {}, {
ay: showCanvas.value && !showUserPopup.value && !showManagerPopup.value && !showRectifyTimePicker.value
}, showCanvas.value && !showUserPopup.value && !showManagerPopup.value && !showRectifyTimePicker.value ? {
az: common_vendor.sr(signatureRef, "f18ba0ce-12", {
"k": "signatureRef"
}),
aA: common_vendor.o((res) => onSignatureConfirm(res.tempFilePath)),
aB: common_vendor.o(($event) => isSignatureEmpty.value = false),
aC: common_vendor.o(($event) => isSignatureEmpty.value = false),
aD: common_vendor.o(($event) => isSignatureEmpty.value = true),
aE: common_vendor.p({
width: signatureWidth.value,
height: 160,
backgroundColor: "#f8f8f8",
penColor: "#000000",
lineWidth: 3,
enableHistory: false
})
} : {}, {
aF: common_vendor.t(isEdit.value ? "保存修改" : "提交整改"),
aG: common_vendor.o(handleSubmit),
aH: common_vendor.gei(_ctx, "")
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-f18ba0ce"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/hiddendanger/rectification.js.map