这一版本优化了很多

This commit is contained in:
王利强
2026-06-03 10:16:37 +08:00
parent 8046316216
commit 2af9f1fd59
954 changed files with 58194 additions and 1609 deletions

View File

@@ -2,6 +2,7 @@
const common_vendor = require("../../common/vendor.js");
const request_api = require("../../request/api.js");
const request_request = require("../../request/request.js");
const utils_watermark = require("../../utils/watermark.js");
if (!Array) {
const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
@@ -10,7 +11,8 @@ if (!Array) {
const _easycom_up_checkbox_group2 = common_vendor.resolveComponent("up-checkbox-group");
const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
const _easycom_up_upload2 = common_vendor.resolveComponent("up-upload");
(_easycom_up_textarea2 + _easycom_up_input2 + _easycom_up_datetime_picker2 + _easycom_up_checkbox2 + _easycom_up_checkbox_group2 + _easycom_u_popup2 + _easycom_up_upload2)();
const _easycom_wd_signature2 = common_vendor.resolveComponent("wd-signature");
(_easycom_up_textarea2 + _easycom_up_input2 + _easycom_up_datetime_picker2 + _easycom_up_checkbox2 + _easycom_up_checkbox_group2 + _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";
@@ -19,8 +21,9 @@ const _easycom_up_checkbox = () => "../../uni_modules/uview-plus/components/u-ch
const _easycom_up_checkbox_group = () => "../../uni_modules/uview-plus/components/u-checkbox-group/u-checkbox-group.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_up_checkbox_group + _easycom_u_popup + _easycom_up_upload)();
(_easycom_up_textarea + _easycom_up_input + _easycom_up_datetime_picker + _easycom_up_checkbox + _easycom_up_checkbox_group + _easycom_u_popup + _easycom_up_upload + _easycom_wd_signature)();
}
const _sfc_main = {
__name: "rectification",
@@ -29,6 +32,32 @@ const _sfc_main = {
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 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: "",
// 整改方案
@@ -55,15 +84,15 @@ const _sfc_main = {
return `${selectedUsers.value[0].name}${selectedUsers.value.length}`;
});
const onUserChange = (ids) => {
common_vendor.index.__f__("log", "at pages/hiddendanger/rectification.vue:125", "选中的ID:", ids);
common_vendor.index.__f__("log", "at pages/hiddendanger/rectification.vue:211", "选中的ID:", ids);
};
const confirmUserSelect = () => {
selectedUsers.value = cateList.value.filter((item) => selectedUserIds.value.includes(item.id));
showUserPopup.value = false;
common_vendor.index.__f__("log", "at pages/hiddendanger/rectification.vue:133", "选中的整改人员:", selectedUsers.value);
common_vendor.index.__f__("log", "at pages/hiddendanger/rectification.vue:219", "选中的整改人员:", selectedUsers.value);
};
const fetchDeptUsers = async () => {
common_vendor.index.__f__("log", "at pages/hiddendanger/rectification.vue:138", "当前hazardId:", hazardId.value);
common_vendor.index.__f__("log", "at pages/hiddendanger/rectification.vue:224", "当前hazardId:", hazardId.value);
try {
const res = await request_api.getDeptUsersWithSubordinates({ hazardId: hazardId.value });
if (res.code === 0 && res.data) {
@@ -79,10 +108,10 @@ const _sfc_main = {
}
});
cateList.value = userList;
common_vendor.index.__f__("log", "at pages/hiddendanger/rectification.vue:156", "整改人员列表:", cateList.value);
common_vendor.index.__f__("log", "at pages/hiddendanger/rectification.vue:242", "整改人员列表:", cateList.value);
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:159", "获取部门人员失败:", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:245", "获取部门人员失败:", error);
}
};
const fileList1 = common_vendor.ref([]);
@@ -100,13 +129,28 @@ const _sfc_main = {
});
});
for (let i = 0; i < lists.length; i++) {
const result = await uploadFilePromise(lists[i].url);
let watermarkedUrl = lists[i].url;
try {
const instance = common_vendor.getCurrentInstance();
watermarkedUrl = await utils_watermark.addTimestampWatermark({
tempFilePath: lists[i].url,
canvasId: "watermarkCanvas",
canvasWidthRef: canvasWidth,
canvasHeightRef: canvasHeight,
instance
});
} catch (e) {
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:281", "加水印失败,将使用原图上传:", e);
}
const result = await uploadFilePromise(watermarkedUrl);
let item = fileList1.value[fileListLen];
const serverPath = typeof result === "string" ? result : (result == null ? void 0 : result.url) || (result == null ? void 0 : result.filePath) || (result == null ? void 0 : result.path) || "";
fileList1.value.splice(fileListLen, 1, {
...item,
status: "success",
message: "",
url: result
url: request_request.toImageUrl(serverPath),
serverPath
});
fileListLen++;
}
@@ -129,12 +173,84 @@ const _sfc_main = {
}
},
fail: (err) => {
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:214", "上传失败:", err);
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:317", "上传失败:", err);
reject(err);
}
});
});
};
const executeSubmit = async () => {
const attachments = fileList1.value.map((file) => {
const path = request_request.toRelativeFilePath(file.serverPath || file.filePath || file.url || "");
const fileName = path ? path.split("/").pop() : file.name || "";
return {
fileName: fileName || "",
filePath: path || "",
fileType: file.type || "image/png",
fileSize: file.size || 0
};
});
const params = {
hazardId: hazardId.value,
assignId: assignId.value,
rectifyPlan: formData.rectifyPlan,
rectifyResult: formData.rectifyResult,
planCost: Number(formData.planCost) || 0,
actualCost: Number(formData.actualCost) || 0,
attachments,
// 整改人员ID数组
rectifyUserIds: selectedUserIds.value.map((id) => Number(id)),
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:377", "提交整改失败:", error);
common_vendor.index.showToast({
title: "操作失败",
icon: "none"
});
} finally {
isSubmitting.value = false;
}
};
const onSignatureConfirm = async (tempFilePath) => {
try {
const res = await uploadFilePromise(tempFilePath);
const path = res && typeof res === "object" ? res.url || res.filePath || "" : res || "";
signatureServerPath.value = request_request.toRelativeFilePath(path);
signatureUrl.value = request_request.toImageUrl(signatureServerPath.value);
if (isSubmitting.value) {
await executeSubmit();
}
} catch (err) {
isSubmitting.value = false;
common_vendor.index.hideLoading();
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:402", "签名上传失败:", err);
common_vendor.index.showToast({ title: "签名上传失败,请重试", icon: "none" });
}
};
const handleSubmit = async () => {
if (!formData.rectifyPlan) {
common_vendor.index.showToast({
@@ -157,57 +273,28 @@ const _sfc_main = {
});
return;
}
const attachments = fileList1.value.map((file) => {
let url = "";
if (typeof file.url === "string") {
url = file.url;
} else if (file.url && typeof file.url === "object") {
url = file.url.url || file.url.path || "";
}
const fileName = typeof url === "string" && url ? url.split("/").pop() : file.name || "";
return {
fileName: fileName || "",
filePath: url || "",
fileType: file.type || "image/png",
fileSize: file.size || 0
};
});
const params = {
hazardId: hazardId.value,
assignId: assignId.value,
rectifyPlan: formData.rectifyPlan,
rectifyResult: formData.rectifyResult,
planCost: Number(formData.planCost) || 0,
actualCost: Number(formData.actualCost) || 0,
attachments,
// 整改人员ID数组
rectifyUserIds: selectedUserIds.value.map((id) => Number(id))
};
if (rectifyId.value) {
params.rectifyId = rectifyId.value;
}
try {
const res = await request_api.submitRectification(params);
if (res.code === 0) {
if (showCanvas.value) {
if (!signatureRef.value || isSignatureEmpty.value) {
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 ? "保存失败" : "提交失败"),
title: "请进行电子签名",
icon: "none"
});
return;
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:296", "提交整改失败:", error);
common_vendor.index.showToast({
title: "操作失败",
icon: "none"
});
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 () => {
@@ -221,18 +308,26 @@ const _sfc_main = {
formData.rectifyResult = data.rectifyResult || "";
formData.planCost = data.planCost ? String(data.planCost) : "";
formData.actualCost = data.actualCost ? String(data.actualCost) : "";
if (data.signPath) {
signatureServerPath.value = request_request.toRelativeFilePath(data.signPath);
signatureUrl.value = request_request.toImageUrl(signatureServerPath.value);
showCanvas.value = false;
}
hazardId.value = data.hazardId || "";
assignId.value = data.assignId || "";
await fetchDeptUsers();
if (data.attachments && data.attachments.length > 0) {
fileList1.value = data.attachments.map((att) => ({
url: att.filePath.startsWith("http") ? att.filePath : request_request.baseUrl.replace("/api", "") + att.filePath,
status: "success",
message: "",
name: att.fileName,
type: att.fileType,
filePath: att.filePath
// 保存原始路径用于提交
}));
fileList1.value = data.attachments.map((att) => {
const serverPath = request_request.toRelativeFilePath(att.filePath);
return {
url: request_request.toImageUrl(serverPath),
status: "success",
message: "",
name: att.fileName,
type: att.fileType,
serverPath
};
});
}
if (data.memberIds) {
const memberIdArr = data.memberIds.split(",").map((id) => String(id.trim()));
@@ -250,7 +345,7 @@ const _sfc_main = {
}
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:356", "获取整改详情失败:", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:600", "获取整改详情失败:", error);
common_vendor.index.showToast({ title: "获取详情失败", icon: "none" });
}
};
@@ -281,70 +376,198 @@ const _sfc_main = {
common_vendor.index.showToast({ title: aiRes.msg || "AI生成失败", icon: "none" });
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:393", "AI生成整改方案失败:", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/rectification.vue:637", "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.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,
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.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.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.rectifyResult = data.formData.rectifyResult || "";
formData.planCost = data.formData.planCost || "";
formData.actualCost = data.formData.actualCost || "";
fileList1.value = data.fileList1 || [];
signatureServerPath.value = data.signatureServerPath || "";
signatureUrl.value = data.signatureUrl || "";
showCanvas.value = data.showCanvas !== void 0 ? data.showCanvas : true;
signaturePaths.value = data.signaturePaths || [];
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:772", "解析草稿失败:", e);
isRestoring.value = false;
}
}
};
common_vendor.watch(
() => [
formData.rectifyPlan,
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:803", "获取系统信息失败:", e);
}
if (options.hazardId) {
hazardId.value = options.hazardId;
}
if (options.assignId) {
assignId.value = options.assignId;
}
fetchDeptUsers();
if (!options.rectifyId)
fetchDeptUsers();
if (options.rectifyId) {
rectifyId.value = options.rectifyId;
isEdit.value = options.isEdit === "1";
fetchRectifyDetail();
} else {
restoreDraft();
}
});
return (_ctx, _cache) => {
return common_vendor.e({
a: !aiGenerating.value
a: showRestoreBanner.value
}, showRestoreBanner.value ? {
b: common_vendor.o(($event) => clearDraft(true))
} : {}, {
c: !aiGenerating.value
}, !aiGenerating.value ? {} : {}, {
b: common_vendor.t(aiGenerating.value ? "AI生成中..." : "AI生成整改方案"),
c: aiGenerating.value,
d: aiGenerating.value,
e: common_vendor.o(handleAiGenerate),
f: common_vendor.o(($event) => formData.rectifyPlan = $event),
g: common_vendor.p({
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
}),
h: common_vendor.o(($event) => formData.rectifyResult = $event),
i: common_vendor.p({
j: common_vendor.o(($event) => formData.rectifyResult = $event),
k: common_vendor.p({
placeholder: "请输入内容",
modelValue: formData.rectifyResult
}),
j: common_vendor.o(($event) => formData.planCost = $event),
k: common_vendor.p({
l: common_vendor.o(($event) => formData.planCost = $event),
m: common_vendor.p({
placeholder: "请输入内容",
type: "number",
modelValue: formData.planCost
}),
l: common_vendor.o(($event) => formData.actualCost = $event),
m: common_vendor.p({
n: common_vendor.o(($event) => formData.actualCost = $event),
o: common_vendor.p({
placeholder: "请输入内容",
type: "number",
modelValue: formData.actualCost
}),
n: common_vendor.o(($event) => value1.value = $event),
o: common_vendor.p({
p: common_vendor.o(($event) => value1.value = $event),
q: common_vendor.p({
hasInput: true,
show: show.value,
mode: "date",
modelValue: value1.value
}),
p: common_vendor.t(selectedUsers.value.length > 0 ? selectedUsersText.value : "请选择整改人员(可多选)"),
q: selectedUsers.value.length === 0 ? 1 : "",
r: common_vendor.o(($event) => showUserPopup.value = true),
s: common_vendor.o(($event) => showUserPopup.value = false),
t: common_vendor.f(cateList.value, (item, k0, i0) => {
r: common_vendor.t(selectedUsers.value.length > 0 ? selectedUsersText.value : "请选择整改人员(可多选)"),
s: selectedUsers.value.length === 0 ? 1 : "",
t: common_vendor.o(($event) => showUserPopup.value = true),
v: common_vendor.o(($event) => showUserPopup.value = false),
w: common_vendor.f(cateList.value, (item, k0, i0) => {
return {
a: "f18ba0ce-7-" + i0 + ",f18ba0ce-6",
b: common_vendor.p({
@@ -356,31 +579,64 @@ const _sfc_main = {
c: item.id
};
}),
v: common_vendor.o(onUserChange),
w: common_vendor.o(($event) => selectedUserIds.value = $event),
x: common_vendor.p({
x: common_vendor.o(onUserChange),
y: common_vendor.o(($event) => selectedUserIds.value = $event),
z: common_vendor.p({
placement: "column",
modelValue: selectedUserIds.value
}),
y: common_vendor.o(($event) => showUserPopup.value = false),
z: common_vendor.o(confirmUserSelect),
A: common_vendor.o(($event) => showUserPopup.value = false),
B: common_vendor.p({
B: common_vendor.o(confirmUserSelect),
C: common_vendor.o(($event) => showUserPopup.value = false),
D: common_vendor.p({
show: showUserPopup.value,
mode: "bottom",
round: "20"
}),
C: common_vendor.o(afterRead),
D: common_vendor.o(deletePic),
E: common_vendor.p({
E: common_vendor.o(afterRead),
F: common_vendor.o(deletePic),
G: common_vendor.p({
fileList: fileList1.value,
name: "1",
multiple: true,
imageMode: "aspectFill",
maxCount: 10
}),
F: common_vendor.t(isEdit.value ? "保存修改" : "提交整改"),
G: common_vendor.o(handleSubmit),
H: common_vendor.gei(_ctx, "")
H: canvasWidth.value,
I: canvasHeight.value,
J: canvasWidth.value + "px",
K: canvasHeight.value + "px",
L: showCanvas.value
}, showCanvas.value ? {
M: common_vendor.o(clearSignature)
} : {
N: common_vendor.o(reSign)
}, {
O: !showCanvas.value
}, !showCanvas.value ? {
P: signatureUrl.value
} : {}, {
Q: showCanvas.value && !showUserPopup.value
}, showCanvas.value && !showUserPopup.value ? {
R: common_vendor.sr(signatureRef, "f18ba0ce-9", {
"k": "signatureRef"
}),
S: common_vendor.o((res) => onSignatureConfirm(res.tempFilePath)),
T: common_vendor.o(($event) => isSignatureEmpty.value = false),
U: common_vendor.o(($event) => isSignatureEmpty.value = false),
V: common_vendor.o(($event) => isSignatureEmpty.value = true),
W: common_vendor.p({
width: signatureWidth.value,
height: 160,
backgroundColor: "#f8f8f8",
penColor: "#000000",
lineWidth: 3,
enableHistory: false
})
} : {}, {
X: common_vendor.t(isEdit.value ? "保存修改" : "提交整改"),
Y: common_vendor.o(handleSubmit),
Z: common_vendor.gei(_ctx, "")
});
};
}