修复待办更新时的异常

This commit is contained in:
ywyonui 2025-09-26 10:34:48 +08:00
parent 4a4573e51c
commit c5fc913a27
5 changed files with 175 additions and 149 deletions

View File

@ -52,7 +52,9 @@ const handleQjDataLoaded = (data: any) => {
QjPageUtils.updateXxts(); QjPageUtils.updateXxts();
} }
nextTick(() => { nextTick(() => {
dkRef.value.init(); if (dkRef.value) {
dkRef.value.init();
}
}); });
}; };

View File

@ -67,6 +67,12 @@ const spParams = computed(() => {
const handleQjDataLoaded = async (data: any) => { const handleQjDataLoaded = async (data: any) => {
data = data || {}; data = data || {};
//
if (!data.id) {
uni.reLaunch({ url: '/pages/base/message/index' });
QjPageUtils.updateXxts();
return;
}
const dkfs = typeof (data.dkfs) === "string" ? parseInt(data.dkfs) : (data.dkfs || 2); const dkfs = typeof (data.dkfs) === "string" ? parseInt(data.dkfs) : (data.dkfs || 2);
data.dkfs = dkfs; data.dkfs = dkfs;
qjData.value = data; qjData.value = data;
@ -77,7 +83,9 @@ const handleQjDataLoaded = async (data: any) => {
return; return;
} }
nextTick(() => { nextTick(() => {
dkRef.value.init(); if (dkRef.value) {
dkRef.value.init();
}
}); });
}; };

View File

@ -5,85 +5,91 @@ import { useDataStore } from "@/store/modules/data";
const { loginByOpenId } = useUserStore(); const { loginByOpenId } = useUserStore();
const { getGwData, setXxts, setGwData, getXxts } = useDataStore(); const { getGwData, setXxts, setGwData, getXxts } = useDataStore();
export const GwPageUtils = { let xxtsId = "";
// 初始化校验
async init(data?: any) { const init = async (data?: any) => {
setXxts({}); xxtsId = '';
let ret = { setXxts({});
success: true, let ret = {
dbFlag: false, success: true,
gwId: getGwData.id, dbFlag: false,
}; gwId: getGwData.id,
if (!data || !data.from || data.from != "db") { };
// 如果是非待办传入了id表示对应的是公文业务id if (!data || !data.from || data.from != "db") {
if (data && data.id) { // 如果是非待办传入了id表示对应的是公文业务id
ret.gwId = data.id; if (data && data.id) {
setXxts({}); 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 {
xxtsId = data.id;
// 优先从后端根据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;
}
} }
return ret; } else {
} else uni.showToast({
// 从待办过来的,需要从后端获取数据 title: "获取消息推送数据失败",
ret.dbFlag = true; icon: "error",
// 检查登录状态 });
const isLoggedIn = await loginByOpenId(data.openId); uni.reLaunch({ url });
if (!isLoggedIn) { ret.success = false;
console.log("用户未登录,跳过处理"); }
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; ret.success = false;
return ret; return ret;
} }
let url = "/pages/base/message/index"; }
try { };
// 优先从后端根据url中的id去查询Xxts
const xxtsRes = await xxtsFindByIdApi({ id: data.id }); const updateXxts = async () => {
if (xxtsRes && xxtsRes.result) { // 如果没有查询过消息推送,表示不是从待办进入的,不自动更新,
const xxts = xxtsRes.result; if (!xxtsId || !xxtsId.length) {
setXxts(xxts); return false;
ret.gwId = xxts.xxzbId; }
// 检查待办状态 console.log("更新待办状态getXxts", getXxts);
if (xxts.dbZt === "B") { // 更新待办状态
// 消息推送状态为B await xxtsSaveApi({
setGwData({ id: xxts.xxzbId, from: "xxts-B" }); id: xxtsId,
if (!data.detailFlag) { dbZt: "B",
// url = "/pages/view/routine/gwlz/gwDetail"; });
// uni.reLaunch({ url }); return true;
ret.success = false; };
} else {
ret.success = true; export const GwPageUtils = {
} init,
} updateXxts
} 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;
},
} }

View File

@ -31,7 +31,10 @@ const qrStatus: any = {
"rejected": "拒绝", "rejected": "拒绝",
}; };
let xxtsId = "";
const init = async (data?: any) => { const init = async (data?: any) => {
xxtsId = '';
setXxts({}); setXxts({});
let ret = { let ret = {
success: true, success: true,
@ -52,6 +55,7 @@ const init = async (data?: any) => {
} }
let url = "/pages/base/message/index"; let url = "/pages/base/message/index";
try { try {
xxtsId = data.id;
// 优先从后端根据url中的id去查询Xxts // 优先从后端根据url中的id去查询Xxts
const xxtsRes = await xxtsFindByIdApi({ id: data.id }); const xxtsRes = await xxtsFindByIdApi({ id: data.id });
if (xxtsRes && xxtsRes.result) { if (xxtsRes && xxtsRes.result) {
@ -94,13 +98,13 @@ const init = async (data?: any) => {
const updateXxts = async () => { const updateXxts = async () => {
// 如果没有查询过消息推送,表示不是从待办进入的,不自动更新, // 如果没有查询过消息推送,表示不是从待办进入的,不自动更新,
if (!getXxts || !getXxts.id) { if (!xxtsId || !xxtsId.length) {
return false; return false;
} }
console.log("更新待办状态getXxts", getXxts); console.log("更新待办状态getXxts", getXxts);
// 更新待办状态 // 更新待办状态
await xxtsSaveApi({ await xxtsSaveApi({
id: getXxts.id, id: xxtsId,
dbZt: "B", dbZt: "B",
}); });
return true; return true;

View File

@ -5,76 +5,82 @@ import { useDataStore } from "@/store/modules/data";
const { loginByOpenId } = useUserStore(); const { loginByOpenId } = useUserStore();
const { getData, setXxts, setData, getXxts } = useDataStore(); const { getData, setXxts, setData, getXxts } = useDataStore();
export const XkTfPageUtils = { let xxtsId = '';
// 初始化校验
async init(data?: any) { const init = async (data?: any) => {
setXxts({}); xxtsId = '';
let ret = { setXxts({});
success: true, let ret = {
dbFlag: false, success: true,
xkTfId: getData.id, dbFlag: false,
}; xkTfId: getData.id,
if (!data || !data.from || data.from != "db") { };
return ret; if (!data || !data.from || data.from != "db") {
return ret;
}
// 从待办过来的,需要从后端获取数据
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 {
xxtsId = data.id;
// 优先从后端根据url中的id去查询Xxts
const xxtsRes = await xxtsFindByIdApi({ id: data.id });
if (xxtsRes && xxtsRes.result) {
const xxts = xxtsRes.result;
setXxts(xxts);
ret.xkTfId = xxts.xxzbId;
// 检查待办状态
if (xxts.dbZt === "B") {
setData({ id: xxts.xxzbId });
url = "/pages/view/routine/xk/tf/detail";
uni.reLaunch({ url });
ret.success = false;
} else {
ret.success = true;
}
} else {
uni.showToast({
title: "获取消息推送数据失败",
icon: "error",
});
uni.reLaunch({ url });
ret.success = false;
} }
// 从待办过来的,需要从后端获取数据 return ret;
ret.dbFlag = true; } catch (error) {
// 检查登录状态 console.error("获取待办信息失败", error);
const isLoggedIn = await loginByOpenId(data.openId); // 如果获取Xxts失败回退到原来的逻辑
if (!isLoggedIn) { const xxtsData = getXxts;
console.log("用户未登录,跳过处理"); if (xxtsData && xxtsData.dbZt === "B") {
setData({ id: data.id });
uni.reLaunch({ url });
ret.success = false; ret.success = false;
return ret; return ret;
} }
let url = "/pages/base/message/index"; }
try { };
// 优先从后端根据url中的id去查询Xxts
const xxtsRes = await xxtsFindByIdApi({ id: data.id }); const updateXxts = async () => {
if (xxtsRes && xxtsRes.result) { // 如果没有查询过消息推送,表示不是从待办进入的,不自动更新,
const xxts = xxtsRes.result; if (!xxtsId || !xxtsId.length) {
setXxts(xxts); return false;
ret.xkTfId = xxts.xxzbId; }
// 检查待办状态 console.log("更新待办状态getXxts", getXxts);
if (xxts.dbZt === "B") { // 更新待办状态
setData({ id: xxts.xxzbId }); await xxtsSaveApi({
url = "/pages/view/routine/xk/tf/detail"; id: xxtsId,
uni.reLaunch({ url }); });
ret.success = false; return true;
} else { }
ret.success = true;
} export const XkTfPageUtils = {
} else { init,
uni.showToast({ updateXxts
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") {
setData({ id: data.id });
uni.reLaunch({ url });
ret.success = false;
return ret;
}
}
},
// 检查待办状态是否需要更新
async updateXxts() {
// 如果没有查询过消息推送,表示不是从待办进入的,不自动更新,
if (!getXxts || !getXxts.id) {
return false;
}
// 更新待办状态
await xxtsSaveApi({
id: getXxts.id,
dbZt: "B",
});
return true;
},
} }