316 lines
12 KiB
JavaScript
316 lines
12 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");
|
|
_easycom_u_navbar2();
|
|
}
|
|
const _easycom_u_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
|
|
if (!Math) {
|
|
_easycom_u_navbar();
|
|
}
|
|
const defaultAvatar = "https://ossweb-img.qq.com/images/lol/web201310/skin/big99008.jpg";
|
|
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:229", "获取用户信息失败:", 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:245", "从本地存储获取用户信息失败:", storageError);
|
|
}
|
|
}
|
|
};
|
|
const infoList = common_vendor.ref([
|
|
{
|
|
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"
|
|
}
|
|
// ,
|
|
// {
|
|
// name: '设备登记',
|
|
// src: '/static/home_icon/shebeidengji.png'
|
|
// }
|
|
]);
|
|
const ViewDetails = (item) => {
|
|
common_vendor.index.navigateTo({
|
|
url: `/pages/plandetail/plandetail?id=${item.id}`
|
|
});
|
|
};
|
|
const goDetails = (item) => {
|
|
common_vendor.index.navigateTo({
|
|
url: `/pages/Inspectionresult/Inspectionresult?id=${item.id}`
|
|
});
|
|
};
|
|
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: 10,
|
|
name: ""
|
|
});
|
|
const checkPlanData = common_vendor.ref([]);
|
|
const getCheckPlanLists = async () => {
|
|
try {
|
|
const res = await request_api.getCheckPlanList(checkPlanParams.value);
|
|
common_vendor.index.__f__("log", "at pages/index/index.vue:331", res);
|
|
if (res.code === 0) {
|
|
checkPlanData.value = res.data.records;
|
|
}
|
|
} catch (error) {
|
|
common_vendor.index.__f__("error", "at pages/index/index.vue:336", error);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
};
|
|
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(["全部状态", "待验收", "待整改", "待交办", "验收通过"]);
|
|
const activeDangerTab = common_vendor.ref(0);
|
|
const switchDangerTab = (index) => {
|
|
activeDangerTab.value = index;
|
|
};
|
|
const filteredDangerData = common_vendor.computed(() => {
|
|
if (activeDangerTab.value === 0) {
|
|
return hiddenDangerData.value;
|
|
}
|
|
const status = dangerTabs.value[activeDangerTab.value];
|
|
return hiddenDangerData.value.filter((item) => item.statusName === status);
|
|
});
|
|
const getHiddenDangerLists = async () => {
|
|
try {
|
|
const res = await request_api.getHiddenDangerList(hiddenDangerParams.value);
|
|
common_vendor.index.__f__("log", "at pages/index/index.vue:388", res);
|
|
if (res.code === 0) {
|
|
hiddenDangerData.value = res.data.records;
|
|
common_vendor.index.__f__("log", "at pages/index/index.vue:391", hiddenDangerData.value, 1111);
|
|
}
|
|
} catch (error) {
|
|
common_vendor.index.__f__("error", "at pages/index/index.vue:394", error);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
};
|
|
common_vendor.onLoad(() => {
|
|
getHiddenDangerLists();
|
|
});
|
|
const viewHazardDetail = (item) => {
|
|
common_vendor.index.navigateTo({
|
|
url: `/pages/hiddendanger/view?hazardId=${item.hazardId}&assignId=${item.assignId}`
|
|
});
|
|
};
|
|
const goRectification = (item) => {
|
|
common_vendor.index.navigateTo({
|
|
url: `/pages/hiddendanger/rectification?hazardId=${item.hazardId}&assignId=${item.assignId}`
|
|
});
|
|
};
|
|
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, index, i0) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.t(item.name),
|
|
b: common_vendor.t(item.runModeName),
|
|
c: common_vendor.t(item.cycle),
|
|
d: common_vendor.t(formatDate(item.planStartTime)),
|
|
e: common_vendor.t(formatDate(item.planEndTime)),
|
|
f: item.progress + "%",
|
|
g: common_vendor.t(item.progress),
|
|
h: common_vendor.t(item.totalCount),
|
|
i: common_vendor.t(item.totalCount - item.finishedCount),
|
|
j: common_vendor.t(item.finishedCount),
|
|
k: common_vendor.o(($event) => ViewDetails(item), item.id),
|
|
l: item.finishedCount < item.totalCount
|
|
}, item.finishedCount < item.totalCount ? {
|
|
m: common_vendor.o(($event) => goDetails(item), item.id)
|
|
} : {}, {
|
|
n: item.id
|
|
});
|
|
}),
|
|
i: common_vendor.f(dangerTabs.value, (tab, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(tab),
|
|
b: activeDangerTab.value === index ? 1 : "",
|
|
c: index,
|
|
d: common_vendor.o(($event) => switchDangerTab(index), index)
|
|
};
|
|
}),
|
|
j: filteredDangerData.value.length === 0
|
|
}, filteredDangerData.value.length === 0 ? {} : {}, {
|
|
k: 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) => goRectification(item), item.hazardId)
|
|
} : {}, {
|
|
m: item.statusName === "待验收" && canAcceptance.value
|
|
}, item.statusName === "待验收" && canAcceptance.value ? {
|
|
n: common_vendor.o(($event) => goAcceptance(item), item.hazardId)
|
|
} : {}, {
|
|
o: item.statusName === "待交办"
|
|
}, item.statusName === "待交办" ? {
|
|
p: common_vendor.o(($event) => assignHazard(item), item.hazardId)
|
|
} : {}, {
|
|
q: item.hazardId
|
|
});
|
|
}),
|
|
l: 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
|