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

443 lines
17 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const request_api = require("../../request/api.js");
const request_three_one_api_info = require("../../request/three_one_api/info.js");
const request_request = require("../../request/request.js");
if (!Array) {
const _easycom_u_navbar2 = common_vendor.resolveComponent("u-navbar");
const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
(_easycom_u_navbar2 + _easycom_u_icon2)();
}
const _easycom_u_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
const _easycom_u_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
if (!Math) {
(_easycom_u_navbar + _easycom_u_icon)();
}
const defaultAvatar = "/static/my/default_avater.png";
const PLAN_INITIAL_SIZE = 4;
const _sfc_main = {
__name: "index",
setup(__props) {
const loading = common_vendor.ref(true);
const userInfo = common_vendor.reactive({
userId: "",
username: "",
nickName: "",
deptId: "",
deptName: "",
role: "",
avatar: "",
phone: ""
});
const canAcceptance = common_vendor.computed(() => {
return userInfo.role === "admin" || userInfo.role === "manage";
});
const getImageUrl = (path) => {
if (!path)
return "";
return request_request.toImageUrl(path);
};
const getUserInfo = async () => {
try {
const res = await request_three_one_api_info.getProfileDetail();
if (res.code === 0 && res.data) {
userInfo.userId = res.data.userId || "";
userInfo.username = res.data.userName || "";
userInfo.nickName = res.data.nickName || "";
userInfo.deptId = res.data.deptId || "";
userInfo.deptName = res.data.deptName || "";
userInfo.avatar = res.data.avatar || "";
userInfo.phone = res.data.phonenumber || res.data.phone || "";
if (res.data.roles && res.data.roles.length > 0) {
userInfo.role = res.data.roles[0].roleKey || "";
}
}
} catch (e) {
common_vendor.index.__f__("error", "at pages/index/index.vue:249", "获取用户信息失败:", e);
try {
const storedUserInfo = common_vendor.index.getStorageSync("userInfo");
if (storedUserInfo) {
const info = JSON.parse(storedUserInfo);
userInfo.userId = info.userId || "";
userInfo.username = info.username || "";
userInfo.nickName = info.nickName || "";
userInfo.deptId = info.deptId || "";
userInfo.deptName = info.deptName || "";
userInfo.role = info.role || "";
userInfo.avatar = info.avatar || "";
userInfo.phone = info.phone || "";
}
} catch (storageError) {
common_vendor.index.__f__("error", "at pages/index/index.vue:265", "从本地存储获取用户信息失败:", storageError);
}
}
};
const allMenuList = [
{
name: "成员管理",
src: "/static/home_icon/chengyuangaunli.png"
},
{
name: "信息填报",
src: "/static/home_icon/xinxitianbao.png"
},
{
name: "区域设置",
src: "/static/home_icon/quyushezhi.png"
},
{
name: "检查清单",
src: "/static/home_icon/jiachaqingdan.png"
},
// {
// name: '检查记录',
// src: '/static/home_icon/jianchajilu.png'
// },
{
name: "证件管理",
src: "/static/home_icon/zhengjianguanli.png"
},
{
name: "隐患排查",
src: "/static/home_icon/yinhuanpaicha.png"
},
{
name: "隐患销号",
src: "/static/home_icon/yinhuanxiaohao.png"
}
];
const commonMenuNames = ["隐患排查", "隐患销号"];
const infoList = common_vendor.computed(() => {
if (userInfo.role === "common") {
return allMenuList.filter((item) => commonMenuNames.includes(item.name));
}
return allMenuList;
});
const formatProgress = (progress) => {
const num = Number(progress);
if (Number.isNaN(num))
return 0;
return Math.min(100, Math.max(0, num));
};
const getTodayDateStr = () => {
const date = /* @__PURE__ */ new Date();
const y = date.getFullYear();
const m = String(date.getMonth() + 1).padStart(2, "0");
const d = String(date.getDate()).padStart(2, "0");
return `${y}-${m}-${d}`;
};
const goTodayInspect = (item) => {
const oneTableId = item.id;
const taskDate = getTodayDateStr();
const tableId = item.tableId ?? item.id;
if (!oneTableId || !taskDate) {
common_vendor.index.showToast({ title: "缺少任务参数", icon: "none" });
return;
}
const name = item.name || "";
const tableIdQuery = tableId ? `&tableId=${tableId}` : "";
common_vendor.index.navigateTo({
url: `/pages/Inspectionresult/detail?oneTableId=${oneTableId}&taskDate=${encodeURIComponent(taskDate)}&name=${encodeURIComponent(name)}${tableIdQuery}`
});
};
const goPlanCheckList = (item) => {
const tableId = item.tableId ?? item.id;
if (!tableId) {
common_vendor.index.showToast({ title: "缺少检查表ID", icon: "none" });
return;
}
common_vendor.index.navigateTo({
url: `/pages/Inspectionresult/list?tableId=${tableId}&name=${encodeURIComponent(item.name || "")}`
});
};
const handleMenuClick = (item) => {
const menuRoutes = {
"成员管理": "/pages/membermanagemen/membermanagemen",
"信息填报": "/pages/corporateInformation/corporateInformation",
"区域设置": "/pages/area/management",
"检查清单": "/pages/checklist/checklist",
"检查记录": "/pages/Inspectionlog/Inspectionlog",
"证件管理": "/pages/Idphotomanagement/Idphotomanagement",
"隐患排查": "/pages/hiddendanger/Inspection",
"隐患销号": "/pages/closeout/application",
"设备登记": "/pages/equipmentregistration/equipmentregistration"
};
const url = menuRoutes[item.name];
if (url) {
common_vendor.index.navigateTo({ url });
} else {
common_vendor.index.showToast({ title: "功能开发中", icon: "none" });
}
};
const checkPlanParams = common_vendor.ref({
pageNum: 1,
pageSize: PLAN_INITIAL_SIZE,
name: ""
});
const checkPlanData = common_vendor.ref([]);
const checkPlanTotal = common_vendor.ref(0);
const planShowAll = common_vendor.ref(false);
const expandedPlanMap = common_vendor.ref({});
const hasMoreCheckPlans = common_vendor.computed(() => {
return !planShowAll.value && checkPlanTotal.value > PLAN_INITIAL_SIZE;
});
const initPlanExpandedState = (records = [], { reset = false, expandFirst = false } = {}) => {
const map = reset ? {} : { ...expandedPlanMap.value };
records.forEach((item, index) => {
if (reset) {
map[item.id] = expandFirst && index === 0;
} else if (!(item.id in map)) {
map[item.id] = false;
}
});
expandedPlanMap.value = map;
};
const isPlanExpanded = (id) => !!expandedPlanMap.value[id];
const togglePlanExpand = (id) => {
expandedPlanMap.value = {
...expandedPlanMap.value,
[id]: !expandedPlanMap.value[id]
};
};
const getCheckPlanLists = async () => {
var _a, _b;
planShowAll.value = false;
try {
const res = await request_api.getCheckPlanList({
pageNum: 1,
pageSize: PLAN_INITIAL_SIZE,
name: checkPlanParams.value.name
});
if (res.code === 0) {
const records = ((_a = res.data) == null ? void 0 : _a.records) || [];
checkPlanTotal.value = Number(((_b = res.data) == null ? void 0 : _b.total) ?? records.length);
checkPlanData.value = records;
initPlanExpandedState(records, { reset: true, expandFirst: true });
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:435", error);
} finally {
loading.value = false;
}
};
const loadMoreCheckPlans = async () => {
var _a;
if (!hasMoreCheckPlans.value)
return;
try {
const res = await request_api.getCheckPlanList({
pageNum: 1,
pageSize: checkPlanTotal.value,
name: checkPlanParams.value.name
});
if (res.code === 0) {
const records = ((_a = res.data) == null ? void 0 : _a.records) || [];
initPlanExpandedState(records);
checkPlanData.value = records;
planShowAll.value = true;
} else {
common_vendor.index.showToast({ title: res.msg || "加载失败", icon: "none" });
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:458", error);
common_vendor.index.showToast({ title: "加载失败", icon: "none" });
}
};
const formatDate = (dateStr) => {
if (!dateStr)
return "";
return dateStr.split(" ")[0];
};
common_vendor.onShow(() => {
getUserInfo();
getCheckPlanLists();
getHiddenDangerLists();
});
const hiddenDangerParams = common_vendor.ref({
pageNum: 1,
pageSize: 10,
name: ""
});
const hiddenDangerData = common_vendor.ref([]);
const dangerTabs = common_vendor.ref([
{ label: "全部", value: null },
{ label: "待交办", value: 1 },
{ label: "待整改", value: 2 },
{ label: "待验收", value: 3 },
{ label: "待销号", value: 4 },
{ label: "已完成", value: 5 }
]);
const activeDangerTab = common_vendor.ref(0);
const switchDangerTab = (index) => {
activeDangerTab.value = index;
};
const filteredDangerData = common_vendor.computed(() => {
const activeTab = dangerTabs.value[activeDangerTab.value];
if (!activeTab || activeTab.value === null) {
return hiddenDangerData.value;
}
return hiddenDangerData.value.filter((item) => item.status === activeTab.value);
});
const getHiddenDangerLists = async () => {
try {
const res = await request_api.getHiddenDangerList(hiddenDangerParams.value);
common_vendor.index.__f__("log", "at pages/index/index.vue:516", res);
if (res.code === 0) {
hiddenDangerData.value = res.data.records;
common_vendor.index.__f__("log", "at pages/index/index.vue:519", hiddenDangerData.value, 1111);
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:522", error);
} finally {
loading.value = false;
}
};
common_vendor.onLoad(() => {
getHiddenDangerLists();
});
const viewHazardDetail = (item) => {
common_vendor.index.navigateTo({
url: `/pages/hiddendanger/detail2?hazardId=${item.hazardId}&assignId=${item.assignId || ""}`
});
};
const goRectification = (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 goAcceptance = (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}`
});
};
return (_ctx, _cache) => {
return common_vendor.e({
a: common_assets._imports_0,
b: common_vendor.p({
title: "湘西州“三个一”安全管理平台",
placeholder: false,
fixed: false,
safeAreaInsetTop: true,
bgColor: "transparent",
titleColor: "#fff",
border: false,
leftIcon: ""
}),
c: getImageUrl(userInfo.avatar) || defaultAvatar,
d: common_vendor.t(userInfo.deptName || "未知部门"),
e: common_vendor.t(userInfo.phone || "未绑定"),
f: common_vendor.f(infoList.value, (item, index, i0) => {
return {
a: item.src,
b: common_vendor.t(item.name),
c: index,
d: common_vendor.o(($event) => handleMenuClick(item), index)
};
}),
g: checkPlanData.value.length === 0
}, checkPlanData.value.length === 0 ? {} : {}, {
h: common_vendor.f(checkPlanData.value, (item, k0, i0) => {
return {
a: common_vendor.t(item.name),
b: "1cf27b2a-1-" + i0,
c: common_vendor.p({
name: isPlanExpanded(item.id) ? "arrow-down" : "arrow-up",
color: "#ffffff",
size: "18"
}),
d: common_vendor.o(($event) => togglePlanExpand(item.id), item.id),
e: common_vendor.o(($event) => togglePlanExpand(item.id), item.id),
f: common_vendor.t(item.runModeName),
g: common_vendor.t(item.cycle),
h: common_vendor.t(formatDate(item.planStartTime)),
i: common_vendor.t(formatDate(item.planEndTime)),
j: formatProgress(item.progress) + "%",
k: common_vendor.t(formatProgress(item.progress)),
l: common_vendor.t(item.pendingCount ?? 0),
m: common_vendor.t(item.waitCheckNum ?? 0),
n: common_vendor.t(item.unusualNum ?? 0),
o: common_vendor.t(item.finishedCount ?? 0),
p: common_vendor.o(($event) => goTodayInspect(item), item.id),
q: common_vendor.o(($event) => goPlanCheckList(item), item.id),
r: isPlanExpanded(item.id),
s: !isPlanExpanded(item.id) ? 1 : "",
t: item.id
};
}),
i: hasMoreCheckPlans.value
}, hasMoreCheckPlans.value ? {
j: common_vendor.o(loadMoreCheckPlans)
} : {}, {
k: common_vendor.f(dangerTabs.value, (tab, index, i0) => {
return {
a: common_vendor.t(tab.label),
b: activeDangerTab.value === index ? 1 : "",
c: index,
d: common_vendor.o(($event) => switchDangerTab(index), index)
};
}),
l: filteredDangerData.value.length === 0
}, filteredDangerData.value.length === 0 ? {} : {}, {
m: common_vendor.f(filteredDangerData.value, (item, index, i0) => {
return common_vendor.e({
a: common_vendor.t(item.title),
b: common_vendor.t(item.levelName),
c: item.levelName === "轻微隐患" ? 1 : "",
d: item.levelName === "一般隐患" ? 1 : "",
e: item.levelName === "重大隐患" ? 1 : "",
f: common_vendor.t(item.address),
g: common_vendor.t(item.source),
h: common_vendor.t(item.statusName),
i: common_vendor.t(item.createdAt),
j: common_vendor.o(($event) => viewHazardDetail(item), item.hazardId),
k: item.statusName === "待整改" && item.canEdit
}, item.statusName === "待整改" && item.canEdit ? {
l: common_vendor.o(($event) => assignHazard(item), item.hazardId)
} : {}, {
m: item.statusName === "待整改" && item.canEdit
}, item.statusName === "待整改" && item.canEdit ? {
n: common_vendor.o(($event) => goRectification(item), item.hazardId)
} : {}, {
o: item.statusName === "待验收" && item.canEdit
}, item.statusName === "待验收" && item.canEdit ? {
p: common_vendor.o(($event) => editRectification(item), item.hazardId)
} : {}, {
q: item.statusName === "待验收" && canAcceptance.value
}, item.statusName === "待验收" && canAcceptance.value ? {
r: common_vendor.o(($event) => goAcceptance(item), item.hazardId)
} : {}, {
s: item.statusName === "待交办"
}, item.statusName === "待交办" ? {
t: common_vendor.o(($event) => assignHazard(item), item.hazardId)
} : {}, {
v: item.hazardId
});
}),
n: common_vendor.gei(_ctx, "")
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map