style: useSysMessage 代码格式化

pull/960/head
ykcory 2023-12-28 05:47:38 +08:00
parent bc68bdc4be
commit 69c796708c
1 changed files with 69 additions and 73 deletions

View File

@ -1,11 +1,10 @@
import { ref, reactive } from 'vue'; import { ref, reactive } from 'vue';
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import { getDictItemsByCode } from '/@/utils/dict/index'; import { getDictItemsByCode } from '/@/utils/dict/index';
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from 'vue-router';
import { useAppStore } from '/@/store/modules/app'; import { useAppStore } from '/@/store/modules/app';
import { useTabs } from '/@/hooks/web/useTabs'; import { useTabs } from '/@/hooks/web/useTabs';
import { useModal } from '/@/components/Modal'; import { useMessage } from '/@/hooks/web/useMessage';
import {useMessage} from "/@/hooks/web/useMessage";
/** /**
* *
@ -27,31 +26,30 @@ export function useSysMessage() {
console.log('+++++++++++++++++++++'); console.log('+++++++++++++++++++++');
const messageList = ref<any[]>([]); const messageList = ref<any[]>([]);
const pageNo = ref(1) const pageNo = ref(1);
let pageSize = 10; const pageSize = 10;
const searchParams = reactive({ const searchParams = reactive({
fromUser: '', fromUser: '',
rangeDateKey: '', rangeDateKey: '',
rangeDate: [], rangeDate: [],
starFlag: '' starFlag: '',
}); });
function getQueryParams() { function getQueryParams() {
let { fromUser, rangeDateKey, rangeDate, starFlag } = searchParams; const { fromUser, rangeDateKey, rangeDate, starFlag } = searchParams;
let params = { const params = {
fromUser, fromUser,
starFlag, starFlag,
rangeDateKey, rangeDateKey,
beginDate: '', beginDate: '',
endDate: '', endDate: '',
pageNo: pageNo.value, pageNo: pageNo.value,
pageSize pageSize,
}; };
if (rangeDateKey == 'zdy') { if (rangeDateKey == 'zdy') {
params.beginDate = rangeDate[0]+' 00:00:00'; params.beginDate = rangeDate[0] + ' 00:00:00';
params.endDate = rangeDate[1]+' 23:59:59'; params.endDate = rangeDate[1] + ' 23:59:59';
} }
return params; return params;
} }
@ -61,53 +59,52 @@ export function useSysMessage() {
//请求数据 //请求数据
async function loadData() { async function loadData() {
if(loadEndStatus.value === true){ if (loadEndStatus.value === true) {
return; return;
} }
let params = getQueryParams(); const params = getQueryParams();
const data = await queryMessageList(params); const data = await queryMessageList(params);
console.log('获取结果', data); console.log('获取结果', data);
if(!data || data.length<=0){ if (!data || data.length <= 0) {
loadEndStatus.value = true; loadEndStatus.value = true;
return; return;
} }
if(data.length<pageSize){ if (data.length < pageSize) {
loadEndStatus.value = true; loadEndStatus.value = true;
} }
pageNo.value = pageNo.value+1 pageNo.value = pageNo.value + 1;
let temp:any[] = messageList.value; const temp: any[] = messageList.value;
temp.push(...data); temp.push(...data);
messageList.value = temp; messageList.value = temp;
} }
//重置 //重置
function reset(){ function reset() {
messageList.value = [] messageList.value = [];
pageNo.value = 1; pageNo.value = 1;
loadEndStatus.value = false; loadEndStatus.value = false;
} }
//标星 //标星
async function updateStarMessage(item){ async function updateStarMessage(item) {
const url = '/sys/sysAnnouncementSend/edit'; const url = '/sys/sysAnnouncementSend/edit';
let starFlag = '1'; let starFlag = '1';
if(item.starFlag==starFlag){ if (item.starFlag == starFlag) {
starFlag = '0' starFlag = '0';
} }
const params = { const params = {
starFlag, starFlag,
id: item.sendId id: item.sendId,
} };
//update-begin-author:taoyan date:2023-3-6 for: QQYUN-4491【应用】一些小问题 4、标星不需要提示吧 //update-begin-author:taoyan date:2023-3-6 for: QQYUN-4491【应用】一些小问题 4、标星不需要提示吧
const data:any = await defHttp.put({url, params}, {isTransformResponse: false}); const data: any = await defHttp.put({ url, params }, { isTransformResponse: false });
if(data.success === true){ if (data.success === true) {
}else{ } else {
createMessage.warning(data.message) createMessage.warning(data.message);
} }
//update-end-author:taoyan date:2023-3-6 for: QQYUN-4491【应用】一些小问题 4、标星不需要提示吧 //update-end-author:taoyan date:2023-3-6 for: QQYUN-4491【应用】一些小问题 4、标星不需要提示吧
} }
const loadingMoreStatus = ref(false); const loadingMoreStatus = ref(false);
async function onLoadMore() { async function onLoadMore() {
loadingMoreStatus.value = true; loadingMoreStatus.value = true;
@ -124,13 +121,13 @@ export function useSysMessage() {
// 消息类型 // 消息类型
function getMsgCategory(item) { function getMsgCategory(item) {
if(item.busType=='email'){ if (item.busType == 'email') {
return '邮件提醒:'; return '邮件提醒:';
} else if(item.busType=='bpm'){ } else if (item.busType == 'bpm') {
return '流程催办:'; return '流程催办:';
} else if(item.busType=='bpm_cc'){ } else if (item.busType == 'bpm_cc') {
return '流程抄送:'; return '流程抄送:';
}else if(item.busType=='bpm_task'){ } else if (item.busType == 'bpm_task') {
return '流程任务:'; return '流程任务:';
} else if (item.msgCategory == '2') { } else if (item.msgCategory == '2') {
return '系统消息:'; return '系统消息:';
@ -151,15 +148,14 @@ export function useSysMessage() {
onLoadMore, onLoadMore,
noRead, noRead,
getMsgCategory, getMsgCategory,
}; };
} }
/** /**
* *
*/ */
export function useMessageHref(emit, props){ export function useMessageHref(emit, props) {
const messageHrefArray:any[] = getDictItemsByCode('messageHref'); const messageHrefArray: any[] = getDictItemsByCode('messageHref');
const router = useRouter(); const router = useRouter();
const appStore = useAppStore(); const appStore = useAppStore();
const rt = useRoute(); const rt = useRoute();
@ -167,19 +163,19 @@ export function useMessageHref(emit, props){
// const defaultPath = '/monitor/mynews'; // const defaultPath = '/monitor/mynews';
//const bpmPath = '/task/handle/' //const bpmPath = '/task/handle/'
async function goPage(record, openModalFun?){ async function goPage(record, openModalFun?) {
if(!record.busType || record.busType == 'msg_node'){ if (!record.busType || record.busType == 'msg_node') {
if(!openModalFun){ if (!openModalFun) {
// 从首页的消息通知跳转 // 从首页的消息通知跳转
await goPageFromOuter(record); await goPageFromOuter(record);
}else{ } else {
// 从消息页面列表点击详情查看 直接打开modal // 从消息页面列表点击详情查看 直接打开modal
openModalFun() openModalFun();
} }
}else{ } else {
await goPageWithBusType(record) await goPageWithBusType(record);
} }
/* busId: "1562035005173587970" /* busId: "1562035005173587970"
busType: "email" busType: "email"
openPage: "modules/eoa/email/modals/EoaEmailInForm" openPage: "modules/eoa/email/modals/EoaEmailInForm"
openType: "component"*/ openType: "component"*/
@ -189,37 +185,37 @@ export function useMessageHref(emit, props){
* busType * busType
* @param record * @param record
*/ */
async function goPageWithBusType(record){ async function goPageWithBusType(record) {
const { busType, busId, msgAbstract } = record; const { busType, busId, msgAbstract } = record;
let temp = messageHrefArray.filter(item=>item.value === busType); const temp = messageHrefArray.filter((item) => item.value === busType);
if(!temp || temp.length==0){ if (!temp || temp.length == 0) {
console.error('当前业务类型不识别', busType); console.error('当前业务类型不识别', busType);
return; return;
} }
let path = temp[0].text; let path = temp[0].text;
path = path.replace('{DETAIL_ID}', busId) path = path.replace('{DETAIL_ID}', busId);
//固定参数 detailId 用于查询表单数据 //固定参数 detailId 用于查询表单数据
let query:any = { const query: any = {
detailId: busId detailId: busId,
}; };
// 额外参数处理 // 额外参数处理
if(msgAbstract){ if (msgAbstract) {
try { try {
let json = JSON.parse(msgAbstract); const json = JSON.parse(msgAbstract);
Object.keys(json).map(k=>{ Object.keys(json).map((k) => {
query[k] = json[k] query[k] = json[k];
}); });
}catch (e) { } catch (e) {
console.error('msgAbstract参数不是JSON格式', msgAbstract) console.error('msgAbstract参数不是JSON格式', msgAbstract);
} }
} }
// 跳转路由 // 跳转路由
appStore.setMessageHrefParams(query); appStore.setMessageHrefParams(query);
if(rt.path.indexOf(path)>=0){ if (rt.path.indexOf(path) >= 0) {
await closeTab(); await closeTab();
await router.replace({ path: path, query:{ time: new Date().getTime() } }); await router.replace({ path: path, query: { time: new Date().getTime() } });
}else{ } else {
closeSameRoute(path) closeSameRoute(path);
await router.push({ path: path }); await router.push({ path: path });
} }
} }
@ -228,12 +224,12 @@ export function useMessageHref(emit, props){
* modal * modal
* @param record * @param record
*/ */
async function goPageFromOuter(record){ async function goPageFromOuter(record) {
//没有定义业务类型 直接跳转我的消息页面 //没有定义业务类型 直接跳转我的消息页面
emit('detail', record) emit('detail', record);
} }
return { return {
goPage goPage,
} };
} }