840 lines
34 KiB
JavaScript
840 lines
34 KiB
JavaScript
"use strict";
|
||
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 request_three_one_api_area = require("../../request/three_one_api/area.js");
|
||
if (!Array) {
|
||
const _easycom_u_radio2 = common_vendor.resolveComponent("u-radio");
|
||
const _easycom_u_radio_group2 = common_vendor.resolveComponent("u-radio-group");
|
||
const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
|
||
const _easycom_up_upload2 = common_vendor.resolveComponent("up-upload");
|
||
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
|
||
const _easycom_up_choose2 = common_vendor.resolveComponent("up-choose");
|
||
const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
|
||
(_easycom_u_radio2 + _easycom_u_radio_group2 + _easycom_up_textarea2 + _easycom_up_upload2 + _easycom_up_input2 + _easycom_up_choose2 + _easycom_u_popup2)();
|
||
}
|
||
const _easycom_u_radio = () => "../../uni_modules/uview-plus/components/u-radio/u-radio.js";
|
||
const _easycom_u_radio_group = () => "../../uni_modules/uview-plus/components/u-radio-group/u-radio-group.js";
|
||
const _easycom_up_textarea = () => "../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
|
||
const _easycom_up_upload = () => "../../uni_modules/uview-plus/components/u-upload/u-upload.js";
|
||
const _easycom_up_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
|
||
const _easycom_up_choose = () => "../../uni_modules/uview-plus/components/u-choose/u-choose.js";
|
||
const _easycom_u_popup = () => "../../uni_modules/uview-plus/components/u-popup/u-popup.js";
|
||
if (!Math) {
|
||
(_easycom_u_radio + _easycom_u_radio_group + _easycom_up_textarea + _easycom_up_upload + _easycom_up_input + _easycom_up_choose + _easycom_u_popup)();
|
||
}
|
||
const _sfc_main = {
|
||
__name: "Inspectionresult",
|
||
setup(__props) {
|
||
const oneTableId = common_vendor.ref("");
|
||
const canvasWidth = common_vendor.ref(300);
|
||
const canvasHeight = common_vendor.ref(300);
|
||
const checkData = common_vendor.ref(null);
|
||
const radiolist1 = common_vendor.reactive([
|
||
{
|
||
name: "正常",
|
||
value: 1,
|
||
disabled: false
|
||
},
|
||
{
|
||
name: "异常",
|
||
value: 2,
|
||
disabled: false
|
||
},
|
||
{
|
||
name: "不涉及",
|
||
value: 3,
|
||
disabled: false
|
||
}
|
||
]);
|
||
const radiovalue1 = common_vendor.ref("");
|
||
const groupChange = (n) => {
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:305", "groupChange", n);
|
||
if (n !== "异常") {
|
||
clearHazard();
|
||
}
|
||
};
|
||
const radioChange = (n) => {
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:313", "radioChange", n);
|
||
};
|
||
const value1 = common_vendor.ref("");
|
||
const showHazardPopup = common_vendor.ref(false);
|
||
const hazardFormData = common_vendor.reactive({
|
||
title: "",
|
||
level: 0,
|
||
source: 0,
|
||
description: "",
|
||
tagIndex: 0,
|
||
regulationId: null,
|
||
// 法律依据ID
|
||
regulationName: ""
|
||
// 法律依据名称(显示用)
|
||
});
|
||
const hazardAddress = common_vendor.ref("");
|
||
const hazardLng = common_vendor.ref(0);
|
||
const hazardLat = common_vendor.ref(0);
|
||
const showAreaPicker = common_vendor.ref(false);
|
||
const areaList = common_vendor.ref([]);
|
||
const selectedAreaId = common_vendor.ref("");
|
||
const selectedAreaName = common_vendor.ref("");
|
||
const tempAreaId = common_vendor.ref("");
|
||
const showLawPopup = common_vendor.ref(false);
|
||
const lawKeyword = common_vendor.ref("");
|
||
const selectedLawId = common_vendor.ref(null);
|
||
const selectedLawName = common_vendor.ref("");
|
||
const lawList = common_vendor.ref([]);
|
||
const lawLoading = common_vendor.ref(false);
|
||
const lawPageNum = common_vendor.ref(1);
|
||
const lawPageSize = common_vendor.ref(10);
|
||
const hasMoreLaw = common_vendor.ref(true);
|
||
const openLawPopup = () => {
|
||
showLawPopup.value = true;
|
||
if (lawList.value.length === 0) {
|
||
fetchRegulationList();
|
||
}
|
||
};
|
||
const fetchRegulationList = async (isLoadMore = false) => {
|
||
if (lawLoading.value)
|
||
return;
|
||
lawLoading.value = true;
|
||
try {
|
||
const params = {
|
||
pageNum: lawPageNum.value,
|
||
pageSize: lawPageSize.value,
|
||
status: 1
|
||
// 启用状态
|
||
};
|
||
if (lawKeyword.value && lawKeyword.value.trim()) {
|
||
params.keyword = lawKeyword.value.trim();
|
||
}
|
||
const res = await request_api.getRegulationList(params);
|
||
if (res.code === 0) {
|
||
const records = res.data.records || res.data || [];
|
||
if (isLoadMore) {
|
||
lawList.value = [...lawList.value, ...records];
|
||
} else {
|
||
lawList.value = records;
|
||
}
|
||
const total = res.data.total || 0;
|
||
hasMoreLaw.value = lawList.value.length < total;
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:392", "获取法规列表失败:", error);
|
||
} finally {
|
||
lawLoading.value = false;
|
||
}
|
||
};
|
||
const searchRegulation = () => {
|
||
lawPageNum.value = 1;
|
||
lawList.value = [];
|
||
hasMoreLaw.value = true;
|
||
fetchRegulationList();
|
||
};
|
||
const loadMoreLaw = () => {
|
||
if (!hasMoreLaw.value || lawLoading.value)
|
||
return;
|
||
lawPageNum.value++;
|
||
fetchRegulationList(true);
|
||
};
|
||
const selectLaw = (item) => {
|
||
selectedLawId.value = item.id;
|
||
selectedLawName.value = item.depict || item.keyword || "";
|
||
};
|
||
const confirmLaw = () => {
|
||
if (selectedLawId.value) {
|
||
hazardFormData.regulationId = selectedLawId.value;
|
||
hazardFormData.regulationName = selectedLawName.value;
|
||
}
|
||
showLawPopup.value = false;
|
||
};
|
||
const fetchAreaList = async () => {
|
||
try {
|
||
const res = await request_three_one_api_area.getAreaList();
|
||
if (res.code === 0 && res.data && res.data.records) {
|
||
areaList.value = res.data.records;
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:436", "获取区域列表失败:", error);
|
||
}
|
||
};
|
||
const confirmAreaSelect = () => {
|
||
if (tempAreaId.value) {
|
||
selectedAreaId.value = tempAreaId.value;
|
||
const selected = areaList.value.find((item) => item.id === tempAreaId.value);
|
||
selectedAreaName.value = selected ? selected.name : "";
|
||
}
|
||
showAreaPicker.value = false;
|
||
};
|
||
const hazardFileList = common_vendor.ref([]);
|
||
const levelChooseRef = common_vendor.ref(null);
|
||
const aiAnalyzing = common_vendor.ref(false);
|
||
const hasHazardData = common_vendor.computed(() => {
|
||
return hazardFormData.title && hazardFileList.value.length > 0;
|
||
});
|
||
const progressPercent = common_vendor.computed(() => {
|
||
if (!checkData.value)
|
||
return 0;
|
||
const current = checkData.value.currentIndex || 1;
|
||
const total = checkData.value.totalCount || 1;
|
||
return Math.round(current / total * 100);
|
||
});
|
||
const levelOptions = common_vendor.ref([
|
||
// { id: 1, title: '轻微隐患' },
|
||
{ id: 2, title: "一般隐患" },
|
||
{ id: 3, title: "重大隐患" }
|
||
]);
|
||
const sourceOptions = common_vendor.ref([
|
||
{ id: 1, title: "随手拍" },
|
||
{ id: 2, title: "企业自查" },
|
||
{ id: 3, title: "行业互查" },
|
||
{ id: 4, title: "专家诊查" }
|
||
]);
|
||
const tagOptions = common_vendor.ref([]);
|
||
const fetchTagOptions = async () => {
|
||
try {
|
||
const res = await request_api.getHiddenDangerLabelList();
|
||
if (res.code === 0) {
|
||
tagOptions.value = res.data.map((item) => ({
|
||
id: item.id,
|
||
title: item.name
|
||
}));
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:501", "获取标签列表失败:", error);
|
||
}
|
||
};
|
||
const openHazardPopup = () => {
|
||
showHazardPopup.value = true;
|
||
};
|
||
const editHazard = () => {
|
||
showHazardPopup.value = true;
|
||
};
|
||
const clearHazard = () => {
|
||
hazardFormData.regulationId = null;
|
||
hazardFormData.regulationName = "";
|
||
selectedLawId.value = null;
|
||
selectedLawName.value = "";
|
||
hazardFormData.title = "";
|
||
hazardFormData.level = 0;
|
||
hazardFormData.source = 0;
|
||
hazardFormData.description = "";
|
||
hazardFormData.tagIndex = 0;
|
||
hazardAddress.value = "";
|
||
hazardLng.value = 0;
|
||
hazardLat.value = 0;
|
||
hazardFileList.value = [];
|
||
selectedAreaId.value = "";
|
||
selectedAreaName.value = "";
|
||
};
|
||
const confirmHazard = () => {
|
||
if (hazardFileList.value.length === 0) {
|
||
common_vendor.index.showToast({ title: "请上传隐患图片", icon: "none" });
|
||
return;
|
||
}
|
||
if (!hazardFormData.title) {
|
||
common_vendor.index.showToast({ title: "请输入隐患标题", icon: "none" });
|
||
return;
|
||
}
|
||
if (!hazardAddress.value) {
|
||
common_vendor.index.showToast({ title: "请输入隐患位置", icon: "none" });
|
||
return;
|
||
}
|
||
if (!hazardFormData.description) {
|
||
common_vendor.index.showToast({ title: "请输入隐患描述", icon: "none" });
|
||
return;
|
||
}
|
||
showHazardPopup.value = false;
|
||
common_vendor.index.showToast({ title: "隐患信息已暂存", icon: "success" });
|
||
};
|
||
const chooseLocation = () => {
|
||
showHazardPopup.value = false;
|
||
setTimeout(() => {
|
||
common_vendor.index.chooseLocation({
|
||
success: (res) => {
|
||
hazardAddress.value = res.address + (res.name ? `(${res.name})` : "");
|
||
hazardLng.value = res.longitude;
|
||
hazardLat.value = res.latitude;
|
||
showHazardPopup.value = true;
|
||
},
|
||
fail: (err) => {
|
||
showHazardPopup.value = true;
|
||
if (err.errMsg && err.errMsg.indexOf("cancel") === -1) {
|
||
common_vendor.index.showToast({ title: "选择位置失败", icon: "none" });
|
||
}
|
||
}
|
||
});
|
||
}, 300);
|
||
};
|
||
const deletePic = (event) => {
|
||
hazardFileList.value.splice(event.index, 1);
|
||
};
|
||
const afterRead = async (event) => {
|
||
let lists = [].concat(event.file);
|
||
let fileListLen = hazardFileList.value.length;
|
||
lists.map((item) => {
|
||
hazardFileList.value.push({
|
||
...item,
|
||
status: "uploading",
|
||
message: "上传中"
|
||
});
|
||
});
|
||
for (let i = 0; i < lists.length; i++) {
|
||
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/Inspectionresult/Inspectionresult.vue:609", "加水印失败,将使用原图上传:", e);
|
||
}
|
||
const result = await uploadFilePromise(watermarkedUrl);
|
||
let item = hazardFileList.value[fileListLen];
|
||
const serverPath = typeof result === "string" ? result : (result == null ? void 0 : result.url) || (result == null ? void 0 : result.path) || "";
|
||
hazardFileList.value.splice(fileListLen, 1, {
|
||
...item,
|
||
status: "success",
|
||
message: "",
|
||
url: request_request.toImageUrl(serverPath),
|
||
serverPath
|
||
});
|
||
fileListLen++;
|
||
}
|
||
};
|
||
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/Inspectionresult/Inspectionresult.vue:644", "上传失败:", err);
|
||
reject(err);
|
||
}
|
||
});
|
||
});
|
||
};
|
||
const handleAiAnalyze = async () => {
|
||
const imageFiles = hazardFileList.value.filter((f) => {
|
||
return f.status === "success" && f.url.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp)$/);
|
||
});
|
||
if (imageFiles.length === 0) {
|
||
common_vendor.index.showToast({ title: "请先上传隐患图片", icon: "none" });
|
||
return;
|
||
}
|
||
const fullImageUrl = imageFiles[0].url;
|
||
aiAnalyzing.value = true;
|
||
try {
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:665", "开始调用AI分析接口,图片地址:", fullImageUrl);
|
||
const analyzeRes = await request_api.analyzeHazardImage({
|
||
imageUrl: fullImageUrl
|
||
});
|
||
if (analyzeRes.code === 0 && analyzeRes.data) {
|
||
const aiData = analyzeRes.data;
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:672", "AI分析结果:", aiData);
|
||
if (aiData.title)
|
||
hazardFormData.title = aiData.title;
|
||
if (aiData.description)
|
||
hazardFormData.description = aiData.description;
|
||
if (aiData.level) {
|
||
const levelMap = { "轻微": 0, "轻微隐患": 0, "一般": 1, "一般隐患": 1, "重大": 2, "重大隐患": 2 };
|
||
const levelIndex = levelMap[aiData.level];
|
||
if (levelIndex !== void 0) {
|
||
hazardFormData.level = levelIndex;
|
||
common_vendor.nextTick$1(() => {
|
||
if (levelChooseRef.value && levelChooseRef.value.$data) {
|
||
levelChooseRef.value.$data.currentIndex = levelIndex;
|
||
}
|
||
});
|
||
}
|
||
}
|
||
common_vendor.index.showToast({ title: "AI分析完成,已自动填充", icon: "success", duration: 2e3 });
|
||
} else {
|
||
common_vendor.index.showToast({ title: analyzeRes.msg || "AI分析失败", icon: "none" });
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:695", "AI分析接口调用失败:", error);
|
||
common_vendor.index.showToast({ title: "AI分析失败,请重试", icon: "none" });
|
||
} finally {
|
||
aiAnalyzing.value = false;
|
||
}
|
||
};
|
||
const handleSubmit = async () => {
|
||
var _a, _b, _c, _d;
|
||
if (!radiovalue1.value) {
|
||
common_vendor.index.showToast({ title: "请选择检查结果", icon: "none" });
|
||
return;
|
||
}
|
||
const selectedItem = radiolist1.find((item) => item.name === radiovalue1.value);
|
||
const resultValue = selectedItem ? selectedItem.value : null;
|
||
if (!resultValue) {
|
||
common_vendor.index.showToast({ title: "请选择检查结果", icon: "none" });
|
||
return;
|
||
}
|
||
if (radiovalue1.value === "异常" && !hasHazardData.value) {
|
||
common_vendor.index.showToast({ title: "请填写隐患信息", icon: "none" });
|
||
return;
|
||
}
|
||
try {
|
||
common_vendor.index.showLoading({ title: "提交中..." });
|
||
if (radiovalue1.value === "异常" && hasHazardData.value) {
|
||
const attachments = hazardFileList.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 selectedTag = tagOptions.value[hazardFormData.tagIndex];
|
||
const tagId = selectedTag ? selectedTag.id : null;
|
||
const hazardParams = {
|
||
taskId: (_a = checkData.value) == null ? void 0 : _a.taskId,
|
||
checkPointId: (_b = checkData.value) == null ? void 0 : _b.checkPointId,
|
||
title: hazardFormData.title,
|
||
level: hazardFormData.level + 1,
|
||
lng: hazardLng.value || 0,
|
||
lat: hazardLat.value || 0,
|
||
address: hazardAddress.value || "",
|
||
areaId: selectedAreaId.value || null,
|
||
// 隐患区域ID
|
||
description: hazardFormData.description || "",
|
||
source: ((_c = sourceOptions.value[hazardFormData.source]) == null ? void 0 : _c.title) || "",
|
||
tagId,
|
||
attachments,
|
||
regulationId: hazardFormData.regulationId || null
|
||
};
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:773", "隐患参数:", hazardParams);
|
||
const hazardRes = await request_api.addHiddenDanger(hazardParams);
|
||
if (hazardRes.code !== 0) {
|
||
common_vendor.index.hideLoading();
|
||
common_vendor.index.showToast({ title: hazardRes.msg || "新增隐患失败", icon: "none" });
|
||
return;
|
||
}
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:782", "新增隐患成功");
|
||
}
|
||
const submitParams = {
|
||
taskId: (_d = checkData.value) == null ? void 0 : _d.taskId,
|
||
result: resultValue,
|
||
remark: value1.value
|
||
};
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:791", "提交参数:", submitParams);
|
||
const res = await request_api.submitCheckResult(submitParams);
|
||
common_vendor.index.hideLoading();
|
||
if (res.code === 0) {
|
||
clearDraft(false);
|
||
if (res.data && res.data.allFinished === true) {
|
||
common_vendor.index.showToast({ title: "全部检查已完成", icon: "success" });
|
||
setTimeout(() => {
|
||
common_vendor.index.navigateBack();
|
||
}, 1500);
|
||
} else if (res.data && res.data.nextTask) {
|
||
common_vendor.index.showToast({ title: "提交成功,进入下一题", icon: "success" });
|
||
resetFormState();
|
||
checkData.value = res.data.nextTask;
|
||
} else {
|
||
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.hideLoading();
|
||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:826", "提交失败:", error);
|
||
common_vendor.index.showToast({ title: "提交失败", icon: "none" });
|
||
}
|
||
};
|
||
const resetFormState = () => {
|
||
radiovalue1.value = "";
|
||
value1.value = "";
|
||
clearHazard();
|
||
};
|
||
const getCheckData = async () => {
|
||
try {
|
||
const res = await request_api.enterCheckPlan(oneTableId.value);
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:845", "检查项数据:", res);
|
||
if (res.code === 0) {
|
||
checkData.value = res.data;
|
||
restoreDraft();
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:852", error);
|
||
}
|
||
};
|
||
const hasDraft = common_vendor.ref(false);
|
||
const showRestoreBanner = common_vendor.ref(false);
|
||
const isRestoring = common_vendor.ref(false);
|
||
const isInitialized = common_vendor.ref(false);
|
||
const getDraftKey = () => {
|
||
var _a;
|
||
return `draft_inspection_result_${oneTableId.value || ""}_${((_a = checkData.value) == null ? void 0 : _a.currentIndex) || ""}`;
|
||
};
|
||
const saveDraft = () => {
|
||
if (isRestoring.value || !isInitialized.value) {
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:867", "【草稿Debug - 巡检】saveDraft 被跳过:", { isRestoring: isRestoring.value, isInitialized: isInitialized.value });
|
||
return;
|
||
}
|
||
const key = getDraftKey();
|
||
const hasContent = radiovalue1.value || value1.value || hazardFormData.title || hazardFormData.description || hazardFileList.value.length > 0;
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:877", "【草稿Debug - 巡检】尝试自动保存草稿. Key:", key, "是否有实质内容:", !!hasContent, "当前数据:", {
|
||
radiovalue1: radiovalue1.value,
|
||
value1: value1.value,
|
||
title: hazardFormData.title,
|
||
description: hazardFormData.description,
|
||
fileCount: hazardFileList.value.length
|
||
});
|
||
if (!hasContent) {
|
||
common_vendor.index.removeStorageSync(key);
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:887", "【草稿Debug - 巡检】当前表单为空,自动删除本地缓存 Key:", key);
|
||
hasDraft.value = false;
|
||
return;
|
||
}
|
||
const data = {
|
||
radiovalue1: radiovalue1.value,
|
||
value1: value1.value,
|
||
hazardFormData: {
|
||
title: hazardFormData.title,
|
||
level: hazardFormData.level,
|
||
source: hazardFormData.source,
|
||
description: hazardFormData.description,
|
||
tagIndex: hazardFormData.tagIndex
|
||
},
|
||
hazardFileList: hazardFileList.value,
|
||
hazardAddress: hazardAddress.value,
|
||
hazardLng: hazardLng.value,
|
||
hazardLat: hazardLat.value
|
||
};
|
||
common_vendor.index.setStorageSync(key, JSON.stringify(data));
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:908", "【草稿Debug - 巡检】成功保存草稿到 LocalStorage, Key:", key);
|
||
hasDraft.value = true;
|
||
};
|
||
const clearDraft = (showToast = true) => {
|
||
const key = getDraftKey();
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:915", "【草稿Debug - 巡检】手动清空草稿, Key:", key);
|
||
common_vendor.index.removeStorageSync(key);
|
||
hasDraft.value = false;
|
||
showRestoreBanner.value = false;
|
||
isRestoring.value = true;
|
||
radiovalue1.value = "";
|
||
value1.value = "";
|
||
hazardFormData.title = "";
|
||
hazardFormData.level = 0;
|
||
hazardFormData.source = 0;
|
||
hazardFormData.description = "";
|
||
hazardFormData.tagIndex = 0;
|
||
hazardFileList.value = [];
|
||
hazardAddress.value = "";
|
||
hazardLng.value = 0;
|
||
hazardLat.value = 0;
|
||
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);
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:945", "【草稿Debug - 巡检】尝试恢复草稿, Key:", key, "获取本地缓存结果:", !!cached);
|
||
if (cached) {
|
||
try {
|
||
const data = JSON.parse(cached);
|
||
const hasContent = data.radiovalue1 || data.value1 || data.hazardFormData.title || data.hazardFormData.description || data.hazardFileList && data.hazardFileList.length > 0;
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:955", "【草稿Debug - 巡检】解析本地缓存成功, 是否有实质内容:", !!hasContent, "缓存数据:", data);
|
||
if (!hasContent) {
|
||
isInitialized.value = true;
|
||
return;
|
||
}
|
||
isRestoring.value = true;
|
||
radiovalue1.value = data.radiovalue1 || "";
|
||
value1.value = data.value1 || "";
|
||
hazardFormData.title = data.hazardFormData.title || "";
|
||
hazardFormData.level = data.hazardFormData.level || 0;
|
||
hazardFormData.source = data.hazardFormData.source || 0;
|
||
hazardFormData.description = data.hazardFormData.description || "";
|
||
hazardFormData.tagIndex = data.hazardFormData.tagIndex || 0;
|
||
hazardFileList.value = data.hazardFileList || [];
|
||
hazardAddress.value = data.hazardAddress || "";
|
||
hazardLng.value = data.hazardLng || 0;
|
||
hazardLat.value = data.hazardLat || 0;
|
||
hasDraft.value = true;
|
||
showRestoreBanner.value = true;
|
||
common_vendor.nextTick$1(() => {
|
||
isRestoring.value = false;
|
||
isInitialized.value = true;
|
||
if (levelChooseRef.value && levelChooseRef.value.$data) {
|
||
levelChooseRef.value.$data.currentIndex = hazardFormData.level;
|
||
}
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:982", "【草稿Debug - 巡检】UI与多选组件状态同步重绘完毕!");
|
||
});
|
||
common_vendor.index.showToast({
|
||
title: "已自动恢复您上次未提交的内容",
|
||
icon: "none",
|
||
duration: 2500
|
||
});
|
||
} catch (e) {
|
||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:991", "【草稿Debug - 巡检】解析草稿异常:", e);
|
||
isRestoring.value = false;
|
||
isInitialized.value = true;
|
||
}
|
||
} else {
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:996", "【草稿Debug - 巡检】本地无任何缓存, 页面已安全标记为 initialized");
|
||
isInitialized.value = true;
|
||
}
|
||
};
|
||
common_vendor.watch(
|
||
() => [
|
||
radiovalue1.value,
|
||
value1.value,
|
||
hazardFormData.title,
|
||
hazardFormData.level,
|
||
hazardFormData.source,
|
||
hazardFormData.description,
|
||
hazardFormData.tagIndex,
|
||
hazardAddress.value,
|
||
hazardFileList.value
|
||
],
|
||
() => {
|
||
if (oneTableId.value) {
|
||
saveDraft();
|
||
}
|
||
},
|
||
{ deep: true }
|
||
);
|
||
common_vendor.onLoad((options) => {
|
||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:1023", "接收到的参数:", options);
|
||
if (options.id) {
|
||
oneTableId.value = options.id;
|
||
getCheckData();
|
||
}
|
||
fetchTagOptions();
|
||
fetchAreaList();
|
||
});
|
||
return (_ctx, _cache) => {
|
||
var _a, _b, _c, _d;
|
||
return common_vendor.e({
|
||
a: checkData.value
|
||
}, checkData.value ? {
|
||
b: common_vendor.t(checkData.value.currentIndex || 1),
|
||
c: common_vendor.t(checkData.value.totalCount || 1),
|
||
d: progressPercent.value + "%"
|
||
} : {}, {
|
||
e: common_vendor.t(((_a = checkData.value) == null ? void 0 : _a.name) || "加载中..."),
|
||
f: ((_b = checkData.value) == null ? void 0 : _b.point) || "",
|
||
g: common_vendor.f(radiolist1, (item, index, i0) => {
|
||
return {
|
||
a: index,
|
||
b: common_vendor.o(radioChange, index),
|
||
c: "643afff0-1-" + i0 + ",643afff0-0",
|
||
d: common_vendor.p({
|
||
customStyle: {
|
||
marginBottom: "8px"
|
||
},
|
||
label: item.name,
|
||
name: item.name
|
||
})
|
||
};
|
||
}),
|
||
h: common_vendor.o(groupChange),
|
||
i: common_vendor.o(($event) => radiovalue1.value = $event),
|
||
j: common_vendor.p({
|
||
placement: "row",
|
||
modelValue: radiovalue1.value
|
||
}),
|
||
k: radiovalue1.value === "异常"
|
||
}, radiovalue1.value === "异常" ? common_vendor.e({
|
||
l: !hasHazardData.value
|
||
}, !hasHazardData.value ? {
|
||
m: common_vendor.o(openHazardPopup)
|
||
} : common_vendor.e({
|
||
n: common_vendor.t(hazardFormData.title),
|
||
o: common_vendor.t((_c = levelOptions.value[hazardFormData.level]) == null ? void 0 : _c.title),
|
||
p: hazardFormData.level === 0 ? 1 : "",
|
||
q: hazardFormData.level === 1 ? 1 : "",
|
||
r: hazardFormData.level === 2 ? 1 : "",
|
||
s: common_vendor.t(((_d = sourceOptions.value[hazardFormData.source]) == null ? void 0 : _d.title) || "-"),
|
||
t: common_vendor.t(hazardAddress.value || "-"),
|
||
v: common_vendor.t(hazardFormData.description || "-"),
|
||
w: hazardFileList.value.length > 0
|
||
}, hazardFileList.value.length > 0 ? {
|
||
x: common_vendor.t(hazardFileList.value.length)
|
||
} : {}, {
|
||
y: common_vendor.o(editHazard),
|
||
z: common_vendor.o(clearHazard)
|
||
})) : {}, {
|
||
A: common_vendor.o(($event) => value1.value = $event),
|
||
B: common_vendor.p({
|
||
placeholder: "请输入备注信息",
|
||
modelValue: value1.value
|
||
}),
|
||
C: common_vendor.o(handleSubmit),
|
||
D: common_vendor.o(($event) => showHazardPopup.value = false),
|
||
E: showRestoreBanner.value
|
||
}, showRestoreBanner.value ? {
|
||
F: common_vendor.o(($event) => clearDraft(true))
|
||
} : {}, {
|
||
G: common_vendor.o(afterRead),
|
||
H: common_vendor.o(deletePic),
|
||
I: common_vendor.p({
|
||
fileList: hazardFileList.value,
|
||
name: "1",
|
||
multiple: true,
|
||
imageMode: "aspectFill",
|
||
maxCount: 10
|
||
}),
|
||
J: canvasWidth.value,
|
||
K: canvasHeight.value,
|
||
L: canvasWidth.value + "px",
|
||
M: canvasHeight.value + "px",
|
||
N: !aiAnalyzing.value
|
||
}, !aiAnalyzing.value ? {} : {}, {
|
||
O: common_vendor.t(aiAnalyzing.value ? "AI识别中..." : "AI 识别隐患"),
|
||
P: aiAnalyzing.value,
|
||
Q: aiAnalyzing.value,
|
||
R: common_vendor.o(handleAiAnalyze),
|
||
S: common_vendor.o(($event) => hazardFormData.title = $event),
|
||
T: common_vendor.p({
|
||
placeholder: "请输入内容",
|
||
border: "surround",
|
||
modelValue: hazardFormData.title
|
||
}),
|
||
U: common_vendor.sr(levelChooseRef, "643afff0-6,643afff0-3", {
|
||
"k": "levelChooseRef"
|
||
}),
|
||
V: common_vendor.o(($event) => hazardFormData.level = $event),
|
||
W: common_vendor.p({
|
||
options: levelOptions.value,
|
||
wrap: false,
|
||
["item-width"]: "183rpx",
|
||
["item-height"]: "72rpx",
|
||
modelValue: hazardFormData.level
|
||
}),
|
||
X: common_vendor.o(($event) => hazardFormData.source = $event),
|
||
Y: common_vendor.p({
|
||
options: sourceOptions.value,
|
||
wrap: false,
|
||
["item-width"]: "183rpx",
|
||
["item-height"]: "72rpx",
|
||
modelValue: hazardFormData.source
|
||
}),
|
||
Z: common_vendor.o(($event) => hazardAddress.value = $event),
|
||
aa: common_vendor.p({
|
||
placeholder: "请输入地址",
|
||
border: "surround",
|
||
modelValue: hazardAddress.value
|
||
}),
|
||
ab: common_vendor.o(chooseLocation),
|
||
ac: common_vendor.t(hazardFormData.regulationName || "请选择法律依据"),
|
||
ad: !hazardFormData.regulationName ? 1 : "",
|
||
ae: common_vendor.o(openLawPopup),
|
||
af: common_vendor.t(selectedAreaName.value || "请选择隐患区域"),
|
||
ag: !selectedAreaName.value ? 1 : "",
|
||
ah: common_vendor.o(($event) => showAreaPicker.value = true),
|
||
ai: common_vendor.o(($event) => hazardFormData.description = $event),
|
||
aj: common_vendor.p({
|
||
placeholder: "请输入内容",
|
||
modelValue: hazardFormData.description
|
||
}),
|
||
ak: common_vendor.o(($event) => hazardFormData.tagIndex = $event),
|
||
al: common_vendor.p({
|
||
options: tagOptions.value,
|
||
modelValue: hazardFormData.tagIndex
|
||
}),
|
||
am: common_vendor.o(($event) => showHazardPopup.value = false),
|
||
an: common_vendor.o(confirmHazard),
|
||
ao: common_vendor.o(($event) => showHazardPopup.value = false),
|
||
ap: common_vendor.p({
|
||
show: showHazardPopup.value,
|
||
mode: "center",
|
||
round: "20",
|
||
safeAreaInsetBottom: false
|
||
}),
|
||
aq: common_vendor.o(($event) => showLawPopup.value = false),
|
||
ar: common_vendor.o(searchRegulation),
|
||
as: lawKeyword.value,
|
||
at: common_vendor.o(($event) => lawKeyword.value = $event.detail.value),
|
||
av: common_vendor.o(searchRegulation),
|
||
aw: lawLoading.value && lawList.value.length === 0
|
||
}, lawLoading.value && lawList.value.length === 0 ? {} : !lawLoading.value && lawList.value.length === 0 ? {} : common_vendor.e({
|
||
ay: common_vendor.f(lawList.value, (item, k0, i0) => {
|
||
return {
|
||
a: common_vendor.t(item.depict),
|
||
b: common_vendor.t(item.legalBasis),
|
||
c: selectedLawId.value === item.id ? 1 : "",
|
||
d: item.id,
|
||
e: common_vendor.o(($event) => selectLaw(item), item.id)
|
||
};
|
||
}),
|
||
az: lawLoading.value
|
||
}, lawLoading.value ? {} : {}), {
|
||
ax: !lawLoading.value && lawList.value.length === 0,
|
||
aA: common_vendor.o(loadMoreLaw),
|
||
aB: common_vendor.o(($event) => showLawPopup.value = false),
|
||
aC: common_vendor.o(confirmLaw),
|
||
aD: common_vendor.o(($event) => showLawPopup.value = false),
|
||
aE: common_vendor.p({
|
||
show: showLawPopup.value,
|
||
mode: "center",
|
||
round: "20",
|
||
safeAreaInsetBottom: false
|
||
}),
|
||
aF: common_vendor.o(($event) => showAreaPicker.value = false),
|
||
aG: common_vendor.o(confirmAreaSelect),
|
||
aH: common_vendor.f(areaList.value, (item, k0, i0) => {
|
||
return common_vendor.e({
|
||
a: item.color,
|
||
b: common_vendor.t(item.name),
|
||
c: tempAreaId.value === item.id
|
||
}, tempAreaId.value === item.id ? {} : {}, {
|
||
d: item.id,
|
||
e: tempAreaId.value === item.id ? 1 : "",
|
||
f: common_vendor.o(($event) => tempAreaId.value = item.id, item.id)
|
||
});
|
||
}),
|
||
aI: areaList.value.length === 0
|
||
}, areaList.value.length === 0 ? {} : {}, {
|
||
aJ: common_vendor.o(($event) => showAreaPicker.value = false),
|
||
aK: common_vendor.p({
|
||
show: showAreaPicker.value,
|
||
mode: "bottom",
|
||
round: "20"
|
||
}),
|
||
aL: common_vendor.gei(_ctx, "")
|
||
});
|
||
};
|
||
}
|
||
};
|
||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-643afff0"]]);
|
||
wx.createPage(MiniProgramPage);
|
||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/Inspectionresult/Inspectionresult.js.map
|