隐患详情重新设计,检查计划重新设计成做题排查式
This commit is contained in:
@@ -1,177 +1,111 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const request_api = require("../../request/api.js");
|
||||
require("../../request/request.js");
|
||||
const utils_upload = require("../../utils/upload.js");
|
||||
const request_three_one_api_area = require("../../request/three_one_api/area.js");
|
||||
const utils_draftCache = require("../../utils/draftCache.js");
|
||||
const utils_useDraftCache = require("../../utils/useDraftCache.js");
|
||||
const components_hazard_hazardForm = require("../../components/hazard/hazardForm.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_choose2 = common_vendor.resolveComponent("up-choose");
|
||||
const _easycom_up_upload2 = common_vendor.resolveComponent("up-upload");
|
||||
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
|
||||
const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
|
||||
(_easycom_u_radio2 + _easycom_u_radio_group2 + _easycom_up_textarea2 + _easycom_up_choose2 + _easycom_up_upload2 + _easycom_up_input2 + _easycom_u_popup2)();
|
||||
(_easycom_u_radio2 + _easycom_u_radio_group2 + _easycom_up_textarea2)();
|
||||
}
|
||||
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_choose = () => "../../uni_modules/uview-plus/components/u-choose/u-choose.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_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_choose + _easycom_up_upload + _easycom_up_input + _easycom_u_popup)();
|
||||
(_easycom_u_radio + _easycom_u_radio_group + _easycom_up_textarea + HazardFormPopup)();
|
||||
}
|
||||
const HazardFormPopup = () => "../../components/hazard/HazardFormPopup.js";
|
||||
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 hazardFormRef = common_vendor.ref(null);
|
||||
const showHazardPopup = common_vendor.ref(false);
|
||||
const hazardPayload = common_vendor.ref(components_hazard_hazardForm.createEmptyHazardPayload());
|
||||
const radiolist1 = common_vendor.reactive([
|
||||
{
|
||||
name: "正常",
|
||||
value: 1,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
name: "异常",
|
||||
value: 2,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
name: "不涉及",
|
||||
value: 3,
|
||||
disabled: false
|
||||
}
|
||||
{ name: "正常", value: 1, disabled: false },
|
||||
{ name: "异常", value: 2, disabled: false },
|
||||
{ name: "不涉及", value: 3, disabled: false }
|
||||
]);
|
||||
const radiovalue1 = common_vendor.ref("");
|
||||
const value1 = common_vendor.ref("");
|
||||
const normalizeInspectionDraft = (data) => {
|
||||
if (!data)
|
||||
return { radiovalue1: "", value1: "", hazardPayload: components_hazard_hazardForm.createEmptyHazardPayload() };
|
||||
if (!data.hazardPayload && data.hazardFormData) {
|
||||
data.hazardPayload = {
|
||||
formData: data.hazardFormData,
|
||||
address: data.hazardAddress || "",
|
||||
lng: data.hazardLng || 0,
|
||||
lat: data.hazardLat || 0,
|
||||
areaId: "",
|
||||
areaName: "",
|
||||
fileList: data.hazardFileList || []
|
||||
};
|
||||
}
|
||||
return {
|
||||
radiovalue1: data.radiovalue1 || "",
|
||||
value1: data.value1 || "",
|
||||
hazardPayload: data.hazardPayload || components_hazard_hazardForm.createEmptyHazardPayload()
|
||||
};
|
||||
};
|
||||
const inspectionDraftHasContent = (data) => {
|
||||
var _a, _b;
|
||||
const normalized = normalizeInspectionDraft(data);
|
||||
const payload = normalized.hazardPayload;
|
||||
return !!(normalized.radiovalue1 || normalized.value1 || ((_a = payload.formData) == null ? void 0 : _a.title) || ((_b = payload.formData) == null ? void 0 : _b.description) || payload.fileList && payload.fileList.length > 0);
|
||||
};
|
||||
const {
|
||||
showRestoreBanner,
|
||||
clear: clearDraft,
|
||||
restore: restoreDraft,
|
||||
bindAutoSave
|
||||
} = utils_useDraftCache.useDraftCache({
|
||||
getKey: () => {
|
||||
var _a;
|
||||
return utils_draftCache.buildDraftKey(
|
||||
utils_draftCache.DRAFT_NS.INSPECTION_RESULT,
|
||||
oneTableId.value,
|
||||
(_a = checkData.value) == null ? void 0 : _a.currentIndex
|
||||
);
|
||||
},
|
||||
getPayload: () => ({
|
||||
radiovalue1: radiovalue1.value,
|
||||
value1: value1.value,
|
||||
hazardPayload: JSON.parse(JSON.stringify(hazardPayload.value))
|
||||
}),
|
||||
hasContent: inspectionDraftHasContent,
|
||||
applyPayload: (data) => {
|
||||
const normalized = normalizeInspectionDraft(data);
|
||||
radiovalue1.value = normalized.radiovalue1;
|
||||
value1.value = normalized.value1;
|
||||
hazardPayload.value = normalized.hazardPayload;
|
||||
common_vendor.nextTick$1(() => {
|
||||
var _a;
|
||||
(_a = hazardFormRef.value) == null ? void 0 : _a.applyPayload(normalized.hazardPayload);
|
||||
});
|
||||
},
|
||||
clearForm: () => {
|
||||
radiovalue1.value = "";
|
||||
value1.value = "";
|
||||
clearHazard();
|
||||
},
|
||||
canSave: () => !!oneTableId.value,
|
||||
requireInitialized: true
|
||||
});
|
||||
bindAutoSave(() => [radiovalue1.value, value1.value, hazardPayload.value]);
|
||||
const groupChange = (n) => {
|
||||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:312", "groupChange", n);
|
||||
if (n !== "异常") {
|
||||
clearHazard();
|
||||
}
|
||||
};
|
||||
const radioChange = (n) => {
|
||||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:320", "radioChange", n);
|
||||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:207", "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:399", "获取法规列表失败:", 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:443", "获取区域列表失败:", 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 hasHazardData = common_vendor.computed(() => components_hazard_hazardForm.hasValidHazardPayload(hazardPayload.value));
|
||||
const progressPercent = common_vendor.computed(() => {
|
||||
if (!checkData.value)
|
||||
return 0;
|
||||
@@ -179,149 +113,24 @@ const _sfc_main = {
|
||||
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:508", "获取标签列表失败:", error);
|
||||
}
|
||||
};
|
||||
const openHazardPopup = () => {
|
||||
showHazardPopup.value = true;
|
||||
};
|
||||
const editHazard = () => {
|
||||
showHazardPopup.value = true;
|
||||
};
|
||||
const onHazardConfirm = (payload) => {
|
||||
if (payload) {
|
||||
hazardPayload.value = JSON.parse(JSON.stringify(payload));
|
||||
}
|
||||
};
|
||||
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 inspectionUploadInstance = common_vendor.getCurrentInstance();
|
||||
const { afterRead, deletePic } = utils_upload.createUploadListHandlers(hazardFileList, {
|
||||
watermark: {
|
||||
canvasId: "watermarkCanvas",
|
||||
canvasWidthRef: canvasWidth,
|
||||
canvasHeightRef: canvasHeight,
|
||||
instance: inspectionUploadInstance
|
||||
}
|
||||
});
|
||||
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:612", "开始调用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:619", "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:642", "AI分析接口调用失败:", error);
|
||||
common_vendor.index.showToast({ title: "AI分析失败,请重试", icon: "none" });
|
||||
} finally {
|
||||
aiAnalyzing.value = false;
|
||||
}
|
||||
var _a;
|
||||
hazardPayload.value = components_hazard_hazardForm.createEmptyHazardPayload();
|
||||
(_a = hazardFormRef.value) == null ? void 0 : _a.resetForm();
|
||||
};
|
||||
const handleSubmit = async () => {
|
||||
var _a, _b, _c, _d, _e;
|
||||
var _a, _b, _c, _d;
|
||||
if (!radiovalue1.value) {
|
||||
common_vendor.index.showToast({ title: "请选择检查结果", icon: "none" });
|
||||
return;
|
||||
@@ -339,40 +148,23 @@ const _sfc_main = {
|
||||
try {
|
||||
common_vendor.index.showLoading({ title: "提交中..." });
|
||||
if (radiovalue1.value === "异常" && hasHazardData.value) {
|
||||
const attachments = hazardFileList.value.filter((f) => f.status === "success").map((file) => utils_upload.buildAttachmentItem(file));
|
||||
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: ((_c = levelOptions.value[hazardFormData.level]) == null ? void 0 : _c.id) || 2,
|
||||
lng: hazardLng.value || 0,
|
||||
lat: hazardLat.value || 0,
|
||||
address: hazardAddress.value || "",
|
||||
areaId: selectedAreaId.value || null,
|
||||
// 隐患区域ID
|
||||
description: hazardFormData.description || "",
|
||||
source: ((_d = sourceOptions.value[hazardFormData.source]) == null ? void 0 : _d.title) || "",
|
||||
tagId,
|
||||
attachments,
|
||||
regulationId: hazardFormData.regulationId || null
|
||||
};
|
||||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:705", "隐患参数:", hazardParams);
|
||||
const payload = ((_a = hazardFormRef.value) == null ? void 0 : _a.getPayload()) || hazardPayload.value;
|
||||
const hazardParams = components_hazard_hazardForm.buildHiddenDangerParams(payload, {
|
||||
taskId: (_b = checkData.value) == null ? void 0 : _b.taskId,
|
||||
checkPointId: (_c = checkData.value) == null ? void 0 : _c.checkPointId
|
||||
});
|
||||
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:714", "新增隐患成功");
|
||||
}
|
||||
const submitParams = {
|
||||
taskId: (_e = checkData.value) == null ? void 0 : _e.taskId,
|
||||
taskId: (_d = checkData.value) == null ? void 0 : _d.taskId,
|
||||
result: resultValue,
|
||||
remark: value1.value
|
||||
};
|
||||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:723", "提交参数:", submitParams);
|
||||
const res = await request_api.submitCheckResult(submitParams);
|
||||
common_vendor.index.hideLoading();
|
||||
if (res.code === 0) {
|
||||
@@ -397,7 +189,7 @@ const _sfc_main = {
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:758", "提交失败:", error);
|
||||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:306", "提交失败:", error);
|
||||
common_vendor.index.showToast({ title: "提交失败", icon: "none" });
|
||||
}
|
||||
};
|
||||
@@ -409,164 +201,19 @@ const _sfc_main = {
|
||||
const getCheckData = async () => {
|
||||
try {
|
||||
const res = await request_api.enterCheckPlan(oneTableId.value);
|
||||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:777", "检查项数据:", res);
|
||||
if (res.code === 0) {
|
||||
checkData.value = res.data;
|
||||
restoreDraft();
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:784", error);
|
||||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:325", 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:799", "【草稿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:809", "【草稿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:819", "【草稿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:840", "【草稿Debug - 巡检】成功保存草稿到 LocalStorage, Key:", key);
|
||||
hasDraft.value = true;
|
||||
};
|
||||
const clearDraft = (showToast = true) => {
|
||||
const key = getDraftKey();
|
||||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:847", "【草稿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:877", "【草稿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:887", "【草稿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:914", "【草稿Debug - 巡检】UI与多选组件状态同步重绘完毕!");
|
||||
});
|
||||
common_vendor.index.showToast({
|
||||
title: "已自动恢复您上次未提交的内容",
|
||||
icon: "none",
|
||||
duration: 2500
|
||||
});
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages/Inspectionresult/Inspectionresult.vue:923", "【草稿Debug - 巡检】解析草稿异常:", e);
|
||||
isRestoring.value = false;
|
||||
isInitialized.value = true;
|
||||
}
|
||||
} else {
|
||||
common_vendor.index.__f__("log", "at pages/Inspectionresult/Inspectionresult.vue:928", "【草稿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:955", "接收到的参数:", options);
|
||||
if (options.id) {
|
||||
oneTableId.value = options.id;
|
||||
getCheckData();
|
||||
}
|
||||
fetchTagOptions();
|
||||
fetchAreaList();
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
var _a, _b, _c, _d;
|
||||
@@ -605,17 +252,17 @@ const _sfc_main = {
|
||||
}, !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)
|
||||
n: common_vendor.t(hazardPayload.value.formData.title),
|
||||
o: common_vendor.t((_c = common_vendor.unref(components_hazard_hazardForm.LEVEL_OPTIONS)[hazardPayload.value.formData.level]) == null ? void 0 : _c.title),
|
||||
p: hazardPayload.value.formData.level === 0 ? 1 : "",
|
||||
q: hazardPayload.value.formData.level === 1 ? 1 : "",
|
||||
r: hazardPayload.value.formData.level === 2 ? 1 : "",
|
||||
s: common_vendor.t(((_d = common_vendor.unref(components_hazard_hazardForm.SOURCE_OPTIONS)[hazardPayload.value.formData.source]) == null ? void 0 : _d.title) || "-"),
|
||||
t: common_vendor.t(hazardPayload.value.address || "-"),
|
||||
v: common_vendor.t(hazardPayload.value.formData.description || "-"),
|
||||
w: hazardPayload.value.fileList.length > 0
|
||||
}, hazardPayload.value.fileList.length > 0 ? {
|
||||
x: common_vendor.t(hazardPayload.value.fileList.length)
|
||||
} : {}, {
|
||||
y: common_vendor.o(editHazard),
|
||||
z: common_vendor.o(clearHazard)
|
||||
@@ -626,138 +273,22 @@ const _sfc_main = {
|
||||
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(($event) => hazardFormData.source = $event),
|
||||
H: common_vendor.p({
|
||||
options: sourceOptions.value,
|
||||
wrap: false,
|
||||
["item-width"]: "152rpx",
|
||||
["item-height"]: "64rpx",
|
||||
modelValue: hazardFormData.source
|
||||
D: common_vendor.sr(hazardFormRef, "643afff0-3", {
|
||||
"k": "hazardFormRef"
|
||||
}),
|
||||
I: common_vendor.o(common_vendor.unref(afterRead)),
|
||||
J: common_vendor.o(common_vendor.unref(deletePic)),
|
||||
K: common_vendor.p({
|
||||
fileList: hazardFileList.value,
|
||||
name: "1",
|
||||
multiple: true,
|
||||
imageMode: "aspectFill",
|
||||
maxCount: 10
|
||||
}),
|
||||
L: canvasWidth.value,
|
||||
M: canvasHeight.value,
|
||||
N: canvasWidth.value + "px",
|
||||
O: canvasHeight.value + "px",
|
||||
P: !aiAnalyzing.value
|
||||
}, !aiAnalyzing.value ? {} : {}, {
|
||||
Q: common_vendor.t(aiAnalyzing.value ? "AI识别中..." : "AI 识别隐患"),
|
||||
R: aiAnalyzing.value,
|
||||
S: aiAnalyzing.value,
|
||||
T: common_vendor.o(handleAiAnalyze),
|
||||
U: common_vendor.o(($event) => hazardFormData.title = $event),
|
||||
V: common_vendor.p({
|
||||
placeholder: "请输入内容",
|
||||
border: "surround",
|
||||
modelValue: hazardFormData.title
|
||||
}),
|
||||
W: common_vendor.sr(levelChooseRef, "643afff0-7,643afff0-3", {
|
||||
"k": "levelChooseRef"
|
||||
}),
|
||||
X: common_vendor.o(($event) => hazardFormData.level = $event),
|
||||
Y: common_vendor.p({
|
||||
options: levelOptions.value,
|
||||
wrap: false,
|
||||
["item-width"]: "183rpx",
|
||||
["item-height"]: "72rpx",
|
||||
modelValue: hazardFormData.level
|
||||
}),
|
||||
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({
|
||||
E: common_vendor.o(onHazardConfirm),
|
||||
F: common_vendor.o(($event) => common_vendor.unref(clearDraft)(true)),
|
||||
G: common_vendor.o(($event) => showHazardPopup.value = $event),
|
||||
H: common_vendor.o(($event) => hazardPayload.value = $event),
|
||||
I: common_vendor.p({
|
||||
title: "填写隐患信息",
|
||||
mode: "collect",
|
||||
["body-height"]: "60vh",
|
||||
["show-draft-banner"]: common_vendor.unref(showRestoreBanner),
|
||||
show: showHazardPopup.value,
|
||||
mode: "center",
|
||||
round: "20",
|
||||
safeAreaInsetBottom: false
|
||||
modelValue: hazardPayload.value
|
||||
}),
|
||||
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, "")
|
||||
J: common_vendor.gei(_ctx, "")
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user