这一版本优化了很多

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_three_one_api_area = require("../../request/three_one_api/area.js");
const utils_watermark = require("../../utils/watermark.js");
const request_request = require("../../request/request.js");
if (!Array) {
const _easycom_up_upload2 = common_vendor.resolveComponent("up-upload");
@@ -23,6 +24,8 @@ const _sfc_main = {
__name: "Inspection",
setup(__props) {
const showAddPopup = common_vendor.ref(false);
const canvasWidth = common_vendor.ref(300);
const canvasHeight = common_vendor.ref(300);
const levelChooseRef = common_vendor.ref(null);
const userRole = common_vendor.ref("");
const canAcceptance = common_vendor.computed(() => {
@@ -34,10 +37,10 @@ const _sfc_main = {
if (userInfoStr) {
const userInfo = JSON.parse(userInfoStr);
userRole.value = userInfo.role || "";
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:224", "当前用户角色:", userRole.value);
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:283", "当前用户角色:", userRole.value);
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:227", "获取用户信息失败:", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:286", "获取用户信息失败:", error);
}
};
getUserRole();
@@ -55,7 +58,7 @@ const _sfc_main = {
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:252", "获取任务信息失败:", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:311", "获取任务信息失败:", error);
}
};
common_vendor.onLoad((options) => {
@@ -72,8 +75,12 @@ const _sfc_main = {
// 隐患描述
tagIndex: 0,
// 隐患标签索引
source: ""
source: 0,
// 隐患来源
regulationId: null,
// 法律依据ID
regulationName: ""
// 法律依据名称(显示用)
});
common_vendor.ref(0);
const lng = common_vendor.ref(0);
@@ -84,6 +91,75 @@ const _sfc_main = {
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/hiddendanger/Inspection.vue:394", "获取法规列表失败:", 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) {
formData.regulationId = selectedLawId.value;
formData.regulationName = selectedLawName.value;
}
showLawPopup.value = false;
};
const fetchAreaList = async () => {
try {
const res = await request_three_one_api_area.getAreaList();
@@ -91,7 +167,7 @@ const _sfc_main = {
areaList.value = res.data.records;
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:296", "获取区域列表失败:", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:438", "获取区域列表失败:", error);
}
};
fetchAreaList();
@@ -104,26 +180,26 @@ const _sfc_main = {
showAreaPicker.value = false;
};
const chooseLocation = () => {
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:312", "chooseLocation called");
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:454", "chooseLocation called");
showAddPopup.value = false;
setTimeout(() => {
common_vendor.index.getLocation({
type: "gcj02",
// 使用国测局坐标系(腾讯地图使用)
success: (locationRes) => {
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:321", "获取当前位置成功:", locationRes);
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:463", "获取当前位置成功:", locationRes);
common_vendor.index.chooseLocation({
latitude: locationRes.latitude,
longitude: locationRes.longitude,
success: (res) => {
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:327", "选择位置成功:", res);
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:469", "选择位置成功:", res);
selectedAddress.value = res.address + (res.name ? `(${res.name})` : "");
lng.value = res.longitude;
lat.value = res.latitude;
showAddPopup.value = true;
},
fail: (err) => {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:336", "选择位置失败:", err);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:478", "选择位置失败:", err);
showAddPopup.value = true;
if (err.errMsg && err.errMsg.indexOf("cancel") === -1) {
common_vendor.index.showToast({
@@ -135,17 +211,17 @@ const _sfc_main = {
});
},
fail: (err) => {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:350", "获取当前位置失败:", err);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:492", "获取当前位置失败:", err);
common_vendor.index.chooseLocation({
success: (res) => {
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:354", "选择位置成功:", res);
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:496", "选择位置成功:", res);
selectedAddress.value = res.address + (res.name ? `(${res.name})` : "");
lng.value = res.longitude;
lat.value = res.latitude;
showAddPopup.value = true;
},
fail: (chooseErr) => {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:361", "选择位置失败:", chooseErr);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:503", "选择位置失败:", chooseErr);
showAddPopup.value = true;
if (chooseErr.errMsg && chooseErr.errMsg.indexOf("cancel") === -1) {
common_vendor.index.showToast({
@@ -160,7 +236,7 @@ const _sfc_main = {
}, 300);
};
const handleAdd = async () => {
var _a;
var _a, _b;
if (!formData.title) {
common_vendor.index.showToast({
title: "请输入隐患标题",
@@ -187,12 +263,12 @@ const _sfc_main = {
});
const selectedTag = tagOptions.value[formData.tagIndex];
const tagId = selectedTag ? selectedTag.id : null;
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:408", "innnn", sourceOptions);
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:550", "innnn", sourceOptions);
const params = {
title: formData.title,
//标题
level: formData.level + 1,
// 1.轻微隐患 2.一般隐患 3.重大隐患
level: ((_a = levelOptions.value[formData.level]) == null ? void 0 : _a.id) || 2,
// 2.一般隐患 3.重大隐患
lng: lng.value || 0,
//经度
lat: lat.value || 0,
@@ -209,12 +285,14 @@ const _sfc_main = {
//关联任务ID
checkPointId: checkPointId.value,
//关联检查点ID
source: ((_a = sourceOptions.value[formData.source]) == null ? void 0 : _a.title) || "",
source: ((_b = sourceOptions.value[formData.source]) == null ? void 0 : _b.title) || "",
//隐患来源(随手拍、企业自查、行业互查、专家诊查)
attachments
attachments,
//附件列表(图片/视频)
regulationId: formData.regulationId || null
// 法律依据ID
};
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:426", "提交的参数:", params);
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:569", "提交的参数:", params);
try {
const res = await request_api.addHiddenDanger(params);
if (res.code === 0) {
@@ -231,6 +309,10 @@ const _sfc_main = {
selectedAreaId.value = "";
selectedAreaName.value = "";
fileList1.value = [];
formData.regulationId = null;
formData.regulationName = "";
selectedLawId.value = null;
selectedLawName.value = "";
fetchHiddenDangerList();
} else {
common_vendor.index.showToast({
@@ -239,7 +321,7 @@ const _sfc_main = {
});
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:454", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:602", error);
common_vendor.index.showToast({
title: "请求失败",
icon: "none"
@@ -259,7 +341,7 @@ const _sfc_main = {
});
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:475", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:623", error);
common_vendor.index.showToast({
title: "请求失败",
icon: "none"
@@ -309,7 +391,20 @@ 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/Inspection.vue:697", "加水印失败,将使用原图上传:", 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.path) || "";
fileList1.value.splice(fileListLen, 1, {
@@ -317,7 +412,7 @@ const _sfc_main = {
status: "success",
message: "",
// url: baseUrl + serverPath,
url: request_request.baseUrl.replace("/prod-api", "") + serverPath,
url: request_request.toImageUrl(serverPath),
serverPath
});
fileListLen++;
@@ -341,7 +436,7 @@ const _sfc_main = {
}
},
fail: (err) => {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:571", "上传失败:", err);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:732", "上传失败:", err);
reject(err);
}
});
@@ -359,20 +454,20 @@ const _sfc_main = {
const fullImageUrl = imageFiles[0].url;
aiAnalyzing.value = true;
try {
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:593", "开始调用AI分析接口图片地址:", fullImageUrl);
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:754", "开始调用AI分析接口图片地址:", fullImageUrl);
const analyzeRes = await request_api.analyzeHazardImage({
// imageUrl: 'https://yx.zhihuixiangxi.com:58880/1.png' ,
imageUrl: fullImageUrl
});
if (analyzeRes.code === 0 && analyzeRes.data) {
const aiData = analyzeRes.data;
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:601", "AI分析结果:", aiData);
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:762", "AI分析结果:", aiData);
if (aiData.title)
formData.title = aiData.title;
if (aiData.description)
formData.description = aiData.description;
if (aiData.level) {
const levelMap = { "轻微": 0, "轻微隐患": 0, "一般": 1, "一般隐患": 1, "重大": 2, "重大隐患": 2 };
const levelMap = { "轻微": 0, "轻微隐患": 0, "一般": 0, "一般隐患": 0, "重大": 1, "重大隐患": 1 };
const levelIndex = levelMap[aiData.level];
if (levelIndex !== void 0) {
formData.level = levelIndex;
@@ -388,7 +483,7 @@ const _sfc_main = {
common_vendor.index.showToast({ title: analyzeRes.msg || "AI分析失败", icon: "none" });
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:624", "AI分析接口调用失败:", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:785", "AI分析接口调用失败:", error);
common_vendor.index.showToast({ title: "AI分析失败请重试", icon: "none" });
} finally {
aiAnalyzing.value = false;
@@ -410,7 +505,7 @@ const _sfc_main = {
});
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:647", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:808", error);
common_vendor.index.showToast({
title: "请求失败",
icon: "none"
@@ -419,10 +514,10 @@ const _sfc_main = {
};
fetchTagOptions();
const levelOptions = common_vendor.ref([
{
id: 1,
title: "轻微隐患"
},
// {
// id: 1,
// title: '轻微隐患'
// },
{
id: 2,
title: "一般隐患"
@@ -452,7 +547,7 @@ const _sfc_main = {
]);
common_vendor.watch(() => formData.source, (newVal) => {
const selected = sourceOptions.value[newVal];
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:693", "隐患来源选择结果:", {
common_vendor.index.__f__("log", "at pages/hiddendanger/Inspection.vue:855", "隐患来源选择结果:", {
索引: newVal,
选中项: selected,
id: selected == null ? void 0 : selected.id,
@@ -460,19 +555,20 @@ const _sfc_main = {
});
});
const statusTabs = common_vendor.ref([
{ label: "全部状态", value: "" },
{ label: "待验收", value: "待验收" },
{ label: "待整改", value: "待整改" },
{ label: "待交办", value: "待交办" },
{ label: "验收通过", value: "验收通过" }
{ label: "全部", value: null },
{ label: "待交办", value: 1 },
{ label: "待整改", value: 2 },
{ label: "待验收", value: 3 },
{ label: "待销号", value: 4 },
{ label: "已完成", value: 5 }
]);
const activeTab = common_vendor.ref(0);
const filteredList = common_vendor.computed(() => {
const currentTab = statusTabs.value[activeTab.value];
if (!currentTab || !currentTab.value) {
if (!currentTab || currentTab.value === null) {
return hiddenDangerList.value;
}
return hiddenDangerList.value.filter((item) => item.statusName === currentTab.value);
return hiddenDangerList.value.filter((item) => item.status === currentTab.value);
});
return (_ctx, _cache) => {
return common_vendor.e({
@@ -530,70 +626,106 @@ const _sfc_main = {
fileList: fileList1.value,
name: "1",
multiple: true,
imageMode: "aspectFill",
maxCount: 10
}),
i: !aiAnalyzing.value
i: canvasWidth.value,
j: canvasHeight.value,
k: canvasWidth.value + "px",
l: canvasHeight.value + "px",
m: !aiAnalyzing.value
}, !aiAnalyzing.value ? {} : {}, {
j: common_vendor.t(aiAnalyzing.value ? "AI识别中..." : "AI 识别隐患"),
k: aiAnalyzing.value,
l: aiAnalyzing.value,
m: common_vendor.o(handleAiAnalyze),
n: common_vendor.o(($event) => formData.title = $event),
o: common_vendor.p({
n: common_vendor.t(aiAnalyzing.value ? "AI识别中..." : "AI 识别隐患"),
o: aiAnalyzing.value,
p: aiAnalyzing.value,
q: common_vendor.o(handleAiAnalyze),
r: common_vendor.o(($event) => formData.title = $event),
s: common_vendor.p({
placeholder: "请输入内容",
border: "surround",
modelValue: formData.title
}),
p: common_vendor.sr(levelChooseRef, "b44c631d-3,b44c631d-0", {
t: common_vendor.sr(levelChooseRef, "b44c631d-3,b44c631d-0", {
"k": "levelChooseRef"
}),
q: common_vendor.o(($event) => formData.level = $event),
r: common_vendor.p({
v: common_vendor.o(($event) => formData.level = $event),
w: common_vendor.p({
options: levelOptions.value,
wrap: false,
["item-width"]: "183rpx",
["item-height"]: "72rpx",
modelValue: formData.level
}),
s: common_vendor.o(($event) => formData.source = $event),
t: common_vendor.p({
x: common_vendor.o(($event) => formData.source = $event),
y: common_vendor.p({
options: sourceOptions.value,
wrap: false,
["item-width"]: "183rpx",
["item-height"]: "72rpx",
modelValue: formData.source
}),
v: common_vendor.o(($event) => selectedAddress.value = $event),
w: common_vendor.p({
z: common_vendor.o(($event) => selectedAddress.value = $event),
A: common_vendor.p({
placeholder: "请输入地址",
border: "surround",
modelValue: selectedAddress.value
}),
x: common_vendor.o(chooseLocation),
y: common_vendor.t(selectedAreaName.value || "请选择隐患区域"),
z: !selectedAreaName.value ? 1 : "",
A: common_vendor.o(($event) => showAreaPicker.value = true),
B: common_vendor.o(($event) => formData.description = $event),
C: common_vendor.p({
B: common_vendor.o(chooseLocation),
C: common_vendor.t(formData.regulationName || "请选择法律依据"),
D: !formData.regulationName ? 1 : "",
E: common_vendor.o(openLawPopup),
F: common_vendor.t(selectedAreaName.value || "请选择隐患区域"),
G: !selectedAreaName.value ? 1 : "",
H: common_vendor.o(($event) => showAreaPicker.value = true),
I: common_vendor.o(($event) => formData.description = $event),
J: common_vendor.p({
placeholder: "请输入内容",
modelValue: formData.description
}),
D: common_vendor.o(($event) => formData.tagIndex = $event),
E: common_vendor.p({
K: common_vendor.o(($event) => formData.tagIndex = $event),
L: common_vendor.p({
options: tagOptions.value,
modelValue: formData.tagIndex
}),
F: common_vendor.o(($event) => showAddPopup.value = false),
G: common_vendor.o(handleAdd),
H: common_vendor.o(($event) => showAddPopup.value = false),
I: common_vendor.p({
M: common_vendor.o(($event) => showAddPopup.value = false),
N: common_vendor.o(handleAdd),
O: common_vendor.o(($event) => showAddPopup.value = false),
P: common_vendor.p({
show: showAddPopup.value,
mode: "center",
round: "20"
}),
J: common_vendor.o(($event) => showAreaPicker.value = false),
K: common_vendor.o(confirmAreaSelect),
L: common_vendor.f(areaList.value, (item, k0, i0) => {
Q: common_vendor.o(($event) => showLawPopup.value = false),
R: common_vendor.o(searchRegulation),
S: lawKeyword.value,
T: common_vendor.o(($event) => lawKeyword.value = $event.detail.value),
U: common_vendor.o(searchRegulation),
V: lawLoading.value && lawList.value.length === 0
}, lawLoading.value && lawList.value.length === 0 ? {} : !lawLoading.value && lawList.value.length === 0 ? {} : common_vendor.e({
X: 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)
};
}),
Y: lawLoading.value
}, lawLoading.value ? {} : {}), {
W: !lawLoading.value && lawList.value.length === 0,
Z: common_vendor.o(loadMoreLaw),
aa: common_vendor.o(($event) => showLawPopup.value = false),
ab: common_vendor.o(confirmLaw),
ac: common_vendor.o(($event) => showLawPopup.value = false),
ad: common_vendor.p({
show: showLawPopup.value,
mode: "center",
round: "20"
}),
ae: common_vendor.o(($event) => showAreaPicker.value = false),
af: common_vendor.o(confirmAreaSelect),
ag: common_vendor.f(areaList.value, (item, k0, i0) => {
return common_vendor.e({
a: item.color,
b: common_vendor.t(item.name),
@@ -604,15 +736,15 @@ const _sfc_main = {
f: common_vendor.o(($event) => tempAreaId.value = item.id, item.id)
});
}),
M: areaList.value.length === 0
ah: areaList.value.length === 0
}, areaList.value.length === 0 ? {} : {}, {
N: common_vendor.o(($event) => showAreaPicker.value = false),
O: common_vendor.p({
ai: common_vendor.o(($event) => showAreaPicker.value = false),
aj: common_vendor.p({
show: showAreaPicker.value,
mode: "bottom",
round: "20"
}),
P: common_vendor.gei(_ctx, "")
ak: common_vendor.gei(_ctx, "")
});
};
}