v1.2.1版本,优化调整了很多,整改验收阶段新加字段
This commit is contained in:
@@ -2,7 +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");
|
||||
const utils_upload = require("../../utils/upload.js");
|
||||
if (!Array) {
|
||||
const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
|
||||
const _easycom_up_upload2 = common_vendor.resolveComponent("up-upload");
|
||||
@@ -23,8 +23,24 @@ const _sfc_main = {
|
||||
const assignId = common_vendor.ref("");
|
||||
const rectifyData = common_vendor.reactive({
|
||||
rectifyPlan: "",
|
||||
rectifyResult: ""
|
||||
rectificationMeasures: "",
|
||||
controlMeasures: "",
|
||||
rectifyResult: "",
|
||||
planCost: null,
|
||||
actualCost: null,
|
||||
rectifierName: "",
|
||||
rectifyStatusName: ""
|
||||
});
|
||||
const formatMoney = (value) => {
|
||||
if (value === null || value === void 0 || value === "") {
|
||||
return "暂无";
|
||||
}
|
||||
const num = Number(value);
|
||||
if (Number.isNaN(num)) {
|
||||
return "暂无";
|
||||
}
|
||||
return `${num.toFixed(2)} 元`;
|
||||
};
|
||||
const rectifyAttachments = common_vendor.ref([]);
|
||||
const formData = common_vendor.reactive({
|
||||
result: 1,
|
||||
@@ -63,45 +79,61 @@ const _sfc_main = {
|
||||
urls
|
||||
});
|
||||
};
|
||||
const resolveAssignWithRectify = (assigns) => {
|
||||
if (!(assigns == null ? void 0 : assigns.length))
|
||||
return null;
|
||||
if (rectifyId.value) {
|
||||
const byRectifyId = assigns.find(
|
||||
(item) => item.rectify && String(item.rectify.rectifyId) === String(rectifyId.value)
|
||||
);
|
||||
if (byRectifyId)
|
||||
return byRectifyId;
|
||||
}
|
||||
if (assignId.value) {
|
||||
const byAssignId = assigns.find(
|
||||
(item) => String(item.assignId) === String(assignId.value) && item.rectify
|
||||
);
|
||||
if (byAssignId)
|
||||
return byAssignId;
|
||||
}
|
||||
return assigns.find((item) => item.rectify) || null;
|
||||
};
|
||||
const applyRectifyData = (rectify) => {
|
||||
if (!rectify)
|
||||
return;
|
||||
rectifyData.rectifyPlan = rectify.rectifyPlan || "";
|
||||
rectifyData.rectificationMeasures = rectify.rectificationMeasures || "";
|
||||
rectifyData.controlMeasures = rectify.controlMeasures || "";
|
||||
rectifyData.rectifyResult = rectify.rectifyResult || "";
|
||||
rectifyData.planCost = rectify.planCost ?? null;
|
||||
rectifyData.actualCost = rectify.actualCost ?? null;
|
||||
rectifyData.rectifierName = rectify.rectifierName || "";
|
||||
rectifyData.rectifyStatusName = rectify.rectifyStatusName || "";
|
||||
rectifyAttachments.value = rectify.attachments || [];
|
||||
};
|
||||
const fetchDetail = async () => {
|
||||
if (!hazardId.value || !assignId.value)
|
||||
if (!hazardId.value)
|
||||
return;
|
||||
try {
|
||||
const res = await request_api.getHiddenDangerDetail({ hazardId: hazardId.value, assignId: assignId.value });
|
||||
const res = await request_api.getHiddenDangerDetail({
|
||||
hazardId: hazardId.value,
|
||||
assignId: assignId.value
|
||||
});
|
||||
if (res.code === 0 && res.data) {
|
||||
if (res.data.assigns && res.data.assigns.length > 0) {
|
||||
const assign = res.data.assigns[0];
|
||||
if (assign.rectify) {
|
||||
rectifyData.rectifyPlan = assign.rectify.rectifyPlan || "";
|
||||
rectifyData.rectifyResult = assign.rectify.rectifyResult || "";
|
||||
if (assign.rectify.attachments) {
|
||||
rectifyAttachments.value = assign.rectify.attachments;
|
||||
}
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance.vue:167", "整改记录:", rectifyData);
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance.vue:168", "整改附件:", rectifyAttachments.value);
|
||||
}
|
||||
const assign = resolveAssignWithRectify(res.data.assigns);
|
||||
if (assign == null ? void 0 : assign.rectify) {
|
||||
applyRectifyData(assign.rectify);
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance.vue:240", "整改记录:", rectifyData);
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance.vue:241", "整改附件:", rectifyAttachments.value);
|
||||
}
|
||||
} else {
|
||||
common_vendor.index.showToast({ title: res.msg || "获取详情失败", icon: "none" });
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:175", "获取隐患详情失败:", error);
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:247", "获取隐患详情失败:", error);
|
||||
common_vendor.index.showToast({ title: "请求失败", icon: "none" });
|
||||
}
|
||||
};
|
||||
common_vendor.onLoad((options) => {
|
||||
if (options.rectifyId) {
|
||||
rectifyId.value = options.rectifyId;
|
||||
}
|
||||
if (options.hazardId) {
|
||||
hazardId.value = options.hazardId;
|
||||
}
|
||||
if (options.assignId) {
|
||||
assignId.value = options.assignId;
|
||||
}
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance.vue:190", "验收页面参数:", { rectifyId: rectifyId.value, hazardId: hazardId.value, assignId: assignId.value });
|
||||
fetchDetail();
|
||||
});
|
||||
const handleCancel = () => {
|
||||
common_vendor.index.navigateBack();
|
||||
};
|
||||
@@ -138,24 +170,7 @@ const _sfc_main = {
|
||||
}
|
||||
};
|
||||
const executeSubmit = async () => {
|
||||
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 || "";
|
||||
}
|
||||
if (typeof url === "string" && url.startsWith("http")) {
|
||||
url = url.replace(request_request.imageBaseUrl, "");
|
||||
}
|
||||
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 attachments = fileList1.value.filter((f) => f.status === "success").map((file) => utils_upload.buildAttachmentItem(file));
|
||||
const params = {
|
||||
rectifyId: Number(rectifyId.value),
|
||||
result: formData.result,
|
||||
@@ -164,7 +179,7 @@ const _sfc_main = {
|
||||
signPath: signatureServerPath.value || ""
|
||||
// 电子签名路径
|
||||
};
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance.vue:271", "提交验收参数:", params);
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance.vue:311", "提交验收参数:", params);
|
||||
try {
|
||||
const res = await request_api.acceptanceRectification(params);
|
||||
common_vendor.index.hideLoading();
|
||||
@@ -185,7 +200,7 @@ const _sfc_main = {
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:293", "验收失败:", error);
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:333", "验收失败:", error);
|
||||
common_vendor.index.showToast({
|
||||
title: "请求失败",
|
||||
icon: "none"
|
||||
@@ -194,76 +209,15 @@ const _sfc_main = {
|
||||
isSubmitting.value = false;
|
||||
}
|
||||
};
|
||||
const deletePic = (event) => {
|
||||
fileList1.value.splice(event.index, 1);
|
||||
};
|
||||
const addWatermark = (tempFilePath) => {
|
||||
const instance = common_vendor.getCurrentInstance();
|
||||
return utils_watermark.addTimestampWatermark({
|
||||
tempFilePath,
|
||||
const acceptUploadInstance = common_vendor.getCurrentInstance();
|
||||
const { afterRead, deletePic } = utils_upload.createUploadListHandlers(fileList1, {
|
||||
watermark: {
|
||||
canvasId: "watermarkCanvas",
|
||||
canvasWidthRef: canvasWidth,
|
||||
canvasHeightRef: canvasHeight,
|
||||
instance
|
||||
});
|
||||
};
|
||||
const afterRead = async (event) => {
|
||||
let lists = [].concat(event.file);
|
||||
let fileListLen = fileList1.value.length;
|
||||
lists.map((item) => {
|
||||
fileList1.value.push({
|
||||
...item,
|
||||
status: "uploading",
|
||||
message: "处理中..."
|
||||
});
|
||||
});
|
||||
for (let i = 0; i < lists.length; i++) {
|
||||
try {
|
||||
const watermarkedUrl = await addWatermark(lists[i].url);
|
||||
const result = await uploadFilePromise(watermarkedUrl);
|
||||
let item = fileList1.value[fileListLen];
|
||||
fileList1.value.splice(fileListLen, 1, {
|
||||
...item,
|
||||
status: "success",
|
||||
message: "",
|
||||
url: request_request.toImageUrl(result.url || result.filePath || result)
|
||||
});
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:352", "加水印或上传失败:", e);
|
||||
let item = fileList1.value[fileListLen];
|
||||
fileList1.value.splice(fileListLen, 1, {
|
||||
...item,
|
||||
status: "failed",
|
||||
message: "处理失败"
|
||||
});
|
||||
}
|
||||
fileListLen++;
|
||||
instance: acceptUploadInstance
|
||||
}
|
||||
};
|
||||
const uploadFilePromise = (filePath) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.uploadFile({
|
||||
url: request_request.baseUrl + "/frontend/attachment/upload",
|
||||
filePath,
|
||||
name: "file",
|
||||
header: {
|
||||
"Authorization": request_request.getToken()
|
||||
},
|
||||
success: (res) => {
|
||||
const data = JSON.parse(res.data);
|
||||
if (data.code === 0) {
|
||||
resolve(data.data);
|
||||
} else {
|
||||
reject(data.msg || "上传失败");
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:382", "上传失败:", err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
const saveDraft = () => {
|
||||
if (isRestoring.value || !isInitialized.value)
|
||||
return;
|
||||
@@ -349,7 +303,7 @@ const _sfc_main = {
|
||||
duration: 2500
|
||||
});
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:502", "解析草稿失败:", e);
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:466", "解析草稿失败:", e);
|
||||
isRestoring.value = false;
|
||||
isInitialized.value = true;
|
||||
}
|
||||
@@ -391,17 +345,18 @@ const _sfc_main = {
|
||||
};
|
||||
const onSignatureConfirm = async (tempFilePath) => {
|
||||
try {
|
||||
const res = await uploadFilePromise(tempFilePath);
|
||||
const path = res && typeof res === "object" ? res.url || res.filePath || "" : res || "";
|
||||
signatureServerPath.value = path;
|
||||
signatureUrl.value = path.startsWith("http") ? path : request_request.baseUrl.replace("/api", "") + path;
|
||||
const { url } = await utils_upload.uploadToCloud(tempFilePath);
|
||||
signatureServerPath.value = url;
|
||||
signatureUrl.value = url;
|
||||
showCanvas.value = false;
|
||||
isSignatureEmpty.value = false;
|
||||
if (isSubmitting.value) {
|
||||
await executeSubmit();
|
||||
}
|
||||
} catch (err) {
|
||||
isSubmitting.value = false;
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:573", "签名上传失败:", err);
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:536", "签名上传失败:", err);
|
||||
common_vendor.index.showToast({ title: "签名上传失败,请重试", icon: "none" });
|
||||
}
|
||||
};
|
||||
@@ -410,7 +365,7 @@ const _sfc_main = {
|
||||
const sysInfo = common_vendor.index.getSystemInfoSync();
|
||||
signatureWidth.value = sysInfo.windowWidth - 40;
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:584", "获取系统信息失败:", e);
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/acceptance.vue:547", "获取系统信息失败:", e);
|
||||
}
|
||||
if (options.rectifyId) {
|
||||
rectifyId.value = options.rectifyId;
|
||||
@@ -421,17 +376,23 @@ const _sfc_main = {
|
||||
if (options.assignId) {
|
||||
assignId.value = options.assignId;
|
||||
}
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance.vue:595", "验收页面参数:", { rectifyId: rectifyId.value, hazardId: hazardId.value, assignId: assignId.value });
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/acceptance.vue:558", "验收页面参数:", { rectifyId: rectifyId.value, hazardId: hazardId.value, assignId: assignId.value });
|
||||
fetchDetail();
|
||||
restoreDraft();
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.t(rectifyData.rectifyPlan || "暂无"),
|
||||
b: common_vendor.t(rectifyData.rectifyResult || "暂无"),
|
||||
c: rectifyAttachments.value.length > 0
|
||||
b: common_vendor.t(rectifyData.rectificationMeasures || "暂无"),
|
||||
c: common_vendor.t(rectifyData.controlMeasures || "暂无"),
|
||||
d: common_vendor.t(rectifyData.rectifyResult || "暂无"),
|
||||
e: common_vendor.t(formatMoney(rectifyData.planCost)),
|
||||
f: common_vendor.t(formatMoney(rectifyData.actualCost)),
|
||||
g: common_vendor.t(rectifyData.rectifierName || "暂无"),
|
||||
h: common_vendor.t(rectifyData.rectifyStatusName || "暂无"),
|
||||
i: rectifyAttachments.value.length > 0
|
||||
}, rectifyAttachments.value.length > 0 ? {
|
||||
d: common_vendor.f(rectifyAttachments.value, (img, idx, i0) => {
|
||||
j: common_vendor.f(rectifyAttachments.value, (img, idx, i0) => {
|
||||
return {
|
||||
a: idx,
|
||||
b: getFullPath(img.filePath),
|
||||
@@ -439,48 +400,48 @@ const _sfc_main = {
|
||||
};
|
||||
})
|
||||
} : {}, {
|
||||
e: common_vendor.n(formData.result === 1 ? "active" : ""),
|
||||
f: common_vendor.o(($event) => formData.result = 1),
|
||||
g: common_vendor.n(formData.result === 2 ? "active" : ""),
|
||||
h: common_vendor.o(($event) => formData.result = 2),
|
||||
i: common_vendor.o(($event) => formData.verifyRemark = $event),
|
||||
j: common_vendor.p({
|
||||
k: common_vendor.n(formData.result === 1 ? "active" : ""),
|
||||
l: common_vendor.o(($event) => formData.result = 1),
|
||||
m: common_vendor.n(formData.result === 2 ? "active" : ""),
|
||||
n: common_vendor.o(($event) => formData.result = 2),
|
||||
o: common_vendor.o(($event) => formData.verifyRemark = $event),
|
||||
p: common_vendor.p({
|
||||
placeholder: "请输入验收备注",
|
||||
modelValue: formData.verifyRemark
|
||||
}),
|
||||
k: common_vendor.o(afterRead),
|
||||
l: common_vendor.o(deletePic),
|
||||
m: common_vendor.p({
|
||||
q: common_vendor.o(common_vendor.unref(afterRead)),
|
||||
r: common_vendor.o(common_vendor.unref(deletePic)),
|
||||
s: common_vendor.p({
|
||||
fileList: fileList1.value,
|
||||
name: "1",
|
||||
multiple: true,
|
||||
imageMode: "aspectFill",
|
||||
maxCount: 10
|
||||
}),
|
||||
n: canvasWidth.value,
|
||||
o: canvasHeight.value,
|
||||
p: canvasWidth.value + "px",
|
||||
q: canvasHeight.value + "px",
|
||||
r: showCanvas.value
|
||||
t: canvasWidth.value,
|
||||
v: canvasHeight.value,
|
||||
w: canvasWidth.value + "px",
|
||||
x: canvasHeight.value + "px",
|
||||
y: showCanvas.value
|
||||
}, showCanvas.value ? {
|
||||
s: common_vendor.o(clearSignature)
|
||||
z: common_vendor.o(clearSignature)
|
||||
} : {
|
||||
t: common_vendor.o(reSign)
|
||||
A: common_vendor.o(reSign)
|
||||
}, {
|
||||
v: !showCanvas.value
|
||||
B: !showCanvas.value
|
||||
}, !showCanvas.value ? {
|
||||
w: signatureUrl.value
|
||||
C: signatureUrl.value
|
||||
} : {}, {
|
||||
x: showCanvas.value
|
||||
D: showCanvas.value
|
||||
}, showCanvas.value ? {
|
||||
y: common_vendor.sr(signatureRef, "39f9b795-2", {
|
||||
E: common_vendor.sr(signatureRef, "39f9b795-2", {
|
||||
"k": "signatureRef"
|
||||
}),
|
||||
z: common_vendor.o((res) => onSignatureConfirm(res.tempFilePath)),
|
||||
A: common_vendor.o(($event) => isSignatureEmpty.value = false),
|
||||
B: common_vendor.o(($event) => isSignatureEmpty.value = false),
|
||||
C: common_vendor.o(($event) => isSignatureEmpty.value = true),
|
||||
D: common_vendor.p({
|
||||
F: common_vendor.o((res) => onSignatureConfirm(res.tempFilePath)),
|
||||
G: common_vendor.o(($event) => isSignatureEmpty.value = false),
|
||||
H: common_vendor.o(($event) => isSignatureEmpty.value = false),
|
||||
I: common_vendor.o(($event) => isSignatureEmpty.value = true),
|
||||
J: common_vendor.p({
|
||||
width: signatureWidth.value,
|
||||
height: 160,
|
||||
backgroundColor: "#f8f8f8",
|
||||
@@ -489,9 +450,9 @@ const _sfc_main = {
|
||||
enableHistory: false
|
||||
})
|
||||
} : {}, {
|
||||
E: common_vendor.o(handleCancel),
|
||||
F: common_vendor.o(handleSubmit),
|
||||
G: common_vendor.gei(_ctx, "")
|
||||
K: common_vendor.o(handleCancel),
|
||||
L: common_vendor.o(handleSubmit),
|
||||
M: common_vendor.gei(_ctx, "")
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user