修复待办更新时的异常

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();
}
nextTick(() => {
dkRef.value.init();
if (dkRef.value) {
dkRef.value.init();
}
});
};

View File

@ -67,6 +67,12 @@ const spParams = computed(() => {
const handleQjDataLoaded = async (data: any) => {
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);
data.dkfs = dkfs;
qjData.value = data;
@ -77,7 +83,9 @@ const handleQjDataLoaded = async (data: any) => {
return;
}
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 { getGwData, setXxts, setGwData, getXxts } = useDataStore();
export const GwPageUtils = {
// 初始化校验
async init(data?: any) {
setXxts({});
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({});
let xxtsId = "";
const init = async (data?: any) => {
xxtsId = '';
setXxts({});
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 {
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
// 从待办过来的,需要从后端获取数据
ret.dbFlag = true;
// 检查登录状态
const isLoggedIn = await loginByOpenId(data.openId);
if (!isLoggedIn) {
console.log("用户未登录,跳过处理");
} 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;
}
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;
},
}
};
const updateXxts = async () => {
// 如果没有查询过消息推送,表示不是从待办进入的,不自动更新,
if (!xxtsId || !xxtsId.length) {
return false;
}
console.log("更新待办状态getXxts", getXxts);
// 更新待办状态
await xxtsSaveApi({
id: xxtsId,
dbZt: "B",
});
return true;
};
export const GwPageUtils = {
init,
updateXxts
}

View File

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

View File

@ -5,76 +5,82 @@ import { useDataStore } from "@/store/modules/data";
const { loginByOpenId } = useUserStore();
const { getData, setXxts, setData, getXxts } = useDataStore();
export const XkTfPageUtils = {
// 初始化校验
async init(data?: any) {
setXxts({});
let ret = {
success: true,
dbFlag: false,
xkTfId: getData.id,
};
if (!data || !data.from || data.from != "db") {
return ret;
let xxtsId = '';
const init = async (data?: any) => {
xxtsId = '';
setXxts({});
let ret = {
success: true,
dbFlag: false,
xkTfId: getData.id,
};
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;
}
// 从待办过来的,需要从后端获取数据
ret.dbFlag = true;
// 检查登录状态
const isLoggedIn = await loginByOpenId(data.openId);
if (!isLoggedIn) {
console.log("用户未登录,跳过处理");
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;
}
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.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;
} 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;
},
}
};
const updateXxts = async () => {
// 如果没有查询过消息推送,表示不是从待办进入的,不自动更新,
if (!xxtsId || !xxtsId.length) {
return false;
}
console.log("更新待办状态getXxts", getXxts);
// 更新待办状态
await xxtsSaveApi({
id: xxtsId,
});
return true;
}
export const XkTfPageUtils = {
init,
updateXxts
}