"use strict"; const common_vendor = require("../../common/vendor.js"); const request_api = require("../../request/api.js"); const utils_hazardNav = require("../../utils/hazardNav.js"); const utils_userInfo = require("../../utils/userInfo.js"); if (!Array) { const _easycom_u_loadmore2 = common_vendor.resolveComponent("u-loadmore"); _easycom_u_loadmore2(); } const _easycom_u_loadmore = () => "../../uni_modules/uview-plus/components/u-loadmore/u-loadmore.js"; if (!Math) { _easycom_u_loadmore(); } const HAZARD_PAGE_SIZE = 10; 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 isApprovalRole = common_vendor.computed(() => userRole.value === "approval"); const getUserRole = () => { try { const userInfoStr = common_vendor.index.getStorageSync("userInfo"); if (userInfoStr) { userRole.value = utils_userInfo.resolveUserIdentityRoleKey(JSON.parse(userInfoStr)); } } catch (error) { common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:107", "获取用户信息失败:", error); } }; 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:123", "获取任务信息失败:", error); } }; common_vendor.onLoad((options) => { getUserRole(); if (options.id) { oneTableId.value = options.id; fetchTaskInfo(options.id); } }); const hiddenDangerList = common_vendor.ref([]); const pageNum = common_vendor.ref(1); const listLoading = common_vendor.ref(false); const loadStatus = common_vendor.ref("loadmore"); 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 buildListParams = () => { const params = { pageNum: pageNum.value, pageSize: HAZARD_PAGE_SIZE }; const currentTab = statusTabs.value[activeTab.value]; if ((currentTab == null ? void 0 : currentTab.value) != null) { params.status = currentTab.value; } return params; }; const resetHiddenDangerList = () => { pageNum.value = 1; hiddenDangerList.value = []; loadStatus.value = "loadmore"; }; const switchStatusTab = (index) => { if (activeTab.value === index) return; activeTab.value = index; resetHiddenDangerList(); fetchHiddenDangerList(); }; const fetchHiddenDangerList = async () => { var _a, _b; if (listLoading.value) return; if (pageNum.value > 1 && loadStatus.value === "nomore") return; listLoading.value = true; if (pageNum.value > 1) { loadStatus.value = "loading"; } try { const res = await request_api.getMyHiddenDangerList(buildListParams()); if (res.code === 0) { const records = ((_a = res.data) == null ? void 0 : _a.records) || []; const total = Number(((_b = res.data) == null ? void 0 : _b.total) ?? 0); if (pageNum.value === 1) { hiddenDangerList.value = records; } else { hiddenDangerList.value = [...hiddenDangerList.value, ...records]; } if (hiddenDangerList.value.length >= total || records.length < HAZARD_PAGE_SIZE) { loadStatus.value = "nomore"; } else { loadStatus.value = "loadmore"; } } else { if (pageNum.value === 1) { hiddenDangerList.value = []; } loadStatus.value = "nomore"; common_vendor.index.showToast({ title: res.msg || "获取隐患列表失败", icon: "none" }); } } catch (error) { common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:210", error); if (pageNum.value > 1) { pageNum.value--; } loadStatus.value = "loadmore"; common_vendor.index.showToast({ title: "请求失败", icon: "none" }); } finally { listLoading.value = false; } }; const loadMoreHiddenDangerList = () => { if (loadStatus.value !== "loadmore" || listLoading.value) return; pageNum.value++; fetchHiddenDangerList(); }; common_vendor.onShow(() => { getUserRole(); resetHiddenDangerList(); fetchHiddenDangerList(); }); common_vendor.onReachBottom(() => { loadMoreHiddenDangerList(); }); 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/process-chain?hazardId=${item.hazardId}` }); }; const Rectification = (item) => { common_vendor.index.navigateTo({ url: utils_hazardNav.buildRectificationUrl(item) }); }; const editRectification = (item) => { common_vendor.index.navigateTo({ url: utils_hazardNav.buildEditRectificationUrl(item) }); }; const acceptance = (item) => { common_vendor.index.navigateTo({ url: utils_hazardNav.buildAcceptanceUrl(item) }); }; const assignHazard = (item) => { common_vendor.index.navigateTo({ url: utils_hazardNav.buildAssignmentUrl(item) }); }; const goWriteoffApply = (item) => { common_vendor.index.navigateTo({ url: utils_hazardNav.buildWriteoffApplyUrl(item) }); }; const goWriteoffApproval = (item) => { common_vendor.index.navigateTo({ url: utils_hazardNav.buildWriteoffApprovalUrl(item) }); }; 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) => switchStatusTab(index), index) }); }), b: hiddenDangerList.value.length === 0 && !listLoading.value }, hiddenDangerList.value.length === 0 && !listLoading.value ? {} : {}, { c: common_vendor.f(hiddenDangerList.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) }, !isApprovalRole.value ? common_vendor.e({ 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: common_vendor.unref(utils_hazardNav.canShowAcceptanceButton)(item, userRole.value) }, common_vendor.unref(utils_hazardNav.canShowAcceptanceButton)(item, userRole.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: common_vendor.unref(utils_hazardNav.canShowWriteoffApplyButton)(item) }, common_vendor.unref(utils_hazardNav.canShowWriteoffApplyButton)(item) ? { v: common_vendor.o(($event) => goWriteoffApply(item), item.hazardId) } : {}, { w: common_vendor.unref(utils_hazardNav.canShowWriteoffApprovalButton)(item, userRole.value) }, common_vendor.unref(utils_hazardNav.canShowWriteoffApprovalButton)(item, userRole.value) ? { x: common_vendor.o(($event) => goWriteoffApproval(item), item.hazardId) } : {}) : {}, { y: item.hazardId }); }), d: !isApprovalRole.value, e: hiddenDangerList.value.length > 0 }, hiddenDangerList.value.length > 0 ? { f: common_vendor.p({ status: loadStatus.value }) } : {}, { g: !isApprovalRole.value }, !isApprovalRole.value ? { h: common_vendor.o(goToAdd) } : {}, { i: 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