调整完善公文审批的流程
This commit is contained in:
parent
cae5247b52
commit
2d2eb83583
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
})
|
||||
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, // 这里应该是xxtsInfo的ID,需要根据实际数据结构调整
|
||||
gwId: gwInfo.value?.id || gwId.value,
|
||||
spId: currentUserApproverId,
|
||||
approveRemark: "同意", // 默认审批意见
|
||||
spRule: gwInfo.value?.spRule, // 从gwInfo中获取spRule字段
|
||||
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 || "";
|
||||
onLoad(async (data?: any) => {
|
||||
const ret = await GwPageUtils.init(data);
|
||||
if (!ret) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 方式2: 如果方式1没有获取到,尝试从URL解析
|
||||
if (!pageId) {
|
||||
try {
|
||||
// 获取当前页面URL
|
||||
const currentUrl = window.location.href;
|
||||
|
||||
// 在uni-app H5环境中,参数通常在hash部分
|
||||
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) {
|
||||
showButton.value = ret.dbFlag;
|
||||
gwId.value = ret.gwId;
|
||||
getGwInfo();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
88
src/utils/gwPageUtils.ts
Normal 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;
|
||||
},
|
||||
}
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user