198 lines
7.6 KiB
JavaScript
198 lines
7.6 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const request_api = require("../../request/api.js");
|
|
if (!Math) {
|
|
HazardFormPopup();
|
|
}
|
|
const HazardFormPopup = () => "../../components/hazard/HazardFormPopup.js";
|
|
const _sfc_main = {
|
|
__name: "Inspection",
|
|
setup(__props) {
|
|
const showAddPopup = common_vendor.ref(false);
|
|
const taskId = common_vendor.ref("");
|
|
const checkPointId = common_vendor.ref("");
|
|
const hazardExtraParams = common_vendor.computed(() => ({
|
|
taskId: taskId.value,
|
|
checkPointId: checkPointId.value
|
|
}));
|
|
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:100", "获取用户信息失败:", error);
|
|
}
|
|
};
|
|
getUserRole();
|
|
const fetchTaskInfo = async (oneTableId) => {
|
|
try {
|
|
const startRes = await request_api.enterCheckPlan(oneTableId);
|
|
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:117", "获取任务信息失败:", error);
|
|
}
|
|
};
|
|
common_vendor.onLoad((options) => {
|
|
if (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:140", error);
|
|
common_vendor.index.showToast({
|
|
title: "请求失败",
|
|
icon: "none"
|
|
});
|
|
}
|
|
};
|
|
common_vendor.onShow(() => {
|
|
fetchHiddenDangerList();
|
|
});
|
|
const openAddPopup = () => {
|
|
showAddPopup.value = true;
|
|
};
|
|
const onHazardAddSuccess = () => {
|
|
showAddPopup.value = false;
|
|
fetchHiddenDangerList();
|
|
};
|
|
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(openAddPopup),
|
|
e: common_vendor.o(onHazardAddSuccess),
|
|
f: common_vendor.o(($event) => showAddPopup.value = $event),
|
|
g: common_vendor.p({
|
|
title: "新增隐患排查",
|
|
mode: "direct",
|
|
["extra-params"]: hazardExtraParams.value,
|
|
show: showAddPopup.value
|
|
}),
|
|
h: 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
|