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

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

@@ -1,6 +1,17 @@
"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) {
@@ -8,21 +19,16 @@ const _sfc_main = {
const checkPointId = common_vendor.ref("");
const oneTableId = common_vendor.ref("");
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 || "";
userRole.value = utils_userInfo.resolveUserRoleKey(JSON.parse(userInfoStr));
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:86", "获取用户信息失败:", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:104", "获取用户信息失败:", error);
}
};
getUserRole();
const fetchTaskInfo = async (oneTableId2) => {
try {
const startRes = await request_api.enterCheckPlan(oneTableId2);
@@ -35,37 +41,114 @@ const _sfc_main = {
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:103", "获取任务信息失败:", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:120", "获取任务信息失败:", 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();
const res = await request_api.getMyHiddenDangerList(buildListParams());
if (res.code === 0) {
hiddenDangerList.value = res.data.records;
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:127", error);
common_vendor.index.__f__("error", "at pages/hiddendanger/Inspection.vue:207", error);
if (pageNum.value > 1) {
pageNum.value--;
}
loadStatus.value = "loadmore";
common_vendor.index.showToast({
title: "请求失败",
icon: "none"
});
} finally {
listLoading.value = false;
}
};
common_vendor.onShow(() => {
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";
@@ -86,53 +169,27 @@ const _sfc_main = {
};
const details = (item) => {
common_vendor.index.navigateTo({
url: `/pages/hiddendanger/detail2?hazardId=${item.hazardId}&assignId=${item.assignId || ""}`
url: `/pages/hiddendanger/process-chain?hazardId=${item.hazardId}`
});
};
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 });
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 acceptance = (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: `/pages/hiddendanger/assignment?hazardId=${item.hazardId}&assignId=${item.assignId}`
});
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 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) => {
@@ -142,12 +199,12 @@ const _sfc_main = {
}, activeTab.value === index ? {} : {}, {
c: index,
d: activeTab.value === index ? 1 : "",
e: common_vendor.o(($event) => activeTab.value = index, index)
e: common_vendor.o(($event) => switchStatusTab(index), index)
});
}),
b: filteredList.value.length === 0
}, filteredList.value.length === 0 ? {} : {}, {
c: common_vendor.f(filteredList.value, (item, k0, i0) => {
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),
@@ -170,19 +227,33 @@ const _sfc_main = {
}, item.statusName === "待验收" && item.canEdit ? {
o: common_vendor.o(($event) => editRectification(item), item.hazardId)
} : {}, {
p: item.statusName === "待验收" && canAcceptance.value
}, item.statusName === "待验收" && canAcceptance.value ? {
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: 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: common_vendor.o(goToAdd),
e: common_vendor.gei(_ctx, "")
d: hiddenDangerList.value.length > 0
}, hiddenDangerList.value.length > 0 ? {
e: common_vendor.p({
status: loadStatus.value
})
} : {}, {
f: common_vendor.o(goToAdd),
g: common_vendor.gei(_ctx, "")
});
};
}