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,27 +26,26 @@ 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';
@ -64,7 +62,7 @@ export function useSysMessage() {
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) {
@ -74,15 +72,15 @@ export function useSysMessage() {
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;
} }
@ -92,22 +90,21 @@ export function useSysMessage() {
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;
@ -151,7 +148,6 @@ export function useSysMessage() {
onLoadMore, onLoadMore,
noRead, noRead,
getMsgCategory, getMsgCategory,
}; };
} }
@ -174,10 +170,10 @@ export function useMessageHref(emit, props){
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"
@ -191,26 +187,26 @@ export function useMessageHref(emit, props){
*/ */
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);
} }
} }
// 跳转路由 // 跳转路由
@ -219,7 +215,7 @@ export function useMessageHref(emit, props){
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 });
} }
} }
@ -230,10 +226,10 @@ export function useMessageHref(emit, props){
*/ */
async function goPageFromOuter(record) { async function goPageFromOuter(record) {
//没有定义业务类型 直接跳转我的消息页面 //没有定义业务类型 直接跳转我的消息页面
emit('detail', record) emit('detail', record);
} }
return { return {
goPage goPage,
} };
} }