v3.8.2 系统通知改造支持分类

This commit is contained in:
JEECG
2025-07-30 18:28:10 +08:00
parent 219869f4c0
commit 0cfa1e223a
3 changed files with 634 additions and 88 deletions

View File

@ -1,4 +1,4 @@
import { ref, reactive } from 'vue';
import { ref, reactive, nextTick } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { getDictItemsByCode } from '/@/utils/dict/index';
import { useRouter, useRoute } from 'vue-router'
@ -18,8 +18,10 @@ const queryMessageList = (params) => {
/**
* 获取消息列表数据
*
* setLocaleText 设置未读消息
*/
export function useSysMessage() {
export function useSysMessage(setLocaleText) {
const { createMessage } = useMessage();
const rangeDateArray = getDictItemsByCode('rangeDate');
console.log('+++++++++++++++++++++');
@ -29,17 +31,18 @@ export function useSysMessage() {
const messageList = ref<any[]>([]);
const pageNo = ref(1)
let pageSize = 10;
const searchParams = reactive({
fromUser: '',
rangeDateKey: '',
rangeDate: [],
starFlag: ''
starFlag: '',
noticeType: ''
});
function getQueryParams() {
let { fromUser, rangeDateKey, rangeDate, starFlag } = searchParams;
let { fromUser, rangeDateKey, rangeDate, starFlag, noticeType } = searchParams;
let params = {
fromUser,
starFlag,
@ -47,7 +50,8 @@ export function useSysMessage() {
beginDate: '',
endDate: '',
pageNo: pageNo.value,
pageSize
pageSize,
noticeType
};
if (rangeDateKey == 'zdy') {
params.beginDate = rangeDate[0]+' 00:00:00';
@ -58,7 +62,7 @@ export function useSysMessage() {
// 数据是否加载完了
const loadEndStatus = ref(false);
//请求数据
async function loadData() {
if(loadEndStatus.value === true){
@ -69,6 +73,7 @@ export function useSysMessage() {
console.log('获取结果', data);
if(!data || data.length<=0){
loadEndStatus.value = true;
setLocaleText();
return;
}
if(data.length<pageSize){
@ -78,6 +83,7 @@ export function useSysMessage() {
let temp:any[] = messageList.value;
temp.push(...data);
messageList.value = temp;
setLocaleText();
}
//重置
@ -86,7 +92,7 @@ export function useSysMessage() {
pageNo.value = 1;
loadEndStatus.value = false;
}
//标星
async function updateStarMessage(item){
const url = '/sys/sysAnnouncementSend/edit';
@ -139,7 +145,27 @@ export function useSysMessage() {
}
return '';
}
// QQYUN-4472 来消息了没有提醒--查看详情改为去处理
function getHrefText(item) {
if(item.busType === 'bpm'|| item.busType === 'bpm_task' || item.busType === 'tenant_invite'){
//判断是否是查看详情
if (item.msgAbstract) {
try {
const json = JSON.parse(item.msgAbstract);
if (json.taskDetail) {
return '查看详情';
}
} catch (e) {
console.error('getHrefText:msgAbstract参数不是JSON格式', item.msgAbstract);
}
}
return '去处理'
}else{
return '查看详情'
}
}
return {
messageList,
reset,
@ -147,11 +173,11 @@ export function useSysMessage() {
loadEndStatus,
searchParams,
updateStarMessage,
onLoadMore,
noRead,
getMsgCategory,
getHrefText
};
}
@ -159,14 +185,115 @@ export function useSysMessage() {
* 用于消息跳转
*/
export function useMessageHref(emit, props){
//const [registerHistoryModal, { openModal: openHistoryModal }] = useModal();
//const [registerTaskModal, { openModal: openTaskModal }] = useModal();
// 注册表单弹窗
//const [registerDesignFormModal, { openModal: openDesignFormModal }] = useModal();
const messageHrefArray: any[] = getDictItemsByCode('messageHref');
const router = useRouter();
const appStore = useAppStore();
const rt = useRoute();
const { close: closeTab, closeSameRoute } = useTabs();
// const defaultPath = '/monitor/mynews';
//*********************************[QQYUN-6713]系统通知打开弹窗修改动态设置弹窗begin******************************************
//当前表单弹窗
const currentModal = ref<string | null>(null);
//当前表单参数
const modalParams = ref<Recordable>({});
//表单注册缓存
const modalRegCache = ref<Recordable>({});
//组件绑定参数
const bindParams = ref<Recordable>({});
/**
* 根据类型打开不同弹窗
* @param type
* @param params
*/
async function handleOpenType(type, params) {
currentModal.value = null;
modalParams.value = { ...params };
switch (type) {
case 'task':
//流程办理
bindParams.value = { actionType: 'todo' };
currentModal.value = 'ProcessTaskHandleModal';
break;
case 'history':
bindParams.value = {};
//历史流程
currentModal.value = 'MyTaskHandleModal';
break;
case 'design':
//表单设计
currentModal.value = 'DesformViewModal';
bindParams.value = {
showRecordCopy: false,
showRecordShare: false,
showRecordSysPrint: false,
showDesignFormBtn: false,
};
break;
case 'cgform':
//Online表单
currentModal.value = 'OnlineAutoModal';
bindParams.value = {
id: params.formId,
}
break;
default:
currentModal.value = null;
break;
}
//注册表单弹窗
initModalRegister();
await nextTick(() => {
if (modalRegCache.value[currentModal.value!]?.isRegister) {
console.log('已注冊,走缓存');
modalRegCache.value[currentModal.value!].modalMethods.openModal(true, modalParams.value);
}
});
}
/**
* 初始化弹窗注册
*/
function initModalRegister() {
//如果当前选择表单为null就不处理
if (!currentModal.value) {
return;
}
//判断缓存中是否存在,不存在就走缓存逻辑
if (!modalRegCache.value[currentModal.value]) {
const [registerModal, modalMethods] = useModal();
modalRegCache.value[currentModal.value] = {
isRegister: false,
register: bindRegisterModal(registerModal, modalMethods),
modalMethods,
};
}
}
/**
* 绑定注册弹窗
* @param regFn
* @param modalMethod
*/
function bindRegisterModal(regFn, modalMethod) {
return async (...args) => {
console.log('开始注册:', currentModal.value);
await regFn(...args);
console.log('注册完成:', currentModal.value);
//打开弹窗
modalMethod.openModal(true, modalParams.value);
//设置缓存标识
modalRegCache.value[currentModal.value!].isRegister = true;
};
}
//*************************************[QQYUN-6713]系统通知打开弹窗修改动态设置弹窗end*********************************************
// const defaultPath = '/monitor/mynews';
//const bpmPath = '/task/handle/'
async function goPage(record, openModalFun?){
if(!record.busType || record.busType == 'msg_node'){
if(!openModalFun){
@ -176,8 +303,38 @@ export function useMessageHref(emit, props){
// 从消息页面列表点击详情查看 直接打开modal
openModalFun()
}
// update-begin-author:taoyan date:2023-5-10 for: QQYUN-4744【系统通知】6、系统通知@人后,对方看不到是哪个表单@的,没有超链接
}else if(record.busType == 'comment'){
// de
let msgAbstract = record.msgAbstract;
if(msgAbstract){
try {
let data = JSON.parse(msgAbstract.toString());
if(data.type == 'designForm'){
showDesignFormModal(data);
} else {
showOnlineCgformModal(data);
}
}catch (e) {
console.error('打开评论表单但是msgAbstract参数不是JSON格式', msgAbstract)
if(openModalFun){
openModalFun();
}
}
}
// update-end-author:taoyan date:2023-5-10 for: QQYUN-4744【系统通知】6、系统通知@人后,对方看不到是哪个表单@的,没有超链接
}else if(record.busType == 'tenant_invite'){
if(props.isLowApp===true){
router.push({ name:"myapps-settings-user", query:{ page:'tenantSetting' }})
}else{
router.push({ name:"system-usersetting", query:{ page:'tenantSetting' }})
}
}else{
await goPageWithBusType(record)
if(props && props.isLowApp===true){
openLowAppFlowModal(record)
}else{
await goPageWithBusType(record)
}
}
/* busId: "1562035005173587970"
busType: "email"
@ -185,6 +342,95 @@ export function useMessageHref(emit, props){
openType: "component"*/
}
/**
* 打开表单设计器 表单弹窗
* @param data
*/
function showDesignFormModal(data) {
handleOpenType('design', {
mode: 'detail',
desformCode: data.code,
dataId: data.dataId,
isOnline: false,
});
}
/**
* 打开Online表单 弹窗
* @param data
*/
function showOnlineCgformModal(data) {
handleOpenType('cgform', {
formId: data.formId,
isUpdate: true,
disableSubmit: true,
record: {
id: data.dataId,
},
});
}
/**
* 判断是不是表单的评论消息
* @param record
*/
function isFormComment(record) {
if(record.busType == 'comment'){
let msgAbstract = record.msgAbstract;
if(msgAbstract){
try {
let data = JSON.parse(msgAbstract);
if(['cgform', 'designForm'].includes(data.type)){
return true
}
}catch (e) {
console.error('打开评论表单但是msgAbstract参数不是JSON格式', msgAbstract)
}
}
}
return false
}
/**
* 如果是工作流任务 在lowApp中 直接打开modal
*/
function openLowAppFlowModal(record){
const { busType, busId, msgAbstract } = record;
let temp = messageHrefArray.filter(item=>item.value === busType);
if(!temp || temp.length==0){
console.error('当前业务类型不识别', busType);
return;
}
if(busType.indexOf('bpm')<0){
console.error('low-app不支持跳转邮箱', busType);
return;
}
//固定参数 detailId 用于查询表单数据
let query:any = {
detailId: busId
};
// 额外参数处理
if(msgAbstract){
try {
let json = JSON.parse(msgAbstract);
Object.keys(json).map(k=>{
query[k] = json[k]
});
}catch (e) {
console.error('msgAbstract参数不是JSON格式', msgAbstract)
}
}
console.log("busType = ", busType)
handleOpenType('task', {
record: {
id: busId,
procInsId: query.procInsId,
processDefinitionId: query.processDefinitionId,
isDetail: query.taskDetail || 'bpm_cc' == busType
}
})
}
/**
* 根据busType不同跳转不同页面
* @param record
@ -213,14 +459,19 @@ export function useMessageHref(emit, props){
console.error('msgAbstract参数不是JSON格式', msgAbstract)
}
}
// 跳转路由
appStore.setMessageHrefParams(query);
if(rt.path.indexOf(path)>=0){
await closeTab();
await router.replace({ path: path, query:{ time: new Date().getTime() } });
if(query.taskDetail){
// 查看任务详情的弹窗
await showHistory(query.procInsId)
}else{
closeSameRoute(path)
await router.push({ path: path });
// 跳转路由
appStore.setMessageHrefParams(query);
if(rt.path.indexOf(path)>=0){
await closeTab();
await router.replace({ path: path, query:{ time: new Date().getTime() } });
}else{
closeSameRoute(path)
await router.push({ path: path });
}
}
}
@ -232,8 +483,84 @@ export function useMessageHref(emit, props){
//没有定义业务类型 直接跳转我的消息页面
emit('detail', record)
}
//===============================================================================================================
//update-begin-author:taoyan date:2022-12-31 for: QQYUN-3485 【查看流程】做一个查看页面,非办理页面,只通过流程实例参数即可
async function showHistory(processInstanceId) {
let { formData, formUrl } = await getTaskInfoForHistory({ processInstanceId });
formData['PROCESS_TAB_TYPE'] = 'history';
handleOpenType('history', {
formData,
formUrl,
title: '流程历史',
});
}
const nodeInfoUrl = '/act/process/extActProcessNode/getHisProcessNodeInfo'
const taskNodeInfo = (params) => defHttp.get({ url: nodeInfoUrl, params });
async function getTaskInfoForHistory(record) {
//查询条件
let params = { procInstId: record.processInstanceId };
const result = await taskNodeInfo(params);
console.log('获取历史任务信息', result);
let formData: any = {
dataId: result.dataId,
taskId: record.id,
taskDefKey: record.taskId,
procInsId: record.processInstanceId,
tableName: result.tableName,
vars: result.records,
};
let tempFormUrl = result.formUrl;
console.log('获取流程节点表单URL', tempFormUrl);
//节点配置表单URLVUE组件类型对应的拓展参数
if (tempFormUrl && tempFormUrl.indexOf('?') != -1 && !isURL(tempFormUrl) && tempFormUrl.indexOf('{{DOMAIN_URL}}') == -1) {
tempFormUrl = result.formUrl.split('?')[0];
console.log('获取流程节点表单URL去掉参数', tempFormUrl);
formData.extendUrlParams = getQueryVariable(result.formUrl);
}
return {
formData,
formUrl: tempFormUrl,
};
}
/**
* 获取URL上参数
* @param url
*/
function getQueryVariable(url) {
if (!url) return;
let t,
n,
r,
i = url.split('?')[1],
s = {};
(t = i.split('&')), (r = null), (n = null);
for (let o in t) {
let u = t[o].indexOf('=');
u !== -1 && ((r = t[o].substr(0, u)), (n = t[o].substr(u + 1)), (s[r] = n));
}
return s;
}
/**
* URL地址
* @param {*} s
*/
function isURL(s) {
return /^http[s]?:\/\/.*/.test(s);
}
//update-end-author:taoyan date:2022-12-31 for: QQYUN-3485 【查看流程】做一个查看页面,非办理页面,只通过流程实例参数即可
//===============================================================================================================
return {
goPage
goPage,
isFormComment,
modalRegCache,
currentModal,
bindParams,
}
}