一单四制优化及加入工作流

This commit is contained in:
王利强
2026-07-27 09:27:22 +08:00
parent 455fd4fc07
commit 7c3285ed5a
725 changed files with 19668 additions and 2921 deletions

View File

@@ -4,18 +4,23 @@ 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");
const utils_userInfo = require("../../utils/userInfo.js");
const utils_hazardNav = require("../../utils/hazardNav.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_loadmore2 = common_vendor.resolveComponent("u-loadmore");
(_easycom_u_navbar2 + _easycom_u_icon2 + _easycom_u_loadmore2)();
}
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";
const _easycom_u_loadmore = () => "../../uni_modules/uview-plus/components/u-loadmore/u-loadmore.js";
if (!Math) {
(_easycom_u_navbar + _easycom_u_icon)();
(_easycom_u_navbar + _easycom_u_icon + _easycom_u_loadmore)();
}
const defaultAvatar = "/static/my/default_avater.png";
const PLAN_INITIAL_SIZE = 4;
const HAZARD_PAGE_SIZE = 10;
const _sfc_main = {
__name: "index",
setup(__props) {
@@ -28,11 +33,25 @@ const _sfc_main = {
deptName: "",
role: "",
avatar: "",
phone: ""
phone: "",
identityName: "",
userIdentity: null
});
const canAcceptance = common_vendor.computed(() => {
return userInfo.role === "admin" || userInfo.role === "manage";
const currentRoleKey = common_vendor.computed(() => utils_userInfo.resolveUserRoleKey(userInfo));
const isApprovalRole = common_vendor.computed(() => currentRoleKey.value === "approval");
const displayIdentityName = common_vendor.computed(() => {
return utils_userInfo.resolveIdentityName(userInfo, userInfo.userIdentity);
});
const loadUserInfoFromStorage = () => {
try {
const storedUserInfo = common_vendor.index.getStorageSync("userInfo");
if (storedUserInfo) {
utils_userInfo.applyStoredUserInfo(userInfo, JSON.parse(storedUserInfo));
}
} catch (storageError) {
common_vendor.index.__f__("error", "at pages/index/index.vue:318", "从本地存储获取用户信息失败:", storageError);
}
};
const getImageUrl = (path) => {
if (!path)
return "";
@@ -42,35 +61,11 @@ const _sfc_main = {
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 || "";
}
utils_userInfo.applyProfileToUserInfo(userInfo, res.data);
}
} 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);
}
common_vendor.index.__f__("error", "at pages/index/index.vue:336", "获取用户信息失败:", e);
loadUserInfoFromStorage();
}
};
const allMenuList = [
@@ -109,7 +104,10 @@ const _sfc_main = {
];
const commonMenuNames = ["隐患排查", "隐患销号"];
const infoList = common_vendor.computed(() => {
if (userInfo.role === "common") {
if (currentRoleKey.value === "approval") {
return [];
}
if (currentRoleKey.value === "common") {
return allMenuList.filter((item) => commonMenuNames.includes(item.name));
}
return allMenuList;
@@ -216,7 +214,7 @@ const _sfc_main = {
initPlanExpandedState(records, { reset: true, expandFirst: true });
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:435", error);
common_vendor.index.__f__("error", "at pages/index/index.vue:509", error);
} finally {
loading.value = false;
}
@@ -240,7 +238,7 @@ const _sfc_main = {
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.__f__("error", "at pages/index/index.vue:532", error);
common_vendor.index.showToast({ title: "加载失败", icon: "none" });
}
};
@@ -250,15 +248,20 @@ const _sfc_main = {
return dateStr.split(" ")[0];
};
common_vendor.onShow(() => {
getUserInfo();
getCheckPlanLists();
getHiddenDangerLists();
});
const hiddenDangerParams = common_vendor.ref({
pageNum: 1,
pageSize: 10,
name: ""
loadUserInfoFromStorage();
getUserInfo().then(() => {
if (isApprovalRole.value) {
fetchWorkbenchList();
} else {
getCheckPlanLists();
resetHiddenDangerList();
fetchHiddenDangerList();
}
});
});
const hiddenDangerPageNum = common_vendor.ref(1);
const hiddenDangerLoading = common_vendor.ref(false);
const hiddenDangerLoadStatus = common_vendor.ref("loadmore");
const hiddenDangerData = common_vendor.ref([]);
const dangerTabs = common_vendor.ref([
{ label: "全部", value: null },
@@ -269,64 +272,198 @@ const _sfc_main = {
{ label: "已完成", value: 5 }
]);
const activeDangerTab = common_vendor.ref(0);
const switchDangerTab = (index) => {
activeDangerTab.value = index;
};
const filteredDangerData = common_vendor.computed(() => {
const buildHiddenDangerListParams = () => {
const params = {
pageNum: hiddenDangerPageNum.value,
pageSize: HAZARD_PAGE_SIZE
};
const activeTab = dangerTabs.value[activeDangerTab.value];
if (!activeTab || activeTab.value === null) {
return hiddenDangerData.value;
if ((activeTab == null ? void 0 : activeTab.value) != null) {
params.status = activeTab.value;
}
return params;
};
const resetHiddenDangerList = () => {
hiddenDangerPageNum.value = 1;
hiddenDangerData.value = [];
hiddenDangerLoadStatus.value = "loadmore";
};
const switchDangerTab = (index) => {
if (activeDangerTab.value === index)
return;
activeDangerTab.value = index;
resetHiddenDangerList();
fetchHiddenDangerList();
};
const fetchHiddenDangerList = async () => {
var _a, _b;
if (hiddenDangerLoading.value)
return;
if (hiddenDangerPageNum.value > 1 && hiddenDangerLoadStatus.value === "nomore")
return;
hiddenDangerLoading.value = true;
if (hiddenDangerPageNum.value > 1) {
hiddenDangerLoadStatus.value = "loading";
}
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);
const res = await request_api.getHiddenDangerList(buildHiddenDangerListParams());
if (res.code === 0) {
hiddenDangerData.value = res.data.records;
common_vendor.index.__f__("log", "at pages/index/index.vue:519", hiddenDangerData.value, 1111);
const records = ((_a = res.data) == null ? void 0 : _a.records) || [];
const total = Number(((_b = res.data) == null ? void 0 : _b.total) ?? 0);
if (hiddenDangerPageNum.value === 1) {
hiddenDangerData.value = records;
} else {
hiddenDangerData.value = [...hiddenDangerData.value, ...records];
}
if (hiddenDangerData.value.length >= total || records.length < HAZARD_PAGE_SIZE) {
hiddenDangerLoadStatus.value = "nomore";
} else {
hiddenDangerLoadStatus.value = "loadmore";
}
} else {
if (hiddenDangerPageNum.value === 1) {
hiddenDangerData.value = [];
}
hiddenDangerLoadStatus.value = "nomore";
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:522", error);
common_vendor.index.__f__("error", "at pages/index/index.vue:635", error);
if (hiddenDangerPageNum.value > 1) {
hiddenDangerPageNum.value--;
}
hiddenDangerLoadStatus.value = "loadmore";
} finally {
hiddenDangerLoading.value = false;
loading.value = false;
}
};
const loadMoreHiddenDangerList = () => {
if (hiddenDangerLoadStatus.value !== "loadmore" || hiddenDangerLoading.value)
return;
hiddenDangerPageNum.value++;
fetchHiddenDangerList();
};
common_vendor.onLoad(() => {
getHiddenDangerLists();
if (!isApprovalRole.value) {
resetHiddenDangerList();
fetchHiddenDangerList();
}
});
common_vendor.onReachBottom(() => {
if (isApprovalRole.value)
return;
loadMoreHiddenDangerList();
});
const workbenchTabs = [
{ label: "待办", value: "todo" },
{ label: "已办", value: "done" }
];
const activeWorkbenchTab = common_vendor.ref(0);
const workbenchList = common_vendor.ref([]);
const workbenchLoading = common_vendor.ref(false);
const normalizeWorkbenchItem = (item) => {
if (!item)
return {};
const hazard = item.hazard || item.hazardInfo || {};
return {
...item,
hazardId: item.hazardId ?? hazard.hazardId ?? "",
assignId: item.assignId ?? hazard.assignId ?? "",
rectifyId: item.rectifyId ?? hazard.rectifyId ?? "",
taskId: item.taskId ?? item.flowTaskId ?? item.currentTaskId ?? "",
taskKey: item.taskKey ?? item.flowTaskKey ?? item.currentTaskKey ?? "",
title: item.title ?? hazard.title ?? item.hazardTitle ?? "",
address: item.address ?? hazard.address ?? "",
source: item.source ?? hazard.source ?? item.hazardSourceName ?? "",
statusName: item.statusName ?? hazard.statusName ?? item.hazardStatusName ?? hazard.hazardStatusName ?? item.taskName ?? "",
hazardStatus: item.hazardStatus ?? hazard.hazardStatus ?? item.status ?? hazard.status ?? "",
createdAt: item.discoveredAt ?? hazard.discoveredAt ?? "",
levelName: item.levelName ?? hazard.levelName ?? ""
};
};
const resolveWorkbenchRecords = (data) => {
if (!data)
return [];
if (Array.isArray(data))
return data;
if (Array.isArray(data.records))
return data.records;
if (Array.isArray(data.list))
return data.list;
return [];
};
const getWorkbenchItemKey = (item) => {
const taskId = item.taskId || item.flowTaskId || "";
const hazardId = item.hazardId || "";
if (taskId && hazardId)
return `${taskId}-${hazardId}`;
return taskId || hazardId || item.rectifyId || JSON.stringify(item);
};
const switchWorkbenchTab = (index) => {
if (activeWorkbenchTab.value === index)
return;
activeWorkbenchTab.value = index;
fetchWorkbenchList();
};
const fetchWorkbenchList = async () => {
workbenchLoading.value = true;
try {
const isTodo = activeWorkbenchTab.value === 0;
const res = isTodo ? await request_api.getFlowTodoList() : await request_api.getFlowDoneList();
if (res.code === 0) {
workbenchList.value = resolveWorkbenchRecords(res.data).map(normalizeWorkbenchItem);
} else {
workbenchList.value = [];
common_vendor.index.showToast({ title: res.msg || "获取工作台数据失败", icon: "none" });
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:727", "获取工作台数据失败:", error);
workbenchList.value = [];
common_vendor.index.showToast({ title: "获取工作台数据失败", icon: "none" });
} finally {
workbenchLoading.value = false;
loading.value = false;
}
};
const goLeaderApproval = (item) => {
const hazardStatus = Number(item.hazardStatus);
const statusName = item.statusName || item.hazardStatusName || "";
if (hazardStatus === 4 || statusName === "待销号") {
common_vendor.index.navigateTo({ url: utils_hazardNav.buildLeaderWriteoffApprovalUrl(item) });
return;
}
if (hazardStatus === 3 || statusName === "待验收") {
common_vendor.index.navigateTo({ url: utils_hazardNav.buildAcceptanceApprovalUrl(item) });
return;
}
common_vendor.index.showToast({ title: "当前状态不支持领导审批", icon: "none" });
};
const viewHazardDetail = (item) => {
common_vendor.index.navigateTo({
url: `/pages/hiddendanger/detail2?hazardId=${item.hazardId}&assignId=${item.assignId || ""}`
url: `/pages/hiddendanger/process-chain?hazardId=${item.hazardId}`
});
};
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 });
common_vendor.index.navigateTo({ url: utils_hazardNav.buildRectificationUrl(item) });
};
const editRectification = (item) => {
common_vendor.index.navigateTo({
url: `/pages/hiddendanger/rectification?rectifyId=${item.rectifyId}&isEdit=1`
});
common_vendor.index.navigateTo({ url: utils_hazardNav.buildEditRectificationUrl(item) });
};
const goAcceptance = (item) => {
common_vendor.index.navigateTo({
url: `/pages/hiddendanger/acceptance?hazardId=${item.hazardId}&assignId=${item.assignId}&rectifyId=${item.rectifyId}`
});
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) });
};
const goSwitchIdentity = () => {
common_vendor.index.navigateTo({
url: `/pages/hiddendanger/assignment?hazardId=${item.hazardId}&assignId=${item.assignId}`
url: "/pages/personalcenter/identity"
});
};
return (_ctx, _cache) => {
@@ -345,20 +482,35 @@ const _sfc_main = {
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) => {
f: displayIdentityName.value
}, displayIdentityName.value ? {
g: common_vendor.t(displayIdentityName.value)
} : {}, {
h: common_vendor.p({
name: "list",
color: "#285CE9",
size: "14"
}),
i: common_vendor.o(goSwitchIdentity),
j: !isApprovalRole.value
}, !isApprovalRole.value ? {
k: 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
})
} : {}, {
l: !isApprovalRole.value
}, !isApprovalRole.value ? common_vendor.e({
m: checkPlanData.value.length === 0
}, checkPlanData.value.length === 0 ? {} : {}, {
h: common_vendor.f(checkPlanData.value, (item, k0, i0) => {
n: common_vendor.f(checkPlanData.value, (item, k0, i0) => {
return {
a: common_vendor.t(item.name),
b: "1cf27b2a-1-" + i0,
b: "1cf27b2a-2-" + i0,
c: common_vendor.p({
name: isPlanExpanded(item.id) ? "arrow-down" : "arrow-up",
color: "#ffffff",
@@ -383,11 +535,13 @@ const _sfc_main = {
t: item.id
};
}),
i: hasMoreCheckPlans.value
o: hasMoreCheckPlans.value
}, hasMoreCheckPlans.value ? {
j: common_vendor.o(loadMoreCheckPlans)
} : {}, {
k: common_vendor.f(dangerTabs.value, (tab, index, i0) => {
p: common_vendor.o(loadMoreCheckPlans)
} : {}) : {}, {
q: !isApprovalRole.value
}, !isApprovalRole.value ? common_vendor.e({
r: common_vendor.f(dangerTabs.value, (tab, index, i0) => {
return {
a: common_vendor.t(tab.label),
b: activeDangerTab.value === index ? 1 : "",
@@ -395,9 +549,9 @@ const _sfc_main = {
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) => {
s: hiddenDangerData.value.length === 0 && !hiddenDangerLoading.value
}, hiddenDangerData.value.length === 0 && !hiddenDangerLoading.value ? {} : {}, {
t: common_vendor.f(hiddenDangerData.value, (item, index, i0) => {
return common_vendor.e({
a: common_vendor.t(item.title),
b: common_vendor.t(item.levelName),
@@ -421,18 +575,65 @@ const _sfc_main = {
}, item.statusName === "待验收" && item.canEdit ? {
p: common_vendor.o(($event) => editRectification(item), item.hazardId)
} : {}, {
q: item.statusName === "待验收" && canAcceptance.value
}, item.statusName === "待验收" && canAcceptance.value ? {
q: common_vendor.unref(utils_hazardNav.canShowAcceptanceButton)(item, currentRoleKey.value)
}, common_vendor.unref(utils_hazardNav.canShowAcceptanceButton)(item, currentRoleKey.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
v: common_vendor.unref(utils_hazardNav.canShowWriteoffApplyButton)(item)
}, common_vendor.unref(utils_hazardNav.canShowWriteoffApplyButton)(item) ? {
w: common_vendor.o(($event) => goWriteoffApply(item), item.hazardId)
} : {}, {
x: common_vendor.unref(utils_hazardNav.canShowWriteoffApprovalButton)(item, currentRoleKey.value)
}, common_vendor.unref(utils_hazardNav.canShowWriteoffApprovalButton)(item, currentRoleKey.value) ? {
y: common_vendor.o(($event) => goWriteoffApproval(item), item.hazardId)
} : {}, {
z: item.hazardId
});
}),
n: common_vendor.gei(_ctx, "")
v: hiddenDangerData.value.length > 0
}, hiddenDangerData.value.length > 0 ? {
w: common_vendor.p({
status: hiddenDangerLoadStatus.value
})
} : {}) : {}, {
x: isApprovalRole.value
}, isApprovalRole.value ? common_vendor.e({
y: common_vendor.f(workbenchTabs, (tab, index, i0) => {
return {
a: common_vendor.t(tab.label),
b: activeWorkbenchTab.value === index ? 1 : "",
c: tab.value,
d: common_vendor.o(($event) => switchWorkbenchTab(index), tab.value)
};
}),
z: workbenchLoading.value
}, workbenchLoading.value ? {} : workbenchList.value.length === 0 ? {} : {}, {
A: workbenchList.value.length === 0,
B: common_vendor.f(workbenchList.value, (item, k0, 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), getWorkbenchItemKey(item))
}, activeWorkbenchTab.value === 0 ? {
k: common_vendor.o(($event) => goLeaderApproval(item), getWorkbenchItemKey(item))
} : {}, {
l: getWorkbenchItemKey(item)
});
}),
C: activeWorkbenchTab.value === 0
}) : {}, {
D: common_vendor.gei(_ctx, "")
});
};
}