From 2d2eb8358314e6280716f976971872899038a25b Mon Sep 17 00:00:00 2001 From: ywyonui Date: Tue, 23 Sep 2025 22:52:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=8C=E5=96=84=E5=85=AC?= =?UTF-8?q?=E6=96=87=E5=AE=A1=E6=89=B9=E7=9A=84=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/view/hr/jsQj/detail.vue | 7 +- src/pages/view/hr/jsQj/sp.vue | 6 +- src/pages/view/routine/gwlz/gwDetail.vue | 3 + src/pages/view/routine/gwlz/gwFlow.vue | 232 +++-------------------- src/store/modules/data.ts | 20 ++ src/store/modules/user.ts | 3 + src/utils/gwPageUtils.ts | 88 +++++++++ src/utils/qjPageUtils.ts | 8 +- 8 files changed, 154 insertions(+), 213 deletions(-) create mode 100644 src/utils/gwPageUtils.ts diff --git a/src/pages/view/hr/jsQj/detail.vue b/src/pages/view/hr/jsQj/detail.vue index e45ff2b..17b6a01 100644 --- a/src/pages/view/hr/jsQj/detail.vue +++ b/src/pages/view/hr/jsQj/detail.vue @@ -31,13 +31,12 @@ diff --git a/src/store/modules/data.ts b/src/store/modules/data.ts index fb631c9..3070f6e 100644 --- a/src/store/modules/data.ts +++ b/src/store/modules/data.ts @@ -14,6 +14,7 @@ export const useDataStore = defineStore({ tf: {}, // 退费时使用 lcgl: {}, // 流程管理使用 qjData: {}, // 请假数据 + gwData: {}, // 公文数据 }), getters: { getData(): any { @@ -46,8 +47,24 @@ export const useDataStore = defineStore({ getQjData(): any { return this.qjData; }, + getGwData(): any { + return this.gwData; + }, }, actions: { + clear() { + this.data = {}; + this.db = {}; + this.xxts = {}; + this.global = {}; + this.file = {}; + this.xs = {}; + this.jcBz = {}; + this.tf = {}; + this.lcgl = {}; + this.qjData = {}; + this.gwData = {}; + }, setData(data: any) { this.data = data; }, @@ -78,6 +95,9 @@ export const useDataStore = defineStore({ setQjData(data: any) { this.qjData = data; }, + setGwData(data: any) { + this.gwData = data; + }, }, persist: { enabled: true, diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 36b2380..e33ce39 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -13,6 +13,7 @@ import { refreshPermissionCache, clearPermissionCachePublic, } from "@/utils/permission"; +import { useDataStore } from "./data"; interface UserState { userdata: any; @@ -190,6 +191,7 @@ export const useUserStore = defineStore({ this.setToken(value[AUTH_KEY]); } // 为了避免数据加载异常。这里清理一下缓存 + useDataStore().clear(); useDicStore().setData({}); useCommonStore().setData({}); @@ -226,6 +228,7 @@ export const useUserStore = defineStore({ this.setUser({}); this.setJs({}); this.setAuth([]); + useDataStore().clear(); useDicStore().setData({}); useCommonStore().setData({}); }, diff --git a/src/utils/gwPageUtils.ts b/src/utils/gwPageUtils.ts new file mode 100644 index 0000000..103d2ab --- /dev/null +++ b/src/utils/gwPageUtils.ts @@ -0,0 +1,88 @@ +import { xxtsFindByIdApi, xxtsSaveApi } from "@/api/base/xxtsApi"; +import { useUserStore } from "@/store/modules/user"; +import { useDataStore } from "@/store/modules/data"; + +const { loginByOpenId } = useUserStore(); +const { getGwData, setXxts, setGwData, getXxts } = useDataStore(); + +export const GwPageUtils = { + // 初始化校验 + async init(data?: any) { + let ret = { + success: true, + dbFlag: false, + gwId: getGwData.id, + }; + if (!data || !data.from || data.from != "db") { + // 如果是非待办,传入了id,表示对应的是公文业务id + if (data && data.id) { + ret.gwId = data.id; + setXxts({}); + } + return ret; + } else + // 从待办过来的,需要从后端获取数据 + ret.dbFlag = true; + // 检查登录状态 + const isLoggedIn = await loginByOpenId(data.openId); + if (!isLoggedIn) { + console.log("用户未登录,跳过处理"); + ret.success = false; + return ret; + } + let url = "/pages/base/message/index"; + try { + // 优先从后端根据url中的id去查询Xxts + const xxtsRes = await xxtsFindByIdApi({ id: data.id }); + if (xxtsRes && xxtsRes.result) { + const xxts = xxtsRes.result; + setXxts(xxts); + ret.gwId = xxts.xxzbId; + // 检查待办状态 + if (xxts.dbZt === "B") { + // 消息推送状态为B: + setGwData({ id: xxts.xxzbId, from: "xxts-B" }); + if (!data.detailFlag) { + // url = "/pages/view/routine/gwlz/gwDetail"; + // uni.reLaunch({ url }); + ret.success = false; + } else { + ret.success = true; + } + } + } else { + uni.showToast({ + title: "获取消息推送数据失败", + icon: "error", + }); + uni.reLaunch({ url }); + ret.success = false; + } + return ret; + } catch (error) { + console.error("获取待办信息失败", error); + // 如果获取Xxts失败,回退到原来的逻辑 + const xxtsData = getXxts; + if (xxtsData && xxtsData.dbZt === "B") { + setGwData({ id: data.id }); + uni.reLaunch({ url }); + ret.success = false; + return ret; + } + } + }, + // 检查待办状态是否需要更新 + async updateXxts() { + // 如果没有查询过消息推送,表示不是从待办进入的,不自动更新, + if (!getXxts || !getXxts.id) { + return false; + } + console.log("更新待办状态:getXxts", getXxts); + // 更新待办状态 + await xxtsSaveApi({ + id: getXxts.id, + dbZt: "B", + }); + return true; + }, +} \ No newline at end of file diff --git a/src/utils/qjPageUtils.ts b/src/utils/qjPageUtils.ts index 2512a4c..9562617 100644 --- a/src/utils/qjPageUtils.ts +++ b/src/utils/qjPageUtils.ts @@ -3,7 +3,7 @@ import { useUserStore } from "@/store/modules/user"; import { useDataStore } from "@/store/modules/data"; const { loginByOpenId } = useUserStore(); -const { getData, setXxts, setData, getXxts } = useDataStore(); +const { getQjData, setXxts, setQjData, getXxts } = useDataStore(); export const QjPageUtils = { // 初始化校验 @@ -11,7 +11,7 @@ export const QjPageUtils = { let ret = { success: true, dbFlag: false, - qjId: getData.id, + qjId: getQjData.id, }; if (!data || !data.from || data.from != "db") { return ret; @@ -36,7 +36,7 @@ export const QjPageUtils = { // 检查待办状态 if (xxts.dbZt === "B") { // 消息推送状态为B: - setData({ id: xxts.xxzbId, from: "xxts-B" }); + setQjData({ id: xxts.xxzbId, from: "xxts-B" }); if (!data.detailFlag) { url = "/pages/view/hr/jsQj/detail"; uni.reLaunch({ url }); @@ -59,7 +59,7 @@ export const QjPageUtils = { // 如果获取Xxts失败,回退到原来的逻辑 const xxtsData = getXxts; if (xxtsData && xxtsData.dbZt === "B") { - setData({ id: data.id }); + setQjData({ id: data.id }); uni.reLaunch({ url }); ret.success = false; return ret;