Files
threeonecheck_web/unpackage/dist/dev/mp-weixin/pages/hiddendanger/Inspection.js
2026-06-30 09:47:10 +08:00

193 lines
7.4 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const request_api = require("../../request/api.js");
const _sfc_main = {
__name: "Inspection",
setup(__props) {
const taskId = common_vendor.ref("");
const checkPointId = common_vendor.ref("");
const oneTableId = common_vendor.ref("");
const userRole = common_vendor.ref("");
const canAcceptance = common_vendor.computed(() => {
return userRole.value === "admin" || userRole.value === "manage";
});
const getUserRole = () => {
try {
const userInfoStr = common_vendor.index.getStorageSync("userInfo");
if (userInfoStr) {
const userInfo = JSON.parse(userInfoStr);
userRole.value = userInfo.role || "";
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:86", "获取用户信息失败:", error);
}
};
getUserRole();
const fetchTaskInfo = async (oneTableId2) => {
try {
const startRes = await request_api.enterCheckPlan(oneTableId2);
if (startRes.code === 0 && startRes.data) {
const tid = startRes.data.taskId;
const detailRes = await request_api.getCheckTaskDetail(tid);
if (detailRes.code === 0 && detailRes.data) {
taskId.value = detailRes.data.taskId;
checkPointId.value = detailRes.data.checkPointId;
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:103", "获取任务信息失败:", error);
}
};
common_vendor.onLoad((options) => {
if (options.id) {
oneTableId.value = options.id;
fetchTaskInfo(options.id);
}
});
const hiddenDangerList = common_vendor.ref([]);
const fetchHiddenDangerList = async () => {
try {
const res = await request_api.getMyHiddenDangerList();
if (res.code === 0) {
hiddenDangerList.value = res.data.records;
} else {
common_vendor.index.showToast({
title: res.msg || "获取隐患列表失败",
icon: "none"
});
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:127", error);
common_vendor.index.showToast({
title: "请求失败",
icon: "none"
});
}
};
common_vendor.onShow(() => {
fetchHiddenDangerList();
});
const goToAdd = () => {
let url = "/pages/hiddendanger/add";
const params = [];
if (oneTableId.value) {
params.push(`id=${oneTableId.value}`);
}
if (taskId.value) {
params.push(`taskId=${taskId.value}`);
}
if (checkPointId.value) {
params.push(`checkPointId=${checkPointId.value}`);
}
if (params.length) {
url += `?${params.join("&")}`;
}
common_vendor.index.navigateTo({ url });
};
const details = (item) => {
common_vendor.index.navigateTo({
url: `/pages/hiddendanger/detail2?hazardId=${item.hazardId}&assignId=${item.assignId || ""}`
});
};
const Rectification = (item) => {
let url = `/pages/hiddendanger/rectification?hazardId=${item.hazardId}&assignId=${item.assignId}`;
if (item.deadline) {
url += `&deadline=${encodeURIComponent(item.deadline)}`;
}
if (item.assigneeId) {
url += `&assigneeId=${item.assigneeId}`;
}
if (item.assigneeName) {
url += `&assigneeName=${encodeURIComponent(item.assigneeName)}`;
}
common_vendor.index.navigateTo({ url });
};
const editRectification = (item) => {
common_vendor.index.navigateTo({
url: `/pages/hiddendanger/rectification?rectifyId=${item.rectifyId}&isEdit=1`
});
};
const acceptance = (item) => {
common_vendor.index.navigateTo({
url: `/pages/hiddendanger/acceptance?hazardId=${item.hazardId}&assignId=${item.assignId}&rectifyId=${item.rectifyId}`
});
};
const assignHazard = (item) => {
common_vendor.index.navigateTo({
url: `/pages/hiddendanger/assignment?hazardId=${item.hazardId}&assignId=${item.assignId}`
});
};
const statusTabs = common_vendor.ref([
{ 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 === null) {
return hiddenDangerList.value;
}
return hiddenDangerList.value.filter((item) => item.status === currentTab.value);
});
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.f(statusTabs.value, (tab, index, i0) => {
return common_vendor.e({
a: common_vendor.t(tab.label),
b: activeTab.value === index
}, activeTab.value === index ? {} : {}, {
c: index,
d: activeTab.value === index ? 1 : "",
e: common_vendor.o(($event) => activeTab.value = index, index)
});
}),
b: filteredList.value.length === 0
}, filteredList.value.length === 0 ? {} : {}, {
c: common_vendor.f(filteredList.value, (item, k0, i0) => {
return common_vendor.e({
a: common_vendor.t(item.title),
b: common_vendor.t(item.statusName),
c: common_vendor.t(item.levelName),
d: item.levelName === "轻微隐患" ? 1 : "",
e: item.levelName === "一般隐患" ? 1 : "",
f: item.levelName === "重大隐患" ? 1 : "",
g: common_vendor.t(item.address),
h: common_vendor.t(item.createdAt),
i: common_vendor.o(($event) => details(item), item.hazardId),
j: item.statusName === "待整改" && item.canEdit
}, item.statusName === "待整改" && item.canEdit ? {
k: common_vendor.o(($event) => assignHazard(item), item.hazardId)
} : {}, {
l: item.statusName === "待整改" && item.canEdit
}, item.statusName === "待整改" && item.canEdit ? {
m: common_vendor.o(($event) => Rectification(item), item.hazardId)
} : {}, {
n: item.statusName === "待验收" && item.canEdit
}, item.statusName === "待验收" && item.canEdit ? {
o: common_vendor.o(($event) => editRectification(item), item.hazardId)
} : {}, {
p: item.statusName === "待验收" && canAcceptance.value
}, item.statusName === "待验收" && canAcceptance.value ? {
q: common_vendor.o(($event) => acceptance(item), item.hazardId)
} : {}, {
r: item.statusName === "待交办"
}, item.statusName === "待交办" ? {
s: common_vendor.o(($event) => assignHazard(item), item.hazardId)
} : {}, {
t: item.hazardId
});
}),
d: common_vendor.o(goToAdd),
e: common_vendor.gei(_ctx, "")
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-b44c631d"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/hiddendanger/Inspection.js.map