调整完善公文审批的流程

This commit is contained in:
ywyonui 2025-09-23 22:52:15 +08:00
parent cae5247b52
commit 2d2eb83583
8 changed files with 154 additions and 213 deletions

View File

@ -31,13 +31,12 @@
<script setup lang="ts">
import { useDataStore } from "@/store/modules/data";
import { ref, computed } from "vue";
import { ref } from "vue";
import JsQjDetailInfo from "./components/jsQjDetailInfo.vue";
import JsQjDetailDk from "./components/jsQjDetailDk.vue";
import LcglSp from "@/components/LcglSp/index.vue";
import { onLoad } from "@dcloudio/uni-app";
import { QjPageUtils } from "@/utils/qjPageUtils";
import { xxtsFindByIdApi } from "@/api/base/xxtsApi";
const { getQjData, setQjData, getXxts } = useDataStore();
@ -48,10 +47,10 @@ const showDkEmptyLabel = ref('');
const handleQjDataLoaded = (data: any) => {
data = data || {};
if (data.spResult != "A" && getXxts && getXxts.dbZt === "A") {
setQjData(data);
if (data.spResult && data.spResult != "A" && getXxts && getXxts.dbZt === "A") {
QjPageUtils.updateXxts();
}
setQjData(data);
const dkfs = typeof (data.dkfs) === "string" ? parseInt(data.dkfs) : (data.dkfs || 2);
const bpmStatus = typeof (data.bpmStatus) === "string" ? parseInt(data.bpmStatus) : (data.bpmStatus || 1);
showDkFlag.value = dkfs === 0 || (dkfs === 1 && bpmStatus > 4);

View File

@ -100,8 +100,10 @@ const spParams = computed(() => {
const handleQjDataLoaded = async (data: any) => {
data = data || {};
setQjData(data);
if (data.spResult != "A" && getXxts && getXxts.dbZt === "A") {
uni.reLaunch({ url: '/pages/base/xs/qj/detail' });
if (data.spResult && data.spResult != "A" && getXxts && getXxts.dbZt === "A") {
uni.reLaunch({ url: '/pages/base/js/qj/detail' });
QjPageUtils.updateXxts();
return;
}
const dkfs = typeof(data.dkfs) === "string" ? parseInt(data.dkfs) : (data.dkfs || 2);
showDkFlag.value = dkfs === 0;

View File

@ -14,6 +14,9 @@ import { gwFindByIdApi } from "@/api/routine/gw";
import { useDicStore } from "@/store/modules/dic";
import { ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import {useDataStore} from "@/store/modules/data";
import { GwPageUtils } from "@/utils/gwPageUtils";
const { setGwData, getXxts } = useDataStore();
const { findByPid } = useDicStore();

View File

@ -84,8 +84,7 @@
</view>
<!-- 审批流程 -->
<LcglSp :yw-id="gwInfo.id" yw-type="GW"/>
<LcglSp :yw-id="gwId" yw-type="GW"/>
<!-- 操作记录详情弹窗 -->
<u-popup :show="showLogDetailModal" @close="showLogDetailModal = false" mode="center">
@ -153,7 +152,7 @@
</view>
</u-popup>
<template #bottom>
<YwConfirm
<YwConfirm v-if="showButton"
:spApi="gwSpApi"
:stopApi="gwStopApi"
:transferApi="gwTransferApi"
@ -170,11 +169,11 @@
</template>
<script setup lang="ts">
import { onLoad } from "@dcloudio/uni-app";
import {ref, onMounted, computed} from "vue";
import BasicLayout from "@/components/BasicLayout/Layout.vue";
import {navigateTo} from "@/utils/uniapp";
import {getGwFlowByIdApi, gwApproveApi, gwSpApi, gwTransferApi, gwStopApi} from "@/api/routine/gw";
import {getGwFlowByIdApi, gwSpApi, gwTransferApi, gwStopApi} from "@/api/routine/gw";
import dayjs from "dayjs";
import {useUserStore} from "@/store/modules/user";
import {imagUrl} from "@/utils";
@ -190,13 +189,17 @@ import {
import LcglSp from "@/components/LcglSp/index.vue";
import YwConfirm from "@/pages/components/YwConfirm/index.vue";
import {useDataStore} from "@/store/modules/data";
const { setData, getXxts } = useDataStore();
import { GwPageUtils } from "@/utils/gwPageUtils";
const { setGwData, getXxts } = useDataStore();
const spParams = computed(() => {
return{
xxtsId: getXxts.id,
ywId: gwInfo.value.id
}
})
return{
xxtsId: getXxts.id,
ywId: gwId.value
};
});
const showButton = ref<boolean>(false);
//
interface GwInfo {
@ -383,7 +386,6 @@ const canCurrentUserOperate = computed(() => {
return true;
});
//
const getGwInfo = async () => {
try {
@ -392,8 +394,14 @@ const getGwInfo = async () => {
if (response.resultCode === 1) {
//
gwInfo.value = response.result.gwInfo;
const data = response.result.gwInfo;
gwInfo.value = data;
//
setGwData(data);
if (data.spResult != "A" && getXxts && getXxts.dbZt === "A") {
showButton.value = false;
GwPageUtils.updateXxts();
}
//
approvers.value = response.result.approvers || [];
ccUsers.value = response.result.ccUsers || [];
@ -480,132 +488,6 @@ const handleTransfer = () => {
navigateTo(`/pages/view/routine/gwlz/gwTransfer?id=${params.id}&title=${params.title}&xxtsInfo=${params.xxtsInfo}&gwInfo=${params.gwInfo}&approvers=${params.approvers}&ccUsers=${params.ccUsers}`);
};
//
const handleApprove = () => {
uni.showModal({
title: "同意公文",
content: "请您再次确认是否同意,公文审批内容",
success: async (res) => {
if (res.confirm) {
try {
// API
await approveGw();
} catch (error) {
console.error("同意失败:", error);
uni.showToast({
title: "同意失败",
icon: "error",
});
}
}
},
});
};
// API
const approveGw = async () => {
try {
//
uni.showLoading({
title: '正在处理...',
mask: true
});
// ID - jsData
const currentUserId = getJs?.id;
if (!currentUserId) {
throw new Error('无法获取当前用户信息');
}
// ID
const currentUserApproverId = getCurrentUserApproverId(currentUserId);
if (!currentUserApproverId) {
throw new Error('无法获取当前用户的审批人记录');
}
//
const approveData = {
xxtsId: gwId.value, // xxtsInfoID
gwId: gwInfo.value?.id || gwId.value,
spId: currentUserApproverId,
approveRemark: "同意", //
spRule: gwInfo.value?.spRule, // gwInfospRule
currentUserId: currentUserId
};
// API - 使API
const response = await gwApproveApi(approveData);
//
uni.hideLoading();
if (response.resultCode === 1) {
uni.showToast({
title: "同意成功",
icon: "success",
duration: 1500
});
//
setTimeout(() => {
//
uni.navigateBack({
delta: 1,
success: () => {
// 线
uni.$emit('refreshGwList');
}
});
}, 1500);
} else {
throw new Error(response.message || '同意失败');
}
} catch (error: any) {
//
uni.hideLoading();
uni.showToast({
title: error.message || "同意失败",
icon: "error",
});
}
};
//
const getCurrentUserApproverStatus = () => {
const userStore = useUserStore();
const getJs = userStore.getJs;
const currentUserId = getJs?.id;
if (!currentUserId || !approvers.value || approvers.value.length === 0) {
return '未知';
}
const currentUserApprover = approvers.value.find(approver => {
return approver.userId === currentUserId || approver.id === currentUserId;
});
return currentUserApprover?.approveStatus || '未知';
};
// ID
const getCurrentUserApproverId = (currentUserId: string) => {
if (!approvers.value || approvers.value.length === 0) {
return null;
}
//
const currentUserApprover = approvers.value.find(approver => {
const matchByUserId = approver.userId === currentUserId;
const matchById = approver.id === currentUserId;
return matchByUserId || matchById;
});
return currentUserApprover?.id || null;
};
// gwInfo
const previewSingleFile = (event?: Event) => {
//
@ -1264,70 +1146,14 @@ const getCreatorName = (tjrId: string) => {
}
};
onMounted(() => {
//
let pageId = "";
// 1: getCurrentPages()
const pages = getCurrentPages();
if (pages.length > 0) {
const currentPage = pages[pages.length - 1];
//
const options = (currentPage as any).options || {};
pageId = options.id || "";
}
// 2: 1URL
if (!pageId) {
try {
// URL
const currentUrl = window.location.href;
// uni-app H5hash
const hash = window.location.hash;
if (hash && hash.includes('?')) {
// hash
const queryString = hash.split('?')[1];
//
const urlParams = new URLSearchParams(queryString);
pageId = urlParams.get('id') || "";
} else {
// search
const urlParams = new URLSearchParams(window.location.search);
pageId = urlParams.get('id') || "";
}
} catch (error) {
// URL
}
}
// 3:
if (!pageId) {
try {
//
const currentPath = window.location.pathname;
//
const pathMatch = currentPath.match(/\/gwFlow\/([^/?]+)/);
if (pathMatch) {
pageId = pathMatch[1];
}
} catch (error) {
//
}
}
// gwId
gwId.value = pageId;
if (gwId.value) {
getGwInfo();
onLoad(async (data?: any) => {
const ret = await GwPageUtils.init(data);
if (!ret) {
return;
}
showButton.value = ret.dbFlag;
gwId.value = ret.gwId;
getGwInfo();
});
</script>

View File

@ -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,

View File

@ -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({});
},

88
src/utils/gwPageUtils.ts Normal file
View File

@ -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;
},
}

View File

@ -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;